@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

:root {
  --navy:   224, 62%, 15%;
  --gold:    44, 55%, 54%;
  --cream:   40, 44%, 97%;
  --canvas:  40, 27%, 94%;

  --background:     hsl(40, 27%, 94%);
  --foreground:     hsl(224, 62%, 15%);
  --card-bg:        hsl(40, 44%, 97%);
  --card-border:    hsl(40, 20%, 85%);
  --border:         hsl(40, 20%, 85%);
  --input-bg:       hsl(40, 44%, 97%);
  --ring:           hsl(44, 55%, 54%);
  --primary:        hsl(224, 62%, 15%);
  --primary-fg:     hsl(40, 44%, 97%);
  --accent:         hsl(44, 55%, 54%);
  --accent-fg:      hsl(224, 62%, 15%);
  --muted-bg:       hsl(40, 20%, 90%);
  --muted-fg:       hsl(224, 40%, 40%);
  --destructive:    hsl(0, 84%, 60%);
  --success:        #16a34a;
  --success-bg:     rgba(34,197,94,0.1);
  --success-border: rgba(34,197,94,0.25);

  --font-sans:  'Space Grotesk', sans-serif;
  --font-serif: 'DM Serif Display', serif;
  --font-mono:  Menlo, monospace;

  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  12px;
  --radius-2xl: 16px;

  --shadow-sm:  0 1px 3px rgba(15,28,63,0.08);
  --shadow-md:  0 4px 12px rgba(15,28,63,0.12);
  --shadow-lg:  0 8px 24px rgba(15,28,63,0.16);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100dvh;
  /* native feel: kill iOS text auto-zoom + the grey tap flash */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* keep body from bouncing/pulling-to-refresh, but DON'T set this on scroll-wrap —
     doing so on both kills momentum/inertia scroll on many Android browsers */
  overscroll-behavior: none;
}

/* every interactive element: no tap flash, no 300ms delay, no accidental text-select on hold */
button, a, .nav-link, .bottom-nav-item, .drawer-item, .chip, .tab-btn,
.ck-stat, .ck-cta, .ck-rail-item, .ck-icon-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

h1,h2,h3,h4 { font-family: var(--font-serif); line-height: 1.15; color: var(--primary); }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
p, li { font-size: 0.9375rem; line-height: 1.65; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── SPLASH SCREEN ── */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: hsl(224, 62%, 15%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem;
  transition: opacity 0.45s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }
#splash.hidden { display: none; }
.splash-logo {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  color: hsl(40, 44%, 97%);
  letter-spacing: -0.02em;
  animation: splashSlideUp 0.6s ease 0.1s both;
}
.splash-logo span {
  color: hsl(44, 55%, 54%);
}
.splash-sub {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  animation: splashSlideUp 0.6s ease 0.35s both;
}
.splash-line {
  width: 48px; height: 2px;
  background: hsl(44, 55%, 54%);
  border-radius: 999px;
  animation: splashExpand 0.5s ease 0.6s both;
}
.splash-dots {
  display: flex; gap: 6px;
  margin-top: 0.5rem;
  animation: splashSlideUp 0.6s ease 0.8s both;
}
.splash-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.3);
  animation: splashDot 1.4s ease 1.2s infinite;
}
.splash-dots span:nth-child(2) { animation-delay: 1.4s; }
.splash-dots span:nth-child(3) { animation-delay: 1.6s; }

@keyframes splashSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes splashExpand {
  from { opacity: 0; width: 0; }
  to   { opacity: 1; width: 48px; }
}
@keyframes splashDot {
  0%,60%,100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.4); }
}
@keyframes splashFade {
  to { opacity: 0; pointer-events: none; }
}

