/*
 * OAuth School. One stylesheet, no build step, in the style of TinyLogin and
 * client.xaa.rocks: colours and spacing are custom properties, so dark mode is
 * a matter of redefining them.
 *
 * The course site is teal. The practice authorization server's own pages
 * (login, consent) use .server, which is deliberately a different-looking site,
 * so learners can see the moment they leave the app and arrive at the
 * authorization server.
 */

:root {
    --bg: #f6f8f8;
    --surface: #ffffff;
    --surface-2: #f0f4f4;
    --ink: #142024;
    --muted: #5b6b70;
    --line: #dce4e5;
    --accent: #0b7a75;
    --accent-ink: #ffffff;
    --accent-soft: #e1f2f1;
    --ok: #137a4b;
    --ok-soft: #e3f5ec;
    --warn: #7a5c00;
    --warn-soft: #fbf1cc;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --server: #3b2f8f;
    --server-soft: #ece9fb;
    --radius: 12px;
    --radius-small: 7px;
    --shadow: 0 1px 2px rgb(16 24 32 / 5%), 0 4px 16px rgb(16 24 32 / 5%);
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1517;
        --surface: #172024;
        --surface-2: #1d282c;
        --ink: #e6eef0;
        --muted: #98a9ae;
        --line: #2a383c;
        --accent: #4fd1c5;
        --accent-ink: #062523;
        --accent-soft: #143331;
        --ok: #5fd39a;
        --ok-soft: #173327;
        --warn: #e8c95a;
        --warn-soft: #332a0e;
        --danger: #ff8d85;
        --danger-soft: #3b1d1b;
        --server: #a99cff;
        --server-soft: #241f45;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.015em; }
h2 { font-size: 1.35rem; margin: 2.25rem 0 .75rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; margin: 0 0 1rem; }
li { margin-bottom: .3rem; }

code, pre, textarea.code, .mono {
    font-family: var(--mono);
    font-size: .875rem;
}

code {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: .05em .35em;
    overflow-wrap: anywhere;
}

pre {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    padding: .8rem 1rem;
    overflow-x: auto;
    margin: 0 0 1rem;
    white-space: pre;
}

.muted { color: var(--muted); }
.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; }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* ---- Layout ------------------------------------------------------------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 67rem;
    margin: 0 auto;
    padding: .7rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.brand {
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: .45rem;
}

/* The OAuth logo, black on transparent; white on a dark page. */
.brand-mark {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
}
@media (prefers-color-scheme: dark) { .brand-mark { filter: invert(1); } }

.shell {
    flex: 1;
    width: 100%;
    max-width: 50rem;
    margin: 0 auto;
    padding: 2.25rem 1.25rem 4rem;
}
.shell.wide { max-width: 72rem; }

/*
 * The main menu, after IndieKey's: a sidebar beside the page on wide screens.
 * On narrow screens it is a popover drawer that slides in from the left,
 * opened by the header's menu button (popovertarget), so the browser handles
 * Escape, tapping outside and focus with no JavaScript. Browsers without
 * popover support show it as a plain list above the page.
 */
.frame {
    flex: 1;
    width: 100%;
    max-width: 67rem;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 2.25rem;
    align-items: start;
}
.frame.wide, .topbar-inner.wide { max-width: 89rem; }
.frame > .shell { grid-column: 2; grid-row: 1; margin: 0; padding-inline: 0; max-width: none; }

.site-menu {
    /* Undo the browser's popover styles: a sidebar until narrow screens. */
    position: sticky;
    inset: auto;
    top: 0;
    width: auto;
    height: auto;
    margin: 0;
    border: 0;
    color: inherit;
    background: none;
    overflow: visible;

    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2.25rem 0 2rem;
    font-size: .95rem;
}

.menu-group { display: flex; flex-direction: column; gap: .15rem; }
.menu-group + .menu-group { padding-top: 1rem; border-top: 1px solid var(--line); }

.menu-heading {
    margin: 0 0 .25rem;
    padding: 0 .75rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}

