@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=Atkinson+Hyperlegible:wght@400;700&display=swap");

:root {
  --pine: #1f2b25;
  --bark: #29372f;
  --moss: #34463b;
  --line: #43574b;
  --bone: #ede6d6;
  --mute: #a9b2a2;
  --fawn: #c9955b;
  --fawn-ink: #231a10;
  --lichen: #a7bf8e;
  --berry: #e07a6a;
  --r-sm: 6px;
  --r-lg: 18px;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --pine: #f1ece0; --bark: #e6dfcf; --moss: #d9d0bc; --line: #c3b9a2;
    --bone: #1f2b25; --mute: #5d6a5f; --fawn: #9c6a33; --fawn-ink: #fff8ee;
    --lichen: #4f6e3a; --berry: #b04637; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--pine); color: var(--bone);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fawn); outline-offset: 2px; }
a { color: var(--fawn); }

.btn {
  border: 1px solid var(--line); background: var(--bark); border-radius: var(--r-sm);
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--mute); }
a.btn { text-decoration: none; color: var(--bone); display: inline-block; }
.btn.primary { background: var(--fawn); color: var(--fawn-ink); border-color: var(--fawn); font-weight: 700; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--berry); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--pine); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; width: 100%;
}
label { display: block; font-size: 14px; color: var(--mute); margin: 12px 0 4px; }
.err { color: var(--berry); font-size: 14px; min-height: 1.4em; margin-top: 8px; }
.muted { color: var(--mute); }
.hidden { display: none !important; }

/* ------------------------------------------------------------- wordmark */
.mark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; }
.mark svg { color: var(--fawn); }

/* ------------------------------------------------------------- sign in */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.gate form { width: min(360px, 100%); }
.gate h1 { font-size: 44px; margin: 18px 0 6px; letter-spacing: -0.02em; }
.gate .switch { margin-top: 16px; font-size: 14px; }
.gate .switch button { background: none; border: 0; color: var(--fawn); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------- chat */
.app { display: grid; grid-template-columns: 272px 1fr; grid-template-rows: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
.side {
  background: var(--bark); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-height: 0; padding: 14px;
}
.side .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.side .new { width: 100%; margin-bottom: 12px; }
.convs { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0; list-style: none; }
.convs li { display: flex; align-items: center; border-radius: var(--r-sm); }
.convs li button.open {
  flex: 1; text-align: left; background: none; border: 0; padding: 8px 8px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute);
}
.convs li.active, .convs li:hover { background: var(--moss); }
.convs li.active button.open { color: var(--bone); }
.convs li .del { opacity: 0; background: none; border: 0; color: var(--mute); cursor: pointer; padding: 6px 8px; }
.convs li:hover .del, .convs li .del:focus-visible { opacity: 1; }
.side .foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.side .foot .who { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.bar .title { flex: 1; font-family: var(--display); font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }

.models-pop {
  position: absolute; right: 16px; top: 58px; z-index: 20; width: min(320px, calc(100vw - 32px));
  background: var(--bark); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 16px 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

.feed { flex: 1; overflow-y: auto; padding: 24px 16px 12px; }
.feed-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 88%; }
.msg.user { align-self: flex-end; }
.msg .bubble { padding: 10px 14px; border-radius: var(--r-lg); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--moss); border-bottom-right-radius: var(--r-sm); }
.msg.assistant .bubble { padding-left: 0; }
.msg .tag { font-size: 13px; color: var(--mute); margin-bottom: 4px; }
.msg.user .tag { text-align: right; }
.msg img.upload { max-width: 280px; width: 100%; border-radius: var(--r-lg); display: block; }
.gen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gen-grid figure { margin: 0; }
.gen-grid img { width: 100%; aspect-ratio: 1; border-radius: var(--r-sm); display: block; background: var(--bark); }
.gen-grid figcaption { font-size: 13px; color: var(--mute); margin-top: 2px; }
.note { font-size: 14px; color: var(--mute); margin-top: 6px; }

.analysis { display: grid; gap: 12px; }
.pred { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 48px; gap: 10px; align-items: center; font-size: 15px; }
.pred .track { height: 8px; background: var(--moss); border-radius: 4px; overflow: hidden; }
.pred .fill { height: 100%; background: var(--lichen); }
.pred .pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--mute); }
.pred.top { font-weight: 700; }
.pred.top .fill { background: var(--fawn); }
.swatches { display: flex; height: 26px; border-radius: var(--r-sm); overflow: hidden; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px 16px; font-size: 14px; }
.facts b { font-weight: 700; display: block; font-size: 15px; }

.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 20px; }
.empty h1 { font-size: clamp(48px, 10vw, 88px); letter-spacing: -0.035em; line-height: .95; }
.empty p { color: var(--mute); max-width: 42ch; margin: 14px auto 0; }

