/* WIIT LLMaaS — one stylesheet for every page. No framework, no build step.
   Two themes built from the same tokens: a warm off-white light theme and a
   dark-grey one, both with muted pastel accents (dusty periwinkle, sage,
   terracotta). The theme follows the OS until the viewer picks one with the
   toggle in the top-right corner; that choice is stored in localStorage and
   applied as <html data-theme="light|dark"> by a tiny inline script in each
   page's <head>, before first paint, so there is no flash of the wrong theme.

   Every colour lives in a token below. If you find yourself writing a hex
   value further down this file, add a token instead — otherwise it will be
   wrong in one of the two themes. */

:root {
  color-scheme: light;

  --bg: #faf9f7;                   /* the working surface */
  --rail: #f3f1ed;                 /* warm off-white sidebar */
  --sunk: #ebe8e3;
  --panel: #ffffff;
  --raised: #ffffff;               /* active nav item, lifted off the rail */

  --ink: #2a2a2e;
  --ink-2: #505058;
  --muted: #83838c;
  --faint: #aeadb4;

  --line: #ebe8e3;
  --line-2: #dedad4;

  --accent: #7f82bd;               /* dusty periwinkle */
  --accent-strong: #6d70ab;
  --accent-deep: #55588f;
  --accent-ink: #ffffff;
  --accent-soft: #efeff8;
  --accent-line: #d9daef;
  --accent-glow: rgba(127, 130, 189, 0.20);

  --danger: #b0605a;               /* muted terracotta */
  --danger-soft: #f8ecea;
  --danger-line: #ecd2ce;
  --danger-ink: #8a3f39;
  --ok: #5a8570;                   /* sage */
  --ok-soft: #e7f0eb;

  --me-bubble: #f0eff6;            /* the user's own turns: a lavender tint */

  --mark-grad: linear-gradient(140deg, #cbc8f0 0%, #e8d0e2 55%, #f5dac8 100%);
  --mark-ink: #3b3950;

  --shadow-sm: 0 1px 2px rgba(40, 36, 30, 0.04);
  --shadow: 0 1px 3px rgba(40, 36, 30, 0.05), 0 10px 30px rgba(40, 36, 30, 0.05);
  --shadow-lg: 0 2px 6px rgba(40, 36, 30, 0.05), 0 20px 48px rgba(40, 36, 30, 0.08);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-pill: 999px;

  --rail-w: 256px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

/* Dark grey, not black: #1e1e21 keeps the pastels soft instead of glowing. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #1e1e21;
    --rail: #19191b;
    --sunk: #2a2a2e;
    --panel: #242427;
    --raised: #2c2c31;

    --ink: #ebe9e6;
    --ink-2: #c4c2c8;
    --muted: #8f8e96;
    --faint: #67666e;

    --line: #2d2d32;
    --line-2: #3a3a40;

    --accent: #a9acdf;
    --accent-strong: #babdea;
    --accent-deep: #c9cbf0;
    --accent-ink: #1c1c24;
    --accent-soft: #2b2c3a;
    --accent-line: #3e405c;
    --accent-glow: rgba(169, 172, 223, 0.16);

    --danger: #de9790;
    --danger-soft: #362526;
    --danger-line: #553433;
    --danger-ink: #f0bab4;
    --ok: #9cc5ad;
    --ok-soft: #233029;

    --me-bubble: #2c2c35;

    --mark-grad: linear-gradient(140deg, #b9b6e4 0%, #d9bfd2 55%, #e6c8b6 100%);
    --mark-ink: #2a2838;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.22);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.35);
  }
}

/* The same dark block again, for an explicit choice. Kept byte-identical to
   the one above; CSS has no way to share a block between a media query and a
   selector without a build step. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #1e1e21;
  --rail: #19191b;
  --sunk: #2a2a2e;
  --panel: #242427;
  --raised: #2c2c31;

  --ink: #ebe9e6;
  --ink-2: #c4c2c8;
  --muted: #8f8e96;
  --faint: #67666e;

  --line: #2d2d32;
  --line-2: #3a3a40;

  --accent: #a9acdf;
  --accent-strong: #babdea;
  --accent-deep: #c9cbf0;
  --accent-ink: #1c1c24;
  --accent-soft: #2b2c3a;
  --accent-line: #3e405c;
  --accent-glow: rgba(169, 172, 223, 0.16);

  --danger: #de9790;
  --danger-soft: #362526;
  --danger-line: #553433;
  --danger-ink: #f0bab4;
  --ok: #9cc5ad;
  --ok-soft: #233029;

  --me-bubble: #2c2c35;

  --mark-grad: linear-gradient(140deg, #b9b6e4 0%, #d9bfd2 55%, #e6c8b6 100%);
  --mark-ink: #2a2838;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  overflow: hidden;                /* each pane scrolls on its own */
}
a { color: var(--accent-strong); text-underline-offset: 2px; }
::selection { background: var(--accent-line); }

/* ======================================================================
   The mark: a pastel tile with a soft four-point star. No letter.
   ====================================================================== */

.mark, .mark-lg, .turn.bot .avatar {
  display: grid; place-items: center;
  background: var(--mark-grad);
  color: var(--mark-ink);
  flex: 0 0 auto;
}
.mark svg, .mark-lg svg, .turn.bot .avatar svg { width: 58%; height: 58%; display: block; }

/* ======================================================================
   The rail: brand, tabs, conversations, account
   ====================================================================== */

.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100dvh;
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  gap: 16px;
}

