:root {
  color-scheme: light;
  --ink: #172334;
  --muted: #596575;
  --blue: #1659ce;
  --accent: #c43d18;
  --line: #c4cdd8;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--muted); border-radius: 4px; min-height: 44px; padding: 10px 18px; cursor: pointer; }
button:hover, button:active { background: #eef4fe; }
button:disabled, button[aria-disabled="true"] { opacity: .52; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
a { color: var(--blue); text-underline-offset: 4px; }
[hidden] { display: none !important; }
.skip { position: fixed; left: 16px; top: -80px; padding: 12px; background: #fff; z-index: 5; }
.skip:focus { top: 10px; }
.topbar { max-width: 1536px; margin: auto; display: flex; align-items: center; gap: 24px; padding: 14px clamp(16px, 3vw, 48px); }
.brand { font-weight: 800; font-size: 20px; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.deck-name { margin: 0 auto 0 0; color: var(--muted); font-size: 14px; }
main { max-width: 1536px; margin: auto; padding: 0 clamp(12px, 2.5vw, 40px); }
.slide-frame { margin: 0 auto; width: min(100%, calc((100svh - 168px) * 16 / 9)); position: relative; background: #fff; }
.slide-frame img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; }
.image-error { padding: 20px; background: #fff; border: 1px solid var(--line); color: var(--accent); }
.reading { max-width: 950px; margin: 16px auto 30px; }
summary { color: var(--muted); cursor: pointer; min-height: 44px; padding: 10px 4px; font-size: 16px; }
h1 { font-size: clamp(26px, 3.5vw, 38px); line-height: 1.35; word-break: keep-all; margin: 24px 0; }
#slide-text { font-size: 20px; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere; }
#slide-text p { margin: 10px 0; white-space: pre-line; }
.source-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 24px; }
.source-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: 16px; }
.controls { position: fixed; left: 0; bottom: 0; width: 100%; background: #fff; z-index: 2; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
.progress { height: 3px; background: #d9e1ea; }
#progress-fill { height: 100%; width: 5%; background: var(--blue); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1456px; padding: 13px 20px; margin: auto; }
.page-controls, .view-controls { display: flex; align-items: center; gap: 12px; }
#page-number { font-size: 16px; font-variant-numeric: tabular-nums; min-width: 74px; text-align: center; }
#next { background: var(--blue); border-color: var(--blue); color: #fff; }
#next:hover { background: #1049ad; }
.keyboard-hint { color: var(--muted); font-size: 14px; margin: 0; }
.notice { margin: 0 20px 12px; font-size: 14px; color: var(--accent); }
dialog { width: min(850px, calc(100% - 32px)); max-height: calc(100dvh - 60px); padding: 24px; color: var(--ink); background: #fff; border: 1px solid var(--muted); border-radius: 8px; overflow-y: auto; }
dialog::backdrop { background: rgb(23 35 52 / .35); }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 25px; margin: 6px 0; line-height: 1.35; word-break: keep-all; }
#contents-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
#contents-list button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 16px 8px; line-height: 1.5; }
#contents-list button[aria-current="page"] { color: var(--blue); font-weight: 800; }
.toc-number { display: inline-block; margin-right: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#notes-content { font-size: 18px; line-height: 1.8; word-break: keep-all; overflow-wrap: anywhere; }
#notes-content p { white-space: pre-line; }
#notes-content h3 { font-size: 20px; margin: 32px 0 10px; }
#notes-content ul { padding-left: 22px; }
#notes-content li { margin-bottom: 10px; }
#notes-content a { display: inline-block; min-height: 44px; }
.photo-credit { border-top: 1px solid var(--line); padding-top: 20px; color: var(--muted); font-size: 16px; }
:root:fullscreen .topbar { display: none; }
:root:fullscreen .slide-frame { width: min(100%, calc((100svh - 116px) * 16 / 9)); }
@media (max-width: 850px) {
  .keyboard-hint { display: none; }
  .topbar { gap: 16px; }
  .deck-name { font-size: 12px; }
  .control-row { gap: 12px; }
}
@media (max-width: 560px) {
  body { padding-bottom: calc(142px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 16px; }
  .deck-name { display: none; }
  .brand { margin-right: auto; }
  main { padding: 0 12px; }
  .slide-frame { width: 100%; }
  .reading { padding: 0 8px; }
  #slide-text { font-size: 19px; line-height: 1.75; }
  .control-row { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .page-controls { width: 100%; justify-content: space-between; }
  .view-controls { width: 100%; justify-content: flex-end; }
  .view-controls button { min-height: 44px; }
  #contents-list { grid-template-columns: 1fr; }
  dialog { padding: 18px; max-height: calc(100dvh - 32px); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
