:root {
    color-scheme: light;
    --lc-bg: #f4f7fb;
    --lc-surface: #ffffff;
    --lc-surface-subtle: #f8fafc;
    --lc-surface-muted: #eef3f8;
    --lc-surface-raised: #ffffff;
    --lc-surface-hover: #f1f5f9;
    --lc-text: #0f172a;
    --lc-text-secondary: #334155;
    --lc-text-muted: #64748b;
    --lc-text-inverse: #ffffff;
    --lc-border: #d8e1ec;
    --lc-border-subtle: #e8eef5;
    --lc-border-strong: #b8c6d8;
    --lc-primary: #2563eb;
    --lc-primary-hover: #1d4ed8;
    --lc-primary-active: #1e40af;
    --lc-primary-soft: #eaf2ff;
    --lc-primary-border: #bfd3ff;
    --lc-action: #2563eb;
    --lc-action-hover: #1d4ed8;
    --lc-action-active: #1e40af;
    --lc-on-action: #ffffff;
    --lc-success: #047857;
    --lc-success-soft: #ecfdf5;
    --lc-success-border: #a7f3d0;
    --lc-warning: #b45309;
    --lc-warning-soft: #fffbeb;
    --lc-warning-border: #fde68a;
    --lc-danger: #b91c1c;
    --lc-danger-hover: #991b1b;
    --lc-danger-action: #b91c1c;
    --lc-danger-action-hover: #991b1b;
    --lc-on-danger-action: #ffffff;
    --lc-danger-soft: #fef2f2;
    --lc-danger-border: #fecaca;
    --lc-info: #0369a1;
    --lc-info-soft: #f0f9ff;
    --lc-info-border: #bae6fd;
    --lc-focus: #2563eb;
    --lc-focus-ring: rgba(37, 99, 235, .28);
    --lc-font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --lc-text-xs: .75rem;
    --lc-text-sm: .875rem;
    --lc-text-md: 1rem;
    --lc-text-lg: 1.125rem;
    --lc-text-xl: 1.375rem;
    --lc-text-2xl: clamp(1.5rem, 1.25rem + .8vw, 2rem);
    --lc-leading-tight: 1.25;
    --lc-leading-body: 1.55;
    --lc-space-1: .25rem;
    --lc-space-2: .5rem;
    --lc-space-3: .75rem;
    --lc-space-4: 1rem;
    --lc-space-5: 1.25rem;
    --lc-space-6: 1.5rem;
    --lc-space-8: 2rem;
    --lc-space-10: 2.5rem;
    --lc-space-12: 3rem;
    --lc-radius-sm: .375rem;
    --lc-radius-md: .625rem;
    --lc-radius-lg: .875rem;
    --lc-radius-pill: 999px;
    --lc-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --lc-shadow-md: 0 12px 30px rgba(15, 23, 42, .09);
    --lc-shadow-overlay: 0 24px 70px rgba(15, 23, 42, .24);
    --lc-control-height: 2.5rem;
    --lc-control-height-compact: 2.25rem;
    --lc-page-gutter: clamp(1rem, 2.5vw, 2rem);
    --lc-content-wide: 90rem;
    --lc-content-reading: 48rem;
    --lc-duration-fast: 120ms;
    --lc-duration-normal: 180ms;
    --lc-ease-standard: cubic-bezier(.2, 0, 0, 1);

    /* Compatibility aliases while older screens migrate. */
    --color-bg: var(--lc-bg);
    --color-surface: var(--lc-surface);
    --color-surface-alt: var(--lc-surface-subtle);
    --color-surface-elevated: var(--lc-surface-raised);
    --color-surface-hover: var(--lc-surface-hover);
    --color-primary: var(--lc-primary);
    --color-primary-hover: var(--lc-primary-hover);
    --color-primary-light: var(--lc-primary-soft);
    --color-primary-border: var(--lc-primary-border);
    --color-text-primary: var(--lc-text);
    --color-text-secondary: var(--lc-text-secondary);
    --color-text-muted: var(--lc-text-muted);
    --color-border: var(--lc-border);
    --color-border-light: var(--lc-border-subtle);
    --color-border-strong: var(--lc-border-strong);
    --color-success: var(--lc-success);
    --color-success-light: var(--lc-success-soft);
    --color-warning: var(--lc-warning);
    --color-warning-light: var(--lc-warning-soft);
    --color-error: var(--lc-danger);
    --color-error-light: var(--lc-danger-soft);
    --font-xs: var(--lc-text-xs);
    --font-sm: var(--lc-text-sm);
    --radius-sm: var(--lc-radius-sm);
    --shadow-sm: var(--lc-shadow-sm);
    --shadow-md: var(--lc-shadow-md);
    --shadow-card: var(--lc-shadow-sm);
    --shadow-lg: var(--lc-shadow-md);
}

