/* Ludworks design system — tokens, base, components and app layouts.
   Light/dark via custom properties: follows the OS unless <html data-theme> overrides.
   CSP note: no inline styles exist anywhere; dynamic values use CSSOM custom properties. */

/* =========================================================== tokens: light */
:root {
  color-scheme: light;
  --c-bg: #fbfbfc;
  --c-surface: #ffffff;
  --c-surface-2: #f4f4f6;
  --c-surface-3: #ebebef;
  --c-sidebar: #f6f6f8;
  --c-overlay: rgba(15, 15, 20, 0.42);
  --c-border: #e6e6eb;
  --c-border-strong: #d4d4dc;
  --c-text: #17171c;
  --c-text-2: #55555f;
  --c-text-3: #8a8a95;
  --c-accent: #5b5bd6;
  --c-accent-hover: #4e4ec8;
  --c-accent-active: #4343b5;
  --c-accent-fg: #ffffff;
  --c-accent-soft: rgba(91, 91, 214, 0.1);
  --c-accent-soft-2: rgba(91, 91, 214, 0.16);
  --c-accent-text: #4747c2;
  --c-danger: #dc2626;
  --c-danger-hover: #c81e1e;
  --c-danger-soft: rgba(220, 38, 38, 0.08);
  --c-danger-text: #b91c1c;
  --c-warning: #d97706;
  --c-warning-soft: rgba(217, 119, 6, 0.1);
  --c-warning-text: #a35a04;
  --c-success: #16a34a;
  --c-success-soft: rgba(22, 163, 74, 0.1);
  --c-success-text: #15803d;
  --c-info: #2563eb;
  --c-info-soft: rgba(37, 99, 235, 0.08);
  --c-info-text: #1d4ed8;
  --c-tooltip-bg: #1d1d22;
  --c-tooltip-fg: #f6f6f8;
  --c-skeleton: #ececf0;
  --c-skeleton-shine: #f6f6f8;

  --shadow-1: 0 1px 2px rgba(18, 18, 24, 0.05);
  --shadow-2: 0 4px 14px rgba(18, 18, 24, 0.08), 0 1px 3px rgba(18, 18, 24, 0.05);
  --shadow-3: 0 18px 50px rgba(18, 18, 24, 0.16), 0 4px 14px rgba(18, 18, 24, 0.08);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--c-accent) 32%, transparent);

  /* category palette (storage charts) */
  --cat-movie: #6366f1;
  --cat-tv: #a855f7;
  --cat-music: #ec4899;
  --cat-image: #f59e0b;
  --cat-game: #10b981;
  --cat-document: #3b82f6;
  --cat-software: #64748b;
  --cat-other: #a8a29e;
  --cat-none: #d4d4d8;
  --cat-trash: #ef4444;

  /* app tints */
  --tint-indigo: #5b5bd6;
  --tint-blue: #2f74e8;
  --tint-violet: #8b5cf6;
  --tint-amber: #d98a06;
  --tint-emerald: #10a36e;
  --tint-teal: #0f9488;
  --tint-sky: #0b8bd1;
  --tint-slate: #64748b;
  --tint-rose: #e11d48;
  --tint-pink: #db2777;
  --tint-orange: #ea580c;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;
  --r-xs: 4px; --r-sm: 6px; --r: 8px; --r-md: 10px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-base: 13.5px; --fs-md: 14.5px; --fs-lg: 16px; --fs-xl: 19px; --fs-2xl: 23px; --fs-3xl: 30px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 140ms;
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --tray-offset: 0px;
}

/* ============================================================ tokens: dark */
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #0e0e11;
  --c-surface: #151518;
  --c-surface-2: #1c1c21;
  --c-surface-3: #26262c;
  --c-sidebar: #111114;
  --c-overlay: rgba(0, 0, 0, 0.6);
  --c-border: #26262d;
  --c-border-strong: #35353e;
  --c-text: #ececf1;
  --c-text-2: #a3a3ae;
  --c-text-3: #6f6f7a;
  --c-accent: #7272ee;
  --c-accent-hover: #8282f3;
  --c-accent-active: #6262e2;
  --c-accent-fg: #ffffff;
  --c-accent-soft: rgba(124, 124, 240, 0.14);
  --c-accent-soft-2: rgba(124, 124, 240, 0.22);
  --c-accent-text: #a9a9ff;
  --c-danger: #e5484d;
  --c-danger-hover: #f05a5f;
  --c-danger-soft: rgba(229, 72, 77, 0.14);
  --c-danger-text: #ff9592;
  --c-warning: #f0a020;
  --c-warning-soft: rgba(240, 160, 32, 0.13);
  --c-warning-text: #ffc560;
  --c-success: #30a46c;
  --c-success-soft: rgba(48, 164, 108, 0.14);
  --c-success-text: #6fdba2;
  --c-info: #3e8bf6;
  --c-info-soft: rgba(62, 139, 246, 0.14);
  --c-info-text: #8ec0ff;
  --c-tooltip-bg: #2b2b32;
  --c-tooltip-fg: #f2f2f5;
  --c-skeleton: #1f1f25;
  --c-skeleton-shine: #2a2a31;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 22px 60px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --cat-none: #4a4a52;
  --cat-other: #8b857f;
  --tint-indigo: #8484f3;
  --tint-blue: #5b9bff;
  --tint-violet: #a78bfa;
  --tint-amber: #f5b23d;
  --tint-emerald: #34d399;
  --tint-teal: #2dd4bf;
  --tint-sky: #38bdf8;
  --tint-slate: #94a3b8;
  --tint-rose: #fb7185;
  --tint-pink: #f472b6;
  --tint-orange: #fb923c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: #0e0e11;
    --c-surface: #151518;
    --c-surface-2: #1c1c21;
    --c-surface-3: #26262c;
    --c-sidebar: #111114;
    --c-overlay: rgba(0, 0, 0, 0.6);
    --c-border: #26262d;
    --c-border-strong: #35353e;
    --c-text: #ececf1;
    --c-text-2: #a3a3ae;
    --c-text-3: #6f6f7a;
    --c-accent: #7272ee;
    --c-accent-hover: #8282f3;
    --c-accent-active: #6262e2;
    --c-accent-fg: #ffffff;
    --c-accent-soft: rgba(124, 124, 240, 0.14);
    --c-accent-soft-2: rgba(124, 124, 240, 0.22);
    --c-accent-text: #a9a9ff;
    --c-danger: #e5484d;
    --c-danger-hover: #f05a5f;
    --c-danger-soft: rgba(229, 72, 77, 0.14);
    --c-danger-text: #ff9592;
    --c-warning: #f0a020;
    --c-warning-soft: rgba(240, 160, 32, 0.13);
    --c-warning-text: #ffc560;
    --c-success: #30a46c;
    --c-success-soft: rgba(48, 164, 108, 0.14);
    --c-success-text: #6fdba2;
    --c-info: #3e8bf6;
    --c-info-soft: rgba(62, 139, 246, 0.14);
    --c-info-text: #8ec0ff;
    --c-tooltip-bg: #2b2b32;
    --c-tooltip-fg: #f2f2f5;
    --c-skeleton: #1f1f25;
    --c-skeleton-shine: #2a2a31;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 6px 18px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-3: 0 22px 60px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --cat-none: #4a4a52;
    --cat-other: #8b857f;
    --tint-indigo: #8484f3;
    --tint-blue: #5b9bff;
    --tint-violet: #a78bfa;
    --tint-amber: #f5b23d;
    --tint-emerald: #34d399;
    --tint-teal: #2dd4bf;
    --tint-sky: #38bdf8;
    --tint-slate: #94a3b8;
    --tint-rose: #fb7185;
    --tint-pink: #f472b6;
    --tint-orange: #fb923c;
  }
}

