:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --surface-raised: #ffffff;
  --border: #d6dde3;
  --border-strong: #b9c4ce;
  --text: #25313c;
  --text-muted: #667481;
  --text-faint: #87939d;
  --primary: #446f8f;
  --primary-hover: #365f7d;
  --primary-soft: #eaf1f6;
  --focus: #9cc4df;
  --success: #467a5c;
  --success-soft: #edf6f0;
  --info: #4f708f;
  --info-soft: #edf3f7;
  --warning: #805919;
  --warning-soft: #fff6e5;
  --danger: #a94b4b;
  --danger-hover: #8d3e3e;
  --danger-soft: #faeeee;
  --disabled: #eef1f3;
  --overlay: rgb(20 28 35 / 0.42);

  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;

  --radius-sm: 6px;
  --radius-btn: 8px;
  --radius: 10px;
  --field-h: 44px;
  --content-max: 1440px;
  --sidebar-w: 256px;
  --topbar-h: 64px;

  --z-sidebar: 20;
  --z-topbar: 30;
  --z-dropdown: 50;
  --z-scrim: 80;
  --z-drawer: 90;
  --z-modal: 100;
  --z-toast: 110;
}

html[data-theme="dark"] {
  --bg: #151a1f;
  --surface: #1d242a;
  --surface-subtle: #232b32;
  --surface-raised: #202830;
  --border: #34414b;
  --border-strong: #4a5a66;
  --text: #e8edf1;
  --text-muted: #aab6bf;
  --text-faint: #8997a2;
  --primary: #78a4c5;
  --primary-hover: #94b8d2;
  --primary-soft: #253744;
  --focus: #4e7895;
  --success: #79aa8c;
  --success-soft: #20362a;
  --info: #8aacc8;
  --info-soft: #243643;
  --warning: #d0a65d;
  --warning-soft: #3b3020;
  --danger: #d58787;
  --danger-hover: #e1a0a0;
  --danger-soft: #402728;
  --disabled: #283137;
  --overlay: rgb(0 0 0 / 0.58);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--bg); font-family: var(--font-ui); line-height: 1.55; text-rendering: optimizeLegibility; }
