:root {
    --ink: #1c2328;
    --ink-muted: #515b66;
    --ink-soft: #6c7580;
    --brand: #0f4c5c;
    --brand-strong: #0b3946;
    --accent: #e36414;
    --accent-soft: #fde7d6;
    --paper: #f6f3ee;
    --surface: #ffffff;
    --surface-strong: #fdf9f4;
    --surface-hover: #f2ede6;
    --border: #e2ded6;
    --shadow: 0 14px 30px rgba(15, 76, 92, 0.14);
    --shadow-soft: 0 8px 18px rgba(15, 76, 92, 0.08);
    --chip-bg: #e9f1f2;
    --chip-ink: #0f4c5c;
    --chip-hover-bg: #d3e6e9;
    --chip-hover-ink: #0b3946;
    --tag-bg: #f1ede7;
    --tag-ink: #3d4a56;
    --good: #1f7a4d;
    --warn: #b0530b;
    --table-head: #f2eee8;
    --table-row: #fbf8f3;
    --highlight: #fff2dc;
}

[data-theme="dark"] {
    --ink: #edf1f2;
    --ink-muted: #c3c8cc;
    --ink-soft: #a1a8ad;
    --brand: #2f4a52;
    --brand-strong: #273e45;
    --accent: #f6a04d;
    --accent-soft: #3a2a1e;
    --paper: #0e1418;
    --surface: #141c21;
    --surface-strong: #182125;
    --surface-hover: #1e2730;
    --border: #2a3640;
    --shadow: 0 18px 36px rgba(0, 0, 0, 0.4);
    --shadow-soft: 0 10px 22px rgba(0, 0, 0, 0.3);
    --chip-bg: #1b2b31;
    --chip-ink: #9bb8bf;
    --chip-hover-bg: #22343b;
    --chip-hover-ink: #c8eff6;
    --tag-bg: #1f2a32;
    --tag-ink: #c8d3da;
    --good: #7fd7a6;
    --warn: #f6b26b;
    --table-head: #18222a;
    --table-row: #131b20;
    --highlight: #3a2a1e;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #edf1f2;
        --ink-muted: #c3c8cc;
        --ink-soft: #a1a8ad;
        --brand: #2f4a52;
        --brand-strong: #273e45;
        --accent: #f6a04d;
        --accent-soft: #3a2a1e;
        --paper: #0e1418;
        --surface: #141c21;
        --surface-strong: #182125;
        --surface-hover: #1e2730;
        --border: #2a3640;
        --shadow: 0 18px 36px rgba(0, 0, 0, 0.4);
        --shadow-soft: 0 10px 22px rgba(0, 0, 0, 0.3);
        --chip-bg: #1b2b31;
        --chip-ink: #9bb8bf;
        --chip-hover-bg: #22343b;
        --chip-hover-ink: #c8eff6;
        --tag-bg: #1f2a32;
        --tag-ink: #c8d3da;
        --good: #7fd7a6;
        --warn: #f6b26b;
        --table-head: #18222a;
        --table-row: #131b20;
        --highlight: #3a2a1e;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    font-family: "Segoe UI", Tahoma, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.65;
    color: var(--ink);
    background: radial-gradient(circle at 8% 12%, rgba(15, 76, 92, 0.15), transparent 45%),
        radial-gradient(circle at 85% 0%, rgba(227, 100, 20, 0.12), transparent 40%),
        linear-gradient(180deg, var(--paper), var(--paper));
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

a { color: inherit; }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 24px;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 10px;
    background: #a63e00;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 1000;
}

.skip-link:focus { left: 12px; }

/* Header */
.header {
    background: var(--brand);
    color: #fff;
    padding: 42px 0 32px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.header::after {
    content: none;
}

.header h1 {
    margin: 0 0 8px 0;
    font-size: 2.6em;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.header-subtitle {
    opacity: 0.95;
    font-size: 1.05em;
    max-width: 640px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.header-brand {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex: 1;
    min-width: 240px;
}

.header-text { }

.header-logo {
    height: 42px;
    width: auto;
    display: block;
    flex-shrink: 0;
    margin-top: 0.2em;
}

/* Theme toggle button */
.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    white-space: nowrap;
    min-width: 116px;
    min-height: 44px;
    line-height: 1;
}

.theme-toggle:hover { background: rgba(255, 255, 255, 0.3); }

.theme-toggle-icon { font-size: 1.1em; }

.theme-icon-light { display: none; }
.theme-icon-dark { display: inline; }

[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
    :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
}

[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: inline; }

/* Stats bar */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
}

.stat-item { text-align: center; }

.stat-item a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s, transform 0.2s;
}

.stat-item a:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.78em;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

/* Search */
.search-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.search-section {
    background: var(--surface);
    padding: 22px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    border: 1px solid var(--border);
}

.search-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
    background: var(--surface-strong);
    color: var(--ink);
}

.search-input:focus { border-color: var(--brand); }

.search-input::placeholder { color: var(--ink-soft); }

.search-status {
    font-size: 0.9em;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-hint, .search-empty {
    color: var(--ink-muted);
    font-size: 0.9em;
    margin-top: 10px;
}

.search-pill {
    background: var(--accent-soft);
    color: var(--warn);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
}

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 34px 0 18px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--brand);
}

.section-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: var(--ink);
}

.section-count {
    background: var(--chip-bg);
    color: var(--chip-ink);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82em;
    font-weight: 600;
}

/* Pack cards */
.pack-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.pack-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.pack-card:hover { box-shadow: var(--shadow); }

.pack-card > details { width: 100%; }

.pack-card > details > summary {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 24px 28px;
    cursor: pointer;
    list-style: none;
    background: var(--surface);
    border-bottom: 1px solid transparent;
    transition: background 0.2s;
}

