/* 틈틈漢字 — 짬 학습(한 손·엄지·흔들리는 버스)을 기준으로 한 화면 */
:root {
  --bg: #f5f2ea; --paper: #ffffff; --ink: #16203a; --sub: #5c6478; --line: #e3ded3; --soft: #efe9dd;
  --accent: #e0482c; --btn: #16203a; --btn-ink: #f7f0e1;
  --ok: #1e7b4b; --ok-bg: #e2f3e8; --mid: #9a6300; --mid-bg: #fbefd6; --bad: #c8372d; --bad-bg: #fbe5e2;
  --fs: 19px; --hanja: min(42vw, 13rem);
  --serif: "Noto Serif KR", "Noto Serif CJK KR", "Source Han Serif K", "AppleMyungjo", "Batang", serif;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1526; --paper: #182038; --ink: #eef0f5; --sub: #a5adc2; --line: #2a3350; --soft: #202a47;
    --btn: #f7f0e1; --btn-ink: #16203a; --accent: #ff6b4d;
    --ok: #6fd69a; --ok-bg: #173526; --mid: #f2c460; --mid-bg: #3a2f17; --bad: #ff8a7a; --bad-bg: #3d1f1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1526; --paper: #182038; --ink: #eef0f5; --sub: #a5adc2; --line: #2a3350; --soft: #202a47;
  --btn: #f7f0e1; --btn-ink: #16203a; --accent: #ff6b4d;
  --ok: #6fd69a; --ok-bg: #173526; --mid: #f2c460; --mid-bg: #3a2f17; --bad: #ff8a7a; --bad-bg: #3d1f1c;
  color-scheme: dark;
}
:root[data-font="XL"] { --fs: 23px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.5; overscroll-behavior-y: contain; }
#app { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(var(--pad-b, 110px) + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.3; margin: .2em 0 .45em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: .95rem; color: var(--sub); font-weight: 600; }
.hz { font-family: var(--serif); font-weight: 900; }
.muted { color: var(--sub); } .small { font-size: .82rem; } .center { text-align: center; }
.boot { display: grid; place-items: center; height: 80vh; }
.boot img { width: 96px; height: 96px; border-radius: 22px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 0 0 12px; }
button { font: 700 1rem var(--sans); min-height: 56px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink); padding: 8px 14px; cursor: pointer; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px; touch-action: manipulation; user-select: none; }
button:active { transform: scale(.98); }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button[disabled]:not(.ok):not(.bad) { opacity: .4; }
.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); min-height: 68px; font-size: 1.12rem; }
.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.link { background: none; border: none; color: var(--sub); min-height: 44px; width: auto; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 999px; background: var(--soft);
  font-size: .82rem; font-weight: 600; }
.chip.warn { background: var(--mid-bg); color: var(--mid); }

