/* ==========================================================================
   Ashane4x AI — UI
   Clean and simple; motion comes from GSAP in app.js.
   ========================================================================== */
:root {
  --bg: #f8f7f6;
  --surface: #ffffff;
  --ink: #121010;
  --ink-2: #3e3a39;
  --muted: #817a78;
  --line: #e9e5e3;
  --line-strong: #dad4d1;
  --accent: #dc2626;
  --accent-ink: #b91c1c;
  --accent-soft: #fdecec;
  --logo-ink: #ffffff;
  --user-bg: #121010;
  --user-ink: #f8f7f6;
  --shadow: 0 1px 2px rgba(18, 16, 16, 0.04), 0 12px 32px -12px rgba(18, 16, 16, 0.14);
  --shadow-lg: 0 2px 4px rgba(18, 16, 16, 0.04), 0 24px 60px -20px rgba(18, 16, 16, 0.22);
  --orb-a: #ff6b6b;
  --orb-b: #ffb199;
  --orb-c: #ffd3c2;
  --font: 'Inter Tight Variable', 'Inter Tight', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Instrument Serif', ui-serif, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 22px;
  --col: 720px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0b0b;
  --surface: #171313;
  --ink: #f3efee;
  --ink-2: #cac3c1;
  --muted: #877f7d;
  --line: #282322;
  --line-strong: #36302f;
  --accent: #f04438;
  --accent-ink: #ff7a70;
  --accent-soft: rgba(240, 68, 56, 0.14);
  --logo-ink: #0d0b0b;
  --user-bg: #f3efee;
  --user-ink: #0d0b0b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --orb-a: #b91c1c;
  --orb-b: #7f1d3a;
  --orb-c: #9a3412;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0b0b;
    --surface: #171313;
    --ink: #f3efee;
    --ink-2: #cac3c1;
    --muted: #877f7d;
    --line: #282322;
    --line-strong: #36302f;
    --accent: #f04438;
    --accent-ink: #ff7a70;
    --accent-soft: rgba(240, 68, 56, 0.14);
    --logo-ink: #0d0b0b;
    --user-bg: #f3efee;
    --user-ink: #0d0b0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 60px -20px rgba(0, 0, 0, 0.7);
    --orb-a: #b91c1c;
    --orb-b: #7f1d3a;
    --orb-c: #9a3412;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { display: block; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb {
  position: absolute;
  left: 50%;
  top: 34%;
  width: min(760px, 120vw);
  aspect-ratio: 1;
  translate: -50% -50%;
  filter: blur(70px) saturate(120%);
  opacity: 0.55;
  transition: opacity 0.8s ease, top 0.8s ease;
}
.blob { position: absolute; border-radius: 50%; mix-blend-mode: multiply; }
:root[data-theme="dark"] .blob { mix-blend-mode: screen; }
:root[data-theme="dark"] .orb { opacity: 0.45; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .blob { mix-blend-mode: screen; }
  :root:not([data-theme="light"]) .orb { opacity: 0.45; }
}
.blob--a { width: 52%; height: 52%; left: 12%; top: 18%; background: var(--orb-a); }
.blob--b { width: 46%; height: 46%; right: 10%; top: 26%; background: var(--orb-b); }
.blob--c { width: 40%; height: 40%; left: 32%; bottom: 14%; background: var(--orb-c); }
.is-chat .orb { opacity: 0.18; top: 10%; }

