/* ═══════════════════════════════════════
   AI创作平台 — 现代精致设计系统 v4
   Design System: Modern Elegant + Subtle Motion
   ═══════════════════════════════════════ */

/* Fonts use local platform stacks to avoid blocking page paint on remote font CDNs. */

/* ── Utility: hidden ── */
.hidden { display: none !important; }

/* ── Root Variables (OKLCH-aware) ── */
:root {
  /* Sidebar — Deep Navy */
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-surface: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-text-active: #60a5fa;
  --sidebar-accent: #3b82f6;
  --sidebar-accent-glow: rgba(59, 130, 246, 0.15);
  --sidebar-border: rgba(255, 255, 255, 0.06);

  /* Main Area — Warm Off-white */
  --main-bg: #f8fafc;
  --main-surface: #ffffff;
  --main-surface-soft: #f1f5f9;

  /* Text */
  --text: #1e293b;
  --text-soft: #475569;
  --text-muted: #94a3b8;

  /* Brand Colors — Refined Blue-Green */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.5);
  --primary-glow: rgba(59, 130, 246, 0.2);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.4);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.4);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.3);

  /* UI Colors */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* Shadows — Layered */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.10);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.14);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 8px 24px rgba(59, 130, 246, 0.18);

  /* Radius — Fluid */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions — Exponential Easing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Layout */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
}

/* ── Global box-sizing reset ── */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ═══════════════════════════════════════
   LAYOUT — Sidebar + Main Area
   ══════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100dvh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 1px 0 12px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

/* ── Sidebar Header ── */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: clamp(14px, 2vw, 20px) clamp(12px, 1.5vw, 18px);
  border-bottom: 1px solid var(--sidebar-border);
  gap: clamp(8px, 1vw, 12px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  color: var(--sidebar-text-hover);
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.sidebar-brand:hover {
  color: var(--sidebar-text-hover);
}

.sidebar-logo {
  width: clamp(34px, 4vw, 42px);
  height: clamp(34px, 4vw, 42px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-light), var(--primary), var(--primary-dark));
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
  flex-shrink: 0;
  transition: transform var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-normal) var(--ease-out-expo);
}

.sidebar-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.sidebar-logo svg {
  width: clamp(18px, 2.2vw, 24px);
  height: clamp(18px, 2.2vw, 24px);
  display: block;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-text h1 {
  margin: 0;
  font-size: clamp(15px, 1.8vw, 18px);
  font-weight: 800;
  color: var(--sidebar-text-hover);
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand-text small {
  display: block;
  margin-top: 1px;
  color: var(--sidebar-text);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: clamp(8px, 1vw, 12px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  padding: clamp(10px, 1.2vw, 14px) clamp(10px, 1.2vw, 14px);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
  cursor: pointer;
  overflow: hidden;
}

.sidebar-nav-item:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-accent-glow);
}

.sidebar-nav-item:active {
  transform: scale(0.97);
}

.sidebar-nav-item.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-accent-glow);
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}

.sidebar-nav-item .nav-icon {
  width: clamp(20px, 2.5vw, 24px);
  height: clamp(20px, 2.5vw, 24px);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  transition: background var(--duration-fast) var(--ease-out-expo);
}

.sidebar-nav-item:hover .nav-icon,
.sidebar-nav-item.active .nav-icon {
  background: var(--sidebar-accent-glow);
}

.sidebar-nav-item .nav-icon svg {
  width: clamp(16px, 2vw, 20px);
  height: clamp(16px, 2vw, 20px);
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav-item .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav-item .nav-badge {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  padding: 0 6px;
  background: var(--sidebar-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

/* Nav section label */
.sidebar-nav-section {
  padding: clamp(12px, 1.5vw, 16px) clamp(10px, 1.2vw, 14px) clamp(4px, 0.5vw, 6px);
  color: rgba(255, 255, 255, 0.22);
  font-size: clamp(9px, 1.1vw, 11px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: clamp(8px, 1vw, 12px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  padding: clamp(8px, 1vw, 12px);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.sidebar-user:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-accent-glow);
}

.sidebar-user-avatar {
  width: clamp(28px, 3.5vw, 36px);
  height: clamp(28px, 3.5vw, 36px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info strong {
  display: block;
  color: var(--sidebar-text-hover);
  font-size: clamp(11px, 1.3vw, 14px);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-info span {
  display: block;
  color: var(--sidebar-text);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 500;
  margin-top: 1px;
}

/* Sidebar balance & actions */
.sidebar-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: clamp(4px, 0.5vw, 8px) clamp(8px, 1vw, 12px);
  color: var(--sidebar-text);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
}

.sidebar-balance strong {
  color: var(--sidebar-accent);
  font-weight: 800;
}

.sidebar-actions {
  display: flex;
  gap: 4px;
  padding: 0 clamp(4px, 0.5vw, 8px) clamp(4px, 0.5vw, 8px);
}

.sidebar-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  border-radius: var(--radius-sm);
  padding: 0 clamp(6px, 0.8vw, 10px);
  color: var(--sidebar-text);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.sidebar-action-btn:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-accent-glow);
}

.sidebar-action-btn.primary {
  color: var(--sidebar-accent);
  background: var(--sidebar-accent-glow);
}

.sidebar-action-btn.primary:hover {
  background: rgba(59, 130, 246, 0.25);
}

.sidebar-action-btn .action-icon {
  width: clamp(12px, 1.5vw, 16px);
  height: clamp(12px, 1.5vw, 16px);
  display: grid;
  place-items: center;
}

.sidebar-action-btn .action-icon svg {
  width: clamp(12px, 1.5vw, 16px);
  height: clamp(12px, 1.5vw, 16px);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Sidebar Toggle (mobile) ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--main-surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.sidebar-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out-expo);
  pointer-events: none;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* ══════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════ */

.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100dvh;
  padding: clamp(16px, 2.5vw, 28px) clamp(16px, 3vw, 32px);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    var(--main-bg);
  transition: margin-left var(--duration-normal) var(--ease-out-expo);
}

.main-area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 1.5vw, 20px);
  margin-bottom: clamp(16px, 2vw, 24px);
  flex-wrap: wrap;
}

.main-area-header h2 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.main-area-header .eyebrow {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.main-area-header-actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  flex-wrap: wrap;
}

/* ── Base Reset ── */
body.is-generating {
  overflow: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out-expo);
}

a:hover {
  color: var(--primary-dark);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.hidden {
  display: none !important;
}/* ═══════════════════════════════════════
   PAGE HEADER (page-hd)
   ═══════════════════════════════════════ */

.page-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 1.5vw, 20px);
  margin-bottom: clamp(16px, 2vw, 24px);
  flex-wrap: wrap;
}

.page-hd > div:first-child p {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-hd > div:first-child h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-hd-actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
}

.canvas-project-titlebar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.canvas-project-titlebox {
  display: grid;
  gap: 6px;
  min-width: min(480px, 72vw);
}

.canvas-project-titlebox span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.canvas-project-titlebox input {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in oklch, var(--main-surface) 95%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  min-height: 42px;
  padding: 0 14px;
}

.canvas-project-titlebox input:focus {
  border-color: color-mix(in oklch, var(--primary) 58%, var(--line));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  outline: none;
}

.canvas-project-save-state {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 38px;
}

.canvas-project-save-state.is-pending,
.canvas-project-save-state.is-saving {
  color: var(--primary);
}

.canvas-project-save-state.is-saved {
  color: #0f9f6e;
}

.canvas-project-save-state.is-error {
  color: #dc2626;
}

.canvas-fullscreen-btn {
  align-items: center;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(59, 130, 246, 0.18));
  border: 1px solid color-mix(in oklch, #14b8a6 52%, var(--line));
  border-radius: 999px;
  color: #dffcf4;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
}

.canvas-fullscreen-btn svg {
  height: 18px;
  width: 18px;
}

.canvas-fullscreen-btn.is-active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(16, 185, 129, 0.24));
  box-shadow: 0 10px 30px rgba(14, 165, 233, 0.18);
}

/* ═══════════════════════════════════════
   BALANCE BADGE
   ═══════════════════════════════════════ */

.badge-balance {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  padding: clamp(6px, 0.8vw, 10px) clamp(10px, 1.2vw, 16px);
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  border: 1px solid rgba(59, 130, 246, 0.12);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
  transition: all var(--duration-normal) var(--ease-out-expo);
  text-decoration: none;
}

.badge-balance:hover {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.10);
  transform: translateY(-1px);
}

.badge-balance .num {
  font-weight: 800;
  font-size: clamp(14px, 1.6vw, 18px);
  color: var(--primary);
}

.badge-balance .label {
  color: var(--text-soft);
  font-weight: 600;
}

.badge-balance .balance-icon {
  width: clamp(16px, 2vw, 20px);
  height: clamp(16px, 2vw, 20px);
  display: grid;
  place-items: center;
}

.badge-balance .balance-icon svg {
  width: clamp(16px, 2vw, 20px);
  height: clamp(16px, 2vw, 20px);
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════
   CARD COMPONENTS (card-v3)
   ═══════════════════════════════════════ */

.card-v3 {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out-expo),
              transform var(--duration-normal) var(--ease-out-expo);
}

.card-v3:hover {
  box-shadow: var(--shadow);
}

.card-v3-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  padding: clamp(14px, 1.8vw, 20px) clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
}

.card-v3-head > div {
  min-width: 0;
}

.card-v3-head .eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-v3-head h3 {
  margin: 0;
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-v3-head-actions {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  flex-wrap: wrap;
}

.card-v3-body {
  padding: clamp(16px, 2vw, 24px);
}

/* ═══════════════════════════════════════
   GRID LAYOUTS
   ═══════════════════════════════════════ */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: clamp(16px, 2vw, 24px);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: clamp(12px, 1.5vw, 18px);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: clamp(12px, 1.5vw, 18px);
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: clamp(12px, 1.5vw, 18px);
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 0 clamp(14px, 1.8vw, 22px);
  font-weight: 700;
  font-size: clamp(12px, 1.4vw, 14px);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  transition: all var(--duration-normal) var(--ease-out-expo);
  gap: clamp(4px, 0.5vw, 8px);
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--main-surface-soft);
  color: var(--text);
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out-expo);
}

