:root {
  --paper: #F6F7FB;
  --card: #FFFFFF;
  --ink: #14181F;
  --ink-soft: #4A5468;
  --ink-faint: #8A93A5;
  --line: #E2E7F0;
  --accent: #2FA08C;
  --accent-deep: #227A6B;
  --accent-soft: #E6F5F1;
  --gold: #F5B301;
  --gold-soft: #FFF6DC;
  --ok: #2E7D53;
  --ok-soft: #E6F4EC;
  --warn: #8A6410;
  --warn-soft: #FCF3DE;
  --bad: #B33F33;
  --bad-soft: #FBEBE9;
  --shadow-s: 0 1px 3px rgba(20, 24, 31, 0.06);
  --shadow: 0 4px 14px rgba(20, 24, 31, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 24, 31, 0.14);
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
:root {
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}
/* 앱(APK)에서는 상태바·네비게이션바 아래로 화면이 깔리므로 최소 여백을 보장한다 */
body.is-native {
  /* 상태바(시계·알림)와 하단 제스처바·작업표시줄이 화면을 덮지 않도록 넉넉히 */
  --sa-top: max(env(safe-area-inset-top, 0px), 38px);
  --sa-bottom: max(env(safe-area-inset-bottom, 0px), 46px);
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px; line-height: 1.62;
  overscroll-behavior: none;
}
#app {
  max-width: 1500px; margin: 0 auto;
  padding: calc(12px + var(--sa-top)) calc(18px + var(--sa-right))
           calc(40px + var(--sa-bottom)) calc(18px + var(--sa-left));
}
h1, h2, h3, .jua { font-family: "Jua", "IBM Plex Sans KR", sans-serif; font-weight: 400; }
h1 { font-size: 1.9rem; margin: 6px 0 2px; }
h2 { font-size: 1.32rem; margin: 0; }
h3 { font-size: 1.12rem; margin: 0; }
.sub { color: var(--ink-soft); font-size: 0.96rem; margin: 0 0 14px; }
.cap { color: var(--ink-faint); font-size: 0.84rem; }
.bad { color: var(--bad); }

button {
  font-family: inherit; font-size: 1rem; border: none; cursor: pointer;
  border-radius: 14px; padding: 11px 18px; min-height: 50px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-s);
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; }
.btn-primary { background: var(--accent); color: #fff; font-family: "Jua", sans-serif; font-size: 1.12rem; box-shadow: 0 3px 0 var(--accent-deep); }
.btn-primary:active { box-shadow: 0 1px 0 var(--accent-deep); transform: translateY(2px); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); min-height: 42px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; }
.btn-ghost svg { width: 18px; height: 18px; }
.btn-soft { background: var(--accent-soft); color: var(--accent-deep); min-height: 40px; padding: 7px 14px; font-size: 0.9rem; box-shadow: none; }
.btn-big { width: 100%; font-size: 1.24rem; min-height: 60px; margin-top: 6px; }

/* 상단바 */
.topbar { display: flex; align-items: center; gap: 12px; padding: 2px 0 10px; }
.topbar .spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 8px; font-family: "Jua", sans-serif; color: var(--accent-deep); font-size: 1.05rem; }
.brand svg { width: 26px; height: 26px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; padding: 5px 12px; border-radius: 99px; }
.pill svg { width: 14px; height: 14px; }
.pill-offline { background: var(--warn-soft); color: var(--warn); }
.pill-queue { background: var(--accent-soft); color: var(--accent-deep); }

