/* =========================================================
 *  JQSTUNNER — app.css (cinematic refresh)
 *  ========================================================= */

/* =========================
 *  0) Theme tokens
 *
 *  Default = Fortnite (electric blue / purple / gold). Other
 *  themes activate via [data-theme="<name>"] on <html>.
 *  Themes: fortnite (default), night, cyberpunk, light, cyan,
 *  gtav, soft.
 *  ========================= */
:root,
[data-theme="fortnite"] {
  --bg: #04060c;
  --bg-2: #0a0e1a;
  --panel: #0f1320;
  --panel-2: #131828;
  --text: #ecf0f8;
  --muted: #8a93a7;
  --subtle: #4a5060;
  --accent: #4c51f7;
  --accent-2: #9d4dbb;
  --accent-3: #f3af19;
  --accent-rgb: 76, 81, 247;
  --accent-2-rgb: 157, 77, 187;
  --accent-3-rgb: 243, 175, 25;
  --success: #319236;
  --success-rgb: 49, 146, 54;
  --danger: #ff6b6b;
  --chip: rgba(76, 81, 247, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --ring: rgba(76, 81, 247, 0.30);
}

[data-theme="night"] {
  --bg: #0a0d12;
  --bg-2: #11151c;
  --panel: #161b25;
  --panel-2: #1c2230;
  --text: #d8dde8;
  --muted: #828ea0;
  --subtle: #4a5060;
  --accent: #3b82f6;
  --accent-2: #64748b;
  --accent-3: #94a3b8;
  --accent-rgb: 59, 130, 246;
  --accent-2-rgb: 100, 116, 139;
  --accent-3-rgb: 148, 163, 184;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --danger: #ef4444;
  --chip: rgba(59, 130, 246, 0.08);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.50);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.40);
  --ring: rgba(59, 130, 246, 0.25);
}

[data-theme="cyberpunk"] {
  --bg: #050309;
  --bg-2: #0d0518;
  --panel: #15082a;
  --panel-2: #1d0d3a;
  --text: #ffe66d;
  --muted: #b896d8;
  --subtle: #6b4a8e;
  --accent: #fde047;
  --accent-2: #ec4899;
  --accent-3: #06b6d4;
  --accent-rgb: 253, 224, 71;
  --accent-2-rgb: 236, 72, 153;
  --accent-3-rgb: 6, 182, 212;
  --success: #22d3ee;
  --success-rgb: 34, 211, 238;
  --danger: #ef4444;
  --chip: rgba(253, 224, 71, 0.10);
  --border: rgba(253, 224, 71, 0.14);
  --border-strong: rgba(253, 224, 71, 0.28);
  --shadow: 0 14px 36px rgba(236, 72, 153, 0.20);
  --shadow-sm: 0 6px 18px rgba(253, 224, 71, 0.18);
  --ring: rgba(253, 224, 71, 0.35);
}

[data-theme="light"] {
  --bg: #f2f6fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --text: #0b1220;
  --muted: #475569;
  --subtle: #94a3b8;
  --accent: #06b6d4;
  --accent-2: #7c3aed;
  --accent-3: #ec4899;
  --accent-rgb: 6, 182, 212;
  --accent-2-rgb: 124, 58, 237;
  --accent-3-rgb: 236, 72, 153;
  --success: #16a34a;
  --success-rgb: 22, 163, 74;
  --danger: #dc2626;
  --chip: #e7f3ff;
  --border: #d6dee8;
  --border-strong: #a3b1c2;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.10);
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
  --ring: rgba(6, 182, 212, 0.35);
}

