/* ============================================================
   PRISM Component Library
   Built on tokens.css — every class references semantic tokens.
   Aesthetic: "Cyberpunk Lightbox"
   — Near-black canvas, indigo accent, white CTA
   — Glassmorphism on chrome, solid surfaces on data
   — Single-color radial glows, hairline borders, subtle shadows
   — Inter (UI, ss03) + Geist Mono (code/metrics)
   — Cinematic motion with staggered reveals
   ============================================================ */

/* ═══════════════ Reset & Base ═══════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  background: var(--bg-canvas);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: var(--tracking-normal);
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01", "ss03";
}

/* —— Ambient background: indigo radial glow + grid mesh —— */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 1200px 700px at 15% -10%, var(--glow-indigo), transparent 55%),
    radial-gradient(ellipse 900px 500px at 90% 110%, var(--glow-indigo-soft), transparent 55%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--white-3) 1px, transparent 1px),
    linear-gradient(90deg, var(--white-3) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, black 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

code {
  background: var(--bg-surface-2);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--indigo-700);
  border: 1px solid var(--border-subtle);
}

::selection { background: var(--accent-solid); color: #fff; }

/* ═══════════════ Scrollbar ═══════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--white-10);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--white-20); background-clip: padding-box; }

/* ═══════════════ SVG Icons ═══════════════ */
.ic {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-sm { width: 15px; height: 15px; stroke-width: 1.5; }
.ic-lg { width: 22px; height: 22px; stroke-width: 1.5; }
.ic-xs { width: 12px; height: 12px; stroke-width: 1.5; }
.ic-spin { animation: spin 1s linear infinite; }

/* ═══════════════ Login Screen ═══════════════ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-canvas);
  z-index: var(--z-modal);
}
.login-screen::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 900px 600px at 30% 25%, var(--glow-indigo), transparent 50%),
    radial-gradient(ellipse 700px 400px at 75% 75%, var(--glow-indigo-soft), transparent 50%);
}
.login-screen::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--white-3) 1px, transparent 1px),
    linear-gradient(90deg, var(--white-3) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse at center, black 15%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 15%, transparent 70%);
}

.login-card {
  position: relative;
  width: 420px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--border-glass);
  border-radius: var(--r-2xl);
  padding: 44px 38px 34px;
  text-align: center;
  box-shadow: var(--shadow-lg), var(--shadow-inset);
  animation: loginRise var(--t-cinema) var(--ease-expo);
}

.login-logo {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border-radius: var(--r-xl);
  background: var(--accent);
  box-shadow: 0 0 32px var(--accent-glow), var(--shadow-sm);
  margin-bottom: 8px;
}
.login-logo svg { width: 28px; height: 28px; stroke: #fff; stroke-width: 1.5; }

.login-card h1 {
  margin: 16px 0 4px;
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.login-sub {
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
  margin-bottom: 32px;
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-wide);
}
.login-card label {
  display: block; text-align: left;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin: 16px 0 6px;
  letter-spacing: var(--tracking-wide);
  font-weight: 500;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: var(--bg-deep);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  font-size: var(--fs-md);
}
.login-card input:hover { border-color: var(--border-strong); }
.login-card input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-faint), 0 0 16px var(--accent-glow);
  background: var(--gray-20);
}
.login-card input::placeholder { color: var(--text-disabled); }
.login-card .btn-primary {
  width: 100%;
  margin-top: 26px;
  padding: 13px;
  font-size: var(--fs-md);
}
.login-hint {
  margin-top: 20px;
  font-size: var(--fs-sm);
  color: var(--text-disabled);
  line-height: var(--lh-relaxed);
}
.login-hint b { color: var(--text-secondary); font-weight: 500; }
.error-text {
  color: var(--danger-text);
  font-size: var(--fs-sm);
  min-height: 18px;
  margin-top: 12px;
  font-family: var(--font-mono);
}

/* ═══════════════ App Layout ═══════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: var(--z-base);
}

/* —— Sidebar (glassmorphism) —— */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  backdrop-filter: blur(var(--sidebar-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--sidebar-blur)) saturate(var(--glass-saturate));
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  padding: 16px 10px 12px;
  position: relative;
  flex-shrink: 0;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}
.brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-lg);
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  flex-shrink: 0;
}
.brand-icon svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 1.5; fill: none; }
.brand-text {
  font-weight: 600;
  font-size: var(--fs-lg);
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  display: flex; flex-direction: column;
}
.brand-text small {
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: var(--tracking-wide);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.side-section-title {
  font-size: var(--fs-2xs);
  color: var(--text-faint);
  letter-spacing: var(--tracking-wider);
  margin: 18px 8px 6px;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
}

#nav {
  display: flex; flex-direction: column;
  gap: 1px;
  flex: 1; overflow-y: auto;
  padding-right: 2px;
}
#nav a {
  padding: var(--nav-padding);
  border-radius: var(--nav-radius);
  color: var(--text-tertiary);
  font-size: var(--fs-base);
  text-decoration: none;
  transition: all var(--t-fast);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  position: relative;
  letter-spacing: var(--tracking-normal);
}
#nav a:hover {
  background: var(--white-4);
  color: var(--text-secondary);
}
#nav a.active {
  background: var(--accent-subtle);
  color: var(--text-primary);
}
#nav a.active::before {
  content: "";
  position: absolute; left: -10px; top: 25%; bottom: 25%;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}
