/* 법무사 시험공부 — "법전과 인주": 종이 바탕, 남색(주), 인주색(오답·과락)만 강조 */
:root {
  --bg: #F6F4EF;          /* 종이 */
  --card: #FFFFFF;
  --text: #18212D;        /* 먹 */
  --muted: #5E6673;       /* 보조 글자 (종이 위 5.6:1) */
  --line: #E3DFD6;
  --line-soft: #EFECE5;
  --primary: #1F3A5F;     /* 남색 */
  --primary-soft: #E8EDF4;
  --on-primary: #FFFFFF;
  --bad: #A63A24;         /* 인주 */
  --bad-soft: #F6E6E1;
  --warn: #8A4B00;
  --warn-soft: #FFF1DC;
  --radius: 14px;
  --tabbar-h: 60px;
  --sans: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --serif: "Noto Serif KR", "AppleMyungjo", "Batang", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161C;
    --card: #1B212A;
    --text: #E9ECF1;
    --muted: #A3ABB8;
    --line: #2C3440;
    --line-soft: #242B35;
    --primary: #9DB8DC;
    --primary-soft: #223047;
    --on-primary: #12161C;
    --bad: #F0907C;
    --bad-soft: #3A2420;
    --warn: #F2B866;
    --warn-soft: #3A2E1C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--sans);
  font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--text);
  word-break: keep-all; overflow-wrap: anywhere;   /* 한글은 어절 단위로 줄바꿈 */
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) max(12px, calc((100% - 640px) / 2 + 12px)) 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.topbar h1 { font-family: var(--serif); font-size: 19px; font-weight: 700; margin: 0 4px; line-height: 1.3; }
.spacer { flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: none; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; cursor: pointer; padding: 0;
}

/* 본문: 아래 탭바 높이만큼 여백을 main에 둠 (body 높이를 고정하지 않음) */
main {
  max-width: 640px; margin: 0 auto; outline: none;
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

/* ---------- 하단 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; padding: 0 max(4px, calc((100% - 640px) / 2)) env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none;
}
/* 선택된 메뉴: 위쪽 막대 + 아이콘 뒤 알약 배경 + 진한 글자 */
.tabbar a { position: relative; -webkit-tap-highlight-color: transparent; }
.tabbar a .i { width: 52px; height: 28px; padding: 3px 14px; border-radius: 999px; box-sizing: border-box; transition: background .15s, color .15s; }
.tabbar a::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: transparent; transition: background .15s; }
.tabbar a.active { color: var(--primary); font-weight: 800; }
.tabbar a.active .i { background: var(--primary); color: var(--on-primary); }
.tabbar a.active::before { background: var(--primary); }
.tabbar a:not(.active):hover .i { background: var(--primary-soft); }
.tabbar a:focus { outline: none; }
.tabbar a:focus-visible .i { outline: 2px solid var(--primary); outline-offset: 2px; }

