/* ================================================
   Design tokens — KJV brand, modern dashboard UX
   ================================================ */
:root {
  /* Surface */
  --bg: #fbf8f3;
  --bg-soft: #f5efe4;
  --surface: #ffffff;
  --surface-2: #fdfaf4;
  --surface-sunken: #f6f1e7;
  --border: #ece4d3;
  --border-strong: #d9ceb7;
  --divider: #efe8d8;

  /* Ink */
  --ink: #1c1614;
  --ink-2: #3a2f29;
  --text: #2b2420;
  --text-muted: #7a6e63;
  --text-subtle: #a99e90;

  /* Brand — KJV burgundy */
  --accent: #c72e2f;
  --accent-hover: #a82425;
  --accent-dark: #720021;
  --accent-darker: #4a0014;
  --accent-soft: #fdf3f3;
  --accent-border: #f0d0d1;

  /* Support */
  --gold: #b88a3e;
  --gold-soft: #f9f1df;
  --cream: #f3ead7;

  /* Semantic */
  --good: #1b9500;
  --good-soft: #eaf5e4;
  --warn: #b8860b;
  --warn-soft: #fdf5e0;
  --bad: #a61b1b;
  --bad-soft: #f9e8e8;

  /* Radius & depth */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  --shadow-xs: 0 1px 1px rgba(74, 0, 20, 0.04);
  --shadow-sm: 0 1px 2px rgba(74, 0, 20, 0.05), 0 2px 4px rgba(74, 0, 20, 0.03);
  --shadow-md: 0 2px 6px rgba(74, 0, 20, 0.06), 0 8px 20px rgba(74, 0, 20, 0.05);
  --shadow-lg: 0 8px 24px rgba(74, 0, 20, 0.10), 0 20px 48px rgba(74, 0, 20, 0.08);
  --ring: 0 0 0 3px rgba(199, 46, 47, 0.15);

  /* Type */
  --serif: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --sans: "Roboto", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-fast: 120ms;
  --t-mid: 200ms;
  --t-slow: 320ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }

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

/* ================================================
   Login screen — bold brand moment
   ================================================ */
.view-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(199, 46, 47, 0.08), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(184, 138, 62, 0.07), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px 40px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark), var(--gold));
}
.login-logo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 14px;
}
.login-sub {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  font-weight: 500;
  margin: 0 0 28px;
}
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  padding: 13px 16px;
  font-family: var(--sans);
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
#login-form input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
#login-form .btn { width: 100%; padding: 13px; font-size: 13px; letter-spacing: 0.06em; }
.login-foot {
  margin-top: 24px;
  color: var(--text-subtle);
  font-size: 11px;
  letter-spacing: 0.3px;
}
.login-foot em { color: var(--gold); font-style: italic; }

.login-sent {
  padding: 8px 0 4px;
  animation: fade-up var(--t-mid) var(--ease);
}
.sent-mark {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--good-soft);
  color: var(--good);
  margin: 0 auto 14px;
  display: grid; place-items: center;
  font-size: 24px;
  font-weight: 700;
  border: 1.5px solid #c5e0b5;
}
.login-sent p {
  color: var(--text);
  font-size: 14px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.login-sent .btn.ghost {
  padding: 8px 14px;
  font-size: 12px;
}

/* ================================================
   App shell — announcement + topbar
   ================================================ */
.announcement {
  background: var(--ink);
  color: var(--cream);
  text-align: center;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  padding: 8px 20px;
  font-weight: 500;
}
.announcement span { opacity: 0.85; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 14px; transition: opacity var(--t-fast) var(--ease); }
.brand[role="button"] { cursor: pointer; }
.brand[role="button"]:hover { opacity: 0.75; }
.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}
.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
}
.brand-sub {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  font-weight: 600;
}