.btn:hover::after {
  opacity: 1;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.22);
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}

.btn.primary:active {
  transform: translateY(0);
}

.btn.secondary {
  border-color: var(--line);
  background: var(--main-surface);
  color: var(--text-soft);
}

.btn.secondary:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn.secondary.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn.secondary.disabled {
  pointer-events: none;
  opacity: 0.4;
}

.btn.danger {
  border-color: inherit;
  background: var(--main-surface);
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger-soft);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
  padding: 0 clamp(4px, 0.5vw, 8px);
  min-height: auto;
}

.btn.ghost:hover {
  background: var(--main-surface-soft);
  color: var(--text);
}

.btn.sm {
  min-height: 30px;
  padding: 0 clamp(8px, 1vw, 14px);
  font-size: clamp(11px, 1.3vw, 13px);
}

.btn.lg {
  min-height: 44px;
  padding: 0 clamp(18px, 2.2vw, 28px);
  font-size: clamp(14px, 1.6vw, 16px);
}

/* ═══════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════ */

.field-v3 {
  display: grid;
  gap: clamp(4px, 0.5vw, 8px);
  margin-bottom: clamp(12px, 1.5vw, 18px);
}

.field-v3 > label {
  color: var(--text-soft);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: var(--main-surface);
  color: var(--text);
  transition: border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo),
              background var(--duration-fast) var(--ease-out-expo);
  font-family: inherit;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
select:hover,
textarea:hover {
  border-color: rgba(59, 130, 246, 0.5);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: var(--main-surface);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ── Generic input catch-all (supports bare <input> without type=) ── */
input {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: var(--main-surface);
  color: var(--text);
  transition: border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo);
  font-family: inherit;
}

input:hover {
  border-color: rgba(59, 130, 246, 0.5);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Reset special input types to defaults */
input[type="checkbox"],
input[type="radio"],
input[type="submit"],
input[type="button"],
input[type="hidden"] {
  width: auto;
  border: none;
  box-shadow: none;
  height: auto;
  padding: 0;
}

/* Height for non-special inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]) {
  height: clamp(36px, 4.5vw, 44px);
  padding: 0 clamp(10px, 1.2vw, 14px);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
  height: clamp(36px, 4.5vw, 44px);
  padding: 0 clamp(10px, 1.2vw, 14px);
  font-size: clamp(13px, 1.5vw, 15px);
}

textarea {
  min-height: 120px;
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 14px);
  resize: vertical;
  line-height: 1.6;
  font-size: clamp(13px, 1.5vw, 15px);
}

input[readonly] {
  background: var(--main-surface-soft);
  color: var(--text-muted);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Content Slot ── */
.content-slot {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(12px, 1.5vw, 18px);
  min-height: 60px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.content-slot:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* ═══════════════════════════════════════
   CHIP GROUP (芯片选择器)
   ═══════════════════════════════════════ */

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(4px, 0.5vw, 8px);
}

.chip-group label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 clamp(10px, 1.2vw, 16px);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 650;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  user-select: none;
}

.chip-group label:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.chip-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* ═══════════════════════════════════════
   MODE TOGGLE (卡片式切换)
   ═══════════════════════════════════════ */

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: clamp(6px, 0.8vw, 10px);
}

.mode-toggle label {
  min-height: clamp(40px, 5vw, 48px);
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  color: var(--text-soft);
  font-weight: 750;
  font-size: clamp(13px, 1.5vw, 15px);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  position: relative;
}

.mode-toggle label:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-toggle label:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

/* ═══════════════════════════════════════
   EDIT UPLOAD BOX
   ═══════════════════════════════════════ */

.edit-upload-box {
  position: relative;
  min-height: clamp(70px, 8vw, 90px);
  display: grid;
  grid-template-columns: clamp(30px, 3.5vw, 40px) minmax(0, 1fr);
  gap: clamp(8px, 1vw, 12px);
  align-items: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(10px, 1.2vw, 16px) clamp(12px, 1.5vw, 18px);
  background: var(--main-surface-soft);
  transition: all var(--duration-fast) var(--ease-out-expo);
}
.edit-upload-box > :not(input) { pointer-events: none; }

.edit-upload-box:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.edit-upload-box input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.edit-upload-icon {
  width: clamp(30px, 3.5vw, 40px);
  height: clamp(30px, 3.5vw, 40px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 700;
  line-height: 1;
}

.edit-upload-box strong {
  display: block;
  color: var(--text);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 750;
}

.edit-upload-box small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 600;
}

.edit-upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: clamp(4px, 0.5vw, 8px);
  margin-top: clamp(8px, 1vw, 12px);
}

.edit-preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--main-surface-soft);
}

.edit-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-preview-item button {
  position: absolute;
  right: 3px;
  bottom: 3px;
  border: 0;
  border-radius: 4px;
  padding: 2px 5px;
  background: inherit;
  color: #fff;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

/* ═══════════════════════════════════════
   COST HINT
   ═══════════════════════════════════════ */

.cost-hint {
  margin-top: clamp(10px, 1.2vw, 14px);
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 16px);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-size: clamp(12px, 1.4vw, 14px);
  color: var(--text-soft);
  text-align: center;
}

.cost-hint strong {
  color: var(--primary);
  font-weight: 700;
}

/* ═══════════════════════════════════════
   GENERATE ACTIONS
   ═══════════════════════════════════════ */

.generate-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(6px, 0.8vw, 10px);
  margin-top: clamp(8px, 1vw, 12px);
}

/* ═══════════════════════════════════════
   PREVIEW STAGE
   ═══════════════════════════════════════ */

.preview-card {
  display: grid;
  grid-template-rows: auto 1fr;
}

.preview-stage {
  min-height: clamp(280px, 35vw, 420px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, rgba(59, 130, 246, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(59, 130, 246, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(59, 130, 246, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(59, 130, 246, 0.08) 75%),
    transparent;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.preview-stage img {
  width: 100%;
  height: 100%;
  max-height: clamp(400px, 50vw, 600px);
  object-fit: contain;
  background: #fff;
}

.empty-state,
.preview-loading {
  width: min(90%, 400px);
  min-height: clamp(80px, 10vw, 120px);
  display: grid;
  place-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(12px, 1.5vw, 20px);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  text-align: center;
  font-weight: 700;
}

.preview-loading span {
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
}

.preview-error {
  width: min(92%, 500px);
  min-height: clamp(90px, 11vw, 130px);
  display: grid;
  place-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  border: 1px solid inherit;
  border-radius: var(--radius);
  padding: clamp(12px, 1.5vw, 20px);
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
  font-weight: 700;
}

.preview-error span {
  color: inherit;
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.preview-spinner {
  width: clamp(24px, 3vw, 32px);
  height: clamp(24px, 3vw, 32px);
  border: 3px solid inherit;
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════
   HISTORY / RECORDS (图库网格)
   ═══════════════════════════════════════ */

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: clamp(10px, 1.2vw, 16px);
}

.history-list .record-card {
  height: auto;
  min-height: clamp(200px, 25vw, 260px);
  display: grid;
  grid-template-rows: clamp(120px, 15vw, 160px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--main-surface);
  color: inherit;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.history-list .record-card:hover {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.history-list .record-card:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.3);
  outline-offset: 2px;
}

.record-image {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary-soft), var(--main-surface-soft));
  color: var(--text-muted);
  font-weight: 750;
}

.record-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease-out-expo);
}

.record-card:hover .record-image img {
  transform: scale(1.05);
}

.record-body {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: clamp(3px, 0.5vw, 6px);
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 14px);
}

.record-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(6px, 0.8vw, 10px);
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 750;
}

.record-meta span:first-child {
  color: var(--primary);
}

.record-body p {
  max-height: clamp(30px, 4vw, 42px);
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(11px, 1.3vw, 13px);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.record-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(6px, 0.8vw, 10px);
  margin-top: auto;
}

.record-body time {
  overflow: hidden;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-delete {
  min-height: 24px;
  border: 1px solid inherit;
  border-radius: 6px;
  padding: 0 clamp(5px, 0.6vw, 8px);
  background: var(--main-surface);
  color: var(--danger);
  font-size: clamp(9px, 1.1vw, 11px);
  font-weight: 800;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.record-delete:hover {
  background: var(--danger-soft);
}

.record-delete-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  min-width: 0;
}

.history-empty-inline {
  grid-column: 1 / -1;
  min-height: clamp(70px, 8vw, 100px);
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--main-surface-soft);
  font-weight: 700;
}

/* ═════════════════════════════════════
   DIALOGS / OVERLAYS
   ═════════════════════════════════════ */

.redeem-dialog,
.record-dialog,
.generation-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: clamp(16px, 2vw, 24px);
  background: inherit;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.redeem-panel,
.record-dialog-panel {
  width: min(92%, 540px);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--main-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--duration-slow) var(--ease-out-expo) forwards;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.redeem-head,
.record-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  padding: clamp(14px, 1.8vw, 20px) clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
}

.redeem-head .eyebrow,
.record-dialog-head .eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.redeem-head h2,
.record-dialog-head h2 {
  margin: 0;
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.01em;
}

.dialog-close,
.record-dialog-close {
  width: clamp(28px, 3.5vw, 36px);
  height: clamp(28px, 3.5vw, 36px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.dialog-close:hover,
.record-dialog-close:hover {
  background: var(--main-surface-soft);
  color: var(--text);
}

.redeem-form,
.record-dialog-body {
  padding: clamp(16px, 2vw, 24px);
}

.record-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1vw, 12px);
  padding: clamp(12px, 1.5vw, 16px) clamp(16px, 2vw, 24px);
  border-top: 1px solid var(--line);
}

/* ── Record Dialog Inner Elements ── */
.record-full-prompt {
  margin-bottom: clamp(12px, 1.5vw, 18px);
}

.record-full-prompt > span {
  display: block;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.record-full-prompt > p {
  margin: 0;
  font-size: clamp(13px, 1.5vw, 15px);
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}

.record-dialog-image {
  margin-bottom: clamp(12px, 1.5vw, 18px);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--main-surface-soft);
  text-align: center;
}

