@font-face {
  font-family: "Readmade Serif";
  src: url("../fonts/NotoSerifKR-subset-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+2000-206F, U+3000-303F, U+1100-11FF, U+3130-318F, U+AC00-D7A3;
}

:root {
  color-scheme: light dark;
  --font-prose: "Readmade Serif", "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
  --paper: #fffefa;
  --canvas: #f7f4ef;
  --ink: #23212a;
  --muted: #66616c;
  --line: #dcd6df;
  --accent: #6138c6;
  --surface: #ffffff;
  --reader-leaf: #fffdf8;
  --reader-leaf-ink: #26222b;
  --reader-leaf-line: #dfd5c8;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; min-width: 280px; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: "Noto Sans KR", system-ui, sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.reader-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.reader-skip { position: absolute; z-index: 50; left: 8px; top: -70px; padding: 8px 12px; border-radius: 8px; background: var(--surface); color: var(--ink); }
.reader-skip:focus { top: 8px; }
.reader-toolbar { position: relative; z-index: 2; display: flex; flex: 0 0 auto; align-items: center; gap: 8px; width: 100%; min-height: 58px; padding: 7px clamp(8px, 2vw, 20px); border-bottom: 1px solid var(--line); background: var(--surface); }
.reader-title { flex: 1 1 160px; min-width: 36px; overflow: hidden; font-size: 16px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.reader-toc { flex: 0 1 190px; min-width: 48px; max-width: 22vw; height: 36px; padding: 0 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.reader-page-tools { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; min-width: 0; }
.reader-icon-button { display: inline-grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 18px; font-weight: 750; line-height: 1; }
.reader-icon-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.reader-icon-button:disabled { opacity: .4; cursor: default; }
.reader-progress { width: 74px; min-width: 40px; max-width: 90px; overflow: hidden; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.reader-progress-track { width: 58px; height: 4px; overflow: hidden; border-radius: 99px; background: var(--line); }
.reader-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.reader-close { font-size: 24px; }
.reader-main { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; padding: 8px; }
.reader-stage { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: inset 0 0 0 1px #ffffff70; touch-action: pan-y; --reader-book-font-size: 18px; --reader-book-line-height: 1.9; --reader-book-font-family: var(--font-prose); }
.reader-stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.reader-empty { display: grid; justify-items: center; gap: 12px; padding: 24px; color: var(--muted); text-align: center; }
.reader-empty p { margin: 0; }
.reader-empty button, .reader-file-picker { min-height: 40px; padding: 0 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); color: var(--accent); font-weight: 750; }
.reader-empty button:hover, .reader-file-picker:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.reader-notice { position: absolute; z-index: 5; left: 50%; bottom: 18px; max-width: min(560px, calc(100% - 28px)); margin: 0; padding: 9px 14px; transform: translateX(-50%); border: 1px solid transparent; border-radius: 10px; background: #fffef5ed; color: var(--muted); font-size: 13px; text-align: center; box-shadow: 0 5px 22px #20192524; pointer-events: none; }
.reader-notice:empty { display: none; }
.reader-notice.is-error { border-color: #e7a3aa; background: #fff4f5; color: #9d2736; }

.reader-stage:has(.reader-flip-book) { background: radial-gradient(ellipse at 50% 28%, #e8ded1 0%, #d7c9b9 60%, #bba993 100%); }
.reader-flip-book { position: relative; flex: 0 0 auto; margin: auto; filter: drop-shadow(0 14px 17px #271a1e5e); }
.reader-book-leaf { position: relative; box-sizing: border-box; width: 100%; height: 100%; overflow: hidden; padding: 48px 34px 47px; border: 1px solid #e5ddd3; background: var(--reader-leaf) !important; color: var(--reader-leaf-ink) !important; font-family: var(--font-prose); font-size: var(--reader-book-font-size, 18px) !important; line-height: 1.72; overflow-wrap: anywhere; }
.reader-book-leaf::before { content: 'READMADE  /  READING ROOM'; position: absolute; top: 18px; left: 34px; right: 34px; padding-bottom: 8px; border-bottom: 1px solid var(--reader-leaf-line); color: #887969; font: 700 9px/1.2 "Noto Sans KR", sans-serif; letter-spacing: .17em; }
.reader-book-leaf-body { width: 100%; height: 100%; overflow: visible; color: inherit; font-family: var(--reader-book-font-family, var(--font-prose)); font-size: var(--reader-book-font-size, 18px); line-height: var(--reader-book-line-height, 1.9); overflow-wrap: anywhere; }
.reader-book-leaf-body * { font-family: var(--reader-book-font-family, var(--font-prose)) !important; }
.reader-book-leaf-body :is(p, h1, h2, h3, h4, h5, h6, blockquote, li, pre, figcaption) { line-height: var(--reader-book-line-height, 1.9) !important; }
.reader-book-leaf h2 { margin: 0 0 .95em; font-size: 1.36em; letter-spacing: -.035em; }
.reader-book-leaf p { margin: 0 0 1.08em; white-space: pre-wrap; }
.reader-book-leaf h1, .reader-book-leaf h3, .reader-book-leaf h4, .reader-book-leaf h5, .reader-book-leaf h6 { margin: 0 0 .95em; }
.reader-book-leaf table { max-width: 100%; border-collapse: collapse; }
.reader-book-leaf th, .reader-book-leaf td { border: 1px solid #c8c0b5; padding: 6px 8px; overflow-wrap: anywhere; }
.reader-book-leaf .table-cell-paragraph { min-height: 1lh; margin: 0; }
.reader-book-leaf [data-rm-min-line-height] span, .reader-book-leaf [data-rm-min-line-height] strong, .reader-book-leaf [data-rm-min-line-height] em { line-height: normal !important; }
.reader-book-asset { max-width: 100%; margin: 0 0 1em; overflow-x: auto; }
.reader-book-asset--overflow { max-height: calc(100% - 4px); overflow: auto; overscroll-behavior: contain; }
.reader-book-leaf img { display: block; max-width: 100%; height: auto; object-fit: contain; }
.reader-book-leaf figure { max-width: 100%; margin: 0 0 1em; }
.reader-book-leaf figcaption { font-size: .85em; }
.reader-book-image { max-width: 100%; margin: 0 0 1em; }
.reader-book-leaf .reader-book-kicker { margin: 0 0 .8em; color: #765ab2; font-size: .68em; font-weight: 800; letter-spacing: .1em; }
.reader-book-figure { display: flex; justify-content: center; align-items: center; height: min(42%, 220px); margin: 0 0 1em; }
.reader-book-figure img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.reader-book-folio { position: absolute; left: 34px; right: 34px; bottom: 17px; padding-top: 8px; border-top: 1px solid var(--reader-leaf-line); color: #887969; font: 700 10px/1 "Noto Sans KR", sans-serif; letter-spacing: .15em; text-align: center; }
.reader-book-leaf--magazine { background: #fffaf2 !important; }
.reader-book-leaf--magazine::before { color: #805a5c; border-color: #dcc9bc; }
.reader-book-leaf--magazine .reader-book-folio { border-color: #dcc9bc; }
.reader-book-leaf--cover { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 44px 28px 36px; background: linear-gradient(145deg, #faf3e8, #fffefa 66%) !important; text-align: center; }
.reader-book-leaf--cover::before { content: 'READMADE  /  THE COLLECTION'; }
.reader-book-leaf--cover .reader-book-leaf-body, .reader-book-leaf--end .reader-book-leaf-body { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.reader-book-leaf--cover .reader-book-figure { width: 100%; height: 57%; margin: 0 0 1.2em; }
.reader-book-leaf--cover .reader-book-figure img { width: 100%; height: 100%; object-fit: contain; }
.reader-book-leaf--cover h2 { margin: 0 0 .18em; font-size: 1.3em; }
.reader-book-leaf--cover p { margin: .15em 0; font-size: .8em; }
.reader-book-leaf--end { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; background: #f3eadf !important; text-align: center; }
.reader-book-leaf--end strong { color: #554372; font-size: 1.2em; font-weight: 900; }
.reader-book-leaf--end p { color: #705d68; font-size: .83em; }

.reader-stage[data-reader-paper="night"] { --reader-leaf: #1c1a17; --reader-leaf-ink: #f3efe6; --reader-leaf-line: #514a40; }
.reader-stage[data-reader-paper="night"] .reader-book-leaf--magazine { background: #25201f !important; }
.reader-stage[data-reader-paper="night"] .reader-book-leaf--cover { background: linear-gradient(145deg, #29231d, #1c1a17 66%) !important; }
.reader-stage[data-reader-paper="night"] .reader-book-leaf--end { background: #28211e !important; }
.reader-stage[data-reader-paper="night"] .reader-book-leaf th,
.reader-stage[data-reader-paper="night"] .reader-book-leaf td { border-color: #655e53; }
.reader-stage[data-reader-paper="night"] .reader-book-leaf a { color: #c6aeff; }
.reader-stage[data-reader-paper="night"]:has(.reader-flip-book) { background: radial-gradient(ellipse at 50% 28%, #343039 0%, #242129 62%, #17151a 100%); }

.reader-stage.is-sample-scroll { display: block; overflow: auto; padding: clamp(20px, 5vw, 60px); background: var(--paper); }
.reader-prose { max-width: 66ch; margin-inline: auto; color: #26222b; background: #fffdf8; font-family: var(--font-prose); font-size: 18px; line-height: 1.9; word-break: keep-all; line-break: strict; overflow-wrap: break-word; }
.reader-prose h2 { margin: 0 0 1.5em; font-family: inherit; line-height: 1.4; }
.reader-prose p { margin: 0 0 1.2em; text-indent: 1em; }
.reader-prose-meta { font-size: .78em; line-height: 1.45; text-indent: 0 !important; }
.reader-prose[data-reader-paper="night"] { background: #1c1a17; color: #f3efe6; }

.reader-settings-dialog { width: min(430px, calc(100vw - 24px)); max-width: min(430px, calc(100vw - 24px)); max-height: min(680px, calc(100dvh - 24px)); padding: 20px; overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px #15121c40; }
.reader-settings-dialog::backdrop { background: #17131d91; backdrop-filter: blur(3px); }
.reader-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.reader-settings-head h2 { margin: 0; font-size: 20px; }
.reader-settings-grid { display: grid; gap: 14px; }
.reader-setting-range, .reader-setting-select, .reader-setting-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 40px; color: var(--muted); font-size: 14px; }
.reader-setting-range input { width: 100%; accent-color: var(--accent); }
.reader-setting-range output { min-width: 38px; color: var(--ink); font-weight: 750; text-align: right; }
.reader-setting-select select { grid-column: 2 / -1; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.reader-setting-row > :last-child { grid-column: 2 / -1; justify-self: start; }
.reader-face-toggle { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.reader-face-toggle button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.reader-face-toggle button[data-reader-face="serif"] { font-family: var(--font-prose); }
.reader-face-toggle button[data-reader-face="sans"] { font-family: "Noto Sans KR", system-ui, sans-serif; }
.reader-face-toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.reader-paper-chip, .reader-sound { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 700; }
.reader-paper-chip[aria-pressed="true"] { border-color: #554d6a; background: #201d2a; color: #ede8f5; }
.reader-sound { display: inline-flex; align-items: center; gap: 8px; }
.reader-sound [data-sound-icon] { color: var(--accent); }
.reader-file-picker { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-top: 4px; }
.reader-file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.reader-file-picker:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.reader-showcase { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.reader-showcase button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; }
.reader-showcase button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.reader-showcase img { width: 38px; height: 52px; flex: 0 0 auto; border-radius: 4px; object-fit: cover; }
.reader-showcase button span { display: grid; gap: 2px; min-width: 0; }
.reader-showcase small { color: var(--accent); font-size: 10px; font-weight: 850; }
.reader-showcase strong, .reader-showcase em { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.reader-showcase em { color: var(--muted); font-style: normal; }

@media (max-width: 600px) {
  .reader-toolbar { min-height: 46px; gap: 2px; padding: 4px 5px; }
  .reader-title { flex: 1 1 50px; min-width: 20px; font-size: 12px; }
  .reader-toc { flex: 0 1 92px; min-width: 28px; height: 30px; max-width: 28vw; padding: 0 4px; font-size: 11px; }
  .reader-page-tools { gap: 1px; }
  .reader-icon-button { width: 28px; height: 30px; border-radius: 7px; font-size: 15px; }
  .reader-page-tools .reader-icon-button { width: 26px; height: 30px; }
  .reader-progress { width: 40px; min-width: 34px; max-width: 44px; font-size: 10px; }
  .reader-progress-track { display: none; }
  .reader-close { font-size: 21px; }
  .reader-main { padding: 5px; }
  .reader-stage { border-radius: 9px; }
  .reader-book-leaf { padding: 43px 27px 42px; }
  .reader-book-leaf::before { left: 27px; right: 27px; }
  .reader-book-folio { left: 27px; right: 27px; }
  .reader-settings-dialog { padding: 17px; }
  .reader-showcase { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root { --paper: #211f26; --canvas: #15131a; --ink: #f0edf2; --muted: #b9b3be; --line: #46414d; --accent: #bb9aff; --surface: #28252e; }
  .reader-notice.is-error { background: #3e2229; color: #ffb1b8; }
  .reader-flip-book { filter: drop-shadow(0 12px 15px #08070b9c); }
}

@media (prefers-reduced-motion: reduce) { .reader-progress-track span { transition: none; } }

.reader-book-leaf--cover .reader-book-image { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; margin: 0; }
.reader-book-leaf--cover .reader-book-image figure { width: 100%; height: 100%; margin: 0; }
.reader-book-leaf--cover .reader-book-image img { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