/* ===================================================================== base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html.modal-open, html.palette-open { overflow: hidden; }
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
::selection { background: var(--c-accent-soft-2); }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.011em; line-height: 1.25; }
p { margin: 0; }
a { color: var(--c-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg, video, canvas { display: block; max-width: 100%; }
svg.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
code:not(pre code) { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-xs); padding: 1px 5px; }
pre { margin: 0; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-4) 0; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: var(--r-xs);
  background: var(--c-surface); color: var(--c-text-2);
  font-size: 11px; font-family: var(--font-sans); font-weight: 500; line-height: 1;
}
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: var(--r-xs); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -48px; z-index: 400; padding: 8px 12px; border-radius: var(--r);
  background: var(--c-accent); color: var(--c-accent-fg); font-weight: 600; transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }
.noscript { padding: 24px; text-align: center; color: var(--c-text-2); }
.clipboard-proxy { position: fixed; left: -9999px; top: 0; opacity: 0; }

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

@keyframes lw-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lw-pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes lw-slide-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes lw-slide-in-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes lw-spin { to { transform: rotate(360deg); } }
@keyframes lw-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes lw-indeterminate { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes lw-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ================================================================ utilities */
.row { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.row.gap-3 { gap: var(--s-3); }
.row.gap-4 { gap: var(--s-4); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.stack-xs { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.stack-md { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.spacer { flex: 1 1 auto; }
.muted { color: var(--c-text-2); }
.faint { color: var(--c-text-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.bold { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 0.93em; }
.nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.break { overflow-wrap: anywhere; }
.center { text-align: center; }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.danger-text { color: var(--c-danger-text); }
.success-text { color: var(--c-success-text); }
.warning-text { color: var(--c-warning-text); }
.accent-text { color: var(--c-accent-text); }
.hidden { display: none !important; }
.link-button {
  background: none; border: 0; padding: 0; color: var(--c-accent-text); font-weight: 500; cursor: pointer;
}
.link-button:hover { text-decoration: underline; text-underline-offset: 2px; }
.divider { height: 1px; background: var(--c-border); margin: var(--s-2) 0; }
.tint-indigo { --tint: var(--tint-indigo); } .tint-blue { --tint: var(--tint-blue); } .tint-violet { --tint: var(--tint-violet); }
.tint-amber { --tint: var(--tint-amber); } .tint-emerald { --tint: var(--tint-emerald); } .tint-teal { --tint: var(--tint-teal); }
.tint-sky { --tint: var(--tint-sky); } .tint-slate { --tint: var(--tint-slate); } .tint-rose { --tint: var(--tint-rose); }
.tint-pink { --tint: var(--tint-pink); } .tint-orange { --tint: var(--tint-orange); }

/* ================================================================== buttons */
.btn {
  --btn-bg: var(--c-surface); --btn-fg: var(--c-text); --btn-border: var(--c-border-strong); --btn-bg-hover: var(--c-surface-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--btn-border); border-radius: var(--r);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-base); font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; user-select: none; -webkit-user-select: none;
  box-shadow: var(--shadow-1);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur) var(--ease), transform 60ms var(--ease);
}
.btn:hover { background: var(--btn-bg-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--c-accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  --btn-bg: var(--c-accent); --btn-fg: var(--c-accent-fg); --btn-border: transparent; --btn-bg-hover: var(--c-accent-hover);
  box-shadow: var(--shadow-inset), 0 1px 2px rgba(40, 40, 120, 0.25);
}
.btn-primary:active:not(:disabled) { background: var(--c-accent-active); }
.btn-primary:focus-visible { border-color: transparent; box-shadow: var(--shadow-inset), var(--focus-ring); }
.btn-secondary { /* defaults */ }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--c-text-2); --btn-border: transparent; --btn-bg-hover: var(--c-surface-3); box-shadow: none; }
.btn-ghost:hover { color: var(--c-text); }
.btn-danger {
  --btn-bg: var(--c-danger); --btn-fg: #fff; --btn-border: transparent; --btn-bg-hover: var(--c-danger-hover);
  box-shadow: var(--shadow-inset), 0 1px 2px rgba(120, 20, 20, 0.25);
}
.btn-danger:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 30%, transparent); border-color: transparent; }
.btn-danger-ghost { --btn-bg: transparent; --btn-fg: var(--c-danger-text); --btn-border: transparent; --btn-bg-hover: var(--c-danger-soft); box-shadow: none; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 6px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-lg { width: 40px; }
.btn-block { display: flex; width: 100%; }
.btn-icon-right { margin-left: -2px; opacity: 0.7; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid var(--btn-fg); border-right-color: transparent; border-radius: 50%;
  animation: lw-spin 0.7s linear infinite; visibility: visible;
}
.btn-group { display: inline-flex; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* =================================================================== inputs */
.input, .select, .textarea {
  display: block; width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r);
  background: var(--c-surface); color: var(--c-text);
  font-size: var(--fs-base); line-height: 1.4;
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--c-border-strong) 60%, var(--c-text-3)); }
.input:focus, .select:focus, .textarea:focus, .input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--c-accent); box-shadow: var(--focus-ring);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--c-danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 25%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--c-surface-2); color: var(--c-text-2); cursor: not-allowed; }
.input[readonly] { cursor: text; }
.input-sm { height: 28px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.input.mono { font-family: var(--font-mono); font-size: 13px; }
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="number"].input { font-variant-numeric: tabular-nums; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input.has-icon { padding-left: 32px; }
.input-group .input.has-action { padding-right: 40px; }
.input-group .input-icon { position: absolute; left: 10px; color: var(--c-text-3); pointer-events: none; }
.input-group .input-action { position: absolute; right: 3px; }
.input-addon { display: flex; }
.input-addon > .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon > .select, .input-addon > .btn { width: auto; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; flex-shrink: 0; }

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--c-text); }
.field-req { color: var(--c-danger); margin-left: -2px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.label-extra { font-size: var(--fs-sm); }
.field-hint { font-size: var(--fs-sm); color: var(--c-text-2); }
.field-error { font-size: var(--fs-sm); color: var(--c-danger-text); font-weight: 500; }
.field-inline { grid-template-columns: 1fr auto; align-items: center; column-gap: var(--s-4); }
.field-inline > .field-error { grid-column: 1 / -1; }
.field-inline-text { display: grid; gap: 2px; min-width: 0; }

.checkbox, input[type="radio"].radio {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 16px; height: 16px; margin: 0; display: inline-grid; place-content: center;
  border: 1.5px solid var(--c-border-strong); border-radius: var(--r-xs); background: var(--c-surface);
  cursor: pointer; transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
input[type="radio"].radio { border-radius: 50%; }
.checkbox:hover { border-color: var(--c-accent); }
.checkbox:checked, .checkbox:indeterminate, .radio:checked { background-color: var(--c-accent); border-color: var(--c-accent); }
.checkbox:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 12px; background-position: center; background-repeat: no-repeat;
}
.checkbox:indeterminate {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  background-size: 12px; background-position: center; background-repeat: no-repeat;
}
.radio:checked { box-shadow: inset 0 0 0 3px var(--c-surface); }
.checkbox:focus-visible, .radio:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.checkbox:disabled { opacity: 0.5; cursor: not-allowed; }
.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 4px 0; }
.check-row .checkbox { margin-top: 2px; }
.check-row.is-disabled { opacity: 0.55; cursor: not-allowed; }
.check-text { display: grid; gap: 1px; }
.check-label { font-weight: 500; }
.check-hint { font-size: var(--fs-sm); color: var(--c-text-2); }