.site-menu > .menu-group > a,
.site-menu .link-button {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    padding: .45rem .75rem;
    color: var(--ink);
    text-decoration: none;
    border-radius: var(--radius-small);
}
.site-menu > .menu-group > a:hover,
.site-menu .link-button:hover { background: var(--surface-2); }
.site-menu form { margin: 0; }
.site-menu [aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.menu-user { margin: 0 0 .35rem; padding: 0 .75rem; font-size: .85rem; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.menu-user code { font-size: .78rem; }

.menu-button {
    display: none;
    align-items: center;
    gap: .5rem;
    padding: .4rem .75rem;
    font: inherit;
    font-size: .95rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    cursor: pointer;
}
.menu-button:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 48rem) {
    .frame, .frame.wide { display: block; padding: 0; }
    .frame > .shell { padding-inline: 1.25rem; }
    .site-menu { position: static; padding: 1.5rem 1.25rem 0; }

    @supports selector(:popover-open) {
        .menu-button { display: inline-flex; }

        .site-menu {
            position: fixed;
            inset: 0 auto 0 0;
            width: min(18rem, 85vw);
            height: 100dvh;
            padding: 1.25rem .75rem;
            overflow-y: auto;
            background: var(--surface);
            border-right: 1px solid var(--line);
            box-shadow: var(--shadow);
            transform: translateX(-100%);
            transition: transform .2s ease, display .2s allow-discrete, overlay .2s allow-discrete;
        }

        .site-menu:not(:popover-open) { display: none; }
        .site-menu:popover-open { transform: none; }
        .site-menu::backdrop { background: rgb(0 0 0 / .4); }

        @starting-style {
            .site-menu:popover-open { transform: translateX(-100%); }
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-menu { transition: none; }
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    padding: 1.5rem;
    border-top: 1px solid var(--line);
}

/* ---- Components ---------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    margin: 0 0 1.25rem;
    box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card.disabled { opacity: .45; pointer-events: none; filter: grayscale(1); }

.notice {
    border-radius: var(--radius-small);
    padding: .8rem 1rem;
    margin: 0 0 1.25rem;
    border: 1px solid transparent;
}
.notice > :last-child { margin-bottom: 0; }
.notice.info    { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.notice.warn    { background: var(--warn-soft); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.ok      { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice.danger  { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.big     { font-size: 1.15rem; }

.banner {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
}
.banner form { margin: 0; }

.button, button {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    padding: .55rem 1rem;
    border-radius: var(--radius-small);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
}
.button:hover, button:hover { filter: brightness(1.07); }
.button.quiet, button.quiet {
    background: transparent;
    color: var(--accent);
}
.button.danger, button.danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.button.small, button.small { font-size: .8rem; padding: .3rem .6rem; }
.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font-weight: 400;
    text-decoration: underline;
    cursor: pointer;
}

.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label, .field .label { font-size: .9rem; font-weight: 600; }
.field .help { font-size: .82rem; color: var(--muted); }

input[type=text], input[type=url], input[type=email], input[type=password], input[type=search], textarea, select {
    width: 100%;
    padding: .55rem .7rem;
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
}
textarea { resize: vertical; }
textarea.code { white-space: pre; overflow-x: auto; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
input[readonly], textarea[readonly] { background: var(--surface-2); }

.inline-field { display: flex; gap: .5rem; align-items: stretch; margin-bottom: .75rem; }
.inline-field .label {
    flex: 0 0 9.5rem;
    display: flex;
    align-items: center;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
}
.inline-field input { flex: 1; font-family: var(--mono); font-size: .85rem; }

.copyable { display: flex; gap: .4rem; align-items: stretch; }
.copyable input { font-family: var(--mono); font-size: .85rem; }
.copy { flex: 0 0 auto; }

.facts {
    display: grid;
    grid-template-columns: minmax(8rem, auto) 1fr;
    gap: .45rem 1rem;
    margin: 0 0 1rem;
    align-items: baseline;
}
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
    vertical-align: middle;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tabs a {
    padding: .5rem .85rem;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---- Home ---------------------------------------------------------------- */

.hero {
    background: linear-gradient(135deg, var(--accent-soft), var(--surface));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    margin-bottom: 2rem;
}
.hero h1 { font-size: 2.2rem; }
.hero p { font-size: 1.08rem; max-width: 40rem; }

.exercise-list { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: .6rem; }
.exercise-list li { margin: 0; }
.exercise-list a {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: .9rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
}
.exercise-list a:hover { border-color: var(--accent); }
.exercise-list .title { font-weight: 650; font-size: 1.08rem; display: block; }
.exercise-list .summary { font-size: .9rem; color: var(--muted); display: block; }
.exercise-list .num {
    flex: 0 0 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid var(--line);
    font-weight: 700;
    color: var(--muted);
    font-size: .9rem;
}
.exercise-list .done .num { background: var(--ok); border-color: var(--ok); color: var(--surface); }

/* ---- Exercises ------------------------------------------------------------ */

.step-label {
    display: inline-block;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--accent);
    margin-bottom: .2rem;
}

.checklist { list-style: none; padding: 0; margin: .25rem 0 0; }
.checklist li { display: flex; gap: .55rem; align-items: flex-start; margin-bottom: .35rem; }
.checklist .mark { flex: 0 0 1.2rem; font-weight: 700; text-align: center; }
.checklist .ok .mark { color: var(--ok); }
.checklist .fail .mark { color: var(--danger); }
.checklist .detail { display: block; font-size: .9rem; margin-top: .15rem; }
.checklist .fail .detail { color: var(--ink); }
.checklist .ok .detail { color: var(--muted); font-family: var(--mono); font-size: .8rem; }

.verdict { margin-bottom: 1.25rem; }
.verdict.fail { border-left: 4px solid var(--danger); }
.verdict.ok { border-left: 4px solid var(--ok); }
.verdict h3 { margin-top: 0; }

.claims { margin-top: 1rem; }
.claims summary { cursor: pointer; font-weight: 600; font-size: .9rem; }

.client-pick {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    background: var(--surface-2);
    border-radius: var(--radius-small);
    padding: .7rem .9rem;
    margin-bottom: 1rem;
}

.activity { font-size: .88rem; }
.activity ul { list-style: none; padding: 0; margin: 0 0 .5rem; }
.activity li { display: flex; gap: .5rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); margin: 0; }
.activity li:last-child { border-bottom: 0; }
.activity .when { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 4.2rem; }

.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-top: .45rem; flex: 0 0 .6rem; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--danger); }

