/* VCS NTQ Co-Pilot — house style.

   Adopts the design language of the Bixby operations-dashboard and MRP projects:
   oklch slate-blue neutrals, a single indigo accent, 0.625rem panel radii,
   Archivo for UI and JetBrains Mono for every figure, tag name and timestamp.

   Semantic tokens only — nothing below names a raw colour, so retheming touches
   the two blocks at the top and nothing else. Theme is driven by .dark on
   <html>, same as both Bixby apps. */

:root {
  /* Native chrome — scrollbars, form controls — follows this, not the tokens. */
  color-scheme: light;

  --canvas: oklch(98.5% 0.003 250);
  --surface: oklch(100% 0 0);
  --surface-raised: oklch(97% 0.004 250);
  --surface-sunken: oklch(95.5% 0.006 250);
  --line: oklch(90% 0.008 250);
  --line-strong: oklch(83% 0.012 250);

  --ink: oklch(21% 0.02 255);
  --ink-muted: oklch(48% 0.018 255);
  --ink-faint: oklch(62% 0.015 255);

  --accent: oklch(52% 0.19 277);
  --accent-soft: oklch(94% 0.035 277);
  --accent-ink: oklch(100% 0 0);

  --ok: oklch(58% 0.11 178);
  --warn: oklch(64% 0.14 68);
  --critical: oklch(56% 0.2 22);
  --critical-soft: oklch(95% 0.04 22);

  --shadow: 0 1px 2px oklch(21% 0.02 255 / 6%), 0 8px 24px oklch(21% 0.02 255 / 5%);
  --shadow-lg: 0 24px 60px oklch(21% 0.02 255 / 14%);

  --radius: 0.625rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.875rem;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html.dark {
  color-scheme: dark;

  --canvas: oklch(16.5% 0.014 258);
  --surface: oklch(20.5% 0.016 258);
  --surface-raised: oklch(24% 0.018 258);
  --surface-sunken: oklch(18% 0.015 258);
  --line: oklch(29% 0.018 258);
  --line-strong: oklch(38% 0.022 258);

  --ink: oklch(96% 0.005 250);
  --ink-muted: oklch(72% 0.018 255);
  --ink-faint: oklch(58% 0.018 255);

  --accent: oklch(72% 0.15 277);
  --accent-soft: oklch(30% 0.06 277);
  --accent-ink: oklch(17% 0.02 277);

  --ok: oklch(76% 0.13 178);
  --warn: oklch(78% 0.15 72);
  --critical: oklch(69% 0.19 20);
  --critical-soft: oklch(31% 0.08 20);

  --shadow: 0 1px 2px oklch(0% 0 0 / 30%), 0 8px 24px oklch(0% 0 0 / 26%);
  --shadow-lg: 0 24px 70px oklch(0% 0 0 / 55%);
}

/* --------------------------------------------------------------- base */

* { box-sizing: border-box; border-color: var(--line); }
/* Belt and braces: no image may exceed its container, whatever else happens. */
img { max-width: 100%; height: auto; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Figures never reflow as they change. */
  font-variant-numeric: tabular-nums;
  transition: background-color .25s var(--ease), color .25s var(--ease);
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* Wide-tracked section labels, lifted from the operations dashboard. */
.eyebrow {
  font-size: 0.6875rem;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}

/* Tag names, values, timestamps — anything that must align in a column. */
code, .mono {
  font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* -------------------------------------------------------------- login */

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute;
  inset: -40% 40% 55% -25%;
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 62%);
  opacity: .10;
  pointer-events: none;
}
html.dark .login-page::before { opacity: .18; }

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 34px 30px 28px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  margin: 0 0 3px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.login-card .sub { margin: 0 0 26px; color: var(--ink-muted); font-size: 13px; }

.mark {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  margin-bottom: 18px;
  padding: 8px;
  /* A white tile, not the accent. The mark is navy + blue, which all but
     disappears against the dark canvas, and tinting brand colours is worse than
     giving them a surface to sit on. */
  background: #fff;
  border: 1px solid var(--line);
}
.mark img { width: 100%; height: auto; display: block; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--canvas);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  width: 100%;
  margin-top: 6px;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: filter .15s, transform .06s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.login-err {
  display: none;
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--critical-soft);
  border: 1px solid var(--critical);
  color: var(--critical);
}
.login-err.on { display: block; }

