:root {
  color-scheme: light;
  --bg: #f6f1ea;
  --surface: rgba(255, 253, 249, 0.88);
  --surface-solid: #fffdf9;
  --ink: #27231f;
  --muted: #766e65;
  --line: #ded5cb;
  --line-strong: #c9bbae;
  --pink: #df6f8f;
  --pink-soft: #f3d8e0;
  --green: #56816a;
  --green-soft: #dce9df;
  --yellow: #b88921;
  --yellow-soft: #f2e4ad;
  --blue-soft: #d9e9f0;
  --shadow: 0 18px 50px rgba(65, 46, 37, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191715;
  --surface: rgba(36, 32, 29, 0.9);
  --surface-solid: #24201d;
  --ink: #f4eee8;
  --muted: #b8ada3;
  --line: #453d37;
  --line-strong: #62564d;
  --pink: #ed8ca8;
  --pink-soft: #4b3039;
  --green: #8db89d;
  --green-soft: #2b4233;
  --yellow: #e2ba59;
  --yellow-soft: #4a3e20;
  --blue-soft: #263e49;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

/* Authored layout rules such as .app-layout { display: grid } otherwise win
   over the browser's built-in [hidden] rule. Keep inactive app views hidden. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 8%, color-mix(in srgb, var(--pink-soft) 58%, transparent) 0 16rem, transparent 16.1rem),
    radial-gradient(circle at 92% 12%, color-mix(in srgb, var(--yellow-soft) 42%, transparent) 0 12rem, transparent 12.1rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  transform: translateY(-200%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
}
.skip-link:focus { transform: none; }

.app-header {
  display: grid;
  grid-template-columns: minmax(230px, 0.7fr) minmax(320px, 1.35fr) auto;
  gap: 24px;
  align-items: center;
  padding: 24px clamp(18px, 3vw, 48px) 18px;
}

.brand-block, .page-identity, .viewer-actions, .header-actions, .focus-header {
  display: flex;
  align-items: center;
}

.brand-block { gap: 13px; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 9px); gap: 4px; transform: rotate(-7deg); }
.brand-mark span { display: block; width: 9px; height: 25px; border-radius: 999px; }
.brand-mark span:nth-child(1) { background: var(--pink); }
.brand-mark span:nth-child(2) { background: var(--yellow); }
.brand-mark span:nth-child(3) { background: var(--green); }

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(21px, 2vw, 29px); letter-spacing: 0.02em; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0; font-size: 16px; }
.brand-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: 0 9px 25px rgba(78, 58, 50, 0.08);
}
.search-box:focus-within { outline: 3px solid color-mix(in srgb, var(--pink) 24%, transparent); border-color: var(--pink); }
.search-icon { width: 16px; height: 16px; border: 2px solid var(--muted); border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon::after { content: ""; position: absolute; width: 7px; height: 2px; right: -5px; bottom: -3px; background: var(--muted); transform: rotate(45deg); border-radius: 2px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: var(--muted); }
kbd { flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 7px; color: var(--muted); font-size: 11px; background: var(--bg); }

.header-actions { gap: 9px; justify-content: flex-end; }
.icon-button, .source-link, .text-button, .primary-button, .quiet-button, .zoom-button, .dialog-close, .focus-toolbar button {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-solid);
  cursor: pointer;
  text-decoration: none;
}
.icon-button { width: 42px; height: 42px; }
.source-link { padding: 10px 14px; color: var(--ink); font-size: 13px; }
button:hover, .source-link:hover { border-color: var(--line-strong); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--pink) 34%, transparent); outline-offset: 2px; }

.chapter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 clamp(18px, 3vw, 48px) 17px;
  scrollbar-width: thin;
}
.tab-button {
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.tab-button:hover { color: var(--ink); background: color-mix(in srgb, var(--surface-solid) 72%, transparent); }
.tab-button.is-active { color: var(--surface-solid); background: var(--ink); }

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 clamp(18px, 3vw, 48px) 18px;
}
.mode-button {
  min-width: 126px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}
.mode-button.is-active { border-color: var(--ink); background: var(--ink); color: var(--surface-solid); }

.install-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  max-width: 1040px;
  margin: 0 auto 18px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: 0 10px 26px rgba(65, 46, 37, .09);
}
.install-banner.is-ready { border-color: var(--green); background: var(--green-soft); }
.install-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--pink); color: #fff; font-weight: 900; }
.install-banner strong, .install-banner small { display: block; }
.install-banner strong { font-size: 13px; }
.install-banner small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.install-dismiss { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; }
.install-dialog { width: min(92vw, 560px); height: auto; }
.install-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.install-steps { list-style: none; display: grid; gap: 14px; margin: 0; padding: 20px; }
.install-steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; }
.install-steps li > b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--pink-soft); color: var(--pink); }
.install-steps span { font-size: 14px; line-height: 1.55; }
.install-status { margin: 0 20px 20px; padding: 12px 14px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.offline-download {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 280px) auto auto;
  gap: 12px;
  align-items: center;
  max-width: 1040px;
  margin: 0 auto 18px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-solid);
}
.offline-download-copy { display: flex; align-items: center; gap: 10px; min-width: 0; }
.offline-download-copy strong, .offline-download-copy small { display: block; }
.offline-download-copy strong { font-size: 12px; }
.offline-download-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.offline-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-soft); }
.offline-meter { height: 7px; overflow: hidden; border-radius: 999px; background: var(--line); }
.offline-meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--green)); transition: width .2s ease; }
.offline-count { min-width: 45px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.offline-download.is-ready { border-color: var(--green); background: var(--green-soft); }
.offline-download.is-ready .offline-dot { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent); }
.offline-download.has-error { border-color: #b84c5b; }
.offline-download.has-error .offline-dot { background: #b84c5b; box-shadow: 0 0 0 4px color-mix(in srgb, #b84c5b 18%, transparent); }

.play-hub, .men-directory {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(18px, 3vw, 48px) 46px;
}
.play-hero, .directory-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(110deg, var(--surface-solid), color-mix(in srgb, var(--pink-soft) 45%, var(--surface-solid)));
  box-shadow: var(--shadow);
}
.play-hero h2, .directory-hero h2 { font-size: clamp(22px, 3vw, 34px); }
.play-hero p:not(.eyebrow), .directory-hero p:not(.eyebrow) { max-width: 720px; margin: 8px 0 0; color: var(--muted); }
.reset-progress { margin-left: 0; white-space: nowrap; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr); gap: 18px; align-items: start; }
.calculator-column { display: grid; gap: 18px; }
.tool-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tool-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.status-chip { padding: 7px 11px; border-radius: 999px; background: var(--pink-soft); color: var(--pink); font-size: 12px; }
.status-chip b { font-size: 17px; }
.interactive-map { position: relative; width: min(100%, 560px); margin: 22px auto 0; padding: 0 18px; }
.interactive-map img { display: block; width: 100%; border-radius: 18px; box-shadow: 0 14px 34px rgba(47, 34, 28, .18); }
.map-marker {
  position: absolute;
  left: 63.1%;
  top: 28.1%;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--surface-solid);
  border-radius: 50% 50% 50% 10%;
  background: var(--pink);
  color: #fff;
  box-shadow: 0 5px 16px rgba(49, 29, 34, .34);
  font-size: 11px;
  font-weight: 900;
  transition: left .25s ease, top .25s ease;
}
.map-marker.destination { z-index: 2; background: var(--green); opacity: 0; }
.map-marker.destination.is-visible { opacity: 1; }
.route-progress { height: 6px; margin: 12px 18px 0; border-radius: 999px; overflow: hidden; background: var(--line); }
.route-progress span { display: block; width: 2%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--green)); transition: width .25s ease; }
.map-numbering-note { margin: 9px 22px 0; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: center; }
.route-metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 22px 0; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.route-metrics div { padding: 12px 14px; background: var(--surface-solid); }
.route-metrics div + div { border-left: 1px solid var(--line); }
.route-metrics span, .fee-result span { display: block; color: var(--muted); font-size: 11px; }
.route-metrics strong { display: block; margin-top: 4px; font-size: 14px; }
.route-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; padding: 18px 22px 12px; }
.route-form label, .money-field, .directory-search { color: var(--muted); font-size: 12px; font-weight: 700; }
.route-form input, .money-field input, .directory-search input, .stage-field select {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--ink);
}
.stage-field { display: block; margin: 12px 20px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.stage-field select { margin-top: 6px; }
.calculate-route { min-height: 42px; padding-inline: 18px; }
.route-result { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; margin: 2px 22px 0; padding: 14px; border-radius: 15px; background: var(--bg); }
.destination-badge { display: grid; place-items: center; min-width: 68px; min-height: 50px; padding: 8px; border-radius: 12px; background: var(--pink-soft); font-weight: 900; font-size: 12px; }
.destination-badge[data-type="item"] { background: var(--yellow-soft); }
.destination-badge[data-type="game"] { background: var(--green-soft); }
.destination-badge[data-type="parameterUp"] { background: var(--blue-soft); }
.destination-badge[data-type="parameterDown"] { background: color-mix(in srgb, var(--pink-soft) 58%, var(--blue-soft)); }
.destination-badge[data-type="secretShop"] { background: linear-gradient(135deg, var(--blue-soft), var(--yellow-soft), var(--pink-soft)); }
.route-result p { margin: 0; }
.route-path { margin-top: 5px !important; color: var(--muted); font-size: 11px; }
.route-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 22px 20px; }
.route-actions button { flex: 1; min-width: 130px; }
.route-actions button:disabled { opacity: .45; cursor: not-allowed; }
.fee-tool, .history-tool { padding-bottom: 18px; }
.money-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--yellow-soft); color: var(--yellow); font-weight: 900; }
.money-field { display: block; margin: 18px 20px 10px; }
.money-field > span { display: flex; align-items: center; margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); }
.money-field b { padding-left: 13px; color: var(--green); font-size: 17px; }
.money-field input { margin: 0; border: 0; background: transparent; }
.fee-result { display: flex; align-items: center; justify-content: space-between; margin: 10px 20px 0; padding: 13px 14px; border-radius: 13px; background: var(--bg); }
.fee-result strong { font-size: 22px; }
.fee-result .fee-formula { font-size: 12px; text-align: right; }
.fee-result.total { background: var(--green-soft); }
.fee-balance { margin: 11px 21px 0; color: var(--muted); font-size: 12px; }
.fee-balance.is-negative { color: #b84c5b; font-weight: 800; }
.fee-rules { margin: 13px 20px 0; color: var(--muted); font-size: 12px; }
.fee-rules summary { cursor: pointer; font-weight: 800; }
.fee-rules ul { margin-bottom: 0; padding-left: 19px; line-height: 1.7; }
.move-history { list-style: none; margin: 0; padding: 12px 20px 0; }
.move-history li { display: grid; grid-template-columns: 48px 1fr auto; gap: 9px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.move-history li:last-child { border-bottom: 0; }
.move-history strong { font-size: 13px; }
.move-history small { color: var(--muted); }
.move-history .history-empty { display: block; color: var(--muted); border: 0; }

.directory-search { width: min(100%, 310px); }
.men-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.man-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-solid);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 7px 20px rgba(65, 46, 37, .07);
}
.man-card:hover { transform: translateY(-2px); border-color: var(--pink); box-shadow: 0 13px 28px rgba(65, 46, 37, .12); }
.man-portrait { width: 76px; aspect-ratio: 1; object-fit: cover; object-position: 18% 12%; border-radius: 13px; background: var(--pink-soft); }
.man-card h3 { margin: 0; font-size: 16px; }
.man-reading { margin: 2px 0 8px; color: var(--muted); font-size: 10px; }
.man-meta { display: flex; gap: 5px; flex-wrap: wrap; }
.man-meta span { padding: 3px 6px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 10px; }
.man-detail-line { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.mobile-nav { display: none; }

.app-layout {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1540px;
  margin: 0 auto;
  padding: 0 clamp(18px, 3vw, 48px) 42px;
}
.archive-tabs { grid-column: 1 / -1; padding: 0 0 2px; }

.sidebar, .viewer-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar { align-self: start; overflow: hidden; }
.map-shortcuts { padding: 20px; border-bottom: 1px solid var(--line); }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading-row > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.map-card-list { display: grid; gap: 9px; margin-top: 14px; }
.map-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-solid);
  text-align: left;
  cursor: pointer;
}
.map-card:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(74, 51, 43, 0.08); }
.map-card img { display: block; width: 70px; height: 70px; object-fit: cover; object-position: 50% 35%; border-radius: 10px; background: var(--pink-soft); }
.map-card strong, .map-card small { display: block; }
.map-card strong { font-size: 13px; }
.map-card small { margin-top: 4px; color: var(--muted); }
.mini-map { width: 70px; height: 50px; border-radius: 10px; background: linear-gradient(135deg, var(--pink-soft), var(--blue-soft)); position: relative; }
.mini-map::before { content: ""; position: absolute; inset: 10px 12px; border: 5px solid var(--pink); border-right-color: var(--green); border-bottom-color: var(--yellow); }

.result-section { padding: 18px 10px 12px 18px; }
.result-section .section-heading-row { padding-right: 8px; }
.search-hint { margin: 6px 8px 12px 0; color: var(--muted); font-size: 12px; }
.page-list { list-style: none; margin: 0; padding: 0 8px 0 0; max-height: min(54vh, 600px); overflow: auto; scrollbar-width: thin; }
.page-item { margin: 3px 0; }
.page-link {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.page-link:hover { background: color-mix(in srgb, var(--pink-soft) 44%, transparent); }
.page-link.is-current { background: var(--pink-soft); }
.page-index { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.page-link strong { display: block; font-size: 13px; line-height: 1.35; }
.page-link small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.35; }
mark { padding: 0 2px; border-radius: 3px; background: var(--yellow-soft); color: var(--ink); }
.empty-state { margin: 16px 8px; color: var(--muted); font-size: 13px; }

.viewer-panel { min-width: 0; overflow: hidden; }
.viewer-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.page-identity { min-width: 0; gap: 12px; }
.page-number { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 15px; background: var(--pink-soft); color: var(--pink); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.viewer-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.text-button, .primary-button, .quiet-button, .zoom-button { padding: 8px 11px; font-size: 12px; }
.primary-button { border-color: var(--ink); background: var(--ink); color: var(--surface-solid); }

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
}
.viewer-toolbar label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.viewer-toolbar output { display: inline-block; min-width: 36px; color: var(--ink); font-variant-numeric: tabular-nums; }
.viewer-toolbar input[type="range"] { width: min(24vw, 230px); accent-color: var(--pink); }
.zoom-button { width: 34px; height: 34px; padding: 0; font-size: 17px; }
.quiet-button { margin-left: auto; }
.quiet-button + .quiet-button { margin-left: 0; }

.document-stage {
  height: min(74vh, 910px);
  min-height: 540px;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 22%, transparent) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 22%, transparent) 25%, transparent 25%) 0 11px / 22px 22px,
    color-mix(in srgb, var(--bg) 88%, var(--surface-solid));
  text-align: center;
  scrollbar-color: var(--line-strong) transparent;
}
.document-stage img { display: block; width: min(100%, 860px); max-width: none; height: auto; margin: 0 auto; box-shadow: 0 14px 34px rgba(47, 34, 28, 0.18); background: #fff; }
.page-caption { display: flex; justify-content: space-between; gap: 16px; padding: 10px 18px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); }

.ocr-panel { margin: 0; padding: 18px 20px 22px; border-top: 1px solid var(--line); }
.ocr-note { margin: 8px 0 13px; color: var(--muted); font-size: 12px; }
.ocr-panel pre { max-height: 340px; margin: 0; padding: 15px; overflow: auto; border-radius: 14px; background: var(--bg); color: var(--ink); font: 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }

dialog { width: min(96vw, 1400px); height: 94vh; margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface-solid); color: var(--ink); box-shadow: 0 30px 100px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(16, 12, 10, 0.75); backdrop-filter: blur(4px); }
.focus-header { justify-content: space-between; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-close { padding: 8px 12px; }
.focus-stage { height: calc(94vh - 124px); overflow: auto; padding: 22px; text-align: center; background: var(--bg); }
.focus-stage img { display: block; width: min(100%, 980px); max-width: none; height: auto; margin: 0 auto; box-shadow: var(--shadow); }
.focus-toolbar { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.focus-toolbar button { min-width: 38px; padding: 7px 11px; }
.focus-toolbar output { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr auto; }
  .search-box { grid-column: 1 / -1; grid-row: 2; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: minmax(260px, 0.7fr) 1fr; }
  .map-shortcuts { border-bottom: 0; border-right: 1px solid var(--line); }
  .page-list { max-height: 280px; }
  .document-stage { height: 70vh; }
  .tool-layout { grid-template-columns: 1fr; }
  .calculator-column { grid-template-columns: 1fr 1fr; }
  .men-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { padding-bottom: 72px; }
  .app-header { gap: 14px; padding-top: 14px; padding-bottom: 12px; }
  .brand-block .eyebrow { display: none; }
  .source-link { display: none; }
  kbd { display: none; }
  .mode-tabs { display: none; }
  .install-banner { grid-template-columns: auto minmax(0, 1fr) auto; margin: 0 12px 12px; }
  .install-banner .text-button { grid-column: 2; justify-self: start; }
  .install-dismiss { grid-column: 3; grid-row: 1; }
  .offline-download { grid-template-columns: minmax(0, 1fr) auto; margin: 0 12px 12px; }
  .offline-download-copy { grid-column: 1 / -1; }
  .offline-meter { grid-column: 1; }
  .offline-count { grid-column: 2; }
  .offline-download .text-button { grid-column: 1 / -1; justify-self: start; }
  .play-hub, .men-directory { padding: 0 12px 22px; }
  .play-hero, .directory-hero { align-items: stretch; flex-direction: column; margin-bottom: 12px; padding: 16px; border-radius: 18px; }
  .play-hero h2, .directory-hero h2 { font-size: 23px; }
  .tool-layout, .calculator-column { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .tool-card { border-radius: 19px; }
  .tool-heading { padding: 15px 16px; }
  .interactive-map { margin-top: 14px; padding: 0 10px; }
  .map-marker { width: 32px; height: 32px; }
  .route-metrics { margin: 12px 12px 0; }
  .route-metrics div { padding: 10px 8px; }
  .route-metrics strong { font-size: 12px; }
  .route-form { grid-template-columns: 1fr 1fr; padding: 14px 12px 10px; }
  .calculate-route { grid-column: 1 / -1; }
  .route-result { margin-inline: 12px; }
  .route-actions { padding: 12px 12px 16px; }
  .route-actions button { min-width: 0; }
  .directory-search { width: 100%; }
  .men-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .man-card { grid-template-columns: 58px minmax(0, 1fr); gap: 9px; padding: 8px; border-radius: 14px; }
  .man-portrait { width: 58px; border-radius: 10px; }
  .man-card h3 { font-size: 14px; }
  .man-reading { margin-bottom: 5px; }
  .man-detail-line { display: none; }
  .mobile-nav {
    position: fixed;
    z-index: 80;
    left: 10px;
    right: 10px;
    bottom: 9px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 30px rgba(30, 21, 18, .22);
  }
  .mobile-nav button { display: grid; place-items: center; gap: 2px; padding: 6px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 10px; }
  .mobile-nav button span { font-size: 16px; }
  .mobile-nav button.is-active { background: var(--pink-soft); color: var(--pink); font-weight: 800; }
  .sidebar { display: block; }
  .result-section { padding-right: 14px; }
  .map-shortcuts { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-list { max-height: none; overflow: visible; }
  .viewer-topbar { align-items: flex-start; flex-direction: column; }
  .viewer-actions { width: 100%; justify-content: stretch; }
  .viewer-actions button { flex: 1; }
  .viewer-toolbar { flex-wrap: wrap; }
  .viewer-toolbar input[type="range"] { flex: 1; width: auto; }
  .quiet-button { margin-left: 0; }
  .document-stage { min-height: 420px; height: 66vh; padding: 12px; }
  .page-caption span:last-child { display: none; }
  dialog { width: 100vw; height: 100dvh; border-radius: 0; }
  .focus-stage { height: calc(100dvh - 124px); padding: 10px; }
}

@media print {
  body { background: #fff; }
  .app-header, .chapter-tabs, .sidebar, .viewer-topbar, .viewer-toolbar, .page-caption, .ocr-panel { display: none !important; }
  .app-layout, .viewer-panel { display: block; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .document-stage { height: auto; min-height: 0; padding: 0; overflow: visible; background: #fff; }
  .document-stage img { width: 100%; box-shadow: none; }
}

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