/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, var(--bg-top), var(--bg) 20rem) no-repeat, var(--bg); color: var(--ink); font: 400 1rem/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 50; background: var(--surface); color: var(--ink); padding: .6rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--r-control); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
h1 { font-size: clamp(1.75rem, 1.1rem + 2vw, 2.75rem); line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.01em; font-weight: 700; margin: 2rem 0 .75rem; }
p, li { max-width: 68ch; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.hint { color: var(--ink-2); margin: .25rem 0 .5rem; font-size: .925rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Public frame (candidate site, signed-out staff pages) ---------- */
header.site { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem clamp(1rem, 3vw, 2rem); }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; }
/* A 44px hit area. Only the icon-only and header brands centre their content; the sidebar brand stays left-aligned. */
a.brand { min-height: 2.75rem; min-width: 2.75rem; }
.topbar-brand, header.site a.brand { justify-content: center; }
.brand img { border-radius: 6px; }
/* The mark is solid black: invert it to white on the dark themes (the print block below undoes this). */
:root[data-theme="dark"] .brand img { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .brand img { filter: invert(1); }
}
.wordmark { letter-spacing: .28em; font-weight: 700; font-size: .85rem; }
.brand-sub { color: var(--ink-2); font-size: .85rem; font-weight: 500; }
.site-tools { display: flex; align-items: center; gap: .75rem; }
main { max-width: 46rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 4rem; }
main.wide { max-width: 90rem; }
footer.site { padding: 1.25rem clamp(1rem, 3vw, 2rem) 2rem; color: var(--ink-2); font-size: .85rem; }
footer.site p { margin: .2rem 0; }

/* ---------- Cards and page heads ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: 1.25rem 1.4rem; margin: 1rem 0; }
.card > :first-child, .panel > :first-child { margin-top: 0; }
.card > :last-child, .panel > :last-child { margin-bottom: 0; }
.card-title { font-size: 1rem; font-weight: 700; margin: 0 0 .5rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .4rem 0 0; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Buttons ---------- */
.button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding: .6rem 1.15rem; font: inherit; font-weight: 600; line-height: 1.2; border-radius: var(--r-control); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; user-select: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); transition: transform var(--dur-press) var(--ease-out); }
.button:active { transform: scale(0.97); }
.button:hover { border-color: var(--control-border); }
.button.primary { background: linear-gradient(180deg, var(--sheen-top), var(--accent)); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.secondary { color: var(--accent-text); }
.button.danger { color: var(--critical); border-color: var(--critical); }
.button.link { padding: .25rem .1rem; border: none; background: none; box-shadow: none; color: var(--accent-text); text-decoration: underline; text-underline-offset: .18em; font-weight: 500; }
.button.link:active { transform: none; }
/* Nothing animates on any candidate test page: no press shrink, no dialog pop. */
#part-form .button:active, #gate-form .button:active, .test-bar .button:active, .test-review .button:active, .test-overview .button:active, #qmap-dialog .button:active { transform: none; }
#qmap-dialog[open] { animation: none; }
.button[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1.25rem 0 0; }
.secondary-action { margin-top: 1rem; }
.inline-form { display: inline; }

/* ---------- Forms ---------- */
.field { margin: 1.25rem 0; }
fieldset { min-width: 0; }
fieldset.field { border: 1px solid var(--line); border-radius: var(--r-card); padding: 1rem 1.25rem; margin: 1.25rem 0; background: var(--surface); }
legend { font-weight: 650; padding: 0 .35rem; }
label { font-weight: 550; }
.field > label { display: block; margin-bottom: .35rem; }
.field > label.choice { display: flex; margin: .4rem 0; }
.choice { display: flex; align-items: flex-start; gap: .7rem; margin: .4rem 0; padding: .7rem .85rem; min-height: 2.75rem; border: 1px solid var(--line-table); border-radius: var(--r-control); background: var(--surface); font-weight: 400; cursor: pointer; }
.choice:hover { border-color: var(--control-border); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: .2rem 0 0; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; }
input[type=url], input[type=text], input[type=email], input[type=file], .code-input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); padding: .6rem .75rem; min-height: 2.75rem; border: 1px solid var(--control-border); border-radius: var(--r-control); width: 100%; max-width: 32rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.code-input { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .3em; max-width: 12rem; }
.has-error { border-left: 3px solid var(--critical); padding-left: .9rem; }
fieldset.has-error { border-color: var(--critical); }
.error { color: var(--critical); font-weight: 600; margin: .25rem 0 .5rem; }
.error:empty { display: none; }