.record-dialog-image img,
.record-dialog-image video {
  max-width: 100%;
  max-height: clamp(200px, 25vw, 320px);
  object-fit: contain;
  background: var(--main-surface-soft);
  display: block;
  margin: 0 auto;
}

.record-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1vw, 12px);
}

.record-detail-grid > div {
  display: grid;
  gap: 3px;
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--main-surface-soft);
}

.record-detail-grid > div > span {
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.record-detail-grid > div > strong {
  font-size: clamp(14px, 1.7vw, 18px);
  font-weight: 800;
  color: var(--text);
}

.record-detail-grid > div > strong.status {
  font-size: clamp(12px, 1.4vw, 14px);
}

.record-error {
  margin-top: clamp(10px, 1.2vw, 14px);
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.5vw, 16px);
  background: var(--danger-soft);
  border: 1px solid inherit;
  border-radius: var(--radius);
  color: var(--danger);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

/* ── Error Dialog (generation error popup) ── */
.error-dialog-panel {
  width: min(92%, 460px);
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--main-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--duration-slow) var(--ease-out-expo) forwards;
}

.error-dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(16px, 2vw, 24px) clamp(18px, 2.2vw, 28px);
  border-bottom: 1px solid var(--line);
  color: var(--danger);
}

.error-dialog-head svg {
  width: clamp(20px, 2.5vw, 28px);
  height: clamp(20px, 2.5vw, 28px);
  flex-shrink: 0;
}

.error-dialog-head h2 {
  margin: 0;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 800;
  color: var(--text);
}

.error-dialog-body {
  padding: clamp(16px, 2vw, 24px) clamp(18px, 2.2vw, 28px);
  color: var(--text);
  font-size: clamp(13px, 1.5vw, 15px);
  line-height: 1.6;
  word-break: break-word;
}

.error-dialog-foot {
  display: flex;
  justify-content: flex-end;
  padding: clamp(12px, 1.5vw, 16px) clamp(18px, 2.2vw, 28px);
  border-top: 1px solid var(--line);
}

/* ═════════════════════════════════════
   TABLES
   ═════════════════════════════════════ */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table-v3 {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--main-surface);
}

/* ═════════════════════════════════════
   PAGINATION
   ═════════════════════════════════════ */

.pagination,
.pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1vw, 14px);
  margin-top: clamp(16px, 2vw, 24px);
}

.pagination span,
.pages span {
  color: var(--text-muted);
  font-weight: 650;
  font-size: clamp(12px, 1.4vw, 14px);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 clamp(12px, 1.5vw, 18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.page-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.page-btn.active {
  pointer-events: none;
  opacity: 0.5;
}

/* ═════════════════════════════════════
   STATUS BADGES
   ═════════════════════════════════════ */

.status-badge,
.badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  padding: 0 clamp(8px, 1vw, 12px);
  background: var(--main-surface-soft);
  color: var(--text-soft);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-badge.succeeded,
.badge.success {
  background: var(--success-soft);
  color: inherit;
  border-color: inherit;
}

.status-badge.failed,
.badge.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: inherit;
}

.status-badge.running,
.status-badge.queued,
.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: inherit;
}

.status-badge.deleted,
.badge.deleted {
  background: var(--main-surface-soft);
  color: var(--text-muted);
  border-color: var(--line-strong);
}

/* ═════════════════════════════════════
   ALERTS & MESSAGES
   ═════════════════════════════════════ */

.alert,
.inline-message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.5vw, 16px);
  background: var(--main-surface);
  color: var(--text-soft);
  font-weight: 650;
}

.inline-message {
  margin-top: clamp(12px, 1.5vw, 18px);
}

.alert.error,
.inline-message.error {
  border-color: inherit;
  background: var(--danger-soft);
  color: var(--danger);
}

.alert.success,
.inline-message.success {
  border-color: inherit;
  background: var(--success-soft);
  color: inherit;
}

.alert.warning,
.inline-message.warning {
  border-color: inherit;
  background: var(--warning-soft);
  color: var(--warning);
}

.generation-notice {
  margin-bottom: clamp(12px, 1.5vw, 18px);
  border: 1px solid inherit;
  border-radius: var(--radius);
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.5vw, 16px);
  background: var(--warning-soft);
  color: inherit;
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  line-height: 1.6;
}

/* ═════════════════════════════════════
   SHOP GRID (商城一排3个)
   ═════════════════════════════════════ */

.grid-3cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2vw, 24px);
}

@media (max-width: 960px) {
  .grid-3cols { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .grid-3cols { grid-template-columns: 1fr; }
}

/* ═════════════════════════════════════
   PRICE CARD (商城套餐)
   ═════════════════════════════════════ */

.price-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.price-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.5);
}

.price-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.price-card.featured:hover {
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-elevated);
}

.package-badge {
  position: absolute;
  top: clamp(10px, 1.2vw, 14px);
  right: clamp(10px, 1.2vw, 14px);
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 clamp(8px, 1vw, 12px);
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.package-body {
  display: grid;
  gap: clamp(12px, 1.5vw, 18px);
  padding: clamp(18px, 2.2vw, 26px) clamp(18px, 2.2vw, 26px) clamp(16px, 2vw, 24px);
  text-align: center;
}

.package-head h3 {
  margin: 0;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.package-desc {
  margin: clamp(4px, 0.5vw, 8px) 0 0;
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  line-height: 1.5;
}

.price-amount {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.package-credits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.5vw, 8px);
  padding: clamp(6px, 0.8vw, 10px) clamp(12px, 1.5vw, 18px);
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
}

.package-credits strong {
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 800;
}

.package-buy-btn {
  margin-top: clamp(4px, 0.5vw, 8px);
}

/* ═════════════════════════════════════
   BUY SUMMARY (购买确认)
   ═════════════════════════════════════ */

.buy-summary {
  display: grid;
  gap: clamp(8px, 1vw, 14px);
  margin-bottom: clamp(14px, 1.8vw, 20px);
}

.buy-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(8px, 1vw, 12px) clamp(12px, 1.5vw, 16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface-soft);
}

.buy-summary-row span {
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
}

.buy-summary-row strong {
  color: var(--text);
  font-size: clamp(13px, 1.6vw, 17px);
  font-weight: 800;
}

.buy-summary-row.total {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.buy-summary-row.total span {
  color: var(--primary-dark);
}

.buy-summary-row.total strong {
  color: var(--primary-dark);
  font-size: clamp(17px, 2.2vw, 23px);
}

.pay-type-select {
  margin-bottom: clamp(8px, 1vw, 14px);
}

.pay-type-select .field-hint {
  display: block;
  margin-bottom: clamp(6px, 0.8vw, 10px);
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
}

.pay-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: clamp(6px, 0.8vw, 10px);
}

.pay-type-item {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(38px, 4.5vw, 46px);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  color: var(--text-soft);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.pay-type-item:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.pay-type-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pay-type-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* ═════════════════════════════════════
   EMPTY STATE
   ═════════════════════════════════════ */

.empty-state {
  display: grid;
  place-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  padding: clamp(30px, 4vw, 50px) clamp(20px, 2.5vw, 32px);
  text-align: center;
}

.empty-state .icon {
  font-size: clamp(36px, 4.5vw, 52px);
  line-height: 1;
}

.empty-state h3 {
  margin: 0;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  line-height: 1.5;
}

/* ═════════════════════════════════════
   PROMPT OPTIMIZE BAR
   ═════════════════════════════════════ */

.prompt-optimize-bar {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  margin-top: clamp(4px, 0.5vw, 8px);
}

.prompt-optimize-bar .hint {
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
}

/* ═════════════════════════════════════
   CHAT LAYOUT (AI对话界面)
   ═════════════════════════════════════ */

.chat-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ── Chat Sidebar ── */
.chat-sidebar {
  width: clamp(260px, 30vw, 340px);
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
}

.chat-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(12px, 1.5vw, 18px) clamp(14px, 1.8vw, 22px);
  border-bottom: 1px solid var(--sidebar-border);
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  min-width: 0;
  color: var(--sidebar-text-hover);
}

.chat-sidebar-header svg {
  flex-shrink: 0;
}

.chat-sidebar-title {
  font-size: clamp(13px, 1.6vw, 17px);
  font-weight: 800;
  color: var(--sidebar-text-hover);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-new-btn {
  width: clamp(32px, 4vw, 40px);
  height: clamp(32px, 4vw, 40px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--sidebar-accent-glow);
  color: var(--sidebar-accent);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  flex-shrink: 0;
}

.chat-new-btn:hover {
  background: var(--sidebar-accent);
  color: #fff;
  transform: scale(1.05);
}

.chat-new-btn svg {
  width: clamp(16px, 2vw, 20px);
  height: clamp(16px, 2vw, 20px);
}

.chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: clamp(6px, 0.8vw, 10px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-sidebar-list::-webkit-scrollbar {
  width: 4px;
}

.chat-sidebar-list::-webkit-scrollbar-thumb {
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
}

.chat-sidebar-empty {
  display: grid;
  place-items: center;
  padding: clamp(30px, 4vw, 50px) clamp(16px, 2vw, 24px);
  color: var(--sidebar-text);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600);
  text-align: center;
}

.chat-conv-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.5vw, 18px);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  min-width: 0;
}

.chat-conv-item:hover {
  background: var(--sidebar-accent-glow);
}

.chat-conv-item.active {
  background: var(--sidebar-accent-glow);
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}

.chat-conv-title {
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  color: var(--sidebar-text-hover);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(6px, 0.8vw, 10px);
  font-size: clamp(10px, 1.2vw, 12px);
  color: var(--sidebar-text);
  font-weight: 600;
}

.chat-conv-count {
  white-space: nowrap;
}

.chat-sidebar-user {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  padding: clamp(10px, 1.2vw, 14px) clamp(14px, 1.8vw, 18px);
  border-top: 1px solid var(--sidebar-border);
  min-width: 0;
}

