/* ═══════════════════════════════════════════════════════════════════
   DARK MODE — additive only. Every rule is scoped to
   html[data-theme="dark"], so light mode renders exactly as before.
   Palette matches the Milo iOS app (iOS dark): pure-black canvas,
   #1C1C1E / #2C2C2E elevated surfaces, navy event tints.
   ═══════════════════════════════════════════════════════════════════ */

/* ───────── 1. Foundation: redefine the design tokens ───────── */
html[data-theme="dark"] {
  --bg: #000000;
  --bg-soft: #0A0A0A;
  --card: #1C1C1E;
  --ink: #F5F5F7;
  --ink-dim: #C7C7CC;
  --muted: #98989D;
  --faint: #636366;
  --line: rgba(255, 255, 255, 0.10);

  --milo: #3D87FF;
  --milo-soft: rgba(61, 135, 255, 0.16);
  --milo-2: #1E3A5F;
  --milo-dark: #5E9EFF;

  --orange: #FF9F0A;
  --red: #FF453A;
  --green: #30D158;
  --yellow: #FFD60A;
  --pink: #FF375F;
  --purple: #BF5AF2;

  --glass-bg: rgba(28, 28, 30, 0.55);
  --glass-bg-strong: rgba(22, 22, 24, 0.80);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.40),
    0 1px 0 rgba(0, 0, 0, 0.30),
    0 10px 30px -12px rgba(0, 0, 0, 0.60),
    0 30px 60px -30px rgba(0, 0, 0, 0.70);

  /* convenience tokens used only by the dark overrides below */
  --d-surface: #1C1C1E;
  --d-surface-2: #2C2C2E;
  --d-surface-3: #3A3A3C;
}

html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--ink);
}

