:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1d232b;
  --muted: #5d6673;
  --line: #e1ddd3;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --sel: #e3f1ee;
  --ok: #1d7a3a;
  --ok-bg: #e5f4e9;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --ko-ink: #3b4a63;
  --warn: #b26a00;
  --warn-bg: #fff6dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c; --card: #1e2227; --ink: #e8e6e1; --muted: #9aa3ad; --line: #333941;
    --accent: #3fb8a1; --accent-ink: #0d1512; --sel: #1d3631;
    --ok: #6fcf8a; --ok-bg: #1b3022; --bad: #f2867c; --bad-bg: #3a1f1d; --ko-ink: #a9b8d1;
    --warn: #f0b44c; --warn-bg: #2e2716;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.75 "Noto Sans", "Segoe UI", sans-serif;  /* 17px; rem so html.big scales everything */
}
/* font size "big": 1.5x the normal size */
html.big { font-size: 150%; }
html[lang="ar"] body { font-family: "Noto Naskh Arabic", "Sakkal Majalla", "Simplified Arabic", Tahoma, sans-serif; }
html[lang="th"] body { font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; }
html[lang="ne"] body { font-family: "Noto Sans Devanagari", "Nirmala UI", "Mangal", sans-serif; }
html[lang="km"] body { font-family: "Noto Sans Khmer", "Leelawadee UI", "Khmer UI", sans-serif; line-height: 1.95; }
html[lang="my"] body { font-family: "Noto Sans Myanmar", "Myanmar Text", "Padauk", sans-serif; line-height: 2.05; }
html[lang="bn"] body { font-family: "Noto Sans Bengali", "Nirmala UI", "Vrinda", sans-serif; line-height: 1.9; }
html[lang="ja"] body { font-family: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif; }
[lang="ko"], .ko { font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; }
button { font: inherit; cursor: pointer; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.3; }
.brand > span:first-child { font-weight: 700; }
.brand .ko { font-size: .8rem; color: var(--muted); }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.controls select { font: inherit; font-size: .9rem; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.view { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view button { border: 0; background: transparent; color: var(--ink); padding: .3rem .8rem; font-size: .9rem; }
.view button.on { background: var(--accent); color: var(--accent-ink); }

/* top tabs: glossary / all questions / mock exam, on every screen except the first language pick */
.tabs { flex: 1 1 22rem; max-width: 34rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.tabs a {
  display: flex; align-items: center; justify-content: center; gap: .4rem; min-width: 0;
  padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: .9rem; line-height: 1.25; text-align: center;
}
.tabs a > span:last-child { display: flex; flex-direction: column; min-width: 0; overflow-wrap: break-word; }
.tabs .ic { font-size: 1.1rem; }
.tabs .ko { font-size: .72rem; color: var(--ko-ink); }
.tabs a:hover, .tabs a:focus-visible { border-color: var(--accent); }
.tabs a.on { background: var(--sel); border-color: var(--accent); font-weight: 700; }

main { max-width: 860px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }
h1 { margin: 0; font-size: 1.6rem; }
.ko-sub { margin: .2rem 0 1.2rem; color: var(--muted); }

.plan { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .95rem; }
.plan th, .plan td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: start; }
.plan td:not(:first-child), .plan th:not(:first-child) { text-align: center; width: 6.5rem; }
.plan tfoot td { font-weight: 700; border-bottom: 0; }
.info { padding-inline-start: 1.2rem; color: var(--muted); font-size: .95rem; }
.notice { margin: 0 0 1.2rem; padding: .75rem 1rem; background: var(--warn-bg); border-inline-start: 4px solid var(--warn); border-radius: 8px; font-size: .92rem; }
.notice p { margin: 0; }
.notice p + p { margin-top: .4rem; color: var(--ko-ink); font-size: .88rem; }
.notice strong { color: var(--warn); }
.notice a { color: inherit; font-weight: 600; }
.prep { padding-top: 2rem; text-align: center; }
.prep .notice { font-size: 1.05rem; text-align: start; }
.prep-count { margin: 2rem 0; font-size: 72px; font-weight: 700; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.disclaimer { margin-top: 1.5rem; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 1rem; }

.lang-go { display: flex; gap: .5rem; margin-top: .5rem; max-width: 420px; }
.lang-go select { flex: 1; min-width: 0; font: inherit; font-size: 1.1rem; padding: .6rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.lang-go button { font-size: 1.3rem; padding: .4rem 1.2rem; }

.menu { display: grid; gap: .75rem; margin-top: .5rem; }
.menu-item {
  display: flex; align-items: center; gap: 1rem; width: 100%; text-align: start; text-decoration: none;
  padding: 1rem 1.2rem; background: var(--card); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px;
}
.menu-item:hover, .menu-item:focus-visible { border-color: var(--accent); background: var(--sel); }
.menu-item .ic { font-size: 1.8rem; line-height: 1; }
.menu-item .nm { display: block; font-size: 1.2rem; font-weight: 700; }
.menu-item .ko { display: block; font-size: .85rem; color: var(--ko-ink); }

#gl-search { width: 100%; font: inherit; padding: .5rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
#gl-list h3 { margin: 1.4rem 0 .3rem; font-size: 1.05rem; color: var(--accent); }
.gl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.gl td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; width: 50%; overflow-wrap: anywhere; }
.gl td[lang="ko"] { color: var(--ko-ink); text-align: start; }
body.view-tr .gl td[lang="ko"], body.view-ko .gl td:not([lang]) { display: none; }
.small { font-size: .85rem; padding: .3rem .8rem; float: inline-end; }

.primary, .ghost { border-radius: 10px; padding: .6rem 1.2rem; border: 1px solid var(--accent); }
.primary { background: var(--accent); color: var(--accent-ink); }
.ghost { background: transparent; color: var(--accent); }
#start { margin-top: .5rem; font-size: 1.05rem; padding: .75rem 1.6rem; }

.exam-top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 4; background: var(--card);
  margin: -1.5rem -1.5rem 1rem; padding: .75rem 1.5rem; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0;
}
/* during the exam the top bar scrolls away so the progress/timer row can stay pinned */
body.in-exam .bar { position: static; }
/* with the tabs the bar is tall: in big font, and on phones, it scrolls away instead of covering the page */
html.big .bar { position: static; }
@media (max-width: 520px) { .bar { position: static; } }
.progress { font-weight: 700; font-size: 1.1rem; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); direction: ltr; }
.timer.low { color: var(--bad); font-weight: 700; }
#submit { margin-inline-start: auto; }

.qmeta { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; font-size: .82rem; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .65rem; color: var(--muted); }
.chip.multi { border-color: var(--accent); color: var(--accent); }
.qtext { font-size: 1.15rem; font-weight: 600; margin: 0 0 .25rem; }
.ko-block { direction: ltr; text-align: left; color: var(--ko-ink); }
.qtext.ko-block { font-size: 1.02rem; font-weight: 600; }
.missing { font-size: .85rem; color: var(--bad); margin: .2rem 0; }
.figs { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; justify-content: center; }
.video { margin: .6rem 0; }
.vframe { position: relative; aspect-ratio: 16 / 9; max-width: 640px; border-radius: 8px; overflow: hidden; background: #000; }
.vframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vlink { display: inline-block; margin-top: .4rem; color: var(--accent); font-weight: 600; text-decoration: none; }
.vlink:hover { text-decoration: underline; }
.vurl { display: none; }
.figs img { border-radius: 8px; border: 1px solid var(--line); max-height: 340px; background: #fff; }
.notes { background: var(--bg); border-radius: 10px; padding: .6rem 1rem; margin: .5rem 0 1rem; font-size: .95rem; }
.notes ul { margin: 0; padding-inline-start: 1.1rem; }
.notes .ko-block ul { padding-inline-start: 1.1rem; }

.opts { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .55rem; }
.opt {
  display: grid; grid-template-columns: 2rem 1fr; gap: .4rem .6rem; align-items: start;
  width: 100%; text-align: start; padding: .7rem .9rem;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px;
}
.opt:hover { border-color: var(--accent); }
.opt.on { background: var(--sel); border-color: var(--accent); }
.opt .mk { font-size: 1.3rem; line-height: 1.3; color: var(--accent); font-family: "Noto Sans KR", sans-serif; }
.opt .t { display: grid; gap: .15rem; }
.opt .ko-block { font-size: .93rem; }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }

.nav { display: flex; justify-content: space-between; margin-top: 1.25rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); gap: .35rem; margin-top: 1.25rem; direction: ltr; }
.grid button { padding: .3rem 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font-size: .85rem; }
.grid button.done { background: var(--sel); border-color: var(--accent); }
.grid button.cur { outline: 2px solid var(--accent); outline-offset: 1px; }

#score { text-align: center; padding: .5rem 0 1rem; }
#score .big { font-size: 3.2rem; font-weight: 700; line-height: 1.1; direction: ltr; }
#score .verdict { font-size: 1.3rem; font-weight: 700; margin: .3rem 0; }
#score .pass { color: var(--ok); }
#score .fail { color: var(--bad); }
.breakdown { width: 100%; max-width: 520px; margin: 1rem auto 0; border-collapse: collapse; font-size: .92rem; }
.breakdown td, .breakdown th { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: center; }
.breakdown td:first-child, .breakdown th:first-child { text-align: start; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin: 1rem 0 1.5rem; }

.rv { border-top: 1px solid var(--line); padding: 1.25rem 0; }
.rv-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .4rem; font-weight: 700; }
.rv-head .ok { color: var(--ok); }
.rv-head .bad { color: var(--bad); }
.exp { margin-top: .9rem; background: var(--bg); border-radius: 10px; padding: .75rem 1rem; font-size: .93rem; }
.exp h4 { margin: 0 0 .25rem; font-size: .9rem; color: var(--muted); }
.exp p { margin: 0 0 .5rem; }
.rv .opt { cursor: default; }