html.dark-mode,
html.dark {
    color-scheme: dark;
    --lc-bg: #0b1220;
    --lc-surface: #152033;
    --lc-surface-subtle: #101827;
    --lc-surface-muted: #1d2a3e;
    --lc-surface-raised: #1a2740;
    --lc-surface-hover: #213049;
    --lc-text: #f8fafc;
    --lc-text-secondary: #d5deea;
    --lc-text-muted: #9baabd;
    --lc-border: #33445b;
    --lc-border-subtle: #25354a;
    --lc-border-strong: #4a5d76;
    --lc-primary: #60a5fa;
    --lc-primary-hover: #93c5fd;
    --lc-primary-active: #bfdbfe;
    --lc-primary-soft: rgba(59, 130, 246, .16);
    --lc-primary-border: rgba(96, 165, 250, .34);
    --lc-action: #2563eb;
    --lc-action-hover: #1d4ed8;
    --lc-action-active: #1e40af;
    --lc-on-action: #ffffff;
    --lc-success: #6ee7b7;
    --lc-success-soft: rgba(16, 185, 129, .14);
    --lc-success-border: rgba(52, 211, 153, .32);
    --lc-warning: #fcd34d;
    --lc-warning-soft: rgba(245, 158, 11, .14);
    --lc-warning-border: rgba(251, 191, 36, .32);
    --lc-danger: #fca5a5;
    --lc-danger-hover: #fecaca;
    --lc-danger-action: #b91c1c;
    --lc-danger-action-hover: #991b1b;
    --lc-on-danger-action: #ffffff;
    --lc-danger-soft: rgba(239, 68, 68, .14);
    --lc-danger-border: rgba(248, 113, 113, .34);
    --lc-info: #7dd3fc;
    --lc-info-soft: rgba(14, 165, 233, .14);
    --lc-info-border: rgba(56, 189, 248, .32);
    --lc-focus: #93c5fd;
    --lc-focus-ring: rgba(147, 197, 253, .30);
    --lc-shadow-sm: 0 1px 2px rgba(2, 6, 23, .54);
    --lc-shadow-md: 0 16px 34px rgba(2, 6, 23, .42);
    --lc-shadow-overlay: 0 26px 78px rgba(2, 6, 23, .62);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--lc-font-sans); background: var(--lc-bg); }
body { margin: 0; background: var(--lc-bg); color: var(--lc-text-secondary); font-family: var(--lc-font-sans); line-height: var(--lc-leading-body); }
button, input, select, textarea { font: inherit; }
a { color: var(--lc-primary); }
img, svg { max-width: 100%; }

:where(a, button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
    outline: 3px solid var(--lc-focus-ring);
    outline-offset: 2px;
}

.lc-page { width: min(100%, var(--lc-content-wide)); margin-inline: auto; padding: 0 var(--lc-page-gutter) var(--lc-space-10); }
.lc-page[data-width="reading"] { max-width: var(--lc-content-reading); }
.lc-stack { display: flex; flex-direction: column; gap: var(--lc-space-5); }
.lc-stack[data-gap="sm"] { gap: var(--lc-space-3); }
.lc-stack[data-gap="lg"] { gap: var(--lc-space-8); }

