/* AstroLab — themeable design tokens (dark default, light via html.light)
   plus semantic component classes. Colors come from variables only, so both
   themes share one rule set. */

:root,
html.dark {
  --bg: #09090b;
  --bg-glow: radial-gradient(60% 45% at 50% 0%, rgba(255, 92, 92, 0.06), transparent 70%);
  --surface: #131316;
  --surface-2: #101012;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f4f5;
  --text-strong: #fafafa;
  --muted: #71717a;
  --faint: #52525b;
  --accent: #ff5c5c;
  --accent-hover: #ff7070;
  --accent-subtle: rgba(255, 92, 92, 0.12);
  --accent-glow: rgba(255, 92, 92, 0.25);
  --ok: #22c55e;
  --danger: #ef4444;
  --on-accent: #ffffff;
  --star: 255, 255, 255;
  --star-gold: 232, 200, 135;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --user-pill-bg: rgba(255, 255, 255, 0.06);
  --user-pill-line: rgba(255, 255, 255, 0.1);
  --card: rgba(255, 255, 255, 0.03);
}

html.light {
  --bg: #f7f7f8;
  --bg-glow: radial-gradient(60% 45% at 50% 0%, rgba(229, 72, 77, 0.06), transparent 70%);
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-hover: rgba(0, 0, 0, 0.045);
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.18);
  --text: #1c1c21;
  --text-strong: #09090b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #e5484d;
  --accent-hover: #f05c60;
  --accent-subtle: rgba(229, 72, 77, 0.09);
  --accent-glow: rgba(229, 72, 77, 0.18);
  --ok: #16a34a;
  --danger: #dc2626;
  --on-accent: #ffffff;
  --star: 90, 70, 160;
  --star-gold: 190, 140, 40;
  --shadow: 0 20px 50px rgba(24, 24, 32, 0.14);
  --user-pill-bg: rgba(0, 0, 0, 0.045);
  --user-pill-line: rgba(0, 0, 0, 0.1);
  --card: rgba(0, 0, 0, 0.028);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg-glow), var(--bg);
  color: var(--text);
  font-family: "Geist", "Inter", system-ui, sans-serif;
  font-size: 15px;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection { background: rgba(255, 92, 92, 0.3); }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.hidden { display: none !important; }

#stars { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ── shell ──────────────────────────────────────────────────────────── */

.app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  height: 56px;
  flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.brand .mark { color: var(--accent); font-size: 13px; }

.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 60%, transparent); }
.dot.bad { background: var(--danger); }

.actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.btn-ghost.icon { padding: 7px 11px; font-size: 14px; }
.mark-sm { color: var(--accent); }
.caret { color: var(--muted); margin-left: 6px; font-size: 11px; }
.model-btn { display: inline-flex; gap: 8px; align-items: center; max-width: 240px; }
.model-btn #modelLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mwrap { position: relative; }

/* ── panels: exactly one can be open; layers are explicit ───────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-height: 60vh; overflow-y: auto; z-index: 60; }
.float { position: fixed; right: 16px; top: 64px; width: 300px; z-index: 70; }

.panel h3 { margin: 2px 0 14px; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.val { color: var(--accent); font-family: "Geist Mono", monospace; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; font-size: 13px; margin: 12px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.check small { color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.55; }

.group {
  font-family: "Geist Mono", monospace;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 9px 4px;
}

.mitem {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 120ms ease, border-color 120ms ease;
}
.mitem:hover { background: var(--surface-hover); }
.mitem.sel { background: var(--accent-subtle); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.mitem.off { opacity: 0.42; cursor: not-allowed; }
.mitem .tick { width: 14px; text-align: center; color: var(--accent); flex: none; }
.mitem .nm { font-size: 13px; font-weight: 500; color: var(--text-strong); }
.mitem .id { font-family: "Geist Mono", monospace; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mitem .warn { font-size: 11px; color: var(--danger); }
.badge {
  font-family: "Geist Mono", monospace;
  font-size: 9px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 7px;
  flex: none;
}

/* ── chat ───────────────────────────────────────────────────────────── */

.chat {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 18px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.empty { padding-top: 9vh; max-width: 620px; margin: 0 auto; }
.kicker {
  font-family: "Geist Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 16px;
}
.hero {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--text-strong);
}
.hero em { font-style: normal; color: var(--accent); }
.sub { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 28px; }

.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.suggestion {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.suggestion::before { content: "✦"; color: var(--accent); font-size: 10px; flex: none; }
.suggestion:hover { border-color: var(--line-strong); background: var(--surface-hover); transform: translateY(-1px); }
.hintline { font-family: "Geist Mono", monospace; color: var(--muted); font-size: 10.5px; margin-top: 24px; }

.msg { margin: 18px 0; animation: rise 0.3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg { animation: none; } }

.msg.user { display: flex; justify-content: flex-end; }
.u-pill {
  max-width: 76%;
  padding: 10px 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--user-pill-bg);
  border: 1px solid var(--user-pill-line);
  border-radius: 16px 16px 5px 16px;
}