/* ── LAYOUT ── */
.app-shell { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.5rem 1rem;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar-brand { font-family: var(--font-serif); font-size: 1.5rem; color: var(--primary); }
.sidebar-sub   { font-size: 0.75rem; color: var(--muted-fg); margin-bottom: 1.5rem; }

.nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 500;
  color: var(--muted-fg); text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 0.2rem; cursor: pointer; border: none;
  background: transparent; width: 100%; text-align: left;
}
.nav-link:hover  { background: var(--muted-bg); color: var(--foreground); text-decoration: none; }
.nav-link.active { background: var(--primary); color: var(--primary-fg); }
.nav-link svg    { width: 16px; height: 16px; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 0.75rem 0; }

.main-content {
  flex: 1; overflow-y: auto; padding: 2rem;
  max-width: 960px; margin: 0 auto; width: 100%;
}

/* the real scroll region — momentum on iOS, no rubber-band reload bleeding to the WebView */
#scroll-wrap {
  overflow-y: auto;                   /* canonical rule (inline attr kept for safety) */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
  /* tell the browser this layer scrolls vertically — no hit-test ambiguity with
     the horizontal swipe handler, no 300-350ms delay waiting to see if the touch
     might be a horizontal swipe */
  touch-action: pan-y pinch-zoom;
  /* promote to its own compositor layer so scroll never blocks the main thread */
  will-change: scroll-position;
}

/* Mobile header */
.mobile-header {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

/* Bottom nav */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg); border-top: 1px solid var(--border);
  grid-template-columns: repeat(5, 1fr);
  z-index: 100;
  /* clear the iOS home indicator / Android gesture bar */
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.bottom-nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0.5rem 0; gap: 0.2rem;
  font-size: 0.625rem; font-weight: 500;
  color: var(--muted-fg); text-decoration: none;
  transition: color 0.12s; cursor: pointer;
  border: none; background: transparent;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 20px; height: 20px; }

/* More drawer */
.drawer-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg); border-top: 1px solid var(--border);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: 201; padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.25s ease;
}
.drawer.open { transform: translateY(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.drawer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.drawer-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
  padding: 0.75rem; border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  color: var(--muted-fg); text-decoration: none;
  font-size: 0.75rem; font-weight: 500;
  text-align: center; transition: all 0.15s;
  cursor: pointer; background: transparent;
}
.drawer-item:hover { background: var(--muted-bg); color: var(--foreground); text-decoration: none; }
.drawer-item.active { background: rgba(15,28,63,0.08); border-color: rgba(15,28,63,0.25); color: var(--primary); }
.drawer-item svg { width: 20px; height: 20px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .bottom-nav { display: grid; }
  .main-content { padding: 1rem; padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
}

/* ── CARDS ── */
.card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-header { margin-bottom: 0.75rem; }
.card-title  { font-family: var(--font-serif); font-size: 1.1rem; color: var(--primary); }
.card-desc   { font-size: 0.8125rem; color: var(--muted-fg); margin-top: 0.2rem; }
.card-body   { font-size: 0.875rem; }
.card-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.card-hover { transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; cursor: pointer; }
.card-hover:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card.accent-border { border-color: hsl(var(--gold), 0.4); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-sans); font-weight: 600; font-size: 0.875rem;
  padding: 0.5rem 1.25rem; border-radius: var(--radius-md);
  border: none; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { opacity: 0.88; }
.btn-accent  { background: var(--accent); color: var(--accent-fg); }
.btn-accent:hover { opacity: 0.88; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--muted-bg); }
.btn-ghost   { background: transparent; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--muted-bg); color: var(--foreground); }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.75rem; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; justify-content: center; }
.btn-icon.btn-lg { width: 48px; height: 48px; border-radius: var(--radius-xl); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.6875rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  border: 1px solid transparent;
}
.badge-navy    { background: var(--primary); color: var(--primary-fg); }
.badge-gold    { background: rgba(201,168,76,0.15); color: var(--accent); border-color: rgba(201,168,76,0.3); }
.badge-muted   { background: var(--muted-bg); color: var(--muted-fg); border-color: var(--border); }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-danger  { background: rgba(239,68,68,0.1); color: #dc2626; border-color: rgba(239,68,68,0.25); }
.badge-outline { background: transparent; border-color: var(--border); color: var(--foreground); }

/* Selectable chip */
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--border); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; color: var(--muted-fg); background: transparent;
  transition: all 0.15s; font-family: var(--font-sans);
}
.chip:hover    { border-color: var(--accent); color: var(--foreground); }
.chip.selected { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }

/* ── INPUTS ── */
.input, .textarea, .select-el {
  width: 100%; font-family: var(--font-sans); font-size: 0.875rem;
  background: var(--card-bg); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select-el:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.18);
}
.textarea { min-height: 120px; resize: vertical; }
.select-el { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
label { font-size: 0.8125rem; font-weight: 600; color: var(--foreground); margin-bottom: 0.35rem; display: block; }

/* Password input */
.input-password-wrap { position: relative; }
.input-password-wrap .input { padding-right: 2.5rem; }
.input-eye { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted-fg); padding: 0.25rem; }

/* ── UTILITIES ── */
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.space-y-8 > * + * { margin-top: 2rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--muted-fg); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.italic { font-style: italic; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── TABS ── */
.tabs-list {
  display: inline-flex; background: var(--muted-bg);
  border-radius: var(--radius-md); padding: 0.25rem; gap: 0.25rem;
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: 0.4rem 1rem; border-radius: var(--radius-sm);
  border: none; background: transparent;
  font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500;
  color: var(--muted-fg); cursor: pointer; transition: all 0.15s;
}
.tab-btn.active { background: var(--card-bg); color: var(--foreground); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── RESULT BOX ── */
.result-box {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-top: 1.5rem;
}
.result-box-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(201,168,76,0.06); border-bottom: 1px solid var(--border);
}
.result-box-title { font-family: var(--font-serif); font-size: 0.9375rem; }
.result-box-body {
  padding: 1.25rem 1.5rem;
  font-size: 0.875rem; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}

/* ── CHAT ── */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100dvh - 180px); min-height: 400px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.msg { display: flex; gap: 0.75rem; max-width: 85%; }
.msg-ai { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px;
}
.msg-ai .msg-avatar   { background: rgba(201,168,76,0.15); color: var(--accent); }
.msg-user .msg-avatar { background: rgba(15,28,63,0.15); color: var(--primary); }
.msg-bubble {
  padding: 0.75rem 1rem; border-radius: var(--radius-xl);
  font-size: 0.875rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.msg-ai .msg-bubble   { background: var(--muted-bg); border: 1px solid var(--border); border-top-left-radius: var(--radius-sm); }
.msg-user .msg-bubble { background: var(--primary); color: var(--primary-fg); border-top-right-radius: var(--radius-sm); }
.chat-footer { padding: 0.75rem 1rem; border-top: 1px solid var(--border); background: var(--muted-bg); }
.chat-input-row { display: flex; gap: 0.75rem; align-items: flex-end; }
.chat-textarea { min-height: 48px; max-height: 160px; resize: none; flex: 1; }
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 0.5rem 0; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-fg); animation: blink 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── STATUS BARS ── */
.status-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.85rem; border-radius: var(--radius-md);
  font-size: 0.8125rem; border: 1px solid;
}
.status-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.status-muted   { background: var(--muted-bg); border-color: var(--border); color: var(--muted-fg); }

/* ── SKELETON ── */
.skeleton { background: var(--muted-bg); border-radius: var(--radius-sm); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── SPINNER ── */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PAGE ANIMATIONS ── */
.page-enter { animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── MODULE GRID ── */
.module-card { text-decoration: none; color: inherit; display: block; }
.module-card .card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.module-icon { width: 28px; height: 28px; color: var(--accent); margin-bottom: 0.5rem; transition: transform 0.15s; }
.module-card:hover .module-icon { transform: scale(1.1); }

/* ── HOOK CARD ── */
.hook-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.875rem 1rem; background: var(--card-bg);
  transition: border-color 0.15s;
}
.hook-card:hover { border-color: rgba(15,28,63,0.3); }
.hook-text { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.75rem; line-height: 1.5; }
.hook-actions { display: flex; gap: 0.5rem; }

/* ── BIO CARD ── */
.bio-card { padding: 0.875rem; background: var(--muted-bg); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 0.875rem; line-height: 1.65; }
.bio-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }

/* ── PROVIDER STATUS ── */
.provider-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.875rem; padding: 0.35rem 0; }
.provider-row + .provider-row { border-top: 1px solid var(--border); }

/* ── LLM RESULT CARD ── */
.llm-result { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; }
.llm-result-header { padding: 0.6rem 1rem; background: var(--muted-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.llm-result-body { padding: 1rem; font-size: 0.8125rem; line-height: 1.7; white-space: pre-wrap; overflow-y: auto; max-height: 280px; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 5rem; right: 1rem; z-index: 999; display: flex; flex-direction: column; gap: 0.5rem; }
@media (min-width: 769px) { .toast-container { bottom: 1.5rem; } }
.toast {
  padding: 0.65rem 1rem; background: var(--primary); color: var(--primary-fg);
  border-radius: var(--radius-md); font-size: 0.8125rem; font-weight: 500;
  box-shadow: var(--shadow-md); animation: slideIn 0.2s ease;
  display: flex; align-items: center; gap: 0.5rem;
}
.toast.error { background: var(--destructive); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── KEY INPUT GROUP ── */
.key-group { padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted-bg); }
.key-group-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }

/* ── RESPONSIVE GRIDS ── */
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.35rem; }
}
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (min-width: 1024px) {
  .grid-lg-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Page heading */
.page-heading { margin-bottom: 1.5rem; }
.page-heading h1 { margin-bottom: 0.25rem; }
.page-heading p { color: var(--muted-fg); font-size: 0.9375rem; }

/* inline green/red */
.text-green { color: #16a34a; }
.text-red   { color: #dc2626; }

/* Discover source btn */
.source-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border); font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; color: var(--muted-fg); background: transparent;
  transition: all 0.15s; font-family: var(--font-sans);
}
.source-btn.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.source-btn:hover:not(.active) { border-color: var(--accent); color: var(--foreground); }
.source-tag { font-size: 0.625rem; opacity: 0.7; }

/* Always-on badge */
.badge-always { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); font-size: 0.625rem; padding: 0.15rem 0.4rem; border-radius: 999px; font-weight: 600; }

/* Post idea card */
.idea-card { cursor: pointer; }
.idea-card:hover { border-color: rgba(15,28,63,0.35); }
.idea-card .arrow { color: var(--muted-fg); transition: color 0.15s; }
.idea-card:hover .arrow { color: var(--primary); }

