/* ==========================================================================
   Hermes Dashboard Theme System — Ported to Symfony
   ==========================================================================
   Based on @nous-research/hermes-agent dashboard theme engine.
   Matches the exact DOM/CSS structure from App.tsx + Backdrop.tsx.
   6 built-in themes: default(teal), midnight, ember, mono, cyberpunk, rose
   Use via: <html data-theme="midnight"> or JS theme switcher
   ========================================================================== */

/* ----------------------------------------------------------------------- */
/* 1. Root defaults (Hermes Teal / default theme)                          */
/* ----------------------------------------------------------------------- */
:root,
[data-theme="default"] {
  /* ---- Palette Layers (LENS_0 from design-language) ---- */
  --background: color-mix(in srgb, #041c1c 100%, transparent);
  --background-base: #041c1c;
  --background-alpha: 1;
  --midground: color-mix(in srgb, #ffe6cb 100%, transparent);
  --midground-base: #ffe6cb;
  --midground-alpha: 1;
  --foreground: color-mix(in srgb, #ffffff 0%, transparent);
  --foreground-base: #ffffff;
  --foreground-alpha: 0;

  --warm-glow: rgba(255, 189, 56, 0.35);
  --noise-opacity-mul: 1;

  /* ---- Typography ---- */
  --theme-font-sans: system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --theme-font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo,
    Consolas, monospace;
  --theme-font-display: var(--theme-font-sans);
  --theme-base-size: 15px;
  --theme-line-height: 1.55;
  --theme-letter-spacing: 0;

  /* ---- Layout ---- */
  --radius: 0.5rem;
  --theme-radius: 0.5rem;
  --theme-spacing-mul: 1;
  --theme-density: comfortable;

  /* ---- Shadcn-compat tokens (derived from palette) ---- */
  --color-foreground: var(--midground);
  --color-card: color-mix(in srgb, var(--midground-base) 4%, var(--background-base));
  --color-card-foreground: var(--midground);
  --color-primary: var(--midground);
  --color-primary-foreground: var(--background-base);
  --color-secondary: color-mix(in srgb, var(--midground-base) 6%, var(--background-base));
  --color-secondary-foreground: var(--midground);
  --color-muted: color-mix(in srgb, var(--midground-base) 8%, var(--background-base));
  --color-muted-foreground: color-mix(in srgb, var(--midground-base) 80%, transparent);
  --color-accent: color-mix(in srgb, var(--midground-base) 10%, var(--background-base));
  --color-accent-foreground: var(--midground);
  --color-destructive: #fb2c36;
  --color-destructive-foreground: #ffffff;
  --color-success: #4ade80;
  --color-warning: #ffbd38;
  --color-border: color-mix(in srgb, var(--midground-base) 15%, transparent);
  --color-input: color-mix(in srgb, var(--midground-base) 15%, transparent);
  --color-ring: var(--midground);
  --color-popover: color-mix(in srgb, var(--midground-base) 4%, var(--background-base));
  --color-popover-foreground: var(--midground);
  --radius-sm: calc(var(--theme-radius) - 4px);
  --radius-md: calc(var(--theme-radius) - 2px);
  --radius-lg: var(--theme-radius);
  --radius-xl: calc(var(--theme-radius) + 4px);
  --color-text-primary: var(--midground);
  --color-text-secondary: color-mix(in srgb, var(--midground-base) 70%, transparent);
  --color-text-tertiary: color-mix(in srgb, var(--midground-base) 45%, transparent);
  --color-text-disabled: color-mix(in srgb, var(--midground-base) 25%, transparent);
}

/* ----------------------------------------------------------------------- */
/* 2. All themes                                                           */
/* ----------------------------------------------------------------------- */
[data-theme="midnight"] {
  --background-base: #0a0a1f;
  --midground-base: #d4c8ff;
  --warm-glow: rgba(167, 139, 250, 0.32);
  --noise-opacity-mul: 0.8;
  --theme-font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --theme-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-letter-spacing: -0.005em;
  --theme-radius: 0.75rem;
}
[data-theme="ember"] {
  --background-base: #1a0a06;
  --midground-base: #ffd8b0;
  --warm-glow: rgba(249, 115, 22, 0.38);
  --noise-opacity-mul: 1;
  --theme-font-sans: "Spectral", Georgia, "Times New Roman", serif;
  --theme-font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-radius: 0.25rem;
  --color-destructive: #c92d0f;
  --color-warning: #f97316;
}
[data-theme="mono"] {
  --background-base: #0e0e0e;
  --midground-base: #eaeaea;
  --warm-glow: rgba(255, 255, 255, 0.1);
  --noise-opacity-mul: 0.6;
  --theme-font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --theme-font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-radius: 0;
}
[data-theme="cyberpunk"] {
  --background-base: #040608;
  --midground-base: #9bffcf;
  --warm-glow: rgba(0, 255, 136, 0.22);
  --noise-opacity-mul: 1.2;
  --theme-font-sans: "Share Tech Mono", "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-font-mono: "Share Tech Mono", "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-radius: 0;
  --color-success: #00ff88;
  --color-warning: #ffd700;
  --color-destructive: #ff0055;
}
[data-theme="rose"] {
  --background-base: #1a0f15;
  --midground-base: #ffd4e1;
  --warm-glow: rgba(249, 168, 212, 0.3);
  --noise-opacity-mul: 0.9;
  --theme-font-sans: "Fraunces", Georgia, serif;
  --theme-font-mono: "DM Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --theme-radius: 1rem;
}

/* Dynamic derived tokens that depend on current theme's base colors */
[data-theme] {
  --background: color-mix(in srgb, var(--background-base) calc(var(--background-alpha, 1) * 100%), transparent);
  --midground: color-mix(in srgb, var(--midground-base) calc(var(--midground-alpha, 1) * 100%), transparent);
  --theme-font-display: var(--theme-font-sans);
  --color-foreground: var(--midground);
  --color-card: color-mix(in srgb, var(--midground-base) 4%, var(--background-base));
  --color-card-foreground: var(--midground);
  --color-primary: var(--midground);
  --color-primary-foreground: var(--background-base);
  --color-secondary: color-mix(in srgb, var(--midground-base) 6%, var(--background-base));
  --color-secondary-foreground: var(--midground);
  --color-muted: color-mix(in srgb, var(--midground-base) 8%, var(--background-base));
  --color-muted-foreground: color-mix(in srgb, var(--midground-base) 80%, transparent);
  --color-accent: color-mix(in srgb, var(--midground-base) 10%, var(--background-base));
  --color-accent-foreground: var(--midground);
  --color-border: color-mix(in srgb, var(--midground-base) 15%, transparent);
  --color-input: color-mix(in srgb, var(--midground-base) 15%, transparent);
  --color-ring: var(--midground);
  --color-popover: color-mix(in srgb, var(--midground-base) 4%, var(--background-base));
  --color-popover-foreground: var(--midground);
  --color-text-primary: var(--midground);
  --color-text-secondary: color-mix(in srgb, var(--midground-base) 70%, transparent);
  --color-text-tertiary: color-mix(in srgb, var(--midground-base) 45%, transparent);
  --color-text-disabled: color-mix(in srgb, var(--midground-base) 25%, transparent);
  --radius: var(--theme-radius, 0.5rem);
  --radius-sm: calc(var(--theme-radius, 0.5rem) - 4px);
  --radius-md: calc(var(--theme-radius, 0.5rem) - 2px);
  --radius-lg: var(--theme-radius, 0.5rem);
  --radius-xl: calc(var(--theme-radius, 0.5rem) + 4px);
}

/* ==========================================================================
   2. Base Reset & Typography — matches index.css exactly
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--theme-font-sans);
  font-size: var(--theme-base-size);
  line-height: var(--theme-line-height);
  letter-spacing: var(--theme-letter-spacing);
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  color-scheme: dark;
}

body {
  font-family: var(--theme-font-sans);
  min-height: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  /* Body 本身透明 — 纯黑背景由 .hermes-shell 提供 */
  background: transparent;
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, kbd, pre, samp { font-family: var(--theme-font-mono); }
small { font-size: 1.0625rem; }
code { font-size: 0.875rem; }

a {
  color: var(--midground);
  text-decoration: none;
  transition: opacity 0.15s;
}
a:hover { opacity: 0.8; }

/* ==========================================================================
   3. Shell — 纯黑容器，与 Hermes 的 `bg-black` 一致
   ========================================================================== */
.hermes-shell {
  display: flex;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background-color: #000;
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* ==========================================================================
   4. Backdrop — 每个层独立 fixed，匹配 Backdrop.tsx
   ========================================================================== */

/* z-[1]: 深色画布 + difference 混合，让 #000 + #041c1c = 显示茶色 */
.hermes-backdrop__canvas {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 1;
  background-color: var(--background-base);
  mix-blend-mode: difference;
}

/* z-[2]: 纹理填充图 + difference 混合，极低透明度 — 匹配 Backdrop.tsx */
.hermes-backdrop__filler {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 2;
  background: url('/images/filler-bg0.jpg') top left / cover no-repeat;
  mix-blend-mode: difference;
  opacity: 0.033;
  filter: invert(1);
}

/* z-[99]: 暖光晕 — 左上角径向渐变，lighten 混合 */
.hermes-backdrop__glow {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 99;
  background: radial-gradient(ellipse at 0% 0%, transparent 60%, var(--warm-glow) 100%);
  mix-blend-mode: lighten;
  opacity: 0.24;
}

/* z-[200]: FG inversion — foreground 色 + difference 混合，dark 主题下 alpha=0 透明无效果 */
.hermes-backdrop__inversion {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 200;
  background-color: var(--foreground);
  mix-blend-mode: difference;
}

/* z-[201]: 噪点纹理 — SVG fractalNoise, color-dodge 混合 */
.hermes-backdrop__noise {
  position: fixed;
  pointer-events: none;
  inset: 0;
  z-index: 201;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' fill='%23eaeaea' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  background-size: 512px 512px;
  mix-blend-mode: color-dodge;
  opacity: calc(0.55 * var(--noise-opacity-mul, 1));
}

/* ==========================================================================
   5. Dashboard Layout
   ========================================================================== */

.hermes-body {
  display: flex;
  min-height: 0;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 2; /* 在 backdrop canvas/filler 之上 */
}

/* ---- Sidebar (fixed, z-50, 半透明底 + blur) ---- */
.hermes-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 256px;
  height: 100dvh;
  flex-shrink: 0;
  border-right: 1px solid color-mix(in srgb, var(--midground-base) 20%, transparent);
  background-color: color-mix(in srgb, var(--background-base) 95%, transparent);
  backdrop-filter: blur(8px);
  overflow: hidden;
  transition: width 600ms cubic-bezier(0.33, 1.35, 0.62, 1);
}

.hermes-sidebar--collapsed { width: 56px; }

.hermes-sidebar__header {
  display: flex;
  height: 56px;
  flex-shrink: 0;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--midground-base) 20%, transparent);
  justify-content: space-between;
}

.hermes-sidebar__brand {
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 0.95;
  letter-spacing: 0.0525rem;
  color: var(--midground);
  text-transform: uppercase;
  mix-blend-mode: plus-lighter;
}

.hermes-sidebar__collapse-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.hermes-sidebar__collapse-btn:hover { color: var(--midground); }

.hermes-sidebar__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-top: 1px solid color-mix(in srgb, var(--midground-base) 10%, transparent);
  padding: 8px 0;
}