.lc-card,
.lc-section-card { overflow: clip; border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface); box-shadow: var(--lc-shadow-sm); }
.lc-card__header,
.lc-section-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--lc-space-4); padding: var(--lc-space-5) var(--lc-space-6); border-bottom: 1px solid var(--lc-border-subtle); }
.lc-card__title,
.lc-section-card__title { margin: 0; color: var(--lc-text); font-size: var(--lc-text-lg); line-height: var(--lc-leading-tight); }
.lc-card__body,
.lc-section-card__body { padding: var(--lc-space-6); }
.lc-card__footer,
.lc-section-card__footer { padding: var(--lc-space-4) var(--lc-space-6); border-top: 1px solid var(--lc-border-subtle); background: var(--lc-surface-subtle); }

.lc-button { min-height: var(--lc-control-height); display: inline-flex; align-items: center; justify-content: center; gap: var(--lc-space-2); padding: 0 var(--lc-space-4); border: 1px solid transparent; border-radius: var(--lc-radius-md); background: var(--lc-action); color: var(--lc-on-action); font-size: var(--lc-text-sm); font-weight: 700; line-height: 1; text-decoration: none; cursor: pointer; transition: background-color var(--lc-duration-fast) var(--lc-ease-standard), border-color var(--lc-duration-fast) var(--lc-ease-standard), box-shadow var(--lc-duration-fast) var(--lc-ease-standard); }
.lc-button:hover { background: var(--lc-action-hover); }
.lc-button:active { background: var(--lc-action-active); }
.lc-button[data-variant="secondary"] { border-color: var(--lc-border); background: var(--lc-surface); color: var(--lc-text); }
.lc-button[data-variant="secondary"]:hover { border-color: var(--lc-border-strong); background: var(--lc-surface-hover); }
.lc-button[data-variant="quiet"] { background: transparent; color: var(--lc-text-secondary); }
.lc-button[data-variant="quiet"]:hover { background: var(--lc-surface-hover); color: var(--lc-text); }
.lc-button[data-variant="danger"] { background: var(--lc-danger-action); color: var(--lc-on-danger-action); }
.lc-button[data-variant="danger"]:hover { background: var(--lc-danger-action-hover); }
.lc-button:disabled,
.lc-button[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }

.lc-field { display: grid; gap: var(--lc-space-2); }
.lc-label { color: var(--lc-text); font-size: var(--lc-text-sm); font-weight: 700; }
.lc-control { width: 100%; min-height: var(--lc-control-height); padding: .55rem .75rem; border: 1px solid var(--lc-border-strong); border-radius: var(--lc-radius-md); background: var(--lc-surface); color: var(--lc-text); }
.lc-control::placeholder { color: var(--lc-text-muted); opacity: 1; }
.lc-control:disabled { background: var(--lc-surface-muted); color: var(--lc-text-muted); cursor: not-allowed; }
.lc-help { margin: 0; color: var(--lc-text-muted); font-size: var(--lc-text-xs); }
.lc-field-error { margin: 0; color: var(--lc-danger); font-size: var(--lc-text-sm); font-weight: 600; }

.lc-alert { display: flex; align-items: flex-start; gap: var(--lc-space-3); padding: var(--lc-space-4); border: 1px solid var(--lc-info-border); border-radius: var(--lc-radius-md); background: var(--lc-info-soft); color: var(--lc-info); }
.lc-alert[data-tone="success"] { border-color: var(--lc-success-border); background: var(--lc-success-soft); color: var(--lc-success); }
.lc-alert[data-tone="warning"] { border-color: var(--lc-warning-border); background: var(--lc-warning-soft); color: var(--lc-warning); }
.lc-alert[data-tone="danger"] { border-color: var(--lc-danger-border); background: var(--lc-danger-soft); color: var(--lc-danger); }

