:root {
    --bg: #f3f6f9;
    --surface: #ffffff;
    --text: #1b2733;
    --muted: #5d6b78;
    --line: #d9e1e8;
    --primary: #0b5cab;
    --primary-soft: #e8f1fb;
    --success: #1f7a4d;
    --shadow: 0 8px 20px rgba(17, 42, 67, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%);
}

.container {
    width: min(1100px, 92vw);
    margin: 0 auto;
}

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

.header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    line-height: 1;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.brand-logo {
    height: 34px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 34px !important;
    object-fit: contain !important;
    border-radius: 0;
    display: block;
    flex: 0 0 auto;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.top-nav a,
.tab-link {
    text-decoration: none;
    color: var(--text);
    background: #f6f9fc;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
}

.top-nav a:hover,
.tab-link:hover {
    border-color: #b5c7d8;
}

.tab-link.active {
    background: var(--primary-soft);
    border-color: #b9d2eb;
    color: #0f4f8b;
}

.hero {
    margin: 24px 0;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 4vw, 42px);
}

.hero h2 {
    margin: 0;
    color: var(--primary);
    font-size: clamp(16px, 2.3vw, 22px);
}

.hero p {
    margin: 14px 0 0;
    color: var(--muted);
    max-width: 72ch;
}

.hero-center {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 36px 20px;
}

.slogan-text {
    margin: 0 auto;
    width: 100%;
    max-width: 920px;
    text-align: center;
    font-size: clamp(28px, 5vw, 56px);
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: #0b3f78;
    text-transform: uppercase;
}

.toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-bottom: 14px;
}

.search-form,
.sort-form {
    display: flex;
    gap: 8px;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button,
.btn {
    border: 1px solid #0e4f93;
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    display: inline-block;
}

.btn-light {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-media {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #e9eff5;
}

.card-media-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #e9eff5;
    border-bottom: 1px solid var(--line);
}

.card-body {
    padding: 14px;
    display: grid;
    gap: 10px;
}

.badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: #edf7f1;
    color: var(--success);
    border: 1px solid #cbe6d8;
    font-size: 12px;
    width: fit-content;
}

.badge-recency {
    font-size: 12px;
}

.badge-recency-current {
    background: #e9f8ef;
    color: #1b7a47;
    border: 1px solid #bfe4cc;
}

.badge-recency-new {
    background: #eef5ff;
    color: #245ea8;
    border: 1px solid #c9dbf6;
}

.badge-recency-stable {
    background: #f3f4f6;
    color: #49515c;
    border: 1px solid #d8dbe1;
}

.badge-recency-none {
    background: #f5f5f5;
    color: #6b7280;
    border: 1px solid #e2e5e9;
}

.toc-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.toc-box summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toc-box summary::-webkit-details-marker {
    display: none;
}

.toc-box[open] .toc-chevron {
    transform: rotate(90deg);
}

.toc-chevron {
    transition: transform 0.15s ease;
}

.toc-links {
    border-top: 1px solid var(--line);
    padding: 10px 12px 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.toc-links a {
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 13px;
}

.toc-links a:hover {
    border-color: #b5c7d8;
}

.toc-chip-wrap {
    position: sticky;
    top: 72px;
    z-index: 8;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px 12px;
}

.toc-chip-head {
    margin-bottom: 8px;
}

.toc-chip-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toc-chip-link {
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 13px;
    line-height: 1.2;
}

.toc-chip-link:hover {
    border-color: #b5c7d8;
    background: #f1f6fb;
}

.toc-chip-link:focus-visible {
    outline: 2px solid #78a9d8;
    outline-offset: 2px;
}

.card[id] {
    scroll-margin-top: 128px;
}

.toc-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toc-fab.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.toc-fab:focus-visible {
    outline: 2px solid #78a9d8;
    outline-offset: 2px;
}

.toc-floating-layer {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.toc-floating-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 24, 38, 0.28);
}

.toc-floating-panel {
    position: absolute;
    right: 18px;
    bottom: 72px;
    width: min(340px, calc(100vw - 24px));
    max-height: min(70vh, 480px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px;
}

.toc-floating-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.toc-floating-close {
    min-width: 32px;
    min-height: 32px;
    padding: 4px 8px;
}

.toc-floating-links {
    display: grid;
    gap: 8px;
}

.toc-floating-links a {
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

.toc-floating-links a:hover {
    border-color: #b5c7d8;
    background: #f1f6fb;
}

.toc-floating-links a:focus-visible {
    outline: 2px solid #78a9d8;
    outline-offset: 2px;
}

.meta {
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.pagination {
    margin: 18px 0 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.notice {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #d8e4f0;
    background: #f5f9fd;
}

.notice.error {
    border-color: #f0d0d0;
    background: #fff5f5;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

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

.form-grid .full {
    grid-column: 1 / -1;
}

.site-footer {
    border-top: 1px solid var(--line);
    padding: 16px 0;
    margin-top: 24px;
    color: var(--muted);
}

@media (max-width: 900px) {
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .card-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .toc-chip-wrap {
        top: 64px;
    }

    .toc-chip-bar {
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .toc-floating-panel {
        left: 12px;
        right: 12px;
        bottom: 76px;
        width: auto;
    }

    .toc-links {
        grid-template-columns: 1fr;
    }

    .header-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
