/* ═══════════════════════════════════════════════════════
   Private Notes PWA — Design System
   Target: Symphony Q100 (2.8"–3.5" QVGA, touch + D-pad)
   ═══════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────── */
:root {
  /* Colors — Dark OLED-Friendly Palette */
  --bg-primary: #060612;
  --bg-secondary: #0f0f23;
  --bg-surface: #1a1a2e;
  --bg-surface-hover: #242444;
  --bg-elevated: #252545;

  /* Accent Colors */
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --accent-alt: #7c3aed;
  --accent-alt-glow: rgba(124, 58, 237, 0.2);
  --cyan: #00d4ff;
  --cyan-glow: rgba(0, 212, 255, 0.3);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.25);
  --yellow: #f59e0b;
  --red-danger: #ef4444;

  /* Text */
  --text-primary: #eaeaf0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --text-inverse: #060612;

  /* Focus — High contrast cyan ring for D-pad */
  --focus-ring: 3px solid var(--cyan);
  --focus-glow: 0 0 0 5px var(--cyan-glow);

  /* Spacing — Compact for small screens */
  --sp-xs: 2px;
  --sp-sm: 4px;
  --sp-md: 8px;
  --sp-lg: 12px;
  --sp-xl: 16px;
  --sp-2xl: 24px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 50%;

  /* Fonts */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
}

/* ─── Reset & Base ───────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Focus States — CRITICAL for D-pad ──────────────── */
*:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-glow);
}

*:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

*:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-glow);
}

/* Force focus visible for keyboard/D-pad users */
body.using-keyboard *:focus {
  outline: var(--focus-ring) !important;
  outline-offset: 2px !important;
  box-shadow: var(--focus-glow) !important;
}

/* ─── Screen Management ──────────────────────────────── */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: screenFadeIn var(--duration) var(--ease);
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════
   LOCK SCREEN
   ═══════════════════════════════════════════════════════ */
#screen-lock {
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
}

.lock-container {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-lg);
}

.lock-icon {
  color: var(--accent);
  animation: lockPulse 2s ease-in-out infinite;
}

@keyframes lockPulse {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px var(--accent-glow)); }
  50%      { opacity: 0.7; filter: drop-shadow(0 0 12px var(--accent-glow)); }
}

.lock-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lock-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.2em;
}

.lock-subtitle.error {
  color: var(--red-danger);
  animation: headShake 0.5s ease-in-out;
}

.lock-subtitle.locked {
  color: var(--yellow);
}

@keyframes headShake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(6px); }
  45%  { transform: translateX(-4px); }
  60%  { transform: translateX(3px); }
  75%  { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

/* PIN Dots */
.pin-dots {
  display: flex;
  gap: var(--sp-md);
  padding: var(--sp-md) 0;
}

.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--r-full);
  border: 2px solid var(--text-muted);
  background: transparent;
  transition: all var(--duration) var(--ease);
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  transform: scale(1.15);
}

.pin-dot.error {
  border-color: var(--red-danger);
  background: var(--red-danger);
  animation: headShake 0.5s ease-in-out;
}

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
  width: 100%;
  max-width: 240px;
}

.numpad-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 52px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.numpad-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.12) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.numpad-btn:active::after,
.numpad-btn.pressed::after {
  opacity: 1;
}

.numpad-btn:active,
.numpad-btn.pressed {
  transform: scale(0.94);
  background: var(--bg-surface-hover);
}

.numpad-sub {
  font-size: 0.5rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.1em;
  margin-top: -2px;
}

.numpad-action {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.numpad-enter {
  background: linear-gradient(135deg, var(--accent), #c23152);
  color: #fff;
  border-color: transparent;
}

/* Lock animation on unlock */
.lock-container.unlocking .lock-icon {
  animation: unlockBounce 0.6s ease forwards;
}

@keyframes unlockBounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.2) rotate(-10deg); }
  60%  { transform: scale(0.9) rotate(5deg); }
  100% { transform: scale(0) rotate(0deg); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════
   NOTES LIST SCREEN
   ═══════════════════════════════════════════════════════ */

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 44px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  letter-spacing: -0.01em;
}

.header-icon {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* Icon Buttons */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-family: var(--font);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.accent-btn {
  background: linear-gradient(135deg, var(--accent), #c23152);
  border-color: transparent;
  color: #fff;
}

.icon-btn.danger-btn {
  color: var(--red-danger);
}

.icon-btn.danger-btn:hover,
.icon-btn.danger-btn:focus-visible {
  background: rgba(239, 68, 68, 0.15);
}

/* Sync Indicator */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.sync-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
}

.sync-dot.offline {
  background: var(--red-danger);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
  animation: offlinePulse 1.5s ease-in-out infinite;
}

.sync-dot.syncing {
  background: var(--yellow);
  animation: syncPulse 0.8s ease-in-out infinite;
}

@keyframes offlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

/* Search Bar */
.search-bar {
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-secondary);
  display: flex;
  gap: var(--sp-sm);
  animation: slideDown var(--duration) var(--ease);
}

