:root {
  --ink: #101b24;
  --ink-soft: #2b3c48;
  --ink-faint: #6c7b74;
  --paper: #f4f6f2;
  --paper-raise: #ffffff;
  --rail: #14212a;
  --rail-raised: #1d2d38;
  --rail-line: #2c3f4c;
  --line: #dde2da;
  --line-strong: #c6cec4;
  --amber: #f2a71b;
  --amber-deep: #b97a06;
  --amber-soft: #fdf0d4;
  --jade: #0f6858;
  --jade-soft: #e0ede8;
  --brick: #a63a2b;
  --brick-soft: #f7e3df;
  --focus: #1f6fd0;

  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-soft: 0 1px 2px rgba(16, 27, 36, 0.05), 0 8px 24px -18px rgba(16, 27, 36, 0.35);
  --shadow-raise: 0 18px 40px -28px rgba(16, 27, 36, 0.55);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

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

.shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 344px;
  min-height: 100dvh;
  max-height: 100dvh;
}

/* ---------- Left rail ---------- */

.rail {
  background: var(--rail);
  color: #e8eeea;
  padding: 26px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid #0c161d;
  overflow-y: auto;
}

.rail__brand { display: flex; gap: 14px; align-items: flex-start; }

.rail__mark {
  width: 46px; height: 46px;
  color: var(--amber);
  flex: none;
  margin-top: 3px;
}

.rail__eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8fa4ac;
}

.rail__title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #f7f9f6;
}

.rail__line { display: block; }

.rail__desc {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.65;
  color: #a9bbc1;
}

.rail__new {
  width: 100%;
  justify-content: center;
}

.btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn--ghost {
  background: transparent;
  border-color: var(--rail-line);
  color: #e6eeea;
}
.btn--ghost:hover { background: var(--rail-raised); border-color: #43596a; }

.rail__section { display: flex; flex-direction: column; gap: 10px; }

.rail__heading {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #7e929b;
}

.capabilities {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px;
  color: #d3ded9;
}
.capabilities li { display: flex; align-items: center; gap: 9px; }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot--jade { background: #4fb79d; }
.dot--amber { background: var(--amber); }

.meter { display: flex; flex-direction: column; gap: 8px; }
.meter__bar {
  height: 5px;
  background: #253743;
  border-radius: 99px;
  overflow: hidden;
}
.meter__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4fb79d, var(--amber));
  transition: width 0.4s ease;
}
.meter__value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #eef4f0;
  display: flex; gap: 6px; align-items: baseline;
}
.meter__value small { color: #7e929b; font-size: 11px; }
.rail__hint { margin: 0; font-size: 11.5px; color: #8ba0a8; }
.rail__hint[data-blocked="true"] { color: var(--amber); }

.rail__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--rail-line);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #cfe0da;
}
.status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(242, 167, 27, 0.15);
}
.status.is-live .status__dot { background: #4fb79d; box-shadow: 0 0 0 3px rgba(79, 183, 157, 0.18); }
.status.is-offline .status__dot { background: #d3785f; box-shadow: 0 0 0 3px rgba(211, 120, 95, 0.16); }

.rail__legal {
  margin: 0;
  font-size: 10.8px;
  line-height: 1.55;
  color: #7b8f98;
}

/* ---------- Stage ---------- */

.stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(1200px 300px at 30% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 70%),
    var(--paper);
}

.stage__head {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 34px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 242, 0.86);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.stage__head > div:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; }

.stage__eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stage__title {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 1.08;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage__badges { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; flex: none; }

.badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--jade-soft);
  color: var(--jade);
  border: 1px solid #c6ded7;
  white-space: nowrap;
}
.badge--muted { background: transparent; color: var(--ink-faint); border-color: var(--line-strong); }

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 26px 34px 32px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* intro */

.intro { max-width: 860px; margin: 6px 0 40px 44px; }
.intro__kicker {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber-deep);
}
.intro__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  max-width: 22ch;
}
.intro__body { margin: 12px 0 26px; color: var(--ink-soft); max-width: 58ch; font-size: 14.2px; }

.intro__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.starter {
  text-align: left;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 13px 15px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.starter:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: var(--line-strong); }
.starter__tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.starter__text { font-size: 13.4px; font-weight: 500; line-height: 1.45; }

/* messages */

.msg {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 940px;
  margin: 0 auto 22px 0;
  animation: rise 0.32s ease both;
}

.msg__rail {
  position: relative;
  display: flex;
  justify-content: center;
}
.msg__rail::before {
  content: "";
  position: absolute;
  top: 0; bottom: -26px;
  width: 2px;
  background-image: linear-gradient(to bottom, var(--line-strong) 55%, transparent 55%);
  background-size: 2px 12px;
  opacity: 0.85;
}
.msg--last .msg__rail::before { bottom: 0; background-image: none; background: var(--line-strong); }
.msg__node {
  position: relative;
  z-index: 1;
  width: 12px; height: 12px;
  margin-top: 6px;
  background: var(--paper);
  border: 2px solid var(--line-strong);
  border-radius: 3px;
  transform: rotate(45deg);
}
.msg--user .msg__node { background: var(--ink); border-color: var(--ink); }
.msg--assistant .msg__node { background: var(--amber); border-color: var(--amber-deep); }