.lc-badge { display: inline-flex; align-items: center; min-height: 1.5rem; padding: 0 .55rem; border: 1px solid var(--lc-border); border-radius: var(--lc-radius-pill); background: var(--lc-surface-subtle); color: var(--lc-text-secondary); font-size: var(--lc-text-xs); font-weight: 700; white-space: nowrap; }
.lc-badge[data-tone="success"] { border-color: var(--lc-success-border); background: var(--lc-success-soft); color: var(--lc-success); }
.lc-badge[data-tone="warning"] { border-color: var(--lc-warning-border); background: var(--lc-warning-soft); color: var(--lc-warning); }
.lc-badge[data-tone="danger"] { border-color: var(--lc-danger-border); background: var(--lc-danger-soft); color: var(--lc-danger); }
.lc-badge[data-tone="info"] { border-color: var(--lc-info-border); background: var(--lc-info-soft); color: var(--lc-info); }

.lc-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--lc-space-6); padding-block: var(--lc-space-6); }
.lc-page-header__copy { min-width: 0; }
.lc-page-header__eyebrow { margin: 0 0 var(--lc-space-1); color: var(--lc-primary); font-size: var(--lc-text-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lc-page-header__title { margin: 0; color: var(--lc-text); font-size: var(--lc-text-2xl); line-height: var(--lc-leading-tight); }
.lc-page-header__subtitle { max-width: 52rem; margin: var(--lc-space-2) 0 0; color: var(--lc-text-muted); }
.lc-page-header__actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: var(--lc-space-2); }

.lc-choice { display: inline-flex; align-items: flex-start; gap: var(--lc-space-2); min-width: 0; color: var(--lc-text-secondary); }
.lc-choice input { width: 1rem; height: 1rem; margin-top: .2rem; accent-color: var(--lc-primary); }
.lc-choice__copy { min-width: 0; }

.lc-filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--lc-space-3); padding: var(--lc-space-4); border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface); }
.lc-filter-bar__actions { display: flex; flex-wrap: wrap; gap: var(--lc-space-2); margin-inline-start: auto; }
.lc-filter-chip { display: inline-flex; align-items: center; gap: var(--lc-space-1); min-height: 2rem; padding: 0 var(--lc-space-3); border: 1px solid var(--lc-primary-border); border-radius: var(--lc-radius-pill); background: var(--lc-primary-soft); color: var(--lc-primary); font-size: var(--lc-text-xs); font-weight: 700; }

.lc-tabs { display: flex; max-width: 100%; gap: var(--lc-space-1); overflow-x: auto; border-bottom: 1px solid var(--lc-border); }
.lc-tab { min-height: var(--lc-control-height); padding: 0 var(--lc-space-4); border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--lc-text-muted); font-weight: 700; white-space: nowrap; cursor: pointer; }
.lc-tab:hover { color: var(--lc-text); }
.lc-tab[aria-selected="true"],
.lc-tab[aria-current="page"] { border-bottom-color: var(--lc-primary); color: var(--lc-primary); }

.lc-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--lc-space-3); }
.lc-pagination__pages { display: flex; flex-wrap: wrap; gap: var(--lc-space-1); }
.lc-pagination a,
.lc-pagination button { display: inline-flex; min-width: var(--lc-control-height); min-height: var(--lc-control-height); align-items: center; justify-content: center; padding: 0 var(--lc-space-3); border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface); color: var(--lc-text-secondary); text-decoration: none; }
.lc-pagination [aria-current="page"] { border-color: var(--lc-action); background: var(--lc-action); color: var(--lc-on-action); }

.lc-disclosure { border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface); }
.lc-disclosure > summary { min-height: var(--lc-control-height); display: flex; align-items: center; padding: var(--lc-space-3) var(--lc-space-4); color: var(--lc-text); font-weight: 700; cursor: pointer; }
.lc-disclosure__body { padding: 0 var(--lc-space-4) var(--lc-space-4); color: var(--lc-text-secondary); }