.switch { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; cursor: pointer; }
.switch-input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: relative; width: 36px; height: 20px; border-radius: var(--r-full);
  background: var(--c-border-strong); transition: background-color var(--dur) var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform var(--dur) var(--ease);
}
.switch-input:checked + .switch-track { background: var(--c-accent); }
.switch-input:checked + .switch-track::after { transform: translateX(16px); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus-ring); }
.switch.is-disabled { opacity: 0.5; cursor: not-allowed; }

.segmented {
  display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r);
  background: var(--c-surface-2); border: 1px solid var(--c-border);
}
.segment {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--c-text-2);
  font-size: var(--fs-sm); font-weight: 500; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segment:hover { color: var(--c-text); }
.segment.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-1), 0 0 0 1px var(--c-border); }
.segment:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.segmented-sm .segment { height: 24px; padding: 0 9px; }

/* ==================================================================== cards */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); min-width: 0;
}
/* The heading keeps at least ~12rem; when the actions do not fit beside it (narrow cards,
   phones) they wrap onto their own line, right-aligned, instead of crushing the title. */
.card-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-2) var(--s-3); padding: 16px 20px 0; }
.card-heading { display: grid; gap: 3px; min-width: 0; flex: 1 1 12rem; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); font-weight: 600; }
.card-title-icon { color: var(--c-text-3); }
.card-desc { color: var(--c-text-2); font-size: var(--fs-sm); }
.card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--s-2); flex: 0 1 auto; margin-left: auto; max-width: 100%; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 12px 0 0; }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); padding: 12px 20px;
  border-top: 1px solid var(--c-border); background: color-mix(in srgb, var(--c-surface-2) 55%, transparent);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.card-footer .card-footer-text { margin-right: auto; color: var(--c-text-2); font-size: var(--fs-sm); }
.card.danger-zone { border-color: color-mix(in srgb, var(--c-danger) 35%, var(--c-border)); }
.card-hover { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-hover:hover { border-color: var(--c-border-strong); box-shadow: var(--shadow-2); }

/* =================================================================== tables */
.table-wrap {
  overflow: auto; border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface);
  box-shadow: var(--shadow-1);
}
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.card-body.flush .table-wrap { border-top: 1px solid var(--c-border); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 0 12px; height: 36px; text-align: left; white-space: nowrap;
  background: var(--c-surface-2); color: var(--c-text-2); font-size: 12px; font-weight: 500;
  border-bottom: 1px solid var(--c-border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 80ms linear; }
.table tbody tr:hover { background: color-mix(in srgb, var(--c-surface-2) 70%, transparent); }
.table tbody tr.is-selected { background: var(--c-accent-soft); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.table .td-check { width: 40px; padding-right: 0; }
.table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.table .align-center { text-align: center; }
.table .empty-row td { padding: 0; }
.table .empty-row:hover { background: transparent; }
.table .skeleton-row td { padding: 14px 12px; }
.th-sort {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; margin: 0; height: 100%;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
.th-sort:hover, th.is-sorted .th-sort { color: var(--c-text); }
.th-sort-icon { display: inline-flex; opacity: 0.55; }
th.is-sorted .th-sort-icon { opacity: 1; }
.table-wrap.scroll-y { overflow-y: auto; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-title { font-weight: 500; color: var(--c-text); }
.cell-sub { color: var(--c-text-3); font-size: var(--fs-xs); }
.cell-stack { display: grid; gap: 1px; min-width: 0; }
.cell-actions { display: flex; justify-content: flex-end; gap: 2px; }

/* ============================================================ badges/chips */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; flex-shrink: 0;
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border);
}
.badge-accent { background: var(--c-accent-soft); color: var(--c-accent-text); border-color: transparent; }
.badge-success { background: var(--c-success-soft); color: var(--c-success-text); border-color: transparent; }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning-text); border-color: transparent; }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger-text); border-color: transparent; }
.badge-info { background: var(--c-info-soft); color: var(--c-info-text); border-color: transparent; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 4px 0 9px; max-width: 100%;
  border-radius: var(--r-full); border: 1px solid var(--c-border); background: var(--c-surface-2);
  font-size: var(--fs-sm); color: var(--c-text);
}
.chip:not(:has(.chip-x)) { padding-right: 9px; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-accent { background: var(--c-accent-soft); border-color: transparent; color: var(--c-accent-text); }
.chip-x {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--c-text-3);
}
.chip-x:hover { background: var(--c-surface-3); color: var(--c-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===================================================================== tabs */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
/* More tabs off to one side (the scrollbar is hidden): fade that edge. */
.tabs.fade-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.tabs.fade-start { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
.tabs.fade-start.fade-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 0 10px; height: 36px; border: 0; background: none;
  color: var(--c-text-2); font-size: var(--fs-base); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--c-text); text-decoration: none; }
.tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.tab .icon { opacity: 0.8; }
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); display: inline-grid; place-items: center;
  background: var(--c-surface-3); color: var(--c-text-2); font-size: 11px;
}
.tabs-underline { border-bottom: 1px solid var(--c-border); }
.tabs-underline .tab { border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 0; }
.tabs-underline .tab.is-active { color: var(--c-text); border-bottom-color: var(--c-accent); }
.tabs-pills .tab { height: 30px; border-radius: var(--r-sm); }
.tabs-pills .tab.is-active { background: var(--c-surface-3); color: var(--c-text); }
.tabs-vertical { flex-direction: column; gap: 2px; overflow: visible; }
.tabs-vertical .tab { height: 34px; border-radius: var(--r); width: 100%; padding: 0 10px; }
.tabs-vertical .tab:hover { background: var(--c-surface-2); }
.tabs-vertical .tab.is-active { background: var(--c-accent-soft); color: var(--c-accent-text); }
.tabs-vertical .tab.is-active .icon { opacity: 1; }

