:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #2b3040;
  --head: #161a26;
  --muted: #7a8196;
  --border: #e3e7f0;
  --border-2: #d3d9e6;
  --accent: #4f46e5;
  --accent-d: #3f37c9;
  --accent-soft: #ecebff;
  --ok: #16a34a;
  --ok-d: #11823b;
  --ok-soft: #e4f7eb;
  --bad: #e5484d;
  --bad-d: #c13338;
  --bad-soft: #fde8e8;
  --warn-soft: #fff5d9;
  --warn: #a16800;
  --gold: #f5b400;
  --orange: #f97316;
  --teal: #0ea5a4;
  --pink: #db2777;
  --gl-line: #4f46e5;
  --gen-line: #a0a7b8;
  --shadow: 0 10px 30px rgba(22, 26, 60, .12);
  --shadow-sm: 0 1px 2px rgba(22, 26, 60, .05), 0 4px 14px rgba(22, 26, 60, .05);
  --r: 16px;
  --top-h: 60px;
  --tab-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220; --surface: #181c2e; --surface-2: #20253a; --text: #d9dcea; --head: #f3f4fb; --muted: #8e95ad;
    --border: #282e46; --border-2: #343b57; --accent: #8b85ff; --accent-d: #6c64f0; --accent-soft: #24234a;
    --ok: #34d17a; --ok-d: #23a35c; --ok-soft: #13301f; --bad: #ff6b6f; --bad-d: #d4484c; --bad-soft: #3a1c22;
    --warn-soft: #3a3016; --warn: #f0c75e; --gl-line: #8b85ff; --gen-line: #626a86;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5); --shadow-sm: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1220; --surface: #181c2e; --surface-2: #20253a; --text: #d9dcea; --head: #f3f4fb; --muted: #8e95ad;
  --border: #282e46; --border-2: #343b57; --accent: #8b85ff; --accent-d: #6c64f0; --accent-soft: #24234a;
  --ok: #34d17a; --ok-d: #23a35c; --ok-soft: #13301f; --bad: #ff6b6f; --bad-d: #d4484c; --bad-soft: #3a1c22;
  --warn-soft: #3a3016; --warn: #f0c75e; --gl-line: #8b85ff; --gen-line: #626a86;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); --shadow-sm: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text); overflow-x: hidden;
  font: 500 16px/1.6 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: var(--top-h);
  padding: 0 18px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; color: var(--head); white-space: nowrap; font-size: 18px; letter-spacing: -.2px; }
.brand::before { content: "FR"; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 13px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #9b5cf6); box-shadow: 0 3px 0 var(--accent-d); }
.brand span { font-weight: 600; color: var(--muted); font-size: 13px; margin-left: 2px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#quickSearch { width: 240px; padding: 9px 14px 9px 36px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e95ad' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") 12px 50% no-repeat; outline: none; transition: border-color .2s, background-color .2s, width .25s; }
#quickSearch:focus { border-color: var(--accent); background-color: var(--surface); width: 280px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 11px; height: 38px; min-width: 38px; padding: 0 10px; cursor: pointer; font-weight: 700; transition: transform .1s, background .2s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.off { opacity: .45; }
#menuBtn { display: none; }

/* ---------- layout & sidebar ---------- */
.layout { display: flex; min-height: calc(100vh - var(--top-h)); }
.sidebar {
  width: 296px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface);
  padding: 14px 10px 40px; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; scrollbar-width: thin;
}
.nav-group a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; margin: 1px 0;
  text-decoration: none; color: var(--text); font-size: 14px; font-weight: 600; transition: background .15s, color .15s, transform .15s;
}
.nav-group a:hover { background: var(--surface-2); transform: translateX(2px); }
.nav-group a.active { background: var(--accent-soft); color: var(--accent); }
.nav-group a .num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; flex-shrink: 0; }
.nav-group a.active .num { background: var(--accent); color: #fff; }
.nav-group a .badge { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--muted); }
.nav-group a .badge.done { color: var(--ok); }
.nav-group a.missing { opacity: .45; }
.nav-title { margin: 18px 12px 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 28px 36px 90px; max-width: 1320px; margin: 0 auto; }
.main.enter { animation: enter .3s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; color: var(--head); font-weight: 800; letter-spacing: -.4px; }
h1 + .sub { color: var(--muted); margin: 0 0 18px; }
h2 { font-size: 20px; margin: 30px 0 12px; color: var(--head); font-weight: 800; letter-spacing: -.2px; }
h3 { font-size: 17px; margin: 22px 0 8px; color: var(--head); font-weight: 700; }
h4 { font-size: 15px; margin: 16px 0 6px; color: var(--head); font-weight: 700; }
.sub { color: var(--muted); }
.muted { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; margin: 12px 0; box-shadow: var(--shadow-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--accent); }

