:root {
  --ink: #17211f;
  --muted: #65716d;
  --line: #d9dedb;
  --paper: #f7f8f6;
  --surface: #ffffff;
  --accent: #b9ef68;
  --accent-dark: #6d9e2f;
  --danger: #b94e43;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app-shell { width: min(1380px, calc(100% - 48px)); min-height: 100vh; margin: 0 auto; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 650; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 7px; color: var(--ink); background: var(--accent); font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.progress-mini { width: 160px; display: grid; grid-template-columns: auto auto; gap: 5px 9px; align-items: center; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.progress-mini strong { color: var(--ink); text-align: right; font-weight: 500; }
.progress-track { grid-column: 1 / -1; height: 4px; overflow: hidden; background: #e2e7e3; border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent-dark); border-radius: inherit; transition: width .25s ease; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 4px; font-size: 12px; font-weight: 650; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: default; opacity: .58; transform: none; }
.button:focus-visible, .filter-tab:focus-visible, .station-option:focus-visible, .seen-toggle:focus-visible, .close-button:focus-visible, .search-box input:focus-visible, select:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
.button-primary { color: var(--ink); background: var(--accent); }
.button-primary:hover { background: #c8f582; }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button-secondary:hover { border-color: var(--ink); }
.button-quiet { color: var(--muted); background: transparent; border-color: transparent; padding-inline: 4px; }
.button-quiet:hover { color: var(--ink); }
.button-danger { color: var(--danger); background: #fbeceb; border-color: #f2d5d1; }
kbd { padding: 2px 5px; border: 1px solid currentColor; border-radius: 3px; color: inherit; font-family: var(--mono); font-size: 10px; font-weight: 500; }

.app-grid { display: grid; grid-template-columns: 315px minmax(0, 1fr); gap: 22px; padding: 22px 0 34px; }
.library-panel, .practice-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); }
.library-panel { height: calc(100vh - 128px); min-height: 590px; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 15px; border-bottom: 1px solid var(--line); }
.sidebar-heading h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.library-count { display: grid; place-items: center; min-width: 25px; height: 25px; padding: 0 6px; border-radius: 3px; color: var(--ink); background: var(--accent); font-family: var(--mono); font-size: 10px; }
.library-tools { padding: 12px 12px 14px; border-bottom: 1px solid var(--line); }
.filter-tabs { display: flex; gap: 2px; margin-bottom: 10px; }
.filter-tab { padding: 6px 9px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; }
.filter-tab:hover { color: var(--ink); background: var(--paper); }
.filter-tab.is-active { color: var(--ink); background: #e9f6d9; font-weight: 700; }
.search-box { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 9px; color: var(--muted); background: var(--paper); border: 1px solid var(--paper); border-radius: 3px; }
.search-box:focus-within { background: var(--surface); border-color: var(--ink); }
.search-box > span { font-size: 20px; line-height: 0; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #8b9691; }
.paper-list { flex: 1; overflow-y: auto; padding: 8px 9px 13px; scrollbar-color: #c8d0ca transparent; scrollbar-width: thin; }
.paper-group { border-bottom: 1px solid var(--line); }
.paper-group summary { display: flex; align-items: center; gap: 9px; padding: 11px 7px; cursor: pointer; list-style: none; }
.paper-group summary::-webkit-details-marker { display: none; }
.paper-group summary:hover { background: var(--paper); }
.paper-group summary::after { content: "+"; margin-left: auto; color: #87928d; font-family: var(--mono); font-size: 12px; }
.paper-group[open] summary::after { content: "−"; }
.paper-index { color: var(--accent-dark); font-family: var(--mono); font-size: 10px; }
.paper-name { flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.paper-name strong { font-size: 12px; font-weight: 650; }
.paper-name small, .paper-progress { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.question-list { padding: 0 4px 9px 22px; }
.station-option { width: 100%; display: grid; grid-template-columns: 27px minmax(0, 1fr) 7px; align-items: center; gap: 4px; padding: 7px 7px; border: 0; border-left: 2px solid transparent; color: var(--muted); background: transparent; text-align: left; }
.station-option:hover { color: var(--ink); background: var(--paper); }
.station-option.selected { color: var(--ink); background: #eef8df; border-left-color: var(--accent-dark); }
.station-option.seen .question-dot { background: var(--accent-dark); }
.station-number { font-family: var(--mono); font-size: 9px; }
.station-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.question-dot { width: 6px; height: 6px; background: #cbd3ce; border-radius: 50%; }
.empty-library { padding: 22px 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.practice-panel { min-height: calc(100vh - 128px); }
.practice-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 45px; padding: 0 24px; color: var(--muted); border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.practice-toolbar #stationState { color: var(--ink); }
.practice-content { max-width: 900px; padding: 42px 54px 30px; }
.question-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.question-label, .timer-label { display: block; margin: 0 0 8px; color: var(--muted); font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.question-heading h2 { margin: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.1; letter-spacing: -.045em; }
.seen-toggle { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--surface); font-size: 11px; }
.seen-toggle:hover { color: var(--ink); border-color: var(--ink); }
.seen-toggle.is-seen { color: var(--ink); border-color: var(--accent-dark); background: #eef8df; }
.check-icon { display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid currentColor; border-radius: 3px; font-size: 10px; }
.timer-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 32px 0 34px; padding: 20px 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; }
.timer-label { margin-bottom: 7px; }
.timer-display { display: block; font-family: var(--mono); font-size: clamp(42px, 6vw, 66px); font-weight: 400; line-height: 1; letter-spacing: -.09em; }
.timer-dial { --ring-angle: 0deg; position: relative; display: grid; place-items: center; width: 86px; height: 86px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--accent-dark) var(--ring-angle), #dfe4df 0); }
.timer-dial::before { content: ""; position: absolute; width: 72px; height: 72px; border-radius: 50%; background: var(--paper); }
.timer-dial-inner { position: relative; font-family: var(--mono); font-size: 10px; letter-spacing: -.05em; }
.prompt-content { color: #26332f; font-size: 17px; line-height: 1.65; }
.prompt-content p { margin: 0 0 20px; }
.prompt-content p:last-child, .prompt-content blockquote:last-child { margin-bottom: 0; }
.prompt-content blockquote { margin: 0 0 20px; padding: 3px 0 3px 16px; border-left: 3px solid var(--accent-dark); font-style: italic; }
.visual-wrap { margin: 0 0 24px; padding: 8px; border: 1px solid var(--line); background: var(--paper); }
.visual-wrap img { display: block; width: 100%; max-height: 330px; object-fit: contain; background: #e2e5e2; }
.visual-caption { margin: 7px 2px 0; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding-top: 34px; border-top: 1px solid var(--line); margin-top: 36px; }
.utility-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-top: 15px; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.utility-row span + span::before { content: "·"; margin-right: 14px; color: var(--line); }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(23, 33, 31, .36); }
.modal-backdrop[hidden] { display: none; }
.settings-modal { width: min(500px, 100%); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(23, 33, 31, .18); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { margin: 0; font-size: 18px; }
.close-button { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--surface); font-size: 20px; line-height: 1; }
.close-button:hover { color: var(--ink); border-color: var(--ink); }
.settings-grid { padding: 0 22px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row > span { display: grid; gap: 4px; }
.setting-row strong { font-size: 12px; }
.setting-row small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.setting-row select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: var(--paper); font-size: 11px; }
.switch { appearance: none; position: relative; width: 38px; height: 22px; flex: 0 0 auto; border-radius: 999px; background: #c9d1cc; transition: background .15s ease; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .15s ease; }
.switch:checked { background: var(--accent-dark); }
.switch:checked::after { transform: translateX(16px); }
.settings-footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 21px; background: var(--paper); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(340px, calc(100% - 40px)); padding: 11px 14px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); box-shadow: 0 8px 24px rgba(23, 33, 31, .14); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 30px, 720px); }
  .topbar { align-items: flex-start; padding: 15px 0; }
  .topbar-actions { gap: 13px; }
  .progress-mini { width: 125px; }
  .app-grid { display: flex; flex-direction: column; }
  .practice-panel { min-height: 0; order: 1; }
  .library-panel { order: 2; height: 500px; min-height: 0; }
  .practice-content { max-width: none; padding-inline: 30px; }
}

@media (max-width: 550px) {
  .app-shell { width: calc(100% - 20px); }
  .brand-text { max-width: 125px; white-space: normal; line-height: 1.1; }
  .topbar-actions { gap: 8px; }
  .progress-mini { display: none; }
  .button-primary { padding-inline: 11px; }
  .button-quiet kbd { display: none; }
  .practice-toolbar { padding-inline: 15px; font-size: 9px; }
  .practice-content { padding: 27px 17px 24px; }
  .question-heading { display: block; }
  .seen-toggle { margin-top: 15px; }
  .timer-row { margin-top: 24px; padding: 16px; }
  .timer-display { font-size: 43px; }
  .timer-dial { width: 70px; height: 70px; }
  .timer-dial::before { width: 58px; height: 58px; }
  .prompt-content { font-size: 16px; }
  .action-row .button-primary, .action-row .button-secondary { flex: 1 1 calc(50% - 5px); }
  .action-row .button-quiet { width: 100%; }
  .utility-row { gap: 10px; }
  .utility-row span + span::before { margin-right: 10px; }
  .settings-grid { padding-inline: 17px; }
  .modal-heading { padding-inline: 17px; }
  .settings-footer { padding-inline: 17px; }
}
