:root {
  --bg: #fff8ef;
  --card: #ffffff;
  --ink: #2d2a32;
  --muted: #7a7486;
  --line: #eee4d6;
  --primary: #ff8a3d;
  --primary-ink: #ffffff;
  --morning: #ffb547;
  --morning-bg: #fff1d6;
  --evening: #6c6cf0;
  --evening-bg: #e8e8ff;
  --good: #22a565;
  --good-bg: #e2f6eb;
  --bad: #e5484d;
  --bad-bg: #fde8e8;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(80, 50, 20, 0.08);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { max-width: 100%; }
.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.wrap.wide { max-width: 1000px; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; border: 1px solid var(--line);
}
.card + .card { margin-top: 14px; }

button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 14px; padding: 11px 18px;
  background: #f1ebe2; color: var(--ink); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover, .btn:hover { filter: brightness(0.97); }
button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.88rem; border-radius: 10px; }
.btn-big { padding: 16px 26px; font-size: 1.15rem; border-radius: 18px; }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password], textarea, select {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: #f1ebe2; color: var(--muted); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.morning { background: var(--morning-bg); color: #b86e00; }
.tag.evening { background: var(--evening-bg); color: var(--evening); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 100; max-width: 90vw; font-weight: 600;
}

/* ── 첫 화면 ── */
.kid-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.kid-pick a {
  display: block; text-decoration: none; background: #fff; border-radius: 22px; padding: 22px 12px;
  text-align: center; box-shadow: var(--shadow); border: 2px solid transparent;
}
.kid-pick a:hover { border-color: var(--primary); }
.kid-pick .emoji { font-size: 3.2rem; display: block; }
.kid-pick .name { font-size: 1.2rem; font-weight: 800; margin-top: 6px; display: block; }
.logo { font-size: 2rem; font-weight: 900; letter-spacing: -0.02em; }
.logo span { color: var(--primary); }

/* ── 아이 화면 ── */
.kid { font-size: 1.08rem; }
.kid-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.kid-head .avatar { font-size: 2.6rem; }
.badges { display: flex; gap: 8px; }
.badge { background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 800; box-shadow: var(--shadow); }
.mission {
  display: block; width: 100%; text-align: left; border-radius: 24px; padding: 22px; margin-bottom: 14px;
  border: 3px solid transparent; position: relative;
}
.mission.morning { background: var(--morning-bg); }
.mission.evening { background: var(--evening-bg); }
.mission.now { border-color: var(--primary); }
.mission.evening.now { border-color: var(--evening); }
.mission .icon { font-size: 2.6rem; }
.mission .title { font-size: 1.35rem; font-weight: 900; margin: 4px 0; }
.mission .desc { color: var(--muted); font-weight: 600; font-size: 0.98rem; }
.mission .status { position: absolute; right: 18px; top: 18px; }
.now-label { font-size: 0.8rem; background: var(--primary); color: #fff; border-radius: 999px; padding: 3px 10px; }
.mission.evening .now-label { background: var(--evening); }

.concept-card { background: #fff; border-radius: 22px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 14px; }
.concept-card .summary { white-space: pre-wrap; line-height: 1.8; font-size: 1.08rem; }
.concept-card ul { padding-left: 1.2em; line-height: 1.9; }
.concept-card li::marker { content: "⭐ "; }

.progress { height: 12px; background: #f1e6d6; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }
.evening-mode .progress > div { background: var(--evening); }

.q-card { background: #fff; border-radius: 24px; padding: 24px; box-shadow: var(--shadow); margin-top: 16px; }
.q-prompt { font-size: 1.3rem; font-weight: 800; line-height: 1.6; white-space: pre-wrap; word-break: keep-all; }
.q-image { margin: 14px 0; border-radius: 14px; border: 1px solid var(--line); max-height: 360px; object-fit: contain; width: 100%; background: #fafafa; cursor: zoom-in; }
.choices { display: grid; gap: 10px; margin-top: 18px; }
.choice {
  background: #fbf6ef; border: 2.5px solid var(--line); border-radius: 16px; padding: 15px 16px;
  font-size: 1.12rem; text-align: left; justify-content: flex-start; font-weight: 700;
}
.choice .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #fff; margin-right: 6px; font-size: 0.9rem; flex-shrink: 0; }
.choice.picked { border-color: var(--primary); }
.choice.right { border-color: var(--good); background: var(--good-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.ox { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.ox button { font-size: 3.2rem; padding: 22px 0; border-radius: 22px; background: #fbf6ef; border: 3px solid var(--line); font-weight: 900; }
.ox button.o { color: #2a7bf6; }
.ox button.x { color: var(--bad); }
.ox button.right { border-color: var(--good); background: var(--good-bg); }
.ox button.wrong { border-color: var(--bad); background: var(--bad-bg); }
.short-input { display: flex; gap: 10px; margin-top: 18px; }
.short-input button { flex-shrink: 0; white-space: nowrap; }
.short-input input { min-width: 0; font-size: 1.3rem; padding: 14px; text-align: center; font-weight: 700; }

.feedback { border-radius: 20px; padding: 18px; margin-top: 16px; animation: pop 0.25s ease; }
.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback .big { font-size: 1.5rem; font-weight: 900; }
.feedback.good .big { color: var(--good); }
.feedback.bad .big { color: var(--bad); }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result-hero { text-align: center; padding: 26px 10px; }
.result-hero .emoji { font-size: 5rem; animation: pop 0.4s ease; }
.result-hero .score { font-size: 3rem; font-weight: 900; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti span { position: absolute; top: -40px; font-size: 1.6rem; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: grid; place-items: center; z-index: 200; padding: 16px; cursor: zoom-out; }
.lightbox img { max-height: 92vh; border-radius: 10px; }

/* ── 부모 화면 ── */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.tabs button { background: transparent; white-space: nowrap; }
.tabs button.on { background: var(--ink); color: #fff; }
.kid-tabs button.on { background: var(--primary); color: #fff; }
.drop {
  border: 2.5px dashed #e3d4bf; border-radius: 16px; padding: 18px; text-align: center; background: #fffdf9;
  cursor: pointer; display: block; font-weight: 600;
}
.drop:hover { border-color: var(--primary); }
.drop input { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs .t { position: relative; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumbs .t button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.8rem; }
.unit-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line); cursor: pointer; }
.unit-item + .unit-item { margin-top: 8px; }
.unit-item:hover { border-color: var(--primary); }
.unit-item.off { opacity: 0.55; }
.q-item { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.q-item + .q-item { margin-top: 10px; }
.q-item.off { opacity: 0.5; }
.q-item .p { font-weight: 700; white-space: pre-wrap; }
.q-item ol { margin: 8px 0 0; padding-left: 1.3em; }
.q-item li.ans { color: var(--good); font-weight: 800; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #ddd; border-radius: 99px; transition: 0.2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(20px); }
.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.cal .d { text-align: center; font-size: 0.7rem; color: var(--muted); }
.cal .c { aspect-ratio: 1; border-radius: 6px; background: #f1ebe2; }
.bar { height: 10px; background: #f1ebe2; border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--good); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid #f1d9bf; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { background: var(--morning-bg); border-radius: 14px; padding: 12px 14px; font-size: 0.92rem; line-height: 1.5; }
.pin-pad { max-width: 320px; margin: 40px auto; text-align: center; }
.pin-pad input { text-align: center; font-size: 1.8rem; letter-spacing: 0.4em; }

/* ── 그림 ── */
.figure { display: block; width: 100%; max-height: 340px; object-fit: contain; margin: 14px 0; border-radius: 14px; background: #fff; border: 1px solid var(--line); cursor: zoom-in; }
.figure.sm { max-height: 160px; margin: 8px 0; }
.concept-item { border-top: 2px dashed var(--line); padding-top: 14px; margin-top: 14px; }
.concept-item h3 { margin-bottom: 6px; }
.concept-item .ex { background: var(--morning-bg); border-radius: 12px; padding: 10px 12px; font-weight: 700; margin-top: 8px; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.fig-box { border: 1px dashed var(--line); border-radius: 12px; padding: 8px; }
.fig-box .cap { font-size: 0.8rem; color: var(--muted); font-weight: 700; }

/* ── 별 보상 ── */
.star-balance { font-size: 1.4rem; margin: 10px 0 12px; }
.star-balance b { font-size: 2rem; color: #e09a00; }
.reward { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: #fbf6ef; border: 2px solid var(--line); }
.reward + .reward { margin-top: 8px; }
.reward .r-emoji { font-size: 2.2rem; }
.reward .progress > div { background: #ffc233; }
.reward.ready { border-color: #ffc233; background: #fff6d8; }
.ledger td { padding: 7px 6px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.ledger .plus { color: var(--good); font-weight: 800; }
.ledger .minus { color: var(--bad); font-weight: 800; }
.reward-edit.off { opacity: 0.55; }

/* ── 오늘의 이야기 ── */
.story-card { display: block; width: 100%; text-align: left; border-radius: 24px; padding: 20px; margin-bottom: 14px; background: #e7f6ee; border: 3px solid transparent; }
.story-card.unread { border-color: var(--good); }
.story-card .icon { font-size: 2.2rem; }
.story-card .title { font-size: 1.2rem; font-weight: 900; margin: 4px 0; word-break: keep-all; }
.story { background: #fff; border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow); }
.story h1 { font-size: 1.5rem; word-break: keep-all; }
.story .who { color: var(--muted); font-weight: 700; margin-bottom: 14px; }
.story-body p, .story-body li { font-size: 1.12rem; line-height: 1.9; word-break: keep-all; }
.story-body blockquote { margin: 14px 0; padding: 12px 16px; background: var(--morning-bg); border-radius: 14px; font-weight: 700; line-height: 1.8; }
.story-body ul, .story-body ol { padding-left: 1.3em; }
.story-fig { margin: 16px 0; }
.story-fig .figure { max-height: 380px; cursor: zoom-in; }
.story-fig figcaption { text-align: center; color: var(--muted); font-size: 0.9rem; margin-top: -6px; }
.story-extra { margin-top: 18px; border-radius: 16px; padding: 14px 16px; background: #f3f0ff; line-height: 1.7; }
.story-extra.act { background: #e7f6ee; }
.story-list a { display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.story-list a + a { margin-top: 8px; }
.q-item.draft { border-color: #f3c7c7; background: #fffafa; }
