:root {
  color-scheme: dark;
  --paper: #262624;
  --surface: #30302e;
  --ink: #eeeae3;
  --muted: #b3ada2;
  --line: #4b4943;
  --control-line: #787268;
  --clay: #d9a089;
  --clay-soft: #44322c;
  --clay-text: #e6b59d;
  --error: #f0a397;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { min-height: 48px; padding: 10px 16px; color: var(--ink); background: transparent; border: 1px solid var(--control-line); border-radius: 7px; cursor: pointer; touch-action: manipulation; transition: background-color .14s, border-color .14s; }
button:active { background: var(--surface); }
button:disabled { color: #969086; background: var(--surface); cursor: default; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--clay); outline-offset: 4px; }
input { min-width: 0; width: 100%; min-height: 52px; padding: 12px 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--control-line); border-radius: 7px; transition: border-color .14s; }
input:focus { border-color: var(--clay); }
input::placeholder { color: var(--muted); }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 12px; padding: 0; font-size: 14px; font-weight: 550; }
.shell { max-width: 504px; min-height: 100svh; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 10px; min-height: 40px; font-family: var(--sans); font-size: 18px; font-weight: 500; }
.brand-mark { width: 28px; height: 32px; color: var(--clay); }
.intro { padding: 32px 0 30px; }
h1 { margin-bottom: 16px; font-family: var(--sans); font-size: clamp(40px, 12vw, 50px); font-weight: 500; line-height: 1.25; letter-spacing: -.035em; }
.intro p { max-width: 30ch; color: var(--muted); font-size: 15px; line-height: 1.7; }
.muted { color: var(--muted); }
.level-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 5px; background: var(--surface); border-radius: 10px; }
.level-options label { position: relative; cursor: pointer; }
.level-options input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
.level-options span { display: grid; place-items: center; min-height: 44px; border: 1px solid transparent; border-radius: 6px; font-size: 16px; font-weight: 500; }
.level-options input:checked + span { color: var(--paper); background: var(--clay); }
.level-options input:focus-visible + span { outline: 2px solid var(--clay); outline-offset: 3px; }
.field-hint { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.range-fields { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 10px; align-items: end; }
.range-fields label { color: var(--muted); font-size: 12px; }
.range-fields input { margin-top: 8px; padding-block: 10px; font-family: var(--sans); font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.range-dash { display: grid; place-items: center; height: 56px; color: var(--muted); font-family: var(--sans); }
.quick-ranges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.quick-ranges button { min-height: 44px; padding: 8px 2px; color: var(--muted); border: 0; border-radius: 5px; font-size: 13px; }
.quick-ranges button:active { background: var(--surface); }
.neighbor-ranges button { color: var(--clay); text-decoration: underline; text-underline-offset: 4px; font-variant-numeric: tabular-nums; }
.neighbor-ranges button:disabled { color: var(--muted); background: transparent; text-decoration: none; }
#range-hint { margin: 10px 0 20px; }
.primary { width: 100%; min-height: 54px; padding: 14px 20px; color: var(--paper); background: var(--clay); border-color: var(--clay); font-size: 16px; font-weight: 500; }
.primary:active { background: #e4b099; border-color: #e4b099; }
.primary:disabled { color: var(--muted); background: var(--surface); border-color: var(--line); }
.error { margin: 12px 0; color: var(--error); font-size: 14px; overflow-wrap: anywhere; }
.notice { margin-top: 20px; padding: 16px; background: var(--surface); border-radius: 8px; font-size: 14px; }
.notice button { margin-top: 12px; }
.resume { display: grid; grid-template-columns: minmax(0, 1fr) 20px; gap: 4px 12px; width: 100%; margin-top: 22px; padding: 16px 0; text-align: left; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.resume .muted { font-size: 12px; }
.resume strong { grid-column: 1; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.resume svg { grid-column: 2; grid-row: 1 / 3; align-self: center; width: 20px; height: 20px; }
.setup-footer { margin-top: 24px; color: var(--muted); text-align: center; font-size: 12px; }
.reader-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.text-button { display: inline-flex; align-items: center; gap: 4px; padding-inline: 0; color: var(--muted); background: transparent; border: 0; }
.text-button svg { width: 18px; height: 18px; }
.range-label { color: var(--muted); font-size: 12px; }
.reader-heading { margin: 28px 0 16px; }
.card-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-meta strong { font-family: var(--sans); font-size: 20px; font-weight: 500; letter-spacing: .01em; }
.counter { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.thumbnail-frame { position: relative; height: clamp(200px, 60vw, 280px); }
.thumbnail { position: relative; display: block; width: 100%; height: 100%; padding: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.thumbnail img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.thumbnail-frame .retry-button { position: absolute; bottom: 12px; left: 50%; width: max-content; max-width: calc(100% - 24px); margin: 0; transform: translateX(-50%); background: var(--paper); }
.thumbnail-frame:has(.retry-button:not([hidden])) .expand-label { display: none; }
.expand-label { position: absolute; bottom: 10px; right: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; color: var(--ink); background: #262624ed; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; }
.expand-label svg { width: 14px; height: 14px; }
.image-status { position: absolute; top: 50%; left: 16px; right: 16px; transform: translateY(-50%); color: var(--muted); text-align: center; font-size: 14px; pointer-events: none; }
.card-title-slot { height: 3.3em; min-height: 3.3em; max-height: 3.3em; margin: 22px 0 24px; overflow: hidden; font-size: 23px; line-height: 1.65; }
.card-title { display: -webkit-box; margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-family: var(--sans); font-size: inherit; font-weight: 500; line-height: inherit; overflow-wrap: anywhere; }
.progress-track { height: 2px; margin: 20px 0; overflow: hidden; background: var(--surface); }
.progress-track span { display: block; width: 10%; height: 100%; background: var(--clay); transition: width .15s; }
.card-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card-navigation button:last-child { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.card-navigation button:last-child:active { background: #d8d2c8; }
.card-navigation button:last-child:disabled { color: #969086; background: var(--surface); border-color: var(--line); }
.jump-form { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.jump-form label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.jump-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.reader-note { margin-top: 16px; color: var(--muted); font-size: 12px; }
.retry-button { display: block; margin: 12px auto; color: var(--clay); }
dialog { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; margin: 0; padding: 0; color: var(--ink); background: var(--paper); border: 0; }
dialog::backdrop { background: var(--paper); }
body:has(dialog[open]) { overflow: hidden; }
.lightbox-layout { display: flex; flex-direction: column; height: 100%; min-height: 100%; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.lightbox-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; padding: 12px 20px; }
.lightbox-header h2 { font-family: var(--sans); font-size: 15px; font-weight: 500; }
.lightbox-header p { margin-top: 3px; font-size: 12px; }
.close-button { width: 48px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 28px; }
.image-stage { position: relative; display: grid; place-items: center; flex: 1 1 0; min-height: 0; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; }
.image-stage img { width: 100%; height: 100%; min-height: 0; max-height: 100%; object-fit: contain; pointer-events: none; }
.lightbox-footer { flex: 0 0 auto; padding: 12px 20px 20px; }
.gesture-hint { margin-bottom: 12px; color: var(--muted); text-align: center; font-size: 12px; }
.lightbox-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; max-width: 560px; margin: 0 auto; }
.lightbox-controls button { padding: 10px 4px; font-size: 14px; }
.toggle-button { color: var(--clay-text); background: var(--clay-soft); border-color: var(--clay); }
.toggle-button:active { background: #523b32; }
@media (min-width: 768px) { .shell { padding-top: 48px; } .intro { padding-top: 44px; } }
@media (max-width: 359px) { .shell { padding-inline: max(20px, env(safe-area-inset-left)); } h1 { font-size: 40px; } }
@media (orientation: landscape) and (max-height: 520px) {
  .lightbox-header { padding-block: 4px; }
  .lightbox-footer { padding-block: 4px 8px; }
  .gesture-hint { display: none; }
  .intro { padding-top: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
