:root {
    color-scheme: light;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%237c8299' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f9f9fd;
    --sunken: #eef0f6;
    --border: #e3e6ef;
    --border-soft: #eef0f5;
    --text: #1d2030;
    --text-2: #535a70;
    --muted: #7c8299;
    --accent: #7c3aed;
    --accent-2: #6d28d9;
    --accent-soft: #f2ecfe;
    --accent-text: #6d28d9;
    --code: #fbfaff;
    --code-tag: #7c3aed;
    --code-attr: #b4530d;
    --code-value: #0f7a55;
    --code-punct: #9aa0b4;
    --danger: #b42343;
    --shadow: 0 1px 2px rgb(20 24 40 / .04), 0 8px 24px -12px rgb(20 24 40 / .12);
    --radius: 14px;
    --sidebar: 288px;
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
}

:root.dark {
    color-scheme: dark;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238a92aa' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --bg: #0f121b;
    --surface: #171b27;
    --surface-2: #1b2030;
    --sunken: #12151f;
    --border: #2a3144;
    --border-soft: #232a3b;
    --text: #e7e9f2;
    --text-2: #b6bdd1;
    --muted: #8a92aa;
    --accent: #a78bfa;
    --accent-2: #c4b5fd;
    --accent-soft: #2b2342;
    --accent-text: #cdb8ff;
    --code: #131724;
    --code-tag: #c4a7ff;
    --code-attr: #f2b37a;
    --code-value: #7ad7ae;
    --code-punct: #6f7790;
    --danger: #f39aac;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -16px rgb(0 0 0 / .6);
}

* { box-sizing: border-box; }
html { scroll-padding-top: 24px; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 50; padding: 10px 14px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }

/* Buttons and fields */
.button, .icon-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 34px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 550;
    transition: border-color .15s, color .15s, background .15s;
}
.button:hover, .icon-button:hover { border-color: var(--accent); color: var(--accent-text); }
.button:disabled { opacity: .6; cursor: progress; }
.button--small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.icon-button { padding: 6px 10px; }
.field { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.field select, .control select, .control input:not([type="checkbox"]), .control textarea {
    min-height: 34px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface-2); color: var(--text); font-size: 13px;
}
select { -webkit-appearance: none; appearance: none; line-height: 1.2; }
select, .field select, .control select {
    background-image: var(--chevron);
    background-position: right 10px center; background-size: 14px 14px; background-repeat: no-repeat;
}
.field select, .control select { height: 34px; padding-right: 32px; text-overflow: ellipsis; }
.field select {
    padding-left: 12px; background-color: var(--surface); color: var(--text-2); font-weight: 550;
    transition: border-color .15s, color .15s;
}
.field select:hover { border-color: var(--accent); color: var(--accent-text); }
.control select:hover { border-color: var(--accent); }
.control select:focus, .control input:not([type="checkbox"]):focus, .control textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
select option { background: var(--surface); color: var(--text); font-weight: 400; }

/* Sidebar */
.appbar { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgb(10 12 20 / .45); backdrop-filter: blur(2px); }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar);
    display: flex; flex-direction: column; padding: 22px 16px 14px;
    background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sidebar-close { display: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 750; letter-spacing: -.4px; text-decoration: none; }
