@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/dm-sans-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/dm-sans-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Libre Caslon Display";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/libre-caslon-display-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C4,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Libre Caslon Display";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/libre-caslon-display-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --paper: #fffefa;
  --surface: #f0f2eb;
  --surface-hover: #e7ebe1;
  --ink: #263c35;
  --ink-soft: #435750;
  --muted: #6d7871;
  --line: #e2e6dc;
  --line-strong: #cdd4c6;
  --green: #254e43;
  --green-hover: #1c3d34;
  --green-tint: #e8f1ed;
  --green-border: #bfd6cc;
  --amber: #9b6a22;
  --amber-accent: #c08a3e;
  --amber-tint: #fbf5e7;
  --amber-border: #e9d6ae;
  --clay: #a63d2d;
  --clay-tint: #fceee9;
  --clay-border: #e6bfb5;
  --serif: "Libre Caslon Display", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-paper: 0 1px 2px rgba(38, 60, 53, 0.04), 0 6px 20px rgba(38, 60, 53, 0.03);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber-accent);
  outline-offset: 2px;
}

.ic { width: 16px; height: 16px; flex-shrink: 0; display: block; }
.kbd {
  font: 500 11px/1 var(--sans);
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 3px 5px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 54px;
  background: rgba(247, 248, 244, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(12px, 2vw, 24px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-wrap { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.brand {
  font: 400 26px/1 var(--serif);
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand span { color: var(--amber-accent); }
.byline {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 99px;
  transition: color 0.15s, background 0.15s;
}
.byline:hover { color: var(--green); background: var(--surface); }

.search-wrap {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 78, 67, 0.08);
}
.search-wrap .ic { color: var(--muted); }
.search-wrap input {
  border: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  font-size: 14px;
  outline: none;
}
.search-wrap input::placeholder { color: var(--muted); }

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill-btn:hover { background: var(--surface); border-color: var(--line-strong); }
.pill-btn[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}
.pill-btn[aria-pressed="true"] .count-chip {
  background: rgba(255, 254, 250, 0.22);
  color: var(--paper);
}
.count-chip {
  font-size: 11.5px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--green-tint);
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

/* Filter Toolbar */
.toolbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px clamp(12px, 2vw, 24px);
}
.toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 2px;
  flex-shrink: 0;
}
.seg {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg:hover { color: var(--ink); }
.seg.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(38, 60, 53, 0.08);
}

.select-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px 0 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  max-width: 100%;
}
.field span {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
}
.field select {
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding-right: 4px;
  max-width: 185px;
  cursor: pointer;
  outline: none;
}

.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.telemetry {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--green-tint);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.text-btn {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
  padding: 4px 6px;
  border-radius: 5px;
}
.text-btn:hover { background: var(--green-tint); }

/* Desktop Master-Detail Workbench — flex viewport shell (zero hardcoded height math!) */
@media (min-width: 960px) {
  html, body { height: 100dvh; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  .topbar, .toolbar { flex-shrink: 0; }
  .workbench {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

.rail {
  border-right: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.rail-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-item {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px 10px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.rail-item:hover { background: var(--bg); }
.rail-item[aria-selected="true"] {
  background: var(--green-tint);
  border-color: var(--green-border);
}
.rail-num {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: center;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
}
.rail-item[aria-selected="true"] .rail-num {
  background: var(--green);
  color: var(--paper);
}
.rail-body { min-width: 0; }
.rail-primary {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-dots { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 99px; flex-shrink: 0; }
.dot-ok { background: var(--green); }
.dot-err { background: var(--clay); }
.dot-saved { background: var(--amber-accent); }

.rail-more {
  margin: 6px 8px 10px;
  padding: 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}
.rail-more:hover { background: var(--green-tint); }

/* Stage (Reading Desk) */
.stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
.stage-inner {
  flex: 1;
  overflow-y: auto;
  padding: 20px clamp(16px, 3vw, 40px) 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  padding: 48px 20px;
  max-width: 380px;
}
.empty-title { font: 400 26px/1.2 var(--serif); margin: 0 0 8px; }
.empty-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* Paper Sheet */
.paper {
  width: 100%;
  max-width: 820px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
  padding: clamp(16px, 2.5vw, 28px);
}
.paper-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.paper-meta-col { min-width: 0; }
.p-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
}
.meta-chip-green { background: var(--green-tint); color: var(--green); }
.p-title {
  font: 400 clamp(24px, 3vw, 30px)/1.12 var(--serif);
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
}
.p-topic {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s;
}
.icon-pill:hover { background: var(--surface); color: var(--ink); }
.icon-pill[aria-pressed="true"] {
  background: var(--amber-tint);
  border-color: var(--amber-border);
  color: var(--amber);
}
.icon-pill[aria-pressed="true"] path { fill: currentColor; }

/* Question Parts (Always Visible — Zero <details>!) */
.p-parts {
  margin: 18px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.part-block { margin: 0; }
.part-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.part-img-btn {
  display: block;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
  transition: border-color 0.15s;
}
.part-img-btn:hover { border-color: var(--line-strong); }
.part-img-btn img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.p-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.p-sources a {
  color: var(--ink-soft);
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.p-sources a:hover { color: var(--green); text-decoration: underline; }

/* Interactive Answer & Action Dock */
.dock {
  width: 100%;
  max-width: 820px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px clamp(14px, 2vw, 20px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.opt-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.opt-btn {
  min-width: 46px;
  height: 42px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.08s, background 0.15s, border-color 0.15s, color 0.15s;
}
.opt-btn:hover { background: var(--surface); border-color: var(--green); }
.opt-btn:active { transform: scale(0.97); }
.opt-btn.is-correct {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}
.opt-btn.is-wrong {
  background: var(--clay-tint);
  border-color: var(--clay);
  color: var(--clay);
}
.opt-btn.is-reveal {
  background: var(--green-tint);
  border-color: var(--green);
  color: var(--green);
}

.dock-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}
.fb-ok { color: var(--green); }
.fb-err { color: var(--clay); }
.fb-muted { color: var(--muted); }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.15s;
}
.action-btn:hover { background: var(--surface); border-color: var(--green); }
.action-btn[aria-pressed="true"] {
  background: var(--green-tint);
  border-color: var(--green);
  color: var(--green);
}
.action-btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
  margin-left: auto;
}
.action-btn-primary:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
  color: var(--paper);
}

/* Written Intelligence Panel (Rubrics & Expected Answer) */
.panel {
  width: 100%;
  max-width: 820px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: clamp(16px, 2.2vw, 24px);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 650;
}
.badge-official { background: var(--green-tint); color: var(--green); border: 1px solid var(--green-border); }
.badge-ai { background: var(--amber-tint); color: var(--amber); border: 1px solid var(--amber-border); }
.score-pill {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 99px;
}
.panel-note {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--amber-tint);
  border: 1px solid var(--amber-border);
  font-size: 13px;
  color: var(--amber);
}
.panel-meta {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.dim-grid {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.dim-card {
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.dim-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 3px;
}
.dim-pts { font-size: 12px; font-weight: 650; color: var(--green); white-space: nowrap; }
.dim-desc { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }

.expected-box {
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink);
  margin: 10px 0;
}
.zero-box {
  margin: 12px 0 0;
  padding: 10px 13px;
  border-radius: 8px;
  background: var(--clay-tint);
  border: 1px solid var(--clay-border);
  font-size: 13px;
  color: var(--clay);
  line-height: 1.5;
}
.panel-foot {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.panel-foot a { color: var(--green); font-weight: 600; text-decoration: underline; }
.keypoints { margin: 8px 0 12px; padding-left: 18px; color: var(--ink-soft); font-size: 14px; }
.keypoints li { margin: 4px 0; }

/* Bottom Study Navigation Bar */
.study-bar {
  flex-shrink: 0;
  background: rgba(255, 254, 250, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px clamp(12px, 2.5vw, 28px) calc(10px + env(safe-area-inset-bottom, 0px));
}
.study-bar-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.15s;
}
.nav-btn:hover:not(:disabled) { background: var(--surface); border-color: var(--green); }
.nav-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.nav-btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}
.nav-btn-primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }

.nav-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 8px;
  min-width: 120px;
}
.nav-center:hover { background: var(--surface); }
.nav-pos { font-size: 13px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-track {
  width: 100%;
  max-width: 140px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.2s ease;
}

.shortcut-hint {
  max-width: 820px;
  margin: 7px auto 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 11.5px;
  color: var(--muted);
}
.shortcut-hint span { display: inline-flex; align-items: center; gap: 4px; }
.shortcut-hint kbd {
  font: 600 10.5px/1 var(--sans);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
}

/* Lightbox Zoom */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(25, 38, 34, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.94);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

/* Responsive Utilities */
.mobile-only { display: none; }
.desktop-only { display: flex; }

@media (max-width: 959px) {
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }

  .topbar { height: 50px; gap: 8px; justify-content: space-between; }
  .byline { display: none; }
  .search-wrap { display: none; }
  .toolbar .mobile-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 11px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .toolbar .mobile-search-wrap input {
    border: 0;
    background: transparent;
    width: 100%;
    font-size: 14px;
    outline: none;
  }
  .pill-btn { padding: 0 11px; font-size: 13px; }

  .mobile-context {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
  }
  .mobile-context-edit { font-size: 12.5px; color: var(--green); flex-shrink: 0; }

  .toolbar { display: none; padding: 12px 14px; }
  .toolbar.is-open { display: block; }
  .toolbar-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .segmented { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .seg { text-align: center; padding: 7px 4px; font-size: 12.5px; }
  .select-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .field { width: 100%; justify-content: space-between; }
  .field select { flex: 1; min-width: 0; max-width: none; text-align: right; }
  .toolbar-meta { margin-left: 0; justify-content: space-between; }

  .workbench {
    display: block;
    height: auto;
    min-height: calc(100dvh - 92px);
  }
  .stage { overflow: visible; padding-bottom: 72px; }
  .stage-inner { overflow: visible; padding: 12px 12px 24px; }
  .paper { padding: 14px; border-radius: 10px; }
  .dock { padding: 12px; border-radius: 10px; }
  .panel { padding: 14px; border-radius: 10px; }
  .dock-feedback { margin-left: 0; width: 100%; }
  .action-btn-primary { margin-left: 0; }

  .study-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
  }

  /* Slide-over Question Queue Drawer on mobile */
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: 76dvh;
    border-right: 0;
    border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 36px rgba(25, 38, 34, 0.22);
    transform: translateY(105%);
    transition: transform 0.22s ease;
  }
  .rail.is-open { transform: translateY(0); }
  .rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 650;
  }
  .rail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(25, 38, 34, 0.42);
  }
}