/* 프로필 */
.hero-greet { text-align: center; padding: 8px 0 2px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-top: 14px; }
.profile-card {
  background: var(--card); border: 2px solid var(--line); border-radius: 22px;
  padding: 20px 14px 18px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
}
.profile-card:active { transform: scale(0.98); }
.profile-card .avatar {
  width: 96px; height: 96px; margin: 0 auto 8px; border-radius: 50%;
  border: 3px solid var(--pc-accent, var(--accent)); background: var(--pc-soft, var(--accent-soft)); padding: 7px;
}
.profile-card .avatar svg { width: 100%; height: 100%; }
.profile-card .name { font-family: "Jua", sans-serif; font-size: 1.32rem; color: var(--pc-accent, var(--ink)); }
.profile-card .grade { color: var(--ink-faint); font-size: 0.84rem; display: inline-flex; align-items: center; gap: 4px; }
.profile-card .grade svg { width: 13px; height: 13px; }
.parent-card { --pc-accent: #3B4A6B; --pc-soft: #ECEFF6; }
.settings-row { margin-top: 22px; display: flex; align-items: center; justify-content: center; gap: 18px; color: var(--ink-soft); font-size: 0.92rem; }
.chk { display: inline-flex; align-items: center; gap: 7px; }

/* 홈 */
.home-head {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(120deg, var(--accent-soft), #fff 70%);
  border: 1.5px solid var(--line); border-radius: 22px;
  padding: 14px 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.home-head .avatar { flex: none; width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); padding: 5px; }
.home-head .avatar svg { width: 100%; height: 100%; }
.home-head .greet { flex: 1; min-width: 0; }
.home-head .hello { font-family: "Jua", sans-serif; font-size: 1.5rem; color: var(--accent-deep); }
.home-head .date { color: var(--ink-soft); font-size: 0.88rem; }
.coach-btn { background: var(--gold-soft); color: var(--warn); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.coach-btn svg { width: 20px; height: 20px; }

.daypack { background: var(--card); border: 2px solid var(--accent); border-radius: 22px; padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow-lg); }
.daypack-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.daypack-head .left { flex: 1; }
.daypack-head h2 { color: var(--accent-deep); }
.done-badge { background: var(--ok-soft); color: var(--ok); font-family: "Jua", sans-serif; padding: 8px 14px; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px; }
.done-badge svg { width: 18px; height: 18px; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.subject-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; min-height: 92px;
  background: var(--card); box-shadow: var(--shadow-s); width: 100%;
}
.subject-card .sicon { flex: none; width: 52px; height: 52px; border-radius: 15px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--sc) 12%, #fff); color: var(--sc); }
.subject-card .sicon svg { width: 26px; height: 26px; }
.subject-card .sbody { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.subject-card .slabel { font-size: 0.8rem; font-weight: 700; color: var(--sc); }
.subject-card .stitle { font-family: "Jua", sans-serif; font-size: 1.16rem; }
.subject-card .smeta { color: var(--ink-faint); font-size: 0.82rem; }
.subject-card .sgo { flex: none; font-family: "Jua", sans-serif; font-size: 1rem; padding: 9px 16px; border-radius: 12px; background: var(--sc); color: #fff; }
.subject-card.wait { border-style: dashed; }
.subject-card.wait .sgo { background: var(--warn-soft); color: var(--warn); }
.subject-card.fb .sgo { background: var(--ok-soft); color: var(--ok); }

.pending { margin-bottom: 18px; }
.pending-day { border-left: 3px solid var(--warn); padding-left: 12px; margin-bottom: 12px; }
.pd-date { font-family: "Jua", sans-serif; color: var(--warn); margin-bottom: 6px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.section-title h2 { font-size: 1.1rem; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 8px; }
.section-title svg { width: 20px; height: 20px; }

.assign-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.assign-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 13px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; box-shadow: var(--shadow-s); }
.assign-card .aicon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--paper); display: flex; align-items: center; justify-content: center; }
.assign-card .aicon svg { width: 21px; height: 21px; }
.assign-card .info { flex: 1; min-width: 0; }
.assign-card .title { font-family: "Jua", sans-serif; font-size: 1.06rem; }
.assign-card .meta { color: var(--ink-faint); font-size: 0.8rem; }
.chip { flex: none; font-size: 0.82rem; font-weight: 700; padding: 6px 13px; border-radius: 99px; }
.chip-todo { background: var(--accent-soft); color: var(--accent-deep); }
.chip-wait { background: var(--warn-soft); color: var(--warn); }
.chip-done { background: var(--ok-soft); color: var(--ok); }
.empty { text-align: center; color: var(--ink-soft); padding: 44px 0; }
.empty.small { padding: 18px 0; font-size: 0.9rem; }

/* 선생님 편지 */
.letter-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.lmascot { width: 76px; height: 76px; }
.lmascot svg { width: 100%; height: 100%; }
.letter { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-s); }
.letter-head { display: flex; align-items: center; gap: 12px; }
.lmini { width: 40px; height: 40px; flex: none; }
.lmini svg { width: 100%; height: 100%; }
.letter-head > div { flex: 1; }
.ltitle { font-family: "Jua", sans-serif; font-size: 1.1rem; }
.lmeta { color: var(--ink-faint); font-size: 0.82rem; }
.ltext { margin: 10px 0 0; }

/* 풀이 화면 */
.solve-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.solve-title { font-family: "Jua", sans-serif; color: var(--accent-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34%; }
.progress-track { flex: 1; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.progress { font-family: "Jua", sans-serif; color: var(--accent-deep); font-size: 1.05rem; white-space: nowrap; }
.page-area { display: flex; justify-content: center; }
.page-area canvas { display: block; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); touch-action: none; }
.solve-bottom { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.solve-bottom .spacer { flex: 1; }
.tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 66px; min-height: 54px; border: 1.5px solid var(--line); background: var(--card); box-shadow: none; color: var(--ink-soft); font-size: 0.8rem; }
.tool svg { width: 21px; height: 21px; }
.tool.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }

/* 완료 */
.done-screen { text-align: center; padding: 40px 0; }
.done-screen .burst { position: relative; width: 170px; height: 140px; margin: 0 auto 10px; }
.done-screen .burst svg { position: absolute; color: var(--gold); }
.done-screen .burst .s1 { width: 92px; left: 39px; top: 6px; animation: pop 0.5s ease-out; }
.done-screen .burst .s2 { width: 44px; left: 0; top: 48px; animation: pop 0.6s 0.12s ease-out backwards; }
.done-screen .burst .s3 { width: 44px; right: 0; top: 38px; animation: pop 0.6s 0.24s ease-out backwards; }
.queued-note { display: inline-flex; align-items: center; gap: 8px; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 9px 15px; font-size: 0.9rem; }
.queued-note svg { width: 19px; height: 19px; }
@keyframes pop { 0% { transform: scale(0.2) rotate(-18deg); opacity: 0; } 70% { transform: scale(1.12) rotate(4deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }

/* 피드백 */
.teacher-note { display: flex; gap: 14px; align-items: flex-start; background: var(--accent-soft); border-radius: 18px; padding: 15px 18px; margin-bottom: 14px; }
.tmascot { flex: none; width: 58px; height: 58px; }
.tmascot svg { width: 100%; height: 100%; }
.teacher-note .from { font-family: "Jua", sans-serif; color: var(--accent-deep); margin-bottom: 3px; }
.fb-item { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow-s); }
.fb-head { display: flex; align-items: center; gap: 12px; }
.fb-head .ptext { flex: 1; font-weight: 700; }
.fb-comment { margin-top: 7px; }
.tag { display: inline-block; font-size: 0.78rem; background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 2px 9px; margin: 5px 5px 0 0; }
.fb-img { margin-top: 10px; width: 100%; border: 1px solid var(--line); border-radius: 12px; display: none; }
.fb-img.show { display: block; }

/* 설정 */
.setup-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 16px 20px; box-shadow: var(--shadow-s); max-width: 640px; }
.setup-card .lbl { color: var(--ink-soft); font-size: 0.9rem; margin: 10px 0 5px; }
.setup-card input, .noterow textarea, .paper-body textarea {
  width: 100%; font-size: 1.02rem; padding: 12px; border: 1.5px solid var(--line);
  border-radius: 12px; font-family: inherit; background: #FBFCFE; color: var(--ink);
}
.setup-card input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.setup-msg { margin-top: 10px; min-height: 22px; color: var(--ink-soft); }
.nav-row { display: flex; gap: 10px; margin-top: 12px; max-width: 640px; }
.nav-row button { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 99px; font-size: 0.94rem; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 0.95; }

/* ===================== 부모 모드 ===================== */
.pin-wrap { max-width: 380px; margin: 4vh auto; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 6px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
.pin-dots span.on { background: var(--accent); border-color: var(--accent); }
.pin-msg { min-height: 24px; color: var(--ink-soft); font-size: 0.9rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.keypad button { min-height: 62px; font-size: 1.4rem; font-family: "Jua", sans-serif; }
.keypad button.ghost { background: var(--paper); color: var(--ink-soft); font-size: 1rem; }

.parent-top { border-bottom: 1px solid var(--line); }
.ptitle { font-family: "Jua", sans-serif; color: #3B4A6B; }
.pstudents { display: flex; gap: 6px; }
.pstudent { min-height: 40px; padding: 7px 15px; border-radius: 99px; background: var(--paper); color: var(--ink-soft); box-shadow: none; font-size: 0.94rem; }
.pstudent.on { background: var(--accent); color: #fff; font-weight: 700; }
.ptabs { display: flex; gap: 8px; margin: 12px 0 14px; flex-wrap: wrap; }
.ptabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 9px 16px; border-radius: 12px; background: var(--card); color: var(--ink-soft); box-shadow: var(--shadow-s); font-size: 0.95rem; }
.ptabs button svg { width: 18px; height: 18px; }
.ptabs button.on { background: var(--accent); color: #fff; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow-s); }
.stat .sv { font-family: "Jua", sans-serif; font-size: 1.7rem; color: var(--accent-deep); }
.stat .sv.small { font-size: 1.05rem; line-height: 1.5; }
.stat .sv .u { font-size: 0.9rem; color: var(--ink-faint); margin-left: 2px; }
.stat .sl { color: var(--ink-faint); font-size: 0.82rem; }
.stat.wide { grid-column: span 2; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.pcard { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-s); }
.pcard.accent { border-color: var(--accent); }
.pcard.tip { background: var(--accent-soft); border-color: transparent; color: var(--accent-deep); }
.pcard-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.focus { font-family: "Jua", sans-serif; font-size: 1.16rem; color: var(--accent-deep); margin-bottom: 8px; }
.mini-h { font-weight: 700; margin: 12px 0 4px; font-size: 0.92rem; }
.mini-h.ok { color: var(--ok); } .mini-h.warn { color: var(--warn); }
.plist { margin: 0; padding-left: 20px; }
.plist li { margin: 4px 0; }
.ptable { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.ptable th, .ptable td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable th { color: var(--ink-soft); font-weight: 700; width: 84px; }
.bar { display: inline-block; width: 88px; height: 9px; background: var(--line); border-radius: 99px; overflow: hidden; margin-right: 8px; vertical-align: middle; }
.bar span { display: block; height: 100%; background: var(--accent); }
.radar, .trend, .curbar { width: 100%; height: auto; display: block; }
.taglist { list-style: none; margin: 0; padding: 0; }
.taglist li { padding: 5px 0; }

.tcomment { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; }
.paper-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.paper { border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.paper img { width: 100%; display: block; border-bottom: 1px solid var(--line); background: #fff; }
.paper-body { padding: 10px 12px 12px; }
.paper-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.paper-h .ptxt { font-weight: 700; font-size: 0.94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vchip { flex: none; font-size: 0.76rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.vchip.ok { background: var(--ok-soft); color: var(--ok); }
.vchip.warn { background: var(--warn-soft); color: var(--warn); }
.vchip.bad { background: var(--bad-soft); color: var(--bad); }
.vchip.muted { background: var(--paper); color: var(--ink-faint); }
.nlabel { display: block; margin: 8px 0 4px; font-size: 0.82rem; color: var(--ink-soft); }
textarea { min-height: 62px; resize: vertical; }
textarea.saved { border-color: var(--ok); }
.noterow { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.noterow:first-of-type { border-top: none; }
.nnum { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep); display: flex; align-items: center; justify-content: center; font-family: "Jua", sans-serif; }
.nbody { flex: 1; min-width: 0; }
.ntext { font-weight: 700; margin-bottom: 2px; }
.cap.obs { margin-top: 6px; color: var(--ok); }

@media (prefers-reduced-motion: reduce) { .done-screen .burst svg { animation: none; } }

/* ---------- 지문/앞문제 오버레이 ---------- */
.ctx-overlay { position: fixed; inset: 0; background: rgba(20, 24, 31, 0.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80; }
.ctx-sheet { background: #fff; border-radius: 20px; padding: 20px 24px; max-width: 900px; width: 100%; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg); }
.ctx-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.passage { background: var(--paper); border-radius: 14px; padding: 16px 18px; font-size: 1.12rem; line-height: 1.85; }
.ctx-prev { margin-top: 14px; }
.ctx-item { border-top: 1px dashed var(--line); padding: 10px 0; }
.ctx-ans { color: var(--accent-deep); font-size: 0.92rem; margin-top: 3px; }

/* ---------- 키보드 입력 ---------- */
.type-area { margin-top: 10px; background: var(--card); border: 1.5px solid var(--accent); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow-s); }
.type-area.hidden { display: none; }
.type-area .tlabel { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; color: var(--accent-deep); margin-bottom: 6px; }
.type-area .tlabel svg { width: 17px; height: 17px; }
.type-area textarea { width: 100%; font-size: 1.12rem; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; }

/* ---------- 제출 답안 다시보기(읽기 전용) ---------- */
.readonly-note { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; background: var(--ok-soft); color: var(--ok); border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; }
.readonly-note svg { width: 20px; height: 20px; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.review { margin: 0; border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow-s); }
.review img { width: 100%; display: block; }
.review figcaption { padding: 10px 13px; font-size: 0.92rem; border-top: 1px solid var(--line); }

/* ---------- 작은 화면(태블릿 세로 등) 잘림 방지 ---------- */
@media (max-width: 900px) {
  .pgrid { grid-template-columns: 1fr; }
  .stat.wide { grid-column: span 2; }
  .ptabs button { flex: 1 1 44%; justify-content: center; }
}

/* ---------- 학습 로드맵 ---------- */
.lead { font-size: 1.04rem; margin: 0 0 10px; }
.engine-box { background: var(--accent-soft); border-radius: 12px; padding: 12px 15px; margin-bottom: 12px; }
.ebadge { display: inline-block; background: var(--accent); color: #fff; font-size: 0.76rem; font-weight: 700; border-radius: 99px; padding: 3px 10px; margin-right: 8px; }
.pgrid.tight { gap: 10px; margin-bottom: 4px; }
.roadmap { display: flex; flex-direction: column; }
.rm-item { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.rm-item:first-child { border-top: none; }
.rm-item.now { background: var(--accent-soft); border-radius: 14px; padding: 14px; border-top: none; }
.rm-month { flex: none; width: 92px; font-family: "Jua", sans-serif; font-size: 1.24rem; color: var(--accent-deep); }
.rm-now { display: block; font-family: inherit; font-size: 0.72rem; background: var(--accent); color: #fff; border-radius: 99px; padding: 2px 8px; margin-top: 4px; width: fit-content; }
.rm-body { flex: 1; min-width: 0; }
.rm-theme { font-family: "Jua", sans-serif; font-size: 1.1rem; margin-bottom: 4px; }
.rm-why { margin: 0 0 8px; color: var(--ink-soft); font-size: 0.94rem; }
.ptable.subj th { width: 68px; color: var(--accent-deep); font-size: 0.88rem; vertical-align: top; }
.ptable.subj td { font-size: 0.92rem; }
.rm-measure { margin-top: 8px; background: var(--gold-soft); color: var(--warn); border-radius: 10px; padding: 7px 12px; font-size: 0.88rem; }

/* ================= 주간 여정 보드 ================= */
.board-head {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--accent-soft), #fff 65%);
  border: 1.5px solid var(--line); border-radius: 22px;
  padding: 14px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.bh-avatar { flex: none; width: 66px; height: 66px; border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); padding: 5px; }
.bh-avatar svg { width: 100%; height: 100%; }
.bh-text { flex: 1; min-width: 180px; }
.bh-text .hello { font-family: "Jua", sans-serif; font-size: 1.46rem; color: var(--accent-deep); }
.bh-text .date { color: var(--ink-soft); font-size: 0.88rem; }
.bh-progress { flex: none; width: 210px; }
.bh-progress .track { height: 12px; background: #fff; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; }
.bh-progress .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 0.5s; }
.bh-progress .stars { display: flex; gap: 4px; justify-content: space-between; margin-top: 6px; }
.wstar { width: 20px; height: 20px; color: #DDE3EC; display: block; }
.wstar svg { width: 100%; height: 100%; }
.wstar.on { color: var(--gold); animation: pop 0.45s ease-out; }
.trophy { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-soft); color: var(--warn); font-family: "Jua", sans-serif; border-radius: 99px; padding: 9px 16px; }
.trophy svg { width: 22px; height: 22px; }

.journey { position: relative; margin: 4px 0 16px; padding: 6px 0 2px; }
.journey .road { position: absolute; left: 0; right: 0; top: 46px; width: 100%; height: 120px; pointer-events: none; }
.stops { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: transparent; box-shadow: none; border: none; padding: 6px 4px 10px; min-height: 0; cursor: pointer;
}
.stop-day { font-family: "Jua", sans-serif; font-size: 1.02rem; color: var(--ink-soft); }
.stop-circle {
  width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 3px solid var(--line); color: var(--ink-faint); box-shadow: var(--shadow-s);
  transition: transform 0.15s;
}
.stop-circle svg { width: 30px; height: 30px; }
.stop-num { font-family: "Jua", sans-serif; font-size: 1.4rem; color: var(--ink-soft); }
.stop-subs { display: flex; gap: 4px; min-height: 22px; }
.chipicon { width: 22px; height: 22px; color: var(--sc); opacity: 0.45; }
.chipicon svg { width: 100%; height: 100%; }
.chipicon.ok { opacity: 1; }
.stop-meta { font-size: 0.8rem; color: var(--ink-faint); }

.stop.done .stop-circle { background: linear-gradient(140deg, var(--gold), #FFD86B); border-color: var(--gold); color: #6A4B00; }
.stop.done .stop-meta { color: var(--warn); font-weight: 700; }
.stop.today .stop-circle { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent); animation: pulse 1.8s infinite; }
.stop.today .stop-day { color: var(--accent-deep); font-size: 1.12rem; }
.stop.missed .stop-circle { border-color: var(--warn); border-style: dashed; background: var(--warn-soft); color: var(--warn); }
.stop.missed .stop-meta { color: var(--warn); }
.stop.locked { cursor: default; }
.stop.locked .stop-circle { background: #F1F3F8; border-color: #E3E7EF; color: #B9C0CD; }
.stop.locked .stop-day, .stop.locked .stop-meta { color: #B9C0CD; }
.stop.locked .chipicon { opacity: 0.22; }
.stop.empty .stop-circle { border-style: dotted; }
.stop.sel .stop-circle { transform: scale(1.06); }
.stop:not(.locked):active .stop-circle { transform: scale(0.94); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent); } 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent) 8%, transparent); } }

.daypack.today { border-color: var(--accent); }
.daypack.missed { border-color: var(--warn); border-style: dashed; }

@media (prefers-reduced-motion: reduce) { .stop.today .stop-circle { animation: none; } .wstar.on { animation: none; } }
@media (max-width: 820px) {
  .journey .road { display: none; }
  .stops { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .stop-circle { width: 58px; height: 58px; }
  .bh-progress { width: 100%; }
}

/* ================= 실시간 코칭 ================= */
.live-status { margin-bottom: 12px; }
.live-on, .live-off { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 18px; box-shadow: var(--shadow-s); }
.live-on { border-color: var(--accent); background: linear-gradient(120deg, var(--accent-soft), #fff 60%); }
.dot { flex: none; width: 13px; height: 13px; border-radius: 50%; background: #C6CCD8; }
.dot.on { background: #2E9E5B; box-shadow: 0 0 0 5px rgba(46,158,91,0.18); animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0%,100% { box-shadow: 0 0 0 5px rgba(46,158,91,0.18); } 50% { box-shadow: 0 0 0 11px rgba(46,158,91,0.06); } }
.lo-main { flex: 1; min-width: 220px; }
.lo-title { font-size: 1.08rem; }
.lo-meta { color: var(--ink-soft); font-size: 0.9rem; }
.lo-meta .warn { color: var(--bad); }
.lo-bar { flex: none; width: 160px; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.lo-bar .fill { height: 100%; background: var(--accent); }
.live-alert { display: flex; align-items: center; gap: 8px; margin-top: 8px; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 0.92rem; }
.live-alert svg { width: 18px; height: 18px; flex: none; }

.guide-list { display: flex; flex-direction: column; gap: 10px; }
.guide-item { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow-s); transition: border-color 0.2s, box-shadow 0.2s; }
.guide-item.now { border-color: var(--accent); border-width: 2.5px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent); background: linear-gradient(120deg, var(--accent-soft), #fff 55%); }
.guide-item.done-p { opacity: 0.55; }
.gi-head { display: flex; align-items: center; gap: 10px; }
.gnum { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-deep); display: flex; align-items: center; justify-content: center; font-family: "Jua", sans-serif; }
.guide-item.now .gnum { background: var(--accent); color: #fff; }
.gtext { flex: 1; font-weight: 700; min-width: 0; }
.gans { flex: none; font-size: 0.82rem; color: var(--ink-faint); }
.gi-body { margin-top: 8px; display: grid; gap: 5px; }
.grow { font-size: 0.92rem; padding: 6px 10px; border-radius: 9px; }
.grow b { display: inline-block; min-width: 62px; font-size: 0.8rem; }
.grow.watch { background: #F2F5FA; color: var(--ink-soft); }
.grow.do { background: var(--ok-soft); color: var(--ok); }
.grow.dont { background: var(--bad-soft); color: var(--bad); }
.grow.when { background: var(--warn-soft); color: var(--warn); }
.gnote { width: 100%; margin-top: 6px; font-size: 0.95rem; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; }
.live-save { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.live-save select, .live-save input { min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-family: inherit; font-size: 1rem; background: #fff; }
.live-save input { flex: 1; min-width: 220px; }

.week-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 2px 0 6px; }
.wn-label { font-family: "Jua", sans-serif; font-size: 1.06rem; color: var(--accent-deep); min-width: 190px; text-align: center; }
.week-nav .btn-ghost svg { width: 16px; height: 16px; }

/* ---------- 학습 기록 (월별) ---------- */
.arch-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.month-tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.mtab { min-height: 42px; padding: 8px 15px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-s); font-family: "Jua", sans-serif; }
.mtab.on { background: var(--accent); color: #fff; }
.mtab .cap { color: inherit; opacity: 0.7; font-size: 0.76rem; }
.arch-day { margin-bottom: 16px; }
.ad-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 8px; }
.ad-date { font-family: "Jua", sans-serif; font-size: 1.1rem; color: var(--accent-deep); }
.arch-item { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; margin-bottom: 10px; box-shadow: var(--shadow-s); overflow: hidden; }
.arch-item.todo { border-style: dashed; }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; }
.ai-subj { flex: none; font-size: 0.78rem; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft); border-radius: 99px; padding: 3px 10px; }
.ai-title { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-score { flex: none; font-size: 0.84rem; font-weight: 700; padding: 4px 11px; border-radius: 99px; }
.ai-score.graded { background: var(--ok-soft); color: var(--ok); }
.ai-score.wait { background: var(--warn-soft); color: var(--warn); }
.ai-score.todo { background: var(--paper); color: var(--ink-faint); }
.ai-body { display: none; padding: 0 16px 14px; }
.arch-item.open .ai-body { display: block; }
.paper-noimg { padding: 18px; background: var(--paper); font-weight: 700; border-bottom: 1px solid var(--line); }

/* ---------- 주간 관찰 ---------- */
.deadline { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 13px; font-size: 0.92rem; }
.deadline.closed { background: var(--bad-soft); color: var(--bad); }
.wq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; margin-bottom: 14px; }
.wq { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow-s); }
.wq-title { font-family: "Jua", sans-serif; font-size: 1.06rem; color: var(--accent-deep); }
.wq-hint { color: var(--ink-faint); font-size: 0.84rem; margin: 4px 0 8px; line-height: 1.5; }
.wq-input, #wFree { width: 100%; font-size: 0.98rem; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; }
.past-review { border-top: 1px solid var(--line); padding: 9px 0; }
.past-review:first-of-type { border-top: none; }

/* 툴바 오버플로 방지 (폰·태블릿 세로) */
.solve-bottom { flex-wrap: wrap; }
@media (max-width: 900px) {
  .solve-bottom .tool span { display: none; }
  .solve-bottom .tool { min-width: 52px; }
  .solve-title { display: none; }
}
/* 접근성: 포커스 링, 대비 보정 */
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
:root { --ink-faint: #6B7488; }
.stop.locked .stop-day, .stop.locked .stop-meta { color: #8A93A5; }

/* ================= 상용 학습앱 톤 (조사 반영) ================= */
:root {
  --paper: #FDF6E9;            /* 웜 크림 배경 — 순백 대신 */
  --card: #FFFDF7;
  --ink: #3A3229;
  --ink-soft: #6B6055;
  --ink-faint: #97897A;
  --line: #E8DCC6;
  --cta: #FF8A2B;              /* 진행/시작 */
  --good: #3FBF6F;             /* 완료/정답 */
  --amber: #F2A03D;            /* 오답은 빨강 대신 앰버 */
  --ok: #2F8F55; --ok-soft: #E6F5EC;
  --warn: #8A6410; --warn-soft: #FDF2DC;
  --bad: #C2604A; --bad-soft: #FBEDE7;
  --gold: #FFC93C; --gold-soft: #FFF6DC;
}
body { background: var(--paper); }
.btn-primary { background: var(--cta); box-shadow: 0 3px 0 #D96D14; }
.btn-primary:active { box-shadow: 0 1px 0 #D96D14; }
.chip-done, .done-badge, .vchip.ok { background: var(--ok-soft); color: var(--ok); }

/* 숲 배경 여정 */
.journey { position: relative; padding: 0; margin: 6px 0 18px; border-radius: 22px; overflow: hidden;
  border: 2px solid var(--line); box-shadow: var(--shadow); }
.scene-forest { position: absolute; inset: 0; width: 100%; height: 100%; }
.journey .road { position: absolute; left: 0; right: 0; bottom: 34px; top: auto; height: 92px; }
.stops { position: relative; padding: 18px 8px 14px; }
.stop-day { color: #4C5B45; text-shadow: 0 1px 0 rgba(255,255,255,0.7); }
.stop-meta { color: #4C5B45; text-shadow: 0 1px 0 rgba(255,255,255,0.6); }
.stop-circle { background: #FFFDF7; border-color: #E4CFA6; }
.stop.done .stop-circle { background: #FFF6DC; border-color: var(--gold); padding: 6px; }
.stop-sticker { width: 46px; height: 46px; display: block; }
.stop-sticker svg { width: 100%; height: 100%; }
.stop.today .stop-circle { border-color: var(--cta); background: #FFF3E6; color: #C96A12;
  box-shadow: 0 0 0 6px rgba(255,138,43,0.22); }
.stop.missed .stop-circle { border-color: var(--amber); background: #FDF3E2; color: #8A6410; border-style: solid; }
.stop.locked .stop-circle { background: rgba(255,255,255,0.75); border-color: #DCD3C2; }

/* 습관 나무 */
.tree-box { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #F3FAEC;
  border: 2px solid #D8EBC6; border-radius: 18px; padding: 6px 12px 8px; box-shadow: none; min-height: 0; }
.tree-svg { width: 54px; height: 54px; display: block; }
.tree-label { font-size: 0.74rem; color: #4C8B2B; font-weight: 700; }

/* 완료 화면 */
.done-stamp { width: 150px; margin: 0 auto 6px; animation: stampIn 0.45s cubic-bezier(.2,1.4,.5,1); }
.done-stamp svg { width: 100%; height: auto; }
@keyframes stampIn { 0% { transform: scale(2.2) rotate(-16deg); opacity: 0; } 100% { transform: scale(1) rotate(-7deg); opacity: 1; } }
.sticker-get { margin: 6px 0 4px; }
.sg-frame { width: 104px; height: 104px; margin: 0 auto; background: #FFF; border: 3px dashed var(--gold);
  border-radius: 20px; padding: 10px; animation: pop 0.5s 0.25s ease-out backwards; }
.sg-frame svg { width: 100%; height: 100%; }
.sg-label { font-family: "Jua", sans-serif; color: var(--warn); margin-top: 6px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -18px; left: var(--l); width: 9px; height: 14px; background: var(--c);
  border-radius: 2px; animation: fall 2.4s var(--d) ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(var(--r)); opacity: 0.15; } }

/* 빈 상태 일러스트 */
.empty-illust { width: 190px; height: auto; display: block; margin: 0 auto 10px; }

/* 과목 카드: 파스텔 배경 + 진한 글씨 */
.subject-card { background: color-mix(in srgb, var(--sc) 30%, #FFFDF7); border-color: color-mix(in srgb, var(--sc) 55%, #fff); }
.subject-card .sicon { background: #FFFDF7; color: var(--ink); }
.subject-card .slabel { color: var(--ink-soft); }
.subject-card .sgo { background: var(--cta); color: #fff; }
.subject-card.fb .sgo { background: var(--good); }
.subject-card.wait .sgo { background: #FFF3E6; color: #C96A12; }

@media (prefers-reduced-motion: reduce) {
  .done-stamp, .sg-frame, .confetti i { animation: none; }
}
/* 미리보기(잠금 해제된 미래) 정거장 */
.stop.preview .stop-circle { border-color: #C9B896; border-style: dashed; background: #FFFDF7; color: #8A7A5E; }
.stop.preview .stop-meta { color: #7A6A52; }

/* ================= 마스코트 ================= */
.mascot { display: block; height: auto; }
.mascot-pair { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.mascot-pair .mascot-eraser { margin-bottom: 2px; }
.hero-greet .mascot-pair { margin-bottom: 2px; }
.bh-buddy { flex: none; }
.bh-buddy .mascot { animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.stop { position: relative; }
.stop-marker { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.12)); animation: bob 2.2s ease-in-out infinite; }
.done-buddies { margin-bottom: 2px; }
.page-area { position: relative; }
.page-buddy { position: absolute; left: 14px; bottom: 12px; display: flex; align-items: flex-end; gap: 6px;
  opacity: 0.95; transition: opacity 0.35s, transform 0.35s; pointer-events: none; }
.page-buddy.hide { opacity: 0; transform: translateY(8px); }
.pb-say { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 5px 11px;
  font-family: "Jua", sans-serif; font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 12px; }
.empty.boot .mascot { margin: 0 auto 10px; animation: bob 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .bh-buddy .mascot, .stop-marker, .empty.boot .mascot { animation: none; } }
@media (max-width: 820px) { .bh-buddy, .page-buddy { display: none; } }

/* ===== 오늘의 배움 (전체화면 설명) ===== */
.lesson-view {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--bg, #FDF6E9);
  padding: 14px clamp(12px, 3vw, 34px) 16px;
  overflow: auto;
}
.lesson-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 10px;
}
.ls-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ls-accent, #FF8A2B); color: #fff;
  font-weight: 700; font-size: 15px;
  padding: 7px 14px; border-radius: 999px;
}
.ls-badge svg { width: 18px; height: 18px; }
.ls-title { font-weight: 700; font-size: clamp(19px, 2.4vw, 27px); color: var(--ink, #42352A); }
.ls-dots { display: flex; gap: 7px; margin-left: auto; }
.ls-dots i {
  width: 11px; height: 11px; border-radius: 50%;
  background: rgba(120, 106, 86, 0.22);
}
.ls-dots i.done { background: rgba(120, 106, 86, 0.45); }
.ls-dots i.on { background: var(--ls-accent, #FF8A2B); transform: scale(1.25); }
.lesson-body {
  flex: 1; display: grid; grid-template-columns: 1.5fr 1fr;
  gap: clamp(14px, 2.4vw, 30px); align-items: center; min-height: 0;
}
.ls-figwrap { width: 100%; max-width: 1000px; justify-self: center; }
.ls-figwrap canvas {
  width: 100%; height: auto; display: block;
  border-radius: 22px;
  box-shadow: 0 6px 22px rgba(90, 74, 50, 0.10);
}
.ls-textwrap { align-self: center; }
.ls-step {
  display: inline-block; font-weight: 700; font-size: clamp(16px, 1.6vw, 19px);
  color: var(--ls-accent, #FF8A2B);
  background: #fff; border-radius: 999px; padding: 5px 13px;
  box-shadow: 0 2px 8px rgba(90, 74, 50, 0.08);
}
.ls-textwrap h2 {
  margin: 16px 0 12px; line-height: 1.34;
  font-size: clamp(29px, 3.7vw, 48px); color: var(--ink, #42352A);
}
.ls-textwrap p {
  margin: 0; line-height: 1.66;
  font-size: clamp(21px, 2.2vw, 29px); color: #5B4E40;
}
.ls-sub {
  margin-top: 16px; font-size: 15px; color: #8A7A66;
  border-left: 4px solid var(--ls-accent, #FF8A2B); padding-left: 12px;
}
.ls-closing {
  display: flex; align-items: center; gap: 12px;
  margin-top: 20px; padding: 14px 16px;
  background: #fff; border-radius: 18px;
  box-shadow: 0 3px 12px rgba(90, 74, 50, 0.09);
  font-weight: 700; font-size: clamp(20px, 2.1vw, 27px); color: var(--ink, #42352A);
}
.lesson-foot {
  display: flex; align-items: center; gap: 12px; padding-top: 14px;
}
.lesson-foot .spacer { flex: 1; }
.lesson-foot button {
  font-size: clamp(15px, 1.8vw, 19px); padding: 13px 26px; border-radius: 16px;
}
@media (max-width: 860px) {
  .lesson-body { grid-template-columns: 1fr; align-content: start; }
  .ls-title { width: 100%; order: 3; }
  .ls-dots { order: 2; }
}

/* 오늘의 배움 — 교과서형 본문·정리 슬라이드 */
.ls-detail {
  margin-top: 14px; padding: 13px 16px;
  background: #fff; border-radius: 14px;
  font-size: clamp(19px, 1.9vw, 24px); line-height: 1.64; color: #5B4E40;
  box-shadow: 0 2px 10px rgba(90, 74, 50, 0.07);
}
.lesson-view.is-summary { justify-content: flex-start; }
.ls-summary {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 24px); align-content: center; padding: 6px 0 4px;
}
.ls-card {
  background: #fff; border-radius: 20px; padding: 24px 26px;
  box-shadow: 0 4px 16px rgba(90, 74, 50, 0.09);
  border-top: 5px solid var(--ls-accent, #FF8A2B);
}
.ls-card.warn { border-top-color: #E4572E; }
.ls-card h3 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px; font-size: clamp(21px, 2.3vw, 27px); color: var(--ink, #42352A);
}
.ls-card h3 svg { width: 20px; height: 20px; color: var(--ls-accent, #FF8A2B); }
.ls-card.warn h3 svg { color: #E4572E; }
.ls-card ul { margin: 0; padding-left: 20px; }
.ls-card li {
  margin-bottom: 13px; line-height: 1.6;
  font-size: clamp(20px, 2vw, 26px); color: #5B4E40;
}
@media (max-width: 860px) {
  .ls-summary { grid-template-columns: 1fr; }
}

/* 오늘의 배움 — 직접 해 보기(인터랙티브) 컨트롤 */
.ls-controls {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-top: 12px;
}
.ls-readout {
  font-weight: 700; font-size: clamp(20px, 2.4vw, 30px);
  color: var(--ink, #42352A);
  background: #fff; border-radius: 999px; padding: 8px 22px;
  box-shadow: 0 3px 12px rgba(90, 74, 50, 0.10);
  border: 2px solid var(--ls-accent, #FF8A2B);
}
.ls-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ls-btns button {
  font-family: inherit; font-weight: 700;
  font-size: clamp(14px, 1.6vw, 18px);
  padding: 11px 18px; border-radius: 14px;
  border: 2px solid rgba(120, 106, 86, 0.22);
  background: #fff; color: var(--ink, #42352A);
  cursor: pointer; transition: transform .06s ease, box-shadow .12s ease;
  box-shadow: 0 2px 8px rgba(90, 74, 50, 0.07);
}
.ls-btns button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(90, 74, 50, 0.12); }
.ls-btns button:active:not(:disabled) { transform: translateY(1px); }
.ls-btns button:disabled { opacity: .45; cursor: default; }
.ls-btns button.key {
  background: var(--ls-accent, #FF8A2B); color: #fff; border-color: transparent;
}

/* 설명 버튼의 유형 이름 (좁은 화면에서는 감춘다) */
.tool .tool-sub { display: none; font-style: normal; }
@media (min-width: 860px) { .tool .tool-sub { display: inline; } }


/* ===== 시스템바(상단 상태바·하단 버튼)와 겹치지 않게 ===== */
.lesson-view {
  padding-top: calc(14px + var(--sa-top));
  padding-bottom: calc(18px + var(--sa-bottom));
  padding-left: calc(clamp(12px, 3vw, 34px) + var(--sa-left));
  padding-right: calc(clamp(12px, 3vw, 34px) + var(--sa-right));
}
.ctx-overlay {
  padding-top: calc(20px + var(--sa-top));
  padding-bottom: calc(20px + var(--sa-bottom));
}
.toast { bottom: calc(26px + var(--sa-bottom)); }
/* 도구 줄은 #app의 아래 여백(40px + 시스템바) 안쪽에 놓인다 */
.solve-bottom { padding-bottom: 2px; }
body.is-native .done-screen, body.is-native .ctx-sheet { margin-bottom: var(--sa-bottom); }

/* ===== 상단 '설명 다시 보기' 버튼 ===== */
.lesson-top {
  display: inline-flex; align-items: center; gap: 7px;
  background: #FFF3E6; color: #B85C06;
  border: 2px solid var(--cta); border-radius: 999px;
  font-weight: 700; font-size: 0.94rem;
  padding: 9px 16px; min-height: 44px; white-space: nowrap;
  box-shadow: 0 2px 0 rgba(217, 109, 20, 0.35);
}
.lesson-top:active { box-shadow: none; transform: translateY(1px); }
.lesson-top svg { width: 18px; height: 18px; }
.lesson-top .lt-sub { font-weight: 700; opacity: 0.85; }
@media (max-width: 720px) {
  .lesson-top .lt-full { display: none; }
  .lesson-top { padding: 8px 13px; font-size: 0.88rem; }
}
@media (min-width: 721px) { .lesson-top .lt-short { display: none; } }

/* 아직 안 배운 유형이면 상단 버튼을 더 눈에 띄게 */
.lesson-top.is-new {
  background: var(--cta); color: #fff; border-color: transparent;
  animation: ltPulse 1.8s ease-in-out 3;
}
@keyframes ltPulse {
  0%, 100% { box-shadow: 0 2px 0 rgba(217,109,20,.35); }
  50% { box-shadow: 0 2px 0 rgba(217,109,20,.35), 0 0 0 7px rgba(255,138,43,.22); }
}
@media (prefers-reduced-motion: reduce) { .lesson-top.is-new { animation: none; } }

/* ===== 벡터 아트(webapp/art/*.svg) 전환에 따른 보정 ===== */
.scene-forest { object-fit: cover; object-position: center bottom; }
.stop-sticker img, .sticker-img { width: 100%; height: 100%; display: block; }
.sg-frame .sticker-img { width: 100%; height: 100%; }
.tree-svg { width: 54px; height: 54px; }
.lmascot .mascot { width: 100%; height: auto; }
.mascot { max-width: 100%; }

/* ===== 말풍선 (캐릭터가 말을 거는 형태) ===== */
.say { display: flex; align-items: flex-end; gap: 10px; position: relative; z-index: 2; }
.say-right { flex-direction: row-reverse; }
.say-face { flex: none; }
.say-face .mascot { display: block; }
.say-bubble {
  position: relative; background: #fff; border-radius: 18px;
  padding: 11px 16px; box-shadow: 0 3px 12px rgba(90, 74, 50, 0.12);
  font-weight: 700; color: var(--ink, #42352A); line-height: 1.5;
  font-size: 0.98rem; max-width: 34ch;
}
.say-bubble::after {
  content: ""; position: absolute; bottom: 14px; width: 0; height: 0;
  border: 9px solid transparent;
}
.say-left .say-bubble::after { left: -16px; border-right-color: #fff; }
.say-right .say-bubble::after { right: -16px; border-left-color: #fff; }
.say-hero { justify-content: center; margin: 2px 0 10px; }
.say-board { margin: 0; padding: 12px 14px 0; }
.say-board .say-bubble { background: rgba(255, 255, 255, 0.94); }
@media (max-width: 620px) {
  .say-bubble { font-size: 0.92rem; padding: 9px 13px; }
}
.empty-illust .mascot { width: 150px; height: auto; margin: 0 auto; }

/* ===== 앱 내부 업데이트 알림 ===== */
.upd-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--sa-bottom)); z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: #2B3442; color: #fff;
  padding: 10px 12px 10px 18px; border-radius: 999px;
  box-shadow: 0 8px 26px rgba(20, 24, 31, 0.28);
  font-weight: 700; font-size: 0.95rem;
  max-width: calc(100vw - 24px);
}
.upd-bar button {
  min-height: 38px; padding: 7px 14px; border-radius: 999px;
  background: var(--accent, #2FA08C); color: #fff; font-weight: 700; font-size: 0.9rem;
  box-shadow: none;
}
.upd-bar button.ghost { background: transparent; color: #C7D0DC; }
.upd-row {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.ver-chip {
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
  background: rgba(120, 106, 86, 0.08); border-radius: 999px; padding: 3px 10px;
}

/* ===== 완료 연출: 오뜌의 도트 선글라스가 툭 떨어진다 =====
   밈의 재미는 '내려오는 순간'에 있다. 다 푼 뒤에만 나온다. */
.otyu-drop { display: inline-block; animation: otyuDrop .68s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes otyuDrop {
  0%   { transform: translateY(-46px) rotate(-6deg); opacity: 0; }
  62%  { transform: translateY(6px) rotate(2deg); opacity: 1; }
  80%  { transform: translateY(-3px) rotate(-1deg); }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .otyu-drop { animation: none; } }

/* ===== 기한 안 다시 풀기 ===== */
.task-row { display: flex; align-items: stretch; gap: 8px; }
.task-row .subject-card { flex: 1; }
.redo-btn {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 82px; padding: 10px 8px; border-radius: 18px;
  border: 2px dashed rgba(120, 106, 86, 0.30); background: #FFFDF7;
  color: var(--ink-soft); font-size: 0.82rem; font-weight: 700; line-height: 1.2;
  box-shadow: none;
}
.redo-btn svg { width: 20px; height: 20px; }
.redo-btn:active { transform: translateY(1px); }
.try-chip {
  margin-left: 6px; font-size: 0.72rem; font-weight: 700;
  background: var(--gold-soft); color: var(--warn); border-radius: 999px; padding: 2px 8px;
}

/* 부팅이 오래 걸릴 때의 탈출구 */
.boot-escape { margin-top: 18px; }
.boot-escape .cap { margin-bottom: 6px; }

/* ===== 풀이 화면 — 도구를 오른쪽 세로 레일로 (가로 화면) =====
   가로 화면에서 귀한 건 세로다. 예전에는 위·아래로 헤더와 툴바가 132px을 먹고
   #app 여백이 136px을 더 먹는데, 정작 학습지 양옆 354px(폭의 29%)은
   레터박스로 그냥 버려졌다. 도구를 옆으로 몰면 학습지가 세로를 다 써서
   쓰는 칸이 48mm -> 81mm 로 넓어진다(아이가 세로셈 하나 쓰는 게 45mm). */
body.solving { overflow: hidden; }
body.solving #app {
  max-width: none; height: 100%; box-sizing: border-box; display: flex;
  padding: calc(4px + var(--sa-top)) calc(6px + var(--sa-right))
           calc(4px + var(--sa-bottom)) calc(6px + var(--sa-left));
}
.solve-wrap { flex: 1; display: flex; gap: 8px; min-width: 0; min-height: 0; }
.solve-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.solve-main .page-area { flex: 1; min-height: 0; align-items: center; overflow: hidden; }
.solve-rail {
  width: 112px; flex: none; display: flex; flex-direction: column; gap: 6px; min-height: 0;
}
/* 도구는 자리가 모자라면 스크롤되고, **이전/다음은 언제나 바닥에 붙어 보인다.**
   예전에는 세로가 짧은 화면(폰 가로·10인치 미만 태블릿)에서 '다음'이 화면 밖으로
   밀려났는데 body가 overflow:hidden이라 스크롤로도 닿을 수 없었다 — 아이가 갇혔다. */
.rail-tools {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 6px;
}
.rail-nav { flex: none; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.solve-rail .spacer { display: none; }
.solve-rail > button, .rail-tools > button, .rail-nav > button { width: 100%; }
/* 제출은 되돌릴 수 없다 — '다음'과 다른 색으로 눈에 띄게 */
#next.is-submit { background: var(--ok, #2E9E5B); box-shadow: 0 3px 0 #1F7A43; }
#next.is-submit:active { box-shadow: 0 1px 0 #1F7A43; }

/* 세로가 아주 짧으면(폰 가로) 도구를 납작하게 눌러 전부 보이게 한다 */
@media (orientation: landscape) and (max-height: 620px) {
  .solve-rail { width: 92px; }
  .solve-rail .tool { min-height: 38px; font-size: 0.78rem; padding: 0 7px; gap: 6px; }
  .solve-rail .tool span { display: none; }
  .solve-rail .lesson-top { padding: 5px 6px; font-size: 0.78rem; }
  .solve-rail .rail-quit { min-height: 34px; }
  .solve-rail #prev, .solve-rail #next { min-height: 40px; font-size: 0.9rem; }
  .rail-prog { padding: 0 2px 2px; }
}
.solve-rail .tool {
  flex-direction: row; justify-content: flex-start; gap: 9px;
  padding: 0 11px; min-height: 48px; font-size: 0.86rem;
}
.solve-rail .rail-quit { justify-content: flex-start; gap: 8px; min-height: 42px; }
.solve-rail .lesson-top { justify-content: center; padding: 8px 10px; font-size: 0.86rem; }
.solve-rail .lesson-top .lt-full { display: none; }
.solve-rail .lesson-top .lt-short { display: inline; }
.rail-prog { display: flex; align-items: center; gap: 8px; padding: 2px 2px 4px; }
.rail-prog .progress-track { flex: 1; }
.rail-prog .progress { font-size: 0.95rem; }
.solve-rail #prev, .solve-rail #next { min-height: 50px; }

/* 세로 화면(폰)에서는 다시 아래 가로 바로 — 세로가 남고 가로가 귀하다 */
@media (orientation: portrait) {
  .solve-wrap { flex-direction: column; }
  .solve-rail { width: auto; flex-direction: row; align-items: center; gap: 8px; }
  /* 도구는 가로로 흐르되 **줄바꿈하지 않는다** — 넘치면 옆으로 스크롤한다.
     예전에는 wrap 때문에 '다음'이 '이전'과 떨어져 반대쪽 구석에 홀로 떨어졌고,
     과목마다 도구 개수가 달라 연필·지우개 위치가 통째로 바뀌었다. */
  .rail-tools {
    flex: 1 1 auto; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    align-items: center;
  }
  .rail-nav { flex-direction: row; padding-top: 0; }
  .rail-nav > button { width: auto; min-width: 74px; }
  .solve-rail > button { width: auto; }
  .solve-rail .tool { flex-direction: column; gap: 2px; min-width: 56px; padding: 0 7px; }
  .solve-rail .tool span { display: none; }
  .solve-rail .rail-quit span { display: none; }
  .rail-prog { min-width: 96px; }
}

/* ===== 손맛: 눌림 · 전환 =====
   버튼은 누를 때 쏙 들어갔다가 놓을 때 살짝 튀어오른다(되돌아오는 곡선의 오버슛).
   캔버스에는 transform 애니메이션을 절대 쓰지 않는다 — 펜 좌표를
   getBoundingClientRect로 재기 때문에, 움직이는 중에 쓰면 획이 어긋난다.
   그래서 학습지는 투명도만 바꾼다. */
button, .profile-card, .subject-card {
  transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.25, 1.35),
              box-shadow 0.12s ease-out, background-color 0.12s ease-out;
}
button:active:not(:disabled), .profile-card:active, .subject-card:active {
  transform: scale(0.955);
  transition-duration: 0.06s;
}
.tool:active:not(:disabled) { transform: scale(0.92); }

@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-in { animation: viewIn 0.2s ease-out; }

@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
.page-area canvas { animation: pageIn 0.16s ease-out; }

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 움직임을 줄여 달라고 한 기기에서는 전부 끈다 */
@media (prefers-reduced-motion: reduce) {
  button, .profile-card, .subject-card { transition: none; }
  button:active:not(:disabled), .profile-card:active, .subject-card:active,
  .tool:active:not(:disabled) { transform: none; }
  .view-in, .page-area canvas { animation: none; }
}

/* 저장이 안 되는 동안 계속 떠 있는 경고 — 토스트는 지나가면 끝이라 안 된다 */
.save-alarm {
  position: fixed; left: 0; right: 0; top: 0; z-index: 90;
  padding: calc(8px + var(--sa-top)) 14px 8px;
  background: #C62828; color: #fff; text-align: center;
  font-weight: 700; font-size: 0.95rem; letter-spacing: -0.2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

/* 마스코트는 종이(캔버스) 기준으로 붙어야 한다. page-area는 남는 폭을 다 차지해서,
   여기에 붙이면 종이 밖 허공에 떠 있었다. */
.page-stage { position: relative; display: block; line-height: 0; }
.page-stage .page-buddy { left: 12px; bottom: 10px; }

/* ===== 문제 번호 단추 줄 =====
   고치고 싶은 문제로 바로 간다. 다시 풀기 중에는 '먼저 쓴 답 그대로'(주황 테두리)와
   '새로 쓴 것'(초록)을 구분해, 어디를 고쳤는지 아이가 한눈에 본다. */
.prob-strip { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 1px; }
.pnum {
  width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft);
  font-family: "Jua", sans-serif; font-size: 0.92rem; box-shadow: none;
}
.pnum.done { background: var(--ok-soft, #E7F6EC); border-color: #86C79B; color: #1F7A43; }
.pnum.prev { background: #FFF3E6; border-color: var(--cta); color: #B85C06; }
.pnum.now { outline: 3px solid var(--accent); outline-offset: 1px; }
.redo-one { border-color: var(--cta) !important; color: #B85C06 !important; background: #FFF3E6 !important; }

@media (orientation: portrait) {
  /* 가로 바에서는 한 줄로 흐르게 (줄바꿈하면 도구 위치가 밀린다) */
  .prob-strip { flex-wrap: nowrap; }
}
@media (orientation: landscape) and (max-height: 620px) {
  .pnum { width: 26px; min-width: 26px; height: 26px; font-size: 0.8rem; border-radius: 8px; }
}
