/* =============================================================
   cyseo — themeable design tokens. Each theme is one ruleset on
   :root[data-theme="…"]. The "dark" theme below is the default and
   defines every token; lighter themes only override what differs.
   Components reference --surface-* tokens (recipe-based), not raw
   colours, so a theme swap doesn't require touching components.
   ============================================================= */

:root, :root[data-theme="dark"] {
  /* warm-dark palette (Raycast-style) */
  --bg-0: #0e0e10;          /* deepest, page canvas */
  --bg-1: #16161a;           /* primary surface */
  --bg-2: #1c1c21;           /* elevated surface */
  --bg-3: #23232a;           /* hover / focus tint */
  --bg-4: #2c2c34;           /* pressed */

  --line-1: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --line-3: rgba(255, 255, 255, 0.16);

  --fg-0: #fafafb;            /* primary text */
  --fg-1: #c8c8d0;            /* secondary text */
  --fg-2: #8a8a92;            /* tertiary, captions */
  --fg-3: #5b5b62;            /* disabled / placeholder */

  /* accents (used sparingly) */
  --accent: #ff6363;           /* Raycast red */
  --accent-2: #8b5cf6;         /* violet for variety */
  --accent-3: #38bdf8;         /* sky for info */
  --accent-fg: #ffffff;        /* foreground on accent surfaces */

  /* status */
  --ok:   #4ade80;
  --warn: #fbbf24;
  --bad:  #f87171;

  /* extension-tag colour swatch (used for tiny icon tiles) */
  --tag-rose:    #ff6363;
  --tag-amber:   #f9a826;
  --tag-lemon:   #c6d530;
  --tag-mint:    #4ade80;
  --tag-sky:     #38bdf8;
  --tag-indigo:  #818cf8;
  --tag-violet:  #a78bfa;
  --tag-pink:    #f472b6;

  /* glass surface recipe — every theme defines these the same way. */
  --surface-bg:          rgba(22, 22, 26, 0.55);
  --surface-bg-hover:    rgba(28, 28, 33, 0.65);
  --surface-bg-active:   rgba(35, 35, 40, 0.70);
  --surface-input-bg:    rgba(255, 255, 255, 0.04);
  --surface-input-hover: rgba(255, 255, 255, 0.07);

  /* layered rim — 5 stacked box-shadow layers reference these. */
  --rim-top:     rgba(255, 255, 255, 0.20);
  --rim-top-hi:  rgba(255, 255, 255, 0.32);
  --rim-bottom:  rgba(0, 0, 0, 0.28);
  --rim-inner:   rgba(255, 255, 255, 0.06);
  --rim-inner-hi:rgba(255, 255, 255, 0.12);
  --rim-outer:   rgba(0, 0, 0, 0.50);
  --rim-drop:    rgba(0, 0, 0, 0.35);

  /* mesh wash on page bg */
  --mesh-1: rgba(255, 99, 99, 0.30);
  --mesh-2: rgba(139, 92, 246, 0.28);
  --mesh-3: rgba(56, 189, 248, 0.22);
  --mesh-4: rgba(244, 114, 182, 0.20);

  /* dot-grid mask alpha */
  --dot-alpha: 0.045;

  /* primary button: white on dark for the dark theme */
  --btn-primary-bg:    #fafafb;
  --btn-primary-fg:    #0e0e10;
  --btn-primary-hover: #ffffff;

  /* shadow tokens (legacy generic, may still be referenced) */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.45);
  --shadow-lg:  0 16px 40px rgba(0,0,0,0.55);

  /* typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "HarmonyOS Sans", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", monospace;

  /* spacing */
  --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; --s-16: 64px;

  /* radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-full: 999px;
}

/* =============================================================
   theme: silver — cool light glass over a soft silver canvas
   ============================================================= */
