:root {
  --ink: #17201d;
  --muted: #5e6d68;
  --soft: #eef3f0;
  --paper: #f9fbf9;
  --surface: #ffffff;
  --line: #d8dfd9;
  --line-strong: #b9c4bd;
  --accent: #c0622a;
  --accent-strong: #8f4523;
  --accent-soft: rgba(192, 98, 42, 0.08);
  --blue: #2e5a6f;
  --green: #3d6458;
  --good: #287455;
  --warn: #8b6122;
  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 8px rgba(23, 32, 29, 0.06);
  --shadow: 0 8px 28px rgba(23, 32, 29, 0.10);
  --shadow-lg: 0 18px 48px rgba(23, 32, 29, 0.12);
  color-scheme: light;
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--soft);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 60% at 80% -10%, rgba(49, 94, 115, 0.07) 0%, transparent 60%),
    linear-gradient(180deg, #f6f9f6 0%, #eef3f0 100%);
}

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

button {
  cursor: pointer;
}

/* ── Topbar ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(216, 223, 217, 0.88);
  background: rgba(251, 252, 250, 0.94);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: flex;
  flex-direction: column;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #1c2b26 0%, var(--ink) 100%);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 2px 8px rgba(23, 32, 29, 0.22), inset 0 1px 0 rgba(255,255,255,0.07);
}

.brand-mark svg {
  flex-shrink: 0;
}

.brand-mark span {
  font-family: "Inter Tight", "Inter", Georgia, serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  opacity: 0.75;
}

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

h1 {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: clamp(20px, 2.1vw, 30px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.topbar p,
.view-head p,
.source-note p,
.tray p {
  color: var(--muted);
}

.topbar p {
  margin-top: 4px;
  font-size: 13px;
}

/* ── Metrics ─────────────────────────────────────────────────────── */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
}

.metric-strip div {
  min-width: 80px;
  padding: 8px 12px;
  border-left: 2px solid var(--line);
}

.metric-strip dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-strip dd {
  margin-top: 3px;
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── App shell ───────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 270px;
  gap: 0;
  min-height: calc(100vh - 84px);
}

/* ── Rail / Sidebar ──────────────────────────────────────────────── */

.rail {
  position: sticky;
  top: 84px;
  align-self: start;
  height: calc(100vh - 84px);
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(252, 253, 251, 0.75);
  overflow-y: auto;
}

.nav-stack {
  display: grid;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  transition:
    color 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 140ms ease;
}