/* ---------- Notices ---------- */
.error-summary { border: 1px solid var(--critical); background: var(--critical-soft); border-radius: var(--r-card); padding: 1rem 1.25rem; margin: 0 0 1.5rem; }
.error-summary h2 { margin: 0 0 .5rem; font-size: 1.05rem; color: var(--critical); }
.error-summary a { color: var(--critical); }
.notice, .phone-note { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); box-shadow: var(--shadow-1); border-radius: var(--r-control); padding: .8rem 1rem; }
.notice.warning { border-left-color: var(--warning); }
.phone-note { display: none; }

/* ---------- Tables: crisp, 8px corners, shaded uppercase header ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-table); border-radius: var(--r-table); background: var(--surface); margin: 1rem 0; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; margin: 1rem 0; }
.table-wrap table.data { margin: 0; }
table.data th, table.data td { text-align: left; padding: .65rem .85rem; border-bottom: 1px solid var(--line-table); vertical-align: top; }
table.data thead th { background: var(--raised); color: var(--ink-2); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
table.data tbody tr:last-child > * { border-bottom: none; }
table.data tbody th { font-weight: 600; }
table.data .num { text-align: right; }

/* ---------- Pills, statuses, stats, empty states ---------- */
.pill, .status { display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .6rem; border-radius: var(--r-pill); font-size: .8rem; font-weight: 600; line-height: 1.6; background: var(--raised); color: var(--ink-2); white-space: nowrap; }
.pill[data-tone="accent"] { background: var(--accent-soft); color: var(--accent-text); }
.pill[data-tone="ok"], .status.ok { background: var(--ok-soft); color: var(--ok); }
.pill[data-tone="warning"] { background: var(--warning-soft); color: var(--warning); }
.pill[data-tone="critical"], .status.bad { background: var(--critical-soft); color: var(--critical); }
.pass { color: var(--ok); font-weight: 600; }
.fail { color: var(--critical); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: 1rem 1.2rem; }
.stat-value { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.stat-label { color: var(--ink-2); font-size: .875rem; }
.empty { display: grid; justify-items: center; gap: .3rem; text-align: center; padding: 2.5rem 1.5rem; border: 1px dashed var(--line-strong); border-radius: var(--r-card); color: var(--ink-2); }
.empty strong { color: var(--ink); }
.one-time { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .2em; }

/* ---------- Menus (details), dialogs, theme switch ---------- */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; gap: .5rem; min-height: 2.75rem; padding: .35rem .6rem; border-radius: var(--r-control); user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary:hover { background: var(--raised); }
.menu-panel { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; min-width: 14rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-2); padding: .5rem; transform-origin: top right; }
details.menu[open] > .menu-panel { animation: pop var(--dur-pop) var(--ease-out); }
.menu-panel a, .menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 2.75rem; padding: .5rem .7rem; border-radius: var(--r-control); color: var(--ink); text-decoration: none; font: inherit; background: none; border: none; cursor: pointer; text-align: left; }
.menu-panel a:hover, .menu-item:hover { background: var(--raised); }
dialog { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); padding: 1.25rem 1.4rem; max-width: min(32rem, calc(100vw - 2rem)); }
dialog[open] { animation: pop var(--dur-dialog) var(--ease-out); }
dialog::backdrop { background: var(--backdrop); }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.theme-switch { display: inline-flex; gap: 8px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); }
.theme-switch button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2rem; border: none; border-radius: var(--r-pill); background: none; color: var(--ink-2); cursor: pointer; }
.theme-switch button::after { content: ''; position: absolute; inset: -6px -4px; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--control-border); }
.theme-swap, .theme-swap *, .theme-swap *::before, .theme-swap *::after { transition: none !important; animation: none !important; }