:root[data-theme="silver"] {
  --bg-0: #e7eaf2;
  --bg-1: #f3f5f9;
  --bg-2: #ffffff;
  --bg-3: #eef0f5;
  --bg-4: #e0e3eb;

  --line-1: rgba(0, 0, 0, 0.05);
  --line-2: rgba(0, 0, 0, 0.10);
  --line-3: rgba(0, 0, 0, 0.16);

  --fg-0: #1a1d24;
  --fg-1: #3f4754;
  --fg-2: #6b7280;
  --fg-3: #a4abb8;

  --accent: #3a5470;             /* steel blue */
  --accent-2: #6366f1;
  --accent-3: #0ea5e9;
  --accent-fg: #ffffff;

  --tag-rose:    #e85a73;
  --tag-amber:   #e88a2a;
  --tag-lemon:   #b5c025;
  --tag-mint:    #2e9d6f;
  --tag-sky:     #2f8fd0;
  --tag-indigo:  #6066c4;
  --tag-violet:  #7c5dbf;
  --tag-pink:    #d262a0;

  --surface-bg:          rgba(255, 255, 255, 0.55);
  --surface-bg-hover:    rgba(255, 255, 255, 0.75);
  --surface-bg-active:   rgba(255, 255, 255, 0.85);
  --surface-input-bg:    rgba(255, 255, 255, 0.55);
  --surface-input-hover: rgba(255, 255, 255, 0.80);

  /* light rim: top is a much brighter white edge, bottom is faint dark */
  --rim-top:     rgba(255, 255, 255, 0.95);
  --rim-top-hi:  rgba(255, 255, 255, 1.0);
  --rim-bottom:  rgba(40, 50, 70, 0.10);
  --rim-inner:   rgba(255, 255, 255, 0.55);
  --rim-inner-hi:rgba(255, 255, 255, 0.85);
  --rim-outer:   rgba(60, 80, 100, 0.20);
  --rim-drop:    rgba(60, 80, 100, 0.20);

  --mesh-1: rgba(168, 184, 210, 0.55);
  --mesh-2: rgba(190, 200, 220, 0.45);
  --mesh-3: rgba(150, 175, 200, 0.40);
  --mesh-4: rgba(205, 215, 230, 0.35);

  --dot-alpha: 0.04;

  /* primary button on silver: deep steel blue with white fg */
  --btn-primary-bg:    #3a5470;
  --btn-primary-fg:    #ffffff;
  --btn-primary-hover: #46627e;

  --shadow-sm:  0 1px 2px rgba(60, 80, 100, 0.10);
  --shadow-md:  0 4px 14px rgba(60, 80, 100, 0.12);
  --shadow-lg:  0 16px 40px rgba(60, 80, 100, 0.18);
}

/* =============================================================
   reset / base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg-0);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Mesh-gradient behind everything. Stronger than before so the glass layers
   actually show colour through them. */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -2;
  background:
    radial-gradient(700px 500px at 12% 8%,   var(--mesh-1), transparent 60%),
    radial-gradient(600px 600px at 88% 14%,  var(--mesh-2), transparent 60%),
    radial-gradient(800px 600px at 50% 110%, var(--mesh-3), transparent 60%),
    radial-gradient(500px 400px at 78% 70%,  var(--mesh-4), transparent 60%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,var(--dot-alpha)) 1px, transparent 1.2px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 90%);
}
:root[data-theme="dark"] body::after,
:root:not([data-theme]) body::after {
  /* dark themes use a light-on-dark grid */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,var(--dot-alpha)) 1px, transparent 1.2px);
}

a { color: var(--fg-0); text-decoration: none; }
a:hover { color: var(--fg-0); }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.012em; color: var(--fg-0); }
h1 { font-size: 22px; line-height: 1.25; letter-spacing: -0.022em; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 14px; line-height: 1.4; }
p  { margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); background-clip: content-box; border: 3px solid transparent; }
::selection { background: rgba(255,99,99,0.30); color: var(--fg-0); }

/* =============================================================
   layout shell
   ============================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 52px 1fr;
  grid-template-areas:
    "side topbar"
    "side main";
  min-height: 100vh;
}

/* sidebar — translucent glass over the mesh gradient */
.sidebar {
  grid-area: side;
  display: flex; flex-direction: column;
  background: var(--surface-bg);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-right: 1px solid var(--rim-inner);
  position: sticky; top: 0; height: 100vh;
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  height: 52px;
  border-bottom: 1px solid var(--rim-inner);
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #ff6363 0%, #ff8a5a 100%);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 2px 6px rgba(255,99,99,0.3);
  letter-spacing: -0.04em;
}
.brand-name { font-size: 13.5px; font-weight: 600; color: var(--fg-0); letter-spacing: -0.01em; }
.brand-sub  { font-size: 11px; color: var(--fg-2); margin-top: 1px; letter-spacing: 0; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--fg-2);
  padding: 6px 10px;
  font-weight: 600;
}
/* layered-border glass — outer dark rim + inner top highlight + inner bottom
   shadow. Mimics the iOS/VisionOS "carved" pill look. */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--fg-1);
  font-weight: 500;
  font-size: 13px;
  margin: 4px 0;
  transition: background .15s, color .15s, box-shadow .2s;
  white-space: nowrap;
  position: relative;
  background: var(--surface-input-bg);
  border: none;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 4px 10px var(--rim-drop);
}
.nav-item:hover {
  background: var(--surface-input-hover);
  color: var(--fg-0);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 6px 14px var(--rim-drop);
}
.nav-item.active {
  background: var(--surface-bg-hover);
  color: var(--fg-0);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 6px 18px var(--rim-drop);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 99, 99, 0.6);
}
.nav-item .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--fg-2);
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { color: var(--fg-0); }

/* small keyboard hint pill on right side of nav-item */
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  color: var(--fg-2);
  margin-left: auto;
}