.chat-sidebar-avatar {
  width: clamp(28px, 3.5vw, 36px);
  height: clamp(28px, 3.5vw, 36px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 800;
  flex-shrink: 0;
}

.chat-sidebar-uname {
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  color: var(--sidebar-text-hover);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Chat Main ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--main-bg);
  overflow: hidden;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  padding: clamp(10px, 1.2vw, 14px) clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--main-surface);
  flex-shrink: 0;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  min-width: 0;
}

.chat-topbar-left svg {
  flex-shrink: 0;
  color: var(--primary);
}

.chat-topbar-title {
  font-size: clamp(14px, 1.7vw, 18px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
}

.chat-balance {
  display: inline-flex;
  align-items: center;
  gap: clamp(4px, 0.6vw, 8px);
  padding: clamp(4px, 0.6vw, 8px) clamp(8px, 1vw, 14px);
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-decoration: none;
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.chat-balance:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

.chat-balance-num {
  font-weight: 800;
  color: var(--primary);
}

.chat-balance-label {
  color: var(--text-soft);
  font-weight: 600;
}

/* ── Chat Messages ── */
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: clamp(16px, 2vw, 24px) clamp(16px, 2vw, 32px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.5vw, 20px);
}

.chat-msgs::-webkit-scrollbar {
  width: 6px;
}

.chat-msgs::-webkit-scrollbar-thumb {
  border-radius: var(--radius-full);
  background: inherit;
}

.chat-welcome {
  display: grid;
  place-items: center;
  text-align: center;
  padding: clamp(40px, 5vw, 60px) clamp(20px, 2.5vw, 32px);
  gap: clamp(8px, 1vw, 14px);
}

.chat-welcome-icon {
  width: clamp(60px, 7vw, 80px);
  height: clamp(60px, 7vw, 80px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--primary-soft);
  color: var(--primary);
}

.chat-welcome-icon svg {
  width: clamp(30px, 3.5vw, 40px);
  height: clamp(30px, 3.5vw, 40px);
}

.chat-welcome-heading {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.chat-welcome-text {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 600;
  line-height: 1.5;
}

.chat-welcome-text strong {
  color: var(--primary);
  font-weight: 800;
}

/* ── Chat Message Bubbles ── */
.chat-msg {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  max-width: min(92%, 780px);
  animation: msgFadeIn var(--duration-normal) var(--ease-out-expo);
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-ai {
  align-self: flex-start;
}

.chat-msg-err {
  align-self: center;
  max-width: min(92%, 600px);
}

.chat-msg-avatar {
  width: clamp(32px, 4vw, 40px);
  height: clamp(32px, 4vw, 40px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 800;
}

.chat-msg-user .chat-msg-avatar {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
}

.chat-msg-ai .chat-msg-avatar {
  background: var(--primary-soft);
  color: var(--primary);
}

.chat-msg-err .chat-msg-avatar {
  background: var(--danger-soft);
  color: var(--danger);
}

.chat-msg-body {
  padding: clamp(10px, 1.2vw, 14px) clamp(14px, 1.8vw, 20px);
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: clamp(13px, 1.5vw, 15px);
  word-break: break-word;
}

.chat-msg-user .chat-msg-body {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-ai .chat-msg-body {
  background: var(--main-surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.chat-msg-err .chat-msg-body {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid inherit;
}

/* ── Typing Indicator ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: clamp(10px, 1.2vw, 14px) clamp(14px, 1.8vw, 20px);
}

.chat-typing .dot {
  width: clamp(6px, 0.8vw, 8px);
  height: clamp(6px, 0.8vw, 8px);
  border-radius: var(--radius-full);
  background: var(--primary);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.chat-typing .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing .dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Chat Footer ── */
.chat-foot {
  padding: clamp(10px, 1.2vw, 16px) clamp(16px, 2vw, 24px);
  background: var(--main-surface);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.chat-foot-inner {
  max-width: 820px;
  margin: 0 auto;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 0.8vw, 10px);
  padding: clamp(6px, 0.8vw, 10px) clamp(12px, 1.5vw, 18px);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  transition: border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo);
}

.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  min-height: clamp(20px, 2.5vw, 24px);
  max-height: 160px;
  padding: 0;
  font-family: inherit;
  font-size: clamp(13px, 1.5vw, 15px);
  line-height: 1.5;
  color: var(--text);
  background: transparent;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: clamp(34px, 4.2vw, 42px);
  height: clamp(34px, 4.2vw, 42px);
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn.sending {
  background: var(--primary-dark);
  pointer-events: none;
}

.chat-send-btn svg {
  width: clamp(16px, 2vw, 20px);
  height: clamp(16px, 2vw, 20px);
}

.chat-foot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1vw, 14px);
  margin-top: clamp(6px, 0.8vw, 10px);
  font-size: clamp(11px, 1.3vw, 13px);
  color: var(--text-muted);
  font-weight: 600;
}

.chat-model-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--main-surface-soft);
  color: var(--text-soft);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 650;
}

.chat-model-tag svg {
  flex-shrink: 0;
}

.chat-model-picker {
  border: none;
  outline: none;
  background: transparent;
  color: var(--primary);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.chat-cost-tag {
  color: var(--text-muted);
  font-weight: 650;
}
/* ══════════════════════════════════════�?   FIX: Missing Styles �?UI Fix Patch v1
   ══════════════════════════════════════�?*/

/* ── .form (form base) ── */
.form {
  display: grid;
  gap: clamp(12px, 1.5vw, 18px);
}

/* ── .section-card ── */
.card.section-card,
.section-card {
  margin-top: 20px;
}

/* ── .field-grid ── */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 1.2vw, 16px);
}

/* ── .model-chip ── */
.model-chip select {
  width: 100%;
  min-width: 0;
}

/* ── .tabs / .tab ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--main-surface-soft);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 clamp(10px, 1.2vw, 16px);
  border-radius: 8px;
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.tab:hover {
  color: var(--primary);
  background: var(--main-surface);
}

.tab.active {
  color: var(--primary);
  background: var(--main-surface);
  box-shadow: var(--shadow-xs);
}

/* ── .pagination / .pages / .page-btn ── */
.pagination,
.pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(14px, 1.8vw, 20px);
}

.pagination span,
.pages span {
  color: var(--text-muted);
  font-weight: 650;
  font-size: clamp(12px, 1.4vw, 14px);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 clamp(12px, 1.5vw, 18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.page-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.page-btn.active {
  pointer-events: none;
  opacity: 0.5;
}

/* ── .media-card (图库卡片) ── */
.media-card {
  display: grid;
  grid-template-rows: clamp(130px, 16vw, 180px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  color: inherit;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.media-card:hover {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.media-card > img,
.media-card > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s var(--ease-out-expo);
}

.media-card:hover > img,
.media-card:hover > video {
  transform: scale(1.05);
}

/* ── .media-card-body, .media-card .prompt, .media-card .meta ── */
.media-card-body {
  display: grid;
  gap: clamp(3px, 0.5vw, 6px);
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 14px);
  min-width: 0;
}

.media-card .prompt {
  font-size: clamp(11px, 1.3vw, 13px);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: clamp(30px, 4vw, 42px);
}

.media-card .meta {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 8px);
  font-size: clamp(10px, 1.2vw, 12px);
  color: var(--text-muted);
  font-weight: 600;
  flex-wrap: wrap;
}

.media-card .meta .status-badge {
  flex-shrink: 0;
}

/* ── .muted (略淡文本) ── */
.muted {
  color: var(--text-muted);
}

/* ── .price-card (商城) ── */
.price-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  padding: clamp(20px, 2.5vw, 28px) clamp(22px, 2.8vw, 32px);
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.price-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.5);
}

.price-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
  position: relative;
}

.price-card.featured::before {
  content: '推荐';
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.price-card .name {
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: clamp(4px, 0.5vw, 8px);
}

.price-card .desc {
  font-size: clamp(12px, 1.4vw, 14px);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: clamp(12px, 1.5vw, 18px);
  line-height: 1.5;
}

.price-card .price {
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: clamp(6px, 0.8vw, 10px);
}

.price-card .credits {
  display: inline-flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 8px);
  padding: clamp(6px, 0.8vw, 10px) clamp(12px, 1.5vw, 18px);
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 700;
  margin-bottom: clamp(12px, 1.5vw, 18px);
}

.price-card .credits strong {
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 800;
}

.price-card .btn {
  width: 100%;
}

/* ── User Center (uc-*) ── */
.uc-section {
  margin-bottom: clamp(16px, 2vw, 24px);
}

.uc-header {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.5vw, 20px);
  min-width: 0;
}

.uc-avatar {
  width: clamp(56px, 7vw, 80px);
  height: clamp(56px, 7vw, 80px);
  display: grid;
  place-items: center;
  border-radius: clamp(14px, 1.8vw, 22px);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 800;
  flex-shrink: 0;
}

.uc-header-info {
  min-width: 0;
}

.uc-header-info h2 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.uc-header-info p {
  margin: clamp(2px, 0.3vw, 4px) 0 0;
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
}

.uc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: clamp(10px, 1.2vw, 16px);
}

.uc-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(12px, 1.5vw, 18px) clamp(14px, 1.8vw, 20px);
  background: var(--main-surface);
  text-align: center;
}

.uc-stat .num {
  display: block;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.uc-stat .label {
  display: block;
  margin-top: clamp(2px, 0.3vw, 4px);
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
}

.uc-step {
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
}

/* ── Upload Card / Grid ── */
.upload-card {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: clamp(16px, 2vw, 24px);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.upload-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 100px), 1fr));
  gap: clamp(6px, 0.8vw, 10px);
}

/* ── No Image ── */
.no-img {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--main-surface-soft);
  color: var(--text-muted);
  font-weight: 700;
  font-size: clamp(11px, 1.3vw, 13px);
  border-radius: var(--radius-sm);
}