/* ============================================================ modal/drawer */
.modal-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: max(16px, 9vh) 16px 16px; overflow-y: auto;
  background: var(--c-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: lw-fade-in 140ms var(--ease);
}
.modal-backdrop.is-leaving, .drawer-backdrop.is-leaving { animation: lw-fade-in 120ms var(--ease) reverse forwards; }
.modal {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 500px; max-height: calc(100dvh - 32px);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); animation: lw-pop-in 180ms var(--ease);
}
.modal:focus { outline: none; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 980px; }
.modal-header { display: flex; align-items: flex-start; gap: var(--s-3); padding: 18px 20px 4px; }
.modal-heading { flex: 1; min-width: 0; display: grid; gap: 4px; }
.modal-title { font-size: var(--fs-lg); font-weight: 600; }
.modal-desc { color: var(--c-text-2); font-size: 13px; }
.modal-close { margin: -4px -6px 0 0; }
.modal-form { display: contents; }
.modal-body { padding: 12px 20px 16px; overflow-y: auto; min-height: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-2); padding: 12px 20px 18px; flex-wrap: wrap; }
.confirm-msg { color: var(--c-text-2); }
.drawer-backdrop { justify-content: flex-end; align-items: stretch; padding: 0; }
.drawer {
  display: flex; flex-direction: column; width: min(460px, 100vw); height: 100%;
  background: var(--c-surface); border-left: 1px solid var(--c-border); box-shadow: var(--shadow-3);
  animation: lw-slide-in-right 220ms var(--ease);
}
.drawer.modal-lg { width: min(640px, 100vw); }
.drawer .modal-header { padding: 18px 20px 12px; border-bottom: 1px solid var(--c-border); }
.drawer .modal-body { flex: 1; padding: 16px 20px; }
.drawer .modal-footer { border-top: 1px solid var(--c-border); padding: 12px 20px; }

/* =================================================================== toasts */
.toast-region {
  position: fixed; right: 16px; bottom: calc(16px + var(--tray-offset)); z-index: 300;
  display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none;
  transition: bottom 200ms var(--ease);
}
.toast {
  pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px;
  padding: 12px 8px 12px 14px; border-radius: var(--r-lg);
  background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: var(--shadow-3);
  animation: lw-slide-up 200ms var(--ease);
}
.toast.is-leaving { animation: lw-fade-in 160ms var(--ease) reverse forwards; }
.toast-icon { margin-top: 1px; }
.toast-info .toast-icon { color: var(--c-accent); }
.toast-success .toast-icon { color: var(--c-success); }
.toast-error .toast-icon { color: var(--c-danger); }
.toast-warning .toast-icon { color: var(--c-warning); }
.toast-content { min-width: 0; padding-top: 1px; }
.toast-title { font-weight: 500; overflow-wrap: anywhere; }
.toast-desc { color: var(--c-text-2); font-size: var(--fs-sm); margin-top: 2px; }
.toast-actions { display: flex; align-items: center; gap: 2px; margin-top: -4px; }