/* topbar — also translucent glass */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  background: var(--surface-bg);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-bottom: 1px solid var(--rim-inner);
}
.topbar-title {
  font-size: 13px; font-weight: 500;
  color: var(--fg-1);
  display: flex; align-items: center; gap: 8px;
}
.topbar-title::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--fg-2);
  margin-right: 2px;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 14px 4px 4px;
  border-radius: var(--r-full);
  background: var(--surface-input-bg);
  border: none;
  cursor: pointer;
  transition: background .15s, box-shadow .2s;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 4px 10px var(--rim-drop);
}
.topbar-user:hover {
  background: var(--surface-input-hover);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 6px 14px var(--rim-drop);
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--tag-rose), var(--tag-amber));
  color: white; display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
}
.topbar-user .meta { line-height: 1.1; }
.topbar-user .name { font-size: 12.5px; font-weight: 500; color: var(--fg-0); }
.topbar-user .role { font-size: 10.5px; color: var(--fg-2); }

/* main scrollable area — transparent so the mesh shows through */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 28px 32px 48px;
  background: transparent;
}
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--s-8);
  gap: var(--s-6);
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.022em; }
.page-sub   { color: var(--fg-2); margin-top: 4px; font-size: 13px; }

/* =============================================================
   surfaces
   ============================================================= */
.card {
  background: var(--surface-bg);
  border: none;
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 10px 28px var(--rim-drop);
}
.card.spacious { padding: var(--s-6) var(--s-6); }
.card.elev {
  background: rgba(28, 28, 33, 0.70);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, var(--shadow-md);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--s-4);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--fg-0); }
.card-sub   { font-size: 11.5px; color: var(--fg-2); margin-top: 2px; }