.composer { padding: 8px 16px max(16px, env(safe-area-inset-bottom)); }
.composer form {
  max-width: 760px; margin: 0 auto; background: var(--bark); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 8px; display: flex; gap: 6px; align-items: flex-end;
}
.composer form.imagine { border-color: var(--fawn); }
.composer textarea { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; max-height: 200px; padding: 9px 6px; }
.composer textarea:focus-visible { outline: none; }
.composer .mode { font-size: 14px; padding: 8px 10px; }
.composer .mode[aria-pressed=true] { background: var(--fawn); color: var(--fawn-ink); border-color: var(--fawn); }
.composer .hint { max-width: 760px; margin: 6px auto 0; font-size: 13px; color: var(--mute); padding: 0 8px; }
.typing { color: var(--mute); }
.typing::after { content: "…"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 760px) {
  .composer .mode { padding: 8px; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .menu-btn { display: grid; }
  .convs li .del { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --------------------------------------------------------------- admin */
.admin { max-width: 1180px; margin: 0 auto; padding: 16px 20px 60px; }
.admin header { display: flex; align-items: center; gap: 16px; padding: 6px 0 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin header .mark { font-size: 20px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; color: var(--mute); }
.tabs button[aria-selected=true] { color: var(--bone); background: var(--bark); }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; margin-top: 20px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.panel { background: var(--bark); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.panel h2 { font-size: 22px; margin-bottom: 4px; }
.panel + .panel { margin-top: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; background: none; border: 0; padding: 12px 6px; cursor: pointer; border-radius: var(--r-sm); }
.row:hover, .row.sel { background: var(--moss); }
.row .name { font-weight: 700; }
.row .sub { font-size: 14px; color: var(--mute); grid-column: 1 / -1; }
.chip { font-size: 13px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--mute); }
.chip.training, .chip.queued { color: var(--lichen); border-color: var(--lichen); }
.chip.ready { color: var(--bone); border-color: var(--mute); }
.chip.error { color: var(--berry); border-color: var(--berry); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 14px 0; }
.stats div { font-size: 14px; color: var(--mute); }
.stats b { display: block; font-size: 22px; color: var(--bone); font-family: var(--display); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; height: 220px; margin-top: 8px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.progress { height: 6px; background: var(--moss); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--lichen); transition: width .4s; }
.sample { background: var(--pine); border-radius: var(--r-sm); padding: 12px; white-space: pre-wrap; font-size: 15px; margin-top: 8px; min-height: 48px; overflow-wrap: anywhere; }
.sample img { max-width: 100%; image-rendering: pixelated; border-radius: var(--r-sm); }
details summary { cursor: pointer; color: var(--mute); margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
td, th { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--mute); font-weight: 400; font-size: 14px; }
.toggle { display: flex; align-items: center; gap: 10px; color: var(--bone); font-size: 15px; margin: 0; }
.toggle input { width: 18px; height: 18px; accent-color: var(--fawn); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bone); color: var(--pine); padding: 10px 16px; border-radius: var(--r-sm); z-index: 99; max-width: calc(100vw - 40px); }

/* --------------------------------------------------------------- plans */
.plans-page { max-width: 1040px; margin: 0 auto; padding: 16px 20px 60px; }
.plans-page header { display: flex; align-items: center; gap: 12px; padding: 6px 0 16px; }
.plans-page header .mark { flex: 1; font-size: 20px; }
.plans-page h1 { font-size: clamp(34px, 6vw, 52px); letter-spacing: -0.02em; margin: 12px 0 6px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-top: 14px; }
.meter .lbl { display: flex; justify-content: space-between; font-size: 14px; color: var(--mute); }
.meter .lbl b { color: var(--bone); font-weight: 700; }
.meter .track { height: 8px; background: var(--moss); border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.meter .fill { height: 100%; background: var(--lichen); }
.meter .fill.full { background: var(--berry); }
.meter .when { font-size: 13px; color: var(--mute); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 24px; align-items: stretch; }
.plan { background: var(--bark); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; display: flex; flex-direction: column; }
.plan.current { border-color: var(--fawn); border-width: 2px; }
.plan h2 { font-size: 26px; }
.plan .price { font-family: var(--display); font-size: 40px; font-weight: 700; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 16px; font-weight: 500; color: var(--mute); font-family: var(--body); }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; flex: 1; }
.plan li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 15px; }
.plan .pp { min-height: 45px; }
.banner { max-width: 760px; margin: 0 auto 8px; background: var(--bark); border: 1px solid var(--fawn); border-radius: var(--r-sm); padding: 10px 14px; font-size: 15px; display: flex; gap: 12px; align-items: center; }
.banner span { flex: 1; }
.plan-link { font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--mute); }
.plan-edit { display: grid; grid-template-columns: 1.4fr .8fr .9fr .9fr .9fr .9fr auto; gap: 8px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
.plan-edit label { margin-top: 0; font-size: 13px; }
@media (max-width: 860px) { .plan-edit { grid-template-columns: 1fr 1fr; } }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: var(--pine); padding: 8px 10px; border-radius: var(--r-sm); overflow-wrap: anywhere; display: block; margin-top: 6px; }
