/* Wyana AI Console
 *
 * An operations console, not a document: scanned and operated rather than read. So state is
 * encoded in shape as well as in words — a status pill reads before its label does — and
 * semantic colour (ok / warn / bad) is kept separate from the accent, which means "this is
 * interactive" and nothing else.
 *
 * System fonts on purpose. The box this runs on may have no outbound internet, and a
 * webfont that fails to load is a console that renders wrong exactly when you need it.
 */

:root {
  --ground: #f6f7f8;
  --surface: #ffffff;
  --sunken: #eef0f2;
  --ink: #131719;
  --muted: #5b656b;
  --faint: #8b959b;
  --rule: #dfe3e6;
  --rule-strong: #c6ccd1;

  --accent: #10656b;
  --accent-soft: #dcecec;
  --accent-ink: #0a4b50;
  --on-accent: #ffffff;

  --ok: #1a7040;
  --ok-soft: #dcefe2;
  --warn: #8a5a08;
  --warn-soft: #f7ebd4;
  --bad: #a03027;
  --bad-soft: #f8e3e1;
  --idle-soft: #e6e9eb;

  --shadow: 0 1px 2px rgba(19, 23, 25, .06), 0 4px 12px rgba(19, 23, 25, .04);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --rail: 216px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0e1214;
    --surface: #161b1e;
    --sunken: #111618;
    --ink: #e6ebed;
    --muted: #9aa5ab;
    --faint: #78848a;
    --rule: #262e32;
    --rule-strong: #38434a;

    --accent: #4fb3ac;
    --accent-soft: #14312f;
    --accent-ink: #7fd0c8;
    --on-accent: #06201f;

    --ok: #5cc08a;
    --ok-soft: #14281c;
    --warn: #d8a355;
    --warn-soft: #2b2213;
    --bad: #e5796c;
    --bad-soft: #2e1a18;
    --idle-soft: #1d2427;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #0e1214;
  --surface: #161b1e;
  --sunken: #111618;
  --ink: #e6ebed;
  --muted: #9aa5ab;
  --faint: #78848a;
  --rule: #262e32;
  --rule-strong: #38434a;
  --accent: #4fb3ac;
  --accent-soft: #14312f;
  --accent-ink: #7fd0c8;
  --on-accent: #06201f;
  --ok: #5cc08a;
  --ok-soft: #14281c;
  --warn: #d8a355;
  --warn-soft: #2b2213;
  --bad: #e5796c;
  --bad-soft: #2e1a18;
  --idle-soft: #1d2427;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

#root.loading {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--faint);
}

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 18px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.brand span.mark { color: var(--accent); font-size: 17px; }

.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.rail a:hover { background: var(--sunken); color: var(--ink); }
.rail a.on { background: var(--accent-soft); color: var(--accent-ink); }
.rail a .glyph { width: 16px; text-align: center; opacity: .8; }

.rail .foot {
  margin-top: auto;
  padding: 12px 9px 0;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--faint);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail .foot button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--faint);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.rail .foot button:hover { color: var(--ink); }

main { padding: 26px 30px 72px; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
h1 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 3px; }
.page-head p { margin: 0; color: var(--muted); max-width: 62ch; }

h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 10px; }
h3 {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 9px;
}

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 9px;
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card > h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
@media (min-width: 1100px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1240px) { .grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 14px 8px 4px;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
td { padding: 9px 14px 9px 4px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--sunken); }
td.num { font-variant-numeric: tabular-nums; text-align: right; padding-right: 18px; }
th.num { text-align: right; padding-right: 18px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.truncate { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--idle-soft);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: currentColor;
  opacity: .75;
}
.pill.plain::before { display: none; }

/* ---------- forms ---------- */

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.hint { font-size: 12px; font-weight: 400; color: var(--faint); }
label .hint { display: block; margin-top: 3px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
textarea.code { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field { margin-bottom: 14px; }
.fields { display: grid; gap: 14px; }
@media (min-width: 780px) { .fields.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .fields.three { grid-template-columns: 1fr 1fr 1fr; } }

button {
  font: inherit;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--faint); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: var(--rule-strong); }
button.danger:hover { border-color: var(--bad); }
button.ghost { border-color: transparent; background: none; color: var(--muted); padding: 5px 8px; }
button.ghost:hover { background: var(--sunken); color: var(--ink); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 4px 9px; font-size: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- misc ---------- */

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--faint);
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
}
.empty strong { display: block; color: var(--muted); margin-bottom: 4px; }