/* ==================================================================== menus */
.menu {
  position: fixed; z-index: 150; min-width: 200px; max-width: 320px; max-height: calc(100dvh - 16px); overflow-y: auto;
  padding: 4px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); animation: lw-pop-in 110ms var(--ease);
}
.menu:focus { outline: none; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 32px; padding: 0 8px;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--c-text);
  font-size: 13px; text-align: left; white-space: nowrap; cursor: pointer;
}
.menu-item:hover, .menu-item:focus { background: var(--c-surface-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 1px var(--c-border-strong); }
.menu-item.danger { color: var(--c-danger-text); }
.menu-item.danger:hover, .menu-item.danger:focus { background: var(--c-danger-soft); }
.menu-item[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.menu-icon { width: 16px; display: inline-flex; color: var(--c-text-3); flex-shrink: 0; }
.menu-item.danger .menu-icon { color: currentColor; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-shortcut { margin-left: auto; }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--c-border); }
.menu-heading { padding: 7px 8px 5px; color: var(--c-text-3); font-size: var(--fs-xs); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================= tooltips */
.tooltip {
  position: fixed; z-index: 500; max-width: 280px; padding: 5px 8px; border-radius: var(--r-sm);
  background: var(--c-tooltip-bg); color: var(--c-tooltip-fg); font-size: 12px; font-weight: 500; line-height: 1.35;
  pointer-events: none; box-shadow: var(--shadow-2); animation: lw-fade-in 100ms var(--ease);
}

/* ============================================================== progress */
.progress { position: relative; width: 100%; height: 6px; border-radius: var(--r-full); background: var(--c-surface-3); overflow: hidden; }
.progress-sm { height: 4px; }
.progress-lg { height: 10px; }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: var(--c-accent); transition: width 300ms var(--ease), background-color var(--dur); }
.progress-success .progress-bar { background: var(--c-success); }
.progress-warning .progress-bar { background: var(--c-warning); }
.progress-danger .progress-bar { background: var(--c-danger); }
.progress-neutral .progress-bar { background: var(--c-text-3); }
.progress.indeterminate .progress-bar { width: 38%; animation: lw-indeterminate 1.2s var(--ease) infinite; }

/* =========================================================== empty/loading */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
.empty-compact { padding: 28px 16px; }
.empty-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border-radius: var(--r-lg);
  background: var(--c-surface-2); color: var(--c-text-3); border: 1px solid var(--c-border);
}
.empty-compact .empty-icon { width: 38px; height: 38px; }
.empty-title { font-weight: 600; font-size: var(--fs-md); }
.empty-msg { color: var(--c-text-2); max-width: 420px; }
.empty-action { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.loading-block { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 64px 16px; color: var(--c-text-3); animation: lw-fade-in 200ms var(--ease); }
.spinner {
  display: inline-block; width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  color: var(--c-text-3); animation: lw-spin 0.7s linear infinite;
}
.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg { width: 28px; height: 28px; border-width: 2.5px; }
.skeleton {
  display: block; height: 12px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--c-skeleton) 0%, var(--c-skeleton-shine) 50%, var(--c-skeleton) 100%);
  background-size: 200% 100%; animation: lw-shimmer 1.4s linear infinite;
}
.skeleton-text { width: 70%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-lines { display: grid; gap: 10px; }
.skeleton-card { padding: 16px; }
.infinite-sentinel { display: flex; justify-content: center; align-items: center; min-height: 40px; padding: 8px; }
.infinite-sentinel.is-done { min-height: 0; padding: 0; }

/* ============================================================ misc widgets */
.avatar {
  --size: 28px;
  display: inline-grid; place-items: center; flex-shrink: 0; width: var(--size); height: var(--size); border-radius: 50%;
  background: hsl(var(--hue, 240) 60% 90%); color: hsl(var(--hue, 240) 45% 32%);
  font-size: calc(var(--size) * 0.38); font-weight: 600; letter-spacing: 0.02em; user-select: none;
}
:root[data-theme="dark"] .avatar { background: hsl(var(--hue, 240) 32% 24%); color: hsl(var(--hue, 240) 70% 84%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar { background: hsl(var(--hue, 240) 32% 24%); color: hsl(var(--hue, 240) 70% 84%); }
}
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.crumb {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border-radius: var(--r-sm);
  color: var(--c-text-2); background: none; border: 0; font: inherit; max-width: 240px;
}
.crumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.crumb:hover, button.crumb:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.crumb.current { color: var(--c-text); font-weight: 500; }
.crumb-sep { color: var(--c-text-3); }
.split { display: grid; grid-template-columns: var(--split, 280px) 1px minmax(0, 1fr); height: 100%; min-height: 0; }
.split-start, .split-end { min-width: 0; min-height: 0; overflow: auto; }
.split-handle { position: relative; background: var(--c-border); cursor: col-resize; touch-action: none; }
.split-handle::after { content: ""; position: absolute; inset: 0 -4px; }
.split-handle:hover, .split-handle:focus-visible, .split.is-resizing .split-handle { background: var(--c-accent); outline: none; }
.split.is-resizing { user-select: none; cursor: col-resize; }
.kbd-group { display: inline-flex; gap: 3px; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 10px 24px; margin: 0; font-size: 13px; }
.kv dt { color: var(--c-text-2); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r-md);
  border: 1px solid var(--c-border); background: var(--c-surface-2); font-size: 13px;
}
.alert-icon { margin-top: 1px; flex-shrink: 0; }
.alert-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.alert-title { font-weight: 600; }
.alert-text { color: var(--c-text-2); }
.alert-actions { display: flex; gap: 6px; align-self: center; }
.alert-info { background: var(--c-accent-soft); border-color: color-mix(in srgb, var(--c-accent) 22%, transparent); }
.alert-info .alert-icon { color: var(--c-accent-text); }
.alert-success { background: var(--c-success-soft); border-color: color-mix(in srgb, var(--c-success) 25%, transparent); }
.alert-success .alert-icon { color: var(--c-success-text); }
.alert-warning { background: var(--c-warning-soft); border-color: color-mix(in srgb, var(--c-warning) 28%, transparent); }
.alert-warning .alert-icon { color: var(--c-warning-text); }
.alert-danger { background: var(--c-danger-soft); border-color: color-mix(in srgb, var(--c-danger) 28%, transparent); }
.alert-danger .alert-icon, .alert-danger .alert-title { color: var(--c-danger-text); }

.secret-box {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: var(--r);
  background: var(--c-surface-2); border: 1px dashed var(--c-border-strong);
  font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere;
}
.secret-box .secret-text { flex: 1; min-width: 0; user-select: all; }
.secret-box.accent { border-color: color-mix(in srgb, var(--c-accent) 55%, transparent); background: var(--c-accent-soft); }

/* =========================================================== logo / brand */
.logo-mark .logo-bg { fill: var(--c-accent); }
.logo-mark .logo-fg { fill: #fff; opacity: 0.95; }
.logo-mark .logo-dot { fill: #fff; opacity: 0.6; }

/* ==================================================================== shell */
#app.boot { min-height: 100dvh; }
.boot-splash { position: fixed; inset: 0; display: grid; place-items: center; }
.boot-splash-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--c-accent); animation: lw-pulse 1.4s ease-in-out infinite; box-shadow: var(--shadow-2); }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.shell.sidebar-collapsed { --sidebar-w: 64px; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; z-index: 40;
  display: flex; flex-direction: column; gap: 2px; padding: 12px 10px;
  background: var(--c-sidebar); border-right: 1px solid var(--c-border); overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px; margin-bottom: 10px;
  color: var(--c-text); text-decoration: none; border-radius: var(--r);
}
.sidebar-brand:hover { text-decoration: none; background: var(--c-surface-3); }
.sidebar-brand-text { display: grid; min-width: 0; }
.sidebar-brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section-label { padding: 14px 10px 5px; color: var(--c-text-3); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 34px; padding: 0 10px; width: 100%;
  border: 0; border-radius: var(--r); background: none; color: var(--c-text-2);
  font-size: var(--fs-base); font-weight: 500; text-decoration: none; white-space: nowrap; text-align: left;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav-icon { color: var(--c-text-3); transition: color var(--dur) var(--ease); }
.nav-item:hover .nav-icon { color: var(--c-text-2); }
.nav-item[aria-current="page"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-1), 0 0 0 1px var(--c-border); }
.nav-item[aria-current="page"] .nav-icon { color: var(--tint, var(--c-accent)); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { margin-top: auto; padding-top: 12px; display: grid; gap: 4px; }
.sidebar-version { padding: 0 10px; font-size: 11px; color: var(--c-text-3); white-space: nowrap; }
.shell.sidebar-collapsed .sidebar { padding: 12px 10px; }
.shell.sidebar-collapsed .nav-label, .shell.sidebar-collapsed .sidebar-brand-text, .shell.sidebar-collapsed .sidebar-version { display: none; }
.shell.sidebar-collapsed .nav-section-label { height: 1px; padding: 0; margin: 10px 8px; background: var(--c-border); font-size: 0; }
.shell.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
.shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.nav-backdrop { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px 0 24px;
  background: color-mix(in srgb, var(--c-bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--c-border);
}
.topbar-title { font-size: 15px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.topbar-actions:empty { display: none; }
.topbar-search { position: relative; margin-left: auto; width: min(300px, 32vw); }
.topbar-search-input { height: 32px; padding-left: 32px; padding-right: 54px; background: var(--c-surface); box-shadow: none; }
.topbar-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--c-text-3); pointer-events: none; }
.topbar-search-kbd { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.topbar-search-input:focus + .topbar-search-kbd, .topbar-search.is-app-search .topbar-search-kbd { display: none; }
.topbar-search.is-app-search .topbar-search-input { padding-right: 10px; }
.topbar-search-btn { display: none; margin-left: auto; }
.nav-toggle { display: none; margin-left: -8px; }
.user-button {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; margin-left: 2px;
  border: 0; border-radius: 50%; background: none;
}
.user-button:hover .avatar { box-shadow: 0 0 0 2px var(--c-border-strong); }
.user-button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.view { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.view:focus { outline: none; }
.view.view-full { padding: 0; height: calc(100dvh - var(--topbar-h) - var(--dock-h, 0px)); overflow: hidden; display: flex; flex-direction: column; }
/* Persistent bottom dock (music player): sticks to the viewport bottom; apps size it with --dock-h. */
.dock { position: sticky; bottom: 0; z-index: 40; }
.dock[hidden] { display: none; }
.shell.has-dock { --dock-h: 72px; }
.view.view-full > .app-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app-root { min-width: 0; animation: lw-fade-in 160ms var(--ease); }

.page { width: 100%; max-width: 1120px; margin: 0 auto; }
.page.narrow { max-width: 780px; }
.page.wide { max-width: 1440px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-heading { display: grid; gap: 4px; min-width: 0; }
.page-title { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; }
.page-subtitle { color: var(--c-text-2); font-size: var(--fs-md); }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.section { display: grid; gap: var(--s-3); }
.section + .section { margin-top: var(--s-8); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.section-title { font-size: var(--fs-md); font-weight: 600; }
.section-desc { color: var(--c-text-2); font-size: 13px; }

/* ============================================================ auth layout */
.auth-root { min-height: 100dvh; }
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: 40px 16px;
  background:
    radial-gradient(1200px 520px at 50% -180px, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 70%),
    var(--c-bg);
}
.auth-card {
  width: 100%; max-width: 408px; padding: 32px 28px 28px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 18px; box-shadow: var(--shadow-2);
  animation: lw-pop-in 220ms var(--ease);
}
.auth-card.wide { max-width: 540px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-title { font-size: var(--fs-xl); font-weight: 650; text-align: center; letter-spacing: -0.02em; }
.auth-subtitle { margin-top: 6px; color: var(--c-text-2); text-align: center; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-actions { display: grid; gap: 10px; margin-top: 20px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.auth-footer { text-align: center; color: var(--c-text-2); font-size: 13px; }
.auth-meta { display: flex; align-items: center; gap: 8px; color: var(--c-text-3); font-size: 12px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--c-text-3); font-size: 12px; margin: 4px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }
.auth-icon {
  display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--c-accent-soft); color: var(--c-accent-text);
}
.auth-icon.success { background: var(--c-success-soft); color: var(--c-success-text); }
.auth-icon.danger { background: var(--c-danger-soft); color: var(--c-danger-text); }
.otp-input { text-align: center; font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.4em; height: 48px; padding-left: calc(10px + 0.4em); }

.steps { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 4px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 7px; color: var(--c-text-3); font-size: 12.5px; font-weight: 500; }
.step-num {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--c-border-strong); font-size: 11.5px; font-weight: 600; background: var(--c-surface);
}
.step.is-active { color: var(--c-text); }
.step.is-active .step-num { border-color: var(--c-accent); background: var(--c-accent); color: #fff; }
.step.is-done { color: var(--c-text-2); }
.step.is-done .step-num { border-color: var(--c-success); background: var(--c-success-soft); color: var(--c-success-text); }
.step-line { width: 22px; height: 1.5px; background: var(--c-border-strong); }
.fingerprint-box { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r-md); background: var(--c-surface-2); border: 1px solid var(--c-border); }
.fingerprint-value { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6; color: var(--c-text); overflow-wrap: anywhere; letter-spacing: 0.02em; }

.strength { display: grid; gap: 6px; }
.strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-seg { height: 4px; border-radius: 2px; background: var(--c-surface-3); transition: background-color 200ms var(--ease); }
.strength-text { display: flex; gap: 8px; justify-content: space-between; font-size: 12px; min-height: 18px; }
.strength-label { font-weight: 600; color: var(--c-text-2); }
.strength-tip { color: var(--c-text-3); text-align: right; }
.strength[data-score="0"] .strength-seg:nth-child(-n+1) { background: var(--c-danger); }
.strength[data-score="1"] .strength-seg:nth-child(-n+1) { background: var(--c-danger); }
.strength[data-score="1"] .strength-seg:nth-child(2) { background: var(--c-warning); }
.strength[data-score="2"] .strength-seg:nth-child(-n+2) { background: var(--c-warning); }
.strength[data-score="3"] .strength-seg:nth-child(-n+3) { background: var(--c-success); }
.strength[data-score="4"] .strength-seg { background: var(--c-success); }
.strength[data-score="0"] .strength-label, .strength[data-score="1"] .strength-label { color: var(--c-danger-text); }
.strength[data-score="2"] .strength-label { color: var(--c-warning-text); }
.strength[data-score="3"] .strength-label, .strength[data-score="4"] .strength-label { color: var(--c-success-text); }

.notfound { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 10vh 16px; }
.notfound-code {
  font-size: 88px; font-weight: 750; letter-spacing: -0.05em; line-height: 1;
  background: linear-gradient(135deg, var(--c-accent), var(--tint-violet) 60%, var(--tint-rose));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.notfound-title { font-size: var(--fs-xl); font-weight: 650; }
.notfound-msg { color: var(--c-text-2); max-width: 420px; }
.notfound .row { margin-top: 12px; }

/* ======================================================== command palette */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 120; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; background: var(--c-overlay); animation: lw-fade-in 120ms var(--ease);
}
.palette {
  display: flex; flex-direction: column; width: min(640px, 100%); max-height: min(560px, 76vh);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px; box-shadow: var(--shadow-3);
  overflow: hidden; animation: lw-pop-in 160ms var(--ease);
}
.palette-input-row { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px; border-bottom: 1px solid var(--c-border); }
.palette-search-icon { color: var(--c-text-3); }
.palette-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 15.5px; color: var(--c-text); }
.palette-input:focus { outline: none; }
.palette-input::placeholder { color: var(--c-text-3); }
.palette-list { flex: 1; overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; color: var(--c-text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.palette-item { display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 10px; border-radius: var(--r); cursor: pointer; font-size: 13.5px; }
.palette-item.is-active { background: var(--c-accent-soft); }
.palette-item-icon { display: inline-flex; color: var(--c-text-3); }
.palette-item.is-active .palette-item-icon { color: var(--c-accent-text); }
.palette-item-title { flex: 0 1 auto; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-sub { flex: 1 1 auto; min-width: 0; color: var(--c-text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-kbd { margin-left: auto; }
.palette-empty { padding: 32px 16px; text-align: center; color: var(--c-text-3); }
.palette-footer { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--c-border); color: var(--c-text-3); font-size: 11.5px; }
.palette-footer span { display: inline-flex; align-items: center; gap: 4px; }
.palette-footer kbd { height: 18px; min-width: 18px; font-size: 10.5px; }

.shortcut-groups { display: grid; gap: 20px; }
.shortcut-group-title { font-size: 12px; font-weight: 600; color: var(--c-text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.shortcut-list { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
.shortcut-list dt { color: var(--c-text); }
.shortcut-list dd { margin: 0; text-align: right; }

/* ============================================================ upload tray */
.upload-tray {
  position: fixed; right: 16px; bottom: 16px; z-index: 90; width: min(380px, calc(100vw - 32px));
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  overflow: hidden; animation: lw-slide-up 200ms var(--ease);
}
.upload-tray-header { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 14px; }
.upload-tray-icon { color: var(--c-accent-text); }
.upload-tray-heading { flex: 1; min-width: 0; display: grid; }
.upload-tray-title { font-weight: 600; font-size: 13px; }
.upload-tray-summary { color: var(--c-text-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.upload-tray > .progress { border-radius: 0; }
.upload-list { max-height: min(340px, 50vh); overflow-y: auto; border-top: 1px solid var(--c-border); }
.upload-tray.is-collapsed .upload-list { display: none; }
.upload-item { display: grid; gap: 6px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--c-border); }
.upload-item:last-child { border-bottom: 0; }
.upload-item-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.upload-file-icon { color: var(--c-text-3); }
.upload-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-actions { display: flex; gap: 2px; }
.upload-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--c-text-2); font-variant-numeric: tabular-nums; }
.upload-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta-right { flex-shrink: 0; }
.upload-item.is-error .upload-status { color: var(--c-danger-text); }
.upload-item.is-completed .upload-status { color: var(--c-success-text); }

/* ============================================================== placeholder */
.placeholder { max-width: 560px; margin: 6vh auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.placeholder-art {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 20px; margin-bottom: 6px;
  color: var(--tint); background: color-mix(in srgb, var(--tint) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 22%, transparent);
}
.placeholder-title { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; }
.placeholder-tagline { color: var(--c-text-2); font-size: var(--fs-md); max-width: 460px; }
.placeholder-features { list-style: none; margin: 14px 0 6px; padding: 16px 20px; display: grid; gap: 9px; text-align: left; width: 100%; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); }
.placeholder-features li { display: flex; gap: 10px; align-items: flex-start; }
.placeholder-check { color: var(--c-success); margin-top: 3px; }
.placeholder-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* ===================================================================== home */
.home-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.home-greeting { font-size: var(--fs-3xl); font-weight: 680; letter-spacing: -0.03em; }
.home-sub { color: var(--c-text-2); font-size: var(--fs-md); margin-top: 4px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 128px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  color: var(--c-text); text-decoration: none; box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tile:hover { text-decoration: none; border-color: color-mix(in srgb, var(--tint) 40%, var(--c-border)); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.tile:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--c-accent); }
.tile-icon {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  color: var(--tint); background: color-mix(in srgb, var(--tint) 13%, transparent);
}
.tile-title { font-weight: 600; font-size: var(--fs-md); }
.tile-desc { color: var(--c-text-2); font-size: var(--fs-sm); margin-top: 2px; }
.tile-arrow { margin-left: auto; color: var(--c-text-3); opacity: 0; transition: opacity var(--dur), transform var(--dur); }
.tile:hover .tile-arrow { opacity: 1; transform: translateX(2px); }
.tile-top { display: flex; align-items: center; }
.stat { display: grid; gap: 2px; }
.stat-label { font-size: 12px; color: var(--c-text-2); font-weight: 500; }
.stat-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--c-text-3); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-card { padding: 16px; }
.connect-list { display: grid; gap: 10px; }
.connect-item { display: flex; align-items: center; gap: 12px; }
.connect-item-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--c-surface-2); color: var(--c-text-2); flex-shrink: 0; }

/* ============================================================== storage */
.stacked-bar { display: flex; width: 100%; height: 10px; border-radius: var(--r-full); background: var(--c-surface-3); overflow: hidden; gap: 1.5px; }
.stacked-seg { height: 100%; min-width: 2px; }
.stacked-seg:first-child { border-radius: var(--r-full) 0 0 var(--r-full); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; min-width: 0; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { margin-left: auto; color: var(--c-text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.donut-layout { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut-layout .legend { flex: 1; min-width: 200px; }
.donut-wrap-inner { position: relative; width: max-content; flex-shrink: 0; }
.donut-track { stroke: var(--c-surface-3); }
.donut-seg { transition: stroke-width var(--dur); }
.donut-seg:hover { stroke-width: 22; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-value { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut-label { font-size: 11.5px; color: var(--c-text-3); }
.usage-summary { display: grid; gap: 10px; }
.usage-numbers { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.usage-big { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.usage-of { color: var(--c-text-2); font-size: 13px; }
.volume { display: grid; gap: 10px; padding: 16px; }
.volume-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.volume-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--c-surface-2); color: var(--c-text-2); flex-shrink: 0; }
.volume-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.volume-path { font-family: var(--font-mono); font-size: 11.5px; color: var(--c-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.volume-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--c-text-2); font-variant-numeric: tabular-nums; gap: 8px; flex-wrap: wrap; }
.volume.is-warning { border-color: color-mix(in srgb, var(--c-warning) 45%, var(--c-border)); }
.volume.is-danger { border-color: color-mix(in srgb, var(--c-danger) 50%, var(--c-border)); }
.mini-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.mini-bar .progress { flex: 1; }
.mini-bar span { font-size: 11.5px; color: var(--c-text-2); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* ========================================================== settings/admin */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 36px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 24px); }
.settings-content { min-width: 0; display: grid; gap: 20px; }
.settings-section-header { display: grid; gap: 4px; margin-bottom: 4px; }
.settings-section-title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.015em; }
.settings-section-desc { color: var(--c-text-2); }
.form-grid { display: grid; gap: 16px; align-items: start; }
.field { align-content: start; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.setting-rows { display: grid; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.setting-row:first-child { padding-top: 0; }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row-text { display: grid; gap: 2px; min-width: 0; }
.setting-rows > .field-inline { padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.setting-rows > .field-inline:first-child { padding-top: 0; }
.setting-rows > .field-inline:last-child { border-bottom: 0; padding-bottom: 0; }
.field-inline .field-label { font-weight: 500; }
.nowrap { white-space: nowrap; }
.setting-label { font-weight: 500; }
.setting-desc { color: var(--c-text-2); font-size: var(--fs-sm); }
.save-bar {
  position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 10px; margin-top: 4px;
  padding: 10px 10px 10px 16px; border-radius: var(--r-lg);
  background: var(--c-surface); border: 1px solid var(--c-border-strong); box-shadow: var(--shadow-3);
  animation: lw-slide-up 180ms var(--ease);
}
.save-bar-msg { flex: 1; font-size: 13px; color: var(--c-text-2); display: flex; align-items: center; gap: 8px; }
.save-bar-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-warning); flex-shrink: 0; }
.secret-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secret-field .input-group { flex: 1; min-width: 200px; }
.list-editor { display: grid; gap: 8px; }
.list-editor-row { display: flex; gap: 8px; }
.list-editor-row .input { flex: 1; }
.qr-box { display: inline-grid; padding: 10px; background: #fff; border-radius: var(--r-lg); border: 1px solid var(--c-border); box-shadow: var(--shadow-1); }
.qr-box svg { width: 196px; height: 196px; }
.totp-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: start; }
.totp-steps { display: grid; gap: 14px; counter-reset: totp; }
.totp-step { display: grid; gap: 6px; }
.totp-step-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.totp-step-title::before {
  counter-increment: totp; content: counter(totp);
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--c-accent-soft); color: var(--c-accent-text); font-size: 11.5px; font-weight: 700;
}
.recovery-codes { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.recovery-codes li { font-family: var(--font-mono); font-size: 13.5px; text-align: center; padding: 6px 8px; border-radius: var(--r-sm); background: var(--c-surface); border: 1px solid var(--c-border); letter-spacing: 0.04em; user-select: all; }
.session-icon, .token-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--c-surface-2); color: var(--c-text-2); flex-shrink: 0; }
.scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; padding: 12px 14px; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-2); }
.scope-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card {
  display: grid; gap: 10px; padding: 10px; border-radius: var(--r-lg); border: 1.5px solid var(--c-border);
  background: var(--c-surface); text-align: left; cursor: pointer; color: var(--c-text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.theme-card:hover { border-color: var(--c-border-strong); }
.theme-card[aria-checked="true"] { border-color: var(--c-accent); box-shadow: var(--focus-ring); }
.theme-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.theme-card-label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; }
.theme-preview { height: 78px; border-radius: var(--r); overflow: hidden; display: grid; grid-template-columns: 28% 1fr; border: 1px solid rgba(127, 127, 140, 0.25); }
.theme-preview.light { background: #fbfbfc; } .theme-preview.light .tp-side { background: #f1f1f4; } .theme-preview.light .tp-line { background: #dedee6; } .theme-preview.light .tp-accent { background: #5b5bd6; }
.theme-preview.dark { background: #151518; } .theme-preview.dark .tp-side { background: #0e0e11; } .theme-preview.dark .tp-line { background: #2c2c34; } .theme-preview.dark .tp-accent { background: #7272ee; }
.theme-preview.system { background: linear-gradient(135deg, #fbfbfc 50%, #151518 50%); }
.theme-preview.system .tp-side { background: linear-gradient(135deg, #f1f1f4 50%, #0e0e11 50%); }
.theme-preview.system .tp-line { background: #8a8a95; } .theme-preview.system .tp-accent { background: #6767e2; }
.tp-main { padding: 10px; display: grid; gap: 6px; align-content: start; }
.tp-line { height: 6px; border-radius: 3px; }
.tp-line.short { width: 55%; }
.tp-accent { height: 12px; width: 40%; border-radius: 4px; }
.member-list { display: grid; gap: 6px; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: center; }
.member-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-results { display: grid; gap: 2px; max-height: 200px; overflow-y: auto; margin-top: 6px; }
.picker-result { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); border: 0; background: none; text-align: left; cursor: pointer; color: var(--c-text); }
.picker-result:hover, .picker-result:focus-visible { background: var(--c-surface-2); outline: none; }
.cat-list { display: grid; gap: 12px; }
.cat-card { padding: 14px 16px; display: grid; gap: 12px; }
.cat-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 150px auto; gap: 8px; align-items: center; }
.cat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--c-surface-2); color: var(--c-text-2); }
.sub-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sub-add { display: flex; gap: 6px; }
.sub-add .input { width: 180px; }
.audit-meta { margin: 0; padding: 10px 12px; max-height: 240px; overflow: auto; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input-group { width: min(320px, 100%); }
.toolbar > .stack-xs { flex: 1 1 280px; }
.toolbar .select { width: auto; min-width: 140px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.pager-label { color: var(--c-text-2); font-size: 12.5px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.test-result { display: grid; gap: 8px; margin-top: 4px; }

/* ============================================================== responsive */
@media (max-width: 1080px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1120px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { position: static; }
  .settings-nav .tabs-vertical { flex-direction: row; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--c-border); padding-bottom: 6px; }
  .settings-nav .tabs-vertical .tab { width: auto; }
}
@media (max-width: 900px) {
  .cat-head { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .cat-head .cat-name, .cat-head .cat-iconsel { grid-column: 2 / -1; }
}
@media (max-width: 860px) {
  .shell, .shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); --sidebar-w: 272px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px; height: 100dvh;
    transform: translateX(-102%); transition: transform 220ms var(--ease); box-shadow: none;
  }
  .shell.sidebar-collapsed .nav-label, .shell.sidebar-collapsed .sidebar-brand-text, .shell.sidebar-collapsed .sidebar-version { display: initial; }
  .shell.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; }
  .shell.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 6px; }
  .shell.sidebar-collapsed .nav-section-label { height: auto; padding: 14px 10px 5px; margin: 0; background: none; font-size: 11px; }
  .nav-collapse { display: none; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 35; background: var(--c-overlay); }
  .shell.nav-open .nav-backdrop { display: block; animation: lw-fade-in 160ms var(--ease); }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 10px 0 16px; gap: 6px; }
  .view { padding: 20px 16px 56px; }
}
@media (max-width: 680px) {
  .topbar-search { display: none; }
  .topbar-search-btn { display: inline-flex; }
  .topbar.search-expanded .topbar-search {
    display: block; position: absolute; left: 8px; right: 8px; top: 50%; transform: translateY(-50%); width: auto; margin: 0; z-index: 2;
  }
  .topbar.search-expanded .topbar-search-input { height: 38px; box-shadow: var(--shadow-2); }
  .form-grid.cols-2, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .totp-setup { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .theme-cards { grid-template-columns: minmax(0, 1fr); }
  .scope-grid { grid-template-columns: minmax(0, 1fr); }
  .member-row { grid-template-columns: minmax(0, 1fr) 100px auto; }
  .page-title { font-size: var(--fs-xl); }
  .home-greeting { font-size: var(--fs-2xl); }
  .hide-sm { display: none; }
  .auth-card { padding: 26px 20px 22px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { max-height: calc(100dvh - 24px); }
  .setting-row { flex-wrap: wrap; }
  .cat-head { grid-template-columns: minmax(0, 1fr) auto; }
  .cat-head .cat-icon { display: none; }
  .cat-head .cat-name, .cat-head .cat-iconsel { grid-column: 1 / -1; }
  .sub-add .input { width: 100%; }
}
@media (max-width: 960px) {
  .hide-md { display: none; }
}
@media (max-width: 480px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { min-height: 0; padding: 12px; gap: 8px; }
  .tile-desc { display: none; }
  .quick-actions .btn:not(.btn-icon) { flex: 1 1 auto; }
  .quick-actions .btn-icon { display: none; }
}
@media (max-width: 400px) {
  .recovery-codes { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .sidebar, .topbar, .upload-tray, .toast-region { display: none !important; }
  .shell { display: block; }
}