.nav { display: flex; gap: 4px; align-items: center; }
.nav-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease);
  font-family: var(--sans);
}
.nav-btn:hover { color: var(--ink); background: var(--surface-sunken); }
.nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.channel-pill {
  font-size: 11px;
  color: var(--accent-dark);
  background: var(--gold-soft);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-weight: 500;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.channel-pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good);
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: all var(--t-fast) var(--ease);
  display: grid;
  place-items: center;
}
.icon-btn:hover {
  color: var(--ink);
  background: var(--surface-sunken);
  border-color: var(--border);
}

/* ================================================
   Main content shell
   ================================================ */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 32px 120px;
}
.view { animation: fade-up var(--t-slow) var(--ease); }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}
.page-header-row .page-title,
.page-header-row .page-sub { margin-bottom: 0; }
.page-header-row .page-sub { margin-top: 6px; }

.page-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 40px;
  line-height: 1.5;
  max-width: 620px;
}

/* ================================================
   Module hub
   ================================================ */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 12px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  cursor: pointer;
  transition: all var(--t-mid) var(--ease);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  overflow: hidden;
}
.module-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
}
.module-card:hover::before { opacity: 1; }
.module-card.coming-soon {
  cursor: pointer;
  opacity: 0.72;
}
.module-card.coming-soon:hover {
  opacity: 0.92;
  transform: none;
  box-shadow: var(--shadow-sm);
}
.module-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}
.module-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-mid) var(--ease);
}
.module-card.active .module-icon {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: transparent;
  color: var(--cream);
  box-shadow: 0 4px 12px rgba(114, 0, 33, 0.25), inset 0 0 0 1px rgba(255,255,255,0.12);
}
.module-card:hover .module-icon { transform: scale(1.04); }

.module-status {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.module-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.module-status.active { color: var(--good); background: var(--good-soft); }
.module-status.beta { color: var(--warn); background: var(--warn-soft); }
.module-status.coming_soon { color: var(--text-subtle); background: var(--surface-sunken); }

.module-card h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.module-card .subtitle {
  color: var(--accent-dark);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 14px;
}
.module-card .description {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  flex: 1;
}
.module-card .card-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.4px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: color var(--t-fast) var(--ease);
}
.module-card.coming-soon .card-foot { color: var(--text-subtle); }
.module-card:hover .card-foot { color: var(--accent-hover); }
.module-card .card-foot :last-child { transition: transform var(--t-mid) var(--ease); }
.module-card:hover .card-foot :last-child { transform: translateX(3px); }

.hub-foot {
  margin-top: 48px;
  padding: 28px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
  font-style: italic;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.hub-foot p { margin: 0; }

/* ================================================
   YouTube module — stats + queue
   ================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}
.stat {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease);
  position: relative;
  overflow: hidden;
}
.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}
.stat-value {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 8px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat.accent { background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 60%); border-color: var(--accent-border); }
.stat.accent .stat-value { color: var(--accent); }

.queue { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px 26px;
  transition: all var(--t-mid) var(--ease);
  position: relative;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}
.card-author { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--gold-soft), var(--cream));
  border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
  flex-shrink: 0;
}
.author-meta { min-width: 0; }
.author-name {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 14px;
}
.author-time { color: var(--text-subtle); font-size: 12px; }

.badge {
  font-size: 10px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.praise { background: var(--good-soft); color: #166000; }
.badge.question { background: var(--warn-soft); color: #8a6d00; }
.badge.objection { background: var(--accent-soft); color: var(--accent-dark); }
.badge.spam, .badge.troll, .badge.skip { background: var(--surface-sunken); color: var(--text-muted); }

.comment-text {
  color: var(--text);
  background: var(--surface-sunken);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.comment-text::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  background: var(--gold);
  border-radius: var(--r-full);
}
.comment-text { padding-left: 22px; }

.draft {
  position: relative;
  background: linear-gradient(180deg, var(--accent-soft) 0%, rgba(253, 243, 243, 0.4) 100%);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.draft-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.draft-label::before { content: "✦"; color: var(--gold); font-size: 13px; }
.draft-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--serif);
  font-style: italic;
}

.card-meta {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }

.card-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ================================================
   Buttons — modern, clear
   ================================================ */
.btn {
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  font-family: var(--sans);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.btn:hover {
  background: var(--surface-sunken);
  border-color: var(--accent-dark);
  color: var(--accent-dark);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(199, 46, 47, 0.25);
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 4px 12px rgba(199, 46, 47, 0.3);
  transform: translateY(-1px);
}
.btn.primary:active { transform: translateY(0); }
.btn.danger {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--border); }

/* ================================================
   Empty state
   ================================================ */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.empty-emoji {
  font-size: 44px;
  margin-bottom: 12px;
  color: var(--gold);
  font-family: var(--serif);
}
.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.empty-state p { font-style: italic; margin: 0; }

/* ================================================
   Order Assistant — chat UI
   ================================================ */
.chat-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 540px;
  max-height: calc(100vh - 280px);
  overflow: hidden;
}

