:root {
  --navy: #26374a;
  --navy-dark: #1c578a;
  --link: #284162;
  --link-hover: #0535d2;
  --red: #af3c43;
  --red-flag: #d52b1e;
  --green: #278400;
  --green-bg: #d8eeca;
  --bad-bg: #f3e9e8;
  --warn-bg: #f9f4d4;
  --info-bg: #d7faff;
  --border: #ccc;
  --muted: #555;
  --bg-alt: #f8f8f8;
  --text: #333;
  --focus: #0e62c9;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; color: var(--text); background: #fff;
  font-family: "Noto Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55; display: flex; flex-direction: column; min-height: 100vh;
}
h1, h2, h3 { font-family: Lato, "Segoe UI", Helvetica, Arial, sans-serif; color: #333; line-height: 1.25; }
h1 { font-size: 2.1rem; margin: 1.6rem 0 1rem; padding-bottom: .35rem; border-bottom: 3px solid var(--red); display: inline-block; }
h2 { font-size: 1.5rem; margin: 1.8rem 0 .8rem; }
h3 { font-size: 1.2rem; margin: 1.2rem 0 .5rem; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 18px; }
main.container { flex: 1; padding-bottom: 3rem; }
main:focus { outline: none; }
.card .btn-row { margin-top: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 6px 10px; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #000; }
.flag { width: 52px; height: 26px; border: 1px solid #ddd; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: Lato, sans-serif; font-size: 1.15rem; }
.brand-text span { font-size: .85rem; color: var(--muted); }
.top-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top-nav a { padding: 8px 12px; text-decoration: none; color: var(--link); border-radius: 3px; }
.top-nav a:hover { background: #eaebed; }
.top-nav a.active { background: var(--navy); color: #fff; }
.header-rule { height: 4px; background: var(--navy); }

.site-footer { background: var(--navy); color: #fff; font-size: .9rem; padding: 18px 0; }
.site-footer a { color: #fff; }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-size: 1rem; padding: 9px 18px; border-radius: 4px;
  border: 1px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: #444; border-color: #444; color: #fff; }
.btn-default { background: #eaebed; color: #335075; border-color: #dcdee1; }
.btn-default:hover { background: #cfd1d5; color: #335075; border-color: #bbbfc5; }
.btn-danger { background: #d3080c; border-color: #d3080c; }
.btn-danger:hover { background: #a00; }
.btn-lg { font-size: 1.1rem; padding: 12px 26px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 1.2rem; }

/* Alerts */
.alert { border-left: 6px solid; padding: 12px 16px; margin: 1rem 0; }
.alert-info { border-color: #269abc; background: var(--info-bg); }
.alert-success { border-color: var(--green); background: var(--green-bg); }
.alert-danger { border-color: #d3080c; background: var(--bad-bg); }
.alert-warning { border-color: #ee7100; background: var(--warn-bg); }
.alert p { margin: .3rem 0; }

/* Cards / grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 1rem 0; }
.card { border: 1px solid var(--border); border-radius: 4px; padding: 18px; background: #fff; display: flex; flex-direction: column; }
.card h3 { margin-top: 0; }
.card p { flex: 1; margin: 0 0 1rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 1rem 0; }
.fact { background: var(--bg-alt); border: 1px solid #e3e3e3; padding: 14px; border-radius: 4px; text-align: center; }
.fact b { display: block; font-size: 1.7rem; color: var(--navy); font-family: Lato, sans-serif; }

.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.test-tile {
  border: 1px solid var(--border); border-radius: 4px; padding: 10px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 2px; background: #fff; position: relative;
}
.test-tile:hover { border-color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.test-tile .t-name { font-weight: 700; color: var(--link); }
.test-tile .t-meta { font-size: .82rem; color: var(--muted); }
.test-tile.passed { border-left: 5px solid var(--green); }
.test-tile.failed { border-left: 5px solid #d3080c; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 10px; font-weight: 700; }
.badge-pass { background: var(--green-bg); color: #1e5c00; }
.badge-fail { background: var(--bad-bg); color: #a00; }
.badge-new { background: #eee; color: #555; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: .5rem 0 1rem; }
.filters button { font: inherit; padding: 5px 12px; border: 1px solid var(--border); background: #fff; border-radius: 16px; cursor: pointer; }
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Exam */
.exam-bar {
  position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 10px 0; margin-top: 1rem; flex-wrap: wrap;
}
.exam-title { font-weight: 700; font-family: Lato, sans-serif; font-size: 1.15rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; padding: 6px 12px; border: 2px solid var(--navy); border-radius: 4px; }
.timer.low { border-color: #d3080c; color: #d3080c; background: var(--bad-bg); }
.progressbar { height: 8px; background: #e6e6e6; border-radius: 4px; overflow: hidden; margin: 12px 0 0; }
.progressbar span { display: block; height: 100%; background: var(--navy); transition: width .2s; }
.exam-layout { display: grid; grid-template-columns: 1fr 240px; gap: 28px; margin-top: 1.2rem; }
@media (max-width: 820px) { .exam-layout { grid-template-columns: 1fr; } }
.q-count { color: var(--muted); font-size: .95rem; margin: 0 0 .4rem; }
.q-text { font-size: 1.3rem; font-weight: 600; margin: 0 0 1.2rem; line-height: 1.4; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { padding: 0; }
.option {
  display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--border); border-radius: 4px;
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer; background: #fff; font-size: 1.05rem;
}
.option:hover { background: #f5f7fa; border-color: #8a9bb0; }
.option input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--navy); flex-shrink: 0; }
.option.selected { border-color: var(--navy); background: #eef2f7; box-shadow: inset 0 0 0 1px var(--navy); }
.option .letter { font-weight: 700; min-width: 1.2em; color: var(--navy); }
.option.correct { border-color: var(--green); background: var(--green-bg); box-shadow: inset 0 0 0 1px var(--green); }
.option.wrong { border-color: #d3080c; background: var(--bad-bg); box-shadow: inset 0 0 0 1px #d3080c; }
.option.locked { cursor: default; }
.flag-toggle { display: inline-flex; align-items: center; gap: 6px; margin-top: .4rem; cursor: pointer; color: var(--muted); }
.nav-panel { border: 1px solid var(--border); border-radius: 4px; padding: 14px; align-self: start; position: sticky; top: 76px; }
.nav-panel h2 { font-size: 1rem; margin: 0 0 .6rem; }
.q-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.q-nav button {
  font: inherit; font-size: .9rem; padding: 6px 0; border: 1px solid var(--border); background: #fff; border-radius: 3px; cursor: pointer; position: relative;
}
.q-nav button.answered { background: #dfe6ee; border-color: #8a9bb0; }
.q-nav button.current { outline: 2px solid var(--navy); font-weight: 700; }
.q-nav button.flagged::after { content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; background: #ee7100; border-radius: 50%; }
.legend-row { font-size: .8rem; color: var(--muted); margin-top: .7rem; display: grid; gap: 3px; }
.legend-row span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1px solid #8a9bb0; vertical-align: -1px; }
.legend-row .l-ans::before { background: #dfe6ee; }
.legend-row .l-flag::before { background: #ee7100; border-radius: 50%; border-color: #ee7100; }

/* Results */
.score-box { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; padding: 20px; border-radius: 4px; margin: 1rem 0; }
.score-box.pass { background: var(--green-bg); border-left: 8px solid var(--green); }
.score-box.fail { background: var(--bad-bg); border-left: 8px solid #d3080c; }
.score-num { font-size: 3rem; font-weight: 700; font-family: Lato, sans-serif; line-height: 1; }
.score-box p { margin: .2rem 0; }
.review-item { border: 1px solid var(--border); border-radius: 4px; padding: 16px; margin-bottom: 14px; }
.review-item.is-right { border-left: 6px solid var(--green); }
.review-item.is-wrong { border-left: 6px solid #d3080c; }
.review-item .q-text { font-size: 1.08rem; margin-bottom: .7rem; }
.review-item .option { font-size: .98rem; padding: 8px 12px; margin-bottom: 6px; cursor: default; }
.explain { background: var(--bg-alt); border: 1px solid #e6e6e6; padding: 10px 14px; border-radius: 4px; margin-top: 10px; font-size: .95rem; }
.explain blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid #bbb; color: var(--muted); font-style: italic; }
.mark { font-weight: 700; }
.mark.ok { color: var(--green); }
.mark.no { color: #d3080c; }

table.data { width: 100%; border-collapse: collapse; margin: .8rem 0; }
table.data th, table.data td { border-bottom: 1px solid #ddd; padding: 8px 10px; text-align: left; }
table.data th { background: var(--bg-alt); }
.meter { height: 10px; background: #e6e6e6; border-radius: 5px; overflow: hidden; min-width: 90px; }
.meter span { display: block; height: 100%; background: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.chapter-list .card p { flex: 0; }
.chapter-list .card .meta { margin: 0 0 .8rem; }
.feedback { margin-top: 1rem; }
.center { text-align: center; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 4px; max-width: 520px; width: 100%; padding: 24px; box-shadow: 0 6px 30px rgba(0,0,0,.3); }
.modal h2 { margin-top: 0; }