.search-bar.hidden {
  display: none;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 60px; }
}

.search-input {
  flex: 1;
  height: 36px;
  padding: 0 var(--sp-md);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--cyan);
}

.search-clear {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font);
}

/* Category Bar */
.category-bar {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.cat-chip {
  flex-shrink: 0;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  scroll-snap-align: start;
  white-space: nowrap;
}

.cat-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.cat-chip:active {
  transform: scale(0.94);
}

/* Notes Container */
.notes-container {
  flex: 1;
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-2xl);
}

/* Note Card */
.note-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--r-md);
  padding: var(--sp-md) var(--sp-lg);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
  min-height: 44px;
}

.note-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--note-color, var(--accent));
  border-radius: 3px 0 0 3px;
}

.note-card:active {
  transform: scale(0.98);
  background: var(--bg-surface-hover);
}

.note-card.pinned {
  border-color: rgba(233, 69, 96, 0.2);
  background: linear-gradient(135deg, var(--bg-surface), rgba(233, 69, 96, 0.05));
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-xs);
}

.note-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.note-card-pin {
  font-size: 0.65rem;
  opacity: 0.6;
}

.note-card-preview {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-sm);
  gap: var(--sp-sm);
}

.note-card-footer-left {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

/* Database Sync Indicator Badge */
.db-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
  transition: all var(--duration) var(--ease);
  line-height: 1.3;
}

.db-indicator.synced {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.db-indicator.pending {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.db-indicator .db-icon {
  flex-shrink: 0;
}

.note-card-time {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.note-card-cat {
  font-size: 0.6rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  padding: var(--sp-2xl);
  color: var(--text-muted);
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 0.78rem;
  line-height: 1.5;
}

.empty-sub kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-elevated);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  font-size: 0.72rem;
  font-family: var(--font);
}

/* ═══════════════════════════════════════════════════════
   NOTE PREVIEW SCREEN (READ-ONLY)
   ═══════════════════════════════════════════════════════ */

.preview-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-scroll-container {
  flex: 1;
  padding: var(--sp-md) var(--sp-lg);
  padding-bottom: 74px; /* Space for bottom action bar */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.preview-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--r-md);
  padding: var(--sp-lg) var(--sp-xl);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.preview-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--note-color, var(--accent));
  border-radius: 4px 0 0 4px;
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-sm);
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.preview-meta-left {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.preview-cat-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

.preview-cat-badge.cat-work {
  color: var(--cyan);
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.25);
}

.preview-cat-badge.cat-ideas {
  color: var(--accent);
  background: rgba(233, 69, 96, 0.12);
  border: 1px solid rgba(233, 69, 96, 0.25);
}

.preview-cat-badge.cat-personal {
  color: var(--green);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.preview-cat-badge.cat-general {
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.preview-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.preview-pin {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}

.preview-pin.hidden {
  display: none;
}

.preview-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--sp-xs) 0 var(--sp-md) 0;
  line-height: 1.35;
  word-break: break-word;
}

.preview-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  margin-bottom: var(--sp-md);
}

.preview-content-body {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.preview-content-body p {
  margin-bottom: var(--sp-sm);
}

.preview-content-body ul,
.preview-content-body ol {
  padding-left: 1.3em;
  margin: var(--sp-sm) 0;
}

.preview-content-body li {
  margin-bottom: var(--sp-xs);
}

.preview-content-body b,
.preview-content-body strong {
  font-weight: 700;
  color: #fff;
}

.preview-content-body i,
.preview-content-body em {
  font-style: italic;
  color: var(--text-secondary);
}

.preview-content-body u {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.preview-empty-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
}

/* Bottom Floating Action Bar */
.preview-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.preview-action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.preview-action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.preview-action-btn:active {
  transform: scale(0.96);
}

.preview-action-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.preview-action-btn.primary:hover {
  background: #d63352;
}

.preview-action-btn.danger {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.2);
}

.preview-action-btn.danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* ═══════════════════════════════════════════════════════
   NOTE EDITOR SCREEN
   ═══════════════════════════════════════════════════════ */

.editor-header {
  background: var(--bg-secondary);
}

/* Save Status */
.save-status {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
}

.save-status.saving {
  color: var(--yellow);
}