.rail-head { display: flex; align-items: center; gap: 9px; padding: 2px 6px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-size: 14.5px; letter-spacing: -0.01em; white-space: nowrap;
}
.brand .mark { width: 28px; height: 28px; border-radius: 9px; }
.brand b { font-weight: 620; }
.brand .name { font-weight: 420; color: var(--ink-2); }

.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none; color: var(--muted);
  cursor: pointer; font-size: 15px;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); border-color: transparent; }
.icon-btn svg { width: 16px; height: 16px; display: block; }

/* The theme toggle. In a pane head it sits at the far right; on the login
   page, which has no pane head, it floats in the viewport's corner. */
.theme-btn { margin-left: auto; }
.theme-btn.floating { position: fixed; top: 14px; right: 16px; z-index: 30; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: none; }
}

/* Primary nav — Chat / API keys / Usage */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 480;
  color: var(--ink-2); text-decoration: none;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.nav a:hover { background: var(--sunk); color: var(--ink); }
.nav a[aria-current="page"] {
  background: var(--raised);
  color: var(--ink);
  font-weight: 560;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}
.nav a[aria-current="page"] .ico { color: var(--accent); opacity: 1; }
.nav .ico { display: grid; place-items: center; width: 16px; flex: 0 0 16px; opacity: 0.75; }
.nav .ico svg { width: 16px; height: 16px; display: block; }

.rail-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint);
  padding: 0 11px; margin-bottom: 6px;
}