/* ── Setup / Auth ── */
.setup-card,
.auth-card {
  width: min(92%, 440px);
  margin: clamp(40px, 6vw, 80px) auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.setup-section {
  padding: clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
}

.setup-section:last-child {
  border-bottom: 0;
}

.setup-form {
  display: grid;
  gap: clamp(12px, 1.5vw, 18px);
}

.auth-card-head {
  padding: clamp(20px, 2.5vw, 30px) clamp(22px, 2.8vw, 32px) clamp(12px, 1.5vw, 18px);
  text-align: center;
}

.auth-card-head h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-card-head p {
  margin: clamp(4px, 0.5vw, 8px) 0 0;
  color: var(--text-muted);
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 600;
}

.auth-switch {
  text-align: center;
  margin-top: clamp(12px, 1.5vw, 18px);
  color: var(--text-muted);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
}


/* ── Server Flash ── */
.server-flash {
  margin-bottom: clamp(12px, 1.5vw, 18px);
  padding: clamp(10px, 1.2vw, 14px) clamp(12px, 1.5vw, 18px);
  border-radius: var(--radius);
  background: var(--success-soft);
  color: inherit;
  border: 1px solid inherit;
  font-weight: 650;
  font-size: clamp(12px, 1.4vw, 14px);
}

.server-flash.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: inherit;
}

/* ── Switch Toggle ── */
.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--line-strong);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out-expo);
  flex-shrink: 0;
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.switch:has(input:checked) { background: var(--primary); }

.switch.active { background: var(--primary); }

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-out-expo);
  z-index: 0;
}

.switch:has(input:checked) .switch-knob { transform: translateX(20px); }
.switch.active .switch-knob { transform: translateX(20px); }

/* ── Small utility ── */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(11px, 1.3vw, 13px);
  background: var(--main-surface-soft);
  padding: 0 4px;
  border-radius: 4px;
}

pre code {
  background: transparent;
  padding: 0;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.wide {
  width: 100%;
}

/* ── User Identity ── */
.user-identity {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.user-identity strong {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity > span {
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 650;
}

/* ══════════════════════════════════════�?   RESPONSIVE MEDIA QUERIES
   ══════════════════════════════════════�?*/

/* ——— ADMIN NAV BAR ——— */

.admin-nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: clamp(16px, 2vw, 24px);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.admin-nav-bar a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 clamp(10px, 1.2vw, 16px);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.admin-nav-bar a:hover {
  border-color: var(--line);
  background: var(--main-surface-soft);
  color: var(--text);
}

.admin-nav-bar a.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

/* Tablet & Small Desktop */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open,
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main-area {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: grid;
  }

  .sidebar-overlay.is-visible {
    display: block;
  }

  .chat-layout {
    height: calc(100vh - 52px);
  }

  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 52px;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out-expo);
  }

  .chat-sidebar.is-open {
    transform: translateX(0);
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .main-area {
    padding: 16px 14px;
  }

  .page-auth .main-area {
    padding: 16px;
  }

  .page-hd {
    flex-direction: column;
    align-items: flex-start;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto {
    grid-template-columns: 1fr;
  }

  .card-v3-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chat-foot-inner {
    padding: 0;
  }

  .table-wrap {
    font-size: 12px;
  }

  .pagination,
  .pages {
    flex-wrap: wrap;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .record-detail-grid {
    grid-template-columns: 1fr;
  }

  .history-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  select {
    font-size: 16px;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  .center-auth-panel {
    border-radius: 20px;
  }

  .center-auth-body {
    padding: 0 clamp(16px, 4vw, 24px) clamp(20px, 4vw, 28px);
  }
}

/* Tablet admin-nav-bar */
@media (max-width: 1024px) {
  .admin-nav-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 8px;
  }
  .admin-nav-bar::-webkit-scrollbar { display: none; }
  .admin-nav-bar a { flex-shrink: 0; }
}

/* Mobile admin-nav-bar with fade edge */
@media (max-width: 640px) {
  .admin-nav-bar {
    mask-image: linear-gradient(to right, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
  }
  .admin-nav-bar a {
    min-height: 34px;
    padding: 0 14px;
    font-size: 13px;
    border: 1px solid var(--line);
  }
  .admin-nav-bar a:hover,
  .admin-nav-bar a.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
  }
}

/* Large Desktop */
@media (min-width: 1440px) {
  .main-area {
    padding: 32px 48px;
  }

  .page-auth .main-area {
    padding: clamp(18px, 3vw, 40px);
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ══════════════════════════════════════�?   ANIMATION PREFERENCE
   ══════════════════════════════════════�?*/

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ══════════════════════════════════════�?   PRINT STYLES
   ══════════════════════════════════════�?*/

@media print {
  .sidebar,
  .sidebar-toggle,
  .sidebar-overlay,
  .chat-sidebar,
  .chat-foot,
  .btn,
  .record-delete-form {
    display: none !important;
  }

  .main-area {
    margin-left: 0;
    padding: 0;
  }

  .card-v3,
  .price-card,
  .history-list .record-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ── Generic UI Components (from admin.css) ── */
/* ── .button (Admin alias for .btn) ── */
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 0 clamp(14px, 1.8vw, 22px);
  font-weight: 700;
  font-size: clamp(12px, 1.4vw, 14px);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  transition: all var(--duration-normal) var(--ease-out-expo);
  gap: clamp(4px, 0.5vw, 8px);
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.button.primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.22);
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}

.button.primary:active {
  transform: translateY(0);
}

.button.secondary {
  border-color: var(--line);
  background: var(--main-surface);
  color: var(--text-soft);
}

.button.secondary:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.button.danger {
  border-color: inherit;
  background: var(--main-surface);
  color: var(--danger);
}

.button.danger:hover {
  background: var(--danger-soft);
}

.button.small {
  min-height: 30px;
  padding: 0 clamp(8px, 1vw, 14px);
  font-size: clamp(11px, 1.3vw, 13px);
}

.button.disabled {
  pointer-events: none;
  opacity: 0.4;
}

/* ── .card / .card-head (Admin card) ── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  padding: clamp(18px, 2.2vw, 26px);
  transition: box-shadow var(--duration-normal) var(--ease-out-expo);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  margin-bottom: clamp(14px, 1.8vw, 22px);
  min-height: 40px;
}

.card-head h3 {
  margin: 0;
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card.section-card,
.section-card {
  margin-top: clamp(16px, 2vw, 24px);
}

.card.code-create-card,
.code-create-card {
  margin-top: clamp(16px, 2vw, 24px);
}

.card.auth-card {
  max-width: 440px;
  margin: 0 auto;
}

.card.auth-card.wide {
  max-width: 600px;
}

/* ── .field (Admin form field) ── */
.field {
  display: grid;
  gap: clamp(4px, 0.5vw, 8px);
  margin-bottom: clamp(12px, 1.5vw, 18px);
}

.field > label,
.field > span,
.field > .field-label {
  color: var(--text-soft);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.field-hint {
  display: block;
  color: var(--text-muted);
  font-size: clamp(10px, 1.2vw, 12px);
  font-weight: 600;
  line-height: 1.5;
}

/* ── .page-admin ── */
.page-admin {
  background: var(--main-bg);
}

/* ── .is-deleted (table row) ── */
.is-deleted td,
tr.is-deleted td {
  background: inherit;
  color: var(--text-muted);
}

.deleted-time {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

/* ── .orphan-table (uploads orphan cleanup) ── */
.orphan-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: clamp(10px, 1.2vw, 14px);
}

.orphan-table th,
.orphan-table td {
  border-bottom: 1px solid var(--line);
  padding: clamp(6px, 0.8vw, 10px) clamp(8px, 1vw, 12px);
  text-align: left;
  font-size: clamp(11px, 1.3vw, 13px);
}

.orphan-table th {
  background: var(--main-surface-soft);
  color: var(--text-muted);
  font-weight: 800;
  font-size: clamp(10px, 1.2vw, 12px);
}

/* ── .stat (inline stats) ── */
.stat {
  color: var(--text);
  font-weight: 800;
  font-size: clamp(13px, 1.6vw, 17px);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: clamp(12px, 1.5vw, 20px);
  right: clamp(12px, 1.5vw, 20px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: clamp(10px, 1.2vw, 14px) clamp(14px, 1.8vw, 20px);
  border-radius: var(--radius);
  background: var(--main-surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 700;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn var(--duration-normal) var(--ease-out-expo);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success {
  border-color: inherit;
  background: var(--success-soft);
  color: inherit;
}

.toast.error {
  border-color: inherit;
  background: var(--danger-soft);
  color: var(--danger);
}

.toast.warning {
  border-color: inherit;
  background: var(--warning-soft);
  color: var(--warning);
}

.toast-leave {
  animation: toastOut var(--duration-fast) var(--ease-out-expo) forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ── Center Auth ── */
.page-auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 2vw, 24px);
  background:
    radial-gradient(circle at 20% 18%, rgba(59, 130, 246, 0.12) 0%, transparent 42%),
    radial-gradient(circle at 82% 82%, rgba(52, 211, 153, 0.08) 0%, transparent 40%),
    linear-gradient(135deg, #fefcf5, #eef3fe);
}

/* Auth pages: override sidebar layout so the card centers correctly */
.page-auth .app-layout {
  display: flex;
  width: 100%;
  min-height: 100dvh;
}

.page-auth .main-area {
  width: 100%;
  min-height: 100dvh;
  margin-left: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.center-auth-page {
  width: min(92vw, 430px);
  margin: 0 auto;
}

.center-auth-page.center-auth-register {
  width: min(94vw, 470px);
}

.center-auth-panel {
  position: relative;
  border: 1px solid oklch(100% 0% 0% / 0.65);
  border-radius: clamp(22px, 3vw, 30px);
  background: oklch(100% 0% 0% / 0.94);
  box-shadow: 0 24px 70px oklch(18% 8% 264 / 0.16), inset 0 1px 0 oklch(100% 0% 0% / 0.8);
  overflow: hidden;
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.center-auth-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary), var(--success));
}

.center-auth-top {
  padding: clamp(24px, 3vw, 36px) clamp(24px, 3vw, 36px) clamp(16px, 2vw, 24px);
  text-align: center;
}

.center-auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: clamp(14px, 1.8vw, 22px);
  color: var(--text);
  text-decoration: none;
}

.center-auth-brand:hover {
  color: var(--text);
}

.center-auth-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, oklch(96% 8% 245), oklch(100% 0% 0%));
  box-shadow: 0 12px 30px oklch(55% 38% 245 / 0.18);
}

.center-auth-brand strong {
  display: block;
  font-size: clamp(17px, 2.2vw, 22px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.center-auth-brand small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 600;
}

.center-auth-brand svg {
  width: 40px;
  height: 40px;
}

.center-auth-brand .icon-frame,
.center-auth-brand .icon-line,
.center-auth-brand .icon-dot {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.center-auth-brand .ai-spark {
  fill: oklch(55% 38% 245 / 0.7);
  stroke: var(--primary);
  stroke-width: 0.6;
}

.center-auth-brand .ai-spark.small {
  fill: var(--primary);
  stroke: none;
}

.center-auth-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--main-surface-soft);
  margin-bottom: clamp(16px, 2vw, 24px);
}

.center-auth-tabs a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 700;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.center-auth-tabs a:hover {
  color: var(--primary);
}

.center-auth-tabs a.active {
  color: var(--primary);
  background: var(--main-surface);
  box-shadow: var(--shadow-xs);
}

.center-auth-body {
  padding: 0 clamp(24px, 3vw, 36px) clamp(26px, 3.2vw, 38px);
}

.center-auth-form {
  display: grid;
  gap: clamp(13px, 1.5vw, 18px);
}

.center-auth-field {
  display: grid;
  gap: clamp(6px, 0.7vw, 9px);
  text-align: left;
}

.center-auth-field > span {
  color: var(--text-soft);
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 750;
}

.center-auth-field input,
.center-auth-field select {
  width: 100%;
  min-width: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 clamp(12px, 1.4vw, 16px);
  height: clamp(42px, 4.8vw, 48px);
  font-size: clamp(13px, 1.5vw, 15px);
  outline: none;
  background: oklch(100% 0% 0%);
  color: var(--text);
  box-shadow: inset 0 1px 2px oklch(18% 8% 264 / 0.04);
  transition: border-color var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) var(--ease-out-expo), background var(--duration-fast) var(--ease-out-expo);
}

.center-auth-field input::placeholder {
  color: oklch(66% 8% 264);
}

.center-auth-field input:focus,
.center-auth-field select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px oklch(55% 38% 245 / 0.12), inset 0 1px 2px oklch(18% 8% 264 / 0.03);
}

.center-auth-submit {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  padding: 0 22px;
  font-size: clamp(14px, 1.6vw, 16px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 10px 24px oklch(55% 38% 245 / 0.26);
  cursor: pointer;
  transition: transform var(--duration-normal) var(--ease-out-expo), box-shadow var(--duration-normal) var(--ease-out-expo), background var(--duration-normal) var(--ease-out-expo);
  margin-top: clamp(4px, 0.5vw, 8px);
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

.center-auth-submit:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 14px 30px oklch(55% 38% 245 / 0.32);
  transform: translateY(-1px);
}

.center-auth-submit:active {
  transform: scale(0.98);
}

.center-auth-submit:focus-visible,
.center-auth-tabs a:focus-visible,
.auth-switch a:focus-visible {
  outline: 3px solid oklch(55% 38% 245 / 0.24);
  outline-offset: 3px;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-muted);
  line-height: 1.7;
}

.auth-switch a {
  font-weight: 800;
  color: var(--primary);
}

/* ── Page Notice Overlay ── */
.page-notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: clamp(16px, 2vw, 24px);
  background: inherit;
  backdrop-filter: blur(8px);
}

.page-notice-panel {
  width: min(92%, 560px);
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--main-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.page-notice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 2vw, 24px) clamp(18px, 2.2vw, 28px);
  border-bottom: 1px solid var(--line);
}