/* ── Multi-provider Engine Room ── */
.uni-out {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.82rem;
  max-height: 340px;
  overflow-y: auto;
  color: var(--foreground);
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
[data-prov] label, [data-res] label { font-size: 0.75rem; }

/* ════════════════════════════════════════════════════════════════════════
   COCKPIT DASHBOARD  (scoped: .ck-*)
   Bold spent in ONE place — the navy Daily Brief hero. Everything else quiet.
   ════════════════════════════════════════════════════════════════════════ */
.ck { display: flex; flex-direction: column; gap: 1.5rem; }

/* 1 · header + status strip */
.ck-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ck-eyebrow { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-fg); }
.ck-hello { font-size: 2rem; margin-top: 0.15rem; }
.ck-status { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ck-stat {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.7rem; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--border);
  font-family: var(--font-sans); font-size: 0.75rem; font-weight: 600;
  color: var(--muted-fg); cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.ck-stat:hover { border-color: var(--accent); color: var(--foreground); }
.ck-stat svg { width: 12px; height: 12px; }
.ck-stat--alert { color: #b91c1c; border-color: rgba(220,38,38,0.35); background: rgba(220,38,38,0.06); }
.ck-stat--alert:hover { border-color: rgba(220,38,38,0.6); color: #991b1b; }

/* live/down dot */
.ck-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.ck-dot--live { background: var(--accent); box-shadow: 0 0 0 0 rgba(201,168,76,0.5); }
.ck-dot--down { background: var(--destructive); }
@media (prefers-reduced-motion: no-preference) {
  .ck-dot--live { animation: ckPulse 2.4s ease-out infinite; }
}
@keyframes ckPulse {
  0%   { box-shadow: 0 0 0 0 rgba(201,168,76,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(201,168,76,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
}

/* 2 · DAILY BRIEF — the hero, the one bold surface */
.ck-brief {
  background: var(--primary); color: var(--primary-fg);
  border-radius: var(--radius-xl); padding: 1.5rem 1.65rem;
  box-shadow: var(--shadow-md);
  background-image: radial-gradient(120% 140% at 100% 0%, rgba(201,168,76,0.16) 0%, rgba(201,168,76,0) 42%);
}
.ck-brief-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.ck-brief-kicker {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.ck-brief-kicker svg { width: 13px; height: 13px; }
.ck-brief-body { display: flex; flex-direction: column; }

.ck-brief-row { display: flex; gap: 0.9rem; padding: 0.85rem 0; align-items: baseline; }
.ck-brief-row + .ck-brief-row { border-top: 1px solid rgba(244,241,234,0.12); }
.ck-brief-row p { font-size: 0.9375rem; line-height: 1.6; color: rgba(244,241,234,0.94); margin: 0; }
.ck-brief-tag {
  flex-shrink: 0; width: 58px;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding-top: 0.2rem;
}
.is-today .ck-brief-tag { color: var(--accent); }
.is-angle .ck-brief-tag { color: #8fb4ff; }
.is-watch .ck-brief-tag { color: #f0a868; }
.ck-brief-raw { white-space: pre-wrap; font-size: 0.9375rem; line-height: 1.7; color: rgba(244,241,234,0.94); }

.ck-brief-loading { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.4rem 0; }
.ck-brief-loading .ck-shim { background: rgba(244,241,234,0.14); }
.ck-shim { height: 11px; border-radius: 999px; }

.ck-empty { font-size: 0.9375rem; line-height: 1.65; color: rgba(244,241,234,0.78); margin: 0; }
.ck-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-family: var(--font-sans); font-size: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}

/* icon button (works on dark hero and light panels) */
.ck-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: transparent; border: none; cursor: pointer;
  color: currentColor; opacity: 0.7; transition: opacity 0.15s, background 0.15s;
}
.ck-icon-btn:hover { opacity: 1; background: rgba(128,128,128,0.12); }
.ck-brief .ck-icon-btn { color: rgba(244,241,234,0.8); }

/* 3 · breaking angle */
.ck-angle {
  background: var(--card-bg); border: 1px solid var(--border);
  border-left: 3px solid #3b82f6; border-radius: var(--radius-lg);
  padding: 1.1rem 1.35rem; box-shadow: var(--shadow-sm);
}
.ck-angle-head { display: flex; align-items: center; justify-content: space-between; }
.ck-angle-kicker {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #3b82f6;
}
.ck-angle-headline { font-family: var(--font-serif); font-size: 1rem; color: var(--primary); margin: 0.4rem 0 0.5rem; }
.ck-angle-body { font-size: 0.875rem; line-height: 1.6; color: var(--foreground); margin-bottom: 0.9rem; }

/* 4 · instruments */
.ck-instruments { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ck-panel {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; box-shadow: var(--shadow-sm);
}
.ck-panel-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted-fg); }
.ck-panel-lead { font-family: var(--font-serif); font-size: 1.5rem; color: var(--primary); margin: 0.45rem 0 0.4rem; line-height: 1.1; }
.ck-lead--down { color: var(--destructive); }
.ck-panel-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; font-size: 0.8125rem; color: var(--muted-fg); line-height: 1.5; }
.ck-panel-sub { font-size: 0.75rem; color: var(--muted-fg); margin-top: 0.5rem; }

.ck-pill { font-size: 0.625rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 999px; }
.ck-pill--ok   { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.ck-pill--wait { background: rgba(240,168,104,0.14); color: #c47a25; border: 1px solid rgba(240,168,104,0.3); }

/* cockpit CTAs */
.ck-cta {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-top: 1rem; padding: 0.5rem 1rem; border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-fg);
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600;
  border: none; cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.ck-cta:hover { opacity: 0.88; }
.ck-cta:active { transform: scale(0.98); }
.ck-cta:disabled { opacity: 0.45; cursor: not-allowed; }
.ck-cta svg { width: 13px; height: 13px; }
.ck-cta--ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.ck-cta--ghost:hover { background: var(--muted-bg); opacity: 1; }
.ck-cta--inline { margin-top: 0; }
.ck-angle .ck-cta { margin-top: 0; }

/* 5 · mirror */
.ck-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.ck-mirror-sub { font-size: 0.8125rem; color: var(--muted-fg); margin-top: 0.3rem; }
.ck-bios { display: flex; flex-direction: column; }
.ck-bio { padding: 0.9rem 0; }
.ck-bio + .ck-bio { border-top: 1px solid var(--border); }
.ck-bio:first-child { padding-top: 0; }
.ck-bio-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.ck-bio-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.ck-bio-copy {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted-fg); font-family: var(--font-sans); font-size: 0.6875rem; font-weight: 600;
  padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); transition: color 0.15s, background 0.15s;
}
.ck-bio-copy:hover { color: var(--foreground); background: var(--muted-bg); }
.ck-bio-copy svg { width: 12px; height: 12px; }
.ck-bio-text { font-size: 0.8125rem; line-height: 1.6; color: var(--foreground); margin: 0; }

/* 6 · what to post next */
.ck-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.ck-h2 { font-size: 1.4rem; }
.ck-empty-sm { font-size: 0.8125rem; color: var(--muted-fg); margin-bottom: 0.75rem; }
.ck-empty-sm strong { color: var(--foreground); font-weight: 600; }

/* 7 · jump rail */
.ck-rail-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted-fg); margin-bottom: 0.6rem; }
.ck-rail {
  display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.35rem;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.ck-rail::-webkit-scrollbar { height: 0; }
.ck-rail-item {
  flex: 0 0 auto; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  min-width: 84px; padding: 0.85rem 0.6rem; border-radius: var(--radius-lg);
  background: var(--card-bg); border: 1px solid var(--border);
  font-family: var(--font-sans); font-size: 0.6875rem; font-weight: 600; color: var(--muted-fg);
  cursor: pointer; transition: border-color 0.15s, color 0.15s, transform 0.12s;
}
.ck-rail-item:hover { border-color: var(--accent); color: var(--foreground); transform: translateY(-2px); }
.ck-rail-ic { color: var(--accent); display: inline-flex; }
.ck-rail-ic svg { width: 18px; height: 18px; }

/* responsive */
@media (max-width: 640px) {
  .ck-hello { font-size: 1.65rem; }
  .ck-instruments { grid-template-columns: 1fr; }
  .ck-brief-tag { width: 52px; }
}

/* ════════════════════════════════════════════════════════════════════════
   REDESIGN LAYER — dark theme, compose FAB, studio/ask sheets, adaptive nav
   ════════════════════════════════════════════════════════════════════════ */

/* ── DARK THEME (default) ─────────────────────────────────────────────────
   Light mode stays intact as the [data-theme="light"] fallback. The token
   ROLES are preserved so existing components keep working; only a handful of
   surfaces (the hero, active states) get scoped overrides below. */
:root[data-theme="dark"] {
  --background:     hsl(224, 44%, 8%);
  --foreground:     hsl(40, 30%, 92%);
  --card-bg:        hsl(224, 40%, 12%);
  --card-border:    hsl(224, 24%, 20%);
  --border:         hsl(224, 24%, 20%);
  --input-bg:       hsl(224, 40%, 12%);
  --ring:           hsl(44, 60%, 58%);
  --primary:        hsl(40, 40%, 90%);   /* cream — primary buttons, active nav, headings */
  --primary-fg:     hsl(224, 50%, 10%);  /* navy text on cream */
  --accent:         hsl(44, 62%, 60%);   /* gold — reserved for the ONE action + live states */
  --accent-fg:      hsl(224, 50%, 10%);
  --muted-bg:       hsl(224, 32%, 16%);
  --muted-fg:       hsl(224, 16%, 64%);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.5);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.6);
}

/* the navy hero would turn cream under the remap — keep it an elevated navy with a gold glow */
[data-theme="dark"] .ck-brief {
  background: hsl(224, 42%, 14%);
  color: var(--foreground);
  border: 1px solid var(--border);
  background-image: radial-gradient(120% 140% at 100% 0%, rgba(201,168,76,0.20) 0%, rgba(201,168,76,0) 46%);
}
[data-theme="dark"] .ck-brief-row p,
[data-theme="dark"] .ck-brief-raw { color: rgba(244,241,234,0.92); }
[data-theme="dark"] .ck-brief-row + .ck-brief-row { border-top-color: rgba(244,241,234,0.10); }

/* live states glow gold; active tab label goes gold (restraint: only here) */
[data-theme="dark"] .bottom-nav-item.active { color: var(--accent); }
[data-theme="dark"] .nav-link.active { background: var(--primary); color: var(--primary-fg); }

/* inputs read better with a faint lift in dark */
[data-theme="dark"] .input,
[data-theme="dark"] .textarea,
[data-theme="dark"] .select-el { background: hsl(224, 38%, 14%); }

/* ── THEME TOGGLE BUTTON ──────────────────────────────────────────────────*/
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted-fg); cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--foreground); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ── COMPOSE FAB (the raised centre of the bottom bar) ─────────────────────*/
.bottom-nav-item.is-compose { position: relative; }
.fab-compose {
  display: none;               /* shown via JS only on mobile bar */
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  align-items: center; justify-content: center;
  border: 3px solid var(--background);
  box-shadow: 0 6px 18px rgba(201,168,76,0.4);
  cursor: pointer; transition: transform 0.12s;
}
.fab-compose:active { transform: translateX(-50%) scale(0.94); }
.fab-compose svg { width: 24px; height: 24px; }
@media (max-width: 768px) { .fab-compose { display: inline-flex; } }