.hermes-sidebar__nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.hermes-sidebar__nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-family: var(--theme-font-sans);
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
  position: relative;
  cursor: pointer;
}
.hermes-sidebar__nav-link:hover { color: var(--midground); }
.hermes-sidebar__nav-link--active { color: var(--midground); }

.hermes-sidebar__nav-link--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background-color: var(--midground);
  mix-blend-mode: plus-lighter;
}

.hermes-sidebar__nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hermes-sidebar__nav-icon svg {
  display: block;
  color: inherit;
  stroke: currentColor;
  fill: none;
}

.hermes-sidebar__nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hermes-sidebar__footer {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid color-mix(in srgb, var(--midground-base) 20%, transparent);
}

.hermes-sidebar__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.05em;
}

.hermes-sidebar__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
}

.hermes-sidebar__theme-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hermes-sidebar__logout-form {
  display: flex;
  align-items: center;
  margin: 0;
}

.hermes-sidebar__logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.hermes-sidebar__logout-btn:hover {
  color: var(--color-destructive, #fb2c36);
  border-color: color-mix(in srgb, var(--color-destructive, #fb2c36) 25%, transparent);
}

/* ---- Main content — 无背景色，backdrop 透出 ---- */
.hermes-main {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 24px 24px 32px;
  overflow-y: auto;
  margin-left: 256px; /* sidebar 宽度 */
}

.hermes-content {
  width: 100%;
  min-width: 0;
  max-width: 1200px;
  margin: 0 auto;
}

/* ==========================================================================
   6. Dashboard Components
   ========================================================================== */

/* ---- Page Header ---- */
.page-header { margin-bottom: 24px; }
.page-header__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--midground);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-header__subtitle {
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
  margin: 0;
}

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}
.stat-card:hover {
  border-color: color-mix(in srgb, var(--midground-base) 30%, transparent);
}
.stat-card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin: 0 0 8px;
}
.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--midground);
  margin: 0 0 4px;
  line-height: 1.1;
}
.stat-card__change {
  font-size: 0.8125rem;
  color: var(--color-success);
  margin: 0;
}
.stat-card__change--negative { color: var(--color-destructive); }