#nav a .ic { color: var(--text-faint); transition: color var(--t-fast); }
#nav a:hover .ic { color: var(--text-tertiary); }
#nav a.active .ic { color: var(--accent-hover); }

.sidebar-foot {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.whoami {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-bottom: 10px;
  font-family: var(--font-mono);
  padding: 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.whoami::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

/* —— Main area —— */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--content-pad);
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
  backdrop-filter: blur(var(--topbar-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--topbar-blur)) saturate(var(--glass-saturate));
  flex-shrink: 0;
}
.topbar-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.save-state {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.content {
  flex: 1; overflow: auto;
  padding: var(--sp-7) var(--content-pad);
  background: var(--bg-canvas);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}
/* Staggered content reveal — cinematic */
.content > * {
  animation: rise var(--t-page) var(--ease-out) backwards;
}
.content > *:nth-child(1) { animation-delay: 0.02s; }
.content > *:nth-child(2) { animation-delay: 0.06s; }
.content > *:nth-child(3) { animation-delay: 0.10s; }
.content > *:nth-child(4) { animation-delay: 0.14s; }
.content > *:nth-child(5) { animation-delay: 0.18s; }
.content > *:nth-child(6) { animation-delay: 0.22s; }
.content > *:nth-child(7) { animation-delay: 0.26s; }
.content > *:nth-child(8) { animation-delay: 0.30s; }

/* ═══════════════ Cards ═══════════════ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--sp-5);
  position: relative;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--card-shadow-hover);
}

/* Glass card variant (hero, featured) */
.card.glass {
  background: var(--glass-card-bg);
  backdrop-filter: blur(var(--glass-card-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-card-blur)) saturate(var(--glass-saturate));
  border-color: var(--glass-card-border);
  box-shadow: var(--shadow-md), var(--shadow-inset);
}

.card h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: var(--tracking-tight);
  display: flex; align-items: center; gap: 8px;
}
.card .desc {
  color: var(--text-tertiary);
  font-size: var(--fs-base);
  margin-bottom: var(--sp-5);
  line-height: var(--lh-relaxed);
}
.card .desc code { margin: 0 2px; }

/* ═══════════════ Grid ═══════════════ */
.grid { display: grid; gap: var(--sp-3); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* ═══════════════ Forms ═══════════════ */
label.fld {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin: var(--sp-4) 0 var(--sp-2);
  letter-spacing: var(--tracking-wide);
  font-weight: 500;
}
input.in, textarea.in, select.in {
  width: 100%;
  padding: var(--input-padding);
  border-radius: var(--input-radius);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  font-size: var(--fs-base);
}
input.in:hover, textarea.in:hover, select.in:hover {
  border-color: var(--border-strong);
}
input.in:focus, textarea.in:focus, select.in:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-faint), 0 0 12px var(--accent-glow);
  background: var(--gray-20);
}
input.in::placeholder, textarea.in::placeholder { color: var(--text-disabled); }
textarea.in {
  min-height: 130px; resize: vertical;
  line-height: var(--lh-relaxed);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
select.in {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23626276' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.hint {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-top: var(--sp-2);
  line-height: var(--lh-relaxed);
}
.hint code { margin: 0 2px; }
.hint b { color: var(--text-secondary); font-weight: 500; }

/* ═══════════════ Buttons ═══════════════ */
/* Primary: White bg + black text (Raycast signature CTA) */
.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
  border: 1px solid var(--cta-bg);
  padding: var(--btn-padding);
  border-radius: var(--btn-radius);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: var(--tracking-normal);
  transition: background var(--t-fast), transform var(--t-instant), box-shadow var(--t-base);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--btn-height);
}
.btn-primary:hover {
  background: var(--cta-bg-hover);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
}
.btn-primary:active {
  background: var(--cta-bg-active);
  transform: scale(0.98);
}

