/* 매일 심화챌린지 — 학원 브랜드(네이비 + 샴페인 골드) 기반
   레이아웃: 폰은 상단 바 + 하단 탭, PC는 같은 화면을 가운데 760px 열로 */
:root {
  --bg: #f2f3f7; --surface: #ffffff; --surface-2: #f7f8fb; --ink: #16213b; --ink-2: #4c5672; --ink-3: #8a92a8;
  --line: #e1e4ec; --navy: #16213b; --navy-ink: #ffffff; --gold: #a8874c; --gold-soft: #f4ecdc;
  --ok: #1d7f55; --ok-soft: #e3f3ea; --bad: #b9382f; --bad-soft: #fbe7e5; --late: #a86a12; --late-soft: #fbf0dc;
  --paper: #ffffff; --shadow: 0 1px 2px rgba(22,33,59,.06), 0 4px 16px rgba(22,33,59,.05);
  --f-body: 'Pretendard', 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --f-num: 'IBM Plex Mono', ui-monospace, 'Consolas', monospace;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0d1322; --surface: #151d31; --surface-2: #1b2440; --ink: #e9ecf4; --ink-2: #b4bbcf; --ink-3: #7d86a0;
  --line: #27314d; --navy: #d6b97f; --navy-ink: #16213b; --gold: #d6b97f; --gold-soft: #2a2a2a;
  --ok: #5cc996; --ok-soft: #12392a; --bad: #f08a80; --bad-soft: #3d1c1a; --late: #e6b25e; --late-soft: #3a2c12;
  --shadow: none; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0d1322; --surface: #151d31; --surface-2: #1b2440; --ink: #e9ecf4; --ink-2: #b4bbcf; --ink-3: #7d86a0;
  --line: #27314d; --navy: #d6b97f; --navy-ink: #16213b; --gold: #d6b97f; --gold-soft: #2a2a2a;
  --ok: #5cc996; --ok-soft: #12392a; --bad: #f08a80; --bad-soft: #3d1c1a; --late: #e6b25e; --late-soft: #3a2c12;
  --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }

