:root {
  --canvas: #e7e2d9;
  --paper: #fbfaf6;
  --paper-deep: #f1ede5;
  --paper-dark: #e8e1d6;
  --ink: #171717;
  --ink-soft: #69645c;
  --line: #d4cfc6;
  --line-strong: #938d83;
  --accent: #7b2532;
  --accent-dark: #541821;
  --accent-soft: #f0dfe2;
  --word: #e8e1cf;
  --selected: #f2c44b;
  --correct: #dcebdc;
  --correct-ink: #245237;
  --error: #f3dddd;
  --error-ink: #9b272d;
  --revealed: #e6def0;
  --revealed-ink: #5c3575;
  --shadow: 0 24px 60px rgba(35, 31, 26, .12);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --clue-size: 14px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--canvas); }
body { margin: 0; overflow: hidden; background: var(--canvas); color: var(--ink); font-family: var(--sans); }
body.high-contrast { --line: #a09a90; --line-strong: #4d4942; --word: #ddd2b9; --selected: #ffca31; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
button, input, select { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(123, 37, 50, .35); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-frame { min-height: 100vh; display: grid; grid-template-columns: 76px minmax(0, 1fr); }
.utility-rail { position: relative; z-index: 10; display: flex; flex-direction: column; align-items: center; padding: 14px 10px; background: #111; color: #f8f5ef; border-right: 1px solid #222; }
.brand-mark { width: 48px; height: 48px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; padding: 0 5px; border: 1px solid rgba(255,255,255,.65); background: transparent; color: inherit; font-family: var(--serif); font-size: 10px; font-weight: 700; letter-spacing: -1px; cursor: pointer; }
.brand-mark span:nth-child(2) { border-inline: 1px solid rgba(255,255,255,.28); }
.rail-nav, .rail-footer { width: 100%; display: grid; gap: 8px; }
.rail-nav { margin-top: 34px; }
.rail-footer { margin-top: auto; }
.rail-button { min-height: 54px; display: grid; place-items: center; gap: 2px; padding: 7px 2px; border: 0; border-radius: 8px; background: transparent; color: rgba(255,255,255,.62); cursor: pointer; transition: background 140ms ease, color 140ms ease; }
.rail-button:hover, .rail-button:focus-visible, .rail-button.is-active { background: rgba(255,255,255,.1); color: #fff; }
.rail-button span:last-child { font-size: 9px; font-weight: 650; letter-spacing: .03em; }
.rail-glyph { font-size: 21px; line-height: 1; }

.desktop-app { min-width: 0; height: 100vh; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 13px 27px; background: var(--paper); border-bottom: 1px solid var(--line-strong); }
.eyebrow, .focus-kicker, .clue-toolbar-kicker, .dialog-kicker, .status-label, .completion-kicker { display: block; font-size: 10px; line-height: 1.2; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.title-line { display: flex; align-items: baseline; gap: 12px; margin-top: 2px; }
.title-line h1 { margin: 0; font-family: var(--serif); font-size: clamp(23px, 2vw, 31px); font-weight: 600; letter-spacing: -.025em; }
.difficulty { padding: 4px 7px; border: 1px solid var(--line-strong); color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.puzzle-heading p { margin: 4px 0 0; color: var(--ink-soft); font-family: var(--serif); font-size: 12px; }
.session-status { display: flex; align-items: stretch; gap: 8px; }
.timer, .progress-status { min-width: 112px; padding: 8px 12px; border: 1px solid var(--line); background: var(--paper); text-align: left; }
.timer { cursor: pointer; }
.timer:hover { border-color: var(--line-strong); }
.timer strong, .progress-status strong { display: block; margin-top: 2px; font-family: var(--mono); font-size: 15px; }
.progress-track { width: 76px; height: 3px; display: block; margin-top: 5px; background: var(--line); }
.progress-track span { width: 0; height: 100%; display: block; background: var(--accent); transition: width 180ms ease; }
.local-button { min-width: 68px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--paper-deep); color: var(--ink-soft); cursor: pointer; font-size: 11px; font-weight: 700; }
.save-dot { width: 7px; height: 7px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: #47745b; box-shadow: 0 0 0 3px rgba(71,116,91,.12); }
body.timer-hidden .timer { display: none; }

.loading-view, .error-view { min-height: 0; display: grid; place-content: center; place-items: center; gap: 14px; padding: 40px; text-align: center; background: var(--paper-deep); }
.loading-view strong { font-family: var(--serif); font-size: 24px; }
.loading-view span { color: var(--ink-soft); }
.loading-grid { width: 82px; aspect-ratio: 1; border: 3px solid var(--ink); background: repeating-conic-gradient(var(--ink) 0 25%, var(--paper) 0 50%) 0 0 / 32px 32px; animation: loading-pulse 1.6s ease-in-out infinite alternate; }
@keyframes loading-pulse { to { transform: rotate(2deg) scale(1.04); opacity: .78; } }
.error-view { background: var(--paper-deep); }
.error-card { max-width: 480px; padding: 38px; border: 1px solid var(--line-strong); background: var(--paper); box-shadow: var(--shadow); }
.error-card h2 { margin: 12px 0 6px; font-family: var(--serif); font-size: 28px; }
.error-card p { color: var(--ink-soft); line-height: 1.6; }
.error-mark { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-family: var(--serif); font-size: 26px; }

.solve-view, .solve-workspace { min-height: 0; height: 100%; }
.solve-workspace { display: grid; grid-template-columns: minmax(500px, .92fr) minmax(520px, 1.08fr); gap: 0; overflow: hidden; }
.board-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; background: var(--paper-deep); border-right: 1px solid var(--line-strong); }
.focus-clue { min-height: 65px; display: grid; grid-template-columns: 47px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 18px; background: var(--paper); border-bottom: 1px solid var(--line); }
.focus-clue-number { width: 43px; height: 43px; display: grid; place-items: center; background: var(--ink); color: #fff; font-family: var(--serif); font-weight: 700; }
.focus-clue strong { display: block; margin-top: 2px; font-family: var(--serif); font-size: 15px; line-height: 1.25; }
.direction-toggle { min-width: 82px; padding: 8px 10px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink-soft); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.grid-stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 16px; overflow: hidden; }
.crossword-grid { --grid-size: 15; width: min(100%, calc(100vh - 230px)); max-height: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(var(--grid-size), 1fr); grid-template-rows: repeat(var(--grid-size), 1fr); border: 3px solid var(--ink); background: var(--ink); gap: 1px; box-shadow: var(--shadow); }
.cell { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 0; border: 0; background: var(--paper); color: var(--ink); cursor: pointer; user-select: none; }
.cell.black { background: var(--ink); cursor: default; }
.cell.word { background: var(--word); }
.cell.selected { background: var(--selected); box-shadow: inset 0 0 0 2px var(--ink); z-index: 1; }
.cell.correct { background: var(--correct); color: var(--correct-ink); }
.cell.incorrect { background: var(--error); color: var(--error-ink); }
.cell.revealed { background: var(--revealed); color: var(--revealed-ink); }
.cell-number { position: absolute; top: 2px; left: 3px; font-family: var(--sans); font-size: var(--cell-number-size, 9px); line-height: 1; font-weight: 600; }
.cell-letter { transform: translateY(5%); font-family: var(--sans); font-size: var(--cell-letter-size, 22px); line-height: 1; font-weight: 650; text-transform: uppercase; }
.cell.pencil .cell-letter { color: var(--ink-soft); font-size: var(--cell-pencil-size, 18px); font-weight: 500; }
.paused-overlay { position: absolute; inset: 16px; display: grid; place-content: center; place-items: center; gap: 14px; background: rgba(251,250,246,.96); border: 1px solid var(--line-strong); z-index: 4; }
.paused-overlay span { font-family: var(--serif); font-size: 27px; }
.paused-overlay button { padding: 10px 17px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; }
.board-toolbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 13px; background: var(--paper); border-top: 1px solid var(--line-strong); }
.tool-group { display: flex; align-items: center; gap: 3px; }
.tool-group-centre { margin-left: auto; }
.tool-button, .icon-tool { min-height: 34px; padding: 6px 10px; border: 1px solid transparent; background: transparent; color: var(--ink-soft); font-size: 11px; font-weight: 700; cursor: pointer; }
.tool-button:hover, .icon-tool:hover { border-color: var(--line); color: var(--ink); }
.tool-button.is-active { border-color: var(--ink); background: var(--ink); color: #fff; }
.icon-tool { min-width: 40px; font-size: 16px; letter-spacing: 2px; }
.keyboard-hint { min-height: 28px; display: flex; align-items: center; justify-content: center; gap: 17px; padding: 5px 12px; border-top: 1px solid var(--line); background: var(--paper); color: var(--ink-soft); font-size: 9px; }
kbd { min-width: 19px; display: inline-block; padding: 2px 4px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--paper-deep); color: var(--ink); font-family: var(--mono); font-size: 8px; text-align: center; }

.clue-workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; background: var(--paper); }
.clue-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 17px; border-bottom: 1px solid var(--line); }
.clue-toolbar strong { display: block; margin-top: 2px; font-family: var(--serif); font-size: 15px; }
.clue-size-controls { display: flex; border: 1px solid var(--line); }
.clue-size-controls button { width: 35px; height: 30px; border: 0; border-right: 1px solid var(--line); background: var(--paper); cursor: pointer; font-family: var(--serif); font-weight: 700; }
.clue-size-controls button:last-child { border-right: 0; }
.clue-tabs { display: none; padding: 0 17px; border-bottom: 1px solid var(--line); }
.clue-tabs button { flex: 1; padding: 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ink-soft); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.clue-tabs button.is-active { border-bottom-color: var(--accent); color: var(--accent); }
.clue-columns { min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.clue-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); border-right: 1px solid var(--line); }
.clue-column:last-child { border-right: 0; }
.clue-column-heading { min-height: 42px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 2px solid var(--ink); }
.clue-column-heading h2 { margin: 0; font-family: var(--serif); font-size: 18px; }
.clue-column-heading span { color: var(--ink-soft); font-size: 9px; }
.clue-list { min-height: 0; margin: 0; padding: 4px 0 18px; overflow: auto; list-style: none; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.clue-item { width: 100%; display: grid; grid-template-columns: 29px minmax(0, 1fr); gap: 7px; padding: 7px 12px; border-top: 0; border-right: 0; border-bottom: 0; border-left: 3px solid transparent; background: transparent; color: inherit; text-align: left; cursor: pointer; font-family: var(--serif); font-size: var(--clue-size); line-height: 1.28; }
.clue-item:hover { background: var(--paper-deep); }
.clue-item.is-active { border-left-color: var(--accent); background: var(--accent-soft); }
.clue-item.is-complete .clue-copy { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1px; }
.clue-number { font-weight: 700; text-align: right; }
.clue-meta { display: block; margin-top: 2px; color: var(--ink-soft); font-family: var(--sans); font-size: 8px; letter-spacing: .05em; text-transform: uppercase; }
.autosave-note { min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 7px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 9px; }

.library-view { min-height: 0; overflow: auto; padding: 32px clamp(24px, 4vw, 58px) 54px; background: var(--paper-deep); }
.view-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.view-heading h2 { margin: 4px 0 8px; font-family: var(--serif); font-size: clamp(31px, 4vw, 52px); font-weight: 600; letter-spacing: -.035em; }
.view-heading p { max-width: 680px; margin: 0; color: var(--ink-soft); line-height: 1.6; }
.catalogue-total { min-width: 160px; padding: 18px; border: 1px solid var(--line-strong); background: var(--paper); text-align: center; }
.catalogue-total strong { display: block; font-family: var(--serif); font-size: 30px; }
.catalogue-total span { color: var(--ink-soft); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.archive-controls { display: grid; grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(140px, .7fr)); gap: 10px; margin-bottom: 16px; }
.archive-controls label { display: grid; gap: 5px; color: var(--ink-soft); font-size: 9px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.archive-controls input, .archive-controls select { min-height: 42px; width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--paper); color: var(--ink); font-size: 13px; text-transform: none; }
.archive-list { display: grid; gap: 8px; }
.archive-item { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto; align-items: center; gap: 15px; padding: 13px 15px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; transition: border-color 120ms ease, transform 120ms ease; }
.archive-item:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.archive-number { width: 42px; height: 42px; display: grid; place-items: center; background: var(--ink); color: #fff; font-family: var(--serif); font-weight: 700; }
.archive-copy strong { display: block; font-family: var(--serif); font-size: 17px; }
.archive-copy span, .archive-meta span { color: var(--ink-soft); font-size: 10px; }
.archive-meta { display: flex; gap: 7px; }
.archive-meta span { padding: 5px 7px; border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .05em; }
.archive-progress { min-width: 94px; text-align: right; }
.archive-progress strong { display: block; font-family: var(--mono); font-size: 13px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 9px; color: var(--ink-soft); }
.status-pill.complete { color: var(--correct-ink); }
.status-pill.started { color: var(--accent); }
.empty-state { padding: 46px 20px; border: 1px dashed var(--line-strong); background: rgba(255,255,255,.45); text-align: center; color: var(--ink-soft); }
.load-more { display: block; margin: 18px auto 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { min-height: 150px; padding: 22px; border: 1px solid var(--line-strong); background: var(--paper); }
.stat-card strong { display: block; font-family: var(--serif); font-size: clamp(34px, 4vw, 52px); font-weight: 600; }
.stat-card span { color: var(--ink-soft); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.stat-card p { margin: 13px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.recent-panel, .settings-card { border: 1px solid var(--line-strong); background: var(--paper); }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h3, .settings-card h3 { margin: 0; font-family: var(--serif); font-size: 22px; }
.panel-heading span { color: var(--ink-soft); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.recent-list { display: grid; }
.recent-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.recent-item:last-child { border-bottom: 0; }
.recent-item strong { font-family: var(--serif); }
.recent-item span { color: var(--ink-soft); font-size: 11px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-card { padding: 21px; }
.settings-card:last-child { grid-column: 1 / -1; }
.settings-card > p { color: var(--ink-soft); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { font-family: var(--serif); font-size: 16px; }
.setting-row small { margin-top: 4px; color: var(--ink-soft); line-height: 1.45; }
.setting-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.primary-button, .secondary-button, .danger-button, .text-button { min-height: 42px; padding: 10px 16px; border-radius: 0; cursor: pointer; font-weight: 700; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.danger-button { border: 1px solid #9b272d; background: transparent; color: #9b272d; }
.text-button { border: 0; background: transparent; color: var(--accent); }

.shortcut-dialog, .action-dialog, .completion-dialog { width: min(92vw, 560px); padding: 0; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.shortcut-dialog::backdrop, .action-dialog::backdrop, .completion-dialog::backdrop { background: rgba(17,17,17,.56); backdrop-filter: blur(2px); }
.shortcut-dialog form, .action-dialog form { padding: 23px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 18px; }
.dialog-heading h2 { margin: 3px 0 0; font-family: var(--serif); font-size: 28px; }
.dialog-close { width: 35px; height: 35px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 22px; }
.shortcut-list { display: grid; gap: 0; margin: 0; }
.shortcut-list div { display: grid; grid-template-columns: 130px 1fr; gap: 15px; padding: 10px 0; border-top: 1px solid var(--line); }
.shortcut-list dt { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.shortcut-list dd { margin: 0; color: var(--ink-soft); font-size: 13px; }
.action-dialog p { color: var(--ink-soft); line-height: 1.55; }
.scope-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scope-grid button { min-height: 72px; padding: 10px; border: 1px solid var(--line-strong); background: var(--paper-deep); cursor: pointer; font-family: var(--serif); font-weight: 700; }
.scope-grid button:hover { background: var(--accent-soft); border-color: var(--accent); }
.completion-dialog { width: min(92vw, 460px); }
.completion-card { padding: 32px; text-align: center; }
.completion-card h2 { margin: 5px 0 8px; font-family: var(--serif); font-size: 34px; }
.completion-card > p { margin: 0; color: var(--ink-soft); }
.completion-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 24px 0; border-block: 1px solid var(--line); }
.completion-stats div { padding: 15px 8px; border-right: 1px solid var(--line); }
.completion-stats div:last-child { border-right: 0; }
.completion-stats strong { display: block; font-family: var(--mono); font-size: 17px; }
.completion-stats span { color: var(--ink-soft); font-size: 9px; letter-spacing: .07em; text-transform: uppercase; }
.completion-actions { display: grid; gap: 8px; }
.menu-popover { position: fixed; z-index: 30; min-width: 190px; padding: 5px; border: 1px solid var(--line-strong); background: var(--paper); box-shadow: var(--shadow); }
.menu-popover button { width: 100%; padding: 10px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; font-size: 12px; }
.menu-popover button:hover { background: var(--paper-deep); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(90vw, 520px); transform: translate(-50%, 18px); opacity: 0; pointer-events: none; padding: 10px 15px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 12px; transition: transform 180ms ease, opacity 180ms ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1260px) {
  .solve-workspace { grid-template-columns: minmax(470px, 1.08fr) minmax(360px, .92fr); }
  .clue-tabs { display: flex; }
  .clue-columns { grid-template-columns: 1fr; }
  .clue-column { border-right: 0; }
  .archive-controls { grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(115px, .7fr)); }
}

@media (max-width: 950px) {
  body { overflow: auto; }
  .app-frame { min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: 58px minmax(0, 1fr); }
  .utility-rail { position: sticky; top: 0; flex-direction: row; padding: 6px 11px; border-right: 0; border-bottom: 1px solid #222; }
  .brand-mark { width: 42px; height: 42px; }
  .rail-nav, .rail-footer { width: auto; display: flex; gap: 3px; margin: 0; }
  .rail-nav { margin-left: 15px; }
  .rail-footer { margin-left: auto; }
  .rail-button { min-width: 54px; min-height: 43px; padding: 4px 7px; }
  .rail-glyph { font-size: 17px; }
  .desktop-app { height: auto; min-height: calc(100vh - 58px); grid-template-rows: auto auto; }
  .topbar { min-height: 78px; padding: 11px 17px; }
  .session-status { gap: 5px; }
  .timer, .progress-status { min-width: 90px; padding: 7px 8px; }
  .local-button { min-width: 54px; }
  .local-button span:last-child { display: none; }
  .solve-workspace { display: grid; grid-template-columns: 1fr; overflow: visible; }
  .board-column { min-height: min(830px, calc(100vh - 136px)); border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .crossword-grid { width: min(92vw, 670px); max-height: none; }
  .clue-workspace { min-height: 620px; }
  .keyboard-hint { flex-wrap: wrap; }
  .library-view { min-height: calc(100vh - 136px); }
  .archive-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .utility-rail { overflow-x: auto; }
  .brand-mark { flex: 0 0 auto; }
  .rail-button { min-width: 48px; }
  .rail-button span:last-child { display: none; }
  .topbar { align-items: flex-start; gap: 10px; padding: 10px 12px; }
  .title-line { display: block; }
  .title-line h1 { max-width: 55vw; font-size: 19px; line-height: 1.1; }
  .difficulty { display: inline-block; margin-top: 5px; }
  .puzzle-heading p { max-width: 55vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .timer, .progress-status { min-width: 68px; padding: 6px; }
  .progress-track { width: 52px; }
  .local-button { display: none; }
  .focus-clue { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px; padding: 8px 10px; }
  .focus-clue-number { width: 36px; height: 36px; }
  .focus-clue strong { font-size: 13px; }
  .direction-toggle { min-width: 62px; padding: 7px 5px; font-size: 8px; }
  .grid-stage { padding: 8px; }
  .paused-overlay { inset: 8px; }
  .board-toolbar { overflow-x: auto; padding: 5px 7px; }
  .tool-button { white-space: nowrap; padding: 6px 7px; font-size: 10px; }
  .keyboard-hint { display: none; }
  .board-column { grid-template-rows: auto auto auto; min-height: auto; }
  .crossword-grid { width: min(96vw, 620px); }
  .clue-toolbar { padding: 8px 12px; }
  .library-view { padding: 24px 13px 46px; }
  .view-heading { display: block; }
  .catalogue-total { margin-top: 18px; }
  .archive-controls { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .archive-item { grid-template-columns: 42px minmax(0, 1fr); gap: 10px; }
  .archive-meta, .archive-progress { grid-column: 2; text-align: left; }
  .archive-meta { flex-wrap: wrap; }
  .stats-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-card:last-child { grid-column: auto; }
  .recent-item { grid-template-columns: minmax(0, 1fr) auto; }
  .recent-item span:last-child { grid-column: 1 / -1; }
  .scope-grid { grid-template-columns: 1fr; }
  .shortcut-list div { grid-template-columns: 100px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
}

@media print {
  body { overflow: visible; background: #fff; }
  .utility-rail, .topbar, .board-toolbar, .keyboard-hint, .clue-toolbar, .clue-tabs, .autosave-note, .toast { display: none !important; }
  .app-frame, .desktop-app, .solve-view, .solve-workspace { display: block; height: auto; }
  .board-column { display: block; border: 0; }
  .focus-clue { margin-bottom: 10px; border: 1px solid #000; }
  .grid-stage { display: block; padding: 0; }
  .crossword-grid { width: 17cm; max-width: 100%; margin: 0 auto; box-shadow: none; }
  .clue-workspace { display: block; margin-top: 18px; }
  .clue-columns { display: grid; grid-template-columns: 1fr 1fr; }
  .clue-list { overflow: visible; }
  .cell.selected, .cell.word { background: var(--paper); box-shadow: none; }
}