/* language modes (.keep: Korean shown while Arabic is missing) */
body.view-tr .ko-block { display: none; }
body.view-ko .tr-block { display: none; }

@media (max-width: 520px) {
  body { font-size: 1rem; }
  .tabs .ic { display: none; }
  .tabs { flex-basis: 100%; max-width: none; }
  html.big .tabs a { font-size: .68rem; padding: .3rem .3rem; }
  html.big .tabs .ko { font-size: .6rem; }
  .panel { padding: 1rem; border-radius: 10px; }
  .figs img { max-height: 240px; }
  .exam-top { margin: -1rem -1rem 1rem; padding: .6rem 1rem; border-radius: 10px 10px 0 0; }
  /* question bank: the four-row top bar would cover a third of the screen, so it scrolls away */
  body.bank-page .bar { position: static; padding: .5rem .75rem; }
  body.bank-page .controls { gap: .4rem; flex: 1 1 100%; min-width: 0; }
  body.bank-page .controls select#type-select { flex: 1 1 100%; max-width: none; min-width: 0; }
}

a.ghost, a.primary { display: inline-block; text-decoration: none; }

/* question bank page (print.html) */
.small-btn { font-size: .9rem; padding: .3rem .8rem; }
.controls select#type-select { max-width: 16rem; }
.controls select#lang-select { max-width: 13rem; min-width: 0; }
.bank-head .hint { color: var(--muted); font-size: .92rem; }
.bank-head .updated { font-weight: 600; margin: 0 0 .5rem; }
#score .dates { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.bank-sec { margin-top: 1rem; }
.bank-sec h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.bank-sec h2 small { font-weight: 400; color: var(--muted); font-size: .85rem; }
.bq { border-top: 1px solid var(--line); padding: 1rem 0; }
.bq .opts { gap: .35rem; }
.bq .opt { padding: .45rem .8rem; }
.bq .figs img { max-height: 260px; }
.exp .ans { margin: 0 0 .4rem; color: var(--ok); }

@media print {
  :root {
    --bg: #f6f5f1; --card: #fff; --ink: #1d232b; --muted: #5d6673; --line: #d5d1c7;
    --accent: #0f6b5c; --sel: #e3f1ee; --ok: #1d7a3a; --ok-bg: #e5f4e9; --bad: #b3261e; --bad-bg: #fbe9e7; --ko-ink: #3b4a63;
    --warn: #b26a00; --warn-bg: #fff6dc;
    color-scheme: light;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bar, .actions, .nav, .grid, #exam, .bank-head .hint { display: none !important; }
  html.big { font-size: 100%; }
  body { background: #fff; font-size: 13px; }
  main { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; }
  .rv, .bq { break-inside: avoid; }
  .bank-sec { break-before: page; margin: 0; }
  .figs img { max-height: 200px; }
  .vframe, .vlink { display: none !important; }
  .vurl { display: block; font-size: 12px; color: var(--muted); }
  .vurl::before { content: "▶ YouTube: "; }
}
body.view-tr .ko-block.keep { display: block; }

/* back arrow follows reading direction: ← in LTR, → in RTL (Arabic) */
.bk::before { content: "←"; }
html[dir="rtl"] .bk::before { content: "→"; }