figure.diagram { margin: 1rem 0 1.5rem; }
figure.diagram svg { width: 100%; height: auto; }

/* ---- Request log ---------------------------------------------------------- */

.log-entry {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    margin-bottom: .6rem;
}
.log-entry > summary {
    list-style: none;
    cursor: pointer;
    padding: .65rem .9rem;
    display: flex;
    gap: .7rem;
    align-items: baseline;
    flex-wrap: wrap;
}
.log-entry > summary::-webkit-details-marker { display: none; }
.log-entry.fail { border-left: 4px solid var(--danger); }
.log-entry.ok { border-left: 4px solid var(--ok); }
.log-entry .kind { font-weight: 650; }
.log-entry .status { font-family: var(--mono); font-size: .8rem; }
.log-entry .when { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.log-entry .summary { color: var(--muted); font-size: .9rem; flex: 1 1 18rem; }
.log-body { padding: 0 .9rem .9rem; border-top: 1px solid var(--line); }
.log-body h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .4rem; }
.log-body pre { font-size: .78rem; }
.log-body .checklist li { font-size: .9rem; }
.log-body .hint { display: block; font-size: .88rem; margin-top: .2rem; background: var(--warn-soft); padding: .4rem .6rem; border-radius: 6px; }
.log-body .vs { font-family: var(--mono); font-size: .78rem; display: block; color: var(--muted); overflow-wrap: anywhere; }
.log-body .notes li { font-size: .9rem; }
.log-new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--surface); } }

.live { font-size: .8rem; color: var(--muted); display: inline-flex; gap: .35rem; align-items: center; }
.live::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ---- Instructor grid ------------------------------------------------------ */

.grid-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
table.grid th, table.grid td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); text-align: center; }
table.grid th:first-child, table.grid td:first-child { text-align: left; white-space: nowrap; }
table.grid thead th { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cell {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 1.7rem;
    border-radius: 6px;
    font-weight: 700;
    cursor: default;
}
.cell.done { background: var(--ok-soft); color: var(--ok); }
.cell.failing { background: var(--danger-soft); color: var(--danger); }
.cell.stuck { background: var(--danger); color: var(--surface); }
.cell.progress { background: var(--accent-soft); color: var(--accent); }
.cell.none { color: var(--line); }
.active-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); margin-right: .3rem; }
.idle-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--line); margin-right: .3rem; }

