:root {
  --navy: #1f3a5f;
  --navy-2: #24527a;
  --teal: #0f5c56;
  --teal-2: #2bb3a3;
  --teal-bg: #e7f6f4;
  --brown: #8a4b08;
  --brown-bg: #fff8f0;
  --purple: #5c3d7a;
  --purple-bg: #f4effa;
  --ok: #1d8a4e;
  --ok-bg: #e6f6ec;
  --bad: #c0392b;
  --bad-bg: #fdecea;
  --warn-bg: #fff4e5;
  --ink: #1d2733;
  --gray: #5c6b7a;
  --line: #d5dde8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 70, .06), 0 4px 16px rgba(20, 40, 70, .06);
  --font: "Pretendard", "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--navy-2); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--navy); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: #fff; color: var(--navy); font-weight: 800;
  border-bottom: 3px solid var(--teal-2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { opacity: .75; font-size: 12px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #dfe8f3; text-decoration: none; padding: 8px 12px; border-radius: 999px;
  white-space: nowrap; font-size: 15px; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: #fff; color: var(--navy); font-weight: 700; }
.nav a .nav-ico { margin-right: 4px; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}

.me-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 4px 12px 4px 6px; cursor: pointer; font-weight: 600;
}
.me-chip:hover { background: rgba(255,255,255,.2); }
.me-avatar { font-size: 22px; line-height: 1; }
.me-name { max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #9fb3c8; }
.sync-dot.saved { background: #4ade80; }
.sync-dot.saving { background: #facc15; }
.sync-dot.offline, .sync-dot.expired, .sync-dot.conflict, .sync-dot.error { background: #f87171; }

.tabbar { display: none; }

.menu-list { display: grid; gap: 8px; margin-top: 12px; }
.menu-item {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  text-decoration: none; color: var(--ink); cursor: pointer; font-size: 22px;
}
.menu-item b { font-size: 16px; }
.menu-item span { grid-column: 2; font-size: 13px; }
.menu-item:hover { border-color: var(--navy-2); background: #f6f9fd; }

/* 사용자 고르기 */
.who { max-width: 820px; margin: 0 auto; }
.who.narrow { max-width: 560px; }
.who-title { text-align: center; font-size: 30px; margin-top: 12px; }
.who-sub { text-align: center; margin-top: -4px; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 22px 0; }
.who-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; border-radius: 18px;
  background: #fff; border: 2px solid transparent; box-shadow: var(--shadow); cursor: pointer; text-decoration: none; color: var(--ink);
  font-size: 17px; transition: transform .1s, border-color .15s;
}
.who-card:hover { transform: translateY(-2px); border-color: var(--teal-2); }
.who-card.current { border-color: var(--teal-2); }
.who-card.add { border: 2px dashed var(--line); box-shadow: none; background: transparent; }
.who-avatar { font-size: 54px; line-height: 1.1; }
.who-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.course-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.course-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; text-align: center;
}
.course-btn.on { border-color: var(--teal); background: var(--teal-bg); }
.course-emoji { font-size: 40px; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-btn { font-size: 30px; padding: 6px 0; border-radius: 12px; border: 2px solid transparent; background: #f3f6fa; cursor: pointer; }
.avatar-btn.on { border-color: var(--teal); background: var(--teal-bg); }
.input.big { font-size: 20px; padding: 12px 14px; }
.input.pin { letter-spacing: 12px; text-align: center; font-size: 26px; max-width: 240px; }
.form-msg { color: var(--bad); font-weight: 600; min-height: 1.4em; }
.btn.big { padding: 14px 22px; font-size: 18px; border-radius: 14px; }
.btn.block { display: flex; width: 100%; }
.center { text-align: center; justify-content: center; }

.app { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; outline: none; }
.footer { text-align: center; color: var(--gray); font-size: 13px; padding: 24px 20px 40px; }
.loading { color: var(--gray); }

/* typography */
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 26px; color: var(--navy); }
h2 { font-size: 21px; color: var(--navy); }
h3 { font-size: 18px; }
.muted { color: var(--gray); }
.small { font-size: 14px; }
.en { font-family: "Segoe UI", Arial, var(--font); }

/* layout pieces */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #2b5d8a 60%, var(--teal) 100%);
  color: #fff; border-radius: 18px; padding: 24px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.hero h1 { color: #fff; margin-bottom: 4px; }
.hero p { margin: 0; opacity: .92; }
.hero .btn { margin-top: 14px; }

.stat { text-align: center; padding: 16px 10px; }
.stat b { display: block; font-size: 26px; color: var(--navy); line-height: 1.2; }
.stat span { color: var(--gray); font-size: 13px; }

.progress { height: 10px; background: #e6ebf2; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal-2), var(--teal)); border-radius: 999px; transition: width .3s; }
.hero .progress { background: rgba(255,255,255,.25); }
.hero .progress > i { background: #fff; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; background: #eef2f8; color: var(--navy); white-space: nowrap;
}
.pill.teal { background: var(--teal-bg); color: var(--teal); }
.pill.brown { background: var(--brown-bg); color: var(--brown); }
.pill.purple { background: var(--purple-bg); color: var(--purple); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: #9a5b00; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  background: var(--navy); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  transition: transform .05s, background .15s;
}
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn.speaking { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.teal { background: var(--teal); }
.btn.teal:hover { background: #12746c; }
.btn.light { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.light:hover { background: #f0f4fa; }
.btn.ghost { background: transparent; color: var(--navy-2); border-color: transparent; padding: 6px 10px; }
.btn.ghost:hover { background: #eef2f8; }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 14px; border-radius: 8px; }
.hero .btn.light { border-color: transparent; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--navy-2); cursor: pointer;
}
.icon-btn:hover { background: #eef2f8; }
.icon-btn.speaking { background: var(--teal); color: #fff; border-color: var(--teal); }
.icon-btn svg { width: 18px; height: 18px; }

/* section bands */
.band {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 26px 0 12px;
  border-radius: 10px; color: #fff; font-weight: 700; font-size: 17px; scroll-margin-top: 80px;
}
.band.navy { background: var(--navy); }
.band.teal { background: var(--teal); }
.band.brown { background: var(--brown); }
.band.purple { background: var(--purple); }
.band.gray { background: #5c6b7a; }
.band small { font-weight: 400; opacity: .85; font-size: 14px; }

.subnav {
  position: sticky; top: 56px; z-index: 10; display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 0; background: var(--bg); margin-bottom: 4px;
}
.subnav a {
  padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; color: var(--navy); font-size: 14px; white-space: nowrap;
}
.subnav a:hover { border-color: var(--navy-2); }

/* 하루 공부 단계 */
.steptabs {
  position: sticky; top: 56px; z-index: 10; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 0; background: var(--bg); margin: 6px 0 4px; scroll-margin-top: 56px;
}
.steptabs::-webkit-scrollbar { display: none; }
.steptab {
  display: inline-flex; align-items: center; gap: 6px; flex: 1; justify-content: center; min-width: 76px;
  padding: 9px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 700; color: var(--gray); white-space: nowrap;
}
.st-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #eef2f8; font-size: 13px; }
.steptab.done { color: var(--ok); border-color: #b8e3c8; }
.steptab.done .st-num { background: var(--ok); color: #fff; font-size: 0; }
.steptab.done .st-num::after { content: "✔"; font-size: 12px; }
.steptab.on { border-color: var(--navy); color: var(--navy); background: #eef4fb; }
.dstep > .band:first-child { margin-top: 10px; }
.step-next { display: flex; justify-content: center; margin: 22px 0 6px; }
.step-next .btn { width: 100%; max-width: 460px; }
.day-pn { margin-top: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--navy); color: #fff; font-weight: 700; }
.passage.chunked { line-height: 2.2; }
.passage .slash { color: #c2410c; font-style: normal; font-weight: 800; margin: 0 2px; }
.passage .sent.your-turn { background: #fff3a6; box-shadow: 0 0 0 2px #facc15; }

/* 중학 홈 */
.hero-kicker { display: inline-block; background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px 12px; font-weight: 700; margin: 6px 0 8px !important; }
.step-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.step-chip { padding: 3px 12px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 14px; }
.step-chip.done { background: #fff; color: var(--ok); font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.quick-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 16px 8px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border: 2px solid transparent;
}
.quick-card:hover { border-color: var(--teal-2); }
.quick-card .q-ico { font-size: 28px; }
.quick-card span:last-child { color: var(--gray); font-size: 14px; }
.quick-card.alert span:last-child { color: var(--bad); font-weight: 700; }
.period-list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.period-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid #eef2f8; }
.period-row:last-child { border-bottom: 0; }
.period-row.now { background: var(--teal-bg); }
.pr-title { display: flex; flex-direction: column; }
.pr-num { font-size: 14px; color: var(--gray); white-space: nowrap; }

.callout { border-radius: 12px; padding: 14px 16px; margin: 12px 0; border-left: 5px solid; }
.callout.warn { background: var(--warn-bg); border-color: #e59a2a; }
.callout.teal { background: var(--teal-bg); border-color: var(--teal); }
.callout.info { background: #eef4fb; border-color: var(--navy-2); }
.callout h4 { margin: 0 0 6px; font-size: 15px; }
.callout ul { margin: 0; padding-left: 20px; }

/* breadcrumbs */
.crumbs { font-size: 14px; color: var(--gray); margin-bottom: 8px; }
.crumbs a { color: var(--gray); text-decoration: none; }
.crumbs a:hover { color: var(--navy); text-decoration: underline; }

/* course list */
.part-title { margin: 28px 0 10px; font-size: 18px; color: var(--teal); }
.week-card { display: block; text-decoration: none; color: inherit; }
.week-card:hover { box-shadow: 0 0 0 2px var(--teal-2), var(--shadow); }
.week-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.week-head .code { font-weight: 800; color: var(--navy); font-size: 18px; }
.days-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.day-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; text-decoration: none; color: var(--ink);
}
.day-chip.done { background: var(--ok-bg); border-color: #b8e3c8; color: var(--ok); }
.day-chip.today { box-shadow: 0 0 0 2px var(--teal-2); }
.mock-card { border: 2px dashed #e4c8a8; background: var(--brown-bg); }

/* grammar */
.grammar-block { margin-bottom: 18px; }
.grammar-block h3 { color: var(--teal); }
.grammar-block p { margin: 4px 0; }
.ex-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
.ex-table th { background: var(--teal); color: #fff; text-align: left; padding: 6px 10px; font-weight: 600; }
.ex-table td { border-bottom: 1px solid #e3ecea; padding: 6px 10px; vertical-align: middle; }
.ex-table tr:nth-child(even) td { background: #f4fbfa; }
.ex-table td.tts { width: 44px; }
details.fold { background: #fff; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 14px; }
details.fold > summary {
  cursor: pointer; padding: 14px 18px; font-weight: 700; color: var(--teal); list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; transition: transform .2s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > .fold-body { padding: 0 18px 16px; }

/* vocab cards */
.word-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.word-card { background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 14px; position: relative; }
.word-card.known { border-color: #b8e3c8; background: #fbfefc; }
.word-card.unsure { border-color: #f1c9a0; background: #fffaf4; }
.word-top { display: flex; align-items: center; gap: 8px; }
.word-top .num { color: var(--gray); font-size: 13px; width: 20px; }
.word-top .w { font-size: 21px; font-weight: 800; color: var(--navy); }
.word-mean { margin: 6px 0 4px; font-weight: 600; }
.word-mean.hidden-mean { position: relative; color: transparent; background: #eef2f8; border-radius: 6px; cursor: pointer; user-select: none; }
.word-mean.hidden-mean::after { content: "눌러서 뜻 보기"; color: var(--gray); font-weight: 400; font-size: 13px; position: absolute; left: 10px; top: 1px; }
.word-ex { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; margin-top: 6px; }
.word-ex .ko { color: var(--gray); font-size: 14px; }
.word-actions { display: flex; gap: 6px; margin-top: 10px; }

.recall-row { display: grid; grid-template-columns: 28px 1fr 1.1fr 40px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #eef2f8; }
.recall-row:last-child { border-bottom: 0; }

/* inputs */
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(36, 82, 122, .15); }
.textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.textarea.lined {
  background-image: repeating-linear-gradient(#fff, #fff 31px, #e3e9f2 32px);
  line-height: 32px; padding-top: 4px;
  background-position: 0 6px; background-attachment: local;
}
.input.ok, .textarea.ok { border-color: var(--ok); background: var(--ok-bg); }
.input.bad, .textarea.bad { border-color: var(--bad); background: var(--bad-bg); }
label.field { display: block; font-weight: 600; margin: 10px 0 6px; font-size: 15px; }

/* questions */
.q { background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 12px; }
.q.ok { border-color: #9fd8b5; }
.q.bad { border-color: #f0b3ab; }
.q-head { display: flex; gap: 10px; align-items: flex-start; }
.q-num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: #eef2f8; color: var(--navy); font-weight: 700; font-size: 14px;
}
.q.ok .q-num { background: var(--ok); color: #fff; }
.q.bad .q-num { background: var(--bad); color: #fff; }
.q-text { flex: 1; font-size: 16px; }
.q-type { font-size: 12px; color: var(--gray); margin-left: 6px; }
.choices { display: grid; gap: 8px; margin: 12px 0 4px 38px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--navy-2); background: #f6f9fd; }
.choice:disabled { cursor: default; }
.choice .mark { flex-shrink: 0; color: var(--gray); font-weight: 700; }
.choice.picked { border-color: var(--navy-2); background: #eef4fb; }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.correct .mark { color: var(--ok); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); text-decoration: line-through; text-decoration-color: rgba(192,57,43,.5); }
.choice.wrong .mark { color: var(--bad); }
.q-input { margin: 12px 0 4px 38px; display: flex; gap: 8px; align-items: flex-start; }
.q-input .input, .q-input .textarea { flex: 1; }
.q-foot { margin: 10px 0 0 38px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.model { background: #f6f9fd; border: 1px dashed #b9c9de; border-radius: 10px; padding: 10px 12px; margin: 10px 0 0 38px; }
.model b { color: var(--navy); }
.model.hint { background: var(--bad-bg); border-color: #f0b3ab; }
.model.hint b { color: var(--bad); }
.selfcheck { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }

/* diff */
.diff { line-height: 2; }
.diff .miss { background: #d8f3e2; color: #0f6b3a; border-radius: 4px; padding: 1px 3px; font-weight: 700; }
.diff .extra { background: #fbdcd8; color: #a5281b; border-radius: 4px; padding: 1px 3px; text-decoration: line-through; }

/* reading */
.passage {
  background: var(--brown-bg); border: 1px solid #e4c8a8; border-radius: 12px; padding: 16px 18px;
  font-size: 17px; line-height: 1.9;
}
.passage .sent { cursor: pointer; border-radius: 4px; transition: background .15s; }
.passage .sent:hover { background: #fbe6cc; }
.passage .sent.reading-now { background: #f7d29e; }
.passage-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }

/* writing */
.cond-list { list-style: none; padding: 0; margin: 8px 0; }
.cond-list li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.cond-list input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--purple); }

/* day finish */
.finish { text-align: center; padding: 28px 20px; }
.finish.done { background: var(--ok-bg); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 25, 40, .55); }
.modal-panel {
  position: relative; background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 88vh; overflow-y: auto;
  padding: 24px 22px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .15s ease-out;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-x { position: absolute; right: 12px; top: 10px; border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--gray); }
.modal h3 { padding-right: 30px; color: var(--navy); }
.ex-box { border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.ex-box.ok { background: var(--ok-bg); }
.ex-box.bad { background: var(--bad-bg); }
.ex-box.info { background: #eef4fb; }
.ex-box.teal { background: var(--teal-bg); }
.ex-box h4 { margin: 0 0 4px; font-size: 14px; color: var(--gray); }
.ex-line { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* flashcard */
.flash {
  min-height: 240px; display: grid; place-items: center; text-align: center; cursor: pointer;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 24px; user-select: none;
}
.flash .big { font-size: 38px; font-weight: 800; color: var(--navy); }
.flash .mean { font-size: 24px; font-weight: 700; margin-top: 8px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; color: var(--gray); font-weight: 600; font-size: 13px; padding: 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }
.table td .w { font-weight: 700; color: var(--navy); }

/* mock exam */
.timer {
  position: sticky; top: 64px; z-index: 9; display: flex; align-items: center; gap: 12px;
  background: var(--navy); color: #fff; border-radius: 12px; padding: 10px 16px; margin-bottom: 14px;
}
.timer b { font-size: 22px; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--bad); }
.score-big { font-size: 48px; font-weight: 800; color: var(--navy); line-height: 1; }

.empty { text-align: center; color: var(--gray); padding: 36px 16px; }

@media (max-width: 760px) {
  body { font-size: 16px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  body.no-profile { padding-bottom: 0; }
  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .topbar .nav { display: none; }
  .brand-text small { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(20,40,70,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar[hidden] { display: none; }
  .tabbar .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    padding: 7px 2px 6px; text-decoration: none; color: var(--gray); font-size: 12px; position: relative; min-height: 58px;
  }
  .tabbar .tab .nav-ico { font-size: 22px; line-height: 1.1; }
  .tabbar .tab.active { color: var(--navy); font-weight: 700; }
  .tabbar .tab.active::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal-2); }
  .tabbar .badge { position: absolute; top: 4px; left: 54%; margin: 0; font-size: 11px; line-height: 17px; min-width: 17px; padding: 0 4px; }
  .footer { padding-bottom: 20px; }
  .subnav, .steptabs { top: 52px; }
  .steptab { min-width: 64px; padding: 8px 8px; font-size: 15px; }
  .st-num { display: none; }
  .steptab.done::before { content: "✔"; color: var(--ok); }
  .quick { gap: 8px; }
  .quick-card { padding: 12px 4px; }
  .quick-card b { font-size: 14px; }
  .period-row { grid-template-columns: 1fr auto; }
  .pr-bar { grid-column: 1 / -1; grid-row: 2; }
  .timer { top: 60px; }
  .app { padding: 16px 12px 40px; }
  .btn { padding: 11px 16px; }
  .btn.sm { padding: 8px 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
  .who-grid { grid-template-columns: repeat(2, 1fr); }
  .course-pick { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: end; }
  .modal-panel { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid { grid-template-columns: 1fr; }
  .choices, .q-input, .q-foot, .model { margin-left: 0; }
  .recall-row { grid-template-columns: 24px 1fr; }
  .recall-row .input { grid-column: 2; }
  .recall-row .icon-btn { display: none; }
  h1 { font-size: 22px; }
}

@media print {
  .topbar, .subnav, .footer, .btn, .icon-btn, .timer, .tabbar { display: none !important; }
  body { background: #fff; }
  .card, .q { box-shadow: none; border: 1px solid #ccc; }
}