.page-notice-head h2 {
  margin: 0;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 800;
}

.page-notice-body {
  padding: clamp(16px, 2vw, 24px) clamp(18px, 2.2vw, 28px);
  font-size: clamp(13px, 1.5vw, 15px);
  line-height: 1.7;
}

/* ── Auth Wrap (switch toggle for settings) ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.2vw, 16px);
  min-height: 100dvh;
  padding: 24px;
}

/* ── Grid (admin generic) ── */
.grid {
  display: grid;
  gap: clamp(16px, 2vw, 24px);
}

/* ── Canvas node inline controls ── */
.canvas-stage-shell {
  height: min(82dvh, 980px);
  min-height: 720px;
  overflow: hidden;
  position: relative;
}

.canvas-stage {
  background:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    var(--main-bg);
  background-size: 28px 28px;
  cursor: grab;
  height: 100%;
  min-height: 720px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
}

.canvas-stage:active {
  cursor: grabbing;
}

.canvas-grid,
.canvas-edges,
.canvas-node-layer,
.canvas-items,
.canvas-selection {
  height: 500%;
  inset: 0;
  min-height: 3600px;
  position: absolute;
  transform: translate(var(--canvas-x, 0), var(--canvas-y, 0)) scale(var(--canvas-scale, 1));
  transform-origin: 0 0;
  width: 500%;
}

.canvas-stage-wrap.is-immersive,
.canvas-stage-wrap:fullscreen {
  background: var(--main-bg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  inset: 0;
  padding: 14px;
  position: fixed;
  z-index: 100000;
}

.canvas-stage-wrap.is-immersive .canvas-stage-shell,
.canvas-stage-wrap:fullscreen .canvas-stage-shell {
  height: calc(100dvh - 84px);
  min-height: 0;
}

.canvas-grid {
  pointer-events: none;
  z-index: 1;
}

.canvas-edges {
  overflow: visible;
  pointer-events: auto;
  z-index: 2;
}

.canvas-edge-path {
  pointer-events: none;
}

.canvas-edge-hit {
  cursor: pointer;
  pointer-events: stroke;
}

.canvas-items {
  pointer-events: none;
  z-index: 3;
}

.canvas-node-layer {
  pointer-events: none;
  z-index: 4;
}

.canvas-selection {
  border: 1px solid color-mix(in oklch, var(--primary) 72%, white);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.16) inset;
  height: auto;
  min-height: 0;
  pointer-events: none;
  transform: translate(var(--canvas-x, 0), var(--canvas-y, 0)) scale(var(--canvas-scale, 1));
  transform-origin: 0 0;
  width: auto;
  z-index: 5;
}

.canvas-item {
  position: absolute;
}

.canvas-item img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.canvas-node-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in oklch, var(--main-surface) 92%, transparent);
  box-shadow: var(--shadow-card);
  color: var(--text);
  cursor: grab;
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 12px;
  position: absolute;
  pointer-events: auto;
  text-align: left;
  touch-action: none;
  user-select: none;
}

.canvas-node-card.dragging {
  cursor: grabbing;
}

.canvas-node-card.active {
  border-color: color-mix(in oklch, var(--primary) 62%, var(--line));
  box-shadow: 0 16px 34px color-mix(in oklch, var(--primary) 16%, transparent);
}

.canvas-node-head {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.canvas-node-title-input {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  min-width: 0;
  padding: 4px 6px;
}

.canvas-node-title-input:focus {
  background: var(--main-surface);
  border-color: color-mix(in oklch, var(--primary) 58%, var(--line));
  outline: none;
}

.canvas-node-delete-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--main-surface);
  color: var(--danger);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  padding: 4px 7px;
}

.canvas-node-delete-btn:hover {
  background: var(--danger-soft);
}

.canvas-stage.is-panning,
.canvas-stage.is-panning .canvas-node-card {
  cursor: grabbing;
}

.canvas-edge-path.is-draft {
  pointer-events: none;
}

.canvas-edge-path.is-running {
  animation: canvasEdgeFlow 0.9s linear infinite;
  stroke: color-mix(in oklch, var(--primary) 72%, #14b8a6);
  stroke-dasharray: 10 8;
  stroke-width: 4;
}

@keyframes canvasEdgeFlow {
  to { stroke-dashoffset: -36; }
}

.canvas-port {
  align-items: center;
  color: var(--text-muted);
  cursor: crosshair;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 6px;
  transition: transform .14s ease, color .14s ease;
}

.canvas-port:hover,
.canvas-port:focus-within {
  color: var(--primary);
  transform: scale(1.04);
}

.canvas-port-dot {
  background: color-mix(in oklch, var(--primary) 74%, white);
  border: 2px solid color-mix(in oklch, var(--main-surface) 45%, var(--primary));
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.28);
  flex: 0 0 12px;
  height: 12px;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
  width: 12px;
}

.canvas-port:hover .canvas-port-dot,
.canvas-port:focus-within .canvas-port-dot {
  background: color-mix(in oklch, var(--primary) 88%, white);
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.18);
  transform: scale(1.18);
}

.canvas-port.input {
  justify-content: flex-start;
}

.canvas-port.output {
  justify-content: flex-end;
}

.canvas-port.output .canvas-port-dot {
  order: 2;
}

.canvas-node-inline-text,
.canvas-node-provider select,
.canvas-node-provider input,
.canvas-node-provider textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--main-surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 8px 10px;
  resize: vertical;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
  user-select: text;
}

.canvas-node-inline-text {
  cursor: text;
}

.canvas-node-inline-text:hover,
.canvas-node-inline-text:focus,
.canvas-node-provider select:hover,
.canvas-node-provider select:focus,
.canvas-node-provider input:hover,
.canvas-node-provider input:focus,
.canvas-node-provider textarea:hover,
.canvas-node-provider textarea:focus {
  background: color-mix(in oklch, var(--main-surface) 92%, var(--primary-soft));
  border-color: color-mix(in oklch, var(--primary) 58%, var(--line));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  outline: none;
}

.canvas-node-inline-text,
.canvas-node-provider,
.canvas-node-upload,
.canvas-node-media-preview,
.canvas-node-result {
  cursor: auto;
  touch-action: auto;
}

.canvas-node-provider {
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 750;
  color: var(--text-muted);
}

.canvas-reference-mentions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.canvas-reference-mention {
  align-items: center;
  background: color-mix(in oklch, var(--primary-soft) 72%, var(--main-surface));
  border: 1px solid color-mix(in oklch, var(--primary) 42%, var(--line));
  border-radius: 999px;
  color: var(--primary);
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 9px;
}