[data-theme="cyan"] {
  --bg: #04060c;
  --bg-2: #0a0e1a;
  --panel: #0f1320;
  --panel-2: #131828;
  --text: #ecf0f8;
  --muted: #8a93a7;
  --subtle: #4a5060;
  --accent: #6ee7ff;
  --accent-2: #b48cff;
  --accent-3: #ff6ec7;
  --accent-rgb: 110, 231, 255;
  --accent-2-rgb: 180, 140, 255;
  --accent-3-rgb: 255, 110, 199;
  --success: #4ade80;
  --success-rgb: 74, 222, 128;
  --danger: #ff6b6b;
  --chip: rgba(110, 231, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --ring: rgba(110, 231, 255, 0.25);
}

[data-theme="gtav"] {
  --bg: #0a0a0a;
  --bg-2: #131313;
  --panel: #181818;
  --panel-2: #1f1f1f;
  --text: #f5e7c8;
  --muted: #b8a98a;
  --subtle: #5a4f3e;
  --accent: #ff8c00;
  --accent-2: #ffeb3b;
  --accent-3: #ff007f;
  --accent-rgb: 255, 140, 0;
  --accent-2-rgb: 255, 235, 59;
  --accent-3-rgb: 255, 0, 127;
  --success: #76b947;
  --success-rgb: 118, 185, 71;
  --danger: #d22b2b;
  --chip: rgba(255, 140, 0, 0.10);
  --border: rgba(255, 235, 59, 0.10);
  --border-strong: rgba(255, 235, 59, 0.22);
  --shadow: 0 14px 36px rgba(255, 140, 0, 0.18);
  --shadow-sm: 0 6px 18px rgba(255, 140, 0, 0.14);
  --ring: rgba(255, 140, 0, 0.35);
}

[data-theme="soft"] {
  --bg: #fff5f7;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #fff0f3;
  --text: #2c1f25;
  --muted: #7a6470;
  --subtle: #c0a8b0;
  --accent: #e85a8a;
  --accent-2: #ff9472;
  --accent-3: #c084fc;
  --accent-rgb: 232, 90, 138;
  --accent-2-rgb: 255, 148, 114;
  --accent-3-rgb: 192, 132, 252;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --danger: #dc2626;
  --chip: #ffe4ec;
  --border: #f3d6df;
  --border-strong: #e8b8c5;
  --shadow: 0 14px 36px rgba(232, 90, 138, 0.12);
  --shadow-sm: 0 6px 18px rgba(232, 90, 138, 0.08);
  --ring: rgba(232, 90, 138, 0.30);
}

/* Splash — mirrors the public landing visual: Fortnite accents,
 * heavier ring/glow, plus a scanline overlay over the body. */
[data-theme="splash"] {
  --bg: #04060c;
  --bg-2: #0a0e1a;
  --panel: #0f1320;
  --panel-2: #131828;
  --text: #ecf0f8;
  --muted: #8a93a7;
  --subtle: #4a5060;
  --accent: #4c51f7;
  --accent-2: #9d4dbb;
  --accent-3: #f3af19;
  --accent-rgb: 76, 81, 247;
  --accent-2-rgb: 157, 77, 187;
  --accent-3-rgb: 243, 175, 25;
  --success: #319236;
  --success-rgb: 49, 146, 54;
  --danger: #ff6b6b;
  --chip: rgba(76, 81, 247, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 48px rgba(76, 81, 247, 0.18);
  --shadow-sm: 0 8px 22px rgba(76, 81, 247, 0.14);
  --ring: rgba(76, 81, 247, 0.40);
}

/* Scanline overlay only on the splash theme */
[data-theme="splash"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.008) 0 1px, transparent 1px 5px);
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 0;
}

/* =========================
 *  1) Global defaults
 *  ========================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 18% 0%, rgba(var(--accent-rgb), 0.10), transparent 60%),
    radial-gradient(1200px 600px at 85% 10%, rgba(var(--accent-2-rgb), 0.08), transparent 55%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

.messages { background: var(--bg-2); }
[data-theme="light"] .messages,
[data-theme="soft"] .messages { background: var(--panel-2); }

/* Cosmetic-image backdrop. Most Fortnite cosmetic PNGs from the wiki use
   transparent backgrounds with bright/white iconography designed for the
   in-game dark UI. On dark themes we just defer to --panel-2 (already dark);
   on the two light themes we hardcode a Fortnite-style dark gradient so the
   art doesn't disappear into a white-on-white silhouette. */
