/* ============================================================
   SOLAR & LUNAR — one site, two skies
   the logo in the header is the switch. everything below re-tints.
   ============================================================ */

:root {
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --rail-w: 168px;
  --topbar-h: 62px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

/* ---- SOLAR: daylight ---- */
html[data-theme="solar"] {
  --bg: #FFFCF2;
  --bg-2: #FFF6DA;
  --surface: #FFFFFF;
  --surface-2: #FBF5E4;
  --ink: #17150F;
  --ink-2: #4E4737;
  --muted: #8A8270;
  --line: #ECE4CF;
  --line-2: #E0D5B7;
  --accent: #F5B400;      /* the yellow from the logo */
  --accent-2: #FF7A00;    /* rays */
  --accent-ink: #1A1300;
  --accent-soft: #FFF0BF;
  --bubble-user: #17150F;
  --bubble-user-ink: #FFF9E6;
  --bubble-ai: #FFFFFF;
  --focus: #FF7A00;
  --shadow: 0 10px 30px -14px rgba(120, 90, 0, .35);
  --meter-on: #F5B400;
  --meter-off: #EADFC0;
  --danger: #C6462A;
}

/* ---- LUNAR: night ---- */
html[data-theme="lunar"] {
  --bg: #090D17;
  --bg-2: #0E1422;
  --surface: #121A2B;
  --surface-2: #182236;
  --ink: #E9EEF8;
  --ink-2: #B9C4DA;
  --muted: #7F8BA6;
  --line: #1E2941;
  --line-2: #2A3752;
  --accent: #A9BCE0;
  --accent-2: #DCE6FF;
  --accent-ink: #0A0E18;
  --accent-soft: #1B2740;
  --bubble-user: #DCE6FF;
  --bubble-user-ink: #0A0E18;
  --bubble-ai: #121A2B;
  --focus: #DCE6FF;
  --shadow: 0 10px 30px -14px rgba(0, 0, 0, .8);
  --meter-on: #A9BCE0;
  --meter-off: #23304A;
  --danger: #FF7B6B;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  transition: background .5s var(--ease), color .5s var(--ease);
  -webkit-font-smoothing: antialiased;
}
html[data-theme="solar"] body {
  background:
    radial-gradient(1200px 500px at 15% -10%, #FFF1B8 0%, transparent 60%),
    var(--bg);
}
html[data-theme="lunar"] body {
  background:
    radial-gradient(900px 500px at 85% -10%, #1A2440 0%, transparent 60%),
    var(--bg);
}

.hidden { display: none !important; }
.display { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.status { font-size: 12.5px; color: var(--muted); }
.msg { min-height: 1.2em; font-size: 13px; color: var(--accent-2); margin: 6px 0 0; }
.danger { color: var(--danger) !important; }
.optional { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
a { color: inherit; }
::selection { background: var(--accent-soft); }

/* ---- buttons/inputs ---- */
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: transform .15s var(--ease), background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
html[data-theme="lunar"] .btn-primary:hover { color: var(--accent-ink); }
.btn-wide { width: 100%; }
.linkbtn {
  font: inherit; font-size: 12.5px; color: var(--muted); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], textarea, input:not([type]) {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none; transition: border-color .2s;
  resize: vertical;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { line-height: 1.45; }
.pill { padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip:disabled { opacity: .5; cursor: wait; }

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 40px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.toggle-label { font-size: 14px; font-weight: 600; }
.toggle-label small { font-weight: 400; color: var(--muted); margin-left: 4px; }

/* ============ consent ============ */
.consent { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 16px; pointer-events: none; }
.consent-card {
  pointer-events: auto; max-width: 560px; width: 100%;
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius);
  padding: 16px; display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; box-shadow: var(--shadow);
  animation: rise .5s var(--ease);
}
.consent-card p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.consent-logo { width: 44px; height: 44px; object-fit: contain; }
.consent-card .btn { grid-column: 1 / -1; justify-self: end; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ auth ============ */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; align-items: center;
  max-width: 1040px; margin: 0 auto; padding: 40px 24px; gap: 40px;
}
.auth-mark img { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 12px 24px rgba(0,0,0,.15)); animation: spin-in 1.2s var(--ease); }
@keyframes spin-in { from { transform: rotate(-30deg) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.auth h1 { font-size: clamp(44px, 7vw, 76px); margin: 12px 0 0; line-height: .95; }
.auth h1 .amp { font-weight: 500; color: var(--accent-2); font-style: italic; }
.tagline { font-family: var(--font-display); font-size: 22px; font-weight: 500; color: var(--ink-2); margin: 8px 0 22px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; max-width: 460px; }
.auth-points li { padding-left: 18px; position: relative; color: var(--ink-2); font-size: 14.5px; }
.auth-points li::before { content: "✦"; position: absolute; left: 0; top: 0; color: var(--accent); }
.auth-card {
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); max-width: 400px; width: 100%; justify-self: end;
}
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; margin-bottom: 8px; }
.tab { flex: 1; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ============ app shell ============ */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10;
}

/* the switch: logo image + two invisible halves */
.modeswitch { position: relative; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; flex: none; }
.modeswitch img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease), filter .5s; }
.modeswitch .half { position: absolute; top: 0; bottom: 0; width: 50%; background: transparent; border: 0; cursor: pointer; padding: 0; }
.modeswitch .half-solar { left: 0; }
.modeswitch .half-lunar { right: 0; }
.modeswitch .half:hover ~ img { transform: scale(1.06); }
html[data-theme="lunar"] .modeswitch img { transform: rotate(180deg); }
html[data-theme="lunar"] .modeswitch .half-solar { right: 0; left: auto; }
html[data-theme="lunar"] .modeswitch .half-lunar { left: 0; right: auto; }
.modeswitch::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; transition: opacity .3s; pointer-events: none; }
.modeswitch:hover::after { opacity: 1; }

.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-size: 20px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

/* usage meter drawn as ray ticks (Solar) / crescent dots (Lunar) */
.meter { display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.meter i { width: 3px; border-radius: 2px; background: var(--meter-off); display: block; transition: background .3s, height .3s; }
.meter i.on { background: var(--meter-on); }
html[data-theme="lunar"] .meter i { width: 6px; height: 6px !important; border-radius: 50%; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface);
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.avatar:hover { border-color: var(--accent); }

.rail { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; border-right: 1px solid var(--line); }
.rail-btn {
  display: flex; align-items: center; gap: 10px; font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-align: left;
  transition: background .15s;
}
.rail-btn:hover { background: var(--surface-2); color: var(--ink); }
.rail-btn.active { background: var(--accent-soft); color: var(--ink); }
.rail-btn .ico { width: 20px; text-align: center; font-size: 16px; }

.content { padding: 22px 26px 40px; min-width: 0; }
.view { display: none; max-width: 860px; margin: 0 auto; }
.view.active { display: flex; flex-direction: column; animation: fade .3s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.view-head h2 { font-size: 30px; margin: 0; line-height: 1; }
.view-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---- tiers ---- */
.tiers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tier {
  font: inherit; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; transition: all .15s var(--ease);
}
.tier b { font-size: 14px; }
.tier small { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tier:hover { border-color: var(--accent); }
.tier.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tier.locked { opacity: .55; }
.tier-solstice { background: linear-gradient(135deg, var(--surface), var(--accent-soft)); }
.tier-note { font-size: 12.5px; color: var(--muted); margin: 8px 0 12px; }

/* ---- chat ---- */
.chatlog {
  flex: 1; min-height: 340px; max-height: calc(100vh - 380px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 8px 4px; scroll-behavior: smooth;
}
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; max-width: 320px; }
.empty img { width: 64px; height: 64px; object-fit: contain; opacity: .9; margin-bottom: 8px; }
.empty .moon-blob { font-size: 44px; display: block; color: var(--accent); }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
  animation: pop .25s var(--ease);
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.bubble.user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--bubble-ai); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.ai.thinking { color: var(--muted); font-style: italic; }
.bubble.err { align-self: center; background: transparent; color: var(--danger); font-size: 13px; border: 1px dashed var(--danger); }
.bubble pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-family: var(--font-mono); font-size: 12.5px; white-space: pre; margin: 8px 0; }
.bubble code { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.bubble-meta { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 6px; }

.composer {
  display: flex; gap: 8px; align-items: flex-end; margin-top: 10px;
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 18px; padding: 8px 8px 8px 14px;
  transition: border-color .2s; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; background: transparent; padding: 6px 0; max-height: 180px; resize: none; }
.composer textarea:focus { border: 0; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 16px; cursor: pointer; flex: none; transition: transform .15s var(--ease), background .2s; }
.send:hover { transform: scale(1.06); background: var(--accent-2); }
.send:disabled { opacity: .5; transform: none; cursor: wait; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; padding: 0 6px; }

/* ---- humanizer ---- */
.hum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hum-step { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; }
.hum-step-wide { grid-column: 1 / -1; }
.step-tag { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: .04em; margin-bottom: 10px; text-transform: lowercase; }
.slider-wrap { padding: 6px 2px 0; }
input[type="range"] { width: 100%; accent-color: var(--accent-2); cursor: pointer; }
.slider-labels { display: flex; justify-content: space-between; color: var(--muted); margin-top: 2px; }
.slider-value { margin-top: 10px; font-weight: 600; font-size: 14px; }
.custom-tone { margin-top: 10px; animation: fade .3s var(--ease); }
.style-status { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.style-status.ok { color: var(--ink-2); }
.style-setup { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2); animation: fade .3s var(--ease); }
.hum-output {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px;
  white-space: pre-wrap; font-size: 15px; line-height: 1.55; min-height: 80px; margin-top: 10px;
}
.hum-output.busy { opacity: .6; }

/* ---- lunar ---- */
.brain-menu { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1.5px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 6px; display: flex; flex-direction: column; min-width: 170px; z-index: 5; box-shadow: var(--shadow);
}
.menu button { font: inherit; font-size: 13.5px; text-align: left; padding: 8px 10px; border: 0; background: transparent; color: var(--ink); border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.brainbar { display: flex; align-items: center; gap: 16px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.brain-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.xp { flex: 1; }
.xp-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }
.xp-text { display: flex; justify-content: space-between; color: var(--muted); margin-top: 4px; }
.lunar-log .bubble.ai { background: var(--surface-2); }

/* ---- account ---- */
.acct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.uses { display: grid; gap: 6px; font-family: var(--font-mono); font-size: 12px; }
.uses .u { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.acct-actions { margin-top: 14px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; z-index: 60;
  box-shadow: var(--shadow); animation: rise .3s var(--ease);
}

/* ============ mobile ============ */
@media (max-width: 820px) {
  :root { --rail-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; left: 0; right: 0; flex-direction: row; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: var(--surface); z-index: 20; }
  .rail-btn { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; }
  .content { padding: 14px 12px 90px; }
  .brand-sub { display: none; }
  .tiers { grid-template-columns: repeat(2, 1fr); }
  .hum-grid, .acct-grid { grid-template-columns: 1fr; }
  .chatlog { max-height: none; min-height: 40vh; }
  .auth { grid-template-columns: 1fr; padding: 28px 18px 40px; gap: 24px; }
  .auth-card { justify-self: stretch; max-width: none; }
  .bubble { max-width: 90%; }
  .meter { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- plus ---- */
.card-plus { background: linear-gradient(135deg, var(--surface), var(--accent-soft)); border-color: var(--accent); }
.card-plus h3 { display: flex; align-items: center; gap: 8px; }
