:root {
  color-scheme:dark;
  --bg:#0b1325;
  --panel:#111f36;
  --text:#e2e8f0;
  --muted:#94a3b8;
  --blue:#bfdbfe;
  --accent:#60a5fa;
  --border:#7897c12e;
  font-family:system-ui,-apple-system,"Yu Gothic",sans-serif;
  background:var(--bg);
  color:var(--text)
}

* {
  box-sizing:border-box
}
body {
  margin:0;
  background:radial-gradient(ellipse at 90% 0,#1b33533d,transparent 55%);
  min-height:100vh
}
button,input,textarea,select {
  font:inherit
}
button {
  color:var(--text);
  background:#182942;
  border:1px solid #7897c159;
  border-radius:8px;
  padding:12px 18px;
  min-height:46px;
  cursor:pointer
}
button:hover {
  border-color:var(--accent);
  background:#213957
}
button:disabled {
  opacity:.45;
  cursor:not-allowed
}
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible {
  outline:3px solid var(--accent);
  outline-offset:4px
}
button.primary {
  background:var(--blue);
  color:#101e33;
  border-color:var(--blue);
  font-weight:650
}
button.primary:hover {
  background:#d5e8ff
}
.quiet,.back {
  background:transparent
}
.back {
  border:0;
  padding-left:0;
  color:var(--muted);
  margin-bottom:24px
}
.site-header {
  max-width:1180px;
  margin:auto;
  padding:24px 36px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  border-bottom:1px solid var(--border)
}
.brand {
  border:0;
  background:transparent;
  padding:0;
  font-family:serif;
  font-size:19px;
  letter-spacing:.06em
}
.brand span {
  color:var(--blue);
  font-size:28px;
  margin-right:8px
}
.brand small {
  font-size:12px;
  color:var(--muted)
}
main {
  min-height:70vh
}
.narrow {
  max-width:860px;
  margin:auto;
  padding:56px 28px 80px
}
.eyebrow {
  font-size:11px;
  letter-spacing:.24em;
  color:var(--accent);
  margin:0 0 24px
}
h1 {
  font-family:"Yu Mincho","Hiragino Mincho ProN",serif;
  font-size:34px;
  line-height:1.55;
  font-weight:500;
  margin:0 0 28px;
  letter-spacing:.06em
}
#home h1 {
  font-size:52px;
  line-height:1.45;
  margin-bottom:22px
}
.lead {
  line-height:2;
  color:var(--muted);
  font-family:serif;
  letter-spacing:.06em
}
.home-tagline { white-space:nowrap; }
.entry-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:20px;
  margin:44px 0 30px
}
.entry {
  text-align:left;
  padding:22px;
  background:linear-gradient(140deg,#172b45aa,#101c30);
  border-color:#7897c13d;
  display:flex;
  flex-direction:column;
  gap:22px
}
.entry-number {
  color:var(--accent);
  letter-spacing:.15em;
  font-size:11px
}
.entry strong {
  font-family:serif;
  font-size:20px;
  font-weight:500;
  display:flex;
  justify-content:space-between;
  gap:12px
}
.entry>span:last-child {
  color:var(--muted);
  font-size:14px;
  line-height:1.9
}
.privacy,.muted {
  color:var(--muted);
  font-size:13px;
  line-height:1.9
}
.privacy {
  margin-top:24px
}
.inline {
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap
}
.spread {
  justify-content:space-between
}
label,legend {
  font-size:15px;
  line-height:1.8
}
label {
  display:block;
  margin-bottom:10px
}
textarea,input[type=number],select {
  border:1px solid #7897c157;
  border-radius:8px;
  background:#080f1e;
  color:var(--text);
  padding:14px;
  max-width:100%
}
textarea {
  width:100%;
  resize:vertical;
  line-height:1.8
}
input[type=number] {
  width:220px
}
#preparation-target { width:min(220px,calc(100% - 48px)); }

/* Independent, frozen text layout. One millimetre of vertical tolerance avoids
   rounding an A4 content box into an extra blank page in print engines. */
#manuscript-print { display:none; }
#manuscript-print.print-measuring { display:block; position:fixed; left:-100000px; top:0; visibility:hidden; pointer-events:none; }
.manuscript-page { position:relative; width:180mm; height:266mm; margin:0; padding:0; border:0; overflow:hidden; background:#fff; color:#000; }
.manuscript-canvas { position:absolute; top:0; color:#000; }
.manuscript-piece { position:absolute; top:0; white-space:pre; overflow-wrap:normal; word-break:normal; }
.manuscript-annotation { color:#17365d; }
.manuscript-source-ruby { display:inline-block; white-space:nowrap; line-height:1.5; padding-top:.6em; text-indent:0; }
.manuscript-source-ruby ruby { ruby-position:over; ruby-align:center; }
.manuscript-source-ruby rt { font-size:.5em; line-height:1; font-weight:normal; color:#000; }
.manuscript-ruby-reading { position:relative; }
.manuscript-markers, .manuscript-pens { position:absolute; inset:0; overflow:visible; pointer-events:none; }
.manuscript-markers { z-index:0; }
.manuscript-markers rect { fill:#ffe588; }
.manuscript-markers rect[data-color=lightblue] { fill:#bde9fa; }
.manuscript-markers rect[data-color=pink] { fill:#ffd0df; }
.manuscript-line { position:relative; z-index:1; }
.manuscript-pens { z-index:2; }
.manuscript-pens path { fill:none; stroke:#c52228; stroke-linecap:round; stroke-linejoin:round; }
.manuscript-pens path[data-color=blue] { stroke:#2563eb; }
.manuscript-pens path[data-color=green] { stroke:#15803d; }
.manuscript-notes-title { position:absolute; top:12px; left:12px; right:12px; margin:0; font:600 18px/1.5 system-ui,sans-serif; color:#17365d; }
.manuscript-note-reference { position:absolute; left:12px; right:12px; margin:0; font:12px/1.6 system-ui,sans-serif; color:#17365d; overflow-wrap:anywhere; }
.manuscript-page .writing-memo { width:calc(180px * var(--memo-print-scale)); }
.manuscript-page .memo-body { border:0; padding:calc(11px * var(--memo-print-scale)); border-radius:calc(10px * var(--memo-print-scale)); box-shadow:inset 0 0 0 calc(2px * var(--memo-print-scale)) currentColor; }
.manuscript-page .memo-tail path { stroke-width:calc(2px * var(--memo-print-scale)); }
.manuscript-page .memo-tip { r:calc(5px * var(--memo-print-scale)); stroke-width:var(--memo-print-scale); }
#pdf-dialog h2 { margin-top:0; }
#pdf-dialog p { line-height:1.8; }
#pdf-small-warning { color:#fcd58a; }
#confirm-message { white-space: pre-line; }
.partial-measurement { margin: 16px 0; }
.partial-measurement .choice { margin-bottom: 0; }
#preparation-info { white-space: pre-line; }
.reading-end-marker {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font: 14px/1.8 system-ui, sans-serif;
  text-align: center;
}
@page { size:A4 portrait; margin:15mm; }
@media print {
  html:has(body.manuscript-printing) { background:#fff!important; color-scheme:light; scrollbar-gutter:auto; }
  body.manuscript-printing { background:#fff!important; margin:0; padding:0; min-height:0; }
  body.manuscript-printing > :not(#manuscript-print) { display:none!important; }
  body.manuscript-printing #manuscript-print { display:block; position:static; visibility:visible; margin:0; padding:0; width:180mm; }
  .manuscript-page { break-inside:avoid; break-after:page; page-break-inside:avoid; page-break-after:always; print-color-adjust:exact; -webkit-print-color-adjust:exact; }
  .manuscript-page:last-child { break-after:auto; page-break-after:auto; }
}
select {
  display:block;
  min-width:140px;
  margin-top:8px
}
fieldset {
  border:1px solid var(--border);
  border-radius:12px;
  padding:24px;
  margin:0 0 28px
}
legend {
  padding:0 8px;
  color:var(--blue)
}
.choice {
  padding:12px 0;
  cursor:pointer;
  display:inline-flex;
  gap:12px;
  align-items:center;
  max-width:100%;
  box-sizing:border-box
}
.choice input {
  accent-color:var(--accent);
  width:20px;
  height:20px;
  flex:0 0 20px
}
.inset {
  margin-left:32px
}
h2 {
  font-size:18px;
  font-weight:500;
  margin-top:36px
}
footer {
  max-width:1108px;
  margin:auto;
  padding:26px 0;
  border-top:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  color:var(--muted);
  font-size:11px;
  letter-spacing:.08em
}
.reader-toolbar {
  position:sticky;
  top:0;
  z-index:5;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 24px;
  background:#0b1325f5;
  border-bottom:1px solid var(--border)
}
.reader-toolbar h1 { margin:0; }
.reader-actions { display:grid; gap:8px; flex-shrink:0; }
.reader-controls { position:sticky; top:0; z-index:5; background:var(--bg); }
.reader-controls .reader-toolbar { position:static; }
#writing-toolbar { padding:8px 16px; border-bottom:1px solid var(--border); background:var(--panel); }
.writing-menu-heading { display:flex; justify-content:flex-end; margin-bottom:4px; }
#writing-off { min-height:32px; width:32px; padding:0; background:transparent; border-color:transparent; font-size:22px; line-height:1; }
#writing-off:hover { background:#213957; border-color:var(--border); }
#writing-mode > span { white-space:normal; line-height:1.3; }
.writing-tools { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; max-width:600px; margin:auto; }
.writing-tools button { min-height:40px; padding:8px 4px; font-size:14px; white-space:nowrap; }
.writing-tools button[aria-pressed=true] { background:var(--blue); color:var(--bg); border-color:var(--blue); }
.writing-options { display:flex; align-items:center; justify-content:center; gap:8px; margin-top:6px; }
.writing-options span { color:var(--muted); font-size:11px; }
.writing-options button { font-size:12px; padding:7px; min-height:34px; }
#marker-colors, #pen-options { display:flex; justify-content:center; gap:6px; margin-top:6px; }
#marker-colors button, #pen-options button { display:flex; align-items:center; gap:5px; min-height:34px; padding:6px 10px; font-size:12px; }
#marker-colors button::before { content:""; width:12px; height:12px; border-radius:50%; background:#ffd148; }
#marker-colors [data-marker-color=lightblue]::before { background:#60c6ff; }
#marker-colors [data-marker-color=pink]::before { background:#ff89b9; }
#marker-colors [aria-pressed=true], #pen-options [aria-pressed=true] { border-color:var(--blue); outline:1px solid var(--blue); background:#23364f; }
#pen-options [data-pen-color]::before { content:""; width:12px; height:12px; border-radius:50%; background:#ff6b6b; }
#pen-options [data-pen-color=blue]::before { background:#60a5fa; }
#pen-options [data-pen-color=green]::before { background:#4ade80; }
#pen-options .tool-icon { width:16px; height:18px; }
#writing-tool-help { margin:6px 0 0; font-size:12px; text-align:center; color:var(--muted); line-height:1.5; }
#reader-stage { display:grid; grid-template-columns:minmax(0,1fr); position:relative; isolation:isolate; }
.reader-text-area { display:flow-root; min-width:0; }
#reader-stage #reader { position:relative; z-index:1; }
#writing-markers, #writing-pen, #writing-memos { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
#writing-markers { z-index:0; overflow:hidden; }
#writing-markers rect { fill:rgba(255,209,72,.38); }
#writing-markers rect[data-color=lightblue] { fill:rgba(96,198,255,.38); }
#writing-markers rect[data-color=pink] { fill:rgba(255,137,185,.38); }
#writing-pen { z-index:2; overflow:visible; touch-action:none; }
#writing-pen path { fill:none; stroke:#ff6b6b; stroke-width:2.8; stroke-linecap:round; stroke-linejoin:round; }
#writing-pen path[data-color=blue] { stroke:#60a5fa; }
#writing-pen path[data-color=green] { stroke:#4ade80; }
#writing-memos { z-index:3; }
.writing-active { user-select:none; -webkit-user-select:none; touch-action:pan-y; }
.writing-drag { touch-action:none; cursor:crosshair; }
/* Paint the entire writing stage without changing its box or glyph layout. */
#reader-stage.paper-mode { background:#fff; color:#17191d; }
#reader-stage.paper-mode .reading-annotation { color:#2563EB; }
#reader-stage.paper-mode #writing-pen path { stroke:#c52228; }
#reader-stage.paper-mode #writing-pen path[data-color=blue] { stroke:#2563eb; }
#reader-stage.paper-mode #writing-pen path[data-color=green] { stroke:#15803d; }
#writing-pen path.pen-selection { stroke-width:8; opacity:.22; }
#reader-stage #writing-pen path.pen-hit { stroke:transparent; stroke-width:20; pointer-events:stroke; touch-action:none; cursor:move; }
#reader-stage.paper-mode #writing-markers rect { fill:#ffe588; }
#reader-stage.paper-mode #writing-markers rect[data-color=lightblue] { fill:#bde9fa; }
#reader-stage.paper-mode #writing-markers rect[data-color=pink] { fill:#ffd0df; }
#writing-memo-dialog { position:fixed; inset:auto 0; top:var(--editor-center,50dvh); transform:translateY(-50%); margin:0 auto; max-height:var(--editor-height,calc(100dvh - 24px)); }
#writing-memo-dialog h2 { margin:0 0 8px; }
#writing-memo-input { width:100%; min-height:46px; padding:10px; border:1px solid #7897c157; border-radius:8px; background:#080f1e; color:var(--text); font-size:16px; }
.ruby-help { margin:8px 16px; color:var(--muted); font-size:12px; text-align:center; }
.reading-annotation { color:#fcd58a; }
/* Atomic base/reading pairs reserve enough line-box space at low line heights.
   The reader measures the base text, never the small reading above it. */
.source-ruby-unit { display:inline-block; white-space:nowrap; line-height:1.5; padding-top:.6em; text-indent:0; }
.source-ruby-unit ruby { ruby-position:over; ruby-align:center; }
.source-ruby-unit rt { font-size:.5em; line-height:1; font-weight:normal; }
.ruby-mode .reading-annotation { cursor:pointer; }
.reading-annotation:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.annotation-draft { text-decoration:underline dotted; text-underline-offset:.2em; }
#ruby-dialog {
  position:fixed;
  inset:auto 0;
  top:var(--editor-center,50dvh);
  transform:translateY(-50%);
  margin:0 auto;
  max-height:var(--editor-height,calc(100dvh - 24px));
}
#ruby-dialog h2 { margin:0 0 8px; }
#ruby-dialog .muted { margin:0 0 12px; }
#ruby-input { width:100%; min-height:46px; padding:10px; border:1px solid #7897c157; border-radius:8px; background:#080f1e; color:var(--text); font-size:16px; }
.ruby-editor-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; margin-top:16px; }
.ruby-editor-actions button { padding:10px 12px; }
.preparation {
  max-width:720px;
  margin:28px auto;
  padding:24px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px
}
.preparation>p:first-child {
  margin-top:0;
  line-height:1.8
}
#reader {
  font-family:"Yu Mincho","Hiragino Mincho ProN","Noto Serif CJK JP",serif;
  font-size:22px;
  line-height:1.8;
  width:min(900px,calc(100% - 40px));
  margin:40px auto 0;
  padding-bottom:max(160px,calc(var(--settings-panel-height,0px) + 32px));
  overflow-wrap:anywhere;
  line-break:strict;
  font-kerning:normal
}
.text-block {
  white-space:pre-wrap;
  position:relative;
  margin:0
}
.line-segment {
  position:relative
}
.natural-gap {
  white-space:pre-wrap;
  margin:0;
  line-height:inherit
}
.layout-status {
  font-size:12px;
  color:var(--muted);
  text-align:center;
  margin:12px 20px;
  min-height:1.5em
}
.measurement-bar {
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:24px;
  background:#0b1325f5;
  border-top:1px solid var(--border);
  padding:14px 24px calc(14px + env(safe-area-inset-bottom))
}
.measurement-bar button {
  min-width:160px;
  font-size:18px
}
.measurement-time { display:flex; flex-direction:column; align-items:center; gap:3px; min-width:70px; }
.measurement-time #elapsed { font-size:20px; }
.measurement-time small { color:var(--blue); font-size:11px; white-space:nowrap; }
.measurement-bar span {
  color:var(--muted);
  font-variant-numeric:tabular-nums
}
.countdown {
  position:fixed;
  inset:0;
  background:#0b1325b8;
  z-index:20;
  display:grid;
  place-items:center;
  font-family:serif;
  font-size:80px;
  color:var(--blue);
  pointer-events:all
}
.estimate {
  color:var(--blue);
  font-family:serif;
  font-size:52px;
  line-height:1.4;
  margin:28px 0 12px
}
.pace-card,.calculation-card,.empty-state {
  padding:24px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#101e32;
}
.pace-card { margin-bottom:20px; }
.pace-card h2,.calculation-card h2 { font-size:17px; margin:0 0 20px; line-height:1.7; }
.pace-card .estimate { font-size:clamp(26px,6vw,48px); margin:16px 0; overflow-wrap:anywhere; }
.calculation-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.calculation-card label { display:block; margin:16px 0 8px; }
.calculation-card .inline { flex-wrap:nowrap; }
.calculation-card .inline>span { flex-shrink:0; white-space:nowrap; }
.calculation-card input { width:100%; min-width:0; }
.calculation-value { color:var(--blue); font-size:24px; margin:24px 0 0; overflow-wrap:anywhere; }
.empty-state { margin-bottom:20px; line-height:1.9; }
.history-section { margin-top:32px; border-top:1px solid var(--border); padding-top:16px; }
.history-section summary { cursor:pointer; padding:12px 0; min-height:44px; }
@media(min-width:601px) { #home { max-width:1100px; } }
@media(max-width:1000px) and (min-width:601px) {
  .entry-grid { grid-template-columns:1fr; }
}
@media(max-width:600px) {
  .calculation-grid { grid-template-columns:1fr; }
  .pace-card,.calculation-card,.empty-state { padding:20px; }
}
.history {
  list-style:none;
  padding:0
}
.history li {
  padding:18px 0;
  border-bottom:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:center
}
.history small {
  display:block;
  color:var(--muted);
  line-height:1.8
}
dialog {
  width:min(440px,calc(100% - 32px));
  border:1px solid #7897c16b;
  border-radius:14px;
  color:var(--text);
  background:#111f36;
  padding:24px;
  max-height:85dvh;
  overflow:auto
}
dialog::backdrop {
  background:#020713b8
}
.dialog-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:24px
}
.dialog-heading h2 {
  margin:0
}
input[type=range] {
  display:block;
  width:100%;
  margin:12px 0 28px;
  accent-color:var(--accent);
  min-height:30px
}
output {
  float:right;
  color:var(--blue)
}
.notice {
  position:fixed;
  bottom:100px;
  left:50%;
  transform:translateX(-50%);
  background:#213957;
  color:var(--text);
  padding:16px 24px;
  border:1px solid var(--accent);
  border-radius:8px;
  z-index:50;
  width:max-content;
  max-width:calc(100% - 32px);
  font-size:14px
}
.reading-view~* {
  background:var(--bg)
}
[hidden] {
  display:none!important
}

@media(max-width:600px) {
  .site-header {
  padding:16px 20px
}
.brand {
  font-size:16px
}
.narrow {
  padding:36px 20px 56px
}
#home h1 {
  font-size:clamp(32px,10vw,40px)
}
.entry-grid {
  grid-template-columns:1fr;
  gap:14px;
  margin-top:32px
}
.entry {
  padding:24px;
  gap:16px
}
.entry strong {
  font-size:clamp(18px,5.6vw,22px)
}
#screen-id-copy { cursor:pointer; border-radius:2px; }
#screen-id-copy:focus-visible { outline:3px solid var(--accent); outline-offset:4px; }
h1 {
  font-size:28px
}
footer {
  margin:0 20px;
  gap:16px;
  line-height:1.8;
  flex-direction:column
}
fieldset {
  padding:16px
}
.inset {
  margin-left:12px
}
.reader-toolbar { padding:8px; gap:6px; }
.preparation {
  margin:20px 16px;
  padding:18px
}
#reader {
  font-size:22px;
  width:calc(100% - 32px);
  margin-top:28px
}
.measurement-bar button {
  flex:1;
  min-width:0;
  font-size:14px;
  padding:10px 6px
}
.measurement-bar { gap:8px; padding:10px 12px calc(10px + env(safe-area-inset-bottom)); }
.estimate {
  font-size:42px
}
.history li {
  align-items:flex-start
}
dialog {
  padding:20px
}

}


/* Let the reader restore source offsets without competing scroll anchoring. */
#reader { overflow-anchor: none; }

/* Reserve scrollbar space so opening settings never changes the text width. */
html { scrollbar-gutter: stable; }
.settings-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.settings-tabs button { flex: 1; min-width: 0; padding: 8px; min-height: 40px; font-size: 14px; white-space: nowrap; }
.settings-tabs [aria-selected=true] { background: var(--blue); color: var(--bg); }
@media(max-width:600px) {
  #settings-dialog[open] {
    position: fixed;
    inset: auto 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    max-height: min(260px,45dvh);
    border-radius: 14px 14px 0 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    z-index: 15;
    box-shadow: 0 -8px 24px #02071340;
  }
  #settings-dialog .dialog-heading { margin-bottom: 8px; }
  #settings-dialog .dialog-heading button { min-height: 36px; padding: 6px 12px; }
  #settings-dialog .settings-help { display: none; }
  #settings-dialog label { margin-bottom: 0; }
  #settings-dialog input[type=range] { margin: 4px 0 0; min-height: 40px; }
}

/* Keep both toolbar rows together when the mobile surface slides away. */
.reader-toolbar { display:grid; grid-template-columns:auto minmax(0,1fr) auto; grid-template-areas:"back actions wake"; gap:12px; padding:8px 16px; }
#reader-topline { display:contents; }
#reader-back { grid-area:back; }
#wake { grid-area:wake; }
#reader-actions { grid-area:actions; display:flex; align-items:center; justify-content:center; gap:6px; width:min(100%,840px); justify-self:center; }
#reader-actions button { min-width:0; }
.reader-toolbar button,.writing-tools button { display:flex; justify-content:center; align-items:center; gap:5px; min-height:44px; padding:8px; white-space:nowrap; }
.tool-icon { width:21px; height:24px; flex:none; }
.button-state { font-size:10px; border:1px solid currentColor; border-radius:3px; padding:1px 2px; }
.reader-toolbar button[aria-pressed=true],.reader-toolbar button[aria-expanded=true],.writing-tools button[aria-pressed=true] { outline:2px solid var(--blue); outline-offset:1px; box-shadow:inset 0 -3px 0 currentColor; }
#writing-mode[aria-expanded=true] { background:#23364f; border-color:var(--blue); }
.writing-tools { grid-template-columns:repeat(6,minmax(0,1fr)); max-width:900px; }
.reader-controls { transition:transform .18s ease; }
@media(max-width:600px) {
  .reader-toolbar { grid-template-columns:minmax(0,1fr); grid-template-areas:"top" "actions"; gap:4px; padding:4px 8px 6px; }
  #reader-topline { grid-area:top; display:flex; align-items:center; justify-content:space-between; min-height:42px; }
  #reader-actions { grid-area:actions; display:flex; gap:3px; width:100%; margin:0; }
  #reader-actions button { flex:1 1 0; }
  .reader-toolbar button { flex-direction:column; gap:0; padding:3px 1px; font-size:10px; min-width:0; }
  #reader-topline #reader-back { flex-direction:row; gap:4px; min-height:40px; padding:4px 10px; font-size:12px; }
  #reader-topline #wake { flex-direction:row; gap:5px; min-height:40px; padding:4px 8px; font-size:11px; }
  #reader-topline #wake .tool-icon { width:19px; height:21px; }
  #reader-actions .button-state { position:static; margin:0; font-size:8px; padding:0 2px; }
  #reader-actions { min-width:0; }
  #writing-toolbar { padding:0 8px 6px; }
  .writing-tools { grid-template-columns:repeat(6,minmax(0,1fr)); gap:3px; }
  .writing-tools button { flex-direction:column; padding:4px 0; gap:0; font-size:10px; min-width:0; }
  .writing-tools .tool-icon { width:18px; height:22px; }
  .writing-options,#writing-tool-help { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); margin:0; }
  .reader-controls.is-scroll-hidden { transform:translateY(calc(-100% - 1px)); pointer-events:none; }
}
@media(prefers-reduced-motion:reduce) { .reader-controls { transition:none; } }

@media(min-width:601px) and (max-width:1000px) {
  .reader-toolbar { gap:6px; padding:8px; }
  #reader-actions { gap:3px; }
  .reader-toolbar button { flex-direction:column; gap:1px; font-size:11px; padding:5px 2px; }
  #reader-topline #reader-back, #reader-topline #wake { flex-direction:row; }
}
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
#reader-topline #reader-back { grid-area:back; }
#reader-topline #wake { grid-area:wake; }
#reader-actions { align-items:center; }
#reader-actions .button-state { position:static; margin:0; font-size:9px; }
#wake[hidden] { display:none!important; }

/* One opacity group keeps ink, background and tail consistent on screen/PDF. */
.writing-memo { position:absolute; z-index:3; width:180px; font:16px/1.5 system-ui,sans-serif; letter-spacing:0; text-align:left; color:#a66d00; pointer-events:none; }
.writing-memo[data-color=lightblue] { color:#08779f; }
.writing-memo[data-color=pink] { color:#bb3068; }
.memo-body { position:relative; padding:9px; border:2px solid currentColor; border-radius:10px; background:#fffdf5; color:inherit; white-space:pre-wrap; overflow-wrap:anywhere; }
.memo-tail, .memo-tip-layer { position:absolute; left:0; top:0; overflow:visible; color:inherit; }
.memo-tail path { fill:none; stroke:currentColor; stroke-width:2; }
.memo-tip { fill:currentColor; stroke:#fffdf5; stroke-width:1; }
.memo-editable .memo-body, .memo-editable .memo-tip { pointer-events:auto; touch-action:none; cursor:move; }
.memo-editable .memo-tip { r:8; stroke-width:2; }
.memo-selected .memo-body { outline:2px dashed currentColor; outline-offset:3px; }
.memo-remove { position:absolute; right:-8px; top:-14px; min-height:28px; width:28px; padding:0; border-radius:50%; color:inherit; background:#fffdf5; pointer-events:auto; touch-action:none; }
#memo-settings-dialog label { display:block; margin:16px 0; }
#memo-settings-open { display:block; margin:6px auto 0; min-height:34px; }
.memo-editable, .memo-editable .memo-tail, .memo-editable .memo-tip-layer { touch-action:none; }

.memo-tip-layer { z-index:2; }

.result-retention { margin:8px 0 0; }

/* Non-interactive progress cues share the actual view/measurement state. */
.home-results { display:flex; align-items:center; justify-content:space-between; gap:20px; margin:0 0 24px; padding:20px 22px; border:1px solid var(--border); border-radius:10px; background:var(--panel); }
.home-results h2 { margin:0 0 10px; font-size:17px; }
.home-results p { margin:0; font-size:14px; line-height:1.8; }
.home-results strong { color:var(--blue); font-weight:500; }
.home-results button { flex-shrink:0; }
.flow-steps { display:flex; gap:8px; list-style:none; padding:0; margin:0 0 28px; }
.flow-steps li { flex:1; display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:10px; border:1px dashed var(--border); border-radius:7px; color:var(--muted); font-size:12px; line-height:1.5; }
.flow-steps .step-marker { display:inline-flex; align-items:center; justify-content:center; min-width:28px; height:24px; border:1px solid currentColor; border-radius:20px; font-size:11px; }
.flow-steps small { font-size:10px; }
.flow-steps .is-current { color:var(--text); border:2px solid var(--accent); padding:9px; background:#182942; font-weight:600; }
.flow-steps .is-current .step-marker { background:var(--blue); color:var(--bg); border-color:var(--blue); }
.flow-steps .is-complete { border-style:solid; }
.reader-progress { display:flex; align-items:center; gap:12px; padding:5px 16px; border-bottom:1px solid var(--border); }
.reader-state { flex-shrink:0; color:var(--blue); font-size:11px; line-height:1.5; }
.reader-progress .flow-steps { flex:1; max-width:700px; margin:0; gap:8px; }
.reader-progress .flow-steps li { flex:initial; padding:2px 5px; border:0; gap:5px; font-size:11px; flex-wrap:nowrap; white-space:nowrap; }
.reader-progress .flow-steps .step-marker { min-width:25px; height:20px; font-size:10px; }
.reader-progress.is-measuring .flow-steps li:not(.is-current) { display:none; }
@media(max-width:600px) {
  .home-results { align-items:flex-start; flex-direction:column; gap:14px; padding:18px; }
  .flow-steps { gap:4px; }
  .flow-steps li { flex-direction:column; flex-wrap:nowrap; gap:3px; padding:7px 2px; font-size:10px; text-align:center; }
  .flow-steps .is-current { padding:6px 1px; }
  .flow-steps small { font-size:9px; }
  .reader-progress { gap:8px; padding:3px 12px; min-height:28px; }
  .reader-progress .flow-steps li { flex-direction:row; padding:0; font-size:10px; }
  .reader-progress .flow-steps li:not(.is-current) { display:none; }
}