/* Conversation list */
.chats { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; min-height: 0; }
.chats .none { color: var(--faint); font-size: 13px; padding: 6px 11px; }
.chat-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background 0.14s, color 0.14s;
}
.chat-item:hover { background: var(--sunk); }
.chat-item.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 540; }
.chat-item .t {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item .x {
  flex: 0 0 auto; opacity: 0;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1;
  padding: 3px 6px; border-radius: 7px;
}
.chat-item:hover .x { opacity: 1; }
.chat-item .x:hover { background: var(--danger-soft); color: var(--danger); }

.rail-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex; align-items: center; gap: 9px;
}
.avatar-sm {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 620;
  text-transform: uppercase;
}
.rail-foot .who {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ======================================================================
   The working pane
   ====================================================================== */

.pane {
  flex: 1; min-width: 0;
  height: 100dvh;
  display: flex; flex-direction: column;
}

.pane-head {
  flex: 0 0 auto;
  height: 56px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.pane-head h1 {
  font-size: 14.5px; font-weight: 580; letter-spacing: -0.005em;
  margin: 0; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pane-head .doc { color: var(--faint); font-size: 13px; white-space: nowrap; }
.spacer { flex: 1; }

.scroll { flex: 1; overflow-y: auto; min-height: 0; }
.sheet { max-width: 780px; margin: 0 auto; padding: 34px 24px 40px; }
.sheet.wide { max-width: 940px; }

/* ======================================================================
   Buttons, controls
   ====================================================================== */

button {
  font: inherit; font-weight: 540; cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink-2);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
button:hover:not(:disabled) { border-color: var(--faint); color: var(--ink); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 2px var(--accent-glow), 0 4px 14px var(--accent-glow);
}
button.primary:hover:not(:disabled) {
  background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink);
}
button.ghost { border-color: transparent; background: none; color: var(--muted); padding: 6px 10px; }
button.ghost:hover:not(:disabled) { background: var(--sunk); color: var(--ink); border-color: transparent; }
button.danger { color: var(--danger); }
button.danger:hover:not(:disabled) {
  background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger);
}
button.tiny { padding: 5px 12px; font-size: 13px; }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select option { background: var(--panel); color: var(--ink); }
label { display: block; font-size: 12.5px; font-weight: 580; color: var(--ink-2); margin-bottom: 6px; }
label .note { display: block; font-weight: 420; color: var(--faint); margin-top: 3px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }

/* ======================================================================
   Page furniture
   ====================================================================== */

h1.page { font-size: 24px; font-weight: 620; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 11.5px; font-weight: 600; color: var(--muted); margin: 34px 0 12px;
     text-transform: uppercase; letter-spacing: 0.08em; }
p.sub { color: var(--muted); margin: 0 0 24px; max-width: 68ch; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }
.card.flush { padding: 4px 22px; }
.card.accent { border-color: var(--accent-line); background: var(--accent-soft); }

code, .mono { font-family: var(--mono); font-size: 13px; }

/* Copyable code, e.g. the API example on the Keys page. Scrolls sideways on
   a phone instead of widening the page. */
pre.snippet {
  margin: 8px 0 0; padding: 12px 14px;
  background: var(--sunk); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  overflow-x: auto; white-space: pre;
}

.pill {
  display: inline-block; padding: 2px 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 560;
  background: var(--sunk); color: var(--muted);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--danger-soft); color: var(--danger); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 8px; border-bottom: 1px solid var(--line); }