/* ---- Card ---- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--midground);
  margin: 0;
}
.card__body { padding: 20px; }

/* ---- Activity List ---- */
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.activity-item:last-child { border-bottom: none; }
.activity-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.activity-item__icon svg {
  display: block;
}
.activity-item__content { flex: 1; min-width: 0; }
.activity-item__title {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  margin: 0 0 2px;
}
.activity-item__time {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

/* ---- Table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  border-bottom: 1px solid var(--color-border);
  font-weight: 500;
}
.data-table td {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td {
  background: color-mix(in srgb, var(--midground-base) 2%, transparent);
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  letter-spacing: 0.03em;
}
.badge--success {
  background: color-mix(in srgb, #4ade80 15%, transparent);
  color: #4ade80;
}
.badge--warning {
  background: color-mix(in srgb, #ffbd38 15%, transparent);
  color: #ffbd38;
}
.badge--danger {
  background: color-mix(in srgb, #fb2c36 15%, transparent);
  color: #fb2c36;
}
.badge--info {
  background: color-mix(in srgb, var(--midground-base) 15%, transparent);
  color: var(--midground);
}

/* ---- Theme Switcher ---- */
.theme-switcher { position: relative; }
.theme-switcher__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: var(--theme-font-sans);
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.theme-switcher__btn:hover { color: var(--midground); }
.theme-switcher__dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  min-width: 200px;
  max-height: 70dvh;
  overflow-y: auto;
  background: color-mix(in srgb, var(--background-base) 95%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
}
.theme-switcher:hover .theme-switcher__dropdown,
.theme-switcher:focus-within .theme-switcher__dropdown { display: block; }
.theme-switcher__header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--theme-font-sans);
}
.theme-option:hover {
  background: color-mix(in srgb, var(--midground-base) 5%, transparent);
}
.theme-option:focus-visible {
  outline: none;
  border-color: var(--midground);
  box-shadow: 0 0 0 1px var(--midground);
}
.theme-option--active {
  background: color-mix(in srgb, var(--midground-base) 8%, transparent);
}
.theme-option__swatch {
  display: flex;
  width: 36px;
  height: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  flex-shrink: 0;
}
.theme-option__swatch span { flex: 1; }
.theme-option__info { flex: 1; min-width: 0; }
.theme-option__label {
  font-size: 0.75rem;
  color: var(--color-text-primary);
  letter-spacing: 0.03em;
}
.theme-option__desc {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
}
.theme-option__check {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--midground);
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-option__check svg {
  display: block;
}
.theme-option--active .theme-option__check { opacity: 1; }