:root { --cosmetic-bg: var(--panel-2); }
[data-theme="light"],
[data-theme="soft"] {
  --cosmetic-bg:
    radial-gradient(ellipse at 30% 20%, rgba(80,90,140,0.30), transparent 60%),
    linear-gradient(135deg, #1a1f3a 0%, #0d1023 100%);
}

/* Soft theme's --muted (#7a6470) on its warm-pink bg passes WCAG AA but
   reads as too faded for headers/back-links/sub-titles on the cosmetic
   pages. Scope a darker plum inside those pages so muted-styled text
   pops without changing the rest of the site. */
[data-theme="soft"] .shop-history-page,
[data-theme="soft"] .fn-item-page {
  --muted: #4a3640;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================
 *  2) App shell + top nav
 *  ========================= */
.app-shell { min-height: 100vh; }

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(15, 19, 32, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  /* Lift the nav (and the theme dropdown inside it) above page content
   * stacking contexts. Without this, .chat-main / .messages overlap
   * the dropdown because they paint later in DOM order. */
  position: sticky;
  top: 0;
  z-index: 100;
}

[data-theme="light"] .top-nav {
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-avatar { width: 32px; height: 32px; border-radius: 50%; }
.brand-mark {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.45);
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 14px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
}
.nav-links a {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 140ms ease;
}
.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}
.nav-links .tiny { font-size: 12px; color: var(--subtle); }

.content { padding: 20px; max-width: 1280px; margin: 0 auto; }

/* Flash messages */
.flash {
  background: rgba(var(--accent-rgb), 0.08);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.20);
  color: var(--text);
  padding: 10px 24px;
  font-size: 13px;
}

/* Theme picker (details > summary + dropdown menu) */
.theme-picker {
  position: relative;
  list-style: none;
}
.theme-picker > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.theme-picker > summary::-webkit-details-marker { display: none; }
.theme-picker[open] > summary {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.06);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 6px 14px 6px 10px;
  transition: border-color 140ms ease, background 140ms ease;
}
.theme-toggle:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.06);
}

.theme-toggle-label { font-weight: 600; }

/* The current-theme swatch on the toggle */
.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* The current-theme swatch reflects the active theme */
.theme-swatch--current {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.40);
}