.chat-suggestions {
  padding: 16px 22px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
}
.chat-suggestions.hidden { display: none; }
.suggestion-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 6px;
}
.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
  transition: all var(--t-fast) var(--ease);
}
.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-empty {
  text-align: center;
  color: var(--text-subtle);
  padding: 60px 20px;
  font-style: italic;
}
.chat-empty-mark { font-size: 40px; color: var(--gold); font-family: var(--serif); margin-bottom: 8px; }

.msg { display: flex; gap: 12px; max-width: 88%; animation: fade-up var(--t-mid) var(--ease); }
.msg.assistant { max-width: 96%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; max-width: 75%; }
.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}
.msg.user .msg-bubble { white-space: pre-wrap; }

/* Markdown inside assistant messages */
.msg.assistant .msg-bubble > :first-child { margin-top: 0; }
.msg.assistant .msg-bubble > :last-child { margin-bottom: 0; }
.msg.assistant .msg-bubble p { margin: 0 0 10px; }
.msg.assistant .msg-bubble strong { font-weight: 700; color: var(--ink); }
.msg.assistant .msg-bubble em { font-style: italic; }
.msg.assistant .msg-bubble ul,
.msg.assistant .msg-bubble ol { margin: 8px 0 10px; padding-left: 22px; }
.msg.assistant .msg-bubble li { margin: 3px 0; }
.msg.assistant .msg-bubble li::marker { color: var(--accent); }
.msg.assistant .msg-bubble a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-border);
  text-underline-offset: 2px;
}
.msg.assistant .msg-bubble a:hover { text-decoration-color: var(--accent); }
.msg.assistant .msg-bubble code {
  background: var(--cream);
  color: var(--accent-dark);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  border: 1px solid var(--border);
}
.msg.assistant .msg-bubble pre {
  background: var(--ink);
  color: var(--cream);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-size: 12.5px;
  margin: 8px 0;
}
.msg.assistant .msg-bubble pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
}
.msg.assistant .msg-bubble blockquote {
  margin: 8px 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--gold);
  color: var(--text-muted);
}
.msg.assistant .msg-bubble h1,
.msg.assistant .msg-bubble h2,
.msg.assistant .msg-bubble h3,
.msg.assistant .msg-bubble h4 {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink);
  margin: 14px 0 8px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.msg.assistant .msg-bubble h1 { font-size: 20px; }
.msg.assistant .msg-bubble h2 { font-size: 17px; }
.msg.assistant .msg-bubble h3 { font-size: 15px; }
.msg.assistant .msg-bubble h4 { font-size: 14px; }
.msg.assistant .msg-bubble hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 12px 0;
}