/* ---- Mobile header ---- */
.hermes-mobile-header { display: none; }

/* ---- Scrollbar ---- */
.hermes-sidebar__nav::-webkit-scrollbar,
.hermes-main::-webkit-scrollbar { width: 6px; }
.hermes-sidebar__nav::-webkit-scrollbar-track,
.hermes-main::-webkit-scrollbar-track { background: transparent; }
.hermes-sidebar__nav::-webkit-scrollbar-thumb,
.hermes-main::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--midground-base) 20%, transparent);
  border-radius: 3px;
}
.hermes-sidebar__nav::-webkit-scrollbar-thumb:hover,
.hermes-main::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--midground-base) 35%, transparent);
}

/* ---- Keyframes ---- */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Utility ---- */
.font-mono { font-family: var(--theme-font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   7. Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .hermes-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
    background-color: color-mix(in srgb, var(--background-base) 97%, transparent);
  }
  .hermes-sidebar--open { transform: translateX(0); }
  .hermes-sidebar--collapsed { width: 256px; }

  .hermes-mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 8px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--midground-base) 20%, transparent);
    background-color: color-mix(in srgb, var(--background-base) 90%, transparent);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .hermes-mobile-header__menu-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .hermes-mobile-header__menu-btn:hover { color: var(--midground); }
  .hermes-mobile-header__brand {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 0.95;
    letter-spacing: 0.05em;
    color: var(--midground);
    mix-blend-mode: plus-lighter;
  }

  .hermes-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
  }
  .hermes-sidebar-overlay--visible { display: block; }

  .hermes-body { flex-direction: column; }
  .hermes-main {
    padding: 16px;
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  html, body, .hermes-shell {
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .hermes-main { padding: 12px; margin-left: 0; }
}

/* ==========================================================================
   8. Auth Pages — 登录/注册/密码重置（无侧栏）
   ========================================================================== */

.hermes-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.hermes-auth__card {
  width: 100%;
  max-width: 420px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  animation: dialog-in 0.25s ease-out;
}

.hermes-auth__title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--midground);
  margin: 0 0 24px;
  text-align: center;
  letter-spacing: -0.01em;
}