/* Per-theme swatch previews in the dropdown */
.tsw-fortnite  { background: linear-gradient(135deg, #4c51f7, #f3af19); }
.tsw-splash    { background: linear-gradient(135deg, #4c51f7, #9d4dbb 60%, #f3af19); }
.tsw-night     { background: linear-gradient(135deg, #3b82f6, #64748b); }
.tsw-cyberpunk { background: linear-gradient(135deg, #fde047, #ec4899); }
.tsw-light     { background: linear-gradient(135deg, #06b6d4, #7c3aed); }
.tsw-cyan      { background: linear-gradient(135deg, #6ee7ff, #ff6ec7); }
.tsw-gtav      { background: linear-gradient(135deg, #ff8c00, #ff007f); }
.tsw-soft      { background: linear-gradient(135deg, #e85a8a, #c084fc); }

.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  z-index: 200;
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.theme-menu button:hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.22);
}

@media (max-width: 600px) {
  .theme-toggle-label { display: none; }
  .theme-toggle { padding: 6px 10px; }
}

/* =========================
 *  3) Chat layout (sidebar + main)
 *  ========================= */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.chat-layout .full-width { grid-column: 1 / -1; }

/* =========================
 *  4) Sidebar
 *  ========================= */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  height: calc(100vh - 140px);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.wallet-line { font-size: 14px; color: var(--muted); }

.section { margin-top: 16px; }

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--subtle);
  font-weight: 700;
  margin-bottom: 8px;
}

.folder-block { margin-bottom: 10px; }
.folder-title { font-weight: 600; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

.chat-list { list-style: none; padding: 0; margin: 0; }

.chat-item {
  padding: 10px;
  border-radius: 12px;
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.chat-item:hover {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.04);
}

.chat-item.active {
  background: rgba(var(--accent-rgb), 0.10);
  border-color: rgba(var(--accent-rgb), 0.50);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.06);
}

.chat-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chat-link {
  display: block;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.chat-link:hover { text-decoration: none; }

.chat-title {
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.chat-sub {
  margin-top: 2px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--muted);
}

.chat-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.chat-actions select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
  font-size: 12px;
}

/* =========================
 *  4a) Stat chips
 *  ========================= */
.stat-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-left-width: 3px;
  border-left-style: solid;
}

.stat-chip--budget { border-left-color: var(--accent); }
.stat-chip--gears  { border-left-color: var(--accent-2); }
.stat-chip--streak { border-left-color: #f59e0b; }

.stat-chip__icon { font-size: 15px; flex-shrink: 0; }
.stat-chip__label {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
.stat-chip__value {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* =========================
 *  4b) Slim sidebar toggle
 *  ========================= */
.sidebar-toggle--slim {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  align-self: flex-start;
}

.sidebar-toggle--slim:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.40);
}

.sidebar-collapsed .sidebar-toggle--slim::before { content: "›"; }
.sidebar-toggle--slim::before { content: "‹"; }
.sidebar-toggle--slim { font-size: 0; }
.sidebar-toggle--slim::before { font-size: 16px; }

/* =========================
 *  4c) Coach select
 *  ========================= */
.coach-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  font-size: 13px;
}

.coach-select-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  white-space: nowrap;
}

.coach-select-current {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.coach-select-change {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.coach-select-change:hover {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.06);
  text-decoration: none;
}

/* =========================
 *  5) Kebab menu (details/summary)
 *  ========================= */
.chat-menu { position: relative; flex: 0 0 auto; }
.chat-menu summary { list-style: none; }
.chat-menu summary::-webkit-details-marker { display: none; }

.chat-menu-btn,
.chat-menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  user-select: none;
  color: var(--text);
  transition: border-color 140ms ease, background 140ms ease;
}

.chat-menu-btn:hover,
.chat-menu > summary:hover {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.06);
}

.chat-menu[open] > summary {
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.10);
}

.chat-menu-panel {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
  min-width: 220px;
  box-shadow: var(--shadow);
}

.menu-label { font-size: 12px; color: var(--muted); }

.menu-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  min-height: 40px;
  font-weight: 600;
  transition: border-color 140ms ease, background 140ms ease;
}
.menu-item:hover {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.05);
}

.menu-item.danger {
  border-color: rgba(255, 107, 107, 0.30);
  background: rgba(255, 107, 107, 0.08);
}

.chat-menu-panel select {
  width: 100%;
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
}

/* =========================
 *  6) Chat main panel
 *  ========================= */
.chat-main {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  min-height: 70vh;
  box-shadow: var(--shadow-sm);
}

.chat-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  position: relative;
}

.chat-header-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
}

.robot-head { font-size: 28px; }
.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

/* =========================
 *  7) Message bubbles
 *  ========================= */
.bubble {
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

.bubble.user {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.30);
  border-left: 3px solid var(--accent);
}

.bubble.assistant {
  background: rgba(var(--accent-2-rgb), 0.06);
  border-color: rgba(var(--accent-2-rgb), 0.24);
  border-left: 3px solid var(--accent-2);
}

.bubble-role {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.18em;
  font-weight: 700;
  opacity: 0.85;
}

.bubble-content { white-space: pre-wrap; line-height: 1.5; }

/* =========================
 *  8) Composer
 *  ========================= */
.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 10px;
}

textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  resize: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 4px var(--ring);
}

textarea::placeholder { color: var(--subtle); }

/* =========================
 *  9) Buttons / chips / cards
 *  ========================= */
.btn-primary, .btn-ghost, .btn-warn, .chip {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn-primary {
  background: var(--accent);
  color: #04060c;
  box-shadow: 0 12px 28px -10px rgba(var(--accent-rgb), 0.55);
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:disabled, .btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn-ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.05);
}

.btn-warn {
  background: var(--danger);
  color: #1a0606;
}
.btn-warn:hover { opacity: 0.92; }

.chip {
  background: var(--chip);
  color: var(--text);
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.full { width: 100%; text-align: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 10px;
}

/* =========================
 *  10) Utility UI bits
 *  ========================= */
.plain-list { list-style: none; padding: 0; margin: 0; }

.row-actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; flex-wrap: wrap; }

.thinking-indicator {
  display: none;
  margin: 10px 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.is-thinking .thinking-indicator { display: block; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.badge.low    { background: rgba(74, 222, 128, 0.10); color: #a7f3d0; border: 1px solid rgba(74, 222, 128, 0.25); }
.badge.medium { background: rgba(250, 204, 21, 0.10); color: #fde68a; border: 1px solid rgba(250, 204, 21, 0.25); }
.badge.high   { background: rgba(239, 68, 68, 0.10);  color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.25); }

.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; }

.danger-zone { margin: 10px 0; }

.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }

/* Headings */
h1, h2, h3 { letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }

/* Form inputs (text/number/date/etc) */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px var(--ring);
}

/* =========================
 *  11) Sidebar toggle + mobile drawer
 *  ========================= */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  color: var(--text);
}