/* AI 출제 표시 · 오늘의 AI 퀴즈 */
.badge.ai { background: #EDE7FB; color: #6D4AC2; }
@media (prefers-color-scheme: dark) { .badge.ai { background: #2E2547; color: #C4B2F2; } }
.daily-cta { display: flex; align-items: center; gap: 8px; margin-top: 8px; text-align: left; border-color: #B9A6EC; }
.daily-cta .grow { font-weight: 700; }
.daily-cta.done { opacity: .75; }
.choices.ox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices.ox button { justify-content: center; font-size: 18px; font-weight: 700; min-height: 64px; }
.choices.ox button .n { display: none; }

/* ---------- 카드 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 12px;
}
.card h2 { font-size: 17px; margin: 0 0 12px; line-height: 1.4; }
.title { font-family: var(--serif); font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.small-text { font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.hero {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.hero .muted { color: inherit; opacity: .85; }
.hero .dday { font-family: var(--serif); font-size: 34px; font-weight: 700; color: inherit; line-height: 1; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { text-align: center; padding: 12px 4px; border-radius: 12px; background: var(--primary-soft); }
.stat b { display: block; font-size: 24px; line-height: 1.3; color: var(--primary); }
.stat small { color: var(--muted); font-size: 13px; }
.stat.bad b { color: var(--bad); }
.stat.bad { background: var(--bad-soft); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft); min-height: 56px;
}
.list li:last-child { border-bottom: 0; }
.list a { color: inherit; text-decoration: none; }
.list b { font-weight: 700; }
.group-label { margin: 16px 0 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.badge {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap;
}
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.plain { background: var(--line-soft); color: var(--muted); }
.dday { font-weight: 700; color: var(--primary); white-space: nowrap; }
.dday.soon { color: var(--bad); }

/* ---------- 버튼·입력 ---------- */
button, .btn {
  font: inherit; font-size: 15px; cursor: pointer; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  min-height: 48px; padding: 10px 16px; text-decoration: none; line-height: 1.4;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
button.good { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
button.bad, .btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 700; }
button.small, .btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.icon { width: 44px; min-height: 44px; padding: 0; flex: none; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px;
}
.btn-block { width: 100%; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

input, textarea, select {
  font: inherit; font-size: 16px; /* 16px 미만이면 iOS가 확대함 */
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
}
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
label { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin: 12px 0 6px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.form-grid label { margin-top: 0; }

/* ---------- 플래시카드 ---------- */
.flash {
  min-height: 280px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; font-size: 19px; line-height: 1.65; cursor: pointer; white-space: pre-wrap;
  user-select: none;
}
.flash .side { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.flash .answer { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); color: var(--primary); width: 100%; font-weight: 500; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.progress > i { display: block; height: 100%; background: var(--primary); transition: width .2s; }

/* ---------- 문제 ---------- */
.question { font-size: 17px; line-height: 1.75; font-weight: 500; white-space: pre-wrap; }
.choices { display: grid; gap: 8px; margin-top: 12px; }
.choices button {
  justify-content: flex-start; align-items: flex-start; text-align: left;
  padding: 12px 14px; white-space: pre-wrap; font-size: 16px; line-height: 1.6;
  border-width: 1.5px; min-height: 52px;
}
.choices button .n { font-weight: 700; color: var(--muted); flex: none; }
.choices button .t { flex: 1; }
.choices button.correct { border-color: var(--primary); background: var(--primary-soft); }
.choices button.correct .n { color: var(--primary); }
.choices button.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choices button.wrong .n { color: var(--bad); }
.choices button .tag { font-size: 12px; font-weight: 700; flex: none; }
.choices button.correct .tag { color: var(--primary); }
.choices button.wrong .tag { color: var(--bad); }
.feedback { margin-top: 12px; }
.feedback.ok { border-color: var(--primary); }
.feedback.no { border-color: var(--bad); }
.feedback .head { font-weight: 700; }
.feedback.ok .head { color: var(--primary); }
.feedback.no .head { color: var(--bad); }

.timer-face { font-family: var(--serif); font-size: 64px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; margin: 12px 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--line-soft); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { border: 0; background: none; color: var(--muted); min-height: 40px; border-radius: 9px; font-weight: 500; }
.seg button.on { background: var(--card); color: var(--primary); font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.empty { text-align: center; padding: 32px 12px; color: var(--muted); }
.empty svg.i { width: 40px; height: 40px; color: var(--primary); margin-bottom: 8px; }
.empty h2 { color: var(--text); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center; transition: .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 최근 7일 막대 */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; }
.week div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 104px; font-size: 12px; color: var(--muted); }
.week span { font-size: 12px; font-weight: 700; color: var(--text); min-height: 18px; }
.week i { width: 70%; max-width: 28px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 3px; margin: 2px 0 6px; }
.week i.zero { background: var(--line); }
.week div.today { color: var(--primary); font-weight: 700; }

/* 과목별 정답률 막대 */
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 3em; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); }
.bar.low .fill { background: var(--bad); }
.bar .v { text-align: right; font-weight: 700; color: var(--primary); }
.bar.low .v { color: var(--bad); }
.bar.none .v { color: var(--muted); font-weight: 500; }

code { font-size: 14px; background: var(--line-soft); padding: 1px 5px; border-radius: 5px; }

/* 1년 기록 (포도알) */
.year-title { font-size: 15px; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.year { display: flex; gap: 6px; --cell: 11px; --gap: 3px; }
.year-days, .year-grid { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--gap); }
.year-days { padding-top: 20px; font-size: 11px; color: var(--muted); line-height: var(--cell); flex: none; }
.year-scroll { overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.year-months { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell); column-gap: var(--gap); height: 20px; font-size: 11px; color: var(--muted); }
.year-months span { white-space: nowrap; }
.year-grid { grid-auto-flow: column; grid-auto-columns: var(--cell); width: max-content; }
.year i, .legend i { display: block; width: var(--cell, 11px); height: var(--cell, 11px); border-radius: 50%; }
.l0 { background: var(--line-soft); box-shadow: inset 0 0 0 1px var(--line); }
.l1 { background: color-mix(in srgb, var(--primary) 30%, var(--card)); }
.l2 { background: color-mix(in srgb, var(--primary) 55%, var(--card)); }
.l3 { background: color-mix(in srgb, var(--primary) 78%, var(--card)); }
.l4 { background: var(--primary); }
.year-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-top: 8px; }
.legend { display: inline-flex; align-items: center; gap: 3px; }
.legend i { display: inline-block; }
.year i.fu { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.year i.now { box-shadow: 0 0 0 1.5px var(--card), 0 0 0 3px var(--text); }
.year i.ex, .year-exam i.ex { background: var(--bad); box-shadow: 0 0 0 1.5px var(--card), 0 0 0 3px var(--bad); }
.year i.ex-past { box-shadow: 0 0 0 1.5px var(--card), 0 0 0 3px var(--bad); }
.year-grid { padding: 3px; margin: -3px; }
.year-exam { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--text); }
.year-exam i { display: block; width: 11px; height: 11px; border-radius: 50%; flex: none; margin: 0 2px; }
.year-exam b { color: var(--bad); }

/* AI 모의고사 */
.mock-cta { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.mock-entry { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.mock-entry > .i:first-child { color: var(--primary); width: 26px; height: 26px; }
.mock-entry > .i:last-child { transform: rotate(180deg); color: var(--muted); }
.mock-bar { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 8px 0 10px; margin: -8px 0 8px; border-bottom: 1px solid var(--line); }
.mock-time { font-family: var(--serif); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); min-width: 4.2em; }
.mock-time.low { color: var(--bad); }
.choices button.picked { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choices button.picked .n { color: var(--primary); }
.choices button:disabled { cursor: default; opacity: 1; }
.omr { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; margin-bottom: 14px; }
.omr button { min-height: 52px; padding: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 16px; font-weight: 700; color: var(--primary); }
.omr button small { font-size: 12px; font-weight: 500; color: var(--muted); }
.omr button.on { background: var(--primary-soft); border-color: var(--primary); }
.omr button.cur { box-shadow: 0 0 0 2px var(--primary); }
details.review summary { cursor: pointer; line-height: 1.6; list-style: none; }
details.review summary::-webkit-details-marker { display: none; }
details.review.no { border-left: 3px solid var(--bad); }

/* 기출 중요도 이유 */
.imp-why { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); font-size: 14px; line-height: 1.5; text-align: left; font-weight: 400; }
.imp-why b { color: var(--warn); }
.week.week14 { grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
.week.week14 div { font-size: 10px; letter-spacing: -0.3px; }
.week.week14 span { font-size: 11px; }
.check-btn { margin-top: 12px; }
.login-hint { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); border: 1px dashed var(--primary); }
.login-hint .i { flex: none; color: var(--primary); }
.acct-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.acct-stats div { background: var(--primary-soft); border-radius: 10px; padding: 8px 4px; }
.acct-stats b { display: block; font-size: 17px; }
.acct-stats span { font-size: 12px; color: var(--muted); }