/* ── SHEETS (studio + ask) reuse drawer mechanics with a grab handle ───────*/
.sheet-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 200; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg); border-top: 1px solid var(--border);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: 201; transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  padding: 0.6rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  max-height: 88dvh; display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--border); margin: 0.25rem auto 0.75rem; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; flex-shrink: 0; }
.sheet-title { font-family: var(--font-serif); font-size: 1.1rem; color: var(--primary); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet--tall { top: 0; max-height: none; border-radius: 0; padding-top: max(0.6rem, env(safe-area-inset-top)); }

/* ── ADAPTIVE STUDIO GRID ─────────────────────────────────────────────────*/
.studio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
@media (max-width: 360px) { .studio-grid { grid-template-columns: repeat(2, 1fr); } }
.studio-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 1rem 0.5rem; border-radius: var(--radius-xl);
  border: 1px solid var(--border); background: transparent;
  color: var(--muted-fg); font-size: 0.75rem; font-weight: 600; text-align: center;
  cursor: pointer; transition: border-color 0.15s, color 0.15s, transform 0.12s, background 0.15s;
}
.studio-tile:hover  { background: var(--muted-bg); color: var(--foreground); }
.studio-tile:active { transform: scale(0.97); }
.studio-tile svg { width: 22px; height: 22px; color: var(--accent); }
.studio-tile.is-pinned { border-color: rgba(201,168,76,0.4); }
.studio-pin {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted-fg); opacity: 0.5; transition: opacity 0.15s, color 0.15s;
}
.studio-pin:hover { opacity: 1; }
.studio-tile.is-pinned .studio-pin { opacity: 1; color: var(--accent); }
.studio-pin svg { width: 13px; height: 13px; }
.studio-hint { font-size: 0.7rem; color: var(--muted-fg); margin: 0.25rem 0 0.85rem; }