.login-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}
.login-hint code {
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.theme-float { position: absolute; top: 20px; right: 20px; z-index: 5; }

/* ---------------------------------------------------------------- app */

.app { display: flex; height: 100dvh; overflow: hidden; }

aside {
  width: 268px;
  flex: 0 0 268px;
  background: var(--surface-sunken);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: margin-left .26s var(--ease);
}
aside.collapsed { margin-left: -268px; }

.side-head {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.side-head span {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}
.newchat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.newchat:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.newchat svg { width: 12px; height: 12px; }

.side-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.side-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12.5px;
}

.conv {
  position: relative;
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  transition: background .13s;
}
.conv:hover { background: var(--surface-raised); }
.conv.active { background: var(--surface); }
.conv.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}
.conv .t {
  font-size: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv.active .t { color: var(--ink); font-weight: 550; }
.conv .d {
  margin-top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

.side-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 27px; height: 27px;
  flex: 0 0 27px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.side-foot .who { flex: 1; font-size: 12.5px; font-weight: 550; }
.side-foot .who small {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.icon-btn {
  width: 30px; height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-faint);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-raised); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ main col */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header {
  flex: 0 0 auto;
  padding: 11px 18px;
  padding-top: calc(11px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 11px;
}
.badge-ai {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
}
.badge-ai img { width: 100%; height: auto; display: block; }

.title { flex: 1; min-width: 0; }
.title h1 {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.title p {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dot-ok {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
  vertical-align: middle;
}
.dot-bad { background: var(--critical); }

.site-sel {
  padding: 7px 11px;
  max-width: 190px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 12.5px;
  font-weight: 500;
}

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

.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 880px; margin: 0 auto; padding: 26px 22px 10px; }

.hero { padding: 28px 2px 8px; animation: rise .4s var(--ease) both; }
.hero h2 {
  margin: 0 0 7px;
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.035em;
}
.hero p {
  margin: 0 0 24px;
  max-width: 62ch;
  color: var(--ink-muted);
  font-size: 14px;
}

.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 9px; }
.chip {
  text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.chip:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.chip b { display: block; font-size: 13.5px; font-weight: 550; line-height: 1.45; }
.chip i {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
}

.msg { display: flex; margin-bottom: 20px; animation: rise .3s var(--ease) both; }
.msg.user { justify-content: flex-end; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.bubble {
  max-width: min(100%, 740px);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble ol, .bubble ul { margin: 0 0 10px; padding-left: 20px; }
.bubble li { margin: 5px 0; }
/* Bullets and text under a numbered step sit inside it. */
.bubble li > ul { margin: 5px 0 8px; padding-left: 18px; }
.bubble li > p { margin: 5px 0; }
.bubble ol > li { margin-bottom: 9px; }
.bubble strong { font-weight: 650; }
.bubble code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-sunken);
  font-size: 12.5px;
  color: var(--ink);
}
.msg.user .bubble code {
  background: oklch(100% 0 0 / 16%);
  border-color: oklch(100% 0 0 / 22%);
  color: var(--accent-ink);
}

.figs { display: grid; gap: 9px; margin: 13px 0 3px; align-items: start; }
.figs.two { grid-template-columns: 1fr 1fr; }
figure.fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-sunken);
}
/* Screenshots vary wildly in aspect ratio — a wide spreadsheet crop next to a
   tall camera image. A fixed display box keeps the row even. */
figure.fig img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: var(--surface-sunken);
  cursor: zoom-in;
  transition: opacity .15s;
}
.figs:not(.two) figure.fig img { height: 260px; }
figure.fig img:hover { opacity: .88; }
figure.fig figcaption {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

details.cites { margin-top: 13px; }
details.cites summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 5px 0;
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}
details.cites summary::-webkit-details-marker { display: none; }
details.cites summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 7px;
  letter-spacing: 0;
  transition: transform .15s var(--ease);
}
details.cites[open] summary::before { transform: rotate(90deg); }
.cite {
  margin-top: 6px;
  padding: 8px 11px;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-sunken);
  font-size: 11.5px;
  color: var(--ink-faint);
}
.cite b { color: var(--ink-muted); font-weight: 600; }
.pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-muted);
}
.spinner {
  width: 14px; height: 14px;
  flex: 0 0 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.err-bubble { border-color: var(--critical) !important; background: var(--critical-soft) !important; }

/* ----------------------------------------------------------- composer */

footer {
  flex: 0 0 auto;
  padding: 13px 22px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer { max-width: 880px; margin: 0 auto; display: flex; gap: 9px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  /* Hidden until the box stops growing -- autosize() flips this to auto once
     the content exceeds max-height. Otherwise the gutter shows on one line. */
  overflow-y: hidden;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.send {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  transition: filter .15s, transform .06s;
}
.send:hover:not(:disabled) { filter: brightness(1.1); }
.send:active:not(:disabled) { transform: translateY(1px); }
.send:disabled { opacity: .4; cursor: default; }
.send svg { width: 18px; height: 18px; }

.disclaimer {
  max-width: 880px;
  margin: 9px auto 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

/* ----------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: oklch(12% 0.01 258 / 94%);
  cursor: zoom-out;
}
.lightbox.on { display: flex; animation: fade .18s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.lightbox .close {
  position: absolute;
  top: 20px; right: 24px;
  width: 36px; height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: oklch(100% 0 0 / 14%);
  color: oklch(100% 0 0);
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
}

/* ------------------------------------------------------ engineer mode */

.mode {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}
.mode button {
  padding: 5px 11px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}
.mode button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
body.engineer .mode button[data-mode="engineer"][aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
/* The explorer button only means something once the program is in play. */
.xopen { display: none; }
body.engineer .xopen { display: grid; }

.conv .eng {
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.bubble p.h { margin-top: 14px; }
.bubble pre {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.bubble pre code { padding: 0; border: 0; background: none; }

.bubble a.rung,
.bubble code.tagref {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
.bubble a.rung {
  border-bottom: 1px dashed var(--accent);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.92em;
}
.bubble code.tagref:hover,
.bubble a.rung:hover { background: var(--accent-soft); }

/* What the agent looked at, above the answer. */
.trail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 11px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line);
  font-size: 11px;
  color: var(--ink-faint);
}
.trail span::before { content: "✓ "; color: var(--ok); }
.trail code { font-size: 10.5px; padding: 0 4px; }

/* Clickable citations into the program explorer. */
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ref {
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}
button.ref { cursor: pointer; }
button.ref:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ref-rung::before { content: "▤ "; }
.ref-tag::before { content: "⌕ "; }
.ref-vision::before { content: "◉ "; }

/* What is open in the program panel, riding along with the next question. */
.ctx {
  max-width: 880px;
  margin: 0 auto 9px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  animation: rise .25s var(--ease) both;
}
.ctx[hidden] { display: none; }
.ctx-row { display: flex; align-items: center; gap: 7px; }
.ctx-pin { font-size: 12px; }
.ctx-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}
.ctx-clear {
  width: 22px; height: 22px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ctx-clear:hover { background: var(--surface); color: var(--ink); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.quick:empty { display: none; }
.quick-btn {
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent); }

.ctx-pill {
  margin-bottom: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  opacity: .85;
}

.lang-sel { max-width: 76px; }

/* The explorer docks beside the chat on a wide screen and covers it on a
   narrow one -- an L5X tree in 300px of width is not worth having. */
.xpanel {
  display: none;
  flex-direction: column;
  /* --xw is set by dragging the divider; the default is half the window. */
  flex: 0 0 var(--xw, min(50vw, 800px));
  min-width: 400px;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.xpanel.on { display: flex; }
/* With the panel docked the chat column is narrow; the title gives way so the
   mode switch and line selector keep their full width. */
.app.x-on header .title { visibility: hidden; flex: 1 1 0; min-width: 0; }
.app.x-on header .site-sel { max-width: 112px; }
.app.x-on header .lang-sel { max-width: 64px; }
.xhead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px 9px 16px;
  padding-top: calc(9px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.xtitle { flex: 1; min-width: 0; }
.xtitle span { display: block; font-size: 13px; font-weight: 650; }
.xtitle small {
  display: block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xpanel iframe { flex: 1; width: 100%; border: 0; background: var(--canvas); }
.xpanel iframe[hidden] { display: none; }

/* The divider between chat and panel. A 7px hit area with a hairline that
   lights up, so it is easy to grab without looking like a thick bar. */
.xsplit {
  display: none;
  flex: 0 0 7px;
  margin: 0 -3px;
  position: relative;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
}
.xsplit::after {
  content: "";
  position: absolute;
  inset: 0 3px;
  background: transparent;
  transition: background .15s;
}
.xsplit:hover::after,
.xsplit:focus-visible::after,
.app.dragging .xsplit::after { background: var(--accent); }
.xsplit:focus-visible { outline: none; }
.app.x-on .xsplit { display: block; }
/* While dragging, the embedded pages must not swallow the pointer. */
.app.dragging { cursor: col-resize; user-select: none; }
.app.dragging iframe { pointer-events: none; }

/* With the panel open the chat keeps room for its header and composer. */
.app.x-on .main { min-width: 480px; }

.xtabs { display: flex; align-items: center; gap: 4px; min-width: 0; }
.xtab {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.xtab:hover { color: var(--ink); background: var(--surface-raised); }
.xtab[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-soft); }
/* Operators have documents but not the program. */
body:not(.engineer) .xtab-program { display: none; }
.docsel {
  min-width: 0;
  max-width: 260px;
  margin-left: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: 12px;
}
.docsel[hidden] { display: none; }

/* Sources under an answer open the document at that place. */
.cite-link { cursor: pointer; transition: border-color .15s, background .15s; }
.cite-link:hover, .cite-link:focus-visible {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.cite-link:hover b { color: var(--accent); }

@media (max-width: 1180px) {
  /* Two usable columns do not fit: the panel covers the chat, no divider. */
  .xpanel.on {
    position: fixed;
    inset: 0;
    z-index: 50;
    min-width: 0;
    box-shadow: var(--shadow-lg);
  }
  .app.x-on .xsplit { display: none; }
  .app.x-on .main { min-width: 0; }
}

/* --------------------------------------------------------- responsive */

/* The sidebar collapses at any width, so the menu button is always there. */
.menu-btn { display: grid; }

@media (max-width: 860px) {
  aside {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    box-shadow: var(--shadow-lg);
  }
  .menu-btn { display: grid; }
  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    background: oklch(12% 0.01 258 / 48%);
  }
  .backdrop.on { display: block; }
  .thread { padding: 18px 14px 6px; }
  .hero h2 { font-size: 23px; }
  .figs.two { grid-template-columns: 1fr; }
  footer { padding: 11px 14px calc(11px + env(safe-area-inset-bottom)); }
  .title p { display: none; }
  .site-sel { max-width: 132px; }
  .mode button { padding: 5px 8px; }
}

@media (max-width: 560px) {
  /* Phone width: the title gives way to the mode switch and line selector. */
  .title { display: none; }
  .site-sel { max-width: 104px; }
}

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