/*
 * Nysana — research terminal, not a marketing page (PRD §52).
 *
 * The rules this file follows: information density over whitespace, tabular numerals so figures
 * line up in columns, one accent colour used only for interaction, and no decorative cards. A
 * confidence label sits next to every number that has one, because a figure without its sample
 * size is a claim the data may not support.
 *
 * One theme, not two. A light variant doubled the surface area of every visual decision and was
 * never the one anybody used; the palette below comes from the brand mark — its blue for
 * interaction, its mint for "measured and good".
 */

:root {
  /*
   * One theme, light. The palette is not the dark one inverted: on white, a colour carries
   * much less weight, so every accent here is a deeper version of the mark's — its blue for
   * interaction, its mint for "measured and good" — while the light originals stay for fills
   * and meters, where saturation still reads.
   *
   * Four surfaces. The frame sits behind the canvas and cards sit on it, so a card is legible
   * from its background alone and its border can stay faint.
   */
  --bg: #ffffff;
  --bg-frame: #f5f7fa;
  --bg-raised: #ffffff;
  --bg-sunken: #eef1f6;
  --bg-input: #ffffff;

  --border: #e3e8ef;
  --border-strong: #cdd5e0;

  --text: #121722;
  --text-dim: #5b6676;
  --text-faint: #8a94a3;

  /* The mark's blue is #5E8DFF; on white it needs to go deeper before it reads as text. */
  --accent: #2f62e0;
  --accent-soft: #5e8dff;
  --accent-dim: #e8effd;
  --mint: #12a17c;

  --good: #12a17c;
  --warn: #b57d0a;
  --bad: #d14338;

  --good-dim: #e2f6f0;
  --warn-dim: #fdf3de;
  --bad-dim: #fdeceb;

  --shadow: 0 1px 2px rgba(18, 23, 34, 0.04), 0 1px 1px rgba(18, 23, 34, 0.03);

  --radius: 10px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;

  --sidebar: 212px;
}

* { box-sizing: border-box; }

/* Any rule that sets display beats the browser's [hidden] default, and several below do. This
   puts the attribute back in charge, so hidden means hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

/*
 * Sidebar plus canvas. The nav is vertical because the product has more destinations than a
 * row of links can hold without turning into a menu, and because a fixed left rail gives every
 * screen the same left edge to line up against.
 */
body { background: var(--bg-frame); }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  gap: 4px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 18px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.sidebar .brand img { width: 22px; height: 22px; display: block; }
.sidebar .brand b { font-weight: 650; }
.sidebar .brand span { color: var(--accent); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.2;
}
.nav-link:hover { background: var(--bg-frame); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 550; }
.nav-link svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.85; }
.nav-link.active svg { opacity: 1; }

.nav-group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 16px 10px 6px;
}

.sidebar .spacer { flex: 1; }

.side-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.who {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text-dim);
  min-width: 0;
}
.who .avatar {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 650;
}
.who b { color: var(--text); font-weight: 550; }
.who small { display: block; color: var(--text-faint); font-size: 10.5px; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 {
  font-size: 13.5px;
  font-weight: 550;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.005em;
}
.topbar .spacer { flex: 1; }

.provider-chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}