.pricewave { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 38vh; opacity: 0.9; transition: opacity 0.8s ease; }
.pricewave path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.35; }
.pricewave circle { fill: var(--accent); filter: drop-shadow(0 0 6px var(--accent)); }
.is-chat .pricewave { opacity: 0; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, env(safe-area-inset-left));
  transition: background 0.3s ease, border-color 0.3s ease;
  border-bottom: 1px solid transparent;
}
.is-chat .nav {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand__logo { width: 30px; height: 30px; color: var(--ink); }
.brand__name { font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.nav__right { display: flex; align-items: center; gap: 10px; }

.quota {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
  backdrop-filter: blur(8px);
}
.quota__dots { display: flex; gap: 5px; }
.quota__dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
}
.quota__dots i.used { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.quota__text b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.quota.is-out .quota__text b { color: var(--muted); }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.icon-btn:hover { border-color: var(--line-strong); transform: rotate(90deg); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Theme toggle: show the moon in light mode, the sun in dark mode */
.theme-toggle:hover { transform: none; }
.theme-toggle svg { stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
/* Smooth colour change only while switching, so normal hovers stay snappy */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, fill 0.4s ease, stroke 0.4s ease !important;
}

/* ---------- Stage layout ---------- */
.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: 64px;
}
.is-home .stage { justify-content: center; padding-bottom: 8vh; }

.hero { text-align: center; padding: 0 20px 34px; }
.is-chat .hero { display: none; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.headline {
  margin: 0;
  font-weight: 640;
  font-size: clamp(40px, 7.4vw, 82px);
  line-height: 1;
  letter-spacing: -0.045em;
}
.headline .line { display: block; overflow: hidden; padding-bottom: 0.08em; }
.headline .line > span { display: inline-block; }
.headline em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--accent-ink);
}
.lede { max-width: 600px; margin: 22px auto 0; font-size: 18px; line-height: 1.5; color: var(--muted); }

.thread { display: none; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 28px 20px 12px; }
.is-chat .thread { display: block; }
.messages { max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }

.dock { padding: 0 20px max(14px, env(safe-area-inset-bottom)); }
.is-chat .dock { padding-top: 6px; background: linear-gradient(to top, var(--bg) 70%, transparent); }

/* ---------- Composer ---------- */
.composer {
  max-width: var(--col);
  margin: 0 auto;
  padding: 16px 14px 12px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-soft); }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 28px;
  max-height: 200px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.55;
  padding: 0;
}
.composer textarea::placeholder { color: var(--muted); }
.composer__row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.composer__hint { font-size: 13px; color: var(--muted); }
kbd { font: 500 11px var(--mono); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-strong); color: var(--ink-2); }
.composer__count { margin-left: auto; font: 500 12px var(--mono); color: var(--muted); }
.composer__count.over { color: #d14b4b; }
.send {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--bg);
  background: var(--ink);
  transition: background 0.25s, opacity 0.25s;
}
.send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.send:not(:disabled) { background: var(--accent); color: #fff; }
.send:disabled { opacity: 0.25; cursor: default; }

/* ---------- Suggestion chips ---------- */
.chips { max-width: var(--col); margin: 16px auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.is-chat .chips { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); background: var(--surface); }
.chip svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.fineprint { margin: 14px auto 0; text-align: center; font-size: 12px; color: var(--muted); }
.is-chat .fineprint { margin-top: 8px; }

/* ---------- Messages ---------- */
.msg--user { align-self: flex-end; max-width: min(82%, 560px); }
.msg--user .bubble {
  padding: 11px 17px;
  border-radius: 20px 20px 6px 20px;
  background: var(--user-bg);
  color: var(--user-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--bot { display: grid; grid-template-columns: 28px 1fr; gap: 14px; }
.msg--bot .brand__logo { width: 28px; height: 28px; margin-top: 2px; }

.answer { font-size: 16.5px; line-height: 1.72; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 14px; }
.answer h3, .answer h4 { margin: 20px 0 8px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.answer ul, .answer ol { margin: 0 0 14px; padding-left: 24px; }
.answer li { margin: 6px 0; padding-left: 4px; }
.answer ol li::marker { color: var(--accent-ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.answer ul li::marker { color: var(--accent); }
.answer strong { font-weight: 650; }
.answer a { color: var(--accent-ink); text-underline-offset: 3px; }
.answer code { font: 0.88em var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--accent-soft); }
.answer pre { margin: 0 0 14px; padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; }
.answer pre code { background: none; padding: 0; }
.answer blockquote { margin: 0 0 14px; padding: 4px 0 4px 16px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.answer.is-streaming > :last-child::after {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.05em;
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(0.55); opacity: 0.5; } }
.answer--error { color: #c43d3d; }

.thinking { display: flex; align-items: center; gap: 12px; height: 28px; color: var(--muted); font-size: 14.5px; }
.thinking__bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.thinking__bars i { width: 4px; height: 6px; border-radius: 2px; background: var(--accent); }
.thinking__bars i:nth-child(2) { background: var(--ink); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
}
.source svg { width: 13px; height: 13px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}
.copy:hover { color: var(--ink); background: var(--surface); }
.copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Student access gate ---------- */
.unlock {
  max-width: var(--col);
  margin: 0 auto;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.unlock__head { display: flex; align-items: center; gap: 14px; }
.unlock__head > div { display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; line-height: 1.4; }
.unlock__head span:not(.unlock__icon) { color: var(--muted); }
.unlock__icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); }
.unlock__icon svg { width: 21px; height: 21px; fill: none; stroke: var(--accent-ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.unlock__row { display: flex; gap: 10px; margin-top: 16px; }
.unlock__row input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: 600 16px var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.unlock__row input::placeholder { letter-spacing: 0; text-transform: none; font-weight: 400; color: var(--muted); }
.unlock__row input:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 4px var(--accent-soft); }
.unlock__btn {
  height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s;
}
.unlock__btn:hover { filter: brightness(1.08); }
.unlock__btn:disabled { opacity: 0.6; cursor: progress; }
.unlock__error { margin: 10px 2px 0; font-size: 13.5px; color: var(--accent-ink); }
@media (max-width: 640px) {
  .unlock { padding: 16px; }
  .unlock__btn { padding: 0 16px; }
}

.install-link { padding: 0; border: 0; background: none; color: var(--accent-ink); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Limit card ---------- */
.limit {
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.limit > div:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; }
.limit > div:first-child > span { color: var(--muted); }
.limit__clock { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); }
.limit__clock b { font: 600 26px/1.15 var(--mono); color: var(--accent-ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 76px;
  z-index: 20;
  translate: -50% 0;
  max-width: min(92vw, 440px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .nav { height: 58px; padding: 0 14px; }
  .stage { padding-top: 58px; }
  .brand__name { font-size: 15px; }
  .quota { padding: 0 11px; gap: 8px; }
  .quota__of { display: none; }
  .quota__text::after { content: ' left'; }
  .headline { font-size: clamp(38px, 11.5vw, 52px); }
  .lede { font-size: 16px; margin-top: 16px; }
  .hero { padding-bottom: 26px; }
  .is-home .stage { padding-bottom: 4vh; }
  .dock { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
  .thread { padding: 20px 14px 8px; }
  .composer { padding: 14px 12px 10px 16px; }
  .composer__hint { display: none; }
  .chip:nth-child(n + 4) { display: none; }
  .pricewave { height: 16vh; opacity: 0.6; }
  .msg--bot { grid-template-columns: 1fr; gap: 8px; }
  .msg--bot .brand__logo { width: 24px; height: 24px; }
  .limit { flex-direction: column; align-items: flex-start; gap: 10px; }
  .limit__clock { flex-direction: row; align-items: baseline; gap: 8px; }
}

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