:root {
  --accent: #d4654a;
  --accent-ink: #2a120c;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif SC", Georgia, serif;
}
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1a;
  --bg-deep: #1a1a1a;
  --surface: #262626;
  --line: #3a3a3a;
  --text: #f2f0ec;
  --muted: #a3a3a3;
  --paper: #f2f0ec;
  --on-paper: #1c1916;
  --field: #141414;
  --chrome: rgba(26, 26, 26, 0.94);
  --scrub: rgba(255, 255, 255, 0.16);
  --tick: rgba(255, 255, 255, 0.28);
  --scrub-hot: rgba(255, 255, 255, 0.12);
  --danger: #ffb4a4;
  --ok: #d7c4a3;
  --danger-line: #8a4034;
  --wash: rgba(255, 255, 255, 0.04);
  --wash-line: rgba(255, 255, 255, 0.3);
  --shelf-edge: #3a3530;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --restrict-wash: rgba(212, 140, 116, 0.18);
  --restrict-line: rgba(224, 176, 156, 0.45);
  --restrict-on: #c4a090;
  --restrict-on-ink: #2a1612;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-deep: #ffffff;
  --surface: #f6f5f3;
  --line: #e4e0da;
  --text: #1c1916;
  --muted: #6f675f;
  --paper: #1c1916;
  --on-paper: #f7f4ef;
  --field: #ffffff;
  --chrome: rgba(255, 255, 255, 0.94);
  --scrub: rgba(0, 0, 0, 0.14);
  --tick: rgba(0, 0, 0, 0.28);
  --scrub-hot: rgba(0, 0, 0, 0.08);
  --danger: #9f2d2d;
  --ok: #6b4e2e;
  --danger-line: #9f2d2d;
  --wash: rgba(0, 0, 0, 0.04);
  --wash-line: rgba(0, 0, 0, 0.18);
  --shelf-edge: #c8b8a4;
  --shadow: 0 12px 32px rgba(28, 25, 22, 0.08);
  --restrict-wash: rgba(176, 96, 76, 0.12);
  --restrict-line: rgba(150, 82, 64, 0.32);
  --restrict-on: #a56b5c;
  --restrict-on-ink: #fff8f6;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;
    --bg: #ffffff;
    --bg-deep: #ffffff;
    --surface: #f6f5f3;
    --line: #e4e0da;
    --text: #1c1916;
    --muted: #6f675f;
    --paper: #1c1916;
    --on-paper: #f7f4ef;
    --field: #ffffff;
    --chrome: rgba(255, 255, 255, 0.94);
    --scrub: rgba(0, 0, 0, 0.14);
    --tick: rgba(0, 0, 0, 0.28);
    --scrub-hot: rgba(0, 0, 0, 0.08);
    --danger: #9f2d2d;
    --ok: #6b4e2e;
    --danger-line: #9f2d2d;
    --wash: rgba(0, 0, 0, 0.04);
    --wash-line: rgba(0, 0, 0, 0.18);
    --shelf-edge: #c8b8a4;
    --shadow: 0 12px 32px rgba(28, 25, 22, 0.08);
    --restrict-wash: rgba(176, 96, 76, 0.12);
    --restrict-line: rgba(150, 82, 64, 0.32);
    --restrict-on: #a56b5c;
    --restrict-on-ink: #fff8f6;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button::-moz-focus-inner { border: 0; }
button:focus, button:focus-visible { outline: none; }
.ghost:active, .tab:active, .theme-choices button:active, .hand-choices button:active, .tag-chip:active,
.shelf-pager button:active, .restrict-add button:active {
  background: var(--wash);
}
button.feature:active { border-color: var(--muted); }
img { max-width: 100%; }

.view { min-height: 100dvh; }
.mark {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--accent);
}
h1 { font-weight: 560; letter-spacing: -0.03em; }