/* 홈 */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand b { font: 900 1.25rem var(--serif); letter-spacing: .02em; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.today .big { font-size: 2.4rem; font-weight: 900; line-height: 1.1; }
.today .big small { font-size: 1rem; color: var(--sub); font-weight: 600; }
.bar { height: 12px; border-radius: 6px; background: var(--soft); overflow: hidden; position: relative; margin: 10px 0; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 6px; transition: width .3s; opacity: .45; }
.bar i.s { background: var(--ok); opacity: 1; }
.bar.one i { opacity: 1; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats3 div { background: var(--soft); border-radius: 12px; padding: 8px; text-align: center; }
.stats3 b { display: block; font-size: 1.2rem; } .stats3 span { font-size: .75rem; color: var(--sub); }
details.card summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.gbar { margin: 8px 0; } .gbar .row { font-size: .8rem; } .gbar .row span:last-child { text-align: right; color: var(--sub); }

/* 아래 고정 도크 — 엄지가 닿는 곳 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
  background: linear-gradient(to top, var(--bg) 80%, rgba(0,0,0,0)); padding: 16px 12px calc(10px + env(safe-area-inset-bottom)); }
.dock .in { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.dock .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dock .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dock .opts button { min-height: 68px; font-size: 1.12rem; line-height: 1.2; padding: 6px; word-break: keep-all; }
.dock .opts button.hz { font-size: 2.1rem; }
.dock .grade button { min-height: 76px; font-size: 1.15rem; flex-direction: column; gap: 0; }
.dock .grade small { font-size: .7rem; font-weight: 600; opacity: .8; }
body.tabs-on .dock { bottom: calc(64px + env(safe-area-inset-bottom)); padding-bottom: 8px; }

/* 학습 화면 */
.sess-top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 2px 0 8px; }
.sess-top .link { font-size: 1.5rem; padding: 0 6px; min-width: 44px; }
.sess-top .prog { flex: 1; height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.sess-top .prog i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.sess-top .cnt { font-size: .82rem; color: var(--sub); min-width: 64px; text-align: right; }
.stage { min-height: 46vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; touch-action: pan-y; transition: transform .15s; cursor: pointer; }
.stage .kind { font-size: .82rem; color: var(--sub); font-weight: 700; margin-bottom: 2px; }
.stage .glyph { font: 900 var(--hanja)/1.05 var(--serif); }
.stage .glyph.sm { font-size: min(30vw, 8rem); }
.stage .glyph.w { font-size: min(17vw, 5rem); letter-spacing: .04em; }
.stage .hint { color: var(--sub); font-size: .85rem; margin-top: 4px; }
.stage.nudge-r { transform: translateX(16px) rotate(1.2deg); } .stage.nudge-l { transform: translateX(-16px) rotate(-1.2deg); }
.ans { width: 100%; text-align: left; margin-top: 6px; }
.he { font-size: 1.9rem; font-weight: 900; text-align: center; line-height: 1.25; }
.he small { display: block; font-size: .8rem; font-weight: 600; color: var(--sub); }
.story { font-size: 1rem; background: var(--soft); border-radius: 14px; padding: 10px 13px; margin: 10px 0; text-align: left; }
.story b { font-family: var(--serif); color: var(--accent); }
.story .blank { display: inline-block; min-width: 2.2em; border-bottom: 2px solid var(--accent); color: transparent; }
.exs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
/* 예시 한자어(組立 조립 …): 짬 학습 중 흘끗 봐도 읽히게 크게 — 한자는 획이 많아 한 단계 더 크게 */
.exs { gap: 8px; margin-top: 10px; }
.exs .chip { font-size: 1.12rem; font-weight: 600; padding: 6px 14px; gap: 6px; line-height: 1.3; }
.exs .w { font-family: var(--serif); font-weight: 900; font-size: 1.22em; letter-spacing: .02em; }
.words p { margin: 6px 0; font-size: 1.02rem; } .words b.hz { font-size: 1.4rem; margin-right: 4px; }
.verse { border-left: 4px solid var(--accent); padding: 4px 12px; margin: 10px 0; text-align: left; }
.verse .o { font-family: var(--serif); font-size: 1.2rem; line-height: 1.75; }
.verse mark { background: var(--mid-bg); color: inherit; border-radius: 4px; padding: 0 2px; }
.verse .k { color: var(--sub); font-size: .9rem; }
.speak { width: auto; min-height: 40px; padding: 4px 14px; font-size: .85rem; margin: 6px auto 0; border-width: 1px; }
.fam { font: 900 3.4rem var(--serif); letter-spacing: .12em; }
.pending { position: fixed; top: 8px; right: 10px; z-index: 30; }

/* 걸으며 보기 */
.walk .glyph { font-size: min(60vw, 19rem); }
.walk .he { font-size: 2.3rem; min-height: 3.2rem; }

/* 찾기 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.grid button { flex-direction: column; min-height: 92px; padding: 4px; gap: 0; }
.grid .hz { font-size: 2.1rem; line-height: 1.2; }
.grid small { font-size: .68rem; color: var(--sub); font-weight: 500; }
.grid button[data-box="1"], .grid button[data-box="2"] { border-color: var(--mid); }
.grid button[data-box="3"], .grid button[data-box="4"] { border-color: var(--accent); }
.grid button[data-box="5"], .grid button[data-box="6"] { border-color: var(--ok); background: var(--ok-bg); }
input, select { font: 1rem var(--sans); min-height: 54px; width: 100%; border: 2px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink); padding: 8px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button { width: auto; min-height: 46px; padding: 4px 14px; border-width: 1px; }
.chips button.on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
label.f { display: block; margin: 12px 0 4px; font-weight: 700; font-size: .9rem; }

/* 탭 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); z-index: 13;
  background: var(--paper); border-top: 1px solid var(--line); padding: 2px 4px env(safe-area-inset-bottom); }
.tabs button { border: none; flex-direction: column; gap: 0; min-height: 60px; font-size: .78rem; background: none; border-radius: 12px; }
.tabs .ti { font: 900 1.3rem var(--serif); }
.tabs button.on { color: var(--accent); }
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 40; max-width: 92vw; }
.toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 16px 16px 24px; }
@media (min-width: 760px) { .dock .opts { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* v1.3 — 아이디·다시 하기·알림 */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 { display: flex; gap: 8px; } .row2 input { flex: 1; } .row2 button { width: auto; min-width: 92px; }
.note { background: var(--soft); border-radius: 14px; padding: 10px 14px; margin: 0 0 10px; font-size: .9rem; }
.note.ok { background: var(--ok-bg); color: var(--ok); } .note.warn { background: var(--mid-bg); color: var(--mid); }
.note .link { display: inline; min-height: 0; padding: 0; color: inherit; text-decoration: underline; }
.danger { border-color: var(--bad); color: var(--bad); background: var(--paper); }
#ck.danger { background: var(--bad); color: #fff; }
.code { font: 800 1.9rem/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .12em;
  text-align: center; padding: 10px; border: 2px dashed var(--line); border-radius: 14px; margin: 8px 0; user-select: all; }
.card details { margin-top: 6px; } .card details summary { cursor: pointer; font-weight: 600; min-height: 36px; }
.card ol { padding-left: 1.2em; margin: 6px 0 10px; }
.sess-top .undo { color: var(--accent); font-size: .85rem; padding: 0 6px; white-space: nowrap; }
button { word-break: keep-all; }
button.stack { flex-direction: column; gap: 2px; line-height: 1.3; }
button.stack small { font-size: .78rem; font-weight: 600; opacity: .75; }
.days { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin: 0 2px 12px; }
.days i { width: 16px; height: 16px; border-radius: 50%; background: var(--soft); border: 2px solid var(--line); }
.days i.on { background: var(--accent); border-color: var(--accent); }
.days i.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.days span { font-size: .72rem; color: var(--sub); margin-left: 4px; }
a.chip.help { color: var(--ink); text-decoration: none; }
a.btnlink { display: flex; align-items: center; justify-content: center; min-height: 56px; border-radius: 16px; border: 2px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 700; }
.reps { margin: 8px auto 0; font-size: 1.05rem; letter-spacing: .12em; color: var(--accent); display: flex; justify-content: center; align-items: center; gap: 8px; }
.reps span { letter-spacing: 0; font-size: .78rem; color: var(--sub); font-weight: 700; }
.mine { background: var(--soft); border-radius: 12px; padding: 8px 12px; margin: 10px 0; text-align: center; }
.stage { min-height: max(46vh, calc(100svh - var(--pad-b, 110px) - 64px)); touch-action: manipulation; }
