/* Liken -- blue. The shared stylesheet also carries a brown accent set for studywithai;
   the client sets data-accent on <html> from /api/config. Neutrals are tuned for blue here;
   studywithai will warm them under [data-accent="brown"] when it's built. */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --ink: #1a2233;
  --muted: #5b6b85;
  --border: #dde4f0;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 6px 20px rgba(20, 33, 61, 0.06);
  --radius: 14px;

  --scripture: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* accent -- light */
[data-accent="blue"] { --accent: #2f5fbf; --accent-weak: #e8f0ff; --accent-ink: #ffffff; }
[data-accent="brown"] { --accent: #8a5a2b; --accent-weak: #f4ece1; --accent-ink: #ffffff; }

/* dark neutrals (system default when no explicit choice) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1526;
    --surface: #151f36;
    --surface-2: #1c2842;
    --ink: #e7ecf7;
    --muted: #93a2c2;
    --border: #263450;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.32);
  }
  :root:not([data-theme="light"])[data-accent="blue"] { --accent: #7aa2ff; --accent-weak: #1a2947; --accent-ink: #0b1120; }
  :root:not([data-theme="light"])[data-accent="brown"] { --accent: #cc9b6a; --accent-weak: #2b2116; --accent-ink: #150e05; }
}

/* explicit dark toggle wins in both directions */
:root[data-theme="dark"] {
  --bg: #0e1526;
  --surface: #151f36;
  --surface-2: #1c2842;
  --ink: #e7ecf7;
  --muted: #93a2c2;
  --border: #263450;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.32);
}
:root[data-theme="dark"][data-accent="blue"] { --accent: #7aa2ff; --accent-weak: #1a2947; --accent-ink: #0b1120; }
:root[data-theme="dark"][data-accent="brown"] { --accent: #cc9b6a; --accent-weak: #2b2116; --accent-ink: #150e05; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.wordmark { font-family: var(--scripture); font-size: 1.5rem; font-weight: 700; color: var(--accent); letter-spacing: 0.01em; }
.tagline { color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-toggle {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-icon { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); box-shadow: inset -4px -4px 0 0 var(--surface-2); }
:root[data-theme="dark"] .theme-icon, :root:not([data-theme="light"]) .theme-icon { box-shadow: none; }

/* layout */
.layout {
  display: grid; gap: 20px; max-width: 1240px; margin: 0 auto; padding: 20px;
  align-items: start;
  grid-template-columns: 200px minmax(0, 1fr) 300px;
  grid-template-areas: "rail chat side";
}
.rail-col { grid-area: rail; position: sticky; top: 20px; align-self: start; }
.chat { grid-area: chat; }
.side { grid-area: side; }
/* medium: rail stays anchored left, chat + study stack on the right */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 170px minmax(0, 1fr); grid-template-areas: "rail chat" "rail side"; }
}
/* phone: single column, ads drop to the bottom */
@media (max-width: 680px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "chat" "side" "rail"; }
  .rail-col { position: static; }
}

/* chat */
.chat { display: flex; flex-direction: column; min-height: 60vh; }
.transcript { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 16px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: var(--radius); box-shadow: var(--shadow); }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg.liken { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--accent-weak); border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.msg .who { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.msg.thinking { color: var(--muted); font-style: italic; }

.composer { display: flex; gap: 10px; align-items: flex-end; position: sticky; bottom: 0; padding-top: 8px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer textarea {
  flex: 1; resize: none; max-height: 180px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-family: var(--ui); font-size: 1rem; line-height: 1.45;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.composer button {
  flex: none; padding: 12px 18px; border: none; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 0.95rem; cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: default; }
.disclaimer { color: var(--muted); font-size: 0.78rem; margin: 10px 2px 0; }
.usage-status { color: var(--muted); font-size: 0.78rem; margin: 4px 2px 0; font-variant-numeric: tabular-nums; }
.usage-status:empty { display: none; }

/* side panels */
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel-h { margin: 0; font-size: 1rem; }
.panel-sub { margin: 2px 0 12px; color: var(--muted); font-size: 0.8rem; }
.books { display: flex; flex-direction: column; gap: 8px; }
.book-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; }
.book-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.book-toggle.off { color: var(--muted); }

.passages { display: flex; flex-direction: column; gap: 12px; max-height: 46vh; overflow-y: auto; }
.passages-empty { color: var(--muted); font-size: 0.85rem; margin: 0; }
.passage { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.passage .ref { font-size: 0.78rem; font-weight: 700; color: var(--accent); letter-spacing: 0.02em; }
.passage .text { font-family: var(--scripture); font-size: 0.95rem; line-height: 1.5; margin-top: 3px; }

.rail-slot:empty { display: none; }

/* billing */
.top-actions { display: flex; align-items: center; gap: 10px; }
.upgrade { padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.upgrade:hover { filter: brightness(1.06); }

.plan-menu { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.plan-card { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: min(360px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.plan-card h3 { margin: 0; font-family: var(--scripture); color: var(--accent); }
.plan-card p { margin: 0 0 6px; color: var(--muted); font-size: 0.9rem; }
.plan-btn { padding: 12px 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: var(--radius); font-weight: 600; cursor: pointer; text-align: left; }
.plan-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.plan-close { padding: 8px; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; }

/* Premium unlocks usage; the ad rail still displays for everyone -- so nothing hides it. */
.disclaimer-note { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