.hermes-auth__help {
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
  margin: 0 0 20px;
  text-align: center;
  line-height: 1.6;
}

.hermes-auth__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hermes-remember-row {
  margin: 12px 0 4px;
}

.hermes-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  user-select: none;
}

.hermes-remember-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--theme-primary);
  cursor: pointer;
}

.hermes-remember-hint {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

.hermes-auth__links {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  font-size: 0.8125rem;
}

.hermes-auth__links a {
  color: var(--color-text-tertiary);
  transition: color 0.15s;
}
.hermes-auth__links a:hover {
  color: var(--midground);
}

/* ---- Form Elements ---- */

.hermes-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hermes-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.hermes-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  font-family: var(--theme-font-sans);
  color: var(--midground);
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.hermes-input:focus {
  border-color: var(--midground);
  box-shadow: 0 0 0 1px var(--midground);
}

.hermes-input::placeholder {
  color: var(--color-text-disabled);
}

/* ---- Buttons ---- */

.hermes-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--theme-font-sans);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
}

.hermes-btn--primary {
  background: var(--midground);
  color: var(--background-base);
  border-color: var(--midground);
}
.hermes-btn--primary:hover {
  opacity: 0.85;
}
.hermes-btn:focus-visible,
.hermes-btn:focus {
  outline: none;
  border-color: var(--midground);
  box-shadow: 0 0 0 1px var(--midground);
}