.msg.assistant .a-block { display: flex; gap: 12px; }
.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 11px;
  color: var(--on-accent);
  background: var(--accent);
}
.a-body { min-width: 0; flex: 1; }
.a-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.a-name { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.a-text { font-size: 15px; line-height: 1.7; white-space: pre-wrap; word-wrap: break-word; color: var(--text); }
.pulsing { color: var(--muted); font-size: 13.5px; animation: pulse 1.3s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.cursor { color: var(--accent); animation: blink 0.85s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.1; } }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 9px; font-family: "Geist Mono", monospace; font-size: 10.5px; color: var(--muted); }
.mtag { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-family: "Geist Mono", monospace;
  font-size: 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 9px;
  cursor: pointer;
  background: var(--surface);
}
.chip:hover { border-color: var(--line-strong); }
.chip.shield { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.chip-detail {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  margin-top: 9px;
  white-space: pre-wrap;
}
.msg.error .a-text { color: var(--danger); font-size: 13.5px; }
.msg.error .a-block {
  background: color-mix(in srgb, var(--danger) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: 12px;
  padding: 12px 15px;
}

/* ── composer ───────────────────────────────────────────────────────── */

.dock { padding: 10px 18px 16px; border-top: 1px solid var(--line); background: var(--bg); flex: none; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 8px 8px 18px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle), 0 0 20px var(--accent-glow);
}
#input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 130px;
  padding: 8px 0;
}
#input::placeholder { color: var(--muted); }
.send {
  width: 40px;
  height: 40px;
  flex: none;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  cursor: pointer;
  transition: background 120ms ease, transform 100ms ease;
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: 0.35; cursor: not-allowed; }
.send:not(:disabled):active { transform: scale(0.94); }
.fineprint { text-align: center; color: var(--muted); font-family: "Geist Mono", monospace; font-size: 10px; margin: 9px 0 0; }

/* ── compare modal ──────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 18px;
}
.modal { width: min(940px, 100%); max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-strong); }
.prompt-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 12px 15px;
  resize: vertical;
  outline: none;
}
.prompt-box:focus { border-color: var(--accent); }
.cm-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.cm-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.cm-chip.on { border-color: var(--accent); background: var(--accent-subtle); }
.cm-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 10px;
  padding: 11px 24px;
  cursor: pointer;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.cr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; margin-top: 16px; }
.cr-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.cr-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.cr-model { font-family: "Geist Mono", monospace; font-size: 11px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-lat { font-family: "Geist Mono", monospace; font-size: 10.5px; color: var(--muted); flex: none; }
.cr-body { font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--text); }
.cr-err { color: var(--danger); font-size: 12.5px; }

@media (max-width: 640px) {
  .app { max-width: 100%; }
  .suggestions { grid-template-columns: 1fr; }
  .u-pill { max-width: 86%; }
  .hide-sm { display: none; }
  .float { right: 10px; left: 10px; width: auto; }
}

/* ── mode toggle (AI models vs VedAstro) ────────────────────────────── */

.mode-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  flex: none;
}
.mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.on { background: var(--accent-subtle); color: var(--accent); }
.mode-btn + .mode-btn { border-left: 1px solid var(--line); }

/* ── birth chart fields (settings panel) ────────────────────────────── */

.subhead {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.birth-row { display: flex; gap: 6px; margin-bottom: 8px; }
.birth-row input[type="text"] { flex: 1; }

#birthPlace,
.bgrid input,
.bgrid select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
}
.bgrid input, .bgrid select { width: 100%; }
.bgrid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}
#locateBtn { font-size: 12.5px; }
#locateBtn:disabled { opacity: 0.5; cursor: default; }

/* ── header birth chip + inline birth form (VedAstro mode) ──────────── */

.birth-btn {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.birth-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  max-width: 440px;
}
.birth-inline input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  width: 100%;
}
.birth-inline .birth-row { display: flex; gap: 6px; margin: 0; }
.birth-inline .birth-row input { flex: 1; }
.birth-inline .bgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.birth-inline .bgrid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}
.birth-inline .hint { margin: 0; min-height: 1em; }
.birth-inline .btn-primary { width: 100%; }

/* ── small screens: header wraps instead of overflowing ─────────────── */

@media (max-width: 760px) {
  .bar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 6px;
  }
  .actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
  }
  .mode-toggle { order: 10; }
  .mode-btn { padding: 5px 8px; font-size: 11.5px; }
  .birth-btn { max-width: 140px; font-size: 11.5px; }
  .model-btn { max-width: 140px; }
}