.search label { display: block; margin-bottom: .5rem; }
.search-row { display: flex; gap: .5rem; align-items: center; }
.search-row input { flex: 1; min-width: 0; font-family: var(--mono, ui-monospace, monospace); }
.search-results { list-style: none; padding: 0; margin: .75rem 0 0; }
.search-results li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; padding: .45rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.ok-text { color: var(--ok); }
.fail-text { color: var(--danger); }

.problems { list-style: none; padding: 0; }
.problems li { display: flex; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.problems .count { font-weight: 800; font-size: 1.2rem; min-width: 2rem; color: var(--danger); }

.join-code { font-family: var(--mono); font-size: 2.4rem; font-weight: 800; letter-spacing: .08em; }

/* ---- The practice authorization server's own pages -------------------- */

body.server { background: var(--server-soft); }
.server-bar {
    background: var(--server);
    color: #fff;
    padding: .55rem 1.25rem;
    font-size: .85rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
@media (prefers-color-scheme: dark) { .server-bar { color: #120e2b; } }
.server-bar code { background: transparent; border-color: rgb(255 255 255 / 35%); color: inherit; }
.server .shell { max-width: 30rem; padding-top: 3rem; }
.server .card { padding: 1.75rem; }
.server h1 { font-size: 1.4rem; }
.server .button, .server button { background: var(--server); border-color: var(--server); }
.server .button.quiet, .server button.quiet { background: transparent; color: var(--server); }

.user-pick { display: grid; gap: .6rem; margin: 1.25rem 0; }
.user-pick button {
    width: 100%;
    justify-content: flex-start;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: .75rem 1rem;
    font-weight: 400;
    text-align: left;
}
.user-pick button:hover { border-color: var(--server); filter: none; }
.avatar {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--server);
    color: #fff;
    font-weight: 700;
    flex: 0 0 2.2rem;
    margin-right: .5rem;
}
.user-pick .who { display: block; font-weight: 650; }
.user-pick .meta { display: block; font-size: .82rem; color: var(--muted); }

.scopes { list-style: none; padding: 0; margin: 1rem 0; }
.scopes li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.scopes code { font-size: .75rem; flex-shrink: 0; align-self: flex-start; max-width: 60%; overflow-wrap: anywhere; }

.destination { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 40rem) {
    h1 { font-size: 1.55rem; }
    .inline-field { flex-direction: column; gap: .2rem; }
    .inline-field .label { flex: none; }
    .facts { grid-template-columns: 1fr; gap: .1rem; }
    .facts dd { margin-bottom: .5rem; }
}

/* ---- Token request, sent from the exercise page ---------------------------- */

.token-request .param { margin-bottom: .75rem; }
.token-request .param input { font-family: var(--mono); }
.request-preview { white-space: pre-wrap; word-break: break-all; margin: 0; }
.exchange pre { white-space: pre-wrap; word-break: break-all; margin: .35rem 0 1rem; }
.exchange > :last-child { margin-bottom: 0; }
.curl-route > summary, .request-again > summary { cursor: pointer; font-weight: 600; }
.curl-route[open] > summary, .request-again[open] > summary { margin-bottom: .75rem; }
.curl-route .card, .request-again .card { border: 0; box-shadow: none; padding: 0; margin: 0; background: transparent; }

/* ---- Exercise stages as tabs ---------------------------------------------- */

.stage-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.5rem 0 1.25rem;
    border-bottom: 1px solid var(--line);
}
.stage-reset { margin: 0 0 0 auto; flex: none; }
.stage-tabs {
    display: flex;
    gap: .25rem;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.stage-tabs .tab {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem .9rem;
    white-space: nowrap;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}
.stage-tabs .tab:hover { color: var(--ink); }
.stage-tabs .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-mark {
    display: inline-grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    font-size: .75rem;
    background: var(--line);
    color: var(--ink);
}
.stage-tabs .tab[aria-selected="true"] .tab-mark { background: var(--accent); color: var(--accent-ink); }
.stage-tabs .tab.done .tab-mark { background: var(--ok-soft); color: var(--ok); }
.tab-panel > h2:first-child { margin-top: 0; }
.tab-next { margin-top: 2rem; text-align: right; }
@media (max-width: 640px) {
    .stage-bar { flex-wrap: wrap; gap: .25rem; }
    .stage-reset { order: -1; }
    .stage-tabs { flex: 1 0 100%; }
}
.notice.completed { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