/* tabs: scrollable pill bar */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 18px 0 16px; position: sticky; top: calc(var(--top-h) + 8px); z-index: 5;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); padding: 5px; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: none; background: none; padding: 8px 14px; cursor: pointer; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; transition: background .2s, color .2s; }
.tabs button:hover { color: var(--head); }
.tabs button.active { color: #fff; background: var(--accent); box-shadow: 0 2px 0 var(--accent-d); }

.pair { display: grid; grid-template-columns: 1fr; gap: 0; }
.lang-en, .lang-az { padding: 14px 18px; border-radius: 14px; }
.lang-en { background: var(--surface); border: 1px solid var(--border); }
.lang-az { background: var(--accent-soft); margin-top: 8px; border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent); }
.lang-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.lang-az .lang-label { color: var(--accent); }
.lang-en > :first-child, .lang-az > :first-child { margin-top: 0; }
.lang-en > :last-child, .lang-az > :last-child { margin-bottom: 0; }

table { border-collapse: separate; border-spacing: 0; margin: 10px 0; font-size: 14px; border: 1px solid var(--border); border-radius: 12px; }
thead tr:first-child > :first-child, table > tr:first-child > :first-child { border-top-left-radius: 11px; }
thead tr:first-child > :last-child, table > tr:first-child > :last-child { border-top-right-radius: 11px; }
.gl-table { width: 100%; }
.gl-table td:nth-child(3) { min-width: 260px; }
th, td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
tr > :last-child { border-right: 0; }
tbody tr:last-child > td, table > tr:last-child > td { border-bottom: 0; }
th { background: var(--surface-2); font-weight: 700; color: var(--head); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.calc td { border-right: none; }
.tablewrap { overflow-x: auto; }
.je { font-family: ui-monospace, Menlo, monospace; font-size: 14px; background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; margin: 10px 0; border-radius: 8px; }
.tip { background: var(--ok-soft); border-left: 4px solid var(--ok); padding: 10px 14px; margin: 10px 0; border-radius: 10px; }
.warn { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; margin: 10px 0; border-radius: 10px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }

/* glossary marks */
.gl { border-bottom: 1.5px dotted var(--gl-line); cursor: help; transition: background .15s; border-radius: 2px; }
.gl.gen { border-bottom-color: var(--gen-line); }
body.no-annot .gl { border-bottom: none; cursor: inherit; }
.gl:hover { background: var(--accent-soft); }

.pop {
  position: absolute; z-index: 50; max-width: 360px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 14px; line-height: 1.5; animation: popin .15s ease-out;
}
@keyframes popin { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.pop .p-en { font-weight: 800; color: var(--head); }
.pop .p-az { font-size: 16px; color: var(--accent); font-weight: 700; margin: 2px 0 4px; }
.pop .p-def { color: var(--text); }
.pop .p-ex { color: var(--muted); font-style: italic; margin-top: 4px; }
.pop .p-meta { color: var(--muted); font-size: 12px; margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pop .p-hits { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.pop .p-hits div { font-size: 13px; }
.pop button { font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 3px 9px; cursor: pointer; }
.selpop { max-width: 440px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-2); background: var(--surface); border-radius: 12px; padding: 9px 16px; cursor: pointer;
  font-weight: 700; font-size: 14px; color: var(--head); text-decoration: none; box-shadow: 0 2px 0 var(--border-2); transition: transform .08s, box-shadow .08s, background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--border-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:active { box-shadow: 0 0 0 var(--accent-d); transform: translateY(3px); }
.btn.green { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 3px 0 var(--ok-d); }
.btn.small { padding: 4px 11px; font-size: 13px; border-radius: 10px; }
.btn.big { padding: 13px 22px; font-size: 15px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- quiz ---------- */
.q { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow-sm); transition: border-color .25s, box-shadow .25s; }
.q.correct { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 15%, transparent); animation: good .45s ease-out; }
.q.wrong { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 13%, transparent); animation: shake .4s; }
@keyframes good { 40% { transform: scale(1.01); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.q-head { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.q-head .qn { font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; }
.q-en { color: var(--head); }
.q-az { display: none; background: var(--accent-soft); padding: 12px 14px; border-radius: 12px; margin: 10px 0; animation: enter .2s; }
.q.show-az .q-az { display: block; }
.opts { display: grid; gap: 8px; margin: 14px 0; }
.opt { position: relative; display: flex; gap: 12px; align-items: center; padding: 11px 14px; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--surface);
  transition: border-color .15s, background .15s, transform .1s; }
.opt:hover { border-color: var(--border-2); background: var(--surface-2); }
.opt:active { transform: scale(.995); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .letter { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--border-2); font-weight: 800; font-size: 13px; color: var(--muted); transition: all .15s; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt:has(input:checked) .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt:has(input[type=checkbox]) .letter { border-radius: 7px; }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt.is-correct { background: var(--ok-soft); border-color: var(--ok); }
.opt.is-correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-chosen-wrong { background: var(--bad-soft); border-color: var(--bad); }
.opt.is-chosen-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt:has(input:disabled) { cursor: default; }
.num-in { padding: 11px 14px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); width: 240px; max-width: 100%; font-weight: 700; outline: none; transition: border-color .2s; }
.num-in:focus { border-color: var(--accent); }
.verdict { font-weight: 800; margin: 10px 0; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.analysis { border-top: 1px dashed var(--border-2); margin-top: 12px; padding-top: 12px; animation: enter .3s; }
.analysis .wrongs div { margin: 4px 0; }
.score-box { position: sticky; bottom: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: 18px;
  padding: 12px 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; z-index: 4; }
.score-box .score-text { flex: 1; min-width: 160px; font-size: 14px; }
.long-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea.long-ans { width: 100%; min-height: 260px; padding: 12px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface-2); font-family: ui-monospace, Menlo, monospace; font-size: 13px; outline: none; transition: border-color .2s; }
textarea.long-ans:focus { border-color: var(--accent); background: var(--surface); }
.marking label { display: flex; gap: 8px; padding: 4px 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }

/* ---------- home ---------- */
.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 24px; color: #fff; display: flex; gap: 22px; align-items: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%); box-shadow: 0 14px 30px rgba(79, 70, 229, .28); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero::before { width: 260px; height: 260px; right: -70px; top: -110px; }
.hero::after { width: 160px; height: 160px; right: 120px; bottom: -90px; }
.hero h1 { color: #fff; font-size: 26px; }
.hero p { margin: 4px 0 16px; opacity: .9; }
.hero .txt { position: relative; z-index: 1; flex: 1; min-width: 0; }
.hero .btn { background: #fff; color: #4f46e5; border-color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.hero .btn.ghost { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: none; }
.hero .ringbox { position: relative; z-index: 1; }
.hero .ring .trk { stroke: rgba(255, 255, 255, .25); }
.hero .ringbox .in { color: #fff; }
.ring { display: block; transform: rotate(-90deg); }
.ring circle { fill: none; }
.ring .trk { stroke: var(--surface-2); }
.ring .prg { stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.3, .8, .3, 1); }
.ringbox { position: relative; flex: none; display: grid; place-items: center; }
.ringbox > .in { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 800; color: var(--head); line-height: 1.1; }
.ringbox > .in small { display: block; font-size: 11px; font-weight: 700; opacity: .8; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.kpi { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0; }
.kpi .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }
.kpi b { display: block; font-size: 20px; color: var(--head); font-weight: 800; line-height: 1.15; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.action { display: block; text-decoration: none; color: var(--text); padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .15s, border-color .15s, box-shadow .15s; }
.action:hover { transform: translateY(-3px); border-color: var(--c, var(--accent)); box-shadow: var(--shadow); }
.action .ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; margin-bottom: 10px; background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); }
.action b { display: block; color: var(--head); font-weight: 800; }
.action span { font-size: 13px; color: var(--muted); }
.action .cnt { float: right; font-size: 12px; font-weight: 800; color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, transparent); padding: 2px 8px; border-radius: 99px; }
.continue { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text); }
.continue .meta { flex: 1; min-width: 0; }
.continue .meta small { color: var(--accent); font-weight: 800; text-transform: uppercase; font-size: 11px; letter-spacing: .08em; }
.continue .meta b { display: block; color: var(--head); font-size: 17px; font-weight: 800; }
.continue .go { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 20px; flex: none; box-shadow: 0 3px 0 var(--accent-d); transition: transform .15s; }
.continue:hover .go { transform: translateX(3px); }
.week { display: flex; gap: 6px; }
.week .d { flex: 1; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.week .d i { display: grid; place-items: center; height: 34px; border-radius: 10px; background: var(--surface-2); margin-bottom: 4px; font-style: normal; font-size: 14px; }
.week .d.on i { background: var(--orange); color: #fff; box-shadow: 0 2px 0 #c2570c; }
.week .d.today i { outline: 2px solid var(--orange); outline-offset: 1px; }
.group-h { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.group-h h2 { margin: 0; }
.group-h .pill { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }

/* topic cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tcard { position: relative; display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); transition: transform .15s, border-color .15s, box-shadow .15s; }
.tcard:hover { transform: translateY(-2px); border-color: var(--c, var(--accent)); box-shadow: var(--shadow); }
.tcard .tc-main { flex: 1; min-width: 0; }
.tcard .t-num { color: var(--muted); font-size: 12px; font-weight: 700; }
.tcard .t-title { font-weight: 800; color: var(--head); line-height: 1.3; }
.tcard .t-az { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard .ringbox .in { font-size: 13px; }
.tcard.read::after { content: "✓"; position: absolute; top: 10px; right: 12px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--ok); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .8s cubic-bezier(.3, .8, .3, 1); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 18px; min-width: 130px; box-shadow: var(--shadow-sm); }
.stat b { display: block; font-size: 22px; color: var(--head); font-weight: 800; }
.stat span { color: var(--muted); font-size: 13px; }

/* topic header */
.thead { position: relative; overflow: hidden; border-radius: 22px; padding: 22px 24px; color: #fff; display: flex; gap: 18px; align-items: center; background: linear-gradient(135deg, var(--c, #4f46e5), color-mix(in srgb, var(--c, #4f46e5) 55%, #1e1b4b)); }
.duo { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 760px) { .duo { grid-template-columns: 1fr; } }
.thead h1 { color: #fff; margin: 2px 0 2px; }
.thead .k { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.thead .az { opacity: .9; }
.thead .chip { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .3); color: #fff; }
.thead .chips { margin: 10px 0 0; }
.thead .ringbox .in { color: #fff; }
.thead .ring .trk { stroke: rgba(255, 255, 255, .25); }
.thead .txt { flex: 1; min-width: 0; position: relative; z-index: 1; }
.topic-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); }
.topic-foot .sp { flex: 1; }

.gl-table td:first-child { font-weight: 700; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; align-items: center; }
.filters input[type=search] { flex: 1 1 260px; }
.filters input, .filters select { padding: 9px 12px; border: 1px solid var(--border-2); border-radius: 11px; background: var(--surface); outline: none; font-weight: 600; font-size: 14px; transition: border-color .2s; }
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.flash { min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; cursor: pointer; font-size: 24px; font-weight: 800; color: var(--head);
  background: linear-gradient(160deg, var(--surface), var(--accent-soft)); border-width: 2px; border-radius: 22px; transition: transform .2s; user-select: none; animation: flip .35s ease-out; }
.flash:hover { transform: translateY(-2px); }
@keyframes flip { from { transform: rotateX(70deg); opacity: .3; } }
.flash .f-sub { font-size: 15px; font-weight: 600; color: var(--muted); margin-top: 10px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- question bank ---------- */
.why .key { font-weight: 700; padding: 8px 12px; margin: 4px 0 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.why .ans { margin: 10px 0 4px; padding: 10px 14px; border-radius: 10px; background: var(--ok-soft); border-left: 4px solid var(--ok); }
.why .trap, .trap { margin: 10px 0 4px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); border-left: 4px solid var(--warn); }
.why h4 { margin: 10px 0 6px; }
.why ol { padding-left: 22px; }
.why ol li { margin: 4px 0; }
.wrongs-box { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; background: var(--surface); }
.wrongs-box summary { cursor: pointer; font-weight: 700; }
.wrongs-box .wrongs div { margin: 6px 0; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.wrongs-box .wrongs div:last-child { border-bottom: 0; }
.wrongs-box .wrongs div.mine { background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; border-bottom: 0; }
.chip.trapchip { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.chip.lvl { letter-spacing: 1px; }
.chip.lvl.l3 { color: var(--bad); }
.case { border-left: 5px solid var(--accent); }
.q.in-case { margin-left: 16px; border-left: 3px solid var(--accent-soft); }
.case .q-az, .q .q-az { display: none; }
.case.show-az .q-az { display: block; }
table.grid-q { border-collapse: collapse; width: 100%; margin: 10px 0; border: 0; border-radius: 0; }
table.grid-q td { border: 0; border-top: 1px solid var(--border); padding: 9px 6px; vertical-align: middle; }
table.grid-q td.g-opts { white-space: nowrap; text-align: right; }
.gopt { display: inline-flex; align-items: center; gap: 4px; margin: 3px 0 3px 6px; padding: 6px 12px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 14px; transition: all .15s; }
.gopt input { position: absolute; opacity: 0; pointer-events: none; }
.gopt:hover { border-color: var(--border-2); }
.gopt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.gopt.is-correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.gopt.is-chosen-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
tr.row-ok td:first-child { border-left: 4px solid var(--ok); }
tr.row-bad td:first-child { border-left: 4px solid var(--bad); }
.terms-hint { margin: 8px 0; font-size: 14px; }
.terms-hint summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.bank-f .filters { margin: 6px 0; }
@media (max-width: 640px) {
  table.grid-q td.g-opts { white-space: normal; text-align: left; }
  table.grid-q tr { display: flex; flex-direction: column; }
  .gopt { margin: 3px 6px 3px 0; }
  .q.in-case { margin-left: 4px; }
}

/* hints + working sheet */
.q-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.q-tools .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.q-tools .btn.has-data::after { content: " •"; color: var(--accent); }
.hint-n { color: var(--muted); font-size: 12px; margin-left: 2px; }
.hint-box { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; margin: 8px 0; animation: enter .2s; }
.hint-list { margin: 0 0 6px; padding-left: 20px; }
.hint-list li { margin: 4px 0; line-height: 1.5; animation: enter .25s; }
.sheet-box { margin: 8px 0; }
.sheet-scroll { overflow-x: auto; max-width: 100%; }
.sheet { border-collapse: collapse; font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--surface); border-radius: 8px; }
.sheet th { background: var(--surface-2); color: var(--muted); font-weight: 600; padding: 2px 6px; border: 1px solid var(--border); min-width: 24px; }
.sheet td { border: 1px solid var(--border); padding: 0; }
.sheet input { width: 110px; border: 0; padding: 5px 7px; background: transparent; color: var(--text); font: inherit; }
.sheet input:focus { outline: 2px solid var(--accent); outline-offset: -2px; text-align: left; }
.sheet input.numc { text-align: right; }
.sheet input.f { color: var(--accent); }
.sheet input.err { color: #c0392b; }
.sheet-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.sheet-help { font-size: 12px; }
@media (max-width: 600px) { .sheet input { width: 84px; } }

/* profile */
#acct { display: flex; align-items: center; }
.acct-me { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 14px; font-weight: 700; padding: 4px 10px 4px 4px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); }
.acct-me img, .acct-me .ava { width: 30px; height: 30px; border-radius: 50%; }
.acct-me .ava { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #9b5cf6); color: #fff; font-weight: 800; }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.err { background: #d9822b; }
.prof-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.prof-head img { width: 56px; height: 56px; border-radius: 50%; }
.prof-table .bar { height: 6px; margin-top: 4px; min-width: 80px; }
.prof-table .bar i { background: var(--accent); }
.login-card { max-width: 440px; margin: 20px auto; padding: 26px; }
.login-card::before { content: "👋"; display: block; font-size: 40px; text-align: center; margin-bottom: 6px; }
.auth-tabs { position: static; margin-top: 0; }
#authForm label, #gateForm label { display: block; margin: 12px 0; font-size: 14px; font-weight: 700; color: var(--head); }
#authForm input, #gateForm input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; outline: none; transition: border-color .2s; }
#authForm input:focus, #gateForm input:focus { border-color: var(--accent); background: var(--surface); }
#authForm button[type=submit], #gateForm button[type=submit] { width: 100%; padding: 12px; margin-top: 6px; }
.ava.big { width: 60px; height: 60px; font-size: 26px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #9b5cf6); color: #fff; font-weight: 800; box-shadow: 0 4px 0 var(--accent-d); }

/* ---------- mobile tab bar, overlay, toast ---------- */
.tabbar { display: none; }
.scrim { display: none; }
.toast { position: fixed; left: 50%; top: 14px; z-index: 70; transform: translate(-50%, -140%); padding: 11px 18px; border-radius: 14px; background: var(--head); color: var(--bg); font-weight: 700; box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2, 1.3, .4, 1); pointer-events: none; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* phone layout: nothing may be wider than the screen */
.main { min-width: 0; }
select { max-width: 100%; }
@media (max-width: 960px) {
  .kpis, .actions { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  #menuBtn { display: inline-block; }
  .brand span { display: none; }
  #quickSearch { width: 150px; }
  #quickSearch:focus { width: 180px; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); bottom: 0; height: auto; z-index: 30; transform: translateX(-105%); transition: transform .28s cubic-bezier(.3, .8, .3, 1); box-shadow: var(--shadow); padding-bottom: calc(var(--tab-h) + 30px); }
  .sidebar.open { transform: none; }
  .sidebar.open + .main + .scrim, .scrim.on { display: block; position: fixed; inset: var(--top-h) 0 0 0; z-index: 25; background: rgba(10, 12, 30, .35); animation: fade .2s; }
  @keyframes fade { from { opacity: 0; } }
  .main { padding: 18px 16px calc(var(--tab-h) + 40px); }
  .long-grid { grid-template-columns: 1fr; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 6px 4px env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; font-size: 11px; font-weight: 700; color: var(--muted); border-radius: 14px; transition: color .2s, background .2s; }
  .tabbar a span { font-size: 21px; line-height: 1.1; filter: grayscale(1); opacity: .65; transition: transform .2s, filter .2s, opacity .2s; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .tabbar a.active span { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }
  .score-box { bottom: calc(var(--tab-h) + 10px); }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 12px; }
  #quickSearch { display: none; }
  .top-actions { gap: 6px; }
  .icon-btn { padding: 0 9px; }
  .acct-me .nm { display: none; }
  .acct-me { padding: 2px; }
  .main { padding: 14px 12px calc(var(--tab-h) + 40px); }
  h1 { font-size: 24px; }
  .hero { flex-direction: column-reverse; align-items: flex-start; padding: 20px; }
  .hero .ringbox { align-self: center; }
  .thead { padding: 18px; }
  .thead .ringbox { display: none; }
  .kpi { padding: 12px; }
  .kpi .ic { width: 36px; height: 36px; font-size: 18px; }
  .q { padding: 14px 14px; border-radius: 16px; }
  .card { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* phone: glossary-style tables become stacked cards */
@media (max-width: 640px) {
  .gl-table { border: 0; background: none; }
  .gl-table thead { display: none; }
  .gl-table tbody, .gl-table tr, .gl-table td { display: block; }
  .gl-table tr { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; }
  .gl-table td { border: 0; padding: 2px 0; min-width: 0 !important; white-space: normal !important; }
  .gl-table td:first-child { font-size: 16px; color: var(--head); padding-right: 44px; }
  .gl-table td:nth-child(2) { color: var(--accent); font-weight: 700; }
  .gl-table td:nth-child(3) { color: var(--text); font-size: 14px; }
  .gl-table td:nth-child(4):not(:last-child) { font-size: 12px; color: var(--muted); }
  .gl-table td:nth-child(4):not(:last-child):not(:has(i))::before { content: "Mövzu: "; }
  .gl-table td:last-child:has(button) { position: absolute; top: 8px; right: 10px; padding: 0; }
  .gl-table td:empty { display: none; }
  .prof-table td:nth-child(2)::before { content: "Həll edilib: "; color: var(--muted); }
  .prof-table td:nth-child(3)::before { content: "Düzgün: "; color: var(--muted); }
  .prof-table td:nth-child(3), .prof-table td:nth-child(2) { color: var(--text); font-weight: 600; font-size: 14px; }
}

/* results card + test history */
.qres { margin-top: 16px; }
.qres-k { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.qres-k > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.qres-k span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.qres-k b { font-size: 19px; color: var(--head); font-weight: 800; font-variant-numeric: tabular-nums; }
.qres-k .g b { color: var(--ok-d); } .qres-k .r b { color: var(--bad-d); }
.qres-sort { margin: 14px 0 8px; gap: 6px; flex-wrap: wrap; }
.qres-sort .btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.qres-t { width: 100%; border-collapse: collapse; font-size: 14px; }
.qres-t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.qres-t td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.qres-t tbody tr { cursor: pointer; } .qres-t tbody tr:hover { background: var(--surface-2); }
.qres-t .mk { font-weight: 800; } .qres-t tr.ok .mk { color: var(--ok-d); } .qres-t tr.bad .mk { color: var(--bad-d); }
.qres-t .tt { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.okc { color: var(--ok-d); } .badc { color: var(--bad-d); }
.hist-t td:first-child { white-space: nowrap; }
.q.hl { animation: hl 1.6s ease; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } }
