:root {
  color-scheme: light;
  --ink: #24332e;
  --muted: #71807a;
  --paper: #fffdf8;
  --surface: #f5f2eb;
  --line: #dfe5dc;
  --brand: #a54c38;
  --deep: #243d36;
  --accent: #edc95c;
  font-family: "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #e9eee8; color: var(--ink); }
body { min-width: 320px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, #book-stage:focus-visible { outline: 3px solid #3c7461; outline-offset: 2px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem clamp(1rem, 4vw, 3rem); background: rgba(255, 253, 248, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand-block, .toolbar-status, .navigation, .record-actions { display: flex; align-items: center; }
.brand-block { gap: .7rem; }
.brand-mark { display: grid; place-items: center; width: 1.55rem; height: 1.55rem; color: var(--brand); font-size: 1.8rem; line-height: 1; }
.brand-block h1 { margin: 0; color: var(--deep); font-size: clamp(1rem, 2vw, 1.25rem); letter-spacing: -.04em; }
.brand-subtitle { color: var(--muted); font-size: .78rem; }
.toolbar-status { gap: .5rem; color: var(--muted); font-size: .86rem; }
.toolbar-button, .control-button, .nav-button, .close-button, .notice-card button { border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); padding: .52rem .8rem; transition: background .15s ease, color .15s ease, transform .15s ease; }
.toolbar-button:hover, .control-button:hover, .nav-button:hover, .close-button:hover, .notice-card button:hover { background: var(--deep); color: white; }
.toolbar-button:active, .control-button:active, .nav-button:active { transform: translateY(1px); }
.reader-main { width: min(1280px, 100%); margin: 0 auto; padding: 1.5rem clamp(.8rem, 4vw, 3rem) 3rem; }
.book-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 65vh; padding: clamp(.7rem, 2vw, 1.25rem); border: 1px solid rgba(171, 184, 169, .4); border-radius: 1.2rem; background: radial-gradient(circle at 50% 10%, #fffaf0 0, #f5f0e5 42%, #dce6dd 100%); box-shadow: 0 1.2rem 3rem rgba(32, 58, 45, .12); overflow: auto; perspective: 1800px; }
.book-flip { --book-scale: 1; width: 100%; min-height: min(78vh, 740px); transform: scale(var(--book-scale)); transform-origin: center top; transition: transform .2s ease; }
#book-stage.single-view .book-flip { width: min(100%, 34rem); max-width: 34rem !important; }
.flip-page { display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--paper); color: var(--muted); box-shadow: inset 0 0 0 1px rgba(90, 73, 55, .08); }
.flip-page canvas { display: block; width: 100%; height: 100%; background: var(--paper); }
.page-placeholder { padding: 1rem; color: var(--muted); font-size: .82rem; text-align: center; }
.stf__parent { margin: 0 auto; box-shadow: 0 1rem 2.4rem rgba(32, 58, 45, .22); }
.navigation { flex-wrap: wrap; justify-content: center; gap: .5rem; padding: 1rem 0 0; }
.nav-button { width: 2.3rem; height: 2.3rem; padding: 0; font-size: 1.5rem; line-height: 1; }
.page-entry { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
#page-input { width: 3.4rem; padding: .46rem .4rem; border: 1px solid var(--line); border-radius: .55rem; text-align: center; color: var(--ink); background: var(--paper); }
#page-slider { width: min(28rem, 38vw); accent-color: var(--brand); }
.control-button { padding: .46rem .7rem; font-size: .85rem; }
.notice-card { width: min(38rem, calc(100% - 2rem)); margin: 1.25rem auto 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--paper); text-align: center; color: var(--muted); }
.error-card { color: #7a3328; }
.error-card p { margin: .45rem 0 .9rem; }
.error-card a { display: inline-block; margin-left: .5rem; color: var(--brand); }
.record-panel { position: fixed; top: 0; right: 0; z-index: 20; display: flex; flex-direction: column; width: min(28rem, 92vw); height: 100vh; padding: 1.5rem; background: var(--paper); box-shadow: -1rem 0 3rem rgba(31, 52, 42, .2); overflow-y: auto; }
.record-panel[hidden] { display: none; }
.record-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.record-panel h2 { margin: .2rem 0 0; color: var(--deep); font-size: 1.7rem; }
.eyebrow { margin: 0; color: var(--brand); font-size: .76rem; font-weight: 700; letter-spacing: .08em; }
.close-button { width: 2.2rem; height: 2.2rem; padding: 0; font-size: 1.4rem; }
.record-help { color: var(--muted); font-size: .88rem; line-height: 1.6; }
.record-label { margin-top: 1rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
#record-text { width: 100%; min-height: 12rem; margin-top: .5rem; resize: vertical; padding: .8rem; border: 1px solid var(--line); border-radius: .7rem; background: #fffefb; color: var(--ink); line-height: 1.7; }
.save-status { min-height: 1.4rem; margin-top: .4rem; color: #4e745f; font-size: .78rem; }
.record-actions { flex-wrap: wrap; gap: .45rem; margin-top: .35rem; }
.quiet { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 1.4rem; z-index: 30; transform: translateX(-50%); padding: .7rem 1rem; border-radius: 999px; background: var(--deep); color: white; box-shadow: 0 .5rem 1.2rem rgba(0, 0, 0, .18); }
.toast[hidden] { display: none; }
.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 { align-items: flex-start; padding: .75rem; }
  .brand-subtitle { display: none; }
  .toolbar-status { gap: .3rem; font-size: .75rem; }
  .toolbar-button { padding: .42rem .55rem; font-size: .78rem; }
  .reader-main { padding: .7rem .55rem 2rem; }
  .book-stage { min-height: 58vh; padding: .45rem; border-radius: .8rem; }
  .book-flip { min-height: calc(100vh - 210px); }
  #page-slider { order: 5; flex-basis: 100%; width: 100%; }
  .navigation { gap: .35rem; }
  .control-button { padding: .42rem .55rem; font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