.auth-view, #auth-view {
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 8px 0 0; font-size: 2rem; }
.lede { color: var(--muted); line-height: 1.5; }
.tabs { display: flex; gap: 8px; margin: 18px 0; }
.tab, .ghost, .primary, .file-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 14px;
}
.tab.on { background: var(--paper); color: var(--on-paper); border-color: transparent; }
.primary {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: white;
  border: 0;
  padding: 12px 16px;
}
.primary:disabled { opacity: 0.6; }
label { display: grid; gap: 6px; margin: 12px 0; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.92rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-family: ui-sans-serif, system-ui, sans-serif; }

.topbar, .chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
}
.topbar h1, .reader-title h1 { margin: 0; font-size: 1.6rem; }
.top-actions, .reader-title { display: flex; align-items: center; gap: 10px; }
.topbar h1.brand { color: var(--accent); font-size: 1.5rem; letter-spacing: 0.04em; }
.upload-entry { position: relative; }
.badge {
  position: absolute;
  top: -7px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: white;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
}
.reader-title { min-width: 0; flex: 1; }
.reader-title h1 {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-title p { margin: 0; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums; }

.drop {
  margin: 0 20px 18px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: var(--wash);
}
.drop.over { border-color: var(--accent); background: rgba(212, 101, 74, 0.08); }
.drop p { margin: 6px 0 0; color: var(--muted); }
.drop-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.file-btn { background: var(--paper); color: var(--on-paper); border: 0; }
.file-btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.file-btn input { display: none; }
@media (pointer: coarse) {
  .folder-btn, .upload-folder-hint { display: none; }
}
.upload-progress { width: min(240px, 40vw); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; }
.track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.track span, .bar span { display: block; height: 100%; background: var(--accent); width: 0; }

.jobs { list-style: none; margin: 0 20px 8px; padding: 0; display: grid; gap: 8px; }
.jobs li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}
.jobs .msg { color: var(--muted); text-align: right; }
.job-actions { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.job-actions button { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; }
.status-failed { color: var(--danger); }
.status-done { color: var(--ok); }

.shelf-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 8px;
  flex-wrap: wrap;
}
.tool {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}
.tool select, .sheet input, .upload-meta input {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}
.tool select { border-radius: 999px; }
.tag-filters { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding-bottom: 2px; }
.tag-chip {
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 6px 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
}
.tag-chip.on { background: var(--paper); color: var(--on-paper); border-color: transparent; }
.tag-chip.restricted { background: var(--restrict-wash); border-color: var(--restrict-line); }
.tag-chip.restricted.on { background: var(--restrict-on); color: var(--restrict-on-ink); border-color: transparent; }
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
  padding: 8px 20px 40px;
}
.shelf-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 4px 20px 28px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.shelf-pager button { width: auto; margin: 0; padding: 8px 16px; }
.shelf-pager button:disabled { opacity: 0.4; }
.theme-choices, .hand-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-choices button, .hand-choices button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 14px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.theme-choices button.on, .hand-choices button.on { background: var(--paper); color: var(--on-paper); border-color: transparent; }
.restrict-block { display: grid; gap: 10px; }
.restrict-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.restrict-toggle input { width: auto; margin: 0; }
.restrict-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.restrict-tags .tag-chip { display: inline-flex; align-items: center; gap: 6px; }
.restrict-add { display: flex; gap: 8px; }
.restrict-add input { flex: 1; min-width: 0; }
.restrict-add button { width: auto; margin: 0; padding: 8px 16px; }
.restrict-block .settings-note { margin: 0; }
.shelf.inner { padding: 0; }
.shelf.authors { grid-template-columns: 1fr; gap: 12px; }
.author-row {
  display: grid;
  grid-template-columns: minmax(96px, 180px) 1fr;
  align-items: end;
  gap: 16px;
  width: 100%;
  padding: 14px 16px 4px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 6px solid var(--shelf-edge);
  border-radius: 0;
  box-shadow: 0 10px 14px -12px rgba(0, 0, 0, 0.8);
  -webkit-tap-highlight-color: transparent;
}
.book:hover, .book:active, .book:focus, .book:focus-visible,
.series-link:focus, .series-link:focus-visible,
.author-row:active, .author-row:focus {
  outline: none;
  background: transparent;
}
.author-name { display: grid; gap: 4px; padding-bottom: 14px; min-width: 0; }
.author-name strong { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author-name span { color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; }
.author-strip {
  display: flex;
  align-items: flex-end;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 1px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.author-row:hover .author-strip, .author-row:focus-visible .author-strip {
  border-color: var(--wash-line);
  background: var(--wash);
  box-shadow: none;
}
.author-row:focus-visible { outline: none; }
.strip-cover {
  flex: none;
  width: 84px;
  aspect-ratio: 3 / 4;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  background: var(--surface);
  box-shadow: -6px 0 12px rgba(0, 0, 0, 0.45);
}
.strip-cover + .strip-cover { margin-left: -34px; }
.strip-cover.stacked { outline: 2px solid var(--line); outline-offset: -2px; }
.strip-more { flex: none; align-self: center; margin: 0 6px 0 10px; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.book.stacked { padding: 18px 18px 0 0; }
.book.stacked .cover-wrap {
  box-shadow:
    7px -7px 0 0 var(--bg),
    8px -8px 0 0 var(--line),
    14px -14px 0 0 var(--bg),
    15px -15px 0 0 var(--line);
}
.pile-count {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent);
  color: white;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  line-height: 22px;
  text-align: center;
}
.shelf-head { display: grid; gap: 12px; padding: 8px 20px 4px; }
.page-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-head strong { font-size: 1.3rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { flex: none; background: var(--paper); color: var(--on-paper); border-color: transparent; font-family: ui-sans-serif, system-ui, sans-serif; }
.series-info { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.series-info p { margin: 0; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.series-continue { width: auto; margin: 0; }
.series-link {
  justify-self: start;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pile-count { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.book.finished .cover-wrap { opacity: 0.55; }
.upload-meta { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  align-items: end;
  padding: 12px;
}
.sheet form {
  width: min(480px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 12px;
}
.sheet h2 { margin: 0 0 8px; font-size: 1.25rem; }
.sheet-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.sheet-actions-end { display: flex; gap: 8px; }
.sheet-actions .primary { width: auto; margin: 0; padding: 10px 18px; }
.danger {
  border-radius: 999px;
  border: 1px solid var(--danger-line);
  background: transparent;
  color: var(--danger);
  padding: 8px 14px;
}
#meta-confirm p { margin: 4px 0 0; color: var(--text); line-height: 1.5; }
.book {
  display: grid;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.cover-wrap img, .strip-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, 0.35); }
.book h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book p { margin: 0; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.85rem; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 24px 0; }

.reader {
  position: fixed;
  inset: 0;
  height: auto;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg-deep);
  -webkit-tap-highlight-color: transparent;
}
.reader, .reader * { -webkit-tap-highlight-color: transparent; }
.reader button:focus, .reader button:active, .scrub:focus { outline: none; }
.stage {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  cursor: pointer;
  position: relative;
}
#page-canvas { background: transparent; transform-origin: center center; }
.reader.zooming { grid-template-rows: minmax(0, 1fr); }
.reader.zooming .reader-chrome,
.reader.zooming .scrub,
.reader.zooming .toc { display: none !important; }
.reader.zooming .stage { cursor: grab; }
#page-note {
  position: absolute;
  margin: 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.scrub {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  height: 44px;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.scrub-rail {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 2px;
  background: var(--scrub);
  transition: height 0.22s cubic-bezier(0.22, 1, 0.36, 1), left 0.22s cubic-bezier(0.22, 1, 0.36, 1), right 0.22s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-radius 0.22s cubic-bezier(0.22, 1, 0.36, 1), background 0.22s ease;
}
.scrub-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: rgba(212, 101, 74, 0.75);
  transition: background 0.22s ease;
}
.scrub-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--paper);
  opacity: 0.85;
  transform: translate(-50%, -50%);
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1), height 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-radius 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}
.scrub-ticks { position: absolute; inset: 0; opacity: 0; transition: opacity 0.22s ease; pointer-events: none; }
.scrub-ticks i { position: absolute; top: 25%; bottom: 25%; width: 1px; background: var(--tick); }
.scrub-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  transform: translateX(-50%) translateY(4px);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--paper);
  color: var(--on-paper);
  font: 600 0.78rem ui-sans-serif, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.scrub.active .scrub-rail {
  left: 16px;
  right: 16px;
  bottom: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--scrub-hot);
}
.scrub.active .scrub-fill { background: var(--accent); }
.scrub.active .scrub-thumb {
  width: 7px;
  height: 20px;
  border-radius: 4px;
  opacity: 1;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}
.scrub.active .scrub-ticks { opacity: 1; }
.scrub.active .scrub-bubble { opacity: 1; transform: translateX(-50%) translateY(0); }
.toc {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100%);
  background: var(--chrome);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 2;
}
.toc-head, .toc li button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.toc-head { padding: 16px; }
.toc ul { list-style: none; margin: 0; padding: 0 8px 20px; overflow: auto; }
.toc li button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
}
.toc li button.on { background: var(--surface); }
.toc .pg { color: var(--muted); font-variant-numeric: tabular-nums; font-family: ui-sans-serif, system-ui, sans-serif; }