pre.block {
  background: var(--sunken);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
pre.block.tall { max-height: 380px; overflow-y: auto; }

.card:empty { display: none; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 11px 15px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--ground);
  box-shadow: var(--shadow);
  max-width: 460px;
  z-index: 50;
}
.toast.bad { background: var(--bad); color: #fff; }

.meter { display: flex; align-items: baseline; gap: 7px; }
.meter b { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.meter span { font-size: 12px; color: var(--faint); }

.stats { display: flex; gap: 26px; flex-wrap: wrap; }

/* ---------- gate (api key) ---------- */

.gate { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.gate .card { width: min(420px, 100%); }
.gate h1 { margin-bottom: 6px; }
.gate p { color: var(--muted); margin: 0 0 18px; }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 12px; white-space: pre-wrap; }
.bubble.customer { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.bubble.agent { align-self: flex-start; background: var(--sunken); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.bubble.system { align-self: center; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; max-width: 100%; }

.composer { display: flex; gap: 9px; margin-top: 14px; }
.composer input { flex: 1; }

.trace-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.trace-line:last-child { border-bottom: 0; }
.trace-line .score { font-family: var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }

/* What the model was sent. One ruled block per message, with the role and its position in the
 * gutter: this is scanned for the message that explains the reply, not read top to bottom. */
.sent-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.sent-head h2 { margin: 0 0 4px; }
.sent-note { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 68ch; }
.sent-msg { border-top: 1px solid var(--rule); margin-top: 13px; padding-top: 13px; }
details.sent-msg[open] summary { margin-bottom: 0; }
.sent-msg > * + * { margin-top: 8px; }
.sent-role { display: flex; align-items: center; gap: 8px; }
.sent-index { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.sent-aside {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.sent-id { font-family: var(--mono); font-size: 11px; color: var(--faint); }

details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; }
details summary:hover { color: var(--ink); }
details[open] summary { margin-bottom: 8px; }

.list-reset { list-style: none; margin: 0; padding: 0; }

a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* Documentation ---------------------------------------------------------------
 *
 * The one screen in here that is read rather than operated, so it gets what an operations
 * table deliberately does not: a measure, a line height, and room between paragraphs.
 */

.docs-search {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.docs-search input { max-width: 380px; }
.docs-count { color: var(--faint); font-size: 12px; }

.docs { display: grid; gap: 16px; align-items: start; }
/* One column: the contents list is more use above the prose than below it. */
.docs-side { order: -1; }
@media (min-width: 1100px) {
  .docs { grid-template-columns: minmax(0, 1fr) 232px; gap: 26px; }
  .docs-body { grid-column: 1; }
  .docs-side { grid-column: 2; order: 0; position: sticky; top: 26px; }
}

.docs-toc { display: flex; flex-direction: column; gap: 1px; }
.docs-toc strong {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 7px;
}
.docs-toc-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  border-left: 2px solid transparent;
}
.docs-toc-link:hover { background: var(--sunken); color: var(--ink); }
.docs-toc-link.on {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}

.docs-section { scroll-margin-top: 20px; }
.docs-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.docs-section-head h2 { margin: 0; display: flex; align-items: center; gap: 9px; }
.docs-section-head button { opacity: 0; }
.docs-section:hover .docs-section-head button,
.docs-section-head button:focus-visible { opacity: 1; }
.docs-glyph { color: var(--accent); font-size: 13px; width: 1em; text-align: center; }
.docs-blurb { color: var(--muted); font-size: 13px; margin: 5px 0 0; }

.docs-article { border-top: 1px solid var(--rule); margin-top: 18px; padding-top: 16px; }
.docs-article h3 {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 10px;
}
.docs-article > *:last-child { margin-bottom: 0; }

.prose { max-width: 82ch; margin: 0 0 12px; line-height: 1.62; font-size: 13.5px; color: var(--ink); }
.prose-list {
  max-width: 82ch;
  margin: 0 0 12px;
  padding-left: 20px;
  line-height: 1.62;
  font-size: 13.5px;
}
.prose-list li { margin-bottom: 7px; }
.prose-list li::marker { color: var(--faint); }
.prose code, .prose-list code, .note code, .docs-table code { background: var(--sunken); border-radius: 4px; padding: 1px 4px; }

.docs-article pre.block { margin: 0 0 14px; }

.note {
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 0 6px 6px 0;
  padding: 11px 14px;
  margin: 0 0 14px;
  max-width: 82ch;
  font-size: 13px;
  line-height: 1.55;
}
.note code { background: rgba(0, 0, 0, .07); }
/* The few places where getting it wrong costs something: a live connection, an approval
   that runs as the agent, a user with more rights than the agent needs. */
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

.docs-table { margin-bottom: 14px; }
.docs-table td { line-height: 1.5; font-size: 13px; }
.docs-table tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; }
  .rail nav { flex-direction: row; }
  .rail .brand { padding: 0 10px 0 0; }
  .rail .foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  main { padding: 18px; }
}

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