:root {
  color-scheme: light;
  --ink: #151617;
  --deep: #202123;
  --ivory: #f3eee6;
  --bronze: #d3c5b9;
  --bronze-ink: #755632;
  --gold: #c7a66a;
  --line: rgba(211, 197, 185, 0.34);
  --muted: rgba(243, 238, 230, 0.68);
  --page-ratio: 0.71287;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
  scroll-behavior: smooth;
}

html.der-tag-reader,
html.der-tag-reader body {
  color: var(--ink) !important;
  background: var(--ivory) !important;
}

html.der-tag-reader body {
  background:
    radial-gradient(circle at 50% 18%, rgba(199, 166, 106, 0.1), transparent 34%),
    linear-gradient(180deg, #f7f3ec, var(--ivory)) !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ivory);
  background:
    linear-gradient(180deg, rgba(10, 11, 12, 0.38), rgba(10, 11, 12, 0.86)),
    url("assets/kfk-textur.jpg") center / cover fixed,
    var(--ink);
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
.stage:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--ivory);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  color: var(--ivory);
  background: rgba(15, 16, 17, 0.84);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.home-action {
  gap: 7px;
  border-color: rgba(199, 166, 106, 0.56) !important;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 3px;
  letter-spacing: 0.12em;
}

.brand-copy strong {
  font-size: 0.86rem;
}

.brand-copy small {
  color: var(--bronze);
  font-size: 0.72rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions a,
.top-actions button {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ivory);
  background: rgba(32, 33, 35, 0.72);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.top-actions a:hover,
.top-actions button:hover {
  border-color: var(--bronze);
  background: rgba(51, 50, 49, 0.92);
  transform: translateY(-1px);
}

.reader {
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 38px) 32px;
}

.reader-heading {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  margin: 0 auto 14px;
  text-align: center;
}

.reader-heading p {
  margin: 0;
  color: var(--bronze-ink);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.reader-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  font-weight: 400;
  color: var(--ink) !important;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(48px, 1fr) auto minmax(48px, 1fr);
  align-items: center;
  min-height: min(73vh, 860px);
  border: 1px solid rgba(211, 197, 185, 0.24);
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(199, 166, 106, 0.11), transparent 44%),
    linear-gradient(135deg, rgba(35, 36, 38, 0.92), rgba(13, 14, 15, 0.98));
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.46);
  touch-action: pan-y;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.stage::before {
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stage::after {
  left: 50%;
  bottom: -18%;
  width: min(68%, 760px);
  height: 30%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  filter: blur(28px);
}

.page-frame {
  position: relative;
  z-index: 2;
  width: min(calc((73vh - 28px) * var(--page-ratio)), 550px, 76vw);
  margin: 14px auto;
  aspect-ratio: 216 / 303;
  overflow: hidden;
  background: #1a1b1c;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.54),
    0 0 0 1px rgba(243, 238, 230, 0.12);
  transition: opacity 180ms ease, transform 240ms ease;
}

.page-frame.is-changing {
  opacity: 0.32;
  transform: translateY(4px) scale(0.994);
}

.page-zoom-trigger {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.page-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-zoom-cue {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 9px 12px;
  border: 1px solid rgba(243, 238, 230, 0.36);
  border-radius: 999px;
  color: var(--ivory);
  background: rgba(21, 22, 23, 0.9);
  font-size: 0.76rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.page-zoom-trigger:hover .page-zoom-cue,
.page-zoom-trigger:focus-visible .page-zoom-cue {
  opacity: 1;
  transform: translateY(0);
}

.page-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 28px;
  color: var(--ivory);
  background: var(--deep);
  text-align: center;
}

.page-error[hidden] {
  display: none;
}

.edge-button {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--bronze);
  background: rgba(21, 22, 23, 0.78);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.edge-button:hover:not(:disabled) {
  color: var(--ivory);
  border-color: var(--bronze);
  transform: scale(1.04);
}

.edge-button:disabled,
.control-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.reader-controls {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 220px) auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ivory);
  background: rgba(32, 33, 35, 0.88);
  cursor: pointer;
}

.control-button:last-child {
  justify-self: end;
}

.control-button-zoom {
  border-color: var(--gold) !important;
  color: var(--ink);
  background: var(--gold);
  font-weight: 700;
}

.control-button-zoom:hover {
  background: #d4b777;
}