.sidebar-overlay { display: none; }

.sidebar-collapsed .chat-layout { grid-template-columns: 72px 1fr; }

.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 10px;
  overflow: hidden;
}

.sidebar-toggle--in-sidebar {
  width: 100%;
  justify-content: center;
}

.sidebar-collapsed .sidebar .wallet-line,
.sidebar-collapsed .sidebar .stat-chips,
.sidebar-collapsed .sidebar .btn-primary.full,
.sidebar-collapsed .sidebar .section-title,
.sidebar-collapsed .sidebar .folder-block,
.sidebar-collapsed .sidebar .chat-list,
.sidebar-collapsed .sidebar .muted.small {
  display: none;
}

.sidebar-collapsed .sidebar .section { margin-top: 8px; }

.sidebar-collapsed .sidebar {
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-2-rgb), 0.05)),
    var(--panel);
}

/* =========================
 *  12) Responsive
 *  ========================= */
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; }
  .chat-main { height: auto; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 280px;
    height: 100vh;
    z-index: 30;
    transition: left 0.2s ease;
    overflow: auto;
    border-radius: 0;
  }

  .sidebar-open .sidebar { left: 0; }

  .sidebar-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    background: rgba(0, 0, 0, 0.50);
    backdrop-filter: blur(2px);
  }

  .sidebar-open .sidebar-overlay { display: block; }

  .chat-menu-panel { min-width: 200px; }
}

/* =========================
 *  13) Markdown / code helpers
 *  ========================= */
.bubble-content pre {
  background: #050810;
  color: #e8eaf0;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
}

.bubble-content code {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
  border: 1px solid rgba(var(--accent-rgb), 0.18);
}

.bubble-content ul,
.bubble-content ol { padding-left: 20px; }

.bubble-content.md-assistant { white-space: normal; line-height: 1.5; }

.bubble-content.md-assistant p { margin: 0 0 0.65em 0; }
.bubble-content.md-assistant p:last-child { margin-bottom: 0; }

.bubble-content.md-assistant ul,
.bubble-content.md-assistant ol {
  margin: 0.35em 0 0.75em 1.25em;
  padding-left: 1.1em;
}
.bubble-content.md-assistant li { margin: 0.25em 0; }
.bubble-content.md-assistant li > p { margin: 0; }

.bubble-content.md-assistant pre {
  margin: 0.6em 0;
  max-height: 420px;
  overflow: auto;
}

.bubble-content.md-assistant blockquote {
  margin: 0.6em 0;
  padding-left: 12px;
  border-left: 3px solid rgba(var(--accent-rgb), 0.40);
  color: var(--muted);
}

.bubble-content pre code,
.bubble-content.md-assistant pre code {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  color: inherit !important;
}

/* Code-copy button */
.bubble-content pre {
  position: relative;
  padding-top: 38px;
}

.codecopy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ecf0f8;
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 140ms ease;
  z-index: 5;
}
.codecopy-btn:hover { background: rgba(255, 255, 255, 0.12); }
.codecopy-btn:active { transform: translateY(1px); }

/* Boot splash */
.boot-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 1.5rem;
  text-align: center;
}

/* TOS page */
.tos-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem;
}

/* =========================================================
 *  Parent panel
 *  Shared layout primitives for /parent, /parent/child/<id>/...
 *  All values come from theme tokens so every theme inherits.
 *  ========================================================= */
.parent-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
}

.crumbs {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  margin-bottom: 6px;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { opacity: 0.5; margin: 0 6px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.page-head .lede { color: var(--muted); font-size: 13px; margin: 6px 0 0; max-width: 60ch; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* KPI tiles ------------------------------------------------ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.kpi__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
}
.kpi__value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.kpi__sub { font-size: 12px; color: var(--muted); }
.kpi--accent { border-left: 3px solid var(--accent); }
.kpi--good   { border-left: 3px solid var(--success); }
.kpi--warn   { border-left: 3px solid var(--danger); }

/* Generic panel card --------------------------------------- */
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.panel-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-card__title { font-size: 14px; font-weight: 700; letter-spacing: -0.005em; }
.panel-card__sub { font-size: 12px; color: var(--muted); }

/* Children grid (parent dashboard) ------------------------- */
.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.child-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 140ms ease, transform 140ms ease;
}
.child-card:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
  transform: translateY(-1px);
}
.child-card__head { display: flex; align-items: center; gap: 10px; }
.child-card__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.14);
  border: 1px solid rgba(var(--accent-rgb), 0.30);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.child-card__name { font-weight: 700; line-height: 1.2; }