body.is-locked { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); text-underline-offset: .18em; }
a:hover { color: var(--primary-hover); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.svg-sprite { position: absolute; }
.skip-link { position: fixed; z-index: 999; top: 8px; left: 8px; transform: translateY(-160%); padding: 8px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.skip-link:focus { transform: none; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar); width: var(--sidebar-w); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; gap: 12px; align-items: center; min-height: var(--topbar-h); padding: 10px 18px; border-bottom: 1px solid var(--border); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; color: #fff; background: var(--primary); border-radius: 8px; font-weight: 800; font-size: .9rem; letter-spacing: .04em; }
.brand-copy { min-width: 0; display: grid; line-height: 1.2; }
.brand-copy strong { font-size: .92rem; }
.brand-copy span { margin-top: 4px; color: var(--text-muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { display: grid; gap: 4px; padding: 16px 12px; overflow-y: auto; }
.side-link { display: flex; gap: 10px; align-items: center; min-height: 42px; padding: 8px 10px; color: var(--text-muted); border-radius: 8px; text-decoration: none; font-size: .9rem; font-weight: 650; }
.side-link svg { width: 18px; height: 18px; flex: 0 0 auto; }
.side-link:hover { color: var(--text); background: var(--surface-subtle); }
.side-link.is-active { color: var(--primary); background: var(--primary-soft); }
.sidebar-footer { margin-top: auto; padding: 16px 18px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .78rem; }
.sidebar-footer p { margin: 8px 0 0; }
.mini-status { display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 650; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--text-faint); }
.status-dot.success { background: var(--success); }

.app-area { min-width: 0; margin-left: var(--sidebar-w); }
.topbar { position: sticky; top: 0; z-index: var(--z-topbar); min-height: var(--topbar-h); display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 10px 24px; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.topbar-title { min-width: 0; display: grid; line-height: 1.15; }
.topbar-title strong { font-size: .92rem; }
.topbar-title span { margin-top: 4px; color: var(--text-muted); font-size: .76rem; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.search-compact { position: relative; width: min(32vw, 320px); }
.search-compact svg { position: absolute; left: 10px; top: 50%; width: 17px; height: 17px; color: var(--text-muted); transform: translateY(-50%); pointer-events: none; }
.search-compact input { padding-left: 34px !important; }
.user-menu { display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 4px 8px 4px 4px; background: transparent; border: 1px solid transparent; border-radius: var(--radius-btn); cursor: pointer; }
.user-menu:hover { background: var(--surface-subtle); border-color: var(--border); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; color: var(--primary); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: 999px; font-size: .72rem; font-weight: 800; }
.chev { width: 16px; height: 16px; transform: rotate(90deg); }
.mobile-only { display: none !important; }

.main { width: min(100%, var(--content-max)); margin: 0 auto; padding: 32px 32px 64px; }
.page-head { display: flex; gap: 24px; align-items: flex-end; justify-content: space-between; padding-bottom: 32px; }
.page-head > div:first-child { min-width: 0; max-width: 920px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; flex: 0 0 auto; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; color: var(--text-muted); font-size: .8rem; }
.breadcrumb a { color: inherit; }
h1, h2, h3, h4 { margin: 0; color: var(--text); line-height: 1.22; letter-spacing: -.015em; }
h1 { font-size: clamp(1.9rem, 1.65rem + 1vw, 2.45rem); font-weight: 780; }
h2 { font-size: clamp(1.45rem, 1.32rem + .45vw, 1.8rem); font-weight: 750; }
h3 { font-size: 1.12rem; font-weight: 730; }
h4 { font-size: 1rem; font-weight: 720; }
p { margin: 0; }
.lead { margin-top: 12px; color: var(--text-muted); font-size: 1.05rem; max-width: 78ch; }
.text-muted, .center-muted { color: var(--text-muted); }
.center-muted { text-align: center; font-size: .82rem; }
.kicker { display: inline-block; margin-bottom: 7px; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.section { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.section + .section { margin-top: 64px; }
.section-head { display: flex; gap: 20px; justify-content: space-between; margin-bottom: 22px; }
.section-head p { max-width: 78ch; margin-top: 8px; color: var(--text-muted); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid + .grid, .component-card + .grid, .grid + .component-card, .component-card + .component-card { margin-top: 20px; }
.minw0 { min-width: 0; }
.no-shrink { flex: 0 0 auto; }

.rule-banner { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 20px; padding: 14px 16px; color: var(--info); background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 28%, var(--border)); border-radius: var(--radius); }
.rule-banner svg { flex: 0 0 auto; margin-top: 1px; }
.stat-grid { margin-bottom: 20px; }
.stat-card, .component-card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card { display: grid; padding: 18px; }
.stat-label { color: var(--text-muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat-card strong { margin-top: 8px; font-size: 1.8rem; line-height: 1; }
.stat-card small { margin-top: 8px; color: var(--text-muted); }
.component-card { padding: 24px; }
.component-card.compact { padding: 16px; }
.component-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.component-head > div { min-width: 0; }
.component-head p { margin-top: 5px; color: var(--text-muted); font-size: .9rem; }

.swatches { display: grid; grid-template-columns: repeat(8, minmax(105px, 1fr)); gap: 12px; }
.swatch { overflow: hidden; min-width: 0; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 8px; }
.swatch > span { display: block; height: 58px; background: var(--sw); border-bottom: 1px solid var(--border); }
.swatch b, .swatch code { display: block; padding-inline: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch b { padding-top: 9px; font-size: .76rem; }
.swatch code { padding-top: 2px; padding-bottom: 9px; color: var(--text-muted); font-family: var(--font-mono); font-size: .69rem; }
.type-stack { display: grid; gap: 0; }
.type-stack > div { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: baseline; padding: 13px 0; border-bottom: 1px solid var(--border); }
.type-stack > div:last-child { border-bottom: 0; }
.type-stack > div > span { color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; }
.type-stack p, .type-stack small { color: var(--text-muted); }
.spacing-list { display: grid; gap: 8px; }
.spacing-list > div { display: grid; grid-template-columns: 36px 64px 1fr; gap: 10px; align-items: center; min-height: 28px; }
.spacing-list code { font-family: var(--font-mono); font-size: .75rem; }
.spacing-list i { display: block; width: var(--w); min-width: 4px; height: 14px; background: var(--primary); border-radius: 2px; }
.spacing-list span { color: var(--text-muted); font-size: .82rem; }
.demo-box { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); }
.demo-box p { margin-top: 7px; color: var(--text-muted); }
.demo-box-subtle { background: var(--surface-subtle); }
.demo-box-accent { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }

.demo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.demo-row + .demo-row { margin-top: 16px; }
.btn { display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: var(--field-h); max-width: 100%; padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-btn); cursor: pointer; font-weight: 720; line-height: 1.2; white-space: nowrap; text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { text-decoration: none; }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-subtle); }
.btn-quiet { color: var(--primary); background: transparent; border-color: transparent; }
.btn-quiet:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { color: #fff; background: var(--danger-hover); border-color: var(--danger-hover); }
.btn:disabled { opacity: .46; cursor: not-allowed; }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: .82rem; }
.btn-lg { min-height: 50px; padding: 11px 20px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-btn); cursor: pointer; }
.icon-btn:hover { background: var(--surface-subtle); border-color: var(--border-strong); }
.icon-btn.sm { width: 32px; height: 32px; flex-basis: 32px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.notification-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: var(--danger); border: 2px solid var(--surface); border-radius: 999px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.toolbar-group { display: flex; flex-wrap: wrap; gap: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label:not(.choice):not(.switch), .field .label, .field legend { display: block; margin-bottom: 7px; color: var(--text); font-size: .84rem; font-weight: 720; }
.required { color: var(--danger); }
.field small { display: block; margin-top: 7px; color: var(--text-muted); font-size: .76rem; line-height: 1.4; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { width: 100%; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select { min-height: var(--field-h); padding: 8px 12px; }
textarea { min-height: 126px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: color-mix(in srgb, var(--border-strong) 75%, var(--text)); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); outline: 3px solid var(--focus); outline-offset: 1px; }
input[readonly] { background: var(--surface-subtle); }
input:disabled, select:disabled, textarea:disabled { color: var(--text-muted); background: var(--disabled); border-color: var(--border); cursor: not-allowed; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); }
.field-error { display: flex !important; gap: 6px; align-items: center; color: var(--danger) !important; font-weight: 670; }
.field-error svg { width: 15px; height: 15px; }
.field-meta { display: flex; gap: 12px; justify-content: space-between; }
.input-icon, .input-action { position: relative; }
.input-icon > svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; color: var(--text-muted); transform: translateY(-50%); pointer-events: none; }
.input-icon input { padding-left: 36px !important; }
.input-action { display: flex; }
.input-action input { padding-right: 82px !important; }
.input-btn { position: absolute; right: 5px; top: 5px; min-height: 34px; padding: 4px 8px; color: var(--primary); background: var(--surface-subtle); border: 0; border-radius: 6px; cursor: pointer; font-size: .76rem; font-weight: 700; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; accent-color: var(--primary); }
fieldset.field { margin: 0; padding: 0; border: 0; }
.choice-stack { display: grid; gap: 8px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.choice { display: inline-flex; gap: 8px; align-items: flex-start; min-height: 28px; cursor: pointer; }
.choice input { margin-top: 2px; }
.choice.is-disabled { color: var(--text-muted); cursor: not-allowed; }
.switch { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-track { display: inline-flex; width: 44px; height: 24px; flex: 0 0 44px; align-items: center; padding: 2px; background: var(--border-strong); border: 1px solid var(--border-strong); border-radius: 999px; }
.switch-track span { width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform 140ms ease; }
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track span { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding-top: 20px; border-top: 1px solid var(--border); }
input[type="file"] { padding: 5px; }
input[type="file"]::file-selector-button { min-height: 32px; margin-right: 10px; padding: 5px 10px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-weight: 650; }

.editor { overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.editor-toolbar, .editor-status { background: var(--surface-subtle); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 44px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.editor-toolbar button { min-width: 32px; min-height: 32px; padding: 4px 8px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.editor-toolbar > span { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.editor-content { min-height: 190px; padding: 20px; outline: 0; }
.editor-content > * + * { margin-top: 12px; }
.editor-content blockquote { margin-inline: 0; padding: 10px 14px; color: var(--text-muted); background: var(--surface-subtle); border-left: 4px solid var(--border-strong); }
.editor-status { display: flex; gap: 16px; justify-content: space-between; padding: 6px 10px; color: var(--text-muted); border-top: 1px solid var(--border); font-size: .72rem; }

.badge { display: inline-flex; align-items: center; min-height: 26px; max-width: 100%; padding: 3px 9px; border: 1px solid; border-radius: 999px; font-size: .75rem; font-weight: 730; line-height: 1.2; white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, var(--border)); }
.badge-info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, var(--border)); }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, var(--border)); }
.badge-neutral { color: var(--text-muted); background: var(--surface-subtle); border-color: var(--border); }
.alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 14px 16px; border: 1px solid; border-radius: var(--radius); }
.alert + .alert { margin-top: 10px; }
.alert > svg { width: 19px; height: 19px; margin-top: 1px; }
.alert div { min-width: 0; display: grid; gap: 2px; }
.alert span { font-size: .88rem; }
.alert button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; color: currentColor; background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.alert button:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.alert button svg { width: 17px; height: 17px; }
.alert-success { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, var(--border)); }
.alert-info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, var(--border)); }
.alert-warning { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.alert-danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, var(--border)); }
.compact-alert { padding: 12px; }
.progress-group { margin-top: 22px; }
.progress-meta { display: flex; gap: 12px; justify-content: space-between; margin-bottom: 7px; font-size: .85rem; }
.progress { overflow: hidden; height: 9px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 999px; }
.progress span, .progress-line span { display: block; height: 100%; background: var(--primary); }
.progress-line { width: 100px; height: 6px; overflow: hidden; background: var(--surface-subtle); border-radius: 999px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: .86rem; }
th, td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { color: var(--text); background: var(--surface-subtle); font-size: .74rem; font-weight: 780; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-subtle) 70%, transparent); }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--text-muted); }
.align-right { text-align: right; }
.row-actions { display: inline-flex; gap: 6px; }
.table-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--text-muted); font-size: .8rem; }
.pagination { display: flex; flex-wrap: wrap; gap: 4px; }
.pagination button { min-width: 34px; height: 34px; padding: 0 9px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.pagination button:hover:not(:disabled) { background: var(--surface-subtle); }
.pagination button.is-current { color: #fff; background: var(--primary); border-color: var(--primary); }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
.list-item { display: flex; gap: 10px; align-items: center; min-width: 0; padding: 9px 0; }
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-copy { min-width: 0; flex: 1 1 auto; display: grid; }
.list-copy strong, .list-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-copy span { color: var(--text-muted); font-size: .76rem; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 18px 8px; text-align: center; }
.empty-state p { max-width: 32ch; color: var(--text-muted); font-size: .82rem; }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; color: var(--primary); background: var(--primary-soft); border-radius: 999px; }
.skeleton { display: grid; gap: 10px; padding: 10px 0 16px; }
.skeleton span { display: block; width: 100%; height: 12px; background: linear-gradient(90deg, var(--surface-subtle), color-mix(in srgb, var(--border) 70%, var(--surface)), var(--surface-subtle)); background-size: 200% 100%; border-radius: 6px; animation: shimmer 1.4s infinite linear; }
.skeleton .skeleton-title { width: 55%; height: 18px; }
.skeleton .short { width: 72%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { position: relative; min-height: 42px; padding: 8px 12px; color: var(--text-muted); background: transparent; border: 0; cursor: pointer; font-weight: 690; white-space: nowrap; }
.tab::after { content: ""; position: absolute; right: 8px; bottom: -1px; left: 8px; height: 2px; background: transparent; }
.tab.is-active { color: var(--primary); }
.tab.is-active::after { background: var(--primary); }
.tab-panel { display: none; padding: 18px 4px 0; color: var(--text-muted); }
.tab-panel.is-active { display: block; }

.accordion { border-top: 1px solid var(--border); }
.accordion-trigger { width: 100%; display: flex; gap: 16px; align-items: center; justify-content: space-between; min-height: 48px; padding: 10px 0; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; text-align: left; font-weight: 700; }
.accordion-trigger svg { width: 18px; height: 18px; flex: 0 0 auto; transition: transform 140ms ease; }
.accordion-trigger[aria-expanded="true"] svg { transform: rotate(90deg); }
.accordion-panel { display: none; padding: 14px 0 18px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.accordion-panel.is-open { display: block; }

.dropdown-wrap { position: relative; }
.dropdown { position: absolute; z-index: var(--z-dropdown); top: calc(100% + 6px); right: 0; width: 180px; display: none; padding: 6px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.dropdown.is-open { display: grid; }
.dropdown button { padding: 8px 10px; color: var(--text); background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.dropdown button:hover { background: var(--surface-subtle); }
.dropdown hr { width: 100%; margin: 5px 0; border: 0; border-top: 1px solid var(--border); }
.danger-text { color: var(--danger) !important; }

.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--overlay); }
.modal { position: fixed; z-index: var(--z-modal); top: 50%; left: 50%; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; transform: translate(-50%, -50%); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 12px; }
.modal-head, .drawer-head { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; }
.modal-body > * + * { margin-top: 16px; }
.modal-actions, .drawer-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 14px 22px; background: var(--surface-subtle); border-top: 1px solid var(--border); }
.drawer { position: fixed; z-index: var(--z-drawer); inset: 0 0 0 auto; width: min(430px, calc(100vw - 24px)); display: grid; grid-template-rows: auto 1fr auto; background: var(--surface-raised); border-left: 1px solid var(--border); transform: translateX(102%); transition: transform 180ms ease; }
.drawer.is-open { transform: none; }
.drawer-body { display: grid; align-content: start; gap: 18px; padding: 22px; overflow-y: auto; }
.toast-region { position: fixed; z-index: var(--z-toast); right: 18px; bottom: 18px; width: min(380px, calc(100vw - 36px)); display: grid; gap: 10px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 13px 14px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); pointer-events: auto; }
.toast > svg { color: var(--success); }
.toast div { display: grid; gap: 2px; }
.toast span { color: var(--text-muted); font-size: .8rem; }
.toast button { width: 28px; height: 28px; padding: 0; background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.toast button svg { width: 16px; height: 16px; }

.stress-copy { overflow-wrap: anywhere; padding: 12px; color: var(--text-muted); background: var(--surface-subtle); border: 1px dashed var(--border-strong); border-radius: 8px; font-family: var(--font-mono); font-size: .76rem; }
.narrow-simulator { position: relative; }
.narrow-label { position: absolute; top: 12px; right: 14px; color: var(--text-muted); font-family: var(--font-mono); font-size: .7rem; }
.narrow-frame { width: min(320px, 100%); display: grid; gap: 18px; margin: 10px auto 0; padding: 16px; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 12px; }
.mini-card { min-width: 0; display: grid; gap: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.mini-card p { margin-top: 6px; color: var(--text-muted); font-size: .8rem; }
.quality-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 20px; }
.quality-grid > div { display: flex; gap: 9px; align-items: center; min-width: 0; padding: 11px 12px; color: var(--success); background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 25%, var(--border)); border-radius: 8px; font-size: .8rem; font-weight: 650; }
.quality-grid svg { width: 16px; height: 16px; flex: 0 0 auto; }
.page-footer { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; margin-top: 64px; padding-top: 20px; color: var(--text-muted); border-top: 1px solid var(--border); font-size: .76rem; }
.page-footer strong { color: var(--text); }
.theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-icon-dark { display: block; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .swatches { grid-template-columns: repeat(4, minmax(105px,1fr)); }
  .quality-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-grid !important; }
  .desktop-only { display: none !important; }
  .sidebar { transform: translateX(-102%); transition: transform 180ms ease; }
  .sidebar.is-open { z-index: var(--z-drawer); transform: none; }
  .app-area { margin-left: 0; }
  .topbar { padding-inline: 14px; }
  .main { padding: 24px 20px 48px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .main { padding-inline: 12px; }
  .section + .section { margin-top: 48px; }
  .component-card { padding: 16px; }
  .component-head { flex-direction: column; align-items: stretch; }
  .component-head .btn { align-self: flex-start; }
  .grid-2, .grid-4, .form-grid, .quality-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .swatches { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .page-actions .btn { flex: 1 1 auto; }
  .toolbar, .table-footer { align-items: stretch; }
  .toolbar-group { width: 100%; }
  .toolbar-group .btn { flex: 1 1 auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .modal-head, .drawer-head { padding: 16px; }
  .modal-body, .drawer-body { padding: 16px; }
  .modal-actions, .drawer-actions { padding: 12px 16px; }
  .alert { padding: 12px; }
  .user-menu { padding-right: 4px; }
}

@media (max-width: 420px) {
  .topbar-title span { display: none; }
  .swatches { grid-template-columns: 1fr 1fr; }
  .demo-row .btn { flex: 1 1 100%; }
  .demo-row .icon-btn { flex: 0 0 40px; }
  .badge { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