.page-status {
  display: grid;
  gap: 8px;
  color: #70685e;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.page-status strong {
  color: var(--ink);
  font-size: 1.08rem;
}

.progress-track {
  height: 2px;
  overflow: hidden;
  background: rgba(21, 22, 23, 0.16);
}

.progress-track span {
  display: block;
  width: 8.333%;
  height: 100%;
  background: var(--gold);
  transition: width 220ms ease;
}

.page-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.page-dot {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  color: transparent;
  background: transparent;
  cursor: pointer;
}

.page-dot::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  margin: auto;
  border-radius: 50%;
  background: rgba(21, 22, 23, 0.28);
  transition: background 160ms ease, transform 160ms ease;
}

.page-dot[aria-current="page"]::before {
  background: var(--gold);
  transform: scale(1.5);
}

.reader-hint {
  margin: 12px 0 0;
  color: #70685e;
  font-size: 0.86rem;
  text-align: center;
}

.site-footer {
  display: grid;
  gap: 6px;
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 36px 20px 54px;
  border-top: 1px solid var(--line);
  color: #70685e;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer strong {
  color: var(--ink);
  letter-spacing: 0.08em;
}

.site-footer .footer-line {
  margin-top: 14px;
  color: var(--bronze-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
}

.zoom-dialog {
  color-scheme: dark;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ivory);
  background: rgba(10, 11, 12, 0.98);
}

.zoom-dialog::backdrop {
  background: rgba(0, 0, 0, 0.9);
}

.zoom-toolbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(21, 22, 23, 0.94);
  backdrop-filter: blur(14px);
}

#zoomLabel {
  align-self: center;
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.zoom-toolbar button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ivory);
  background: var(--deep);
  cursor: pointer;
}

.zoom-toolbar button:disabled {
  opacity: 0.34;
  cursor: default;
}

.zoom-canvas {
  min-height: calc(100dvh - 64px);
  padding: 22px;
  overflow: auto;
  text-align: center;
  touch-action: pan-x pan-y pinch-zoom;
}

.zoom-canvas img {
  width: min(1446px, 150vw);
  max-width: none;
  height: auto;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.62);
}

.noscript-message {
  margin: 24px auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  text-align: center;
}

.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;
}

@media (max-width: 760px) {
  .topbar {
    min-height: 66px;
    padding: 10px 14px;
  }

  .brand-copy {
    display: none;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .top-actions {
    gap: 5px;
  }

  .top-actions a,
  .top-actions button {
    min-height: 40px;
    padding: 8px 11px;
    font-size: 0.88rem;
  }

  .reader {
    padding: 16px 9px 28px;
  }

  .reader-heading {
    margin-bottom: 10px;
  }

  .stage {
    display: flex;
    justify-content: center;
    min-height: 0;
    padding: 10px;
    border-radius: 18px;
    touch-action: pan-y pinch-zoom;
  }

  .page-frame {
    width: min(100%, calc((100dvh - 215px) * var(--page-ratio)));
    min-width: 240px;
    margin: 0 auto;
  }

  .edge-button {
    display: none;
  }

  .reader-controls {
    grid-template-columns: 1fr auto 1fr;
    gap: 7px;
    margin-top: 12px;
  }

  .control-button {
    min-height: 44px;
    padding: 9px 13px;
    font-size: 0.9rem;
  }

  .control-button-zoom {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .page-status {
    min-width: 92px;
  }

  .page-dots {
    gap: 1px;
    margin-top: 10px;
  }

  .page-dot {
    width: 24px;
    height: 24px;
  }

  .reader-hint {
    margin-top: 7px;
    padding: 0 18px;
    line-height: 1.45;
  }

  .site-footer {
    padding-top: 28px;
  }

  .zoom-canvas {
    padding: 10px;
  }

  .zoom-canvas img {
    width: max(100%, 980px);
  }

  .page-zoom-cue {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 390px) {
  .fullscreen-action {
    display: none;
  }

  .top-actions a,
  .top-actions button {
    padding-inline: 9px;
    font-size: 0.82rem;
  }

  .reader-heading {
    gap: 10px;
  }

  .reader-heading h1 {
    font-size: 1.24rem;
  }

  .reader-heading p {
    font-size: 0.7rem;
  }

  #zoomPreviousButton span:last-child,
  #zoomNextButton span:first-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