/* Markdown tables — compact, readable */
.msg.assistant .msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0 12px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.msg.assistant .msg-bubble thead {
  background: var(--surface-sunken);
}
.msg.assistant .msg-bubble th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.msg.assistant .msg-bubble td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  vertical-align: top;
}
.msg.assistant .msg-bubble tbody tr:last-child td { border-bottom: none; }
.msg.assistant .msg-bubble tbody tr:hover { background: var(--surface-2); }
.msg.assistant .msg-bubble td:first-child,
.msg.assistant .msg-bubble th:first-child { font-family: "SF Mono", Menlo, monospace; font-size: 12px; color: var(--accent-dark); font-weight: 600; text-transform: none; letter-spacing: 0; }
.msg.assistant .msg-bubble {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text);
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
}
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 13px;
}
.msg.assistant .msg-avatar {
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  color: var(--cream);
}
.msg.user .msg-avatar {
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
.msg-tools {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-chip {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--gold-soft);
  color: var(--accent-dark);
  border: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.3px;
  font-family: "SF Mono", Menlo, monospace;
}

.msg.thinking .msg-bubble {
  color: var(--text-muted);
  font-style: italic;
}
.thinking-dots::after {
  content: "";
  display: inline-block;
  width: 18px;
  text-align: left;
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

.chat-input {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.chat-input textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--sans);
  line-height: 1.5;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
.chat-input textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.chat-input .btn { flex-shrink: 0; }

/* ================================================
   Coming-soon module view
   ================================================ */
.coming-soon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 56px 48px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  max-width: 640px;
  margin: 0 auto;
}
.coming-soon-mark {
  font-size: 52px;
  color: var(--gold);
  font-family: var(--serif);
  margin-bottom: 8px;
}
.coming-soon-card h2 {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--ink);
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.coming-soon-card > p {
  color: var(--text-muted);
  margin: 0 auto 28px;
  max-width: 480px;
  line-height: 1.65;
  font-size: 15px;
}
.coming-soon-features {
  text-align: left;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px 26px;
  margin: 24px 0 32px;
}
.coming-soon-features .feature-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
}
.coming-soon-features ul {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.9;
}
.coming-soon-features li::marker { color: var(--accent); }

/* Preview-mode banner */
.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, var(--gold-soft) 0%, #fdf3f3 100%);
  border: 1px solid var(--gold);
  border-radius: var(--r-md);
  padding: 14px 20px;
  margin-bottom: 24px;
  font-size: 13.5px;
  color: var(--ink);
}
.preview-banner strong {
  font-family: var(--serif);
  font-weight: 700;
  margin-right: 6px;
  color: var(--accent-dark);
}
.preview-banner .btn { flex-shrink: 0; }

/* ================================================
   Setup wizard — modern numbered steps
   ================================================ */
.wizard {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wizard-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px 32px;
  transition: all var(--t-mid) var(--ease);
  position: relative;
}
.wizard-step.active {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(199, 46, 47, 0.06), var(--shadow-sm);
}
.wizard-step.done {
  background: var(--good-soft);
  border-color: #c5e0b5;
}

.wizard-step-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
}
.step-num {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-mid) var(--ease);
}
.wizard-step.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(199, 46, 47, 0.3);
}
.wizard-step.done .step-num {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
  font-size: 0;
}
.wizard-step.done .step-num::before { content: "✓"; font-size: 18px; font-family: var(--sans); }

.step-title h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.step-title p { color: var(--text-muted); font-size: 13.5px; margin: 0; line-height: 1.55; }
.step-title a { border-bottom: 1px solid transparent; transition: border-color var(--t-fast) var(--ease); }
.step-title a:hover { border-bottom-color: var(--accent); }