main { padding: 20px 24px 72px; max-width: 1480px; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0;
}
.card > h3 {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card > h3 .spacer { flex: 1; }

/*
 * Every card says what it measures and why it is worth reading. Kept visible rather than
 * hidden behind a tooltip: a number whose meaning you have to hover to learn is a number most
 * people will guess at instead.
 */
.card-why {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  font-size: 10.5px;
  line-height: 1.45;
}
.card-why dt { color: var(--accent); white-space: nowrap; }
.card-why dd { color: var(--text-faint); margin: 0; }

.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.lead { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

@media (max-width: 1240px) {
  .grid.k5, .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.lead, .grid.split, .grid.k3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .grid.k5, .grid.k4, .grid.k2 { grid-template-columns: minmax(0, 1fr); }
  main { padding: 16px 16px 92px; }
}

/* ---------------------------------------------------------------- kpi */

.kpi-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.kpi-label svg { width: 15px; height: 15px; opacity: 0.9; }
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 1px;
  line-height: 1.1;
}
.kpi-sub { font-size: 11px; color: var(--text-faint); }
.kpi-spark { margin-top: 10px; height: 38px; }
.kpi-spark svg { display: block; width: 100%; height: 38px; }

/* ---------------------------------------------------------------- score */

.score-row { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 14px; }
.score-value {
  font-size: 46px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-max { font-size: 15px; color: var(--text-faint); }

.verdict {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 550;
  border: 1px solid transparent;
}
.verdict.strong { background: var(--good-dim); color: var(--good); border-color: #b7e4d5; }
.verdict.good   { background: var(--accent-dim); color: var(--accent); border-color: #c3d7fb; }
.verdict.mixed  { background: var(--warn-dim); color: var(--warn); border-color: #f0dcae; }
.verdict.weak   { background: var(--bad-dim); color: var(--bad); border-color: #f5c9c5; }
.verdict.unknown { background: var(--bg-input); color: var(--text-faint); border-color: var(--border); }

.breakdown { display: flex; flex-direction: column; gap: 9px; }
.breakdown-row { display: grid; grid-template-columns: 1fr auto 86px; gap: 10px; align-items: center; }
.breakdown-row .name { font-size: 12px; color: var(--text-dim); }
.breakdown-row .num {
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meter { height: 5px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.full i { background: var(--good); }
.meter.none i { background: var(--border-strong); }

/* ---------------------------------------------------------------- signals */

.signal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.signal-row:last-child { border-bottom: none; }
.signal-row .name { flex: 1; color: var(--text-dim); min-width: 0; }
.signal-row .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad  { background: var(--bad); }
.dot.none { background: var(--border-strong); }

/* ---------------------------------------------------------------- profile card */

.profile { display: flex; gap: 14px; align-items: flex-start; }
.profile img.pic {
  width: 62px; height: 62px; border-radius: 12px; object-fit: cover;
  background: var(--bg-sunken); flex: 0 0 62px;
}
.profile .facts { min-width: 0; flex: 1; }
.profile h1 {
  font-size: 19px; font-weight: 600; margin: 0 0 6px;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 7px;
  overflow-wrap: anywhere;
}
.profile .fact {
  display: flex; gap: 7px; font-size: 11.5px; color: var(--text-dim);
  padding: 1.5px 0; align-items: center;
}
.profile .fact b { color: var(--text); font-weight: 550; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- home */

.hero { max-width: 660px; margin: 56px auto 0; }
.hero h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.02em; }
.hero p.lede { color: var(--text-dim); margin: 0 0 24px; }

.field { display: block; margin-bottom: 12px; }
.field > label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 5px;
}

/* Selecting by type rather than a class means every new input type has to be added here;
   password was the first one to be forgotten, and rendered at the browser's default width. */
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 11px;
}
input[type="text"], input[type="password"] { font-family: var(--mono); }
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.mode-row { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.mode {
  flex: 1;
  min-width: 150px;
  text-align: left;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  border-radius: 4px;
  padding: 9px 11px;
  cursor: pointer;
  color: var(--text);
}
.mode strong { display: block; font-size: 13px; font-weight: 600; }
.mode small { color: var(--text-faint); font-size: 11px; }
.mode[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-dim); }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
}
button.ghost[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }

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

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--bg-raised); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.cap { max-width: 380px; color: var(--text-dim); }

/* ---------------------------------------------------------------- metrics */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.metric { background: var(--bg-raised); padding: 11px 13px; }
.metric .label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.metric .value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  margin-top: 3px;
  letter-spacing: -0.02em;
}
.metric .sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.help {
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 13px;
  height: 13px;
  font-size: 9px;
  line-height: 11px;
  text-align: center;
  color: var(--text-faint);
  cursor: help;
  flex: none;
}

.conf {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.conf.high { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.conf.medium { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.conf.low, .conf.insufficient_data, .conf.limited_data {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
}

.tag {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag.sponsored { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.organic { color: var(--text-faint); }
.tag.up { color: var(--good); }
.tag.down { color: var(--bad); }

/* ---------------------------------------------------------------- sections */

section { margin-top: 28px; }
section > h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.head .handle { font-family: var(--mono); color: var(--text-dim); font-size: 13px; }
.head .facts { display: flex; gap: 18px; margin-top: 8px; flex-wrap: wrap; }
.head .facts div { font-size: 12px; color: var(--text-dim); }
.head .facts b {
  display: block;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Sits under the topbar rather than at the foot of the screen: it is navigation, and
   navigation the reader has to scroll to find is navigation they will not use. */
.tabs {
  display: flex;
  gap: 2px;
  margin: -4px 0 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs a {
  padding: 7px 13px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- progress */

.steps { list-style: none; padding: 0; margin: 18px 0; font-family: var(--mono); font-size: 13px; }
.steps li { padding: 5px 0; display: flex; gap: 10px; align-items: baseline; }
.steps .mark { width: 14px; flex: none; }
.steps .DONE .mark { color: var(--good); }
.steps .RUNNING .mark { color: var(--accent); }
.steps .FAILED .mark { color: var(--bad); }
.steps .SKIPPED .mark, .steps .PENDING .mark { color: var(--text-faint); }
.steps .PENDING { color: var(--text-faint); }
.steps .detail { color: var(--text-dim); font-size: 12px; }

.bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); transition: width 0.4s ease; }

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

.note {
  border-left: 2px solid var(--border-strong);
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-raised);
}
.note.error { border-left-color: var(--bad); color: var(--text); }

.report h3 { font-size: 13px; margin: 18px 0 5px; font-weight: 600; }
.report p { margin: 0 0 6px; color: var(--text-dim); max-width: 78ch; }
.report .cites { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }

.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.chat-log .q { font-weight: 600; }
.chat-log .a { color: var(--text-dim); max-width: 78ch; }

.muted { color: var(--text-faint); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart .axis { stroke: var(--border); }
svg.chart .bar-fill { fill: var(--accent); }
svg.chart .bar-muted { fill: var(--border-strong); }
svg.chart text { fill: var(--text-faint); font-family: var(--mono); font-size: 9px; }
svg.chart .line { stroke: var(--accent); fill: none; stroke-width: 1.5; }
svg.chart .marker { stroke: var(--warn); stroke-dasharray: 3 3; }

@media (max-width: 640px) {
  main { padding: 16px; }
  .hero { margin-top: 24px; }
  .head .facts { gap: 12px; }
  td.cap { max-width: 180px; }
}

/* Language switch: two letters in the header, the active one highlighted. */
.lang-switch { display: flex; gap: 2px; }
.lang-switch button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }

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

/* A control that reads as a link: used where a card reveals its own workings. */
.linky {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
}
.linky:hover { text-decoration: underline; }

.note.warn { border-left-color: var(--warn); }

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
}

.profile .pic { border: 1px solid var(--border); }

/*
 * The modal came with the browser's default backdrop, which on a light page reads as a smear
 * rather than a dimming. Given a surface and a real backdrop it becomes a dialog.
 */
dialog {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(18, 23, 34, 0.14);
  padding: 18px 20px;
  max-width: 400px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(18, 23, 34, 0.32); }

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

/*
 * Fixed to the bottom of the canvas rather than placed on one screen: a question about a
 * number arrives while you are looking at that number, and a question you have to navigate
 * away to ask is a question you do not ask.
 */
#chat-dock {
  position: fixed;
  left: var(--sidebar);
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(18, 23, 34, 0.06);
}

.chat-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 24px;
  max-width: 1480px;
}
.chat-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 12px;
}
.chat-bar input:focus { outline: none; border-color: var(--accent); }
.chat-bar input:disabled { color: var(--text-faint); background: var(--bg-frame); }

.chat-panel {
  border-bottom: 1px solid var(--border);
  max-width: 1480px;
  padding: 12px 24px 0;
}
.chat-head { display: flex; align-items: center; gap: 10px; font-size: 12px; margin-bottom: 8px; }
.chat-head .spacer { flex: 1; }
.chat-x {
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1.4;
}

/* Capped rather than growing: the dock is for a quick exchange, not a transcript to scroll
   the whole screen away for. */
.chat-log { max-height: 320px; overflow-y: auto; padding-bottom: 4px; }
.chat-log > div { margin-bottom: 12px; }
.chat-log .q { font-weight: 600; font-size: 13px; }
.chat-log .a { color: var(--text-dim); max-width: 78ch; font-size: 13px; white-space: pre-wrap; }
.chat-src { color: var(--text-faint); font-size: 10.5px; margin-top: 3px; }

/* The dock covers the foot of the page, so the page has to end above it. */
main { padding-bottom: 92px; }

@media (max-width: 860px) {
  #chat-dock { left: 0; }
  .chat-bar { padding: 8px 16px; }
  .chat-panel { padding: 10px 16px 0; }
}

/* ---------------------------------------------------------------- narrow screens */

/*
 * The rail becomes a drawer rather than disappearing. A first pass simply hid it below 860px,
 * which left every screen on a phone with no way to get to another one.
 */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-dim);
  padding: 5px 7px;
  cursor: pointer;
  line-height: 0;
}
.nav-toggle svg { width: 16px; height: 16px; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(18, 23, 34, 0.35);
  z-index: 25;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    height: 100dvh;
    box-shadow: 0 0 40px rgba(18, 23, 34, 0.18);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }
  body.nav-open .sidebar { transform: none; }

  .topbar h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (min-width: 861px) {
  /* The drawer state is meaningless once the rail is permanent. */
  .scrim { display: none; }
}
