/* Test engine */
.x-intro { display: grid; gap: 22px; }
.mode-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mode-card {
  text-align: left; cursor: pointer; padding: 20px; border-radius: var(--radius-m); background: var(--surface);
  border: 1.5px solid var(--border); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 8px;
  transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--mc); box-shadow: var(--shadow-2); }
.mode-card .mi { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.4rem; background: color-mix(in srgb, var(--mc) 14%, transparent); }
.mode-card h3 { margin: 4px 0 0; }
.mode-card p { margin: 0; color: var(--text-2); font-size: .93rem; }
.mode-card .go { margin-top: auto; padding-top: 8px; font-weight: 900; color: var(--mc); }
.mode-card[data-mode="step"] { --mc: var(--info); }
.mode-card[data-mode="learn"] { --mc: var(--ok); }
.mode-card[data-mode="exam"] { --mc: var(--bad); }
.resume { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--radius-m); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.resume p { margin: 0; flex: 1; min-width: 200px; font-weight: 700; }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { flex: 1; min-width: 120px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--border); }
.stat b { display: block; font-size: 1.4rem; font-weight: 900; line-height: 1.2; }
.stat span { color: var(--text-3); font-weight: 700; font-size: .8rem; }

.x-run { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 22px; align-items: start; }
.x-run.no-palette { grid-template-columns: minmax(0, 1fr); max-width: 820px; margin: 0 auto; }
@media (max-width: 900px) { .x-run { grid-template-columns: minmax(0, 1fr); } }
body.focus .sidebar { transform: translateX(-102%); }
body.focus .sidebar.open { transform: none; box-shadow: var(--shadow-3); }
body.focus .main { margin-left: 0; }
body.focus .menu-btn { display: grid; }
.x-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.x-head .title { font-weight: 900; font-size: 1.05rem; margin-right: auto; }
.timer { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 900; font-size: 1.05rem; padding: 6px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.timer.low { background: var(--bad-soft); color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 40%, transparent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.x-progress { height: 6px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.x-progress > i { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .35s var(--ease); }

.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 26px; box-shadow: var(--shadow-1); animation: rise .35s var(--ease); }
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.q-num { font-weight: 900; color: var(--text-3); font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; margin-right: 4px; }
.q-text { font-size: 1.14rem; font-weight: 750; line-height: 1.55; margin-bottom: 18px; }
.q-figure { margin: 0 0 18px; padding: 14px; border-radius: var(--radius-m); background: var(--surface-2); border: 1px solid var(--border); display: flex; justify-content: center; }
.q-figure svg { max-height: 260px; width: auto; max-width: 100%; }
.q-options { display: grid; gap: 10px; }
.q-options.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.q-options .opt { min-height: 56px; font-size: 1.02rem; }
.q-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 22px; }
.q-actions .spacer { flex: 1; }
.flag-btn[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-text); }
.sol { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-m); animation: pop .3s var(--ease); }
.sol.ok { background: var(--ok-soft); } .sol.bad { background: var(--bad-soft); } .sol.neutral { background: var(--surface-2); border: 1px solid var(--border); }
.sol h4 { margin: 0 0 6px; }
.sol .trap { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-strong); font-size: .93rem; }

.palette { position: sticky; top: calc(var(--topbar-h) + 16px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 18px; box-shadow: var(--shadow-1); max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto; }
.palette h4 { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 14px 0 8px; }
.palette h4:first-of-type { margin-top: 0; }
.pal-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.pal-grid button { position: relative; aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 900; font-size: .88rem; cursor: pointer; color: var(--text-2); }
.pal-grid button.seen { border-color: var(--border-strong); background: var(--surface-2); }
.pal-grid button.answered { background: var(--ok); border-color: var(--ok); color: #fff; }
.pal-grid button.flagged::after { content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.pal-grid button.current { outline: 3px solid var(--brand); outline-offset: 1px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 16px 0; font-size: .78rem; color: var(--text-2); font-weight: 700; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--border); display: inline-block; }
.legend .l-ans { background: var(--ok); border-color: var(--ok); }
.legend .l-seen { background: var(--surface-2); border-color: var(--border-strong); }
.legend .l-flag { background: var(--warn); border-color: var(--warn); border-radius: 50%; }
.palette-toggle { display: none; }
@media (max-width: 900px) {
  .palette { position: fixed; inset: auto 0 0 0; top: auto; max-height: 70vh; border-radius: 22px 22px 0 0; z-index: 80; transform: translateY(105%); transition: transform .3s var(--ease); box-shadow: var(--shadow-3); }
  .palette.open { transform: none; }
  .palette-toggle { display: inline-flex; }
}

.modal-back { position: fixed; inset: 0; z-index: 120; background: rgba(8, 10, 20, .5); display: grid; place-items: center; padding: 16px; animation: pop .2s; }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: var(--radius-l); padding: 24px; box-shadow: var(--shadow-3); border: 1px solid var(--border); }
.modal h3 { margin-top: 0; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal .jump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Results */
.res-hero { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; }
@media (max-width: 640px) { .res-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.ring { --p: 0; width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--brand)) calc(var(--p) * 1%), var(--bg-soft) 0); position: relative; transition: --p 1s; }
.ring::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; text-align: center; }
.ring b { font-size: 2.3rem; font-weight: 900; display: block; line-height: 1; }
.ring span { color: var(--text-3); font-weight: 800; font-size: .85rem; }
.breakdown { display: grid; gap: 12px; }
.bd-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr auto; gap: 12px; align-items: center; font-weight: 700; font-size: .93rem; }
.bd-row .track { height: 10px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bd-row .track i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--brand)); width: 0; transition: width 1s var(--ease); }
@media (max-width: 560px) { .bd-row { grid-template-columns: 1fr auto; } .bd-row .track { grid-column: 1 / -1; grid-row: 2; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.tabs button { min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-weight: 800; font-size: .88rem; cursor: pointer; color: var(--text-2); }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.review-item { margin-bottom: 16px; }
.review-item .q-card { animation: none; padding: 20px; }
.review-item .your { font-weight: 800; font-size: .88rem; margin-top: 10px; }

/* Rough work pad */
.rough { position: fixed; inset: auto 0 0 0; height: min(62vh, 560px); z-index: 90; background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-3); border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform .3s var(--ease); display: flex; flex-direction: column; }
.rough.open { transform: none; }
.rough header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 900; }
.rough canvas { flex: 1; width: 100%; touch-action: none; background-image: radial-gradient(var(--border-strong) 1px, transparent 1px); background-size: 22px 22px; }
html.rough-on, html.rough-on body { overflow: hidden; }

/* Test hub */
.test-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.t-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: all .18s var(--ease); position: relative; }
.t-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.t-card .t-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.t-card b { font-size: 1rem; }
.t-card small { color: var(--text-3); font-weight: 700; }
.t-card .sub { color: var(--text-2); font-size: .9rem; font-weight: 700; }
.t-card .t-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
