:root {
  color-scheme: light;
  --ink: #1f3152;
  --muted: #4b5c76;
  --paper: #fff7e6;
  --surface: #fffdf8;
  --navy: #243b67;
  --navy-deep: #182947;
  --gold: #f1b94a;
  --gold-pale: #ffedbd;
  --forest: #3f7656;
  --line: #b8aa8e;
  --focus: #4523c6;
  --danger: #812d2d;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--paper); }
body { min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--ink); background: radial-gradient(ellipse at 75% 0%, #f8dfa2 0, transparent 37rem), var(--paper); }
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.skip-link { position: fixed; z-index: 20; top: .75rem; left: .75rem; padding: .8rem 1rem; transform: translateY(-180%); background: #fff; border: 3px solid var(--focus); border-radius: .75rem; }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.topbar { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem clamp(1rem,4vw,2rem); background: var(--navy); color: #fff; }
.brand { display: inline-flex; align-items: center; gap: .75rem; min-height: 56px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--gold); color: var(--navy-deep); font-size: 1.7rem; }
.brand-mark svg { display: block; width: 31px; height: 31px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.1rem; }
.brand small { margin-top: .12rem; color: #f8dfa2; font-size: .875rem; }
.parent-entry { min-width: 72px; min-height: 52px; padding: .5rem .9rem; color: #fff; background: transparent; border: 2px solid #c9d5ea; border-radius: 999px; cursor: pointer; }
main { width: min(100% - 2rem, 1100px); min-height: calc(100dvh - 145px); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem) 0 2.5rem; }
.eyebrow { margin: 0 0 .5rem; color: var(--forest); font-size: .95rem; font-weight: 750; letter-spacing: .03em; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 22ch; margin-bottom: .8rem; font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.25; }
h3 { font-size: 1.25rem; }
.library { max-width: 1120px; margin: .25rem auto; }
.library-header { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin: .4rem 0 1.5rem; }
.library-header h1 { max-width: 18ch; margin-bottom: .6rem; }
.library-intro { max-width: 54ch; margin-bottom: 0; color: var(--muted); font-size: 1.12rem; line-height: 1.6; }
.library-count { flex: 0 0 auto; display: grid; place-content: center; min-width: 106px; min-height: 106px; padding: .75rem; border: 4px solid #fff; border-radius: 1.6rem; color: #fff; background: var(--navy); text-align: center; box-shadow: 0 8px 20px #243b6724; }
.library-count strong { font-size: 2.15rem; line-height: 1; }
.library-count span { margin-top: .35rem; font-size: .78rem; }
.library-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem 1rem; margin: 1.25rem 0; padding: 1rem; border: 1px solid #d3c7ad; border-radius: 1.25rem; background: #fffaf0; }
.library-filters > label:not(.favorite-filter) { display: grid; gap: .35rem; min-width: 150px; color: var(--muted); font-weight: 700; }
.library-filters select { min-height: 50px; padding: .6rem 2.4rem .6rem .8rem; border: 2px solid #a99b7e; border-radius: .75rem; color: var(--ink); background: #fff; font: inherit; font-weight: 650; }
.favorite-filter { display: inline-flex; align-items: center; gap: .6rem; min-height: 50px; padding: 0 .5rem; color: var(--ink); font-weight: 700; cursor: pointer; }
.favorite-filter input { width: 24px; height: 24px; accent-color: var(--navy); }
.book-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; gap: 1.25rem; }
.book-card { min-width: 0; overflow: hidden; border: 1px solid #d4c8af; border-radius: 1.5rem; background: var(--surface); box-shadow: 0 12px 32px #243b6714; }
.book-art { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; margin: 0; overflow: hidden; background: linear-gradient(155deg,#94bfdb,#deefe2 58%,#f4ca6d); }
.book-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.book-cover-fallback { position: absolute; inset: 0; display: grid; place-content: center; padding: 1.5rem; color: var(--muted); text-align: center; }
.book-cover-fallback span { font-size: 3rem; }
.book-cover-fallback p { max-width: 26ch; margin: .3rem auto 0; font-weight: 700; line-height: 1.5; }
.book-copy { display: flex; flex-direction: column; align-items: flex-start; padding: 1.15rem 1.25rem 1.35rem; }
.book-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.book-tags .pill { min-height: 36px; margin: 0; }
.book-card h2 { margin: 0 0 .55rem; font-size: clamp(1.45rem,2.5vw,1.9rem); }
.book-description { min-height: 3.2em; margin-bottom: .7rem; color: var(--muted); font-size: 1.05rem; line-height: 1.55; }
.book-meta, .book-progress-copy { margin: 0 0 .5rem; color: var(--muted); font-size: .95rem; line-height: 1.45; }
.book-progress-copy { color: var(--forest); font-weight: 700; }
.ending-progress { display: block; width: 100%; height: .7rem; margin: .1rem 0 .9rem; accent-color: var(--forest); }
.book-actions { display: flex; flex-wrap: wrap; gap: .65rem; width: 100%; margin-top: auto; }
.book-actions .button { min-height: 50px; }
.book-actions .primary { flex: 1 1 11rem; }
.book-actions .secondary { flex: 1 1 10rem; }
.favorite-toggle[aria-pressed="true"] { border-color: var(--navy); background: #edf2fb; }
.empty-library { grid-column: 1 / -1; padding: 2rem; border: 2px dashed var(--line); border-radius: 1.25rem; background: #fffdf8; text-align: center; font-size: 1.1rem; line-height: 1.6; }
.library-review-note { margin-top: 1.4rem; }
.story-meta { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 1.4rem; }
.pill { display: inline-flex; align-items: center; min-height: 40px; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fffaf0; font-size: .9rem; font-weight: 650; }
.review-note { padding: .85rem 1rem; border-left: 5px solid #a97712; background: #fff0c4; color: #432f0b; font-size: .95rem; line-height: 1.5; }
.button-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: .75rem; margin-top: 1.25rem; }
.button { display: inline-flex; justify-content: center; align-items: center; min-width: 56px; min-height: 56px; padding: .8rem 1.15rem; border: 2px solid transparent; border-radius: 1rem; font-weight: 750; line-height: 1.3; text-align: center; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.button:disabled { opacity: .62; cursor: not-allowed; }
.primary { background: var(--navy); color: #fff; box-shadow: 0 5px 0 var(--navy-deep); }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 3px 0 var(--navy-deep); }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.danger { background: #fff; color: var(--danger); border-color: #a85656; }
.choice-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; margin-top: 1.5rem; }
.choice-card { width: 100%; min-height: 112px; padding: 1.1rem; border: 3px solid #897548; border-radius: 1.25rem; background: #fffdf8; box-shadow: 0 6px 0 #d5c08c; font-size: clamp(1.15rem, 3vw, 1.4rem); font-weight: 720; text-align: left; cursor: pointer; }
.choice-card::before { content: "골라 보기"; display: block; margin-bottom: .5rem; color: var(--forest); font-size: .82rem; font-weight: 750; }
.choice-card:hover { background: #fff4d6; }
.reader { max-width: 1020px; margin: .25rem auto; }
.reader-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.reader-toolbar .button { min-height: 48px; }
.scene-progress { flex: 1; color: var(--muted); font-weight: 700; text-align: center; }
.path-map { margin: 0 0 1rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 1rem; background: #fffaf0; }
.path-map summary { min-height: 44px; display: flex; align-items: center; color: var(--navy); font-weight: 750; cursor: pointer; }
.path-map ol { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding-left: 1.4rem; margin-bottom: .3rem; line-height: 1.5; }
.path-map li { padding-left: .15rem; }
.path-map li span { color: var(--forest); font-weight: 700; }
.reader-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(17rem,.92fr); align-items: start; gap: clamp(1rem,3vw,2rem); }
.scene-illustration { min-height: 260px; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 1.5rem; background: linear-gradient(155deg,#94bfdb,#deefe2 58%,#f4ca6d); box-shadow: inset 0 0 0 5px #fffdf8, 0 10px 30px #243b6717; }
.scene-illustration img { display:block; width:100%; height:100%; object-fit:cover; }
.scene-illustration.is-fallback { display:grid; place-items:center; padding:1.5rem; text-align:center; }
.scene-illustration-fallback { max-width:30ch; margin:0; color:var(--muted); font-weight:700; line-height:1.6; }
.scene-copy { padding: .3rem .25rem 1rem; }
.scene-text { font-size: clamp(1.45rem, 3vw, 1.8rem); line-height: 1.7; letter-spacing: .005em; white-space: pre-line; }
.font-scale-115 { font-size: clamp(1.67rem, 3.45vw, 2.07rem); }
.font-scale-125 { font-size: clamp(1.8rem, 3.75vw, 2.25rem); }
.scene-title { margin-bottom: .8rem; color: var(--forest); font-size: 1rem; }
.reader-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
.reader-actions .button { flex: 1 1 150px; }
.font-controls { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; margin: .9rem 0; }
.font-controls > span { margin-right:.25rem; color:var(--muted); font-weight:700; }
.font-controls .button { min-height:48px; }
.quiet { color: var(--muted); line-height: 1.55; }
.ending-card { max-width: 850px; margin: 1rem auto; padding: clamp(1.25rem,4vw,2.5rem); border: 5px solid #fffdf8; border-radius: 2rem; background: linear-gradient(145deg,#fffdf8,#fff1c9); box-shadow: 0 18px 45px #243b671f; }
.ending-stamp { display: inline-block; margin-bottom: 1rem; padding: .35rem .8rem; border-radius: 999px; background: var(--gold-pale); font-weight: 750; }
.ending-illustration { width: min(100%, 620px); aspect-ratio: 4 / 3; margin: 0 auto 1.25rem; overflow: hidden; border: 4px solid #fff; border-radius: 1.5rem; background: linear-gradient(155deg,#94bfdb,#deefe2 58%,#f4ca6d); box-shadow: 0 10px 30px #243b6717; }
.ending-illustration img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ending-illustration.is-fallback { display: grid; place-items: center; padding: 1.5rem; text-align: center; }
.ending-illustration-fallback { max-width: 30ch; margin: 0; color: var(--muted); font-weight: 700; line-height: 1.6; }
.ending-copy { max-width: 42ch; font-size: clamp(1.35rem,3vw,1.7rem); line-height: 1.7; }
.ending-actions > .button { flex: 1 1 14rem; box-shadow: 0 4px 0 #d8cdb8; }
.parent-prompt { margin: 1.2rem 0; padding: 1rem; border-radius: 1rem; background: #e5efe2; font-weight: 700; }
.stage-tag { display: inline-flex; align-items:center; gap:.45rem; color: #643f00; font-size: .9rem; font-weight: 700; }
.stage-tag::before { content:""; width: .65rem; height:.65rem; border-radius:50%; background:#a97712; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding: 1rem clamp(1rem,4vw,2rem); color: var(--muted); background: #f2e7d1; font-size: .875rem; }
dialog { width: min(calc(100% - 1.5rem), 560px); max-height: min(90dvh, 740px); padding: 0; border: 3px solid var(--navy); border-radius: 1.5rem; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px #10213d55; }
dialog::backdrop { background: #162744aa; }
.dialog-content { padding: clamp(1.25rem,4vw,2rem); }
.dialog-content p { font-size: 1.05rem; line-height: 1.6; }
.gate-button { width: 100%; user-select: none; -webkit-user-select: none; }
.gate-form label, #delete-confirm label { display: block; margin: 1rem 0 .45rem; font-weight: 700; line-height: 1.5; }
.gate-form input, #delete-phrase { min-width: 5rem; min-height: 56px; padding: .7rem .85rem; border: 2px solid var(--line); border-radius: .75rem; background: #fff; font: inherit; font-size: 1.1rem; }
.gate-form input { width: 8rem; }
#delete-phrase { width: 100%; }
.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; }
.noscript { margin: 1rem; padding: 1rem; border: 2px solid var(--danger); background: #fff; }
[hidden] { display:none !important; }
@media (max-width: 720px) {
  main { width: min(100% - 1.25rem, 640px); padding-top: 1rem; }
  .library-header { align-items: flex-start; gap: .75rem; }
  .library-header h1 { font-size: clamp(1.85rem,7vw,2.65rem); }
  .library-count { min-width: 82px; min-height: 82px; padding: .5rem; border-radius: 1.2rem; }
  .library-count strong { font-size: 1.7rem; }
  .library-count span { max-width: 8ch; font-size: .72rem; }
  .library-filters { align-items: stretch; }
  .library-filters > label:not(.favorite-filter) { flex: 1 1 9rem; }
  .favorite-filter { flex: 1 1 100%; }
  .book-grid, .reader-grid { grid-template-columns: 1fr; }
  .book-grid { gap: 1rem; }
  .book-card { max-width: 640px; }
  .book-copy { padding: 1rem; }
  .book-description { min-height: 0; }
  .choice-list { grid-template-columns: 1fr; }
  .choice-card { min-height: 88px; }
  .scene-illustration { max-height: 45dvh; }
  .reader-toolbar .button { padding-inline: .8rem; }
}
@media (max-width: 390px) {
  .topbar { padding-inline: .7rem; }
  .brand-mark { width: 44px; height: 44px; }
  .library-header { gap: .4rem; }
  .library-count { min-width: 68px; min-height: 68px; border-width: 3px; }
  .library-count strong { font-size: 1.45rem; }
  .library-count span { font-size: .65rem; }
  .reader-toolbar { gap: .35rem; }
  .reader-toolbar .button { min-width: 48px; font-size: .95rem; }
  .scene-progress { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