/* Ghost: transparent with hairline border */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  padding: var(--btn-padding);
  border-radius: var(--btn-radius);
  font-size: var(--fs-sm);
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--btn-height);
}
.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--white-4);
}

/* Accent button (indigo) */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: var(--btn-padding);
  border-radius: var(--btn-radius);
  font-size: var(--fs-md);
  font-weight: 500;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--btn-height);
}
.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* Small button */
.btn-sm {
  padding: 7px 12px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-sm:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--white-6);
}

/* Danger button */
.btn-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}
.btn-danger:hover {
  background: rgba(244,63,94,0.12);
  border-color: var(--danger);
}

.btn-row {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: var(--sp-5);
}

/* ═══════════════ Toggle Switch ═══════════════ */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--text-secondary);
  user-select: none;
}
.switch input { display: none; }
.switch .track {
  width: 36px; height: 20px;
  border-radius: var(--r-pill);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-default);
  position: relative;
  transition: all var(--t-base);
  flex-shrink: 0;
}
.switch .track::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-tertiary);
  top: 2px; left: 2px;
  transition: all var(--t-base);
}
.switch input:checked + .track {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.switch input:checked + .track::after {
  left: 19px;
  background: #fff;
}
.switch:hover .track { border-color: var(--border-strong); }

/* ═══════════════ Badges ═══════════════ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  font-family: var(--font-mono);
}
.badge.ok   { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.badge.warn { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.badge.err  { background: var(--danger-bg);  color: var(--danger-text);  border: 1px solid var(--danger-border); }
.badge.mut  { background: var(--white-6); color: var(--text-tertiary); border: 1px solid var(--border-subtle); }

/* ═══════════════ Stat Cards ═══════════════ */
.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity var(--t-base);
}
.stat:hover {
  border-color: var(--border-default);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.stat:hover::before { opacity: 1; }
.stat .num {
  font-size: 28px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  margin-top: 6px;
  letter-spacing: var(--tracking-wide);
  font-family: var(--font-mono);
}

/* ═══════════════ Tables ═══════════════ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
th, td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
th {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wider);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  position: sticky; top: 0;
  z-index: var(--z-base);
  text-transform: uppercase;
}
tbody tr {
  transition: background var(--t-fast);
}
tbody tr:hover {
  background: var(--white-3);
}
.tbl-wrap {
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  max-height: 480px;
}

/* ═══════════════ Progress Bar ═══════════════ */
.progress {
  height: 8px;
  background: var(--bg-surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--indigo-700));
  transition: width 0.5s var(--ease-out);
  position: relative;
  border-radius: var(--r-pill);
}
.progress > i::after {
  content: "";
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 24px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
  border-radius: var(--r-pill);
}
.pr-num {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  margin-top: 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pr-who {
  font-size: var(--fs-sm);
  color: var(--text-disabled);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ═══════════════ Console / Log ═══════════════ */
.console {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 14px;
  height: 320px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.7;
  position: relative;
}
.console::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    var(--white-3) 2px,
    var(--white-3) 4px
  );
  pointer-events: none;
  border-radius: var(--r-md);
}
.console .l-info  { color: var(--indigo-700); }
.console .l-warn  { color: var(--warning-text); }
.console .l-error { color: var(--danger-text); }
.console .l-t     { color: var(--text-faint); }

/* ═══════════════ Toast ═══════════════ */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--border-strong);
  padding: 13px 22px;
  border-radius: var(--r-lg);
  font-size: var(--fs-md);
  z-index: var(--z-toast);
  box-shadow: var(--shadow-lg), var(--shadow-inset);
  animation: toastIn 0.3s var(--ease-out);
}

/* ═══════════════ Chips ═══════════════ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  color: var(--accent-hover);
  font-family: var(--font-mono);
  transition: all var(--t-fast);
}
.chip:hover {
  border-color: var(--accent-muted);
  background: var(--accent-faint);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ═══════════════ Attachments ═══════════════ */
.attach {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: var(--fs-base);
  margin-top: 6px;
  transition: border-color var(--t-fast);
}
.attach:hover { border-color: var(--border-default); }
.attach .x {
  margin-left: auto;
  color: var(--danger);
  cursor: pointer;
  font-size: var(--fs-md);
  transition: opacity var(--t-fast);
  opacity: 0.7;
}
.attach .x:hover { opacity: 1; }