/* 상단 바 */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand b { font-size: 16px; letter-spacing: -.01em; }
.brand small { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .who { margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.nav a.on { background: var(--navy); color: var(--navy-ink); }
.tabs-bottom { display: none; }

main { max-width: 760px; margin: 0 auto; padding-block: 18px 96px; padding-inline: 16px; display: grid; gap: 16px; }
main.wide { max-width: 1040px; }
main > .btn { justify-self: start; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.sub { color: var(--ink-3); font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--gold); font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* 버튼 */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; border-radius: 12px; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 입력 */
label.f { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.in { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 15px; }
.in:focus { border-color: var(--gold); outline: none; }
textarea.in { min-height: 120px; font-family: var(--f-num); font-size: 13px; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }
.msg-ok { color: var(--ok); font-size: 13px; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; display: grid; gap: 16px; }
.login .mark { width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: #fff; flex: none; }

/* 오늘의 문제 */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.stats > div { padding: 12px 8px; text-align: center; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; }
.stats b { display: block; font-family: var(--f-num); font-size: 20px; line-height: 1.2; }
.stats span { font-size: 11.5px; color: var(--ink-3); }
.stats .streak b { color: var(--gold); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.lv-심화 { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.lv-실력 { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip.lv-기본 { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.late { background: var(--late-soft); color: var(--late); border-color: transparent; }

.paper { background: var(--paper); border-radius: 10px; padding: 14px; border: 1px solid var(--line); }
.paper img { display: block; width: 100%; height: auto; }
.paper .ph { aspect-ratio: 5 / 1; background: linear-gradient(90deg, #eef0f5, #f7f8fb, #eef0f5); border-radius: 6px; }

.choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.choice { aspect-ratio: 1 / 1; max-height: 64px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 22px; cursor: pointer; display: grid; place-items: center; }
.choice.on { border-color: var(--navy); background: var(--navy); color: var(--navy-ink); }

.answer-box { display: grid; gap: 10px; }
.ans-input { font-family: var(--f-num); font-size: 20px; padding: 13px 14px; letter-spacing: .02em; }
.preview { min-height: 46px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; gap: 10px; font-size: 20px; overflow-x: auto; }
.preview .lab { font-size: 12px; color: var(--ink-3); flex: none; }
.preview.warn { color: var(--bad); font-size: 13px; }
.keypad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.key { padding: 10px 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 17px; }
.key small { font-size: 11px; color: var(--ink-3); }
.key.wide { grid-column: span 2; font-size: 13px; }
.guide-toggle { background: none; border: 0; color: var(--gold); font-weight: 700; cursor: pointer; padding: 0; font-size: 13px; }
.guide { border-top: 1px dashed var(--line); padding-top: 10px; }
.guide table { width: 100%; border-collapse: collapse; font-size: 13px; }
.guide th, .guide td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide th { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.guide code { font-family: var(--f-num); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.guide ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions.one { grid-template-columns: 1fr; }
.actions .btn { flex-direction: column; gap: 2px; padding: 13px 10px; }
.actions .btn small { font-size: 11.5px; font-weight: 500; opacity: .8; }
.actions .btn:disabled { opacity: .6; }
.peers { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.peers span { display: block; }
.wrong-list { display: grid; gap: 6px; }
.wrong-item { display: grid; grid-template-columns: 1fr auto auto 16px; gap: 10px; align-items: center; text-align: left; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 14px; }
.wrong-item:hover { border-color: var(--gold); }
.wrong-item .go { color: var(--ink-3); font-size: 18px; }
.offnote { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--late-soft); color: var(--ink); font-size: 14px; border: 1px solid transparent; }
.offnote > b { color: var(--late); font-size: 12px; letter-spacing: .04em; }
.tracklink { margin-left: 8px; font-weight: 600; letter-spacing: 0; color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.track { position: relative; display: grid; gap: 4px; text-align: left; padding: 14px 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.track b { font-size: 18px; }
.track span { font-size: 12.5px; color: var(--ink-3); }
.track i { position: absolute; top: 10px; right: 10px; font-style: normal; font-size: 11px; color: var(--gold); font-weight: 700; }
.track.on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.track:disabled { opacity: .45; cursor: not-allowed; border-style: dashed; }
.track.has-today { background: var(--ok-soft); border-color: transparent; }
.track.has-today .tstate { color: var(--ok); font-weight: 700; }
.track.no-today .tstate { color: var(--ink-3); }
.track.on { border-color: var(--navy) !important; }
.confirm { border: 1px solid var(--gold); background: var(--gold-soft); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.result { border-radius: 12px; padding: 16px; display: grid; gap: 6px; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.bad { background: var(--bad-soft); color: var(--bad); }
.result.neutral { background: var(--gold-soft); color: var(--ink); font-size: 16px; }
.result b { font-size: 20px; }
.tbl a { text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--gold); }
.result .mine { color: var(--ink-2); font-size: 14px; }
.waiting { text-align: center; padding: 34px 18px; display: grid; gap: 8px; justify-items: center; }
.waiting .clock { font-family: var(--f-num); font-size: 34px; font-weight: 700; color: var(--gold); }

/* 수식 미리보기 */
.mx { display: inline-flex; align-items: center; flex-wrap: nowrap; font-family: 'Times New Roman', 'Noto Serif KR', serif; font-style: normal; }
.mx .fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 2px; font-size: .85em; }
.mx .fr > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }
.mx .fr > span:last-child { padding: 0 3px; }
.mx .sq { display: inline-flex; align-items: flex-start; }
.mx .sq > i { font-style: normal; }
.mx .sq > span { border-top: 1.5px solid currentColor; padding: 0 2px; margin-top: 3px; }
.mx sup { font-size: .65em; }

/* 달력 */
.cal { max-width: 460px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dh { text-align: center; font-size: 11.5px; color: var(--ink-3); padding-bottom: 2px; }
.cal .d { aspect-ratio: 1 / 1; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-family: var(--f-num); font-size: 13px; color: var(--ink-3); position: relative; padding: 0; }
.cal .d.has { cursor: pointer; color: var(--ink); }
.cal .d.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 700; }
.cal .d.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 700; }
.cal .d.ok2 { background: var(--ok-soft); color: var(--ok); border: 1.5px dashed var(--ok); }
.cal .d.late { background: var(--late-soft); color: var(--late); border-color: transparent; }
.cal .d.miss { border-style: dashed; }
.cal .d.today { outline: 2px solid var(--gold); outline-offset: -2px; }
.cal .d.empty { visibility: hidden; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* 표 */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { font-size: 12px; color: var(--ink-3); font-weight: 600; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.top3 td { background: var(--gold-soft); }
.medal { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #fff; font-weight: 800; font-size: 12px; }
.warnline { color: var(--late); font-weight: 600; }
.thumb { max-height: 34px; max-width: 220px; display: block; background: #fff; border-radius: 4px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .2s; }
.notice { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-size: 13px; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--navy); color: var(--navy-ink); }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; }
.demo-bar { background: var(--gold); color: #fff; font-size: 12.5px; text-align: center; padding: 6px 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.demo-bar button { border: 1px solid rgba(255,255,255,.7); background: transparent; color: #fff; border-radius: 99px; padding: 2px 10px; cursor: pointer; font-size: 12px; }
.demo-bar button.on { background: #fff; color: var(--gold); }

.installbar { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 40; display: flex; align-items: center; gap: 10px;
  background: var(--navy); color: var(--navy-ink); border-radius: 14px; padding: 10px 10px 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 520px; margin: 0 auto; }
.installbar .ib-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; background: #fff; }
.installbar .ib-text { flex: 1; min-width: 0; display: grid; gap: 1px; font-size: 13px; line-height: 1.4; }
.installbar .ib-text > b { font-size: 14px; }
.installbar .ib-text span { opacity: .85; }
.installbar .ib-share { display: inline-flex; align-items: center; gap: 2px; vertical-align: -2px; }
.installbar .ib-btn { flex: none; background: var(--gold); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; }
.installbar .ib-x { flex: none; background: transparent; border: 0; color: inherit; opacity: .7; font-size: 16px; padding: 6px; cursor: pointer; }
@media (min-width: 641px) { .installbar { bottom: 16px; } }
@media (max-width: 640px) {
  .nav { display: none; }
  .tabs-bottom { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabs-bottom a { text-decoration: none; text-align: center; font-size: 12px; color: var(--ink-3); padding: 6px 2px; border-radius: 10px; }
  .tabs-bottom a.on { color: var(--navy); font-weight: 800; }
  .tabs-bottom a b { display: block; width: 20px; height: 3px; border-radius: 3px; margin: 0 auto 4px; background: transparent; }
  .tabs-bottom a.on b { background: var(--gold); }
  .stats b { font-size: 18px; }
  .keypad { grid-template-columns: repeat(6, 1fr); }
  .card { padding: 15px; }
  .paper { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
