:root {
  --bg: #f4f7ff; --card: #ffffff; --ink: #22304a; --muted: #6b7a99; --line: #dfe6f5;
  --pri: #4c6ef5; --pri-d: #364fc7; --good: #12b886; --warn: #f59f00; --bad: #fa5252; --sun: #ffd43b;
  --fs: 17px; --r: 18px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
html.big { --fs: 20px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: var(--fs)/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; touch-action: manipulation; }
input { font: inherit; user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
#app { min-height: 100vh; padding-bottom: calc(var(--sab) + 16px); }
.boot { display: grid; place-items: center; min-height: 100vh; font-size: 24px; color: var(--muted); }

.page { max-width: 980px; margin: 0 auto; padding: 14px 16px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; }
.btn { padding: 11px 18px; border-radius: 14px; background: #fff; border: 2px solid var(--line); font-weight: 700; min-height: 48px; box-shadow: 0 3px 0 var(--line); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.pri { background: var(--pri); color: #fff; border-color: var(--pri-d); box-shadow: 0 4px 0 var(--pri-d); }
.btn.red { color: var(--bad); border-color: #ffc9c9; }
.btn.big { font-size: 1.1em; padding: 13px 24px; min-height: 56px; }
.sec { margin: 6px 0; font-size: 1.2em; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: 0 4px 14px rgba(40, 60, 120, .08); margin: 12px 0; }
.card h3 { margin: 0 0 10px; font-size: 1em; }
.muted { color: var(--muted); font-size: .85em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 프로필 */
.hero { margin: 24px 0 10px; } .hero h1 { margin: 6px 0 2px; color: var(--pri-d); } .hero p { margin: 0; color: var(--muted); }
.owl { font-size: 72px; line-height: 1; animation: bob 2.4s ease-in-out infinite; } .owl.sm { font-size: 46px; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-3deg); } }
.plist { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 760px; margin: 0 auto; } .plist .pcard { width: 160px; }
.pcard { background: #fff; border-radius: var(--r); padding: 18px 10px; display: grid; gap: 2px; justify-items: center; box-shadow: 0 4px 14px rgba(40, 60, 120, .1); border: 3px solid transparent; }
.pcard:hover { border-color: var(--pri); } .pcard .av { font-size: 48px; } .pcard small { color: var(--muted); }
.pcard.add { border: 3px dashed var(--line); box-shadow: none; } .pcard.add .av { color: var(--pri); }
#modal { position: fixed; inset: 0; background: rgba(20, 30, 60, .45); display: grid; place-items: center; z-index: 30; padding: 16px; }
.sheet { background: #fff; border-radius: 22px; padding: 20px; width: min(520px, 100%); max-height: 92vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 12px; } .lab { display: block; font-weight: 700; margin: 12px 0 6px; font-size: .9em; }
.sheet input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); font-size: 1.05em; }
.avs, .grades { display: flex; flex-wrap: wrap; gap: 6px; }
.avs button { font-size: 30px; width: 54px; height: 54px; border-radius: 14px; background: var(--bg); border: 3px solid transparent; }
.grades button { padding: 9px 14px; border-radius: 12px; background: var(--bg); font-weight: 700; border: 3px solid transparent; }
.avs .on, .grades .on { border-color: var(--pri); background: #e7ecff; }

/* 홈 */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: calc(var(--sat) + 8px) 16px 8px; background: rgba(244, 247, 255, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 6px; font-weight: 800; } .me .av { font-size: 30px; }
.lvl { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--pri-d); font-size: .9em; }
.lvl small { color: var(--muted); font-weight: 600; white-space: nowrap; }
.xpbar, .pbar, .mbar { flex: 1; height: 10px; border-radius: 6px; background: #e3e9f7; overflow: hidden; min-width: 50px; }
.xpbar i, .pbar i, .mbar i { display: block; height: 100%; background: linear-gradient(90deg, #74c0fc, var(--pri)); border-radius: 6px; transition: width .4s; }
.mbar { display: block; height: 6px; margin-top: 4px; max-width: 160px; } .mbar i { background: var(--good); }
.streak { font-weight: 800; color: #e8590c; white-space: nowrap; }
.tree { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, #e7f5ff, #ebfbee); border-radius: 24px; padding: 18px; margin: 8px 0 14px; }
.plant { font-size: 84px; line-height: 1; animation: bob 3s ease-in-out infinite; }
.tree p { margin: 4px 0 10px; color: var(--muted); } .tree .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.gtabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.gtabs button { flex: 1; min-width: 74px; padding: 9px 6px; border-radius: 14px; background: #fff; font-weight: 800; display: grid; border: 3px solid transparent; }
.gtabs button small { color: var(--muted); font-weight: 600; font-size: .75em; }
.gtabs button.on { border-color: var(--pri); background: #e7ecff; color: var(--pri-d); }
.ghead { display: flex; justify-content: space-between; margin: 14px 4px 6px; } .ghead span { color: var(--muted); font-size: .9em; }
.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.path button { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border-radius: var(--r); padding: 12px 14px; box-shadow: 0 3px 10px rgba(40, 60, 120, .07); border: 3px solid transparent; }
.path .num { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: #e7ecff; color: var(--pri-d); flex: none; }
.path .tx { flex: 1; display: grid; } .path .tx small { color: var(--muted); font-size: .8em; }
.path .st { white-space: nowrap; font-size: .9em; } .path em { font-style: normal; color: #fff; background: var(--warn); padding: 4px 10px; border-radius: 10px; font-weight: 800; }
.path .done .num { background: var(--good); color: #fff; }
.path .lock button { opacity: .55; } .path .lock .num { background: #eee; }
.path .cur button { border-color: var(--warn); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px rgba(245, 159, 0, .18); } }
.foot { justify-content: center; margin-top: 18px; }

/* 수업 */
.ltop { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: calc(var(--sat) + 8px) 16px 8px; background: rgba(244, 247, 255, .95); border-bottom: 1px solid var(--line); }
.ltop .x { width: 44px; height: 44px; border-radius: 12px; background: #fff; font-size: 20px; font-weight: 900; color: var(--muted); }
.ltitle { display: grid; line-height: 1.25; } .ltitle small { color: var(--muted); font-size: .75em; }
.lprog { flex: 1; display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-weight: 800; color: var(--pri-d); }
.lprog .pbar { max-width: 220px; height: 14px; }
.tutor { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.bubble { position: relative; flex: 1; background: #fff; border-radius: 20px; padding: 14px 16px; box-shadow: 0 4px 14px rgba(40, 60, 120, .09); font-size: 1.05em; border: 3px solid #e7ecff; }
.bubble::before { content: ""; position: absolute; left: -12px; top: 18px; border: 8px solid transparent; border-right: 12px solid #e7ecff; }
.tutor.good .bubble { border-color: #b2f2bb; background: #f4fdf6; } .tutor.good .bubble::before { border-right-color: #b2f2bb; }
.tutor.hint .bubble { border-color: #ffd8a8; background: #fff9f0; } .tutor.hint .bubble::before { border-right-color: #ffd8a8; }
.say { font-size: 22px; width: 44px; height: 44px; border-radius: 12px; background: #fff; flex: none; }
.lvtag { display: inline-block; margin-left: 6px; font-size: .75em; color: var(--warn); font-weight: 800; }
.stage { margin: 8px 0; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 10px 0; } .dots i { width: 9px; height: 9px; border-radius: 50%; background: #d0d9ee; } .dots i.on { background: var(--pri); width: 22px; border-radius: 6px; }
.q { font-size: 1.25em; font-weight: 800; line-height: 1.7; }
.sol { margin-top: 10px; padding: 10px 12px; background: #fff9db; border-radius: 12px; font-size: .95em; line-height: 1.6; }
.problem .card { text-align: center; }
.ans { margin: 8px 0; }
.fields { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.box { min-width: 76px; height: 64px; padding: 0 10px; border-radius: 16px; background: #fff; border: 3px solid var(--line); font-size: 1.6em; font-weight: 900; display: grid; place-items: center; position: relative; }
.box.wide { min-width: 150px; }
.box.cur { border-color: var(--pri); box-shadow: 0 0 0 4px #dbe4ff; }
.box .ph { display: none; position: absolute; font-size: .42em; color: #a5b0c8; font-weight: 600; }
.box.empty .ph { display: block; } .box.empty .v { display: none; }
.box.whole { min-width: 64px; } .fracbox { display: grid; gap: 4px; justify-items: center; }
.fracbox .box { height: 54px; min-width: 70px; font-size: 1.4em; } .fracbox .bar { width: 86px; height: 4px; background: var(--ink); border-radius: 2px; }
.unit { font-weight: 800; font-size: 1.15em; color: var(--muted); }
.tip { text-align: center; color: var(--muted); font-size: .8em; margin: 6px 0 0; }
.ans.good .box { border-color: var(--good); background: #ebfbee; } .ans.bad .box { border-color: var(--bad); background: #fff5f5; }
.shake { animation: shake .4s; } @keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ch { min-height: 64px; border-radius: 16px; background: #fff; border: 3px solid var(--line); font-size: 1.2em; font-weight: 800; box-shadow: 0 3px 0 var(--line); padding: 8px; }
.ch.sel { border-color: var(--pri); } .ch.no { opacity: .35; text-decoration: line-through; } .ch.right { border-color: var(--good); background: #ebfbee; }
.ans.good .ch.sel { border-color: var(--good); background: #ebfbee; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; margin: 10px auto 0; }
.key { height: 60px; border-radius: 16px; background: #fff; font-size: 1.5em; font-weight: 800; box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); }
.key:active { transform: translateY(3px); box-shadow: none; background: #e7ecff; }
.key.sm { font-size: 1em; } .key.blank { visibility: hidden; }

/* 분수 표기 */
.fr { display: inline-grid; vertical-align: middle; text-align: center; margin: 0 3px; line-height: 1.15; font-size: .92em; }
.fr i { font-style: normal; padding: 0 3px; } .fr i:first-child { border-bottom: 2px solid currentColor; }

/* 그림 */
.vis { display: flex; justify-content: center; margin: 10px 0; }
.vsvg { width: 100%; height: auto; }
.emo { flex-wrap: wrap; gap: 4px; font-size: 34px; align-items: center; }
.emo .grp { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 220px; justify-content: center; }
.emo .grp.box { border: 2px dashed #a5b4fc; border-radius: 14px; padding: 4px 6px; margin: 3px; height: auto; min-width: 0; font-size: inherit; background: none; }
.emo .op { font-size: 30px; color: var(--pri); margin: 0 6px; }
.emo .gone { opacity: .3; position: relative; } .emo .gone::after { content: "✕"; position: absolute; inset: 0; color: var(--bad); font-size: 26px; display: grid; place-items: center; }
.vtable { border-collapse: collapse; font-size: .95em; } .vtable th, .vtable td { border: 2px solid var(--line); padding: 6px 12px; text-align: center; font-size: 1.1em; }
.vtable th { background: #e7ecff; }

/* 결과 */
.result h1 { margin: 6px 0; } .big-e { font-size: 80px; margin-top: 20px; animation: pop .5s; }
.stars { font-size: 48px; } .stars span { display: inline-block; opacity: .2; filter: grayscale(1); }
.stars span.on { opacity: 1; filter: none; animation: pop .5s backwards; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.3); } }
.gain { font-size: 1.3em; font-weight: 900; color: var(--pri-d); margin: 10px 0; }
.lvup { display: block; color: #e8590c; animation: pop .6s .8s backwards; }
.result .tutor { max-width: 640px; margin: 10px auto; text-align: left; }

/* 보호자 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0; }
.stats div { background: #fff; border-radius: var(--r); padding: 14px 8px; text-align: center; display: grid; box-shadow: 0 4px 14px rgba(40, 60, 120, .08); }
.stats b { font-size: 1.5em; color: var(--pri-d); } .stats small { color: var(--muted); }
.chart { display: flex; gap: 4px; align-items: flex-end; height: 130px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.chart i { width: 70%; background: linear-gradient(#74c0fc, var(--pri)); border-radius: 5px 5px 0 0; min-height: 2px; }
.chart small { font-size: .6em; color: var(--muted); margin-top: 3px; }
.gline { display: flex; align-items: center; gap: 10px; margin: 6px 0; } .gline span { width: 46px; font-weight: 700; } .gline small { width: 90px; color: var(--muted); }
.list { margin: 0; padding-left: 18px; } .list li { margin: 6px 0; } .list small { color: var(--muted); margin-left: 6px; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; } .set small { display: block; color: var(--muted); font-size: .8em; }
.tg { min-width: 64px; padding: 8px 12px; border-radius: 20px; background: #e9ecef; font-weight: 800; }
.tg.on { background: var(--good); color: #fff; }

#toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 20px); transform: translateX(-50%); display: grid; gap: 6px; z-index: 50; pointer-events: none; }
#toast div { background: #22304a; color: #fff; padding: 10px 18px; border-radius: 20px; font-weight: 700; font-size: .9em; }
#toast div.err { background: var(--bad); }

/* 넓은 화면(태블릿 가로): 문제와 입력을 좌우로 */
@media (min-width: 860px) {
  .problem { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
  .problem .right { position: sticky; top: 80px; }
}
@media (max-width: 560px) {
  .two, .stats { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr; }
  .plant { font-size: 64px; } .tree { flex-direction: column; text-align: center; } .tree .acts { justify-content: center; }
  .lvl small { display: none; } .owl.sm { font-size: 36px; }
  .key { height: 54px; }
}

/* 가족 계정 */
.cloudline { margin-top: 22px; color: var(--muted); font-size: .9em; }
.link { color: var(--pri); font-weight: 800; text-decoration: underline; }
.errtxt { color: var(--bad); font-size: .85em; display: block; }
.scrollx { overflow-x: auto; }
.rtable { border-collapse: collapse; width: 100%; font-size: .85em; }
.rtable th, .rtable td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.rtable th { color: var(--muted); font-weight: 700; }
.rtable tr.miss td:nth-child(4) { color: var(--bad); font-weight: 700; }
.rtable tr.first td:nth-child(4) { color: var(--good); font-weight: 700; }
