/* App shell for signed-in pages (candidate home, test rules, admin): translucent navbar,
   a source-list sidebar, and pages made of grouped white sections with hairline rows.
   On phones the sidebar becomes a drawer. Sign-in pages (body.is-auth) hide the shell. */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 52px); }
body.is-auth .shell { display: block; }
body.is-auth .side, body.is-auth .scrim { display: none; }
body.is-auth .shell > main { max-width: none; padding: 0; }
.bar-left { display: flex; align-items: center; gap: 10px; }
.bar-right { display: flex; align-items: center; gap: 14px; }
.menu-btn { display: none; }

/* Avatar and its card: name, email, role, sign out */
.user-menu { position: relative; }
.avatar-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font: 600 14px var(--sans); cursor: pointer; }
.avatar-btn:hover { background: var(--accent-hover); }
.avatar-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.user-pop { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; width: 264px; overflow: hidden;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14); }
.user-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.avatar-sm { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent); font-size: 13px; font-weight: 600; }
.who { display: grid; min-width: 0; line-height: 1.3; }
.who b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta { display: grid; gap: 8px; justify-items: start; padding: 0 14px 12px; }
.meta-label { display: block; margin-bottom: 4px; color: var(--faint); font-size: 11px; font-weight: 600; }
.user-roles ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.user-roles li { padding: 2px 8px; border-radius: 6px; background: var(--fill); font-size: 12px; }
.role-badge { padding: 1px 8px; border-radius: 980px; font-size: 11px; font-weight: 600;
  background: var(--accent-tint); color: var(--accent); }
.role-badge.admin { background: rgba(0, 113, 227, 0.12); color: #0066cc; }
.role-badge.super_admin { background: rgba(175, 82, 222, 0.14); color: #9b45c9; }
:root[data-theme="dark"] .role-badge.admin { color: #4ea6ff; }
:root[data-theme="dark"] .role-badge.super_admin { color: #d08cf0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .role-badge.admin { color: #4ea6ff; }
  :root:not([data-theme="light"]) .role-badge.super_admin { color: #d08cf0; }
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0;
  border-top: 1px solid var(--rule); background: none; color: var(--ink); font: 13.5px var(--sans); text-align: left; cursor: pointer; }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { outline: none; background: var(--fill); }
a.menu-item { text-decoration: none; }

/* Home: reminder to agree to the rules */
.rules-notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 28px;
  padding: 16px 20px; border-radius: 14px; background: var(--warn-tint); color: var(--ink); }
.rules-notice:hover { text-decoration: none; filter: brightness(0.98); }
.rules-notice b { display: block; color: var(--warn); }
.rules-notice span span, .rules-notice > span:first-child { font-size: 14px; }
.rules-notice .go { font-size: 24px; color: var(--warn); }

/* Rules page: the agreement */
.agree-box { padding: 18px 20px; border-radius: 14px; background: var(--sheet); }
.agree-box .check { margin-top: 0; }
.agree-box .btn { margin-top: 14px; }
.agreed { color: var(--accent); font-weight: 600; }

/* Technical test hand-in */
.multi-note { margin-top: 24px; padding: 14px 18px; border-radius: 14px; background: var(--accent-tint); color: var(--ink);
  font-size: 14.5px; }
.handins { display: grid; gap: 12px; }
.handin { padding: 18px 20px; border-radius: 14px; background: var(--sheet); }
.handin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.handin-head b { font-size: 16px; font-weight: 600; }
.handin-slot { margin-top: 6px; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.handin-slot.open { color: var(--accent); font-weight: 600; }
.handin-task { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); }
.handin-task b { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.handin-task p { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.handin-form { display: flex; gap: 10px; margin-top: 14px; }
.handin-form .input { flex: 1; min-width: 0; padding: 10px 14px; font-size: 15px; }
.handin-form .btn { flex: none; padding: 10px 18px; }
.handin-meta { margin-top: 10px; color: var(--muted); font-size: 13px; }
.file-input { padding: 8px 10px; font-size: 14px; cursor: pointer; }
.file-input::file-selector-button { margin-right: 12px; padding: 6px 14px; border: 0; border-radius: 980px;
  background: var(--fill); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; }
.handin .message { min-height: 0; margin-top: 6px; }
.handin .muted.small { margin-top: 10px; }

/* Sidebar */
.side { position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; display: flex; flex-direction: column;
  gap: 1px; padding: 20px 12px 16px; border-right: 1px solid var(--rule); background: var(--paper); }
.side-label { margin: 20px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--faint); }
.side > .side-label:first-child, .side > .side-group:first-child .side-label { margin-top: 0; }
/* Folding groups (Tutorial, Start here, Test): the heading opens and shuts its links; the
   choice is kept in this browser and applied before drawing (theme-init.js). */
.side-toggle { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 20px); padding: 0;
  border: 0; background: none; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--faint); cursor: pointer; text-align: left; }
.side-toggle:hover { color: var(--ink); }
.side-toggle:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.side-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.side-items { display: flex; flex-direction: column; gap: 1px; }
html[data-side-closed~="tutorial"] [data-group="tutorial"] .side-items,
html[data-side-closed~="start"] [data-group="start"] .side-items,
html[data-side-closed~="test"] [data-group="test"] .side-items { display: none; }
html[data-side-closed~="tutorial"] [data-group="tutorial"] .side-toggle svg,
html[data-side-closed~="start"] [data-group="start"] .side-toggle svg,
html[data-side-closed~="test"] [data-group="test"] .side-toggle svg { transform: rotate(-90deg); }
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink);
  font-size: 14px; }
