:root {
  --navy: #102a43;
  --navy-deep: #071a2d;
  --orange: #ef8d32;
  --gold: #f5c85b;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --ink: #24313c;
  --muted: #6f746f;
  --line: #ead9b7;
  --green: #46745c;
  --shadow: 0 18px 52px rgba(20, 34, 44, .16);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #f5efe2; color: var(--ink); }
body { font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif; }
button { font: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100svh; }
.home {
  min-height: 100svh;
  background: linear-gradient(180deg, #102a43 0 26rem, #f5efe2 26rem);
  padding-bottom: 48px;
}
.home-hero {
  position: relative;
  min-height: 23rem;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background: var(--navy-deep) url("assets/october-cover.webp") center 48% / cover no-repeat;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(4, 19, 37, .1), rgba(4, 19, 37, .22) 40%, rgba(4, 19, 37, .9));
}
.home-hero-inner { width: min(100%, 1020px); margin: 0 auto; padding: 46px 24px 38px; }
.brand-line { margin: 0 0 12px; color: #ffe59b; font-size: 15px; font-weight: 800; letter-spacing: .13em; }
.home h1 { margin: 0; font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: clamp(42px, 8vw, 72px); line-height: 1.08; letter-spacing: -.035em; }
.home-subtitle { margin: 16px 0 0; font-size: clamp(17px, 2.4vw, 22px); font-weight: 650; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.hero-meta span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: rgba(4,19,37,.35); font-size: 14px; font-weight: 700; backdrop-filter: blur(8px); }

.month-panel { width: min(calc(100% - 28px), 1020px); margin: -28px auto 0; position: relative; z-index: 2; padding: 24px; border: 1px solid rgba(223, 204, 164, .8); border-radius: 26px; background: rgba(255, 253, 248, .98); box-shadow: var(--shadow); }
.month-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.month-head h2 { margin: 4px 0 0; font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: clamp(28px, 4vw, 38px); }
.progress-copy { color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }
.progress-track { width: 130px; height: 8px; overflow: hidden; margin-top: 8px; border-radius: 99px; background: #eee4d0; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), var(--gold)); transition: width .3s ease; }

.weeks { display: grid; gap: 22px; }
.week-block { border-top: 1px solid var(--line); padding-top: 18px; }
.week-block:first-child { border-top: 0; padding-top: 0; }
.week-title-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.week-number { color: var(--orange); font-size: 13px; font-weight: 900; letter-spacing: .09em; }
.week-title { margin: 0; font-size: 20px; }
.week-work { color: var(--muted); font-size: 14px; }
.day-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.day-card {
  position: relative;
  min-height: 132px;
  padding: 15px 12px 13px;
  text-align: left;
  color: var(--ink);
  border: 1px solid #eadcc1;
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.day-card:hover { transform: translateY(-3px); border-color: #e5bc67; box-shadow: 0 12px 24px rgba(83, 58, 21, .12); }
.day-card:focus-visible { outline: 3px solid #f1bd52; outline-offset: 2px; }
.day-card.done { background: linear-gradient(145deg, #fff, #fff8df); border-color: #e6be63; }
.day-card.done::after { content: "✓"; position: absolute; top: 11px; right: 11px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; color: #fff; background: var(--green); font-size: 13px; font-weight: 900; }
.day-no { display: block; margin-bottom: 14px; color: var(--orange); font-size: 13px; font-weight: 900; letter-spacing: .05em; }
.day-title { display: block; font-size: 16px; font-weight: 850; line-height: 1.35; word-break: keep-all; }
.day-focus { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.4; word-break: keep-all; }
.home-note { width: min(calc(100% - 32px), 960px); margin: 22px auto 0; color: #706d64; font-size: 13px; line-height: 1.7; }
.home-note + .home-note { margin-top: 8px; }
.source-note { color: #858078; }
.home-note a { color: #76511f; }

.reader {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: radial-gradient(circle at 85% 12%, rgba(255,255,255,.7), transparent 22%), linear-gradient(145deg, #efe8d9, #f8f3e9);
  overflow: hidden;
}
.reader-top {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 8px;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  color: #fff;
  background: var(--navy-deep);
}
.back-button, .reader-menu { width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: #fff; background: rgba(255,255,255,.1); cursor: pointer; font-size: 24px; }
.reader-menu { font-size: 18px; }
.reader-title { min-width: 0; text-align: center; }
.reader-title strong { display: block; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.reader-title span { display: block; margin-top: 3px; color: #f9d983; font-size: 12px; font-weight: 700; }

.page-viewport { display: grid; place-items: center; min-height: 0; padding: 18px 16px; overflow: hidden; }
.book-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 1260px);
  height: min(78svh, 820px);
  min-height: 520px;
}
.book-stage::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -8px;
  height: 30px;
  z-index: 0;
  border-radius: 50%;
  background: rgba(31, 36, 41, .2);
  filter: blur(20px);
}
.flip-book { position: relative; z-index: 1; width: 100%; height: 100%; }
.flip-page {
  position: relative;
  overflow: hidden;
  border: 1px solid #e0d2b7;
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 0 28px rgba(84, 68, 39, .035);
}
.flip-page::before { content: ""; position: absolute; inset: 0; z-index: 8; pointer-events: none; box-shadow: inset 14px 0 22px rgba(84,68,39,.035), inset -10px 0 18px rgba(84,68,39,.025); }
.flip-page[data-density="hard"] { background: #f5ead0; }
.flip-book.flip-fallback { width: min(100%, 700px); }
.flip-book.flip-fallback .flip-page { width: 100%; height: 100%; border-radius: 7px 22px 22px 7px; box-shadow: 0 26px 55px rgba(29, 34, 40, .2); animation: pageIn .22s ease both; }
.stf__parent { margin: auto; }
.stf__wrapper { filter: drop-shadow(0 22px 24px rgba(29, 34, 40, .16)); }
.stf__item { background: var(--paper); }

.page { position: absolute; inset: 0; display: grid; animation: pageIn .22s ease both; }
@keyframes pageIn { from { opacity: .78; } to { opacity: 1; } }
.page-inner { align-self: center; width: min(100%, 600px); max-height: 100%; margin: auto; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 46px 42px 58px; }
.page-inner.top { align-self: start; }
.mini-label { margin: 0; color: #a66328; font-size: 14px; font-weight: 900; letter-spacing: .11em; }
.page h1, .page h2 { font-family: "Nanum Myeongjo", "AppleMyungjo", serif; word-break: keep-all; }
.page h1 { margin: 12px 0 16px; font-size: clamp(38px, 8vw, 58px); line-height: 1.14; }
.page h2 { margin: 10px 0 20px; font-size: clamp(31px, 6vw, 44px); line-height: 1.22; }
.lead { margin: 0; font-size: clamp(18px, 3.4vw, 23px); line-height: 1.75; word-break: keep-all; }
.helper { margin: 18px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; word-break: keep-all; }
.task-card { padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.88); box-shadow: 0 10px 30px rgba(116,82,30,.08); }
.task-card + .task-card { margin-top: 14px; }
.task-card strong { color: var(--navy); }
.task-card p { margin: 0; font-size: 18px; line-height: 1.7; word-break: keep-all; }
.prompt { color: var(--navy); font-size: clamp(22px, 4.4vw, 31px) !important; font-weight: 800; line-height: 1.55 !important; }
.think-question { margin-top: 16px !important; padding-top: 16px; border-top: 1px solid var(--line); color: var(--navy); font-size: clamp(20px, 3.5vw, 25px) !important; font-weight: 850; }
.answer-box { margin-top: 14px; padding: 16px 18px; border: 1px solid #e5c76f; border-radius: 16px; background: #fff8d9; }
.answer-box[hidden] { display: none; }
.answer-box strong { display: block; margin-bottom: 7px; color: #9a5a1f; font-size: 15px; }
.answer-box p { color: #4b412f; font-size: 17px; line-height: 1.65; }
.info-card { border-left: 5px solid var(--gold); }
.genre-meta, .compare-intro { margin: -8px 0 18px; color: var(--muted); font-size: 15px; line-height: 1.65; word-break: keep-all; }
.genre-card { border-left: 5px solid var(--orange); }
.genre-card p { white-space: normal; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 9px 24px rgba(80,59,28,.08); }
.compare-card:first-child { border-top: 5px solid var(--orange); }
.compare-card:last-child { border-top: 5px solid var(--green); }
.compare-card h3 { margin: 0 0 12px; color: var(--navy); font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: 24px; }
.compare-card ul { margin: 0; padding-left: 20px; }
.compare-card li { margin: 8px 0; font-size: 16px; line-height: 1.55; word-break: keep-all; }
.compare-example { margin-top: 16px; }
.compare-example[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { padding: 7px 11px; border-radius: 999px; color: #654820; background: #fff0bd; font-size: 14px; font-weight: 800; }

.image-page { color: #fff; background-position: center; background-size: cover; }
.image-page::after { content: ""; position: absolute; inset: 32% 0 0; background: linear-gradient(transparent, rgba(4,19,37,.92)); }
.image-page .page-inner { position: relative; z-index: 1; align-self: end; width: 100%; padding-bottom: 58px; text-align: center; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.image-page h1 { color: #fff7d5; }
.poem-lines { margin: 0; font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: clamp(24px, 5.1vw, 38px); line-height: 1.72; }
.author { margin-top: 12px; font-size: 16px; font-weight: 750; }
.story-copy { padding: 22px; border-radius: 18px; color: #fff; background: rgba(3,19,36,.68); font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: clamp(20px, 3.5vw, 27px); line-height: 1.75; text-align: left; text-shadow: none; backdrop-filter: blur(4px); }

.audio-button, .pill { min-height: 44px; padding: 9px 16px; border: 1px solid #d9bd7e; border-radius: 999px; color: #604720; background: #fff; font-weight: 800; cursor: pointer; }
.audio-button { margin-top: 18px; color: #fff; border-color: rgba(255,255,255,.48); background: rgba(6,27,49,.72); }
.audio-button[hidden] { display: none; }
.pill.primary { color: #fff; border-color: var(--orange); background: var(--orange); }
.pill:disabled { cursor: default; opacity: .72; }

.hanja-card { display: grid; grid-template-columns: minmax(130px, .7fr) 1fr; gap: 26px; align-items: center; }
.hanja-glyph { display: grid; place-items: center; min-height: 210px; border: 2px solid #e5ca8c; border-radius: 18px; color: #111; background: #fff; font-family: "Kaiti SC", "STKaiti", "KaiTi", "YuKyokasho", "AppleMyungjo", serif; font-size: clamp(110px, 22vw, 170px); line-height: 1; }
.hanja-info h2 { margin: 0 0 12px; }
.hanja-info p { margin: 0; font-size: 18px; line-height: 1.65; }
.hanja-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.hanja-vocab-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.hanja-vocab-inline .vocab-card { padding: 15px 17px; }
.hanja-vocab-inline .vocab-card h3 { margin-top: 4px; font-size: 23px; }
.hanja-vocab-inline .vocab-level { margin: 0; color: #a66328; font-size: 12px; font-weight: 900; letter-spacing: .06em; }
.hanja-vocab-inline .bonus-vocab { background: #fbf8f0; box-shadow: none; }
.vocab-list { display: grid; gap: 14px; }
.vocab-card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 9px 24px rgba(80,59,28,.08); }
.vocab-card h3 { margin: 0 0 8px; color: var(--navy); font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: 26px; }
.vocab-card p { margin: 0; font-size: 17px; line-height: 1.6; }
.vocab-card span { display: block; margin-top: 9px; color: #775528; font-size: 15px; line-height: 1.55; }
.reading-vocab-card { border-left: 5px solid var(--green); }

.template-sheet { display: grid; gap: 14px; padding: 22px; border: 2px solid #e2c77e; border-radius: 20px; background: #fffefa; box-shadow: 0 10px 30px rgba(116,82,30,.08); }
.template-line { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 54px; color: var(--navy); font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: clamp(18px, 3.4vw, 25px); font-weight: 700; line-height: 1.65; word-break: keep-all; }
.template-blank { position: relative; display: inline-block; width: clamp(118px, 23vw, 170px); height: 54px; border-bottom: 2px solid #d59b39; background: linear-gradient(180deg, transparent 74%, rgba(245,200,91,.13) 74%); touch-action: none; }
.template-blank canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.template-blank small { position: absolute; right: 4px; bottom: 2px; z-index: 0; color: #af9b79; font-family: "Pretendard", "Noto Sans KR", sans-serif; font-size: 10px; font-weight: 700; pointer-events: none; }
.template-note { margin: 4px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.65; word-break: keep-all; }

.thought-board { position: relative; height: 250px; margin-top: 18px; overflow: hidden; border: 2px solid #e2c77e; border-radius: 17px; background: repeating-linear-gradient(to bottom,#fffefa 0,#fffefa 60px,#eadfc8 61px,#fffefa 62px); touch-action: none; }
.thought-board.task-board { height: 180px; margin-top: 14px; }
.thought-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.canvas-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.finish-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.save-state { color: var(--muted); font-size: 13px; }

.reader-controls {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  color: #fff;
  background: var(--navy-deep);
}
.reader-controls button { width: 50px; height: 50px; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; color: #fff; background: rgba(255,255,255,.09); font-size: 26px; cursor: pointer; }
.reader-controls button:disabled { opacity: .25; cursor: default; }
.page-dots { display: flex; justify-content: center; align-items: center; gap: 6px; }
.page-dot { width: 7px; height: 7px; border-radius: 99px; background: rgba(255,255,255,.34); transition: .2s; }
.page-dot.active { width: 24px; background: var(--gold); }
.page-counter { position: absolute; right: 18px; bottom: 14px; z-index: 3; color: #8a7d67; font-size: 12px; font-weight: 800; }

.modal { width: min(calc(100% - 28px), 520px); padding: 24px; border: 1px solid #ddcca9; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal::backdrop { background: rgba(4,19,37,.7); backdrop-filter: blur(4px); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.modal-head h2 { margin: 4px 0 0; font-family: "Nanum Myeongjo", "AppleMyungjo", serif; font-size: 32px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: #fff; font-size: 26px; cursor: pointer; }
.hanja-animator { display: grid; place-items: center; width: min(72vw, 310px); aspect-ratio: 1; margin: 20px auto 12px; border: 2px solid #dfc178; border-radius: 18px; background: linear-gradient(#eadfbe 1px,transparent 1px),linear-gradient(90deg,#eadfbe 1px,transparent 1px),#fff; background-size: 50% 50%; overflow: hidden; }
.modal-note { min-height: 24px; margin: 10px 0; color: var(--muted); text-align: center; }
.modal-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.write-square { position: relative; width: min(72vw, 310px); aspect-ratio: 1; margin: 20px auto 12px; overflow: hidden; border: 2px solid #dfc178; border-radius: 18px; background: linear-gradient(#eadfbe 1px,transparent 1px),linear-gradient(90deg,#eadfbe 1px,transparent 1px),#fff; background-size: 50% 50%; touch-action: none; }
.write-square canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

@media (max-width: 760px) {
  .home { background: linear-gradient(180deg,#102a43 0 23rem,#f5efe2 23rem); }
  .home-hero { min-height: 21rem; }
  .month-panel { padding: 20px 16px; }
  .day-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .day-card:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 108px; }
  .book-stage { width: min(100%, 620px); height: calc(100svh - 180px); min-height: 470px; }
  .page-viewport { padding: 14px 10px; }
  .page-inner { padding: 34px 26px 48px; }
  .hanja-card { grid-template-columns: 1fr; gap: 18px; }
  .hanja-glyph { min-height: 175px; }
  .hanja-info { text-align: center; }
  .hanja-actions { justify-content: center; }
  .hanja-vocab-inline { grid-template-columns: 1fr; }
  .thought-board { height: 210px; }
  .compare-grid { grid-template-columns: 1fr; }
  .template-sheet { padding: 18px; }
  .template-blank { width: clamp(105px, 36vw, 150px); }
}

@media (max-width: 390px) {
  .home-hero-inner { padding-inline: 18px; }
  .month-head { align-items: start; }
  .progress-copy { text-align: right; }
  .progress-track { width: 96px; }
  .book-stage { min-height: 440px; }
  .page-inner { padding: 28px 22px 44px; }
  .task-card { padding: 18px; }
  .story-copy { font-size: 18px; }
}

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

@media print {
  body { background: #fff; }
  .reader-top, .reader-controls, .image-page, .audio-button, .hanja-actions, .canvas-actions, .finish-row { display: none !important; }
  .reader, .page-viewport, .book-stage, .flip-book { display: block !important; width: 100% !important; height: auto !important; min-height: 0 !important; padding: 0; background: #fff; transform: none !important; }
  .book-stage::after { display: none; }
  .stf__parent, .stf__wrapper, .stf__block { display: block !important; width: 100% !important; height: auto !important; min-height: 0 !important; transform: none !important; }
  .flip-page { display: none !important; position: relative !important; inset: auto !important; width: 100% !important; height: auto !important; min-height: 0; border: 0; box-shadow: none; transform: none !important; clip-path: none !important; }
  .printing-page .flip-page.print-target { display: block !important; }
  .page { position: relative; min-height: 26cm; }
  .page-inner { width: 100%; max-width: none; padding: 1.7cm; }
}