.hermes-btn--danger {
  background: transparent;
  color: var(--color-destructive);
  border-color: var(--color-destructive);
}
.hermes-btn--danger:hover {
  background: color-mix(in srgb, var(--color-destructive) 12%, transparent);
}

.hermes-btn--full {
  width: 100%;
}

/* ---- Alerts / Flash Messages ---- */

.hermes-alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 16px;
  animation: fade-in 0.2s ease-out;
}

.hermes-alert--success {
  background: color-mix(in srgb, #4ade80 12%, transparent);
  color: #4ade80;
  border: 1px solid color-mix(in srgb, #4ade80 25%, transparent);
}

.hermes-alert--error {
  background: color-mix(in srgb, #fb2c36 12%, transparent);
  color: #fb2c36;
  border: 1px solid color-mix(in srgb, #fb2c36 25%, transparent);
}

.hermes-alert--warning {
  background: color-mix(in srgb, #ffbd38 12%, transparent);
  color: #ffbd38;
  border: 1px solid color-mix(in srgb, #ffbd38 25%, transparent);
}

/* ==========================================================================
   9. Account Page
   ========================================================================== */

.hermes-account {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hermes-account__card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.hermes-account__card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--midground);
  margin: 0 0 16px;
}

.hermes-account__card p {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  margin: 0 0 8px;
}

.hermes-account__card--danger {
  border-color: color-mix(in srgb, var(--color-destructive) 40%, transparent);
}

.hermes-account__card--danger h2 {
  color: var(--color-destructive);
}

/* ==========================================================================
   10. Auth Enhanced — 精致化认证页面
   ========================================================================== */

/* ---- Brand Mark in Auth Card ---- */
.hermes-auth__brand {
  text-align: center;
  margin-bottom: 28px;
}

.hermes-auth__brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--midground-base) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--midground-base) 20%, transparent);
  margin-bottom: 12px;
  color: var(--midground);
}

.hermes-auth__brand-name {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* ---- Card Enhancements ---- */
.hermes-auth__card {
  position: relative;
  overflow: hidden;
}

.hermes-auth__card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--midground-base) 30%, transparent) 50%,
    transparent 100%
  );
}

/* ---- Input with action (password toggle) ---- */
.hermes-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.hermes-input-wrap .hermes-input {
  padding-right: 40px;
}

.hermes-input__toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
  line-height: 1;
}

.hermes-input__toggle:hover {
  color: var(--midground);
  background: color-mix(in srgb, var(--midground-base) 8%, transparent);
}

.hermes-input__toggle svg {
  display: block;
}

/* ---- Button with loading state ---- */
.hermes-btn--loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.hermes-btn--loading .hermes-btn__text {
  visibility: hidden;
}

.hermes-btn__spinner {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.hermes-btn--loading .hermes-btn__spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Auth divider ---- */
.hermes-auth__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--color-text-disabled);
  font-size: 0.75rem;
}