/* ═══════════════ Security Results ═══════════════ */
.sec-result { display: flex; flex-direction: column; gap: 8px; }
.sec-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 13px 15px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.sec-item:hover { border-color: var(--border-default); background: var(--bg-surface-2); }
.sec-item .ic { font-size: 18px; flex-shrink: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.sec-item .body { flex: 1; min-width: 0; }
.sec-item .body .t { font-size: var(--fs-base); }
.sec-item .body .m { font-size: var(--fs-sm); color: var(--text-tertiary); margin-top: 2px; word-break: break-all; }

.title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}

/* ═══════════════ Modal ═══════════════ */
.modal {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
}
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(8,8,12,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-box {
  position: relative;
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 26px 28px;
  box-shadow: var(--shadow-xl), var(--shadow-inset);
  animation: modalIn 0.3s var(--ease-out);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h3 {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.modal-body .desc {
  color: var(--text-tertiary);
  font-size: var(--fs-base);
  margin-bottom: 16px;
}
.modal-body h4 {
  font-size: var(--fs-md);
  margin: 0;
}
.ev-name { font-size: var(--fs-base); font-weight: 600; }
.ev-id {
  font-size: var(--fs-xs);
  color: var(--text-disabled);
  margin-top: 2px;
  word-break: break-all;
  font-family: var(--font-mono);
}

/* ═══════════════ Page Banner ═══════════════ */
.page-banner {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.page-banner::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.page-banner .b-ic {
  width: 20px; height: 20px;
  flex-shrink: 0;
  color: var(--accent-hover);
  display: flex; align-items: center; justify-content: center;
}
.page-banner .b-t {
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: 3px;
  letter-spacing: var(--tracking-tight);
}
.page-banner .b-d {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  line-height: var(--lh-relaxed);
}

/* ═══════════════ Empty State ═══════════════ */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.empty .e-ic {
  margin-bottom: 10px;
  color: var(--text-faint);
  opacity: 0.6;
}
.empty .e-ic svg { width: 32px; height: 32px; stroke-width: 1.2; }
.empty .e-t {
  font-size: var(--fs-md);
  margin-bottom: 4px;
  color: var(--text-primary);
}
.empty .e-d { font-size: var(--fs-sm); }

/* ═══════════════ Wizard Steps ═══════════════ */
.wizard {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--border-glass);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
  position: relative;
  box-shadow: var(--shadow-md), var(--shadow-inset);
}
.wizard h2 { margin: 0 0 16px; }

.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 150px;
  display: flex; gap: 12px; align-items: center;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--t-base);
  position: relative;
}
.step:hover {
  border-color: var(--border-default);
  background: var(--bg-surface-2);
  transform: translateY(-1px);
}
.step .dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: all var(--t-base);
  border: 1px solid var(--border-subtle);
}
.step.done .dot {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
  box-shadow: 0 0 12px rgba(16,185,129,0.15);
}
.step.todo .dot {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}
.step.active .dot {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}
.step .s-t { font-size: var(--fs-base); font-weight: 600; }
.step .s-d { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 2px; }
.step .s-state {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-wide);
}
.step.done .s-state { color: var(--success-text); }
.step.todo .s-state { color: var(--warning-text); }
.step.active .s-state { color: var(--accent-hover); }

/* ═══════════════ Callout ═══════════════ */
.callout {
  border-radius: var(--r-md);
  padding: 13px 15px;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  margin-top: var(--sp-4);
  border: 1px solid;
  display: flex; gap: 10px; align-items: flex-start;
}
.callout.info {
  background: var(--accent-faint);
  border-color: var(--accent-muted);
  color: var(--indigo-800);
}
.callout.warn {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}
.callout.ok {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

/* ═══════════════ Tip ═══════════════ */
.tip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xs);
  padding: 2px 8px;
  margin-left: 6px;
}
.tip b { color: var(--accent-hover); }

/* ═══════════════ Keyframes ═══════════════ */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loginRise {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════ Responsive ═══════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 52px; --content-pad: 16px; }
  .sidebar { padding: 14px 4px 10px; }
  .brand-text, .side-section-title, .whoami { display: none; }
  .brand { justify-content: center; padding: 4px 0 14px; }
  #nav a { padding: 10px; justify-content: center; font-size: 0; }
  #nav a .ic { width: 20px; height: 20px; }
  .sidebar-foot { display: none; }
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: var(--fs-md); }
}

/* ═══════════════ Focus visible (a11y) ═══════════════ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
}

/* ═══════════════ Reduced motion ═══════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .sidebar, .topbar, .wizard, .toast, .card.glass {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-elevated);
  }
}