.side-link .num { display: none; }
.side-link:hover { background: var(--fill); text-decoration: none; }
.side-link.active { background: var(--fill); font-weight: 600; }
.side-link.off { color: var(--faint); cursor: default; }
.side-link.off:hover { background: none; }
.side-link em { margin-left: auto; font-size: 11px; font-style: normal; color: var(--faint); }
.side-foot { margin: auto 10px 0; padding-top: 14px; border-top: 1px solid var(--rule); color: var(--faint); font-size: 11.5px; line-height: 1.45; }
.side-foot p + p { margin-top: 6px; }
.scrim { display: none; }

/* Page */
.shell > main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 44px clamp(20px, 4vw, 56px) 80px; }
.doc-head h1 { margin-top: 6px; }
.doc-sub { margin-top: 6px; color: var(--muted); font-size: 17px; }
.block { margin-top: 36px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 0 4px 8px; }
.note { margin-top: 10px; padding: 0 4px; color: var(--faint); font-size: 12.5px; }
.group { background: var(--sheet); border-radius: 14px; }

/* Candidate home: next deadline */
.next-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 22px 24px;
  background: var(--sheet); border-radius: 14px; }
.next-card b { display: block; font: 600 21px/1.2 var(--display); letter-spacing: -0.02em; }
.next-card .mono { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.countdown { font: 600 30px/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; text-align: right; }
.countdown small { display: block; margin-top: 6px; font: 400 12.5px var(--sans); color: var(--faint); letter-spacing: 0; }

/* Candidate home: your timeline, four stops on a line (a column on phones) */
.journey { display: grid; grid-template-columns: repeat(var(--stops, 4), minmax(0, 1fr)); margin: 0; padding: 22px 24px; list-style: none;
  background: var(--sheet); border-radius: 14px; }
.journey li { position: relative; padding: 24px 16px 0 0; }
.journey li::before { content: ""; position: absolute; top: 6px; left: 14px; right: 0; height: 2px; background: var(--rule); }
.journey li:last-child::before { display: none; }
.journey li::after { content: ""; position: absolute; top: 0; left: 0; width: 14px; height: 14px; box-sizing: border-box;
  border: 2px solid var(--accent); border-radius: 50%; background: var(--sheet); }
.journey li.done::after, .journey li.now::after { background: var(--accent); }
.journey li.now::after { box-shadow: 0 0 0 4px var(--accent-tint); }
.journey b { display: block; font-size: 15px; font-weight: 600; }
.journey span { display: block; margin-top: 4px; color: var(--ink); font-size: 14px; }
.journey small { display: block; margin-top: 4px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* Candidate home: steps, a table in a grouped section */
.steps { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--sheet); border-radius: 14px; }
.steps th { padding: 12px 14px 10px 0; border-bottom: 1px solid var(--rule); text-align: left; font-size: 12px;
  font-weight: 600; color: var(--faint); }
.steps td { padding: 16px 14px 16px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.steps tr:last-child td { border-bottom: 0; }
.steps th:first-child, .steps td:first-child { padding-left: 20px; }
.steps td:last-child, .steps th:last-child { padding-right: 20px; text-align: right; }
.steps .n { width: 44px; color: var(--faint); font-variant-numeric: tabular-nums; }
.steps b { font-weight: 600; }
.steps .detail { margin-top: 2px; color: var(--muted); font-size: 13.5px; max-width: 46ch; }
.steps .due { font-size: 13.5px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
/* A heading row per role (home.js): "AI Engineer · 2 steps" */
.steps tr.step-group td { padding: 22px 20px 8px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent); }
.steps tr.step-group td .step-group-count { margin-left: 10px; color: var(--faint); font-weight: 500; letter-spacing: 0.02em; text-transform: none; }

/* Admin: figures in a grouped section */
.figures { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; background: var(--sheet); border-radius: 14px; }
.figures div { padding: 18px 20px; }
.figures div + div { border-left: 1px solid var(--rule); }
.figures dt { font-size: 12.5px; color: var(--muted); }
.figures dd { margin: 6px 0 0; font: 600 32px/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figures .lead-figure dd { color: var(--accent); }
.plain-list { margin: 0; padding: 0 20px; list-style: none; background: var(--sheet); border-radius: 14px; }
.plain-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 15px 0; border-bottom: 1px solid var(--rule); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list .n { color: var(--faint); font-variant-numeric: tabular-nums; }
.plain-list b { display: block; font-weight: 600; }
.plain-list span { color: var(--muted); font-size: 13.5px; }
.plain-list em { font-size: 12px; font-style: normal; color: var(--faint); }

@media (max-width: 1100px) {
  .journey { grid-template-columns: 1fr; gap: 18px; }
  .journey li { padding: 0 0 0 28px; }
  .journey li::before { top: 18px; bottom: -18px; left: 6px; right: auto; width: 2px; height: auto; }
}
@media (max-width: 900px) {
  .shell { display: block; }
  .menu-btn { display: grid; }
  .side { position: fixed; z-index: 30; top: 52px; bottom: 0; left: 0; width: min(280px, 85vw); height: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); transform: translateX(-104%); transition: transform 0.25s ease; }
  body.side-open .side { transform: none; }
  body.side-open .scrim { display: block; position: fixed; z-index: 25; inset: 52px 0 0; background: rgba(0, 0, 0, 0.25); }
  .bar { padding: 0 14px; }
  .shell > main { padding-top: 28px; }
  h1 { font-size: 32px; }
  .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .figures div:nth-child(n + 4) { border-top: 1px solid var(--rule); }
  .figures div:nth-child(4) { border-left: 0; }
}
@media (max-width: 640px) {
  .brand small { display: none; }
  .next-card { grid-template-columns: 1fr; }
  .countdown { text-align: left; }
  .steps thead { display: none; }
  .steps, .steps tbody { display: block; }
  .steps tr { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 6px; padding: 14px 16px;
    border-bottom: 1px solid var(--rule); }
  .steps tr:last-child { border-bottom: 0; }
  .steps td, .steps td:first-child, .steps td:last-child { padding: 0; border: 0; text-align: left; }
  .steps td:not(.n) { grid-column: 2; }
  .steps .status, .steps .due { margin-top: 6px; }
  .steps td:last-child { margin-top: 10px; }
  .steps tr.step-group { display: block; padding: 18px 16px 8px; }
  .steps tr.step-group td { display: block; padding: 0; margin: 0; }
  .handin-form { flex-direction: column; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures div:nth-child(n) { border-left: 0; border-top: 1px solid var(--rule); }
  .figures div:nth-child(-n + 2) { border-top: 0; }
  .figures div:nth-child(even) { border-left: 1px solid var(--rule); }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
/* A project task shown as a small document (task-text.js) */
.task-doc { margin-top: 8px; line-height: 1.55; overflow-wrap: anywhere; }
.task-doc p { margin: 8px 0 0; white-space: normal; }
.task-doc .task-h { margin: 22px 0 4px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; }
.task-doc h3.task-h { font-size: 21px; }
.task-doc h4.task-h { font-size: 17.5px; }
.task-doc h5.task-h { font-size: 15.5px; }
.task-doc .task-h:first-child { margin-top: 4px; }
.task-doc .task-list { margin: 8px 0 0; padding-left: 22px; }
.task-doc .task-list li { margin-top: 4px; }
.task-doc code { font: 0.92em var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--accent-tint); }
.task-doc .task-code { margin: 8px 0 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; overflow-x: auto;
  font: 13px/1.5 var(--mono); white-space: pre; }
.task-doc .task-code code { padding: 0; background: none; font: inherit; }
.task-doc .task-file { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.task-doc .task-file-name { font: 600 13px var(--mono); }
.task-doc .task-download { margin-top: 0; padding: 7px 14px; font-size: 13.5px; }