.brand-tag { font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 2px 6px; border-radius: 6px; color: var(--accent-text); background: var(--accent-soft); }
.edition { display: flex; justify-content: space-between; margin: 20px 6px 14px; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.edition span { color: var(--accent-text); letter-spacing: 0; text-transform: none; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--muted); width: 16px; height: 16px; }
.search kbd { position: absolute; right: 9px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; font: 11px ui-monospace, monospace; color: var(--muted); background: var(--surface-2); }
#search { width: 100%; min-height: 38px; padding: 8px 32px 8px 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
#search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.count { margin: 10px 6px 12px; font-size: 12px; color: var(--muted); }
#catalog { flex: 1; overflow: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; overscroll-behavior: contain; }
.nav-group { margin-bottom: 14px; }
.nav-group h2 { display: flex; justify-content: space-between; margin: 0 8px 4px; padding-top: 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.nav-group h2 span { font-weight: 600; letter-spacing: 0; }
.nav-link { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 5px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 13px; }
.nav-link:hover { background: var(--sunken); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.nav-link mark { background: none; color: var(--accent-text); font-weight: 700; }
.empty { margin: 8px; color: var(--muted); }
.sidebar-footer { display: flex; justify-content: space-between; margin-top: 10px; padding: 12px 8px 2px; border-top: 1px solid var(--border-soft); font-size: 13px; color: var(--text-2); text-decoration: none; }
.sidebar-footer:hover { color: var(--accent-text); }

/* Main */
main { margin-left: var(--sidebar); padding: 0 clamp(20px, 3.4vw, 48px) 56px; max-width: calc(1480px + var(--sidebar)); }
main:focus { outline: none; }
.topline { display: flex; align-items: center; gap: 20px; min-height: 64px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.crumbs { font-weight: 600; letter-spacing: .4px; text-transform: uppercase; font-size: 11px; }
.slash { margin: 0 8px; color: var(--border); }
.locale-switcher { display: flex; gap: 2px; margin-left: auto; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.locale-switcher a { padding: 3px 9px; border-radius: 6px; font-weight: 650; font-size: 12px; text-decoration: none; }
.locale-switcher a[aria-current] { background: var(--accent-soft); color: var(--accent-text); }
.home-link { font-size: 13px; text-decoration: none; color: var(--text-2); }
.home-link:hover { color: var(--accent-text); }

.intro { padding: 30px 0 22px; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent-text); }
h1 { margin: 8px 0 8px; font-size: clamp(28px, 3.2vw, 40px); line-height: 1.1; letter-spacing: -1.2px; font-weight: 720; }
.source { margin: 0; font: 12.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow-wrap: anywhere; }
.source code { color: var(--accent-text); }

.preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.preview-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #22b07d; box-shadow: 0 0 0 3px rgb(34 176 125 / .18); }
.preview-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-left: auto; }
.preview-stage {
    display: flex; justify-content: safe center; padding: 18px; overflow-x: auto;
    background-color: var(--sunken);
    background-image: radial-gradient(circle, color-mix(in srgb, var(--muted) 28%, transparent) 1px, transparent 1px);
    background-size: 16px 16px;
}
/* A fixed width (390/768/1280 px) is honoured even on narrower screens; the stage scrolls instead. */
iframe { display: block; flex: none; width: 100%; max-width: none; height: 360px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); transition: width .2s ease, height .15s ease; }

.note { margin: 14px 0 0; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; line-height: 1.65; }
.details { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 8px 12px 8px 18px; border-bottom: 1px solid var(--border-soft); }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 700; }
.badge-live { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: #138a5f; background: rgb(34 176 125 / .12); }
pre { margin: 0; padding: 18px; overflow: auto; background: var(--code); color: var(--text-2); font: 12.5px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; }
.code-panel pre { max-height: 420px; }
.t-tag { color: var(--code-tag); }
.t-attr { color: var(--code-attr); }
.t-value { color: var(--code-value); }
.t-punct { color: var(--code-punct); }
.caption { margin: 0; padding: 10px 18px 14px; color: var(--muted); font-size: 12px; line-height: 1.65; }

#controls { padding: 4px 18px; }
.control { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1.6fr); align-items: center; gap: 12px; min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.control:last-child { border-bottom: 0; }
.control > span { font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2); overflow-wrap: anywhere; }
.control input:not([type="checkbox"]), .control select, .control textarea { width: 100%; min-width: 0; }
.control textarea { min-height: 84px; resize: vertical; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.control input[type="color"] { padding: 3px; height: 34px; }
.control [aria-invalid="true"] { border-color: var(--danger); }
.control input[type="checkbox"] {
    appearance: none; justify-self: start; width: 38px; height: 22px; margin: 0; border-radius: 99px;
    background: var(--border); position: relative; transition: background .15s;
}
.control input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.control input[type="checkbox"]:checked { background: var(--accent); }
.control input[type="checkbox"]:checked::after { transform: translateX(16px); }
.control-error { grid-column: 2; margin: -2px 0 0; font-size: 12px; color: var(--danger); }
.controls-empty { margin: 14px 0; color: var(--muted); font-size: 13px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.pager-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-decoration: none; }
.pager-link:hover { border-color: var(--accent); }
.pager-link span { font-size: 12px; color: var(--muted); }
.pager-link strong { font-size: 14px; color: var(--text); }
.pager-link--next { text-align: right; }

.installation { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); }
.installation h2 { margin: 8px 0 12px; font-size: 24px; letter-spacing: -.6px; }
.installation > p:not(.eyebrow):not(.caption) { max-width: 780px; margin: 0 0 12px; color: var(--text-2); line-height: 1.75; }
.installation pre { margin: 18px 0; border: 1px solid var(--border); border-radius: 12px; }
.installation a { color: var(--accent-text); }
.installation .caption { padding: 0; }
#status { color: var(--danger); font-size: 13px; }
#status:empty { display: none; }

@media (max-width: 1180px) {
    .details { grid-template-columns: 1fr; }
}

/* Tablet and phone: the catalog becomes a drawer, the preview comes first. */
@media (max-width: 900px) {
    .appbar {
        position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
        min-height: 56px; padding: 8px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
        border-bottom: 1px solid var(--border); backdrop-filter: blur(10px);
    }
    .appbar .icon-button { min-height: 40px; }
    .brand--compact { margin-left: auto; font-size: 16px; }
    .sidebar { width: min(340px, 88vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); visibility: hidden; }
    .sidebar[data-open] { transform: none; visibility: visible; }
    .sidebar-close { display: inline-flex; }
    .search kbd { display: none; }
    .nav-link { min-height: 40px; font-size: 14px; }
    main { margin-left: 0; padding: 0 16px 40px; }
    .topline { min-height: 52px; gap: 12px; }
    .crumbs { display: none; }
    .locale-switcher { margin-left: 0; }
    .locale-switcher a { display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px; }
    .home-link { display: inline-flex; align-items: center; min-height: 40px; margin-left: auto; padding: 0 4px; }
    .intro { padding: 22px 0 16px; }
    .preview-toolbar { padding: 10px 12px; }
    .preview-actions { margin-left: 0; width: 100%; }
    .field { flex: 1 1 140px; }
    .preview-actions .button { flex: 1 1 auto; }
    .field select { flex: 1; }
    .preview-stage { padding: 10px; }
    .button, .field select, .control select, .control input:not([type="checkbox"]) { min-height: 40px; }
    .button--small { min-height: 36px; }
    .field select, .control select { height: 40px; }
}

@media (max-width: 520px) {
    .control { grid-template-columns: 1fr; gap: 6px; }
    .control-error { grid-column: 1; }
    .pager { grid-template-columns: 1fr; }
    .pager-link--next { text-align: left; }
    h1 { letter-spacing: -.8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