/* ---------- Candidate test (the v2 layout is added in Task 7) ---------- */
.prose p { white-space: pre-line; margin: 0 0 .8rem; }
pre.code { font-family: var(--mono); font-size: .875rem; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control); padding: .75rem 1rem; overflow-x: auto; white-space: pre; }
.test-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 0; margin-bottom: 1rem; background: var(--bg-top); border-bottom: 1px solid var(--line); }
.part-label { margin: 0; font-weight: 600; }
.timer { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--mono); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); border-radius: var(--r-pill); padding: .35rem .85rem; }
.timer-label { font-family: var(--font); color: var(--ink-2); font-size: .875rem; }
.timer-value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
fieldset.question { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-1); padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; }
.section { margin: 0 0 2rem; }
.section.with-scenario { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.scenario { position: sticky; top: 4.5rem; max-height: calc(100vh - 6rem); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--raised); padding: 1rem 1.25rem; }
.statements { margin: .5rem 0 .75rem 1.25rem; }
.q-number { font-family: var(--mono); font-size: .85rem; color: var(--ink-2); }
.save-state { min-height: 1.3rem; color: var(--ink-2); font-size: .875rem; margin: 0 0 .5rem; }
.next-note { color: var(--ink-2); }

/* ---------- Staff app shell ---------- */
.app-shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1.1rem .8rem; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 1.25rem; }
.sidebar .brand { padding: .25rem .6rem; min-height: 2.75rem; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list li { max-width: none; }
.nav-list a { display: flex; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .45rem .7rem; border-radius: var(--r-control); border: 1px solid transparent; color: var(--ink-2); text-decoration: none; font-weight: 550; }
.nav-list a:hover { color: var(--ink); background: var(--raised); }
.nav-list a[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem; padding: .6rem clamp(1rem, 3vw, 2rem); background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-section { margin: 0; font-weight: 600; color: var(--ink-2); }
.topbar-brand { display: none; min-height: 2.75rem; align-items: center; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.nav-menu { display: none; }
.nav-menu .menu-panel { left: 0; right: auto; transform-origin: top left; }
.app-main main { max-width: 72rem; width: 100%; margin: 0; padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem; }
.app-main main.wide { max-width: 90rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700; }
.menu-meta { display: grid; gap: .1rem; padding: .5rem .7rem .7rem; margin: 0 0 .35rem; border-bottom: 1px solid var(--line); font-size: .875rem; color: var(--ink-2); }
.menu-meta strong { color: var(--ink); }

/* ---------- Interview kit and result page ---------- */
.kit-item + .kit-item { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.back-link a { display: inline-flex; align-items: center; gap: .25rem; min-height: 2.75rem; }

.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { max-width: none; border-top: 1px solid var(--line); }
.attention-list li:first-child { border-top: none; }
.attention-list a { display: block; padding: .7rem 0; color: var(--ink); text-decoration: none; }
.attention-list a:hover { color: var(--accent-text); text-decoration: underline; }

/* ---------- Candidate test v2 ---------- */
[hidden] { display: none !important; }
.overview-list { list-style: none; margin: 1rem 0 1.5rem; padding: 0; display: grid; gap: .6rem; }
.overview-list li { max-width: none; display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: .9rem 1.1rem; }
.overview-step { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--raised); font-family: var(--mono); font-weight: 600; }
.rules li { margin: .35rem 0; }
.test-bar-tools { display: flex; align-items: center; gap: .6rem; }
.test-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.qmap { position: sticky; top: 5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: 1rem; }
dialog .qmap { position: static; box-shadow: none; border: none; padding: 0; }
.qmap-title { margin: 0 0 .6rem; font-weight: 700; font-size: .9rem; }
.qmap-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: .35rem; }
.qmap-item { position: relative; display: flex; align-items: center; justify-content: center; min-height: 2.75rem; border: 1px solid var(--line-table); border-radius: var(--r-control); color: var(--ink); background: var(--surface); text-decoration: none; font-family: var(--mono); font-weight: 600; }
.qmap-item[data-answered="yes"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.qmap-item[data-flagged="yes"] { border-color: var(--warning); }
.qmap-item[data-flagged="yes"]::after { content: ''; position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 2px var(--surface); }
.qmap-item[aria-current="step"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.qmap-legend { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .25rem; font-size: .8rem; color: var(--ink-2); }
.qmap-legend li { display: flex; align-items: center; gap: .45rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; border: 1px solid var(--line-table); }
.swatch.answered { background: var(--accent); border-color: var(--accent); }
.swatch.flagged { background: var(--warning); border-color: var(--warning); border-radius: 50%; }
.swatch.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.qmap-open { display: none; }
.options { display: grid; margin-top: .75rem; }
.flag-toggle { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; margin-top: .75rem; padding: .35rem .75rem; border-radius: var(--r-pill); color: var(--ink-2); font-weight: 550; cursor: pointer; user-select: none; }
.flag-toggle:hover { color: var(--ink); background: var(--raised); }
.flag-toggle input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--warning); }
.flag-toggle:has(input:checked) { color: var(--warning); background: var(--warning-soft); }
.test-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.test-actions-gap { flex: 1; }
.timer-off { display: none; font-family: var(--font); color: var(--ink-2); font-size: .875rem; }
.timer[data-hidden="yes"] .timer-value { display: none; }
.timer[data-hidden="yes"] .timer-off { display: inline; }
.timer[data-hidden="yes"][data-warn] .timer-value { display: inline; }
.timer[data-hidden="yes"][data-warn] .timer-off { display: none; }
.timer[data-warn="warning"] { border-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.timer[data-warn="critical"] { border-color: var(--critical); background: var(--critical-soft); color: var(--critical); }
.timer-toggle { position: relative; font: inherit; font-family: var(--font); font-size: .8rem; color: var(--accent-text); background: none; border: none; text-decoration: underline; cursor: pointer; padding: .25rem; }
.timer-toggle::after { content: ''; position: absolute; inset: -10px -4px; }
.review-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.review-list a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: .3rem .8rem; border: 1px solid var(--line-table); border-radius: var(--r-control); text-decoration: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .nav-menu { display: block; }
  .topbar-brand { display: inline-flex; }
  .account-name { display: none; }
  .section.with-scenario { grid-template-columns: 1fr; }
  .scenario { position: static; max-height: none; }
  .test-layout { grid-template-columns: 1fr; }
  .js .qmap-home { display: none; }
  .js .qmap-open { display: inline-flex; }
}
@media (max-width: 720px) {
  .phone-note { display: block; }
}
@media (max-width: 420px) {
  .topbar-section { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .button:active { transform: none; }
  @keyframes pop { from { opacity: 0; } }
}
@media print {
  .app-main main, .app-main main.wide { max-width: none; padding: 0; }
  .sidebar, .topbar { display: none !important; }
  :root[data-theme] .brand img { filter: none; }
  .app-shell { display: block; }
  header.site, footer.site, .no-print, .button, .theme-switch { display: none !important; }
  body { background: #fff; color: #000; }
  main, main.wide { max-width: none; padding: 0; }
  .card, .panel, .stat, fieldset.question, .table-wrap { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  table.data thead th { background: #eee; color: #000; }
  h2 { break-after: avoid; }
  .kit-item { break-inside: avoid; }
  .card:has(.kit-item) { break-inside: auto; }
}
.auth-card { max-width: 28rem; margin: 2rem auto; }
.auth-card h1 { font-size: 1.75rem; }
