/* ==========================================================================
   TRANSLATE - interface styles.
   Plain CSS, no framework. Dark, warm, quiet: the page is a tool, not a pitch.
   ========================================================================== */

:root {
  --bg: #0c0b09;
  --surface: #14120e;
  --surface-raised: #1a1712;
  --surface-inset: #0f0e0b;
  --line: rgba(236, 226, 208, 0.12);
  --line-strong: rgba(236, 226, 208, 0.24);
  --text: #ece6da;
  --text-muted: #a79e8f;
  --text-dim: #8b8273;
  --accent: #dfa45f;
  --accent-strong: #efb772;
  --accent-soft: rgba(223, 164, 95, 0.13);
  --danger: #e08f78;
  --danger-soft: rgba(224, 143, 120, 0.12);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-variable.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
}

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

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

.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;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--accent);
  color: #1b1206;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 10px;
}

/* --------------------------------------------------------------------------
   Frame
   -------------------------------------------------------------------------- */

.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 28px) 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.brand-word {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.topnav {
  display: flex;
  gap: 4px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-decoration: none;
}

.topnav a:hover {
  color: var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-top: clamp(18px, 4vw, 34px);
}

/* --------------------------------------------------------------------------
   Introduction
   -------------------------------------------------------------------------- */

.intro {
  margin-bottom: 20px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.intro h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 7vw, 46px);
  line-height: 1.06;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.intro h1 em {
  font-style: italic;
  color: var(--accent-strong);
}

.lead {
  max-width: 48ch;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */

.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-inset);
  padding: clamp(14px, 3vw, 20px);
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-head label,
.mini-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.counter {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

textarea#source-text {
  display: block;
  width: 100%;
  min-height: 136px;
  padding: 13px 14px;
  resize: vertical;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  transition: border-color 0.15s ease;
}

textarea#source-text::placeholder {
  color: var(--text-dim);
}

textarea#source-text:hover {
  border-color: var(--line-strong);
}

textarea#source-text:focus {
  outline: none;
  border-color: var(--accent);
}

.field-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.field-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.field-error,
.form-error {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(224, 143, 120, 0.4);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #f0c6b8;
  font-size: 14px;
}

/* Controls ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 550;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #1b1206;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-ghost {
  min-height: 44px;
  padding: 0 14px;
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.btn-ghost:hover {
  border-color: var(--text-dim);
  background: var(--surface-raised);
}

.btn-quiet {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.btn-quiet:hover {
  color: var(--text);
  background: var(--surface-raised);
}

/* Route and steps --------------------------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.route-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.lang-button {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-inset);
  text-align: left;
  transition: border-color 0.15s ease;
}

.lang-button:hover {
  border-color: var(--line-strong);
}

.lang-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  flex: none;
}

.lang-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.route-arrow {
  flex: none;
  color: var(--text-dim);
  font-size: 14px;
}

.steps-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

#custom-steps {
  width: 84px;
  min-height: 44px;
  padding: 0 10px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

#custom-steps:hover {
  border-color: var(--line-strong);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset {
  min-width: 46px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.preset:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.preset.is-active {
  border-color: rgba(223, 164, 95, 0.55);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.hint {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.mode-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-inset);
}

.segment {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segment:hover {
  color: var(--text);
}

.segment.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

#manual-edit-button,
#reroll-button {
  padding: 0 10px;
}

#manual-edit-button[hidden],
#reroll-button[hidden] {
  display: none !important;
}

/* Route preview ----------------------------------------------------------- */

.route-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  min-height: 26px;
}

.route-token {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-muted);
}

.route-token.is-source {
  color: var(--text);
  border-color: var(--line-strong);
}

.route-token.is-target {
  color: var(--accent);
  border-color: rgba(223, 164, 95, 0.4);
}

.route-token.is-more {
  border-style: dashed;
  color: var(--text-dim);
}

.route-sep {
  color: var(--text-dim);
  font-size: 11px;
}

.route-empty {
  color: var(--text-dim);
  font-size: 13px;
}

/* Start row --------------------------------------------------------------- */

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.start-row .btn {
  flex: 1 1 160px;
}

.estimate {
  color: var(--text-muted);
  font-size: 13px;
}

.setup-note {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
}

/* Advanced options -------------------------------------------------------- */

.options {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.options > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-height: 44px;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
}

.options > summary::-webkit-details-marker {
  display: none;
}

.options > summary::before {
  content: "+";
  font-family: var(--font-mono);
  color: var(--accent);
  margin-right: 2px;
}

.options[open] > summary::before {
  content: "-";
}

.options-title {
  font-size: 14px;
  color: var(--text);
}

.options-note {
  color: var(--text-dim);
  font-size: 12.5px;
}