.save-status.saved {
  color: var(--green);
}

.save-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--green);
}

.save-dot.local {
  background: var(--yellow);
}

.save-status.saving .save-dot {
  background: var(--yellow);
  animation: syncPulse 0.6s ease-in-out infinite;
}

/* Title Input */
.note-title-input {
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: -0.01em;
}

.note-title-input::placeholder {
  color: var(--text-muted);
}

.note-title-input:focus {
  outline: none;
  border-bottom-color: var(--cyan);
  box-shadow: 0 2px 0 0 var(--cyan-glow);
}

/* Editor Meta Row */
.editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: var(--sp-md);
}

.meta-select {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: var(--font);
  cursor: pointer;
  min-height: 30px;
}

.meta-select:focus {
  border-color: var(--cyan);
}

/* Color Picker */
.color-picker {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.color-dot.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 6px rgba(255,255,255,0.2);
}

.color-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: var(--r-full);
  background: inherit;
}

/* Format Toolbar */
.format-toolbar {
  display: flex;
  gap: var(--sp-xs);
  padding: var(--sp-sm) var(--sp-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: var(--bg-secondary);
  overflow-x: auto;
}

.fmt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  padding: 0 var(--sp-md);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}

.fmt-btn:active,
.fmt-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

/* Content Editor */
.note-content-editor {
  flex: 1;
  padding: var(--sp-lg);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 200px;
  word-break: break-word;
}

.note-content-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.note-content-editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--cyan-glow);
}

.note-content-editor ul,
.note-content-editor ol {
  padding-left: 1.2em;
  margin: var(--sp-sm) 0;
}

.note-content-editor li {
  margin-bottom: var(--sp-xs);
}

.note-content-editor b, .note-content-editor strong {
  font-weight: 700;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-xl);
  animation: modalFadeIn var(--duration) var(--ease);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-lg);
  padding: var(--sp-xl);
  width: 100%;
  max-width: 280px;
  animation: modalSlideUp var(--duration) var(--ease);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--sp-md);
}

.modal-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--sp-xl);
}

.modal-actions {
  display: flex;
  gap: var(--sp-md);
}

.modal-btn {
  flex: 1;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.modal-btn-cancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.modal-btn-danger {
  background: var(--red-danger);
  border-color: transparent;
  color: #fff;
}

.modal-btn:active {
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: var(--sp-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 280px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-md);
  padding: var(--sp-md) var(--sp-lg);
  font-size: 0.78rem;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.toast.toast-success {
  border-left: 3px solid var(--green);
}

.toast.toast-error {
  border-left: 3px solid var(--red-danger);
}

.toast.toast-info {
  border-left: 3px solid var(--cyan);
}

.toast.toast-out {
  animation: toastOut 0.3s var(--ease) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Feature Phone Optimizations
   ═══════════════════════════════════════════════════════ */

/* QVGA (240x320) */
@media (max-width: 280px) {
  html { font-size: 12px; }

  .numpad { max-width: 200px; gap: var(--sp-sm); }
  .numpad-btn { height: 44px; font-size: 1.1rem; }

  .lock-title { font-size: 1.15rem; }
  .pin-dots { gap: var(--sp-sm); }
  .pin-dot { width: 10px; height: 10px; }

  .app-header { padding: var(--sp-sm) var(--sp-md); }
  .notes-container { padding: var(--sp-sm) var(--sp-md); }
  .note-card { padding: var(--sp-sm) var(--sp-md); }

  .color-dot { width: 18px; height: 18px; }
  .fmt-btn { min-width: 30px; height: 28px; font-size: 0.75rem; }
}

/* Small Feature Phone (320x480) */
@media (min-width: 281px) and (max-width: 400px) {
  html { font-size: 13px; }
  .numpad { max-width: 220px; }
  .numpad-btn { height: 48px; }
}

/* Larger screens */
@media (min-width: 401px) {
  .lock-container { max-width: 320px; }
  .numpad { max-width: 260px; }

  .notes-container {
    max-width: 480px;
    margin: 0 auto;
  }

  #screen-editor,
  #screen-preview {
    max-width: 480px;
    margin: 0 auto;
  }

  .preview-bottom-bar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Landscape mode */
@media (max-height: 400px) and (orientation: landscape) {
  .lock-container { flex-direction: row; flex-wrap: wrap; gap: var(--sp-md); }
  .lock-icon { display: none; }
  .numpad { max-width: 200px; }
  .numpad-btn { height: 40px; }
  .pin-dots { padding: var(--sp-sm) 0; }
}

/* ═══════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════ */

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

/* Selection */
::selection {
  background: var(--accent);
  color: #fff;
}