.canvas-reference-mention span {
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.canvas-reference-mention small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-reference-mention:hover {
  background: color-mix(in oklch, var(--primary-soft) 90%, var(--main-surface));
  border-color: color-mix(in oklch, var(--primary) 68%, var(--line));
}

.canvas-node-model-settings {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  padding: 8px;
}

.canvas-node-model-settings summary {
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.canvas-node-model-settings[open] summary {
  color: var(--primary);
}

.canvas-node-run-row {
  display: flex;
}

.canvas-node-run-btn {
  border: 1px solid color-mix(in oklch, var(--primary) 58%, var(--line));
  border-radius: 8px;
  background: color-mix(in oklch, var(--primary-soft) 64%, var(--main-surface));
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  min-height: 34px;
  width: 100%;
}

.canvas-node-run-btn:hover {
  background: color-mix(in oklch, var(--primary-soft) 78%, var(--main-surface));
}

.canvas-node-run-btn.is-download {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(34, 197, 94, 0.18));
  border-color: rgba(16, 185, 129, 0.38);
  color: #d7ffe8;
  text-align: center;
}

.canvas-node-media-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.canvas-node-upload {
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  padding: 6px 9px;
  position: relative;
  transition: border-color .14s ease, background .14s ease, color .14s ease, transform .14s ease;
}

.canvas-node-upload:hover {
  background: color-mix(in oklch, var(--primary-soft) 54%, var(--main-surface));
  border-color: color-mix(in oklch, var(--primary) 58%, var(--line));
  color: var(--primary);
  transform: translateY(-1px);
}

.canvas-node-upload input {
  cursor: pointer;
  inset: 0;
  opacity: 0;
  position: absolute;
}

.canvas-node-media-preview,
.canvas-node-result {
  display: grid;
  gap: 6px;
}

.canvas-node-preview-frame {
  align-items: center;
  background: color-mix(in oklch, var(--main-surface) 84%, #000);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  min-height: 180px;
  overflow: hidden;
  padding: 8px;
}

.canvas-node-preview-frame.is-video {
  aspect-ratio: 16 / 9;
  min-height: 0;
  padding: 0;
}

.canvas-node-preview-frame.is-empty {
  background:
    linear-gradient(145deg, rgba(59, 130, 246, 0.08), rgba(15, 23, 42, 0.2)),
    color-mix(in oklch, var(--main-surface) 88%, #000);
  place-items: center;
}

.canvas-node-preview-empty {
  color: var(--text-muted);
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 12px;
  text-align: center;
}

.canvas-node-preview-empty strong {
  color: var(--text);
  font-size: 13px;
}

.canvas-node-preview-empty small {
  font-size: 11px;
  line-height: 1.5;
  max-width: 220px;
}

.canvas-node-result.is-error .canvas-node-preview-frame {
  border-color: rgba(248,113,113,.38);
  background: rgba(127,29,29,.16);
}

.canvas-node-result.is-error .canvas-node-preview-empty strong,
.canvas-node-result.is-error > span {
  color: #fecaca;
}

.canvas-node-result.is-error .canvas-node-preview-empty small {
  color: #fca5a5;
}

.canvas-node-media-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 6px;
  overflow: hidden;
  padding: 6px;
}

.canvas-node-media-thumb {
  background: color-mix(in oklch, var(--main-surface) 86%, #000);
  border-radius: 8px;
  display: grid;
  min-height: 74px;
  overflow: hidden;
  place-items: center;
}

.canvas-node-video-placeholder {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
}

.canvas-node-media-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.canvas-node-media-tools span {
  color: var(--text-muted);
  flex: 1;
  font-size: 11px;
  font-weight: 850;
}

.canvas-node-media-tools button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--main-surface);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
}

.canvas-node-media-tools button:hover {
  border-color: color-mix(in oklch, var(--primary) 56%, var(--line));
  color: var(--primary);
}

.canvas-node-media-preview img,
.canvas-node-media-preview video,
.canvas-node-preview-frame img,
.canvas-node-preview-frame video,
.canvas-node-result video {
  border-radius: 10px;
  max-height: 240px;
  object-fit: cover;
  width: 100%;
}

.canvas-media-lightbox {
  align-items: center;
  background: rgba(15, 23, 42, 0.78);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 28px;
  position: fixed;
  z-index: 100001;
}

.canvas-media-lightbox-shell {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.44);
  display: grid;
  gap: 14px;
  max-height: 88dvh;
  max-width: min(92vw, 1240px);
  overflow: hidden;
  padding: 18px;
  width: 100%;
}

.canvas-media-lightbox-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.canvas-media-lightbox-toolbar strong {
  color: #f8fafc;
  font-size: 15px;
}

.canvas-media-lightbox-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.canvas-media-lightbox-body {
  max-height: calc(88dvh - 72px);
  max-width: 100%;
  overflow: auto;
}

.canvas-media-lightbox-body img,
.canvas-media-lightbox-body video {
  border-radius: 12px;
  display: block;
  max-height: calc(88dvh - 92px);
  max-width: 100%;
}

.canvas-media-lightbox-body audio {
  width: min(86vw, 720px);
}

.canvas-media-lightbox-close {
  width: auto;
}

.canvas-stage-wrap:fullscreen .canvas-context-menu,
.canvas-stage-wrap.is-immersive .canvas-context-menu {
  z-index: 100002;
}

.canvas-minimap-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.canvas-minimap-help {
  align-items: center;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 999px;
  color: #dbeafe;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.canvas-help-modal {
  align-items: center;
  background: rgba(15, 23, 42, 0.72);
  display: grid;
  inset: 0;
  padding: 24px;
  position: fixed;
  z-index: 100003;
}

.canvas-help-panel {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.96));
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 18px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.46);
  color: #e5eefc;
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 760px;
  padding: 22px;
  width: 100%;
}

.canvas-help-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.canvas-help-head span {
  color: #93c5fd;
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.canvas-help-head h2 {
  color: #f8fafc;
  font-size: 24px;
  margin: 0;
}

.canvas-help-close {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  color: #e2e8f0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  min-height: 38px;
  padding: 0 14px;
}

.canvas-help-body {
  display: grid;
  gap: 12px;
}

.canvas-help-section {
  background: rgba(15, 23, 42, 0.36);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
}

.canvas-help-section strong {
  color: #f8fafc;
  font-size: 14px;
}

.canvas-help-section p {
  color: #cbd5e1;
  line-height: 1.7;
  margin: 0;
}

.canvas-context-menu {
  background: var(--main-surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-xl);
  display: grid;
  gap: 6px;
  max-height: min(72dvh, 520px);
  min-width: 220px;
  overflow-y: auto;
  padding: 8px;
  position: fixed;
  z-index: 10000;
}

.canvas-context-menu.hidden {
  display: none;
}

.canvas-context-menu button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  text-align: left;
}

.canvas-context-menu button:hover {
  background: var(--main-surface-soft);
}

.canvas-node-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.canvas-node-media-preview audio,
.canvas-node-result audio {
  width: 100%;
}

