/* ===== 쑥쑥스쿨 스타일 ===== */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #eefaf0;
  --card: #ffffff;
  --card2: #f1faf1;
  --ink: #1f2e22;
  --ink2: #566b5b;
  --line: #d6ead8;
  --primary: #2fa968;
  --primary-soft: #cdf2dc;
  --accent: #ff9fb0;
  --warn: #e24b4b;
  --sky: #7cc6ec;
  --sun: #ffcf6b;
  --shadow: 0 8px 22px rgba(60, 120, 80, 0.12);
  --radius: 24px;
}
html[data-dark="1"] {
  --bg: #11201a;
  --card: #1b2d25;
  --card2: #16261f;
  --ink: #e7f1e8;
  --ink2: #9db3a4;
  --line: #294036;
  --primary: #6dd1a0;
  --primary-soft: #244a39;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.6;
  transition: background .3s, color .3s;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; font-size: 18px; }

/* ===== 레이아웃 ===== */
.app { max-width: 460px; margin: 0 auto; min-height: 100vh; position: relative; }
#main { padding: 16px 14px 92px; }
.view { animation: fadein .32s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 0 0 12px; }
h3 { font-size: 18px; margin: 0 0 10px; color: var(--ink); font-weight: 800; }
.muted { color: var(--ink2); font-size: 15px; }

.card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* ===== 버튼 ===== */
.btn-primary {
  background: var(--primary); color: #fff; border-radius: 12px;
  padding: 12px 16px; font-size: 15px; font-weight: 700; width: 100%;
  transition: transform .1s, filter .2s;
}
/* ===== 버튼 (어린이용: 최소 높이 48px, 큰 글씨, 둥글게) ===== */
.btn-primary {
  background: var(--primary); color: #fff; border-radius: 16px;
  padding: 14px 18px; min-height: 52px; font-size: 18px; font-weight: 800; width: 100%;
  white-space: nowrap;
  transition: transform .1s, filter .2s;
}
.btn-primary:active { transform: scale(.97); }
/* 어린이용 눌림 효과: 터치하면 살짝 작아진다 */
.btn-ghost:active, .btn-sm:active, .tab:active, .menu-item:active,
.side-item:active, .seg-btn:active, .mood-pick button:active,
.shop-buy:active, .coin-badge:active, .back-btn:active { transform: scale(.95); }
button { transition: transform .08s ease, filter .2s, background .15s, color .15s; }
.btn-ghost {
  background: var(--primary-soft); color: var(--primary);
  border-radius: 14px; padding: 12px 16px; min-height: 48px; font-weight: 800; font-size: 16px;
}
.btn-sm { padding: 11px 15px; min-height: 48px; border-radius: 14px; font-size: 16px; font-weight: 800; white-space: nowrap;
  background: var(--card2); color: var(--ink); border: 2px solid var(--line); }
.btn-danger { background: var(--warn); color: #fff; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 13px;
  border-radius: 999px; font-size: 14px; font-weight: 800; background: var(--primary-soft); color: var(--primary);
}