tbody:not(:empty):last-of-type tr:last-child td { border-bottom: none; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase;
     letter-spacing: 0.08em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot th { border-top: 1px solid var(--line-2); border-bottom: none;
           color: var(--ink); font-size: 13px; text-transform: none; letter-spacing: 0; }
tr.revoked td { opacity: 0.45; }

.banner {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--panel);
  border-radius: var(--r);
  padding: 12px 16px; margin-bottom: 18px;
  font-size: 13.5px; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.banner.warn { border-left-color: var(--danger); }
.banner.good { border-left-color: var(--ok); }
.hidden { display: none !important; }
.empty { color: var(--muted); padding: 30px 4px; text-align: center; font-size: 14px; }

/* ======================================================================
   Chat
   ====================================================================== */

.thread { max-width: 720px; margin: 0 auto; padding: 28px 24px 10px; }

.turn { margin-bottom: 28px; }
.turn.me { display: flex; justify-content: flex-end; }
.turn.me .bubble {
  background: var(--me-bubble);
  border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg);
  padding: 11px 17px;
  max-width: 82%;
}
.turn.bot { display: flex; gap: 14px; }
.turn.bot .avatar {
  width: 28px; height: 28px; border-radius: 9px; margin-top: 1px;
}
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.turn.bot .bubble { flex: 1; padding-top: 2px; }
.turn.oops { display: flex; gap: 14px; }
.turn.oops .bubble {
  flex: 1; background: var(--danger-soft); border: 1px solid var(--danger-line);
  color: var(--danger-ink); border-radius: var(--r); padding: 12px 16px;
}
.meta { color: var(--faint); font-size: 12px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.typing::after {
  content: ""; display: inline-block;
  width: 8px; height: 8px; margin-left: 2px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.welcome { text-align: center; padding: 13vh 10px 0; }
.welcome .mark-lg {
  width: 52px; height: 52px; margin: 0 auto 20px;
  border-radius: 16px;
  box-shadow: 0 6px 24px var(--accent-glow);
}
.welcome h2 {
  font-size: 26px; font-weight: 600; letter-spacing: -0.025em;
  color: var(--ink); margin: 0 0 8px; text-transform: none;
}
.welcome p { color: var(--muted); margin: 0 auto; max-width: 44ch; }

/* Composer — text on top, controls beneath. */
.dock { flex: 0 0 auto; padding: 0 24px 18px; background: var(--bg); }
.composer { max-width: 720px; margin: 0 auto; }
.inputwrap {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  padding: 14px 14px 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inputwrap:focus-within {
  border-color: var(--accent-line);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-glow);
}
.inputwrap textarea {
  width: 100%; border: none; background: none; padding: 0 4px;
  resize: none; max-height: 32vh; min-height: 26px; line-height: 1.55;
}
.inputwrap textarea:focus { outline: none; box-shadow: none; }

.tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* Model picker, in the composer where the choice is made */
.picker { position: relative; display: inline-flex; align-items: center; }
.picker select {
  appearance: none;
  border: 1px solid transparent;
  background: none;
  border-radius: var(--r-pill);
  padding: 5px 26px 5px 11px;
  font-size: 13px; font-weight: 580;
  color: var(--ink-2);
  cursor: pointer;
}
.picker select:hover { background: var(--sunk); }
.picker select:focus { box-shadow: none; border-color: var(--accent-line); }
.picker::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.mini { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 480; color: var(--muted); margin: 0; }
.mini input[type="number"] { width: 70px; padding: 4px 9px; border-radius: var(--r-pill); font-size: 12.5px; background: var(--bg); }
.mini select { padding: 4px 9px; border-radius: var(--r-pill); font-size: 12.5px; background: var(--bg); }

.send {
  width: 34px; height: 34px; padding: 0; flex: 0 0 auto;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 16px; line-height: 1;
}
.hint { text-align: center; color: var(--faint); font-size: 12px; margin: 9px 0 0; }

/* Developer note. One per page, at the very bottom: what this screen actually
   does, at a technical level, for whoever is reading the code next. Small and
   faint on purpose — it is a footnote, not part of the product surface, and it
   must never compete with the page's real content. */
.devnote {
  max-width: 720px;
  margin: 34px auto 20px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.65;
}
.devnote b { color: var(--muted); font-weight: 600; }
.devnote code { font-size: 11px; color: var(--muted); }

/* ======================================================================
   Login (no rail)
   ====================================================================== */

body.plain {
  display: grid; place-items: center; overflow: auto;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, var(--accent-soft), transparent 70%),
    var(--rail);
}
.loginbox { width: 100%; max-width: 384px; padding: 24px; }
.loginbox .brand { justify-content: center; margin-bottom: 24px; font-size: 16px; }
.loginbox .brand .mark { width: 34px; height: 34px; border-radius: 11px; }
.loginbox .card { padding: 28px; box-shadow: var(--shadow-lg); }
.loginbox input { width: 100%; }
.loginbox h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; text-align: center; margin: 0 0 4px; }
.loginbox p.sub { text-align: center; font-size: 13.5px; margin-bottom: 22px; }

/* ======================================================================
   Narrow screens: the rail collapses to a top strip
   ====================================================================== */

@media (max-width: 860px) {
  body { flex-direction: column; overflow: auto; }
  .rail {
    flex: 0 0 auto; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 10px;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    position: sticky; top: 0; z-index: 20;
  }
  .rail-head { padding: 0; }
  .brand .name { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 7px 12px; font-size: 13.5px; }
  .nav .ico { display: none; }
  .rail-label, .chats, .rail-foot .who { display: none; }
  .rail-foot { border-top: none; padding-top: 0; margin-left: auto; }
  .pane { height: auto; min-height: calc(100dvh - 58px); }
  .pane-head { padding: 0 10px 0 16px; }
  .pane-head .doc { display: none; }
  .sheet { padding: 22px 16px 40px; }
  .thread { padding: 20px 16px 10px; }
  .dock { padding: 0 16px 14px; position: sticky; bottom: 0; }
  .turn.me .bubble { max-width: 90%; }
  .mini.optional { display: none; }
}