.canvas-node-result > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.canvas-node-result-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.canvas-node-result-image {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.canvas-node-result-grid img {
  aspect-ratio: 1;
  border-radius: 10px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.canvas-node-result-image.is-active img {
  outline: 2px solid color-mix(in oklch, var(--primary) 70%, #fff);
  outline-offset: -2px;
}

.canvas-node-media-preview-panel {
  margin-top: -8px;
}

/* ══════════════════════════════════════�?   END OF FIX PATCH
   ══════════════════════════════════════�?*/

/* ═══════════════════════════════════════
   TECH CINEMA THEME — 2026 redesign
   Inspired by cinematic AI tools, not a product clone.
   ═══════════════════════════════════════ */

:root {
  --sidebar-width: 280px;
  --sidebar-bg: #06080d;
  --sidebar-surface: rgba(255, 255, 255, 0.06);
  --sidebar-text: #87909e;
  --sidebar-text-hover: #f7fbff;
  --sidebar-text-active: #dbfbff;
  --sidebar-accent: #00e0ff;
  --sidebar-accent-glow: rgba(0, 224, 255, 0.13);
  --sidebar-border: rgba(255, 255, 255, 0.10);
  --main-bg: #070a11;
  --main-surface: rgba(16, 20, 31, 0.84);
  --main-surface-soft: rgba(255, 255, 255, 0.055);
  --text: #f2f7fb;
  --text-soft: #bac3cf;
  --text-muted: #7f8b9c;
  --primary: #00e0ff;
  --primary-dark: #00a6c8;
  --primary-light: #86f7ff;
  --primary-soft: rgba(0, 224, 255, 0.12);
  --primary-glow: rgba(0, 224, 255, 0.26);
  --success: #55f0b2;
  --success-soft: rgba(85, 240, 178, 0.13);
  --warning: #ffd166;
  --warning-soft: rgba(255, 209, 102, 0.14);
  --danger: #ff6b7a;
  --danger-soft: rgba(255, 107, 122, 0.14);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.20);
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
  --shadow-xl: 0 34px 110px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 18px 50px rgba(0, 0, 0, 0.22);
  --shadow-elevated: 0 0 0 1px rgba(0, 224, 255, 0.22), 0 24px 74px rgba(0, 224, 255, 0.13);
  --radius-xs: 7px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

html {
  background: #070a11;
}

body {
  background: #070a11;
  color: var(--text);
  font-family: "DIN Alternate", "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: -0.01em;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 224, 255, 0.22), transparent 26%),
    radial-gradient(circle at 84% 18%, rgba(255, 189, 89, 0.13), transparent 22%),
    radial-gradient(circle at 72% 82%, rgba(65, 108, 255, 0.18), transparent 28%),
    linear-gradient(145deg, #06080d 0%, #09111b 52%, #05070c 100%);
}

body::after {
  z-index: -1;
  opacity: 0.34;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.22));
}

::selection {
  background: rgba(0, 224, 255, 0.28);
  color: #fff;
}

.app-layout {
  background: transparent;
}

.sidebar {
  background:
    radial-gradient(circle at 80% 0%, rgba(0, 224, 255, 0.15), transparent 30%),
    linear-gradient(180deg, rgba(16, 20, 31, 0.96), rgba(5, 7, 12, 0.96));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 18px 0 60px rgba(0, 0, 0, 0.34);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 180px;
  background: linear-gradient(135deg, rgba(0, 224, 255, 0.18), transparent 72%);
  pointer-events: none;
}

.sidebar-header,
.sidebar-footer {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.025);
}

.sidebar-logo,
.sidebar-user-avatar,
.chat-sidebar-avatar {
  background:
    radial-gradient(circle at 30% 25%, #ffffff 0 5%, transparent 18%),
    linear-gradient(135deg, #00e0ff, #2f6dff 55%, #ffb55c);
  color: #031019;
  box-shadow: 0 0 34px rgba(0, 224, 255, 0.28);
}

.sidebar-logo svg rect {
  fill: transparent;
}

.sidebar-logo svg path,
.sidebar-logo svg circle {
  stroke: currentColor;
  fill: currentColor;
}

.sidebar-brand-text h1,
.page-hd h1,
.main-area-header h2,
.card-v3-head h3,
.canvas-panel-head h3,
.package-head h3,
.empty-state h3 {
  letter-spacing: -0.045em;
}

.sidebar-brand-text small,
.sidebar-nav-section,
.page-hd p,
.main-area-header .eyebrow,
.card-v3-head .eyebrow,
.card-v3-head .sub,
.field-v3 > label,
.field-v3 > span,
.record-full-prompt > span {
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar-nav-item {
  border: 1px solid transparent;
  isolation: isolate;
}

.sidebar-nav-item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  background: linear-gradient(90deg, rgba(0,224,255,.18), rgba(255,255,255,.045));
  transition: opacity var(--duration-fast) var(--ease-out-expo);
}

.sidebar-nav-item:hover::before,
.sidebar-nav-item.active::before {
  opacity: 1;
}

.sidebar-nav-item.active {
  border-color: rgba(0, 224, 255, 0.24);
  box-shadow: inset 3px 0 0 var(--sidebar-accent), 0 0 22px rgba(0, 224, 255, 0.10);
}

.sidebar-user,
.sidebar-balance,
.sidebar-action-btn {
  border: 1px solid transparent;
}

.sidebar-user:hover,
.sidebar-action-btn:hover {
  border-color: rgba(255,255,255,.08);
}

.main-area {
  background:
    linear-gradient(135deg, rgba(255,255,255,.035), transparent 24%),
    radial-gradient(circle at 70px 70px, rgba(0, 224, 255, 0.09), transparent 28%),
    transparent;
  padding: clamp(18px, 2.5vw, 34px);
}

.page-hd {
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(255,255,255,.095), rgba(255,255,255,.035)),
    radial-gradient(circle at 92% 20%, rgba(0, 224, 255, 0.16), transparent 24%);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.page-hd h1 {
  font-size: clamp(26px, 3.3vw, 44px);
  color: #fff;
}

.page-hd p,
.main-area-header .eyebrow,
.card-v3-head .eyebrow,
.card-v3-head .sub {
  color: var(--primary-light);
}

.card-v3,
.canvas-panel,
.price-card,
.record-card,
.media-card,
.stat-card,
.admin-nav-bar,
.table-wrap,
.chat-main,
.preview-loading,
.empty-state {
  border-color: var(--line);
  background:
    linear-gradient(145deg, rgba(255,255,255,.082), rgba(255,255,255,.032)),
    rgba(9, 12, 20, 0.76);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.card-v3:hover,
.canvas-panel:hover,
.price-card:hover,
.media-card:hover {
  border-color: rgba(0, 224, 255, 0.28);
  box-shadow: var(--shadow-elevated);
}

.card-v3-head,
.canvas-panel-head,
.redeem-head,
.record-dialog-head,
.error-dialog-head {
  background: linear-gradient(90deg, rgba(255,255,255,.052), transparent);
  border-bottom-color: var(--line);
}

.btn,
.button,
.page-btn,
.sidebar-toggle,
.dialog-close,
.record-dialog-close {
  border-radius: 999px;
}

.btn.primary,
.btn-primary,
.button.primary,
.package-badge {
  background: linear-gradient(135deg, #effdff 0%, #00e0ff 32%, #2f6dff 100%);
  color: #020812;
  box-shadow: 0 0 0 1px rgba(255,255,255,.22) inset, 0 16px 34px rgba(0, 224, 255, 0.22);
}

.btn.primary:hover,
.btn-primary:hover,
.button.primary:hover {
  background: linear-gradient(135deg, #fff 0%, #73f4ff 34%, #00b8e5 100%);
  color: #020812;
  box-shadow: 0 0 0 1px rgba(255,255,255,.34) inset, 0 22px 44px rgba(0, 224, 255, 0.30);
}

.btn.secondary,
.btn-secondary,
.button.secondary,
.btn.ghost,
.btn-ghost,
.page-btn {
  border-color: var(--line);
  background: rgba(255,255,255,.045);
  color: var(--text-soft);
}

.btn.secondary:hover,
.btn-secondary:hover,
.button.secondary:hover,
.btn.ghost:hover,
.btn-ghost:hover,
.page-btn:hover {
  border-color: rgba(0, 224, 255, 0.38);
  background: rgba(0, 224, 255, 0.11);
  color: #eaffff;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input,
select,
textarea {
  border-color: var(--line-strong);
  background: rgba(2, 6, 14, 0.62);
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(0, 224, 255, 0.38);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 224, 255, 0.78);
  background: rgba(2, 6, 14, 0.78);
  box-shadow: 0 0 0 4px rgba(0, 224, 255, 0.12);
}

select {
  background-color: rgba(2, 6, 14, 0.62);
}

.badge-balance,
.package-credits,
.cost-hint,
.content-slot,
.buy-summary-row.total {
  border: 1px solid rgba(0, 224, 255, 0.22);
  background: linear-gradient(135deg, rgba(0,224,255,.16), rgba(255,255,255,.045));
  color: var(--text);
  box-shadow: 0 0 28px rgba(0, 224, 255, 0.08);
}

.badge-balance .num,
.package-credits strong,
.cost-hint strong,
.record-meta span:first-child,
.canvas-step-preview {
  color: var(--primary-light);
}

.status-badge,
.badge {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.09);
  color: var(--text-soft);
}

.status-badge.running,
.status-badge.queued,
.badge.warning {
  background: rgba(0, 224, 255, 0.12);
  border-color: rgba(0, 224, 255, 0.22);
  color: var(--primary-light);
}

.status-badge.succeeded,
.badge.success {
  background: rgba(85, 240, 178, 0.12);
  border-color: rgba(85, 240, 178, 0.24);
  color: #b9ffdf;
}

.status-badge.failed,
.badge.error {
  background: rgba(255, 107, 122, 0.14);
  border-color: rgba(255, 107, 122, 0.25);
  color: #ffc3ca;
}

.table-v3,
.admin-table {
  background: rgba(9, 12, 20, 0.78);
}

.table-v3 th,
.admin-table th {
  background: rgba(255,255,255,.055);
  color: var(--primary-light);
}

.table-v3 td,
.admin-table td {
  border-bottom-color: var(--line);
}

.preview-stage,
.record-image,
.history-empty-inline,
.edit-upload-box,
.edit-preview-item,
.record-dialog-image,
.record-detail-grid > div,
.buy-summary-row {
  background:
    linear-gradient(135deg, rgba(0,224,255,.08), rgba(255,255,255,.035)),
    rgba(2, 6, 14, 0.52);
  border-color: var(--line);
}

.redeem-dialog,
.record-dialog,
.generation-overlay {
  background: rgba(2, 6, 14, 0.76);
}

.redeem-panel,
.record-dialog-panel,
.error-dialog-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.035)),
    rgba(8, 12, 20, 0.94);
}

.chat-sidebar {
  background: linear-gradient(180deg, rgba(16, 20, 31, 0.96), rgba(5, 7, 12, 0.96));
}

.chat-conv-item.active,
.chat-conv-item:hover,
.chat-new-btn {
  background: rgba(0, 224, 255, 0.12);
}

.chat-new-btn {
  color: var(--primary-light);
}

.canvas-layout {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.canvas-stage-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 224, 255, 0.13), transparent 30%),
    rgba(5, 8, 14, 0.82);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.canvas-toolbar {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,255,255,.075), rgba(255,255,255,.026));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.canvas-stage-shell {
  background: #05070c;
}

.canvas-stage {
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 224, 255, 0.10), transparent 34%),
    #05070c;
}

.canvas-grid {
  opacity: 0.78;
  background-image:
    linear-gradient(rgba(0, 224, 255, 0.065) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 224, 255, 0.065) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
}

.canvas-node,
.canvas-item {
  border-color: rgba(255,255,255,.14);
  background:
    linear-gradient(145deg, rgba(255,255,255,.105), rgba(255,255,255,.045)),
    rgba(11, 15, 24, 0.94);
  box-shadow: 0 18px 44px rgba(0,0,0,.36);
}

.canvas-node.selected,
.canvas-item.selected {
  border-color: rgba(0, 224, 255, 0.76);
  box-shadow: 0 0 0 1px rgba(0,224,255,.34), 0 0 42px rgba(0,224,255,.18);
}

.canvas-port i {
  background: #061018;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 224, 255, 0.13);
}

.canvas-port:hover i,
.canvas-port.active i {
  background: var(--primary-light);
  border-color: #fff;
  box-shadow: 0 0 0 6px rgba(0, 224, 255, 0.20);
}

.canvas-context-menu {
  border-color: var(--line);
  background:
    linear-gradient(145deg, rgba(255,255,255,.10), rgba(255,255,255,.035)),
    rgba(7, 10, 17, 0.98);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.canvas-context-menu button:hover {
  background: rgba(0, 224, 255, 0.13);
  color: #ecfeff;
}

@media (max-width: 1024px) {
  .canvas-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    box-shadow: 24px 0 70px rgba(0, 0, 0, 0.45);
  }

  .sidebar-toggle {
    background: rgba(10, 14, 22, 0.82);
    color: var(--text);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .main-area {
    padding-top: 64px;
  }
}