.pack-card > details > summary:focus-visible { outline-offset: -6px; }

.pack-card > details > summary::-webkit-details-marker { display: none; }
.pack-card > details > summary::marker { display: none; }

.pack-card > details > summary::after {
    content: "\25BC";
    font-size: 1em;
    color: var(--ink-soft);
    justify-self: end;
}

.pack-card > details[open] > summary::after { content: "\25B2"; }

.pack-card > details[open] > summary {
    border-bottom-color: var(--border);
    background: var(--surface-hover);
}

.pack-card > details > summary:hover { background: var(--surface-hover); }

.pack-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pack-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pack-name {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--ink);
    min-width: 200px;
}

.pack-subtitle {
    font-size: 0.9em;
    color: var(--ink-muted);
}

.search-match {
    color: var(--good);
    font-size: 0.9em;
    font-weight: 600;
}

.pack-badge {
    background: var(--tag-bg);
    color: var(--tag-ink);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.pack-badge.arm-sync {
    background: var(--accent-soft);
    color: var(--warn);
}

.pack-version {
    background: var(--brand);
    color: #fff;
    padding: 5px 12px;
    min-height: 44px;
    align-items: center;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    display: inline-flex;
}

.pack-version:hover {
    background: var(--brand-strong);
    transform: translateY(-1px);
}

.pack-version:active { transform: translateY(0); }

.pack-meta {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: var(--ink-muted);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #a63e00;
    color: #fff;
    padding: 8px 16px;
    min-height: 44px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: background 0.2s;
    white-space: nowrap;
}

.download-btn:hover { background: #822f00; color: #fff; }

.download-btn-sm {
    padding: 6px 12px;
    font-size: 0.8em;
}

/* Pack content */
.pack-content { padding: 24px 28px 30px; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.feature-card {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.feature-card h4 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.feature-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: var(--tag-bg);
    color: var(--tag-ink);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
}

.tag.emphasis { background: var(--accent-soft); color: var(--warn); }

.device-section { margin-bottom: 24px; }

.device-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.device-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.device-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: var(--chip-bg);
    color: var(--chip-ink);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    min-width: 120px;
}

.device-chip:hover {
    background: var(--chip-hover-bg);
    color: var(--chip-hover-ink);
}

.device-chip.no-link {
    background: var(--surface-hover);
    color: var(--ink);
    cursor: default;
}

.device-name { font-weight: 600; }

.device-info {
    font-size: 0.72em;
    color: var(--ink-soft);
}

/* Release table */
.release-table-scroll { overflow-x: auto; }

.release-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.release-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.release-table th {
    text-align: left;
    padding: 12px;
    background: var(--table-head);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    color: var(--ink);
}

.release-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.release-table tr:last-child td { border-bottom: none; }

.release-table tr:hover td { background: var(--table-row); }

.release-version { font-weight: 600; white-space: nowrap; }

.release-date { color: var(--ink-muted); font-size: 0.9em; }

.release-deprecated { color: var(--warn); font-size: 0.85em; font-weight: 600; }

.release-description { color: var(--ink-muted); max-width: 620px; }

/* Markdown is rendered at build time, with raw HTML disabled. */
.release-notes {
    word-break: break-word;
    margin: 0;
    background: var(--surface-strong);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--ink);
    line-height: 1.5;
    overflow-x: auto;
}

.release-notes p { margin: 0 0 0.5em; }
.release-notes p:last-child { margin-bottom: 0; }
.release-notes ul, .release-notes ol { margin: 0.3em 0; padding-left: 1.5em; }
.release-notes code, .release-notes pre { background: var(--surface-hover); }
.release-notes code { padding: 1px 4px; border-radius: 3px; }
.release-notes pre { padding: 8px; border-radius: 6px; overflow-x: auto; }
.release-notes pre code { padding: 0; background: none; }
.release-notes a { color: var(--ink); text-decoration: underline; }
.release-notes blockquote {
    border-left: 3px solid var(--border);
    margin: 0.5em 0;
    padding: 0.25em 0.75em;
    color: var(--ink-muted);
}
.release-notes table { border-collapse: collapse; margin: 0.5em 0; }
.release-notes th, .release-notes td { border: 1px solid var(--border); padding: 4px 8px; }
.release-notes th { background: var(--table-head); }

/* Footer */
.footer {
    margin-top: 50px;
    padding: 30px 0 40px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9em;
}

.footer a { color: var(--brand); }

.footer code {
    background: var(--surface-strong);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--ink);
}

/* Separator */
.section-separator {
    margin: 46px 0;
    border: none;
    border-top: 2px dashed var(--border);
}

/* Responsive */
@media (max-width: 900px) {
    .pack-card > details > summary {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }
    .pack-card > details > summary::after { justify-self: start; }
}

@media (max-width: 768px) {
    .header h1 { font-size: 2em; }
    .stats-bar { gap: 14px; }
    .stat-value { font-size: 1.5em; }
    .download-btn { width: 100%; justify-content: center; }
    .search-box { grid-template-columns: 1fr; }
    .release-table { font-size: 0.8em; min-width: 540px; }
}

/* Permalink glyph */
.pack-permalink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.85em;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    vertical-align: middle;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    line-height: 1;
}

.pack-title:hover .pack-permalink,
.pack-permalink:focus-visible {
    opacity: 1;
}

.pack-permalink:hover {
    color: var(--accent);
    background: var(--accent-soft);
    opacity: 1;
}

.pack-permalink.copied {
    color: var(--good);
    opacity: 1;
}

@media (hover: none) {
    .pack-permalink { opacity: 1; }
}

.js-only { display: none; }

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