.options-body {
  display: grid;
  gap: 20px;
  padding: 8px 2px 4px;
}

.option-block {
  display: grid;
  gap: 8px;
  align-content: start;
}

.option-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.option-note {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.provider-list {
  display: grid;
  gap: 6px;
}

.provider-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.provider-option:hover {
  border-color: var(--line-strong);
}

.provider-option:has(input:checked) {
  border-color: rgba(223, 164, 95, 0.5);
  background: var(--accent-soft);
}

.provider-option input {
  margin: 3px 0 0;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex: none;
}

.provider-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.provider-name {
  font-size: 14px;
  font-weight: 550;
}

.provider-note {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
  justify-self: start;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-inset);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  flex: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent-soft);
  border-color: rgba(223, 164, 95, 0.55);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
  background: var(--accent);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

#seed-input {
  flex: 1 1 180px;
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
}

.chip button:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.chip-more,
.empty-note {
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 6px 0;
}

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

.stage {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-inset);
  padding: clamp(14px, 3vw, 20px);
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stage-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.stage-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
}

.stage-subtitle {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 13px;
}

.idle-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.idle-desktop {
  display: none;
}

.idle-title {
  font-size: 14px;
  color: var(--text);
}

.plan-list {
  margin-top: 8px;
}

.plan-row {
  display: grid;
  grid-template-columns: 46px 34px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.plan-row:last-child {
  border-bottom: 0;
}

.plan-mark {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.plan-code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
}

.plan-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.plan-row.is-target .plan-name {
  color: var(--text);
}

.plan-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.plan-more {
  padding: 8px 0 8px 46px;
  border-bottom: 1px dashed var(--line);
  color: var(--text-dim);
  font-size: 12.5px;
}

.plan-note {
  padding: 8px 0;
  color: var(--text-dim);
  font-size: 13px;
}

.idle-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  counter-reset: step;
}

.idle-list li {
  position: relative;
  padding-left: 26px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
  counter-increment: step;
}

.idle-list li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

.idle-note {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
}

/* Progress ---------------------------------------------------------------- */

.progress-block {
  margin-top: 18px;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

#progress-step {
  color: var(--text);
}

.progress-track {
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(236, 226, 208, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 12px;
}

.stats > div {
  min-width: 72px;
}

.stats dt {
  font-size: 11.5px;
  color: var(--text-dim);
}

.stats dd {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Current step ------------------------------------------------------------ */

.current-card {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-inset);
}

.current-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.current-route {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.current-label {
  font-size: 12px;
  color: var(--text-dim);
}

.current-text {
  margin-top: 6px;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Route strip ------------------------------------------------------------- */

.route-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 14px;
}

.route-seg {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-dim);
}

.route-seg.is-done {
  color: var(--text-muted);
  border-color: var(--line-strong);
}

.route-seg.is-active {
  color: var(--accent-strong);
  border-color: rgba(223, 164, 95, 0.5);
  background: var(--accent-soft);
}

.route-seg-gap {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  padding: 2px 3px;
}

/* Feed -------------------------------------------------------------------- */

.feed {
  display: grid;
  gap: 2px;
  margin-top: 12px;
}

.feed-row {
  border-bottom: 1px solid var(--line);
}

.feed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 2px;
  text-align: left;
}

.feed-item:hover .feed-text {
  color: var(--text);
}

.feed-route {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.feed-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 13.5px;
}

.feed-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

/* Errors ------------------------------------------------------------------ */

.error-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(224, 143, 120, 0.4);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.error-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #f2cfc3;
}

.error-message {
  margin-top: 4px;
  color: #d7b3a7;
  font-size: 13.5px;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.error-actions .btn-primary {
  background: #f0c6b8;
  color: #2a120b;
}

/* Result ------------------------------------------------------------------ */

.result-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
}

.result-head h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.result-similarity {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.compare-block {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-inset);
}

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.compare-text {
  margin-top: 4px;
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--text);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: auto;
}

/* History ----------------------------------------------------------------- */

.history {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.history > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}

.history > summary::-webkit-details-marker {
  display: none;
}

.history > summary:hover {
  color: var(--text);
}

.history-summary-end {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.history-chevron {
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s ease;
}

.history[open] .history-chevron {
  transform: rotate(-135deg) translateY(-1px);
}

.history-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.history-list {
  display: grid;
  gap: 2px;
}

.history-item {
  border-bottom: 1px solid var(--line);
}

.history-item > summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 8px 2px;
  cursor: pointer;
  list-style: none;
}

.history-item > summary::-webkit-details-marker {
  display: none;
}

.history-index {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

.history-route {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  white-space: nowrap;
}

.history-excerpt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 13px;
}

