@font-face {
  font-family: "Titillium Web";
  src: url("./assets/fonts/TitilliumWeb-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Titillium Web";
  src: url("./assets/fonts/TitilliumWeb-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Bebas Neue";
  src: url("./assets/fonts/BebasNeue-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root, [data-theme="light"] {
  color-scheme: light;
  --font-body: "Titillium Web", "Helvetica Neue", sans-serif;
  --font-display: "Bebas Neue", "Titillium Web", sans-serif;
  --text-xs: clamp(.75rem, .73rem + .1vw, .8125rem);
  --text-sm: clamp(.875rem, .85rem + .1vw, .9375rem);
  --text-base: clamp(1rem, .97rem + .12vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + .25vw, 1.3125rem);
  --text-xl: clamp(1.5rem, 1.45rem + .25vw, 1.75rem);
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --color-bg: #e9edeb;
  --color-surface: #ffffff;
  --color-surface-2: #f5f7f6;
  --color-hover: #eaf0ed;
  --color-text: #252323;
  --color-muted: #59625f;
  --color-border: #d6ddda;
  --color-primary: #007361;
  --color-primary-hover: #005b4d;
  --color-highlight: #e4f1ec;
  --color-error: #a13630;
  --color-focus: #007361;
  --color-brandplate: #252323;
  --color-paper: #ffffff;
  --color-paper-ink: #252323;
  --radius-sm: .25rem;
  --radius-md: .5rem;
  --transition: 180ms cubic-bezier(.16, 1, .3, 1);
  --shadow-page: 0 2px 5px #2523231f, 0 14px 42px #25232324;
  --shadow-drawer: 8px 0 40px #25232326;
  --canvas-padding: 24px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #181b1a;
  --color-surface: #252827;
  --color-surface-2: #2c302e;
  --color-hover: #343c38;
  --color-text: #f0f3f1;
  --color-muted: #b5beb9;
  --color-border: #424a45;
  --color-primary: #88d1b8;
  --color-primary-hover: #a9e2ce;
  --color-highlight: #244237;
  --color-error: #ffaaa2;
  --color-focus: #88d1b8;
  --shadow-page: 0 2px 6px #00000035, 0 16px 48px #00000055;
  --shadow-drawer: 8px 0 40px #00000040;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { color: var(--color-text); background: var(--color-bg); font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button, a, input { -webkit-tap-highlight-color: transparent; transition: background-color var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition); }
a { color: inherit; }
button:disabled, input:disabled { opacity: .38; cursor: default; }
img, svg { display: block; }
button svg, a svg { pointer-events: none; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; }
::selection { color: var(--color-text); background: var(--color-highlight); }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.small-icon { width: 15px; height: 15px; }
.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; top: var(--space-2); left: var(--space-2); z-index: 30; padding: var(--space-3) var(--space-4); background: var(--color-surface); color: var(--color-primary); transform: translateY(-150%); border-radius: var(--radius-sm); }
.skip-link:focus { transform: none; }

.reader-shell { height: 100vh; height: 100dvh; min-height: 360px; display: flex; flex-direction: column; overflow: hidden; }
.masthead { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-6); border-top: 3px solid #007361; background: var(--color-surface); }
.identity { display: flex; gap: var(--space-4); align-items: center; min-width: 0; }
.brand-plate { flex: 0 0 auto; width: 96px; height: 46px; min-height: 44px; background: var(--color-brandplate); display: grid; place-items: center; border-radius: 2px; padding: var(--space-3); }
.brand-plate img { width: 100%; height: auto; }
@media (hover: hover) { .brand-plate:hover { background: #007361; } }
.issue-heading { min-width: 0; }
.issue-heading h1 { font-size: var(--text-lg); font-weight: 700; }
.issue-heading p { font-size: var(--text-sm); color: var(--color-muted); margin-top: var(--space-1); }
.edition-label { font-size: var(--text-xs); color: var(--color-muted); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
[data-embed="true"] .masthead { display: none; }

.toolbar { flex: 0 0 auto; display: grid; grid-template-columns: minmax(300px, 1fr) auto auto minmax(200px, 1fr); align-items: center; gap: var(--space-4); padding: var(--space-2) var(--space-6); background: var(--color-surface); border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); z-index: 2; }
.tool-group { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.utility-tools { justify-content: flex-end; gap: var(--space-2); }
.icon-button, .tool-button, .fit-button, .download-button { min-height: 44px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); text-decoration: none; flex: 0 0 auto; font-size: var(--text-sm); white-space: nowrap; }
.icon-button { width: 44px; }
.tool-button { padding-inline: var(--space-3); }
.fit-button { min-width: 54px; font-variant-numeric: tabular-nums; padding-inline: var(--space-2); }
.download-button { background: #007361; color: #fff; padding-inline: var(--space-4); font-weight: 700; }
.link-count { font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.tool-button[aria-pressed="true"], .tool-button[aria-expanded="true"] { color: var(--color-primary); background: var(--color-highlight); }
.navigation-tools { gap: 0; }
.page-form { position: relative; display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); white-space: nowrap; }
.page-label { color: var(--color-muted); margin-right: var(--space-1); }
.page-form input { width: 44px; height: 44px; padding: var(--space-1); border: 1px solid var(--color-border); background: var(--color-surface-2); border-radius: var(--radius-sm); text-align: center; font-size: var(--text-base); font-variant-numeric: tabular-nums; }
.page-form input[aria-invalid="true"] { border-color: var(--color-error); }
.page-input-error { position: absolute; top: calc(100% + var(--space-2)); left: 0; z-index: 5; padding: var(--space-2) var(--space-3); background: var(--color-surface); color: var(--color-error); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-drawer); font-size: var(--text-sm); }
.page-total { color: var(--color-muted); padding-left: var(--space-1); font-variant-numeric: tabular-nums; }
.zoom-tools { gap: 0; padding-inline: var(--space-3); border-inline: 1px solid var(--color-border); }
@media (hover: hover) {
  .icon-button:hover:not(:disabled), .tool-button:hover:not(:disabled), .fit-button:hover:not(:disabled) { background: var(--color-hover); color: var(--color-primary); }
  .download-button:hover, .solid-button:hover { background: #005b4d; }
  .text-link:hover { color: var(--color-primary-hover); text-decoration-thickness: 2px; }
}
.icon-button:active:not(:disabled), .tool-button:active:not(:disabled), .fit-button:active:not(:disabled) { background: var(--color-highlight); }

.reading-area { flex: 1 1 0; min-height: 0; min-width: 0; position: relative; overflow: hidden; outline-offset: -4px !important; }
.page-viewport { height: 100%; width: 100%; overflow: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; outline-offset: -4px !important; scrollbar-color: var(--color-border) var(--color-bg); }
.page-viewport.is-zoomed { touch-action: auto; cursor: grab; }
.page-viewport.is-panning { cursor: grabbing; user-select: none; }
.page-canvas { display: grid; place-items: center; min-width: 100%; min-height: 100%; padding: var(--canvas-padding); }
.page-frame { position: relative; width: min(420px, 100%); aspect-ratio: 595.276 / 841.89; flex: none; background: var(--color-paper); color: var(--color-paper-ink); box-shadow: var(--shadow-page); isolation: isolate; }
.page-media, .link-overlays { position: absolute; inset: 0; }
.page-media img { display: block; width: 100%; height: 100%; max-width: none; object-fit: fill; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.page-frame[data-state="loading"] .page-media, .page-frame[data-state="error"] .page-media { visibility: hidden; }
.page-frame:not([data-state="ready"]) .link-overlays { display: none; }
.page-frame[data-state="ready"] .page-message { display: none; }
.page-frame[data-state="ready"] .page-media { animation: page-arrive 190ms ease-out; }
.link-overlays { pointer-events: none; z-index: 1; }
.page-link { position: absolute; display: block; pointer-events: auto; background: transparent; border-radius: 1px; cursor: pointer; -webkit-user-drag: none; }
.page-link:focus-visible { outline: 3px solid #007361; outline-offset: 2px; box-shadow: 0 0 0 5px #fff; background: #0073611a; z-index: 3; }
@media (hover: hover) { .page-link:hover { background: #0073611c; outline: 1px solid #00736199; z-index: 2; } }
.page-message { position: absolute; inset: 0; padding: var(--space-6); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--space-3); background: #fff; }
.page-message h2 { font-size: var(--text-lg); }
.page-message p { font-size: var(--text-sm); line-height: 1.6; max-width: 30ch; color: #59625f; }
.loading-mark { width: 32px; height: 32px; border: 2px solid #e2e9e5; border-top-color: #007361; border-radius: 50%; margin-bottom: var(--space-2); animation: loading 900ms linear infinite; }
.message-actions { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.solid-button, .subtle-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.solid-button { background: #007361; color: #fff; }
.subtle-button { color: #007361; background: #e4f1ec; }
.page-message .text-link { color: #007361; }
.page-message .text-link:focus-visible, .page-message button:focus-visible { outline-color: #007361; }

.reader-footer { min-height: 40px; position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) var(--space-6) var(--space-3); flex: 0 0 auto; color: var(--color-muted); font-size: var(--text-xs); }
.current-page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reading-hint { white-space: nowrap; }
.hint-divider { margin-inline: var(--space-2); }
.touch-hint { display: none; }
.reading-progress { height: 3px; position: absolute; left: 0; right: 0; bottom: 0; background: var(--color-border); }
.reading-progress > div { width: 0; height: 100%; background: var(--color-primary); transition: width 220ms ease-out; }

.text-viewport { height: 100%; overflow: auto; overscroll-behavior: contain; padding: var(--space-8) var(--space-6); outline-offset: -4px !important; }
.text-page { max-width: 760px; margin-inline: auto; padding: var(--space-10) var(--space-12); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.text-page-heading { padding-bottom: var(--space-6); margin-bottom: var(--space-6); border-bottom: 1px solid var(--color-border); }
.eyebrow { color: var(--color-primary); font-size: var(--text-xs); letter-spacing: .1em; text-transform: uppercase; margin-bottom: var(--space-2); }
.text-page h2 { font-size: var(--text-xl); font-weight: 700; }
.text-note, .muted-note { font-size: var(--text-sm); color: var(--color-muted); margin-top: var(--space-2); }
.page-text { font-size: var(--text-base); line-height: 1.85; overflow-wrap: anywhere; }
.page-text p { white-space: pre-wrap; margin-bottom: var(--space-5); }
.text-page-links { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.text-page-links h3 { font-size: var(--text-lg); }
.text-page-links .resource-list { margin-top: var(--space-4); }

.drawer { position: fixed; inset: 0 auto 0 0; width: 410px; max-width: calc(100vw - 24px); height: 100vh; height: 100dvh; max-height: 100%; margin: 0; padding: 0; border: 0; border-right: 1px solid var(--color-border); color: var(--color-text); background: var(--color-surface); box-shadow: var(--shadow-drawer); overflow: hidden; }
.drawer[open] { display: flex; flex-direction: column; animation: drawer-arrive 220ms cubic-bezier(.16,1,.3,1); }
.drawer[data-panel="links"] { inset: 0 0 0 auto; border-right: 0; border-left: 1px solid var(--color-border); }
.drawer::backdrop { background: #101d1780; }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); padding: var(--space-6) var(--space-5) var(--space-5) var(--space-6); flex: 0 0 auto; }
.drawer-header h2 { font-size: var(--text-lg); }
.drawer-header .eyebrow { margin-bottom: var(--space-1); }
.drawer-header .icon-button { margin-top: calc(-1 * var(--space-2)); margin-right: calc(-1 * var(--space-2)); }
.drawer-body { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
.drawer-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-inline: var(--space-6); padding: var(--space-1); border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); gap: var(--space-1); flex: 0 0 auto; }
.drawer-tab { min-height: 44px; display: flex; gap: var(--space-2); align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--color-muted); }
.drawer-tab[aria-selected="true"] { background: var(--color-surface); color: var(--color-primary); box-shadow: 0 1px 3px #25232314; font-weight: 700; }
.drawer-scroll { overflow: auto; overscroll-behavior: contain; flex: 1 1 0; padding: var(--space-5) var(--space-6) var(--space-6); scrollbar-width: thin; }
.contents-list, .thumbnail-grid, .resource-list { list-style: none; }
.contents-list li { border-bottom: 1px solid var(--color-border); }
.contents-list a { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-4); min-height: 52px; padding: var(--space-3) var(--space-2); text-decoration: none; border-radius: var(--radius-sm); font-size: var(--text-base); line-height: 1.35; }
.contents-list a > span:last-child { color: var(--color-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.contents-list a[aria-current="page"] { color: var(--color-primary); background: var(--color-highlight); font-weight: 700; }
.thumbnail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--space-5) var(--space-4); }
.thumbnail-link { display: block; text-decoration: none; border-radius: var(--radius-sm); }
.thumbnail-image { aspect-ratio: 595.276 / 841.89; border: 2px solid transparent; background: var(--color-bg); padding: var(--space-1); border-radius: var(--radius-sm); display: grid; place-items: center; overflow: hidden; }
.thumbnail-image img { width: 100%; height: 100%; object-fit: contain; box-shadow: 0 1px 3px #2523231a; }
.thumbnail-image .thumbnail-fallback { font-size: var(--text-sm); color: var(--color-muted); text-align: center; padding: var(--space-3); }
.thumbnail-link[aria-current="page"] .thumbnail-image { border-color: var(--color-primary); background: var(--color-highlight); }
.thumbnail-label { display: block; margin-top: var(--space-2); font-size: var(--text-sm); line-height: 1.35; overflow-wrap: anywhere; }
.thumbnail-number { color: var(--color-muted); margin-right: var(--space-2); font-variant-numeric: tabular-nums; }
.drawer-intro { color: var(--color-muted); font-size: var(--text-sm); margin: 0 var(--space-6) var(--space-1); }
.resource-list li + li { border-top: 1px solid var(--color-border); }
.resource-link { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-2); min-height: 56px; text-decoration: none; border-radius: var(--radius-sm); }
.resource-label { font-size: var(--text-base); line-height: 1.4; overflow-wrap: anywhere; display: block; }
.resource-host { display: block; color: var(--color-muted); font-size: var(--text-xs); margin-top: var(--space-1); overflow-wrap: anywhere; }
.resource-link > .icon { color: var(--color-primary); width: 17px; height: 17px; }
.empty-links { padding-block: var(--space-5); color: var(--color-muted); font-size: var(--text-base); }
.drawer-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-6); border-top: 1px solid var(--color-border); font-size: var(--text-xs); color: var(--color-muted); flex: 0 0 auto; background: var(--color-surface-2); }
.text-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; gap: var(--space-2); color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; font-size: var(--text-sm); }
@media (hover: hover) {
  .contents-list a:hover, .resource-link:hover, .drawer-tab:hover { background: var(--color-hover); color: var(--color-primary); }
  .thumbnail-link:hover .thumbnail-image { border-color: var(--color-primary); }
}
.noscript-message { position: fixed; inset: auto var(--space-4) var(--space-4); padding: var(--space-4); z-index: 30; background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-drawer); font-size: var(--text-base); }

@media (max-width: 1150px) {
  .toolbar { grid-template-columns: 1fr auto auto auto; gap: var(--space-2); padding-inline: var(--space-4); }
  .tool-button { padding-inline: var(--space-2); }
  .zoom-tools { padding-inline: var(--space-2); }
  .download-button span { display: none; }
  .download-button { width: 44px; padding: 0; }
}
@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr auto; grid-template-areas: "explore utility" "navigation zoom"; gap: 0 var(--space-2); padding: var(--space-1) var(--space-3); }
  .explore-tools { grid-area: explore; }
  .navigation-tools { grid-area: navigation; justify-self: start; }
  .zoom-tools { grid-area: zoom; border: 0; padding: 0; justify-self: end; }
  .utility-tools { grid-area: utility; gap: var(--space-1); }
  .links-label { font-size: 0; }
  .links-label::after { content: "Links"; font-size: var(--text-sm); }
  .tool-button { gap: var(--space-1); }
  .reader-footer { padding-inline: var(--space-4); }
  .reading-hint { max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
  .desktop-hint, .hint-divider { display: none; }
  .touch-hint { display: none; }
}
@media (max-width: 480px) {
  :root { --canvas-padding: 12px; }
  .masthead { padding: var(--space-3); gap: var(--space-2); }
  .identity { gap: var(--space-3); }
  .brand-plate { width: 72px; height: 36px; padding: var(--space-2); }
  .issue-heading h1 { font-size: var(--text-base); }
  .issue-heading p { font-size: var(--text-xs); margin-top: 0; }
  .edition-label { display: none; }
  .toolbar { gap: 0; padding-inline: var(--space-2); }
  .explore-tools { gap: 0; }
  .tool-button { padding-inline: var(--space-2); }
  .tool-button .icon { width: 17px; height: 17px; }
  #links-button .icon { display: none; }
  .link-count { min-width: 1ch; }
  .navigation-tools { margin-left: calc(-1 * var(--space-1)); }
  .page-label { margin-right: 0; }
  .zoom-tools { margin-right: calc(-1 * var(--space-1)); }
  .fit-button { min-width: 50px; }
  .reader-footer { min-height: 35px; gap: var(--space-2); padding-inline: var(--space-3); padding-top: var(--space-1); padding-bottom: var(--space-2); }
  .reading-hint { font-size: 0; max-width: none; }
  .touch-hint { display: inline; font-size: var(--text-xs); }
  .text-viewport { padding: var(--space-3); }
  .text-page { padding: var(--space-6) var(--space-5); }
  .text-page h2 { font-size: var(--text-lg); }
  .text-page-heading { padding-bottom: var(--space-5); margin-bottom: var(--space-5); }
  .drawer { max-width: calc(100vw - 16px); }
  .drawer-header { padding: var(--space-5); }
  .drawer-tabs { margin-inline: var(--space-5); }
  .drawer-scroll { padding-inline: var(--space-5); }
  .drawer-intro { margin-inline: var(--space-5); }
  .drawer-footer { padding-inline: var(--space-5); }
}
@media (max-width: 350px) {
  .tool-button { padding-inline: var(--space-1); }
  .tool-button .icon { display: none; }
  .toolbar .icon-button { width: 42px; }
}
@media (max-height: 500px) and (min-width: 650px) {
  .masthead { padding-block: var(--space-2); }
  .brand-plate { height: 32px; padding-block: var(--space-2); }
  .edition-label { display: none; }
  .toolbar { display: flex; justify-content: space-between; gap: var(--space-1); }
  .tool-button { padding-inline: var(--space-2); }
  .tool-button span { display: none; }
  .reader-footer { min-height: 30px; }
  :root { --canvas-padding: 12px; }
}
@keyframes page-arrive { from { opacity: .55; } to { opacity: 1; } }
@keyframes drawer-arrive { from { opacity: .7; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