.child-card__sub { font-size: 12px; color: var(--muted); }
.child-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Tighter button modifier --------------------------------- */
.btn-sm { padding: 7px 12px; font-size: 12px; }

/* Field grid (policy / wallet adjust forms) ---------------- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
}
.field-help { font-size: 12px; color: var(--muted); }
.field select,
.field input[type="text"],
.field input[type="number"] { width: 100%; }

/* Conversation list (parent_conversations) ----------------- */
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.conv-item:hover {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.04);
  transform: translateY(-1px);
}
.conv-item__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
}
.conv-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.conv-item__title {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
.conv-item__sub { font-size: 12px; color: var(--muted); }
.conv-item__meta { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.conv-item__chevron { color: var(--subtle); font-size: 16px; line-height: 1; }

/* Two-pane layout for parent_conversation ------------------ */
.parent-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 920px) {
  .parent-grid { grid-template-columns: 1fr; }
}
.aside-stack { display: flex; flex-direction: column; gap: 12px; }
.aside-empty { color: var(--muted); font-size: 13px; font-style: italic; }

/* Month nav (parent_spending) ----------------------------- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.month-nav__center { display: flex; align-items: center; gap: 14px; }
.month-nav__title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.month-nav__totals {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}
.month-nav .nav-pill {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 12px;
  background: var(--panel-2);
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.month-nav .nav-pill:hover {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.40);
  background: rgba(var(--accent-rgb), 0.04);
}

/* Ledger table (parent_spending) -------------------------- */
.ledger {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.ledger thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border);
}
.ledger tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger tbody tr:hover td { background: rgba(var(--accent-rgb), 0.04); }
.ledger .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.ledger .num.credit { color: var(--success); }
.ledger .num.debit  { color: var(--danger); }
.ledger .when {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.ledger .reason { font-weight: 600; letter-spacing: 0.01em; }
.ledger .conv-ref { font-size: 12px; color: var(--muted); }
.ledger-wrap { overflow-x: auto; }

/* Lock banner --------------------------------------------- */
.lock-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(var(--success-rgb), 0.06);
  border: 1px solid rgba(var(--success-rgb), 0.25);
  border-radius: 12px;
  font-size: 13px;
}
.lock-banner.is-locked {
  background: rgba(255, 107, 107, 0.06);
  border-color: rgba(255, 107, 107, 0.30);
}
.lock-banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(var(--success-rgb), 0.55);
}
.lock-banner.is-locked .lock-banner__dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.55);
}
.lock-banner__msg { flex: 1; }

/* Stack helper -------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Transcript (parent review view) -------------------------
 * Flat per-message turns instead of boxed bubbles — easier
 * to skim a long thread. Role is signaled by a thin left
 * rule + a colored sender name, not by a wrapping card.
 * --------------------------------------------------------- */
.transcript { display: flex; flex-direction: column; gap: 10px; }

.transcript__turn {
  padding: 1px 4px 1px 12px;
  border-left: 2px solid var(--border);
  line-height: 1.55;
  font-size: 14px;
  border-radius: 0 6px 6px 0;
}
.transcript__turn.user      { border-left-color: var(--accent); }
.transcript__turn.assistant { border-left-color: var(--accent-2); }
.transcript__turn.system    { border-left-color: var(--subtle); opacity: 0.85; }

.transcript__name {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.005em;
  margin-right: 4px;
}
.transcript__turn.user      .transcript__name { color: var(--accent); }
.transcript__turn.assistant .transcript__name { color: var(--accent-2); }
.transcript__turn.system    .transcript__name { color: var(--muted); }

.transcript__time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-right: 8px;
}

.transcript__body {
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.transcript__body em.muted { font-style: italic; }

/* Multi-line bodies break to their own line under the header so the
 * first chunk of a long message doesn't sit awkwardly next to the
 * sender + timestamp. Single-line messages still stay inline. */
.transcript__turn--block .transcript__body {
  display: block;
  margin-top: 2px;
}

.transcript__turn:hover { background: rgba(var(--accent-rgb), 0.04); }