.history-meta {
  display: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

.history-body {
  display: grid;
  gap: 10px;
  padding: 4px 2px 12px;
}

.history-text {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
}

.history-text span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.history-text p {
  margin: 4px 0 6px;
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-more {
  padding: 8px 0;
}

.empty {
  padding: 10px 2px;
  color: var(--text-dim);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Legal page
   -------------------------------------------------------------------------- */

.legal {
  max-width: 68ch;
  margin: 0 auto;
  padding: clamp(22px, 5vw, 44px) 0 8px;
}

.legal h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 6vw, 42px);
  line-height: 1.1;
  margin-bottom: 14px;
}

.legal-intro {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.65;
}

.legal h2 {
  margin: 28px 0 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.legal p,
.legal li {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.65;
}

.legal ul {
  list-style: disc;
  padding-left: 20px;
  margin-top: 8px;
}

.legal li {
  margin-top: 6px;
}

.legal a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.legal-card {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.legal-card p {
  margin-top: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.legal-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.legal-back {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.legal-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  display: grid;
  gap: 4px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 13px;
}

.footer-meta {
  color: var(--text-dim);
  font-size: 12.5px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */

.dialog {
  width: min(540px, calc(100vw - 20px));
  max-height: min(760px, 88vh);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.dialog::backdrop {
  background: rgba(5, 4, 3, 0.75);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
}

.dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -6px -6px 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.dialog-search {
  padding: 12px 16px;
}

#language-search,
#exclude-search {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}

#language-search:focus,
#exclude-search:focus {
  outline: none;
  border-color: var(--accent);
}

.language-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding: 0 10px 12px;
  overscroll-behavior: contain;
}

.language-group {
  grid-column: 1 / -1;
  padding: 10px 6px 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.language-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text-muted);
  font-size: 13.5px;
}

.language-option:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.language-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.language-option.is-excluded {
  color: var(--text-dim);
  text-decoration: line-through;
}

.language-option.is-disabled {
  color: var(--text-dim);
  cursor: default;
  opacity: 0.7;
}

.language-option-code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex: none;
  width: 34px;
}

.language-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-check {
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
}

.language-empty {
  grid-column: 1 / -1;
  padding: 16px 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.dialog-note {
  margin: 0;
  padding: 0 16px 10px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 13px;
}

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

/* Manual route dialog ----------------------------------------------------- */

.manual-list {
  display: grid;
  gap: 2px;
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 0 16px 12px;
  overscroll-behavior: contain;
}

.manual-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}

.manual-index {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  width: 22px;
}

.manual-arrow {
  color: var(--text-dim);
  font-size: 11px;
}

.manual-select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.manual-select:disabled {
  color: var(--text-muted);
  opacity: 0.75;
}

.manual-move {
  display: flex;
  gap: 2px;
}

.manual-move button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
}

.manual-move button:hover:not(:disabled) {
  background: var(--surface-raised);
  color: var(--text);
}

.manual-move button:disabled {
  opacity: 0.3;
  cursor: default;
}

.manual-more {
  padding: 10px 0;
}

/* --------------------------------------------------------------------------
   Toast and fallbacks
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 24px));
  padding: 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.toast.is-error {
  border-color: rgba(224, 143, 120, 0.5);
  color: #f0cfc3;
}

.noscript {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 12px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Desktop: calm two-column workspace
   -------------------------------------------------------------------------- */

@media (min-width: 700px) {
  .start-row .btn {
    flex: 0 0 auto;
    min-width: 168px;
  }

  .compare {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .history-item > summary {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .history-meta {
    display: inline-flex;
    gap: 8px;
  }

  .site-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 24px;
    row-gap: 2px;
    margin-top: 36px;
  }

  .footer-links {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
  }
}

@media (min-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 470px) minmax(0, 1fr);
    align-items: start;
    gap: 44px;
    padding-top: 34px;
  }

  .stage {
    align-self: start;
    padding: 22px;
  }

  /* Keep the idle preview in view while the settings below are edited. Once a
     run exists the stage can grow tall, so it scrolls with the page instead. */
  body:not(.has-run) .stage {
    position: sticky;
    top: 20px;
  }

  .stage-title {
    font-size: 26px;
  }

  .idle-mobile {
    display: none;
  }

  .idle-desktop {
    display: block;
  }

  /* The compact token strip stays in the accessibility tree for announcements,
     but the stage already shows the planned route on wide screens. */
  .route-preview {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .intro {
    margin-bottom: 18px;
  }

  .current-text {
    font-size: 17px;
  }

  .compare-text {
    font-size: 15px;
  }
}

@media (max-width: 380px) {
  .lang-button {
    padding: 0 9px;
    gap: 6px;
  }

  .lang-name {
    font-size: 13px;
  }

  .preset {
    min-width: 42px;
    padding: 0 7px;
  }

  .route-arrow {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