/* stat tile — Raycast-style with subtle coloured glyph */
.stat {
  background: var(--surface-bg);
  border: none;
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: background .15s, transform .15s, box-shadow .2s;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 10px 28px var(--rim-drop);
}
.stat:hover {
  background: var(--surface-bg-hover);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 14px 36px var(--rim-drop);
}
.stat .label { color: var(--fg-2); font-size: 11.5px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.stat .value { font-size: 28px; font-weight: 600; color: var(--fg-0); margin-top: 6px; letter-spacing: -0.022em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 11.5px; color: var(--fg-2); margin-top: 4px; }
.stat .delta.up { color: var(--ok); }
.stat .icon {
  position: absolute; right: 16px; top: 16px;
  width: 28px; height: 28px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: white;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.stat .icon.rose   { background: linear-gradient(135deg, #ff6363, #ff8a5a); }
.stat .icon.violet { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.stat .icon.sky    { background: linear-gradient(135deg, #38bdf8, #0ea5e9); }
.stat .icon.mint   { background: linear-gradient(135deg, #4ade80, #22c55e); }
.stat .icon.amber  { background: linear-gradient(135deg, #fbbf24, #f97316); }

/* =============================================================
   buttons
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 500;
  border-radius: 8px;
  border: none;
  background: var(--surface-input-bg);
  color: var(--fg-0);
  transition: all .15s ease;
  letter-spacing: 0;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 2px 6px var(--rim-drop);
}
.btn:hover {
  background: var(--surface-input-hover);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 4px 10px var(--rim-drop);
}
.btn:active {
  background: var(--surface-bg-active);
  box-shadow:
    inset 0 1px 2px var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-primary:active { background: var(--btn-primary-hover); filter: brightness(0.94); }

.btn-accent {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.10);
}
.btn-accent:hover { background: #ff7878; }
.btn-accent:active { background: #f04e4e; }

.btn-danger {
  background: rgba(248, 113, 113, 0.10);
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.25);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-1); }
.btn-ghost:hover { background: var(--bg-2); color: var(--fg-0); }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-lg { padding: 10px 22px; font-size: 13.5px; }

/* =============================================================
   form
   ============================================================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
label { font-size: 12px; font-weight: 500; color: var(--fg-1); letter-spacing: 0; }
.hint { font-size: 11px; color: var(--fg-2); font-weight: 400; }

.input, .select, textarea.input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--fg-0);
  background: var(--surface-input-bg);
  border: 1px solid var(--rim-inner-hi);
  border-radius: var(--r-sm);
  transition: border-color .12s, background .12s, box-shadow .12s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-input-hover);
  box-shadow: 0 0 0 3px rgba(58, 84, 112, 0.20);
}
.input::placeholder { color: var(--fg-3); }
textarea.input { resize: vertical; min-height: 72px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1l4 4 4-4' stroke='%238a8a92' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}
.select option { background: var(--bg-2); color: var(--fg-0); }

/* =============================================================
   table
   ============================================================= */
.table-wrap {
  background: var(--surface-bg);
  border: none;
  border-radius: var(--r-lg);
  overflow: hidden;
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 10px 28px var(--rim-drop);
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 16px; }
.table th {
  font-size: 11px; font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.07em;
  background: transparent;
  border-bottom: 1px solid var(--rim-inner-hi);
}
.table td {
  color: var(--fg-0);
  border-bottom: 1px solid var(--rim-inner);
  font-weight: 400;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-input-bg); }

/* badges — small coloured pill */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 500;
  border-radius: var(--r-full);
  background: var(--bg-3);
  color: var(--fg-1);
  border: 1px solid var(--line-2);
}
.badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--fg-2);
}
.badge.success::before { background: var(--ok); }
.badge.warn::before    { background: var(--warn); }
.badge.danger::before  { background: var(--bad); }
.badge.accent::before  { background: var(--accent); }
.badge.violet::before  { background: var(--tag-violet); }
.badge.sky::before     { background: var(--tag-sky); }

.badge.success { color: #86efac; border-color: rgba(74, 222, 128, 0.25); background: rgba(74, 222, 128, 0.08); }
.badge.warn    { color: #fcd34d; border-color: rgba(251, 191, 36, 0.25); background: rgba(251, 191, 36, 0.08); }
.badge.danger  { color: #fca5a5; border-color: rgba(248, 113, 113, 0.25); background: rgba(248, 113, 113, 0.08); }
.badge.accent  { color: #ff9090; border-color: rgba(255, 99, 99, 0.25); background: rgba(255, 99, 99, 0.08); }

/* grid utilities */
.grid { display: grid; gap: var(--s-4); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px)  { .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }

/* =============================================================
   modal
   ============================================================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface-bg-hover);
  border: none;
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 30px 80px rgba(0, 0, 0, 0.55);
  width: min(540px, 92vw);
  padding: 24px 28px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
}
/* (the top highlight is now part of the modal's layered rim shadow) */
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-5); }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  background: transparent; border: none; color: var(--fg-2);
  font-size: 14px;
}
.modal-close:hover { background: var(--bg-3); color: var(--fg-0); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: var(--s-5); }

/* =============================================================
   toast
   ============================================================= */
#toast-root {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface-bg-hover);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    var(--shadow-lg);
  font-size: 12.5px;
  color: var(--fg-0);
  animation: slideIn .18s ease-out;
  display: flex; align-items: center; gap: 8px;
}
.toast::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-2);
}
.toast.success::before { background: var(--ok); }
.toast.error::before   { background: var(--bad); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================================
   misc
   ============================================================= */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-2);
}
.empty-state .glyph { font-size: 32px; opacity: 0.5; margin-bottom: 10px; color: var(--fg-3); }
.empty-state .msg { font-size: 13px; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--line-3);
  border-top-color: var(--fg-0);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider { height: 1px; background: var(--line-1); margin: var(--s-4) 0; }
.text-muted { color: var(--fg-2); }
.text-small { font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12px; }

.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

/* =============================================================
   theme picker (two small swatches in the topbar)
   ============================================================= */
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-full);
  background: var(--surface-input-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer);
}
.theme-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform .12s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.30),
    inset 0 -1px 0 rgba(0,0,0,0.18),
    0 0 0 0.5px rgba(0,0,0,0.35);
}
.theme-swatch:hover { transform: scale(1.10); }
.theme-swatch.active {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(0,0,0,0.20),
    0 0 0 0.5px rgba(0,0,0,0.35),
    0 0 0 2px var(--accent);
}
.theme-swatch.swatch-dark   { background: linear-gradient(135deg, #1a1a1f 0%, #2c2c34 100%); }
.theme-swatch.swatch-silver { background: linear-gradient(135deg, #d8dce6 0%, #b4bdca 100%); }

/* media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s-4);
}
.media-card {
  background: var(--surface-bg);
  border: none;
  border-radius: 12px;
  overflow: hidden;
  transition: background .15s, transform .15s, box-shadow .2s;
  cursor: pointer;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    inset 0 1px 0 var(--rim-top),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner),
    0 0 0 0.5px var(--rim-outer),
    0 8px 22px var(--rim-drop);
}
.media-card:hover {
  background: var(--surface-bg-hover);
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 var(--rim-top-hi),
    inset 0 -1px 0 var(--rim-bottom),
    inset 0 0 0 1px var(--rim-inner-hi),
    0 0 0 0.5px var(--rim-outer),
    0 12px 30px var(--rim-drop);
}
.media-thumb {
  aspect-ratio: 16/10;
  background: var(--bg-2);
  display: grid; place-items: center;
  color: var(--fg-2); font-size: 24px;
  position: relative;
  border-bottom: 1px solid var(--line-1);
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-meta { padding: 10px 12px; }
.media-title {
  font-size: 12.5px; font-weight: 500; color: var(--fg-0);
  margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-sub { font-size: 11px; color: var(--fg-2); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
