.view-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.view-switch button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #7391a8;
    border-radius: 7px;
    color: #e9f0f6;
    background: #173f5f;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.view-switch button:hover,
.view-switch button:focus-visible {
    border-color: #b9d2e4;
    background: #24577d;
    color: #fff;
    outline: none;
    transform: translateY(-1px);
}

.view-switch button.active {
    border-color: #c5dfef;
    color: #102a43;
    background: #c4ddeb;
    box-shadow: 0 0 0 2px rgba(197, 223, 239, 0.16);
}

.view-switch svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brief-scenario {
    display: none;
    margin: 14px 0;
    padding: 17px 19px;
    border: 1px solid #aab7c2;
    border-left: 4px solid #477b9f;
    border-radius: 9px;
    background: #cbd4dc;
}

.brief-scenario p {
    margin: 7px 0 0;
    font-size: 1.02rem;
    line-height: 1.62;
}

.brief-label {
    color: #285a7c;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brief-view .scenario {
    display: none;
}

.brief-view .brief-scenario {
    display: block;
    animation: brief-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes brief-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    html {
        scroll-padding-top: 174px;
    }

    body {
        overflow-x: hidden;
        font-size: 16px;
        line-height: 1.62;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 50;
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 11px 12px 10px;
        border-bottom: 1px solid rgba(183, 211, 231, 0.28);
        box-shadow: 0 8px 24px rgba(12, 34, 51, 0.24);
    }

    .sidebar h1 {
        margin: 0 0 3px;
        padding-right: 82px;
        font-size: 0.98rem;
    }

    .sidebar .small {
        position: absolute;
        top: 13px;
        right: 13px;
        margin: 0;
        color: #c9d6e2;
        font-size: 0.76rem;
        white-space: nowrap;
    }

    .controls {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 7px;
        margin: 7px 0 9px;
    }

    .controls input {
        min-width: 0;
        min-height: 42px;
        padding: 9px 11px;
        font-size: 16px;
    }

    .buttons,
    .view-switch {
        min-width: 176px;
    }

    .buttons button,
    .view-switch button {
        min-height: 42px;
        padding: 7px 10px;
        white-space: nowrap;
    }

    .toc {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        padding: 0 0 3px;
        scroll-snap-type: x proximity;
        scrollbar-color: #567a94 transparent;
        scrollbar-width: thin;
    }

    .toc a {
        flex: 0 0 auto;
        max-width: 290px;
        padding: 7px 9px;
        border: 1px solid rgba(181, 208, 228, 0.18);
        background: rgba(23, 63, 95, 0.72);
        line-height: 1.25;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .main {
        max-width: none;
        padding: 18px 12px 76px;
    }

    .hero {
        margin-bottom: 20px;
        padding: 20px 18px;
        border-radius: 11px;
    }

    .hero h1 {
        font-size: 1.55rem;
    }

    .notice {
        padding: 10px 12px;
    }

    .chapter {
        margin: 28px 0;
    }

    .chapter > h2 {
        margin-bottom: 15px;
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .case {
        margin-bottom: 16px;
        padding: 17px 15px;
        border-radius: 10px;
        scroll-margin-top: 180px;
    }

    .case-head {
        margin-bottom: 13px;
        padding-bottom: 11px;
    }

    .case h3 {
        font-size: 1.1rem;
    }

    details,
    .answer,
    .brief-scenario {
        border-radius: 8px;
    }

    summary {
        min-height: 44px;
        padding: 11px 12px;
    }

    blockquote,
    .answer,
    .brief-scenario {
        padding: 15px 14px;
    }

    blockquote p,
    .answer p,
    .brief-scenario p {
        line-height: 1.64;
    }
}

@media (max-width: 620px) {
    html {
        scroll-padding-top: 224px;
    }

    .controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .controls input {
        grid-column: 1 / -1;
    }

    .buttons,
    .view-switch {
        min-width: 0;
    }

    .buttons button,
    .view-switch button {
        padding-inline: 7px;
        font-size: 0.82rem;
    }

    .main {
        padding-inline: 10px;
    }

    .hero {
        padding: 17px 15px;
    }

    .hero h1 {
        font-size: 1.36rem;
    }

    .hero p,
    .notice {
        font-size: 0.94rem;
    }

    .case {
        padding: 15px 13px;
        scroll-margin-top: 228px;
    }

    .case-head > div {
        gap: 9px;
    }

    .case-no {
        min-width: 34px;
        height: 34px;
    }

    .case h3 {
        font-size: 1.04rem;
    }

    .pages {
        margin: 7px 0 0 43px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .brief-view .brief-scenario {
        animation: none;
    }

    .view-switch button {
        transition: none;
    }
}