/* ===== 폼 ===== */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 15px; color: var(--ink); font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea, .inp {
  width: 100%; padding: 13px 14px; min-height: 48px; border: 2px solid var(--line);
  border-radius: 14px; background: var(--card2); color: var(--ink); font-size: 18px;
}
.field input:focus, .field select:focus, .inp:focus { outline: none; border-color: var(--primary); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.checkbox { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 12px 0; }
.checkbox input { width: 24px; height: 24px; accent-color: var(--primary); }
.err { color: var(--warn); font-size: 15px; min-height: 20px; margin: 6px 0 0; font-weight: 700; }

/* ===== 온보딩 ===== */
.onboard {
  position: fixed; inset: 0; background: linear-gradient(160deg, #d8f0e2, #cfe8f5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
html[data-dark="1"] .onboard { background: linear-gradient(160deg, #16302330, #11201a); background-color: #11201a; }
.onboard-card { background: var(--card); border-radius: 24px; padding: 28px 22px; width: 100%; max-width: 360px; box-shadow: var(--shadow); text-align: center; }
.onboard-tree { font-size: 64px; animation: sway 3s ease-in-out infinite; }
.onboard-card h1 { font-size: 28px; margin: 6px 0; }
.onboard-card .sub { color: var(--ink2); margin: 0 0 18px; }
.onboard-card .field { text-align: left; }

/* ===== 탭바 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 460px; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 0 max(6px, env(safe-area-inset-bottom)); z-index: 20;
}
.tab {
  flex: 1; background: none; display: flex; flex-direction: column; align-items: center;
  gap: 3px; color: var(--ink2); font-size: 13px; font-weight: 800; padding: 8px 0; min-height: 60px; transition: color .2s;
}
.tab .ic { font-size: 26px; transition: transform .2s; }
.tab.active { color: var(--primary); }
.tab.active .ic { transform: translateY(-2px) scale(1.15); }

/* ===== 홈: 나무 ===== */
.tree-wrap { text-align: center; padding: 10px 0 4px; }
.tree-svg { width: 180px; height: 180px; }
.tree-svg .leaf, .tree-svg .crown { transform-origin: center bottom; animation: sway 3.5s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.stage-name { font-size: 20px; font-weight: 800; margin-top: 6px; }
.level-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.level-badge { background: var(--primary); color: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 14px; }
.xpbar { flex: 1; height: 14px; background: var(--primary-soft); border-radius: 999px; overflow: hidden; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--sky)); border-radius: 999px; transition: width .6s ease; }

/* 수업 카드 진행률 링 */
.class-card { display: flex; align-items: center; gap: 14px; }
.ring { width: 72px; height: 72px; flex-shrink: 0; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .5s; }
.ring-label { font-size: 15px; font-weight: 800; fill: var(--ink); }
.class-info b { font-size: 17px; }
.class-info .cd { color: var(--primary); font-weight: 800; font-size: 14px; }

/* 기분 체크인 */
.mood-pick { display: flex; justify-content: space-between; gap: 6px; }
.mood-pick button { flex: 1; font-size: 30px; background: var(--card2); border-radius: 14px; padding: 10px 0; border: 2px solid transparent; transition: transform .15s, border-color .2s; }
.mood-pick button:active { transform: scale(1.15); }
.mood-pick button.sel { border-color: var(--primary); background: var(--primary-soft); }

/* D-day 리스트 */
.dday-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dday-item:last-child { border-bottom: none; }
.dday-tag { font-weight: 800; font-size: 13px; padding: 3px 9px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); min-width: 48px; text-align: center; }
.dday-tag.soon { background: #fde0e0; color: var(--warn); }
html[data-dark="1"] .dday-tag.soon { background: #4a2626; }

/* ===== 시간표 ===== */
.tt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tt th, .tt td { border: 1px solid var(--line); text-align: center; padding: 0; height: 46px; font-size: 11px; }
.tt th { background: var(--card2); color: var(--ink2); font-weight: 700; height: 30px; }
.tt .pcol { width: 26px; background: var(--card2); color: var(--ink2); font-weight: 700; }
.tt td.cell { cursor: pointer; position: relative; color: #3a4a3a; font-weight: 700; }
.tt td.cell .rm { display: block; font-size: 9px; font-weight: 500; opacity: .8; }
.tt td.now { box-shadow: inset 0 0 0 3px var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.legend .chip { background: var(--card2); color: var(--ink); }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ===== 할 일 ===== */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
.filters::-webkit-scrollbar { display: none; height: 0; }
.filters button { white-space: nowrap; }
.filters button.on { background: var(--primary); color: #fff; }
.todo-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: none; }
.todo-check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); background: var(--card2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; }
.todo-check.done { background: var(--primary); border-color: var(--primary); }
.todo-body { flex: 1; min-width: 0; }
.todo-body .tt-title { font-weight: 700; }
.todo-item.done .tt-title { text-decoration: line-through; color: var(--ink2); }
.todo-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 7px; background: var(--card2); color: var(--ink2); font-weight: 700; }
.tag.kind { background: var(--primary-soft); color: var(--primary); }
.tag.pri1 { background: #eef1ee; } .tag.pri2 { background: #fdeec9; color: #a9771a; }
.tag.pri3 { background: #fdd9d9; color: var(--warn); }
.tag.dday { background: var(--sky); color: #0c4a63; }
.tag.dday.soon { background: var(--warn); color: #fff; }
.del-x { background: none; color: var(--ink2); font-size: 18px; padding: 0 4px; }

/* ===== 공부 타이머 ===== */
.timer-wrap { text-align: center; }
.timer-ring { width: 230px; height: 230px; margin: 0 auto; }
.timer-ring .bg { stroke: var(--primary-soft); }
.timer-ring .fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-time { font-size: 42px; font-weight: 800; fill: var(--ink); }
.timer-phase { font-size: 13px; fill: var(--ink2); }
.timer-ctrl { display: flex; gap: 8px; margin-top: 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-box { background: var(--card2); border-radius: 14px; padding: 12px; text-align: center; }
.stat-box b { font-size: 24px; color: var(--primary); } .stat-box span { font-size: 12px; color: var(--ink2); display: block; }
/* 잔디 히트맵 */
.heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-col { display: flex; flex-direction: column; gap: 3px; }
.heat-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--line); }
.heat-cell.l1 { background: #cdebd9; } .heat-cell.l2 { background: #93d8b0; }
.heat-cell.l3 { background: #5bbd87; } .heat-cell.l4 { background: var(--primary); }

/* ===== 성적 ===== */
.gap-row { margin: 8px 0; }
.gap-row .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.gap-bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; position: relative; }
.gap-bar .fill { height: 100%; border-radius: 999px; background: var(--primary); }
.gap-bar .target { position: absolute; top: -3px; width: 2px; height: 18px; background: var(--warn); }

/* ===== 급식 ===== */
.meal-card { border-left: 5px solid var(--primary); }
.meal-card.warn { border-left-color: var(--warn); }
.meal-day { font-weight: 800; margin-bottom: 4px; }
.meal-menu { font-size: 14px; }
.meal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.like-btn { background: none; font-size: 20px; }
.al-warn { color: var(--warn); font-size: 12px; font-weight: 700; margin-top: 5px; }

/* ===== 무드 캘린더 ===== */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--ink2); font-weight: 700; }
.cal-day { aspect-ratio: 1; border-radius: 10px; background: var(--card2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: var(--ink2); cursor: pointer; position: relative; }
.cal-day .em { font-size: 17px; }
.cal-day.empty { background: none; cursor: default; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

/* ===== 암기 카드 ===== */
.deck-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.deck-item:last-child { border-bottom: none; }
.deck-body { flex: 1; }
.mastery { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.mastery > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s; }
.flashcard { perspective: 1000px; height: 220px; margin: 14px 0; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; display: flex; align-items: center; justify-content: center; border-radius: 18px; background: var(--card2); font-size: 24px; font-weight: 700; padding: 20px; text-align: center; box-shadow: var(--shadow); }
.flash-back { transform: rotateY(180deg); background: var(--primary-soft); }

/* ===== 배지 ===== */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-cell { background: var(--card2); border-radius: 16px; padding: 12px 6px; text-align: center; transition: transform .15s; }
.badge-cell.locked { opacity: .4; filter: grayscale(1); }
.badge-cell .em { font-size: 30px; }
.badge-cell .nm { font-size: 11px; font-weight: 700; margin-top: 4px; }

/* 더보기 메뉴 */
.menu-list { }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 18px 6px; min-height: 60px; border-bottom: 2px solid var(--line); font-weight: 800; font-size: 18px; width: 100%; background: none; color: var(--ink); text-align: left; }
.menu-item:last-child { border-bottom: none; }
.menu-item .ic { font-size: 28px; }
.menu-item .arr { margin-left: auto; color: var(--ink2); font-size: 22px; }

/* 부모님·고학년용 접기 섹션 */
.adv-section { margin-top: 4px; }
.adv-section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; min-height: 56px; border-radius: 18px; background: var(--card2); color: var(--ink2);
  font-weight: 800; font-size: 17px; border: 2px dashed var(--line); }
.adv-section > summary::-webkit-details-marker { display: none; }
.adv-section > summary .adv-ic { font-size: 24px; }
.adv-section > summary .adv-hint { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--ink2); }
.adv-section[open] > summary { background: var(--primary-soft); color: var(--primary); border-style: solid; border-color: var(--primary-soft); }
.adv-section[open] > summary .adv-hint { color: var(--primary); }

/* ===== 토스트/팝업/컨페티 ===== */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; z-index: 60; animation: pop .3s; box-shadow: var(--shadow); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.badge-pop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 24px; }
.badge-pop-card { background: var(--card); border-radius: 24px; padding: 28px; text-align: center; max-width: 300px; width: 100%; animation: popin .4s cubic-bezier(.2,1.4,.5,1); }
@keyframes popin { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bp-emoji { font-size: 72px; animation: sway 1.5s ease-in-out infinite; }
.bp-title { color: var(--primary); font-weight: 800; margin: 4px 0; }
.bp-name { font-size: 20px; font-weight: 800; }
.bp-desc { color: var(--ink2); font-size: 14px; margin: 6px 0 16px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 65; width: 100%; height: 100%; }
.fireworks { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100%; height: 100%; }
.fireworks-dim { position: fixed; inset: 0; pointer-events: none; z-index: 39; background: rgba(10,12,24,0.15); opacity: 0; transition: opacity .2s ease; }
.fireworks-dim.show { opacity: 1; }

/* 온보딩 튜토리얼 코치마크 */
.tutorial { position: fixed; inset: 0; z-index: 80; }
.tut-mask { position: absolute; inset: 0; pointer-events: auto; }
.tut-ring { position: absolute; border: 3px solid #ffd86b; border-radius: 18px; box-shadow: 0 0 0 3px rgba(255,216,107,.4); pointer-events: none; transition: all .25s ease; z-index: 1; }
.tut-card { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: calc(100% - 36px); max-width: 420px; height: auto;
  display: flex; flex-direction: column;
  background: var(--card); color: var(--ink); border-radius: 24px; padding: 22px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.35); z-index: 2; transition: top .2s ease; }
.tut-emoji { font-size: 44px; text-align: center; flex: 0 0 auto; }
.tut-title { font-size: 22px; font-weight: 800; text-align: center; margin: 6px 0 4px; flex: 0 0 auto; }
/* 본문만 필요 시 스크롤(버튼 줄은 항상 보이게) */
.tut-text { font-size: 17px; line-height: 1.5; text-align: center; color: var(--ink2); word-break: keep-all; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.tut-dots { display: flex; justify-content: center; gap: 7px; margin: 16px 0; flex: 0 0 auto; }
.tut-dots .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.tut-dots .dot.on { background: var(--primary); transform: scale(1.3); }
.tut-btns { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.tut-btns .btn-sm { flex: 0 0 auto; }
.tut-btns #tut-next { flex: 1; }
.tut-btns #tut-back[disabled] { opacity: .4; }

/* 빈 화면 안내 */
.empty-state { text-align: center; padding: 28px 16px; }
.empty-state .es-emoji { font-size: 56px; line-height: 1; }
.empty-state .es-msg { font-size: 17px; font-weight: 700; color: var(--ink2); margin: 12px 0 16px; word-break: keep-all; }
.empty-state .es-btn { width: auto; display: inline-block; padding-left: 26px; padding-right: 26px; }

/* ===== 모달 ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; z-index: 55; }
.modal-card { background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; animation: slideup .3s ease; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-x { background: var(--card2); width: 32px; height: 32px; border-radius: 50%; font-size: 15px; color: var(--ink2); }

canvas.chart-canvas { max-width: 100%; }

/* ===== 2차 업그레이드 ===== */
/* 공통 뒤로 버튼 헤더 */
.sub-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.back-btn { background: var(--card2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 7px 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.back-btn:active { transform: scale(.96); }
.sub-head h1 { margin: 0; font-size: 22px; }

/* 완료된 할 일 */
.tag.doneflag { background: var(--line); color: var(--ink2); }

/* 홈 하늘 씬 */
/* overflow:hidden 으로 나비·새가 컨테이너 밖에서 나타났다 사라지게 하고,
   container-type:inline-size 로 자식이 컨테이너 너비(cqw)를 기준으로 날 수 있게 한다 */
.sky-scene { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; transition: background 1s; container-type: inline-size; }
.sky-morning { background: linear-gradient(180deg, #ffe8c7 0%, #cfeef0 100%); }
.sky-day { background: linear-gradient(180deg, #bfe3f5 0%, #e8f7ec 100%); }
.sky-sunset { background: linear-gradient(180deg, #ffc49e 0%, #ffd9b0 50%, #c9d9e8 100%); }
.sky-night { background: linear-gradient(180deg, #243b63 0%, #3a4e74 100%); }
.sky-scene .tree-wrap { position: relative; z-index: 2; }
.sky-night .stage-name, .sky-night #xptext { color: #e7f1e8; }
.sky-sunset .stage-name { color: #5a3a28; }
.deco { position: absolute; pointer-events: none; z-index: 1; }
.star { position: absolute; background: #fff; border-radius: 50%; animation: twinkle 2.5s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.sun-moon { position: absolute; top: 16px; right: 20px; width: 46px; height: 46px; border-radius: 50%; z-index: 1; }
.butterfly, .bird, .petal { position: absolute; z-index: 1; font-size: 20px; }
/* 나비·새: 바깥 요소는 컨테이너 너비 기준으로 왼쪽 바깥 → 오른쪽 바깥까지 가로 이동 + 양끝 페이드.
   안쪽 span 은 위아래로 살랑살랑 + 날갯짓(scaleX). 2중 애니메이션으로 자연스럽게 보인다.
   가로 이동 시간(animation-duration)·음수 delay 는 JS 가 하늘 너비에 맞춰 설정한다(속도 일정). */
.butterfly { left: 0; animation: flyX 9s linear infinite; will-change: transform, opacity; }
.bird { left: 0; animation: flyX 14s linear infinite; will-change: transform, opacity; }
.butterfly > span, .bird > span { display: inline-block; }
/* transform 충돌을 피하려고 상하 살랑임(bob)과 날갯짓(flap)을 중첩 span 으로 나눈다.
   바깥 span(> span)=상하 이동(translateY), 안쪽 span(> span > span)=날갯짓(scaleX). */
.butterfly > span { animation: bob 1.6s ease-in-out infinite alternate; }
.bird > span { animation: bobBird 2.4s ease-in-out infinite alternate; }
.butterfly > span > span, .bird > span > span { display: inline-block; }
.butterfly > span > span { animation: flap 0.4s ease-in-out infinite alternate; }
.bird > span > span { animation: flap 0.5s ease-in-out infinite alternate; }
/* 가로 이동: 컨테이너 너비 기준(cqw). 왼쪽 바깥(-40px)에서 오른쪽 바깥(100cqw+40px)까지. 양끝 페이드 */
@keyframes flyX {
  0%   { transform: translateX(-40px); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translateX(calc(100cqw + 40px)); opacity: 0; }
}
@keyframes bob { from { transform: translateY(-8px); } to { transform: translateY(8px); } }
@keyframes bobBird { from { transform: translateY(-5px); } to { transform: translateY(5px); } }
@keyframes flap { from { transform: scaleX(0.6); } to { transform: scaleX(1); } }
.petal { animation: fall 7s linear infinite; top: -20px; }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(190px) rotate(220deg); opacity: 0; } }
.tree-svg.grow { animation: grow .9s cubic-bezier(.2,1.5,.4,1); }
@keyframes grow { 0% { transform: scale(.4); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.tap-hint { font-size: 13px; color: var(--ink2); margin-top: 6px; display: inline-block; padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.72); backdrop-filter: blur(2px); font-weight: 700; }
.sky-night .tap-hint { background: rgba(0,0,0,.38); color: #f0f6f0; }
.sky-sunset .tap-hint { background: rgba(255,255,255,.82); color: #5a3a28; }
html[data-dark="1"] .tap-hint { background: rgba(0,0,0,.35); color: #e7f1e8; }

/* 오늘의 미션 */
.mission-row { display: flex; gap: 10px; justify-content: space-around; }
.mission { text-align: center; flex: 1; }
.mission .mr { width: 68px; height: 68px; }
.mission .mr .bg { stroke: var(--line); }
.mission .mr .fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .6s; }
.mission.done .mr .fg { stroke: #4caf7d; }
.mission .mlabel { font-size: 15px; color: var(--ink); font-weight: 700; margin-top: 6px; line-height: 1.3; word-break: keep-all; }
.mission.done .mlabel { color: var(--primary); font-weight: 800; }
.mission .mem { font-size: 22px; }
.mission-done-banner { text-align: center; margin-top: 10px; padding: 14px 12px; min-height: 48px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-weight: 800; word-break: keep-all; line-height: 1.4; display: flex; align-items: center; justify-content: center; }

/* 성장 로드맵 */
.roadmap-stage { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; margin-bottom: 8px; background: var(--card2); }
.roadmap-stage.current { box-shadow: inset 0 0 0 2px var(--primary); background: var(--primary-soft); }
.roadmap-stage.locked { opacity: .5; }
.roadmap-stage .rs-emoji { font-size: 32px; }
.roadmap-stage .rs-info b { font-size: 15px; } .roadmap-stage .rs-info span { font-size: 12px; color: var(--ink2); display: block; }

/* 성적 갭 색상 */
.gap-bar .fill.ok { background: #4caf7d; } .gap-bar .fill.near { background: #f3a712; } .gap-bar .fill.low { background: var(--warn); }
.gap-diff { font-weight: 800; font-size: 13px; }
.gap-diff.ok { color: #4caf7d; } .gap-diff.near { color: #c6900a; } .gap-diff.low { color: var(--warn); }

/* 급식 칩 */
.menu-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.menu-chip { background: var(--card2); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.menu-chip.al { background: #fde0e0; color: var(--warn); }
html[data-dark="1"] .menu-chip.al { background: #4a2626; color: #ff9b9b; }
.meal-card.today { box-shadow: 0 0 0 2px var(--primary); }
.today-pill { background: var(--primary); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 800; margin-left: 8px; }

/* 집중 사운드 */
.sound-row { display: flex; gap: 8px; margin-top: 10px; }
.sound-btn { flex: 1; background: var(--card2); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 4px; font-size: 13px; font-weight: 700; color: var(--ink); }
.sound-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.sound-btn .ic { display: block; font-size: 20px; }
.vol-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.vol-row input[type=range] { flex: 1; accent-color: var(--primary); }

/* 잔디 히트맵 라벨/범례 */
.heat-wrap { display: flex; gap: 4px; }
.heat-dows { display: flex; flex-direction: column; gap: 3px; padding-top: 16px; }
.heat-dow { height: 13px; font-size: 9px; color: var(--ink2); line-height: 13px; }
.heat-area { flex: 1; overflow-x: auto; }
.heat-months { display: flex; gap: 3px; height: 14px; margin-bottom: 2px; }
.heat-month { font-size: 9px; color: var(--ink2); }
.heat { gap: 3px; }
.heat-col { flex: 1; }
.heat-cell { width: 100%; min-width: 10px; }
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 8px; font-size: 11px; color: var(--ink2); }
.heat-legend .lg { width: 13px; height: 13px; border-radius: 3px; }

/* 주간 리포트 */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.report-box { background: var(--card2); border-radius: 14px; padding: 14px; }
.report-box .rb-label { font-size: 12px; color: var(--ink2); }
.report-box .rb-val { font-size: 22px; font-weight: 800; margin: 2px 0; }
.report-box .rb-delta { font-size: 13px; font-weight: 700; }
.rb-delta.up { color: #4caf7d; } .rb-delta.down { color: var(--warn); } .rb-delta.same { color: var(--ink2); }
.report-comment { background: var(--primary-soft); color: var(--primary); border-radius: 14px; padding: 14px; font-weight: 700; text-align: center; margin-top: 12px; }

/* 시험 플래너 */
.plan-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: none; }
.plan-item.done .pi-subject { text-decoration: line-through; color: var(--ink2); }
.plan-date { font-size: 11px; color: var(--ink2); flex: 0 0 52px; }
.plan-prog { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.plan-prog > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s; }

/* 배지 반짝임 */
.badge-pop-card { position: relative; overflow: visible; }
.spark { position: absolute; font-size: 20px; animation: spark 1.2s ease-out infinite; }
@keyframes spark { 0% { transform: scale(0) rotate(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: scale(1.4) rotate(40deg); opacity: 0; } }
.bp-emoji.shine { animation: shine 1.6s ease-in-out infinite, sway 1.5s ease-in-out infinite; }
@keyframes shine { 0%,100% { filter: drop-shadow(0 0 0 #ffd86b); } 50% { filter: drop-shadow(0 0 16px #ffd86b); } }

/* ===== 학교(NEIS) ===== */
.school-pick { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.school-card { text-align: center; }
.school-emblem { font-size: 48px; }
.school-card h2 { margin: 6px 0; }
.school-meta { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.school-rows { text-align: left; }
.school-rows .sr { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.school-rows .sr:last-child { border-bottom: none; }
.school-rows .sr > span { color: var(--ink2); flex: 0 0 auto; }
.school-rows .sr > b, .school-rows .sr > a { text-align: right; word-break: break-all; }
.school-rows .sr a { color: var(--primary); font-weight: 700; }

/* 학사일정 달력 (행사 이름 표시 + 선택일 상세) */
.cal-day.sch-day { aspect-ratio: auto; min-height: 46px; align-items: stretch; justify-content: flex-start; padding: 3px 4px; }
.cal-day.sch-day .cd-num { font-size: 11px; font-weight: 700; align-self: flex-start; }
.cal-day.sch-day.has-ev { background: var(--primary-soft); }
.cal-day.sch-day.sel { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day .cd-ev { display: none; font-size: 9px; line-height: 1.15; color: var(--primary); font-weight: 700; margin-top: 2px; overflow: hidden; width: 100%; word-break: break-all; }
.cal-day .cd-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-top: 2px; }
.sch-detail { margin-top: 12px; }
.sch-detail:empty { margin-top: 0; }
.sch-detail-head { font-weight: 800; font-size: 14px; margin-bottom: 6px; color: var(--primary); }
.sch-detail-row { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sch-detail-row:last-child { border-bottom: none; }

/* 태블릿·PC: 달력 칸에 행사 이름을 직접 표시(점 숨김) */
@media (min-width: 768px) {
  .cal-day.sch-day { min-height: 66px; }
  .cal-day .cd-ev { display: block; }
  .cal-day.sch-day.has-ev .cd-dot { display: none; }
}

/* ===== 보상 시스템 ===== */
/* 홈 코인 배지 */
.coin-badge { position: absolute; top: 12px; left: 12px; z-index: 3; background: rgba(255,255,255,.9);
  border-radius: 999px; padding: 8px 14px; font-size: 16px; font-weight: 800; color: #b5820a;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 4px; min-height: 40px; }
.coin-badge b { font-size: 18px; }
html[data-dark="1"] .coin-badge { background: rgba(0,0,0,.4); color: #ffd86b; }
.sky-night .coin-badge { background: rgba(0,0,0,.4); color: #ffe08a; }
/* 홈 나무 아이템 */
.tree-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 2px; min-height: 8px; }
/* 상점 아이템을 나무 위 정해진 자리에 직접 배치 */
.tree-stage { position: relative; width: 180px; height: 180px; margin: 0 auto; }
.tree-stage #tree-box { position: absolute; inset: 0; }
.tree-stage .tree-items { position: absolute; inset: 0; margin: 0; display: block; pointer-events: none; min-height: 0; }
.tree-stage .tree-item {
  position: absolute; transform: translate(-50%, -50%); transform-origin: center bottom;
  font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}
.tree-item { font-size: 26px; }
.tree-item.swaying { animation: itemSway 3.2s ease-in-out infinite; }
@keyframes itemSway {
  0%, 100% { transform: translate(-50%, -50%) rotate(-6deg); }
  50%      { transform: translate(-50%, -50%) rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .tree-item.swaying { animation: none; }
  .tree-svg .leaf, .tree-svg .crown { animation: none; }
  /* 하늘 나비·새·꽃잎·별: 움직임 정지(나비·새는 보이도록 opacity 고정) */
  .butterfly, .bird, .petal, .star { animation: none; opacity: 1; }
  /* 정지 시 왼쪽 끝에 겹치지 않도록 서로 다른 위치에(JS가 --rest-left 로 지정) */
  .butterfly, .bird { left: var(--rest-left, 50%); }
  .butterfly > span, .bird > span,
  .butterfly > span > span, .bird > span > span { animation: none; }
}

/* 보상 화면 상단 */
.reward-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.coin-big { background: linear-gradient(135deg, #fff0c2, #ffe08a); color: #8a6200; border-radius: 18px;
  padding: 10px 16px; font-weight: 800; display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow); }
.coin-big b { font-size: 26px; }
.coin-big span { font-size: 13px; font-weight: 700; opacity: .8; }

/* 세그먼트 탭 */
.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg-btn { flex: 1; min-height: 50px; border-radius: 16px; background: var(--card2); color: var(--ink2);
  border: 2px solid var(--line); font-size: 16px; font-weight: 800; }
.seg-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 상점 그리드 */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shop-item { position: relative; background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 16px 12px; text-align: center; box-shadow: var(--shadow); }
.wish-btn { position: absolute; top: 8px; right: 8px; background: none; font-size: 22px; line-height: 1; padding: 4px; min-height: 0; }
.wish-btn.on { transform: scale(1.1); }

/* 홈 찜 진행 막대 */
.wish-card { background: linear-gradient(135deg, #fff6d8, #ffe6a8); border-radius: 20px; padding: 14px 16px; margin-bottom: 18px; color: #7a5a00; box-shadow: var(--shadow); }
html[data-dark="1"] .wish-card { background: linear-gradient(135deg, #3a3418, #2c2a1a); color: #ffe08a; }
.wish-card .wc-top { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; }
.wish-card .wc-emoji { font-size: 30px; }
.wish-card .wc-bar { height: 16px; background: rgba(0,0,0,.12); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.wish-card .wc-fill { height: 100%; background: linear-gradient(90deg, #ffb347, #ff8a5c); border-radius: 999px; transition: width .5s; }
.wish-card .wc-buy { width: 100%; margin-top: 8px; }
.shop-item.owned { border-color: var(--primary); background: var(--primary-soft); }
.shop-emoji { font-size: 44px; }
.shop-name { font-weight: 800; font-size: 17px; margin-top: 4px; }
.shop-desc { font-size: 13px; margin: 4px 0 10px; min-height: 34px; }
.shop-buy { font-size: 16px; }
.shop-have { color: var(--primary); font-weight: 800; padding: 12px 0; }

/* 출석 도장판 */
.stamp-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0; }
.stamp { background: var(--card2); border-radius: 14px; padding: 8px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 2px solid transparent; }
.stamp.on { background: var(--primary-soft); }
.stamp.today { border-color: var(--primary); }
.stamp-dow { font-size: 12px; color: var(--ink2); font-weight: 700; }
.stamp-mark { font-size: 22px; }

/* 쿠폰 */
.coupon-row, .redeem-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 2px solid var(--line); }
.coupon-row:last-child, .redeem-row:last-child { border-bottom: none; }
.coupon-emoji { font-size: 32px; }
.coupon-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.coupon-info b { font-size: 17px; }
.coupon-info span { font-size: 14px; }
.coupon-btns { display: flex; align-items: center; gap: 6px; }

/* 칭찬 팝업 */
.praise-pop { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 68; pointer-events: none; opacity: 0; transition: opacity .3s; }
.praise-pop.show { opacity: 1; }
.praise-card { background: var(--card); border-radius: 26px; padding: 26px 30px; text-align: center; box-shadow: var(--shadow); transform: scale(.7); transition: transform .35s cubic-bezier(.2,1.4,.5,1); }
.praise-pop.show .praise-card { transform: scale(1); }
.praise-emoji { font-size: 60px; }
.praise-text { font-size: 20px; font-weight: 800; color: var(--primary); margin-top: 6px; }

/* 홈 그리드 (기본: 폰 1열) */
.home-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.home-grid > .card { margin-bottom: 14px; }

/* 사이드 내비 (기본 숨김 - 폰) */
.side-nav { display: none; }
.side-item { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; color: var(--ink2); font-weight: 700; font-size: 14px; padding: 11px 12px; border-radius: 12px; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.side-item .ic { font-size: 20px; flex: 0 0 24px; text-align: center; }
.side-item.active { background: var(--primary-soft); color: var(--primary); }
.side-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; padding: 6px 12px 14px; }
.side-logo .lg-tree { font-size: 26px; }
.side-mini { background: var(--card2); border-radius: 14px; padding: 12px; margin: 0 8px 12px; text-align: center; }
.side-mini .sm-tree { font-size: 40px; }
.side-mini .sm-lv { font-weight: 800; margin-top: 4px; }
.side-mini .xpbar { margin-top: 6px; }

/* 가로 스크롤 방지 */
html, body { max-width: 100%; overflow-x: hidden; }
#main { overflow-x: hidden; }
/* 차트 고정 높이 래퍼: maintainAspectRatio:false 차트가 올바른 높이를 갖도록
   canvas를 감싸는 .chart-box 가 높이를 정하고, canvas 는 박스를 가득 채운다 */
.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box > canvas, canvas.chart-canvas { max-width: 100% !important; width: 100% !important; height: 100% !important; display: block; }
table.tt { max-width: 100%; }

/* ===== 태블릿: 768~1199px (좌측 레일 + 2열) ===== */
@media (min-width: 768px) and (max-width: 1199px) {
  .tabbar { display: none; }
  .app { max-width: 100%; display: block; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; left: 0; bottom: 0; width: 76px; background: var(--card); border-right: 1px solid var(--line); padding: 10px 8px; z-index: 20; overflow-y: auto; }
  .side-nav .side-item { flex-direction: column; gap: 2px; font-size: 10px; padding: 10px 2px; text-align: center; }
  .side-nav .side-item .ic { flex: none; }
  .side-nav .side-item .side-label { font-size: 10px; line-height: 1.1; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .side-nav .side-logo, .side-nav .side-mini { display: none; }
  #main { margin-left: 76px; padding: 20px 20px 40px; width: calc(100% - 76px); }
  #main > .view { max-width: 980px; margin-left: auto; margin-right: auto; }
  .home-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .home-grid > .card { margin-bottom: 0; }
  .sky-scene { grid-column: 1 / -1; }
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; max-width: 540px; }
  .badge-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ===== PC: 1200px 이상 (사이드바 + 최대 1280 + 3열) ===== */
@media (min-width: 1200px) {
  .tabbar { display: none; }
  .app { max-width: 100%; display: block; }
  .side-nav { display: flex; flex-direction: column; gap: 3px; position: fixed; top: 0; left: 0; bottom: 0; width: 240px; background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; z-index: 20; overflow-y: auto; }
  #main { margin-left: 240px; width: calc(100% - 240px); padding: 26px 28px 48px; }
  #main > .view { max-width: 1280px; margin-left: auto; margin-right: auto; }
  .home-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
  .home-grid > .card { margin-bottom: 0; }
  .sky-scene { grid-column: 1 / 2; grid-row: 1 / 3; align-self: stretch; }
  .study-wrap { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
  .tt-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
  .tt-wrap > .card { margin-bottom: 0; }
  .chart-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .chart-2col > .card { margin-bottom: 0; }
  .badge-grid { grid-template-columns: repeat(6, 1fr); }
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; max-width: 560px; }
}

/* ===== PC hover 효과 (마우스 환경) ===== */
@media (min-width: 1200px) and (hover: hover) {
  .card { transition: box-shadow .2s, transform .2s; }
  .card:hover { box-shadow: 0 10px 26px rgba(60, 90, 60, 0.12); }
  .menu-item:hover, .side-item:hover { background: var(--primary-soft); color: var(--primary); }
  .btn-primary:hover { filter: brightness(1.05); }
  .btn-ghost:hover, .btn-sm:hover { filter: brightness(.97); }
  .badge-cell:hover, .school-pick:hover, .meal-card:hover { transform: translateY(-2px); }
  .tt td.cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
  .mood-pick button:hover { transform: scale(1.08); }
}

/* ===== 계정 · 2단계 인증 UI ===== */
.ob-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; color: var(--ink2); font-size: 13px; }
.ob-divider::before, .ob-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pw-wrap { position: relative; display: block; }
.pw-wrap .inp { padding-right: 48px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; font-size: 20px; padding: 6px; line-height: 1; min-height: 0; }
.code-inp { text-align: center; letter-spacing: 6px; font-size: 22px; font-weight: 800; }
.totp-qr { display: flex; justify-content: center; margin: 12px 0; }
.totp-qr img, .totp-qr canvas { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 12px; }
.totp-key { text-align: center; font-family: monospace; font-size: 18px; font-weight: 800; letter-spacing: 2px; background: var(--card2); border-radius: 12px; padding: 10px; word-break: break-all; margin-bottom: 10px; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.recovery-grid .rc { font-family: monospace; font-size: 16px; font-weight: 800; background: var(--card2); border-radius: 10px; padding: 10px; text-align: center; letter-spacing: 1px; }
.acc-btns { display: flex; flex-direction: column; gap: 8px; }
.acc-btns .btn-ghost, .acc-btns .btn-sm { width: 100%; }

/* 닉네임 입력 + 🎲 버튼 */
.nick-row { display: flex; gap: 8px; align-items: stretch; }
.nick-row .inp, .nick-row input { flex: 1; }
.dice-btn { flex: 0 0 auto; width: 52px; border-radius: 14px; background: var(--card2);
  border: 2px solid var(--line); font-size: 24px; line-height: 1; }
.dice-btn:active { transform: scale(.94); }

/* ===== 안정성: 오프라인 표시 / 첫 로딩 오류 ===== */
.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: #c0392b; color: #fff; text-align: center;
  padding: 8px 12px; font-size: 15px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.offline-bar.hidden { display: none; }
.boot-error {
  position: fixed; inset: 0; z-index: 70; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(10,12,24,.55);
}
.boot-error-card {
  background: var(--card, #fff); color: var(--text, #222);
  border-radius: 20px; padding: 28px 24px; max-width: 320px; width: 100%;
  text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.boot-error-card .be-emoji { font-size: 44px; }
.boot-error-card .be-msg { font-size: 17px; margin: 10px 0 18px; word-break: keep-all; }

/* ===== 2단계 신규 UI (코인 통계 / 친구 / 부모 리포트 / 스켈레톤) ===== */
/* 로딩 스켈레톤 */
.skeleton { background: linear-gradient(90deg, var(--card2) 25%, rgba(0,0,0,.05) 37%, var(--card2) 63%);
  background-size: 400% 100%; animation: skel 1.2s ease-in-out infinite; border-radius: 10px; }
.skel-line { height: 16px; margin: 8px 0; }
.skel-box { height: 120px; margin-top: 10px; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* 코인/부모 요약 숫자 카드 */
.coin-summary { display: flex; justify-content: space-around; text-align: center; gap: 10px; flex-wrap: wrap; }
.cs-num { font-size: 22px; font-weight: 800; }
.cs-num.up, .up { color: #2e9e67; }
.cs-num.down, .down { color: #c0392b; }
.src-list { list-style: none; padding: 0; margin: 8px 0 0; }
.src-list li { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 16px; }
.src-list li:last-child { border-bottom: none; }

/* 친구 랭킹 */
.friend-code { font-size: 30px; font-weight: 800; letter-spacing: 6px; text-align: center;
  background: var(--card2); border: 2px dashed var(--line); border-radius: 14px; padding: 12px; margin: 6px 0; }
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-row.mine { background: var(--card2); border-radius: 10px; }
.rank-medal { font-size: 18px; width: 28px; text-align: center; }
.rank-name { flex: 1; font-weight: 700; }
.rank-stat { font-size: 14px; color: var(--muted); white-space: nowrap; }
.rank-me { background: #6dc78f; color: #fff; border-radius: 8px; padding: 1px 6px; font-size: 12px; }
.btn-xs { font-size: 13px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card2); white-space: nowrap; min-height: 32px; }

/* 부모 리포트 기분 흐름 */
.pa-mood-row { display: flex; justify-content: space-between; font-size: 26px; }
.pa-mood { flex: 1; text-align: center; }

/* 스크린리더 전용(접근성): 보이지 않지만 읽어줌 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 키보드 포커스 표시(접근성): 모든 상호작용 요소에 또렷한 외곽선 */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 3px solid #3a86ff; outline-offset: 2px; border-radius: 6px;
}

/* 암기 카드 SM-2 평가 버튼 (다시/어려움/알맞음/쉬움) */
.srs-grade { display: flex; gap: 6px; margin-top: 10px; }
.srs-grade button { flex: 1; min-height: 48px; font-weight: 700; color: #fff; border: none; }
.srs-again { background: #d14b4b; }
.srs-hard  { background: #d98a2b; }
.srs-good  { background: #2e9e67; }
.srs-easy  { background: #2f72c9; }
.srs-grade button:active { transform: scale(.96); }

/* ===== 핵심 루프: 오늘의 공부 계획 · 주간 목표 게이지 ===== */
.goal-card { margin-bottom: 14px; }
.goal-top { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 16px; }
.goal-top b { color: var(--primary); }
.goal-bar { height: 18px; background: var(--primary-soft); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.goal-fill { height: 100%; background: linear-gradient(90deg, #4fc98a, #2fa968); border-radius: 999px; transition: width .6s ease; }
.goal-sub { font-size: 13px; }

.plan-card { margin-bottom: 14px; }
.plan-head { display: flex; align-items: center; justify-content: space-between; }
.plan-head h3 { margin: 0; }
.plan-refresh { flex: 0 0 auto; min-width: 44px; }
.plan-sub { font-size: 13px; margin: 2px 0 10px; }
.plan-tip { font-size: 12px; margin-top: 10px; }
.plan-block {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--card2); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px;
}
.plan-block.done { opacity: .6; }
.plan-block .pb-left { flex: 1 1 auto; min-width: 0; }
.plan-block .pb-subj { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.plan-block .pb-subj b { word-break: keep-all; }
.plan-block .pb-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.plan-block .pb-min { font-size: 14px; color: var(--primary); font-weight: 700; white-space: nowrap; }
.plan-block .pb-reason { font-size: 13px; color: var(--muted, #647061); margin-top: 4px; word-break: keep-all; }
/* 전역 .btn-primary { width:100% } 가 flex 자식에도 적용돼 .pb-left 를 0폭으로 눌러
   과목명이 한 글자씩 줄바꿈되던 버그 수정: 폭을 내용에 맞추고 flex 로 안 늘어나게. */
.plan-block .pb-start { flex: 0 0 auto; width: auto; align-self: center; min-height: 48px; white-space: nowrap; }
.plan-block .pb-done { flex: 0 0 auto; align-self: center; font-weight: 700; color: var(--primary); white-space: nowrap; }
/* 좁은 화면(폰)에서는 블록을 세로로 쌓고 버튼은 전체 폭 */
@media (max-width: 480px) {
  .plan-block { flex-direction: column; align-items: stretch; }
  .plan-block .pb-start { width: 100%; align-self: stretch; }
  .plan-block .pb-done { align-self: flex-start; }
}

/* ===== 주간 돌아보기(회고) ===== */
.reflect-metric { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.reflect-metric .rm-box { flex: 1 1 120px; background: var(--card2); border-radius: 16px; padding: 14px; text-align: center; }
.reflect-metric .rm-box b { font-size: 26px; display: block; color: var(--primary); }
.reflect-metric .rm-box span { font-size: 13px; color: var(--muted, #647061); }
.reflect-dow { display: flex; gap: 6px; align-items: flex-end; height: 90px; margin: 10px 0; }
.reflect-dow .rd-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.reflect-dow .rd-bar { width: 70%; background: linear-gradient(180deg, #6dd1a0, #2fa968); border-radius: 6px 6px 0 0; min-height: 3px; }
.reflect-dow .rd-label { font-size: 12px; margin-top: 4px; color: var(--muted, #647061); }
.reflect-pred { background: var(--primary-soft); border-radius: 16px; padding: 14px; margin: 10px 0; font-size: 15px; }
html[data-dark="1"] .reflect-pred { background: #223a2e; }

/* ===== 쑥쑥스쿨 소개(루프 그림) ===== */
.about-loop { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.about-step { display: flex; align-items: center; gap: 12px; background: var(--card2); border-radius: 16px; padding: 14px; }
.about-step .as-emoji { font-size: 30px; flex: 0 0 auto; }
.about-step .as-title { font-weight: 800; font-size: 16px; }
.about-step .as-desc { font-size: 13px; color: var(--muted, #647061); margin-top: 2px; word-break: keep-all; }
.about-arrow { text-align: center; font-size: 20px; color: var(--primary); line-height: 0.6; }
.about-diff { background: var(--card2); border-radius: 16px; padding: 14px; margin-top: 10px; }
.about-diff li { margin: 6px 0; word-break: keep-all; }

/* ===== 학교 위치 지도 ===== */
#school-map-wrap { margin-top: 4px; }
.school-map { height: 240px; width: 100%; border-radius: 16px; overflow: hidden; z-index: 0; }
.map-skeleton { height: 240px; border-radius: 16px; }
.map-loading { text-align: center; margin-top: 8px; }
@media (min-width: 900px) {
  .school-map, .map-skeleton { height: 320px; }
}
.map-addr { margin: 12px 0 6px; font-size: 15px; word-break: keep-all; }
.map-links { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.map-links .map-link { flex: 1 1 140px; text-align: center; text-decoration: none; min-height: 48px;
  display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.map-copy { width: 100%; margin-top: 2px; }
.map-source { font-size: 11px; margin-top: 8px; text-align: right; }
/* 다크모드: 타일은 그대로 두되(지도 가독성), 카드 배경과 조화되게 테두리만 */
html[data-dark="1"] .school-map { border: 1px solid var(--line); }
/* Leaflet 팝업이 다크모드에서도 읽히게 */
html[data-dark="1"] .leaflet-popup-content-wrapper,
html[data-dark="1"] .leaflet-popup-tip { background: var(--card); color: var(--ink); }