.nav-item:hover {
  transform: translateX(2px);
  color: var(--ink);
  background: rgba(23, 32, 29, 0.04);
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.is-active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-item.is-active svg {
  opacity: 1;
  color: var(--accent);
}

.source-note {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.source-note span {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-note p {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ── Workspace ───────────────────────────────────────────────────── */

.workspace {
  min-width: 0;
  padding: 28px 32px;
}

.view {
  display: none;
  animation: viewIn 240ms cubic-bezier(.22,.68,0,1.2) both;
}

.view.is-active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.view-head h2 {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: clamp(22px, 2.8vw, 38px);
  font-weight: 800;
  line-height: 1.03;
  letter-spacing: -0.025em;
}

.view-head p {
  max-width: 720px;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.55;
}

.view-actions,
.tray-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.primary-btn,
.quiet-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(192, 98, 42, 0.3);
}

.primary-btn:hover,
.quiet-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 3px 10px rgba(192, 98, 42, 0.35);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.quiet-btn:hover {
  border-color: var(--blue);
  background: rgba(46, 90, 111, 0.05);
}

/* ── Tool row / filters ──────────────────────────────────────────── */

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 16px 0;
}

.field {
  display: grid;
  min-width: min(360px, 100%);
  gap: 6px;
}

.field.compact {
  min-width: 130px;
}

.field span,
.segmented legend {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select,
textarea {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 98, 42, 0.12);
}

input,
textarea {
  padding: 0 12px;
}

textarea {
  min-height: 148px;
  padding-top: 10px;
  resize: vertical;
  line-height: 1.5;
}

select {
  padding: 0 34px 0 12px;
  cursor: pointer;
}

.segmented {
  display: flex;
  min-height: 40px;
  align-items: stretch;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.segmented legend {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.segmented button {
  min-width: 92px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  transition: background 140ms ease, color 140ms ease;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button:hover:not(.is-active) {
  background: rgba(23, 32, 29, 0.04);
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--ink);
  color: white;
  font-weight: 600;
}

/* ── Results & counts ────────────────────────────────────────────── */

.source-warning,
.result-line {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-warning {
  max-width: 920px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(139, 97, 34, 0.28);
  background: rgba(139, 97, 34, 0.06);
  color: var(--warn);
}

/* ── Question cards ──────────────────────────────────────────────── */

.question-list {
  display: grid;
  gap: 10px;
}

.question-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.question-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.question-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px 0;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  font-size: 11px;
}

.question-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 5px;
}

.small-btn {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
}

.small-btn:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.small-btn.is-selected {
  border-color: var(--green);
  background: var(--green);
  color: white;
  font-weight: 600;
}

.question-body {
  padding: 10px 14px 14px;
}

.prompt {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.01em;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.option-grid li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  overflow: hidden;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.option-label {
  display: grid;
  height: 100%;
  min-height: 36px;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
}

.option-text {
  min-width: 0;
  padding: 7px 10px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.option-grid li.is-correct {
  border-color: rgba(40, 116, 85, 0.55);
  background: rgba(40, 116, 85, 0.07);
}

.option-grid li.is-correct .option-label {
  border-color: rgba(40, 116, 85, 0.35);
  color: var(--good);
}

.answer-panel {
  display: none;
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: rgba(23, 32, 29, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.question-row.is-revealed .answer-panel {
  display: block;
  animation: answerIn 160ms ease both;
}

@keyframes answerIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.answer-panel strong {
  color: var(--ink);
}

.empty-state {
  padding: 40px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ── Tray / right panel ──────────────────────────────────────────── */

.tray {
  position: sticky;
  top: 84px;
  align-self: start;
  height: calc(100vh - 84px);
  padding: 20px 16px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.tray-count {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tray-count span {
  display: block;
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.tray-actions {
  display: grid;
  margin-top: 14px;
  gap: 7px;
}

.tray-actions button {
  width: 100%;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.switch input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Wordlist table ──────────────────────────────────────────────── */

.word-table-wrap {
  max-height: calc(100vh - 250px);
  overflow: auto;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}

.word-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.74);
}

.word-table th,
.word-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.word-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.word-table td {
  font-size: 14px;
  line-height: 1.45;
}

.word-table td:nth-child(1) {
  width: 60px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.word-table td:nth-child(2) {
  width: 150px;
  font-weight: 700;
}

.word-table tr:hover td {
  background: rgba(23, 32, 29, 0.02);
}

/* ── Vocabulary Lab ──────────────────────────────────────────────── */

.backend-status {
  display: grid;
  min-width: min(280px, 100%);
  gap: 3px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.backend-status strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.backend-status.is-ready {
  border-color: rgba(40, 116, 85, 0.42);
  background: rgba(40, 116, 85, 0.04);
}

.backend-status.is-local {
  border-color: rgba(139, 97, 34, 0.42);
  background: rgba(139, 97, 34, 0.04);
}

.backend-status.is-offline {
  border-color: rgba(143, 69, 35, 0.32);
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 20px;
  padding-top: 20px;
}

.lab-panel {
  display: grid;
  align-content: start;
  gap: 13px;
  border-top: 1px solid var(--line);
  padding: 18px 0 0;
}

.lab-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.lab-panel h3 {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lab-panel p,
.muted-copy,
.dict-notes {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.field.wide {
  min-width: 100%;
}

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

.lab-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.lab-message.is-error {
  color: var(--warn);
}

.lab-result {
  display: grid;
  gap: 12px;
}

/* ── Merriam-Webster-style dictionary entry ──────────────────────── */

.dict-entry {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dict-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line);
}

.dict-headword {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.dict-pos {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(46, 90, 111, 0.08);
  color: var(--blue);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 13px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dict-source-tag,
.dict-confidence {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dict-source-tag {
  background: rgba(40, 116, 85, 0.08);
  color: var(--good);
}

.dict-confidence {
  background: rgba(139, 97, 34, 0.08);
  color: var(--warn);
}

.dict-body {
  padding: 18px 24px 22px;
}

.dict-definition {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
}

.dict-definition.dict-missing {
  color: var(--muted);
  font-style: italic;
}

.dict-example {
  margin: 14px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--line-strong);
  background: var(--paper);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
}

.dict-example em {
  font-style: italic;
}

.dict-section {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(249, 251, 249, 0.5);
}

.dict-section-title {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  margin: 0 0 12px;
}

.dict-root-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 0 0 18px;
  list-style: decimal;
}

.dict-root-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: baseline;
  line-height: 1.45;
}

.dict-root-word {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.dict-root-meta {
  color: var(--blue);
  font-size: 12px;
  font-style: italic;
}

.dict-root-meaning {
  color: var(--muted);
  font-size: 14px;
}

.dict-related-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dict-chip {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.dict-chip:hover {
  background: rgba(192, 98, 42, 0.08);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dict-chip:active {
  transform: translateY(0);
}

/* ── Paragraph generator (kept clean) ────────────────────────────── */

.result-block {
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.result-block h3 {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

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

.definition-list {
  display: grid;
  gap: 11px;
  margin: 0;
}

.definition-list div {
  display: grid;
  gap: 4px;
}

.definition-list dt,
.mini-section h4 {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.definition-list dd {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.mini-section {
  display: grid;
  gap: 8px;
}

.root-list,
.related-list,
.glossary-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.root-list li,
.related-list li,
.glossary-list li {
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.root-list strong,
.related-list strong,
.glossary-list strong {
  color: var(--ink);
  font-weight: 600;
}

.root-list span,
.related-list span,
.glossary-list span {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.root-list p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.paragraph-output {
  font-size: 17px;
  line-height: 1.7;
}

/* ── Toast ───────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: white;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 200ms cubic-bezier(.22,.68,0,1.2);
  box-shadow: 0 8px 24px rgba(23, 32, 29, 0.25);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .tray {
    position: fixed;
    right: 16px;
    bottom: 16px;
    top: auto;
    z-index: 30;
    width: min(310px, calc(100vw - 32px));
    height: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .tray-count span {
    font-size: 36px;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-strip {
    width: 100%;
  }

  .app-shell {
    display: block;
  }

  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-stack {
    grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  }

  .nav-item {
    justify-content: center;
    text-align: center;
  }

  .source-note {
    display: none;
  }

  .workspace {
    padding: 20px 16px 160px;
  }

  .view-head {
    display: grid;
  }

  .option-grid {
    grid-template-columns: 1fr;
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }

  .word-table th {
    top: 0;
  }
}

@media (max-width: 560px) {
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .nav-stack {
    grid-template-columns: 1fr 1fr;
  }

  .segmented,
  .segmented button,
  .view-actions,
  .tool-row {
    width: 100%;
  }

  .segmented button {
    min-width: 0;
  }

  .question-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .question-actions,
  .question-actions button {
    width: 100%;
  }

  .lab-actions,
  .lab-actions button {
    width: 100%;
  }
}

/* ── Print ───────────────────────────────────────────────────────── */

@media print {
  body {
    background: white;
  }

  .topbar,
  .rail,
  .tray,
  .tool-row,
  .backend-status,
  .lab-actions,
  .lab-message,
  .view-actions,
  .toast,
  .source-warning,
  .question-actions {
    display: none !important;
  }

  .app-shell,
  .workspace {
    display: block;
    min-height: auto;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  .view.is-active {
    display: block !important;
  }

  .view-head {
    padding: 0 0 14px;
  }

  .question-row {
    break-inside: avoid;
    box-shadow: none;
    border-radius: 0;
  }

  .answer-panel {
    display: block;
  }
}
