:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #eef1f4;
    --text: #18202a;
    --muted: #5f6b78;
    --border: #dce2e8;
    --accent: #2f6fde;
    --accent-soft: #e5eefc;
    --done: #1f9d6b;
    --done-soft: #e3f5ec;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --code-bg: #f1f3f6;
    --radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1318;
        --surface: #161b22;
        --surface-2: #1d242d;
        --text: #e6ebf0;
        --muted: #98a4b1;
        --border: #2a333d;
        --accent: #6ea2ff;
        --accent-soft: #1b2a44;
        --done: #3cc38d;
        --done-soft: #15322a;
        --danger: #ff8a80;
        --danger-soft: #3a1a17;
        --code-bg: #0d1117;
        color-scheme: dark;
    }
}

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

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.82rem;
    margin: 4px 0 0;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.top {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.top__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.top h1 {
    font-size: 1.15rem;
}

.summary {
    min-width: 260px;
    flex: 0 1 320px;
}

.summary__numbers {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
}

.summary__percent {
    margin-left: auto;
    font-weight: 700;
    color: var(--done);
}

.bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.bar--small {
    height: 5px;
    margin: 10px 0 4px;
}

.bar__fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--done);
    transition: width 0.3s ease;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    margin-bottom: 16px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
}

.next {
    border-color: var(--accent);
    background: var(--accent-soft);
    cursor: pointer;
}

.next h2 {
    font-size: 1.05rem;
}

.phase-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.phase-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}

.phase-nav a.is-complete {
    border-color: var(--done);
    color: var(--done);
}

.reference summary {
    cursor: pointer;
    font-weight: 600;
}

.reference[open] summary {
    margin-bottom: 12px;
}

.phase {
    scroll-margin-top: 110px;
}

.phase__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.phase__title {
    font-size: 1.1rem;
}

.phase__count {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.phase__intro:empty {
    display: none;
}

.phase__intro {
    margin-top: 8px;
}

.steps {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.step {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    scroll-margin-top: 110px;
}

.step.is-done {
    background: var(--done-soft);
    border-color: color-mix(in srgb, var(--done) 35%, transparent);
}

.step.is-done .step__title {
    color: var(--muted);
    text-decoration: line-through;
}

.step.is-next {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.step__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.step__check {
    width: 18px;
    height: 18px;
    flex: none;
    accent-color: var(--done);
    cursor: pointer;
}

.step__toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 2px 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.step__id {
    flex: none;
    min-width: 40px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.step__title {
    flex: 1;
    min-width: 0;
}

.step__title code {
    font-size: 0.85em;
}

.step__meta {
    flex: none;
    font-size: 0.78rem;
    color: var(--muted);
}

.step__meta.has-note::before {
    content: "✎ ";
}

.step__chevron {
    flex: none;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.step__toggle[aria-expanded="true"] .step__chevron {
    transform: rotate(90deg);
}

.step__details {
    padding: 4px 16px 16px 40px;
    border-top: 1px solid var(--border);
}

.note {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted);
}

.note textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.markdown {
    overflow-wrap: anywhere;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
    margin: 18px 0 8px;
    font-size: 1rem;
}

.markdown p,
.markdown ul,
.markdown ol {
    margin: 8px 0;
}

.markdown code {
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--code-bg);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.86em;
}

.markdown pre {
    margin: 10px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--code-bg);
    overflow-x: auto;
}

.markdown pre code {
    padding: 0;
    background: none;
    font-size: 0.82rem;
    line-height: 1.5;
}

.markdown table {
    width: 100%;
    margin: 10px 0;
    border-collapse: collapse;
    font-size: 0.88rem;
    display: block;
    overflow-x: auto;
}

.markdown th,
.markdown td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.markdown th {
    background: var(--surface-2);
}

.markdown hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

@media (max-width: 600px) {
    .step__details {
        padding-left: 16px;
    }

    .step__meta {
        display: none;
    }
}