/* ───────── 2. Mobile burger + dropdown tints (dark-on-light → light-on-dark) ───────── */
html[data-theme="dark"] nav.topbar .nav-burger { background: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] nav.topbar .nav-burger:hover { background: rgba(255, 255, 255, 0.14); }
html[data-theme="dark"] .nav-theme-toggle { background: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .nav-theme-toggle:hover { background: rgba(255, 255, 255, 0.14); }
html[data-theme="dark"] .nav-menu a:hover,
html[data-theme="dark"] .nav-menu a:active { background: rgba(255, 255, 255, 0.08); }

/* ───────── 3. Phone shell + screens ───────── */
html[data-theme="dark"] .iphone {
  background: #2C2C2E;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.10),
    0 50px 100px -24px rgba(0, 0, 0, 0.65),
    0 16px 40px -10px rgba(0, 0, 0, 0.50);
}
html[data-theme="dark"] .iphone .screen,
html[data-theme="dark"] .chat-screen,
html[data-theme="dark"] .cal-screen,
html[data-theme="dark"] .rem-screen,
html[data-theme="dark"] .notes-screen,
html[data-theme="dark"] .pers-screen { background: #000000; }
html[data-theme="dark"] .iphone .home-bar { background: rgba(255, 255, 255, 0.35); }

/* App bar / tab bar / status */
html[data-theme="dark"] .app-bar .icn { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .app-tabbar {
  background: #1C1C1E;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 10px 30px -8px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .app-tabbar .tab { color: #8E8E93; }

/* ───────── 4. Chat phone ───────── */
html[data-theme="dark"] .msg.milo .chat-bubble { background: #2C2C2E; color: var(--ink); }
html[data-theme="dark"] .chat-bubble.card-cal,
html[data-theme="dark"] .chat-bubble.card-rem {
  background: #1C1C1E;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .chat-bubble.card-note {
  background: #2A2410;
  border-color: rgba(255, 214, 10, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .chat-composer .c-btn,
html[data-theme="dark"] .chat-composer .send { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .chat-composer .c-input { background: rgba(255, 255, 255, 0.08); color: #8E8E93; }

/* ───────── 5. Calendar phone ───────── */
html[data-theme="dark"] .cal-week { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .cal-week .d { color: #8E8E93; }
html[data-theme="dark"] .cal-week .d.selected .num { background: #F5F5F7; color: #000; }
html[data-theme="dark"] .cal-allday { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .cal-allday .rem-row,
html[data-theme="dark"] .cal-reminder { background: rgba(61, 135, 255, 0.16); }
html[data-theme="dark"] .cal-hours .hr { border-bottom-color: rgba(255, 255, 255, 0.06); }
html[data-theme="dark"] .cal-hours .hr .label { color: #8E8E93; }
html[data-theme="dark"] .cal-reminder.empty .circle { border-color: #636366; }
html[data-theme="dark"] .cal-event { background: rgba(61, 135, 255, 0.16); }

/* ───────── 6. Reminders / Notes / Personality phones ───────── */
html[data-theme="dark"] .rem-sort .chip { border-color: rgba(255, 255, 255, 0.14); }
html[data-theme="dark"] .note-card { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .pers-bar .icn { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .pers-textarea-wrap { background: #1C1C1E; }
html[data-theme="dark"] .w-calendar .w-row { background: rgba(255, 255, 255, 0.08); }

/* Home-screen widgets: white iOS widgets → dark translucent (text already light) */
html[data-theme="dark"] .home-grid .widget {
  background: rgba(28, 28, 30, 0.88);
  box-shadow:
    0 10px 24px -10px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
html[data-theme="dark"] .milo-icon-tile .mit-img {
  background: #2C2C2E;
  box-shadow:
    0 8px 16px -6px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* ───────── 7. Feature cards (milo-features.css) ───────── */
/* White inner surfaces → elevated dark */
html[data-theme="dark"] .fc-card.calendar-card .cal-mockup {
  background: #1C1C1E;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .fc-card.reminders-card .rem,
html[data-theme="dark"] .fc-card.notes-card .note,
html[data-theme="dark"] .fc-card.personality-card .chip,
html[data-theme="dark"] .fc-card.personality-card .preview,
html[data-theme="dark"] .fc-card.web-card .search-bar,
html[data-theme="dark"] .fc-card.web-card .knowledge,
html[data-theme="dark"] .fc-card.web-card .link,
html[data-theme="dark"] .fc-card.lists-card .lists-cat,
html[data-theme="dark"] .fc-card.ai-card .bubble.milo,
html[data-theme="dark"] .fc-card.sync-card .orb { background: #2C2C2E; color: var(--ink); }

/* Calendar card tints + separators */
html[data-theme="dark"] .fc-card.calendar-card .week { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .fc-card.calendar-card .ev.red { background: rgba(255, 69, 58, 0.18); }
html[data-theme="dark"] .fc-card.calendar-card .ev.orange { background: rgba(255, 159, 10, 0.18); }

/* Notes card */
html[data-theme="dark"] .fc-card.notes-card .note.back { background: #242426; }
html[data-theme="dark"] .fc-card.notes-card .line { background: #3A3A3C; }
html[data-theme="dark"] .fc-card.notes-card .check.empty { background: #2C2C2E; border-color: #636366; }
html[data-theme="dark"] .fc-card.notes-card .code-block { background: #0E0E0E; }
html[data-theme="dark"] .fc-card.notes-card .note-attachments { border-top-color: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .fc-card.notes-card .note-sketch { background: #1C1C1E; border-color: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .fc-card.notes-card .note-postit { background: #2C2C2E; border-color: rgba(255, 255, 255, 0.12); }

/* Gradient-background cards → dark gradients */
html[data-theme="dark"] .fc-card.sync-card { background: linear-gradient(160deg, #161616 0%, #1F1B12 100%); }
html[data-theme="dark"] .fc-card.sync-card .orbit-ring { border-color: rgba(255, 255, 255, 0.16); }
html[data-theme="dark"] .fc-card.sync-card .orbit-ring.outer { border-color: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .fc-card.ai-card { background: linear-gradient(160deg, #11203B 0%, #0B1322 100%); }
html[data-theme="dark"] .fc-card.personality-card { background: linear-gradient(160deg, #1C1C1E 0%, #2A1420 100%); }
html[data-theme="dark"] .fc-card.lists-card { background: linear-gradient(160deg, #1C1C1E 0%, #2A2114 100%); }
html[data-theme="dark"] .fc-card.memory-card { background: linear-gradient(160deg, #1C1C1E 0%, #11203B 100%); }
html[data-theme="dark"] .fc-card.pomodoro-card { background: linear-gradient(160deg, #1C1C1E 0%, #12281A 100%); }
html[data-theme="dark"] .fc-card.privacy-card { background: linear-gradient(160deg, #11203B 0%, #0B1322 100%); }
html[data-theme="dark"] .fc-card.privacy-card .p-pill { background: #2C2C2E; color: var(--ink); }

/* Lists card tag chips */
html[data-theme="dark"] .fc-card.lists-card .tag-chip { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .fc-card.lists-card .tag-chip.red { background: rgba(255, 69, 58, 0.20); color: #FF8078; }
html[data-theme="dark"] .fc-card.lists-card .tag-chip.orange { background: rgba(255, 159, 10, 0.20); color: #FFB84D; }
html[data-theme="dark"] .fc-card.lists-card .tag-chip.purple { background: rgba(191, 90, 242, 0.22); color: #D89BF5; }
html[data-theme="dark"] .fc-card.lists-card .tag-chip.pink { background: rgba(255, 55, 95, 0.20); color: #FF7DA0; }

/* Memory graph nodes */
html[data-theme="dark"] .fc-card.memory-card .graph-node,
html[data-theme="dark"] .fc-card.memory-card .graph-node.sat,
html[data-theme="dark"] .fc-card.memory-card .graph-node.theme { fill: #1C1C1E; }
html[data-theme="dark"] .fc-card.memory-card .graph-node.core-inner { fill: #F5F5F7; }

/* ───────── 8. Roadmap section (milo-app.css) ───────── */
html[data-theme="dark"] .rm-card:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px -16px rgba(0, 0, 0, 0.6),
    0 40px 80px -40px rgba(0, 0, 0, 0.7);
}
html[data-theme="dark"] .rm-vote { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .rm-vote:hover { background: rgba(61, 135, 255, 0.14); border-color: var(--milo); }
html[data-theme="dark"] .rm-tag { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .rm-card .foot { border-top-color: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .roadmap-chip .count { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .replay-btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .replay-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* Status pills: light-tint + dark-text → dark-tint + light-text */
html[data-theme="dark"] .rm-status[data-s="planned"] { background: rgba(255, 255, 255, 0.10); color: var(--ink-dim); }
html[data-theme="dark"] .rm-status[data-s="progress"] { background: rgba(255, 159, 10, 0.22); color: #FFB84D; }
html[data-theme="dark"] .rm-status[data-s="shipped"] { background: rgba(48, 209, 88, 0.22); color: #5BE584; }
html[data-theme="dark"] .rm-status[data-s="review"] { background: rgba(191, 90, 242, 0.22); color: #D89BF5; }
html[data-theme="dark"] .rm-source[data-src="user"] { background: rgba(48, 209, 88, 0.22); color: #5BE584; }
html[data-theme="dark"] .rm-source[data-src="admin"] { background: rgba(61, 135, 255, 0.18); color: var(--milo); }

/* Submit-idea card */
html[data-theme="dark"] .rm-submit {
  background: #1C1C1E;
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 30px -16px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .rm-submit .field { background: #2C2C2E; border-color: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .rm-submit .rm-idea-form input,
html[data-theme="dark"] .rm-submit .rm-idea-form textarea { border-bottom-color: rgba(255, 255, 255, 0.12); }

/* Pricing "Best value" badge: yellow background keeps black text in dark mode */
html[data-theme="dark"] .price-card-best { color: #000; }

/* ───────── 9. The theme toggle button (sun/moon swap) ───────── */
html[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ico-sun { display: block; }

/* Goals phone */
html[data-theme="dark"] .goals-screen { background: #000; }
html[data-theme="dark"] .goal-card { background: #1C1C1E; }
html[data-theme="dark"] .goal-ring-track { stroke: #2C2C2E; }
html[data-theme="dark"] .goals-action-btn { background: rgba(255, 255, 255, 0.10); }

/* Goals detail view: reminders card */
html[data-theme="dark"] .reminders-card { background: #1C1C1E; }
html[data-theme="dark"] .reminder-item { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .reminder-check { border-color: #4E4E52; }
html[data-theme="dark"] .reminder-check--done { background: #6E6E73; border-color: #6E6E73; }

/* Keep goals detail-view app-bar icons bare in dark mode too */
html[data-theme="dark"] .goals-screen .app-bar .icn { background: transparent; }

/* Goals feature card */
html[data-theme="dark"] .fc-card.goals-card .goals-card-list { background: #2C2C2E; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
html[data-theme="dark"] .fc-card.goals-card .goals-card-ring-track { stroke: #3A3A3C; }
html[data-theme="dark"] .fc-card.goals-card .goals-card-item { border-bottom-color: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .fc-card.goals-card .goals-card-check { border-color: #4E4E52; }
html[data-theme="dark"] .fc-card.goals-card .goals-card-item--done .goals-card-check { background: #6E6E73; border-color: #6E6E73; }
