:root {
  color-scheme: light;
  --ink: #1d2766;
  --ink-deep: #151f50;
  --muted: #5b6783;
  --line: #e3e9f2;
  --paper: #fff;
  --radius: 24px;
}

body {
  min-width: 300px;
  background: #edf2f8;
  color: var(--ink);
}

[hidden] { display: none !important; }
button, input { font: inherit; }
button { color: inherit; }
button:not(:disabled), summary { cursor: pointer; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible,
.stage-scroll:focus-visible { outline: 2px solid #4d72cf; outline-offset: 3px; }
.tool svg, .top-actions svg, .search svg, .index-content svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: #fafcfe;
}

.topbar-inner {
  max-width: 1680px;
  min-height: 76px;
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-lockup, .contact-link, .top-actions { display: flex; align-items: center; }
.brand-lockup { gap: 18px; }
.brand-lockup:hover, .contact-link:hover { text-decoration: none; }
.brand-lockup img { width: 128px; height: auto; display: block; }
.brand-lockup span {
  border-inline-start: 1px solid #dce4ef;
  padding-inline-start: 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.top-actions { gap: 8px; }
.contact-link {
  min-height: 40px;
  gap: 8px;
  padding-inline: 13px;
  border: 1px solid #dce4ef;
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.contact-link:hover { background: #eef3fc; }

.workspace {
  max-width: 1680px;
  margin-inline: auto;
  padding: 23px clamp(16px, 3vw, 48px) 26px;
  display: grid;
  grid-template-columns: minmax(245px, 278px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.sidebar, .reader {
  min-width: 0;
  border: 1px solid #dde6f0;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 10px 32px #24345b09;
}
.sidebar {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.index-panel { display: flex; flex-direction: column; }
.sidebar .index-panel { position: absolute; inset: 0; }
.index-head { padding: 19px 15px 14px; border-bottom: 1px solid var(--line); }
.index-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 12px;
}
.index-heading h1 { font-size: 21px; font-weight: 800; line-height: 1.3; }
.search {
  min-height: 42px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding-inline: 11px;
  border: 1px solid var(--line);
  background: #f5f8fc;
  border-radius: 12px;
  color: var(--muted);
}
.search input {
  min-width: 0;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 13px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search:focus-within { outline: 2px solid #4d72cf; outline-offset: 2px; }
.search input:focus-visible { outline: 0; }
.index-content {
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  padding: 10px 11px 13px;
}
.index-link, .category summary {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  min-height: 41px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}
.index-link:hover, .category summary:hover { background: #f0f4fb; text-decoration: none; }
.index-link[aria-current="page"] {
  background: #e9effa;
  box-shadow: inset -3px 0 #5778bf;
  color: var(--ink-deep);
}
.index-link > span:first-child, .category-name { flex: 1; }
.index-link small { color: var(--muted); font-size: 11px; font-weight: 600; }
.category-stack {
  margin-block: 9px;
  padding-block: 8px;
  border-block: 1px solid var(--line);
}
.category + .category { margin-block-start: 4px; }
.category summary { list-style: none; }
.category summary::-webkit-details-marker { display: none; }
.category summary svg { width: 14px; height: 14px; color: var(--muted); }
.category[open] summary svg { transform: rotate(180deg); }
.category[open] summary, .category.is-current summary { background: var(--category-tint); }
.category-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--category-color);
  flex: none;
}
.category-links { padding: 3px 10px 6px 0; }
.category-links .index-link { font-size: 12px; }
.index-empty { padding: 18px 8px; color: var(--muted); font-size: 13px; }

.reader { overflow: hidden; }
.reader-toolbar {
  min-height: 66px;
  padding: 10px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.page-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-heading > div { min-width: 0; }
.section-dot {
  width: 10px;
  height: 32px;
  border-radius: 999px;
  flex: none;
  background: #a6c8f0;
}
.page-section { font-size: 11px; color: var(--muted); font-weight: 700; line-height: 1.45; }
.page-title {
  margin: 0;
  color: var(--ink-deep);
  font-size: clamp(15px, 1.6vw, 21px);
  font-weight: 800;
  line-height: 1.38;
  text-wrap: pretty;
}
.viewer-tools, .zoom-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.zoom-tools { direction: ltr; }
.tool {
  border: 1px solid #e4eaf4;
  background: #f6f8fd;
  border-radius: 11px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 700;
}
.tool:hover:not(:disabled) { background: #e9effa; }
.tool:disabled { opacity: .43; cursor: default; }
.icon-button { width: 38px; display: inline-grid; place-items: center; }
.zoom-reset { padding-inline: 9px; min-width: 59px; color: var(--muted); }
.view-mode { padding-inline: 9px; margin-inline-end: 3px; }
.toc-toggle, .drawer-close { display: none; }

.stage-scroll {
  direction: ltr;
  background: radial-gradient(ellipse at 48% 0%, #f0f4fa 0%, #e6edf7 85%);
  height: clamp(330px, calc(100dvh - 250px), 850px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-block: 1px solid #dce5f0;
}
.stage-inner {
  display: grid;
  place-items: center;
  padding: 21px;
  min-width: 100%;
  min-height: 100%;
  width: max-content;
}
.sheet-frame {
  position: relative;
  width: 297mm;
  height: 210mm;
  flex: none;
  background: white;
  box-shadow: 0 0 0 1px #1d27661c, 0 8px 28px #2639632b;
  isolation: isolate;
}
.canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 297mm;
  height: 210mm;
  transform-origin: top left;
}
.canvas > .pg { position: absolute; inset: 0; }

.pagination {
  padding: 11px 17px;
  background: #fff;
}
.pager {
  display: grid;
  grid-template-columns: 1fr minmax(70px, 128px) 1fr;
  align-items: center;
  gap: 12px;
}
.pager-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 108px;
  min-height: 42px;
  padding-inline: 11px;
  justify-self: start;
}
.pager-next {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  justify-self: end;
}
.pager-next:hover:not(:disabled) { background: #33458d; }
.pager-next:disabled { background: #f6f8fd; color: var(--ink); border-color: #e4eaf4; }
.page-status { display: grid; place-items: center; gap: 5px; }
.page-status output { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress { width: 100%; height: 3px; border-radius: 8px; background: #e6ecf7; overflow: hidden; }
.progress span {
  display: block;
  width: var(--progress, 3.57%);
  height: 100%;
  border-radius: 8px;
  background: #5b7bc6;
}
.index-drawer { border: 0; color: var(--ink); }
.index-drawer::backdrop { background: #111c3b73; }

@media (max-width: 950px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { display: none; }
  .toc-toggle { display: inline-flex; align-items: center; gap: 6px; padding-inline: 10px; }
  .drawer-close { display: inline-grid; }
  .index-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    margin: 0;
    max-height: none;
    max-width: none;
    width: min(86vw, 367px);
    height: 100dvh;
    border-radius: 17px 0 0 17px;
    box-shadow: -16px 0 50px #18214238;
    padding: 0;
  }
  #drawer-content, .index-drawer .index-panel { height: 100%; }
  body:has(.index-drawer[open]) { overflow: hidden; }
}

@media (max-width: 640px) {
  .topbar-inner { min-height: 60px; padding-inline: 13px; }
  .brand-lockup img { width: 101px; }
  .brand-lockup span { display: none; }
  .contact-link { padding-inline: 9px; gap: 5px; font-size: 12px; min-height: 38px; }
  .contact-link svg, .toc-toggle svg { width: 16px; height: 16px; }
  .toc-toggle { font-size: 12px; }
  .workspace { padding: 10px 9px calc(86px + env(safe-area-inset-bottom)); }
  .reader { border-radius: 16px; }
  .reader-toolbar { min-height: 58px; padding: 8px 9px; gap: 7px; }
  .page-heading { gap: 6px; }
  .section-dot { width: 6px; height: 25px; }
  .page-section { font-size: 10px; }
  .page-title { font-size: 14px; }
  .viewer-tools, .zoom-tools { gap: 2px; }
  .viewer-tools .tool { min-height: 34px; font-size: 11px; }
  .viewer-tools .icon-button { width: 33px; }
  .viewer-tools .icon-button svg { width: 15px; height: 15px; }
  .zoom-reset { min-width: 42px; padding-inline: 4px; }
  .view-mode { padding-inline: 7px; }
  .stage-scroll { height: calc((100vw - 43px) * .7071 + 26px); min-height: 185px; }
  .stage-inner { padding: 12px; }
  .pagination {
    position: fixed;
    z-index: 5;
    inset: auto 0 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -5px 20px #1821420d;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .pager { gap: 10px; grid-template-columns: 1fr 78px 1fr; }
  .pager-button { min-width: 85px; font-size: 12px; padding-inline: 7px; gap: 3px; }

  .reader.is-flow .stage-scroll { height: auto; overflow: visible; min-height: 0; }
  .reader.is-flow .stage-inner { display: block; width: auto; padding: 0; }
  .reader.is-flow :is(.sheet-frame, .canvas, .canvas > .pg) {
    position: relative;
    width: 100%;
    height: auto;
    transform: none;
    box-shadow: none;
  }
  .reader.is-flow .pg { padding: 0 13px; overflow: hidden; }
  .reader.is-flow .hd {
    position: relative;
    height: 42px;
    margin-inline: -13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-inline: 13px;
  }
  .reader.is-flow .hd :is(img, .tag) { position: static; }
  .reader.is-flow .hd img { height: 19px; order: 1; }
  .reader.is-flow .hd .tag { font-size: 11px; }
  .reader.is-flow .body {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 17px;
    padding-block: 14px 11px;
  }
  .reader.is-flow .card { flex: auto; border-radius: 15px; padding: 20px; }
  .reader.is-flow .card .ttl { font-size: clamp(20px, 5vw, 27px) !important; }
  .reader.is-flow .packw { flex: auto; min-height: 0; }
  .reader.is-flow .packw img { max-height: 270px; }
  .reader.is-flow .mid {
    flex: auto;
    border: 0;
    margin: 0;
    padding: 0;
    font-size: 15px !important;
    line-height: 1.8;
  }
  .reader.is-flow .mid h3 { font-size: 17px; }
  .reader.is-flow .detail { margin-top: 4px; }
  .reader.is-flow .badges { gap: 6px; flex-wrap: wrap; }
  .reader.is-flow .side { flex: auto; }
  .reader.is-flow .photo { height: min(72vw, 330px); }
  .reader.is-flow .ord { flex: auto; }
  .reader.is-flow .ord table { margin-block: 8px; }
  .reader.is-flow .ord td:first-child { width: 58%; }
  .reader.is-flow .bcw { min-height: 98px; }
  .reader.is-flow .bc { width: min(215px, 95%); max-height: 93px; }
  .reader.is-flow .ft { position: relative; inset: auto; margin-bottom: 7px; }
  .reader.is-flow .ft:before { left: 0; right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
.sheet-frame { overflow: hidden; }
.quick-index { display: none; }
@media (max-width: 640px) {
  .quick-index { display: block; padding: 12px 10px 14px; }
  .quick-index h3 { font-size: 15px; margin: 0 4px 7px; }
  .quick-index .index-link {
    background: var(--category-tint);
    margin-block: 5px;
    padding-inline: 11px;
  }
  .quick-index .index-link:active { filter: brightness(.96); }
}
@media (max-width: 640px) {
  .reader.is-contact .stage-scroll { height: auto; overflow: visible; min-height: 0; }
  .reader.is-contact .stage-inner { display: block; width: auto; padding: 0; }
  .reader.is-contact :is(.sheet-frame, .canvas, .canvas > .pg) {
    position: relative;
    width: 100%;
    height: auto;
    transform: none;
    box-shadow: none;
  }
  .reader.is-contact .pg {
    padding: 24px 15px 14px;
    display: grid;
    justify-items: stretch;
  }
  .reader.is-contact .contact-sheet-logo {
    position: static !important;
    transform: none !important;
    height: auto !important;
    width: min(65%, 260px);
    justify-self: center;
  }
  .reader.is-contact .contact-sheet-tagline {
    position: static !important;
    font-size: 14px !important;
    margin-block: 7px 19px;
  }
  .reader.is-contact .contact-sheet-address {
    position: static !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8faff;
    line-height: 1.95 !important;
  }
  .reader.is-contact .contact-sheet-address a { display: inline-block; }
  .reader.is-contact .contact-sheet-url {
    position: static !important;
    font-size: 11px !important;
    letter-spacing: 2px !important;
    margin-block: 14px 10px;
  }
  .reader.is-contact .bar {
    position: static;
    height: 9px;
  }
}