.hermes-auth__divider::before,
.hermes-auth__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ---- Alert with icon ---- */
.hermes-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hermes-alert__icon {
  flex-shrink: 0;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hermes-alert__text {
  flex: 1;
  min-width: 0;
}

/* ---- Subtle input glow on focus ---- */
.hermes-input:focus {
  border-color: var(--midground);
  box-shadow: 0 0 0 1px var(--midground),
              0 0 20px color-mix(in srgb, var(--midground-base) 8%, transparent);
}

/* ---- Password hint ---- */
.hermes-hint {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin: 2px 0 0;
  line-height: 1.4;
}

/* ---- Smooth card entrance ---- */
.hermes-auth__card {
  animation: auth-card-in 0.35s ease-out;
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   11. Floating Labels — 标签浮入输入框
   ========================================================================== */

.hermes-float-group {
  display: flex;
  flex-direction: column;
}

.hermes-float-input-wrap {
  position: relative;
}

.hermes-float-input {
  display: block;
  width: 100%;
  padding: 18px 14px 6px;
  font-size: 0.9375rem;
  font-family: var(--theme-font-sans);
  color: var(--midground);
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  line-height: 1.5;
}

.hermes-float-input:focus {
  border-color: var(--midground);
  box-shadow: 0 0 0 1px var(--midground),
              0 0 20px color-mix(in srgb, var(--midground-base) 8%, transparent);
}

.hermes-float-input::placeholder {
  color: transparent;
}

.hermes-float-label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  color: var(--color-text-tertiary);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: left center;
  line-height: 1;
}

.hermes-float-input:focus ~ .hermes-float-label,
.hermes-float-input:not(:placeholder-shown) ~ .hermes-float-label {
  top: 10px;
  transform: translateY(0);
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.hermes-float-input:focus ~ .hermes-float-label {
  color: var(--midground);
}

/* ---- Float group with password toggle ---- */
.hermes-float-group .hermes-input__toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

/* ---- Float group errors ---- */
.hermes-float-error {
  font-size: 0.75rem;
  color: var(--color-destructive);
  margin-top: 4px;
  min-height: 1.2em;
  opacity: 0;
  transition: opacity 0.2s;
}

.hermes-float-error--visible {
  opacity: 1;
}

/* ==========================================================================
   12. Password Strength & Conditions
   ========================================================================== */

/* ---- Strength bar ---- */
.hermes-pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  height: 3px;
}

.hermes-pw-strength__seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--color-border);
  transition: background-color 0.3s;
}

.hermes-pw-strength__seg--active { background: var(--color-destructive); }
.hermes-pw-strength__seg--weak { background: #fb2c36; }
.hermes-pw-strength__seg--fair { background: #ffbd38; }
.hermes-pw-strength__seg--good { background: #4ade80; }
.hermes-pw-strength__seg--strong { background: #22d3ee; }

.hermes-pw-strength__label {
  font-size: 0.6875rem;
  margin-top: 4px;
  min-height: 1.2em;
  transition: color 0.3s;
}

/* ---- Conditions row ---- */
.hermes-pw-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 6px;
  min-height: 1.4em;
}

.hermes-pw-condition {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.35s ease, color 0.35s ease;
}

.hermes-pw-condition--met {
  opacity: 0;
  pointer-events: none;
}

.hermes-pw-condition__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ==========================================================================
   13. Email Async Check
   ========================================================================== */

.hermes-email-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  margin-top: 4px;
  min-height: 1.2em;
  opacity: 0;
  transition: opacity 0.2s;
}

.hermes-email-status--visible {
  opacity: 1;
}

.hermes-email-status__spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-border);
  border-top-color: var(--midground);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.hermes-email-status--loading .hermes-email-status__spinner {
  display: block;
}

.hermes-email-status--loading .hermes-email-status__icon,
.hermes-email-status--loading .hermes-email-status__text {
  display: none;
}

.hermes-email-status__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.hermes-email-status--available { color: var(--color-success); }
.hermes-email-status--taken { color: var(--color-destructive); }

/* ==========================================================================
   14. Refined Buttons
   ========================================================================== */

.hermes-btn--primary {
  position: relative;
  overflow: hidden;
  background: var(--midground);
  color: var(--background-base);
  border-color: var(--midground);
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}

.hermes-btn--primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--midground-base) 20%, transparent);
}

.hermes-btn--primary:active {
  transform: translateY(0);
  opacity: 0.85;
}

.hermes-btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 40%,
    color-mix(in srgb, #fff 6%, transparent) 50%,
    transparent 60%
  );
  pointer-events: none;
}

.hermes-btn--danger {
  transition: background-color 0.2s, transform 0.15s;
}

.hermes-btn--danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-destructive) 20%, transparent);
}

/* ---- Button subtle ripple on click ---- */
.hermes-btn--primary:active::after,
.hermes-btn--danger:active {
  transform: translateY(0);
}