.advanced-wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 48px; display: grid; gap: 12px; }
.advanced-wrap > .lede { margin-top: 0; }
.feature, .format-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
}
button.feature {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  text-align: left;
}
.feature strong, .feature h2, .format-card h2 { display: block; margin: 0 0 6px; font-size: 1.2rem; }
.settings-note { margin: 0 0 12px; color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.55; }
.field-hint { font-size: 0.85rem; }
.scan-stats, .scan-notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.scan-stats li, .scan-notes li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.scan-notes li { color: var(--muted); justify-content: flex-start; }
#cache-count { margin: 4px 0 0; }
#install-app { width: auto; margin: 12px 0 0; padding: 8px 18px; }
html.locked .view,
html.locked .sheet { display: none !important; }
#screen-lock {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 28px;
}
#screen-lock .brand { margin: 0; color: var(--accent); font-size: 1.5rem; letter-spacing: 0.04em; }
.lock-note {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.92rem;
}
.lock-panel { display: grid; justify-items: center; gap: 18px; }
#lock-panel .lock-dot:not(.lead), #lock-boxes { opacity: 0; transition: opacity .35s ease; }
#screen-lock.awake #lock-panel .lock-dot, #screen-lock.awake #lock-boxes { opacity: 1; }
#lock-cancel {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  z-index: 45;
  width: auto;
  margin: 0;
}
@media (hover: hover) {
  #lock-panel:hover .lock-dot, #lock-panel:hover #lock-boxes { opacity: 1; }
}
.pin-boxes { display: flex; gap: 10px; }
.pin-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s ease, background .2s ease;
}
.pin-box.on { border-color: rgba(212, 101, 74, 0.45); background: rgba(212, 101, 74, 0.08); }
.pin-boxes.shake { animation: pin-shake .36s ease; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.lock-pad {
  position: relative;
  width: min(240px, 66vw);
  aspect-ratio: 1;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.lock-dot {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  transition: opacity .35s ease, color .25s ease, background .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.lock-dot.hot {
  color: var(--text);
  background: rgba(212, 101, 74, 0.2);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(212, 101, 74, 0.16);
  transition-duration: .08s;
}
#screen-lock:not(.awake) .lock-dot.lead { animation: lead-breathe 2.6s ease-in-out infinite; }
@keyframes lead-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .55; }
  50% { transform: translate(-50%, -50%) scale(1.14); opacity: .9; }
}
@media (pointer: coarse), (max-width: 720px) {
  #screen-lock {
    align-content: start;
    padding-top: calc(28px + env(safe-area-inset-top));
    gap: 12px;
  }
  html[data-hand] #lock-panel,
  html[data-hand] #lock-view .lock-panel {
    position: fixed;
    bottom: calc(28px + env(safe-area-inset-bottom));
    width: max-content;
    margin: 0;
    gap: 10px;
    z-index: 3;
  }
  html[data-hand="left"] #lock-panel,
  html[data-hand="left"] #lock-view .lock-panel {
    left: calc(28px + env(safe-area-inset-left));
    right: auto;
  }
  html[data-hand="right"] #lock-panel,
  html[data-hand="right"] #lock-view .lock-panel {
    left: auto;
    right: calc(28px + env(safe-area-inset-right));
  }
  #lock-boxes, #lock-setup-boxes {
    position: fixed;
    left: 0;
    right: 0;
    top: 46%;
    width: auto;
    margin: 0;
    justify-content: center;
    z-index: 6;
  }
}
.lock-dot.pop { animation: key-pop .28s ease-out; }
@keyframes key-pop {
  0% { transform: translate(-50%, -50%) scale(1); }
  40% { transform: translate(-50%, -50%) scale(1.22); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
.lock-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#lock-clear { justify-self: start; }
.feature em, .feature p, .format-card .method {
  margin: 0;
  color: var(--muted);
  font-style: normal;
  font-family: ui-sans-serif, system-ui, sans-serif;
  line-height: 1.55;
}
.chevron { color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; flex: none; }
.format-list { display: grid; gap: 12px; }
.format-card .ext {
  margin: 0 0 10px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.03em;
}
.format-card .plugin { margin: 0 0 8px; font-family: ui-sans-serif, system-ui, sans-serif; }
.format-card .k { color: var(--accent); margin-right: 8px; }

@media (min-width: 721px) {
  .sheet { align-items: center; }
}
@media (max-width: 720px) {
  .drop { flex-direction: column; align-items: stretch; }
  .shelf-tools, .upload-meta { padding-left: 12px; padding-right: 12px; }
  .upload-progress { width: 100%; }
  #shelf-view {
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #shelf-view .topbar {
    flex: none;
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    background: var(--bg);
  }
  #shelf-view .brand { font-size: 1.15rem; }
  #shelf-view .ghost {
    padding: 5px 10px;
    font-size: 0.82rem;
    font-family: ui-sans-serif, system-ui, sans-serif;
  }
  #shelf-view .shelf-tools {
    flex: none;
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 8px;
    padding: 0 12px 8px;
  }
  #shelf-view .tag-filters {
    grid-column: 1 / -1;
    width: 100%;
    flex: none;
    flex-wrap: wrap;
    overflow: visible;
  }
  #shelf-view .tool { font-size: 0.8rem; }
  #shelf-view .tool select { padding: 6px 10px; }
  #shelf-head { flex: none; gap: 8px; padding: 4px 12px 8px; }
  #shelf-head .page-head strong { font-size: 1.05rem; }
  #shelf-head .series-continue { padding: 8px 14px; font-size: 0.85rem; }
  #shelf {
    flex: 1;
    min-height: 0;
    overflow: auto;
    align-content: start;
    -webkit-overflow-scrolling: touch;
  }
  .topbar, .chrome { padding: 12px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 8px 12px 28px; }
  .shelf-pager { flex: none; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)); }
  .shelf.authors { grid-template-columns: 1fr; }
  .author-row { grid-template-columns: 88px 1fr; gap: 10px; padding: 10px 8px 4px; }
  .strip-cover { width: 64px; }
  .strip-cover + .strip-cover { margin-left: -28px; }
  .reader { grid-template-rows: minmax(0, 1fr); }
  .reader-chrome {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    padding-top: calc(6px + env(safe-area-inset-top));
    background: var(--chrome);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  }
  .reader-chrome .ghost {
    flex: none;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-family: ui-sans-serif, system-ui, sans-serif;
  }
  .reader-chrome .reader-title {
    display: grid;
    gap: 0;
    min-width: 0;
  }
  .reader-chrome .reader-title h1 {
    max-width: none;
    font-size: 0.92rem;
  }
  .reader-chrome .reader-title p { font-size: 0.7rem; }
  .reader-chrome .top-actions { flex: none; gap: 4px; }
  .reader.chrome-open .reader-chrome {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}
