:root {
    --ink: #17324d;
    --muted: #5d6b78;
    --line: #d9e3ec;
    --blue: #1676b8;
    --blue-soft: #eef7fd;
    --amber: #8a5a00;
    --amber-soft: #fff7df;
    --danger: #9e2a2b;
    --danger-soft: #fff0f0;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: #f3f6f9;
    font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.75;
}

a {
    color: #075d98;
}

.guide {
    width: min(1040px, calc(100% - 32px));
    margin: 32px auto;
    padding: 48px 56px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(27, 55, 82, 0.08);
}

.guide-header {
    padding-bottom: 28px;
    border-bottom: 3px solid var(--blue);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

h1,
h2,
h3,
h4 {
    color: #0c3e67;
    line-height: 1.35;
}

h1 {
    margin: 0;
    font-size: 2.15rem;
}

h2 {
    margin: 52px 0 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 1.55rem;
}

h3 {
    margin: 28px 0 10px;
    font-size: 1.18rem;
}

h4 {
    margin: 22px 0 8px;
    font-size: 1.03rem;
}

p,
ul,
ol {
    margin-top: 10px;
    margin-bottom: 14px;
}

li + li {
    margin-top: 7px;
}

.lead {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.button {
    display: inline-block;
    padding: 8px 15px;
    color: #fff;
    background: var(--blue);
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.button.secondary {
    color: #17486f;
    background: #eaf3f9;
}

.toc {
    margin-top: 30px;
    padding: 22px 26px;
    background: #f7fafc;
    border-left: 5px solid var(--blue);
}

.toc h2 {
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    font-size: 1.2rem;
}

.toc ol {
    columns: 2;
    column-gap: 42px;
    margin-bottom: 0;
}

.toc li {
    break-inside: avoid;
}

.steps {
    counter-reset: guide-step;
    padding: 0;
    list-style: none;
}

.steps > li {
    position: relative;
    min-height: 46px;
    margin: 15px 0;
    padding: 8px 0 8px 54px;
    counter-increment: guide-step;
}

.steps > li::before {
    position: absolute;
    top: 4px;
    left: 0;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #fff;
    background: var(--blue);
    border-radius: 50%;
    content: counter(guide-step);
    font-weight: 700;
}

.note,
.warning,
.danger,
.done {
    margin: 20px 0;
    padding: 14px 18px;
    border-left: 5px solid var(--blue);
    background: var(--blue-soft);
}

.warning {
    color: #624100;
    background: var(--amber-soft);
    border-left-color: #d99a16;
}

.danger {
    color: #6f2021;
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

.done {
    background: #eef8f0;
    border-left-color: #3f8b50;
}

.label {
    font-weight: 700;
}

figure {
    margin: 24px 0 30px;
    break-inside: avoid;
}

figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #cbd8e3;
    border-radius: 6px;
}

figcaption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.compact-list {
    padding-left: 22px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.menu-grid article,
.stage-sequence article {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.menu-grid h3,
.stage-sequence h3 {
    margin-top: 0;
}

.menu-grid p,
.stage-sequence p {
    margin-bottom: 0;
}

.menu-grid figure {
    margin: 14px 0 0;
}

.menu-grid figure img {
    max-height: 190px;
    object-fit: contain;
    background: #fff;
}

.menu-grid figcaption {
    min-height: 2.8em;
    margin-bottom: 0;
}

.feature {
    display: grid;
    grid-template-columns: 7em 1fr;
    margin: 10px 0 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.feature dt,
.feature dd {
    margin: 0;
    padding: 10px 13px;
    border-bottom: 1px solid var(--line);
}

.feature dt {
    color: #17486f;
    background: #eef5fa;
    font-weight: 700;
}

.feature dt:last-of-type,
.feature dd:last-of-type {
    border-bottom: 0;
}

.figure-compact {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
}

.decision-table {
    width: 100%;
    margin: 18px 0 26px;
    border-collapse: collapse;
}

.decision-table th,
.decision-table td {
    padding: 10px 13px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.decision-table th {
    color: #17486f;
    background: #eef5fa;
}

.stage-sequence {
    display: grid;
    gap: 24px;
}

.stage-sequence figure {
    margin-bottom: 0;
}

code {
    padding: 1px 4px;
    background: #f2f4f6;
    border-radius: 3px;
    font-family: Consolas, monospace;
}

.checklist {
    padding-left: 0;
    list-style: none;
}

.checklist li {
    position: relative;
    padding-left: 30px;
}

.checklist li::before {
    position: absolute;
    left: 0;
    color: #368048;
    content: "✓";
    font-weight: 700;
}

.guide-footer {
    margin-top: 54px;
    padding-top: 16px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.88rem;
}

@media (max-width: 720px) {
    body {
        font-size: 16px;
    }

    .guide {
        width: 100%;
        margin: 0;
        padding: 28px 20px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    h1 {
        font-size: 1.75rem;
    }

    .toc ol {
        columns: 1;
    }

    .menu-grid {
        grid-template-columns: 1fr;
    }

    .feature {
        grid-template-columns: 1fr;
    }

    .feature dt {
        padding-bottom: 2px;
        border-bottom: 0;
    }

    .feature dd {
        padding-top: 2px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 14mm 13mm 15mm;

        @bottom-center {
            content: "第 " counter(page) " 頁";
            color: #5a6472;
            font-size: 9pt;
        }
    }

    body {
        color: #111;
        background: #fff;
        font-size: 10.5pt;
        line-height: 1.55;
    }

    .guide {
        width: auto;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .actions {
        display: none;
    }

    h1 {
        font-size: 22pt;
    }

    h2 {
        margin-top: 26pt;
        font-size: 16pt;
        break-after: avoid;
    }

    h3 {
        font-size: 12.5pt;
        break-after: avoid;
    }

    .toc {
        break-inside: avoid;
    }

    figure img {
        max-height: 175mm;
        object-fit: contain;
    }

    .menu-grid,
    .feature,
    .decision-table {
        break-inside: avoid;
    }

    .menu-grid article {
        break-inside: avoid;
    }

    .stage-sequence article {
        break-before: page;
        break-inside: avoid;
    }

    .stage-sequence article:first-child {
        break-before: auto;
    }

    #rollback {
        break-before: page;
    }

    .figure-compact img {
        max-height: 120mm;
    }

    .guide-footer {
        display: none;
    }

    a {
        color: inherit;
        text-decoration: none;
    }
}