.lc-drawer-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; justify-items: end; background: rgba(2, 6, 23, .58); }
.lc-drawer { width: min(28rem, 100%); height: 100%; overflow: auto; border-left: 1px solid var(--lc-border); background: var(--lc-surface-raised); box-shadow: var(--lc-shadow-overlay); }
.lc-drawer__header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--lc-space-3); padding: var(--lc-space-4); border-bottom: 1px solid var(--lc-border); background: var(--lc-surface-raised); }
.lc-drawer__body { padding: var(--lc-space-4); }

.lc-toast-stack { position: fixed; z-index: 110; right: var(--lc-space-4); bottom: var(--lc-space-4); display: grid; width: min(24rem, calc(100vw - 2rem)); gap: var(--lc-space-2); }
.lc-toast { display: flex; align-items: flex-start; gap: var(--lc-space-3); padding: var(--lc-space-4); border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface-raised); color: var(--lc-text-secondary); box-shadow: var(--lc-shadow-md); }
.lc-toast[data-tone="success"] { border-color: var(--lc-success-border); }
.lc-toast[data-tone="warning"] { border-color: var(--lc-warning-border); }
.lc-toast[data-tone="danger"] { border-color: var(--lc-danger-border); }

.lc-loading-state,
.lc-permission-state { display: grid; justify-items: center; gap: var(--lc-space-3); padding: var(--lc-space-8); color: var(--lc-text-muted); text-align: center; }
.lc-loading-state[aria-busy="true"]::before { width: 1.25rem; height: 1.25rem; border: 2px solid var(--lc-border); border-top-color: var(--lc-primary); border-radius: 50%; content: ""; }
@media (prefers-reduced-motion: no-preference) { .lc-loading-state[aria-busy="true"]::before { animation: lc-spin .8s linear infinite; } @keyframes lc-spin { to { transform: rotate(1turn); } } }

.lc-empty-state { max-width: 40rem; margin: auto; padding: clamp(2rem, 6vw, 4rem); text-align: center; }
.lc-empty-state h2, .lc-empty-state h3 { margin: 0; color: var(--lc-text); }
.lc-empty-state p { margin: var(--lc-space-3) auto 0; color: var(--lc-text-muted); }
.lc-empty-state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--lc-space-3); margin-top: var(--lc-space-6); }

.lc-table-shell { max-width: 100%; overflow-x: auto; border: 1px solid var(--lc-border); border-radius: var(--lc-radius-md); background: var(--lc-surface); }
.lc-table { width: 100%; border-collapse: collapse; }
.lc-table th { background: var(--lc-surface-subtle); color: var(--lc-text-muted); font-size: var(--lc-text-xs); font-weight: 700; text-align: left; }
.lc-table th, .lc-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--lc-border-subtle); vertical-align: top; }
.lc-table tbody tr:hover { background: var(--lc-surface-hover); }

.lc-skeleton { overflow: hidden; border-radius: var(--lc-radius-sm); background: var(--lc-surface-muted); color: transparent; }
@media (prefers-reduced-motion: no-preference) {
    .lc-skeleton { background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.52), transparent); background-size: 220% 100%; animation: lc-skeleton 1.4s linear infinite; }
    @keyframes lc-skeleton { to { background-position-x: -220%; } }
}

.lc-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
    :root { --lc-page-gutter: .875rem; }
    .lc-button,
    .lc-control,
    :where(button, input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea, summary, [role="button"]) { min-height: 44px; }
    .lc-card__header,
    .lc-section-card__header,
    .lc-card__body,
    .lc-section-card__body { padding: var(--lc-space-4); }
    .lc-page-header { flex-direction: column; gap: var(--lc-space-4); }
    .lc-page-header__actions { width: 100%; justify-content: flex-start; }
    .lc-filter-bar { align-items: stretch; }
    .lc-filter-bar > * { flex: 1 1 100%; }
    .lc-filter-bar__actions { margin-inline-start: 0; }
}

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