.msg__body { min-width: 0; }
.msg__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}
.msg__role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.msg__time { font-family: var(--font-mono); font-size: 10px; color: #97a49c; }

.msg__content { min-width: 0; }

.msg--user .msg__content {
  background: var(--ink);
  color: #f2f6f2;
  padding: 11px 15px;
  border-radius: 12px 12px 12px 3px;
  width: fit-content;
  max-width: 62ch;
  font-size: 14.2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--user .msg__content p { margin: 0; }

.msg--assistant .msg__content {
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 3px 12px 12px 12px;
  padding: 16px 20px 14px;
  box-shadow: var(--shadow-soft);
  overflow-wrap: anywhere;
}

.msg--notice .msg__content {
  background: var(--amber-soft);
  border-color: #edd9a9;
}

/* markdown inside answers */

.msg__content h1, .msg__content h2, .msg__content h3, .msg__content h4 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin: 18px 0 8px;
  color: var(--ink);
}
.msg__content h1 { font-size: 22px; }
.msg__content h2 { font-size: 19px; }
.msg__content h3 { font-size: 17px; }
.msg__content h4 { font-size: 15px; }
.msg__content > :first-child { margin-top: 0; }
.msg__content > :last-child { margin-bottom: 0; }
.msg__content p { margin: 0 0 10px; }
.msg__gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg__thumb {
  width: 148px;
  height: 148px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: block;
}
.msg__thumb--broken {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 12px;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.06);
}
.msg__content ul, .msg__content ol { margin: 0 0 10px; padding-left: 20px; }
.msg__content li { margin: 3px 0; }
.msg__content strong { font-weight: 600; color: #0b1620; }
.msg__content em { color: var(--ink-soft); }
.msg__content a { color: var(--jade); text-decoration-color: #a9cdc3; }
.msg__content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: #eef1eb;
  padding: 1px 5px;
  border-radius: 4px;
}
.msg__content pre {
  background: #0f1a22;
  color: #e6eeea;
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 12.6px;
}
.msg__content pre code { background: none; padding: 0; }
.msg__content blockquote {
  margin: 10px 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--amber);
  color: var(--ink-soft);
}
.msg__content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0;
}
.msg__content th, .msg__content td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
.msg__content th { background: #f1f3ee; font-weight: 600; }
.msg__content hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

.cite-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--jade);
  background: var(--jade-soft);
  border: 1px solid #c3ddd4;
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 1px;
  cursor: pointer;
  vertical-align: 1px;
  transition: background-color 0.12s ease;
}
.cite-pill:hover { background: #cfe7df; }

.msg__disclaimer {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 12.8px;
  line-height: 1.6;
}

.msg__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}
.msg__foot:empty { display: none; }
.chip--suggest {
  cursor: pointer;
  border-left: 2px solid var(--amber);
  border-radius: 4px 99px 99px 4px;
  padding-left: 10px;
}
.chip--suggest:hover { background: var(--amber-soft); border-color: #e6c88f; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: #fbfcfa;
  white-space: nowrap;
}
.chip--conf-high { color: var(--jade); border-color: #c3ddd4; background: var(--jade-soft); }
.chip--conf-mid { color: var(--amber-deep); border-color: #edd9a9; background: var(--amber-soft); }
.chip--conf-low { color: var(--brick); border-color: #eccfc9; background: var(--brick-soft); }
.chip--ghost { background: transparent; }

.trace-toggle {
  border: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.trace-toggle:hover { border-color: var(--line-strong); background: #f2f4ef; }
.trace-toggle span[aria-hidden] { transition: transform 0.15s ease; }
.trace-toggle[aria-expanded="true"] span[aria-hidden] { transform: rotate(90deg); }

.msg__trace {
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fafbf8;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trace-row { display: flex; gap: 8px; align-items: baseline; }
.trace-row b { color: var(--ink); font-weight: 500; min-width: 74px; }
.trace-row i { font-style: normal; color: var(--ink-faint); }

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.typing span {
  width: 6px; height: 6px;
  background: var(--line-strong);
  border-radius: 50%;
  animation: blink 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* composer */

.composer {
  position: sticky;
  bottom: 0;
  padding: 12px 34px 20px;
  background: linear-gradient(to top, var(--paper) 62%, rgba(244, 246, 242, 0));
}

.composer__field {
  max-width: 940px;
  margin: 0 0 0 44px;
  background: var(--paper-raise);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raise);
  padding: 12px 14px 10px;
  transition: border-color 0.15s ease;
}
.composer__field:focus-within { border-color: #9fb3a8; }

#input {
  width: 100%;
  border: none;
  resize: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14.6px;
  line-height: 1.55;
  color: var(--ink);
  min-height: 26px;
  max-height: 168px;
  padding: 2px 2px 6px;
}
#input:focus { outline: none; }
#input::placeholder { color: #97a49c; }

.composer__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid #eef0ea;
}
.composer__hint {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #a3afa7;
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: #f1f3ee; color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

.btn--send {
  background: var(--ink);
  color: #f6f9f5;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}
.btn--send:hover { background: #1d2c37; }
.btn--send:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--send svg { width: 16px; height: 16px; }

.composer__attachments {
  max-width: 896px;
  margin: 0 0 8px 44px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px 5px 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-soft);
  max-width: 220px;
}
.attachment img {
  width: 34px; height: 34px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}
.attachment button {
  border: none;
  background: #f1f3ee;
  color: var(--ink-soft);
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  flex: none;
}
.attachment button:hover { background: var(--brick-soft); color: var(--brick); }

/* ---------- Sources panel ---------- */

.sources {
  background: #fbfcf9;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  max-height: 100dvh;
  overflow: hidden;
}

.sources__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.sources__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.sources__count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--ink);
  color: #f4f7f4;
  min-width: 22px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 99px;
}

.sources__body { flex: 1; overflow-y: auto; padding: 16px 22px; }
.sources__empty { color: var(--ink-faint); font-size: 12.8px; line-height: 1.6; margin: 0; }

.source-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  margin-bottom: 10px;
  background: var(--paper-raise);
  animation: rise 0.25s ease both;
}
.source-card.is-target { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(242, 167, 27, 0.14); }
.source-card__ref {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--jade);
  background: var(--jade-soft);
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 6px;
}
.source-card__title { font-size: 12.8px; font-weight: 600; line-height: 1.4; margin: 0 0 4px; }
.source-card__snippet {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.source-card__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.sources__foot {
  border-top: 1px solid var(--line);
  padding: 14px 22px 18px;
}
.sources__subhead {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.knowledge { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.knowledge li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ink-soft);
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.knowledge li:last-child { border-bottom: none; padding-bottom: 0; }
.knowledge li span:last-child { font-family: var(--font-mono); color: var(--ink-faint); font-size: 10.5px; white-space: nowrap; }

/* ---------- motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

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

@media (max-width: 1240px) {
  .shell { grid-template-columns: 264px minmax(0, 1fr); }
  .sources { display: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; max-height: none; }
  .rail {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid #0c161d;
  }
  .rail__brand { flex: 1 1 auto; min-width: 0; overflow: hidden; gap: 10px; }
  .rail__mark { width: 34px; height: 34px; margin-top: 0; }
  .rail__title { display: none; }
  .rail__eyebrow { font-size: 10px; }
  .rail__desc, .rail__section, .rail__legal { display: none; }
  .rail__new { width: auto; margin-left: auto; padding: 8px 10px; white-space: nowrap; flex: none; }
  .rail__new-text { display: none; }
  .rail__footer { display: none; }
  .stage { max-height: none; min-height: calc(100dvh - 74px); }
  .stage__head { padding: 16px 18px 12px; }
  .stage__title { font-size: 22px; }
  .stage__badges { display: none; }
  .thread { padding: 20px 18px 24px; }
  .intro { margin: 4px 0 26px; }
  .intro__grid { grid-template-columns: 1fr; }
  .composer { padding: 10px 14px 16px; }
  .composer__field { margin-left: 0; max-width: 100%; }
  .composer__attachments { margin-left: 0; max-width: 100%; }
  #input { min-height: 62px; font-size: 16px; }
  .composer__hint { display: none; }
  .msg { grid-template-columns: 20px minmax(0, 1fr); gap: 10px; }
  .msg--assistant .msg__content { padding: 14px 15px 12px; }
  .msg--user .msg__content { max-width: 84%; }
}

@media (max-width: 520px) {
  .intro__title { font-size: 27px; }
  .stage__head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .msg__foot { font-size: 10px; }
}

/* ---------------- API key gate ---------------- */
.keygate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 14, 18, 0.86);
}
.keygate__card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rail-line);
  background: var(--rail);
  color: #e6eeea;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.keygate__title { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: 0.01em; }
.keygate__desc { margin: 0; font-size: 13px; line-height: 1.55; color: #a9bcc7; }
.keygate__desc code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}
.keygate__input {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid #334754;
  background: #0b141a;
  color: #e6eeea;
}
.keygate__input:focus { outline: 2px solid var(--jade-soft); outline-offset: 1px; }
.keygate__error { margin: 0; font-size: 13px; color: #f2a6a6; }
.keygate__submit { justify-content: center; }
.rail__key { width: 100%; justify-content: center; margin-bottom: 10px; }