.step-status {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.step-status.done { color: var(--good); background: var(--good-soft); border-color: #c5e0b5; }

.wizard-step-body {
  margin-top: 20px;
  padding-left: 58px;
}
.wizard-detail {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
  line-height: 1.65;
}
.wizard-detail code {
  background: var(--cream);
  color: var(--accent-dark);
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: 12px;
  border: 1px solid var(--border);
  font-family: "SF Mono", Menlo, monospace;
}
.wizard-actions { display: flex; gap: 10px; margin-top: 10px; }
.wizard-step input[type="password"],
.wizard-step input[type="text"] {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  font-family: var(--sans);
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
.wizard-step input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.voice-progress {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, monospace;
}
.voice-progress.error { background: var(--bad-soft); border-color: #e9c8c9; color: var(--bad); }
.voice-progress.done { background: var(--good-soft); border-color: #c5e0b5; color: var(--good); }

/* ================================================
   Autopilot pill
   ================================================ */
.autopilot-pill {
  font-size: 10px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.autopilot-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.autopilot-pill.off {
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-color: var(--border);
}
.autopilot-pill.on {
  color: var(--good);
  background: var(--good-soft);
  border-color: #c5e0b5;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ================================================
   Settings modal
   ================================================ */
.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--divider);
}
.settings-section:last-of-type { border-bottom: none; }
.field-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 8px 0 0;
  font-style: italic;
  line-height: 1.55;
}
.field-hint strong { color: var(--accent-dark); font-style: normal; font-weight: 600; }

.autopilot-section {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
  padding: 20px 22px;
  margin: 12px 0;
}
.autopilot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  transition: var(--t-mid) var(--ease);
  border-radius: var(--r-full);
}
.slider::before {
  position: absolute;
  content: "";
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: #fff;
  transition: var(--t-mid) var(--ease);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.category-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast) var(--ease);
}
.category-chip:hover { border-color: var(--accent); }
.category-chip input { margin: 0; accent-color: var(--accent); }
.category-chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}

.settings-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.settings-col input { width: 100%; }

/* ================================================
   Modal
   ================================================ */
.modal {
  position: fixed; inset: 0;
  background: rgba(28, 22, 20, 0.55);
  display: grid; place-items: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  animation: fade-in var(--t-mid) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modal-pop var(--t-mid) var(--ease);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-card.wide { width: 600px; }
.modal-card h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.modal-card p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.modal-card code {
  background: var(--cream);
  color: var(--accent-dark);
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  border: 1px solid var(--border);
  font-family: "SF Mono", Menlo, monospace;
}
.modal-card input, .modal-card textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  font-family: var(--sans);
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
.modal-card input:focus, .modal-card textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.modal-card textarea {
  resize: vertical;
  min-height: 140px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.55;
}
.modal-card .btn { margin-top: 16px; width: 100%; }
.modal-card.wide .btn { width: auto; margin-top: 0; }

.form-error {
  color: var(--bad);
  font-size: 12.5px;
  margin-top: 10px;
  background: var(--bad-soft);
  border: 1px solid #e9c8c9;
  padding: 10px 12px;
  border-radius: var(--r-sm);
}

.label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 14px;
  font-weight: 700;
}
.edit-original blockquote {
  margin: 0;
  background: var(--surface-sunken);
  padding: 14px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  position: relative;
}
.edit-original blockquote::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  background: var(--gold);
  border-radius: var(--r-full);
}
.edit-original blockquote { padding-left: 22px; }

.edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.wordcount {
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 500;
}
.wordcount.over { color: var(--bad); font-weight: 700; }
.edit-actions { display: flex; gap: 10px; }

/* ================================================
   Toast
   ================================================ */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  border: 1px solid var(--ink-2);
  padding: 12px 22px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slide-up var(--t-mid) var(--ease);
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); color: #fcd5d5; }

@keyframes slide-up {
  from { transform: translate(-50%, 16px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 780px) {
  .main { padding: 32px 20px 80px; }
  .page-title { font-size: 30px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .module-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
  .topbar { padding: 12px 16px; }
  .announcement { font-size: 10px; letter-spacing: 1.2px; }
  .wizard-step-body { padding-left: 0; }
  .settings-row { grid-template-columns: 1fr; }
}
