/* ------------------------------------------------------------------ */
/*  Design tokens                                                      */
/* ------------------------------------------------------------------ */
:root {
  --bg: #08090d;
  --bg-2: #0b0d13;
  --panel: #101219;
  --panel-2: #151823;
  --panel-3: #1b1f2c;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef6;
  --muted: #8e93a6;
  --muted-2: #676c80;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Inter", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
*::selection { background: rgba(139, 92, 246, 0.35); color: #fff; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 42% at 78% -8%, rgba(139, 92, 246, 0.12), transparent 65%),
    radial-gradient(44% 34% at 4% 2%, rgba(34, 211, 238, 0.07), transparent 70%);
  z-index: 0;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
code { font-family: var(--mono); font-size: 0.92em; }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.72);
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.65);
  outline-offset: 2px;
}

.grad-text {
  background: linear-gradient(100deg, #c4b5fd 0%, #a78bfa 38%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------------------ */
/*  Buttons & controls                                                 */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease, opacity 0.15s;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: var(--panel-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn.primary {
  border: none;
  background: linear-gradient(115deg, #7c3aed 0%, #8b5cf6 42%, #0ea5c9 100%);
  color: #fff;
  box-shadow: 0 8px 26px rgba(124, 58, 237, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.primary:hover {
  background: linear-gradient(115deg, #8b5cf6 0%, #9d6bff 45%, #22d3ee 100%);
  box-shadow: 0 12px 34px rgba(124, 58, 237, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn.primary kbd { margin-left: 6px; border-color: rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.16); color: rgba(255, 255, 255, 0.8); }
.btn.lg { padding: 14px 20px; font-size: 14.5px; border-radius: 14px; }
.btn.sm { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn.full { width: 100%; }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.25); background: var(--danger-soft); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.18); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.field > span b { color: var(--text); font-variant-numeric: tabular-nums; }
.hint { font-size: 11.5px; color: var(--muted-2); line-height: 1.45; }
.hint code { color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  background: #0b0d14;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-size: 13.5px;
}
input::placeholder, textarea::placeholder { color: #5a5f72; }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.13); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.13);
  background: #0c0e17;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238e93a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
  cursor: pointer;
}
select:disabled { opacity: 0.45; cursor: not-allowed; }
option { background: #12141d; color: var(--text); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  outline: none;
  padding: 0;
  border: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #a78bfa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #a78bfa;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.chips button {
  padding: 5px 11px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 999px;
  transition: all 0.15s;
}
.chips button:hover { color: var(--text); border-color: rgba(139, 92, 246, 0.45); background: rgba(139, 92, 246, 0.1); }

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #0b0d14;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.segmented button {
  flex: 1;
  padding: 7px 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: #252a3a;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.segmented.sizes button { padding: 7px 5px; font-size: 12px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #0b0d14;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  height: 40px;
}
.stepper button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.stepper button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); color: #fff; }
.stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper b { font-size: 14px; font-variant-numeric: tabular-nums; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #0b0d14;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: all 0.15s;
}
.check input:checked + .check-box {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  border-color: transparent;
}
.check input:checked + .check-box::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
.check input:disabled ~ span { opacity: 0.5; }
.check small { color: var(--muted-2); font-size: 11.5px; margin-left: 2px; }

/* ------------------------------------------------------------------ */
/*  Brand                                                              */
/* ------------------------------------------------------------------ */
.brand { display: inline-flex; align-items: center; gap: 11px; }
.logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.2), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 16px rgba(124, 58, 237, 0.18);
}
.logo svg { width: 27px; height: 27px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; font-size: 16.5px; }
.brand-text small { font-size: 9.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-2); margin-top: 3px; }
.brand-lg .logo { width: 44px; height: 44px; border-radius: 14px; }
.brand-lg .logo svg { width: 32px; height: 32px; }
.brand-lg .brand-text { font-size: 20px; }

/* ------------------------------------------------------------------ */
/*  Auth                                                               */
/* ------------------------------------------------------------------ */
.auth {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, 0.92fr);
  min-height: 100dvh;
}
.auth-art {
  position: relative;
  overflow: hidden;
  padding: 42px 54px 34px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(70% 55% at 85% 18%, rgba(139, 92, 246, 0.16), transparent 68%),
    radial-gradient(50% 50% at 8% 80%, rgba(34, 211, 238, 0.08), transparent 70%),
    linear-gradient(160deg, #0a0b11, #08090d 62%);
}
.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}
.auth-glow.g1 { width: 420px; height: 420px; background: rgba(139, 92, 246, 0.22); top: 8%; right: -8%; }
.auth-glow.g2 { width: 340px; height: 340px; background: rgba(34, 211, 238, 0.12); bottom: -6%; left: 18%; }

.auth-copy {
  position: relative;
  z-index: 2;
  max-width: 590px;
  margin: auto 0;
  padding: 36px 0 80px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: #a5a9ba;
}
.eyebrow i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.14);
}
.auth-copy h1 {
  margin-top: 22px;
  font-size: clamp(38px, 4.4vw, 62px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.auth-sub {
  margin-top: 22px;
  max-width: 470px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}
.auth-features { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 11px; color: #b9bdcc; font-size: 13.5px; }
.fdot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: none;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  position: relative;
}
.fdot::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #22d3ee);
}

.auth-mosaic {
  position: absolute;
  right: -28px;
  bottom: -30px;
  display: flex;
  gap: 14px;
  transform: rotate(-9deg);
  opacity: 0.9;
  pointer-events: none;
}
.tile {
  width: 128px;
  height: 168px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(4px);
}
.tile.t1 { background: linear-gradient(150deg, rgba(139, 92, 246, 0.65), rgba(34, 211, 238, 0.25)); margin-top: 46px; }
.tile.t2 { background: linear-gradient(150deg, rgba(236, 72, 153, 0.5), rgba(251, 191, 36, 0.28)); }
.tile.t3 { background: linear-gradient(150deg, rgba(16, 185, 129, 0.45), rgba(99, 102, 241, 0.45)); margin-top: 76px; }

.auth-foot { position: absolute; left: 54px; bottom: 30px; font-size: 11.5px; color: var(--muted-2); z-index: 2; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    radial-gradient(48% 40% at 70% 0%, rgba(139, 92, 246, 0.08), transparent 70%),
    var(--bg-2);
}
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(22, 25, 35, 0.9), rgba(14, 16, 23, 0.92));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.auth-tabs button {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.18s;
}
.auth-tabs button.active { background: var(--panel-3); color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.auth-heading { margin: 24px 0 20px; }
.auth-heading h2 { font-size: 22px; letter-spacing: -0.02em; }
.auth-heading p { color: var(--muted); font-size: 13px; margin-top: 6px; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--danger); font-size: 12.5px; min-height: 0; }
.form-error:not(:empty) { padding: 9px 12px; background: var(--danger-soft); border: 1px solid rgba(248, 113, 113, 0.2); border-radius: 10px; }
.auth-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.55;
}
.auth-note .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
  margin-top: 5px;
  flex: none;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12);
}

/* ------------------------------------------------------------------ */
/*  Shell / sidebar / topbar                                           */
/* ------------------------------------------------------------------ */
.shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100dvh;
}
.sidebar {
  width: 244px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line);
  background: rgba(9, 10, 15, 0.66);
  backdrop-filter: blur(18px);
  z-index: 30;
}
.sidebar .brand { padding: 0 8px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 30px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: all 0.16s;
  position: relative;
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
.nav-item.active {
  background: linear-gradient(100deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.05));
  border-color: rgba(139, 92, 246, 0.22);
  color: #fff;
}
.nav-item.active svg { color: #b9a5ff; opacity: 1; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #a78bfa, #22d3ee);
}
.nav-count {
  margin-left: auto;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 20px;
  padding: 2px 6px;
  text-align: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.nav-item.active .nav-count { background: rgba(255, 255, 255, 0.14); color: #fff; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.mode-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.2);
  background: rgba(251, 191, 36, 0.07);
  color: #fcd34d;
  font-size: 11px;
  font-weight: 600;
  width: fit-content;
}
.mode-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.14); }
.mode-pill.live { border-color: rgba(52, 211, 153, 0.24); background: rgba(52, 211, 153, 0.08); color: #6ee7b7; }
.mode-pill.live i { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14); }

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #0891b2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
}
.avatar.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 18px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-meta strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .icon-btn { margin-left: auto; width: 28px; height: 28px; }

.main {
  flex: 1;
  min-width: 0;
  height: 100dvh;
  overflow-y: auto;
  padding: 26px 34px 48px;
  scroll-behavior: smooth;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-heading h1 { font-size: 26px; letter-spacing: -0.025em; margin-top: 3px; }
.page-heading .eyebrow { font-size: 9.5px; color: var(--muted-2); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12); }
.status-pill.live i { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12); }

.views { position: relative; }
.view { display: none; }
.view.active { display: block; animation: viewIn 0.32s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ */
/*  Banner / panels                                                    */
/* ------------------------------------------------------------------ */
.banner {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.16);
  background: linear-gradient(100deg, rgba(251, 191, 36, 0.08), rgba(139, 92, 246, 0.05));
  margin-bottom: 18px;
}
.banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(251, 191, 36, 0.1);
  color: var(--warn);
  flex: none;
}
.banner-icon svg { width: 18px; height: 18px; }
.banner strong { font-size: 12.5px; }
.banner p { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.banner p code { color: #d6c9a8; background: rgba(255, 255, 255, 0.05); padding: 1px 5px; border-radius: 4px; }
.banner .btn { margin-left: auto; flex: none; }

.panel {
  background: linear-gradient(180deg, rgba(21, 24, 34, 0.72), rgba(13, 15, 22, 0.86));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h3 { font-size: 14px; letter-spacing: -0.01em; }
.counter { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 448px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.composer { display: flex; flex-direction: column; gap: 13px; }
.composer > textarea { min-height: 132px; font-size: 14px; }
.divider { height: 1px; background: var(--line); margin: 3px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

.advanced { border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:hover { color: var(--text); }
.chev {
  width: 7px;
  height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-right: 3px;
}
.advanced[open] .chev { transform: rotate(-135deg); }
.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 15px;
}
.advanced-grid .field:has(textarea) { grid-column: 1 / -1; }
.inline-inputs { display: flex; align-items: center; gap: 6px; }
.inline-inputs input { text-align: center; padding: 9px 6px; }
.inline-inputs em { font-style: normal; color: var(--muted-2); font-size: 11px; flex: none; }
.advanced-grid .check { align-self: end; padding-bottom: 9px; }

.fineprint { font-size: 11px; color: var(--muted-2); text-align: center; }

.stage-panel { position: sticky; top: 26px; display: flex; flex-direction: column; gap: 16px; min-height: 620px; }
.stage {
  min-height: 470px;
  flex: 1;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background-color: #0a0c12;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.045) 1px, transparent 0);
  background-size: 22px 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.stage.has-result { background-image: none; background: #080a0f; }

.recent-block { padding-top: 2px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.recent-head h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.linkish {
  border: none;
  background: transparent;
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px;
  transition: color 0.15s;
}
.linkish:hover { color: #c4b5fd; }
.recent-strip { display: flex; gap: 8px; overflow-x: auto; min-height: 64px; padding-bottom: 4px; }
.recent-thumb {
  width: 66px;
  height: 66px;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-thumb:hover { transform: translateY(-2px); border-color: rgba(139, 92, 246, 0.5); }
.recent-empty { font-size: 11.5px; color: var(--muted-2); display: flex; align-items: center; }

/* ------------------------------------------------------------------ */
/*  Stage: empty / loading / result                                    */
/* ------------------------------------------------------------------ */
.stage-empty {
  margin: auto;
  padding: 42px 28px;
  text-align: center;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-art {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 32% 28%, rgba(167, 139, 250, 0.85), transparent 45%),
    radial-gradient(circle at 70% 72%, rgba(34, 211, 238, 0.7), transparent 48%),
    linear-gradient(145deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 48px rgba(76, 29, 149, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
  margin-bottom: 22px;
}
.empty-art::before {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
}
.empty-art::after {
  content: "";
  position: absolute;
  inset: 39px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.7);
}
.empty-art.small { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 16px; }
.empty-art.small::before { inset: 17px; }
.empty-art.small::after { inset: 27px; }
.stage-empty h3 { font-size: 16px; letter-spacing: -0.01em; }
.stage-empty p { color: var(--muted); font-size: 12.5px; margin-top: 8px; line-height: 1.65; }
.stage-tips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.stage-tips span {
  font-size: 10.5px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  padding: 4px 9px;
  border-radius: 999px;
}

.gen-loading { display: flex; flex-direction: column; height: 100%; padding: 14px; gap: 12px; }
.gen-frame {
  flex: 1;
  min-height: 330px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #14121f, #0b1118 55%, #101a20);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gen-frame .shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(167, 139, 250, 0.12) 45%, rgba(34, 211, 238, 0.1) 55%, transparent 80%);
  background-size: 240% 100%;
  animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -80% 0; }
}
.gen-frame .partial {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 0.5s ease, transform 0.6s ease;
  z-index: 2;
}
.gen-frame .partial.show { opacity: 1; transform: none; }
.gen-frame .scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 26%;
  background: linear-gradient(180deg, transparent, rgba(34, 211, 238, 0.09), transparent);
  animation: scan 3.2s ease-in-out infinite;
  z-index: 3;
  pointer-events: none;
}
@keyframes scan {
  0%, 100% { top: -26%; }
  50% { top: 100%; }
}
.loading-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  font-size: 10.5px;
  color: #e5e7f0;
}
.loading-badge .spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.6px solid rgba(255, 255, 255, 0.25);
  border-top-color: #c4b5fd;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-progress { height: 3px; background: rgba(255, 255, 255, 0.07); border-radius: 999px; overflow: hidden; }
.gen-progress .bar {
  height: 100%;
  width: 6%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b5cf6, #22d3ee);
  transition: width 1.1s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.6);
}
.gen-status { display: flex; align-items: center; gap: 10px; padding: 0 2px; min-height: 30px; }
.gen-status .status-text { font-size: 12.5px; color: #c3c7d6; }
.gen-status .timer { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; margin-left: auto; }
.gen-status .btn { margin-left: 8px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); animation: pulse 1.4s ease-in-out infinite; flex: none; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0); }
}

.result-wrap { display: flex; flex-direction: column; height: 100%; }
.result-media {
  position: relative;
  flex: 1;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background:
    radial-gradient(60% 60% at 50% 40%, rgba(139, 92, 246, 0.07), transparent 70%),
    #080a0f;
}
.result-media img {
  max-width: 100%;
  max-height: min(52vh, 520px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  animation: imgIn 0.5s ease both;
}
@keyframes imgIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: none; }
}
.image-badge {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ddd6fe;
  backdrop-filter: blur(8px);
}
.image-badge.demo { color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 2px;
  flex-wrap: wrap;
}
.result-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 10.5px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  white-space: nowrap;
}
.tag b { color: #cbd0e0; font-weight: 600; }
.tag.accent { color: #c4b5fd; border-color: rgba(139, 92, 246, 0.3); background: rgba(139, 92, 246, 0.09); }
.result-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  transition: all 0.15s;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover { color: #fff; border-color: var(--line-strong); background: rgba(255, 255, 255, 0.08); }
.action-btn.primary-action { background: linear-gradient(110deg, rgba(139, 92, 246, 0.9), rgba(14, 165, 201, 0.9)); color: #fff; border: none; }
.prompt-quote {
  margin: 8px 0 0;
  padding: 11px 13px;
  border-left: 2px solid rgba(139, 92, 246, 0.5);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 0 9px 9px 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  max-height: 76px;
  overflow: hidden;
  position: relative;
}
.prompt-quote:hover { max-height: 220px; overflow: auto; }

.result-multi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  width: 100%;
}
.result-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: #0a0c12;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.result-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.result-card .mini-bar { display: flex; padding: 6px; gap: 4px; }
.result-card .action-btn { padding: 5px 7px; font-size: 10.5px; flex: 1; justify-content: center; }

.stage-error {
  margin: auto;
  padding: 36px 28px;
  text-align: center;
  max-width: 380px;
}
.error-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.error-icon svg { width: 24px; height: 24px; }
.stage-error h3 { font-size: 15px; }
.stage-error p { font-size: 12.5px; color: var(--muted); margin-top: 7px; line-height: 1.6; }
.stage-error .btn { margin-top: 16px; }

/* ------------------------------------------------------------------ */
/*  Edit view                                                          */
/* ------------------------------------------------------------------ */
.dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  transition: all 0.18s;
}
.dropzone:hover, .dropzone.dragging {
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(139, 92, 246, 0.07);
  color: var(--text);
}
.dropzone svg { width: 26px; height: 26px; color: #a78bfa; margin-bottom: 2px; }
.dropzone strong { font-size: 12.5px; font-weight: 600; }
.dropzone span { font-size: 10.5px; color: var(--muted-2); }
.upload-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.upload-strip:empty { display: none; }
.upload-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background-color: #151823;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.055) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb button {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}
.upload-thumb button:hover { background: var(--danger); }
.mask-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mask-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.mask-pick:hover { color: var(--text); border-color: var(--line-strong); }
.mask-pick svg { width: 15px; height: 15px; }
.mask-preview { display: flex; align-items: center; gap: 8px; }
.mask-preview .upload-thumb { width: 40px; height: 40px; }
.mask-preview span { font-size: 11px; color: var(--muted); }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ */
/*  Gallery                                                            */
/* ------------------------------------------------------------------ */
.gallery-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  pointer-events: none;
}
.search input { padding-left: 36px; }
.gallery-toolbar .segmented { width: auto; }
.gallery-toolbar .segmented button { flex: none; padding: 7px 14px; }
.gallery-total { margin-left: auto; font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 13px;
  margin-top: 18px;
}
.gallery-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0;
  text-align: left;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.gallery-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.gallery-card:hover img { transform: scale(1.04); }
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, transparent 32%, transparent 48%, rgba(4, 5, 9, 0.92) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 11px;
  opacity: 0.94;
}
.gallery-prompt {
  font-size: 11.5px;
  line-height: 1.45;
  color: #e6e8f1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-meta { display: flex; gap: 6px; margin-top: 6px; align-items: center; font-size: 9.5px; color: rgba(255, 255, 255, 0.55); flex-wrap: wrap; }
.gallery-meta em { font-style: normal; }
.gallery-meta .sep { opacity: 0.4; }
.gallery-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(8, 9, 13, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ddd6fe;
  backdrop-filter: blur(6px);
}
.gallery-badge.demo { color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
.gallery-open {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 13, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  opacity: 0;
  transition: opacity 0.18s;
}
.gallery-card:hover .gallery-open { opacity: 1; }
.gallery-open svg { width: 13px; height: 13px; }

.empty-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 70px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.012);
}
.empty-block h3 { font-size: 16px; margin-top: 6px; }
.empty-block p { font-size: 12.5px; color: var(--muted); margin: 6px 0 18px; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 20px; }
.load-more-wrap .btn { min-width: 160px; }

/* ------------------------------------------------------------------ */
/*  Settings                                                           */
/* ------------------------------------------------------------------ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-grid .wide { grid-column: 1 / -1; }
.account-row { display: flex; align-items: center; gap: 13px; }
.account-row strong { display: block; font-size: 14px; }
.account-row span { font-size: 12px; color: var(--muted-2); }
.settings-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.055);
}
.settings-line:last-of-type { border-bottom: none; }
.settings-line b, .settings-line code {
  color: #d5d9e6;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.settings-line b.ok { color: var(--ok); }
.conn-card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.18);
  background: rgba(251, 191, 36, 0.06);
}
.conn-card.live { border-color: rgba(52, 211, 153, 0.2); background: rgba(52, 211, 153, 0.06); }
.conn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
  flex: none;
}
.conn-card.live .conn-icon { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.conn-icon svg { width: 18px; height: 18px; }
.conn-card strong { font-size: 13px; }
.conn-card p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.55; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-grid .wide .stat-grid { grid-template-columns: repeat(4, 1fr); }
.stat {
  padding: 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat b { font-size: 22px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; color: var(--muted-2); }

.table-wrap { overflow-x: auto; margin: 0 -6px; }
.model-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 680px; }
.model-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  white-space: nowrap;
}
.model-table td { padding: 11px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.045); color: var(--muted); vertical-align: middle; }
.model-table tr:last-child td { border-bottom: none; }
.model-table td:first-child { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 11.5px; }
.model-table tr:hover td { background: rgba(255, 255, 255, 0.018); }
.mini-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-tag { font-size: 9.5px; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.tips { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 9px; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.tips li::marker { color: var(--accent); }
.tips code { color: #c4b5fd; background: rgba(139, 92, 246, 0.09); padding: 1px 5px; border-radius: 4px; }
.doc-links { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.doc-links a { font-size: 12px; color: #a5b4fc; transition: color 0.15s; }
.doc-links a:hover { color: #c7d2fe; }

/* ------------------------------------------------------------------ */
/*  Modal                                                              */
/* ------------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 5, 9, 0.76);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(1020px, 100%);
  max-height: calc(100dvh - 40px);
  background: linear-gradient(180deg, #141720, #0d0f16);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  overflow: hidden;
  position: relative;
  animation: modalIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.modal-media {
  background:
    radial-gradient(60% 60% at 50% 50%, rgba(139, 92, 246, 0.08), transparent 70%),
    #07080c;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  min-height: 380px;
  overflow: hidden;
}
.modal-media img { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.modal-info { padding: 26px 24px; overflow-y: auto; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.modal-info h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); margin: 18px 0 7px; font-weight: 700; }
.modal-prompt { font-size: 13px; line-height: 1.7; color: #d6dae7; white-space: pre-wrap; word-break: break-word; }
.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 9, 13, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}
.modal-close:hover { background: rgba(255, 255, 255, 0.12); }
.modal-close svg { width: 15px; height: 15px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.meta-item { background: #0e1017; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; }
.meta-item span { font-size: 9.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; }
.meta-item b { font-size: 12px; font-weight: 600; color: #dfe3ee; word-break: break-word; }
.modal-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 22px; }
.modal-actions .btn { flex: 1; min-width: 88px; }
.modal-id { font-size: 10px; color: var(--muted-2); font-family: var(--mono); margin-top: 12px; word-break: break-all; }

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 5, 9, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease both;
}
.confirm-box {
  width: min(400px, 100%);
  background: linear-gradient(180deg, #171a24, #10121a);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease both;
}
.confirm-box h3 { font-size: 16px; }
.confirm-box p { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.confirm-actions { display: flex; gap: 8px; margin-top: 20px; }
.confirm-actions .btn { flex: 1; }

/* ------------------------------------------------------------------ */
/*  Toasts                                                             */
/* ------------------------------------------------------------------ */
.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(20, 23, 33, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  color: #dfe3ee;
  backdrop-filter: blur(12px);
  animation: toastIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  pointer-events: auto;
}
.toast.out { animation: toastOut 0.2s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
.toast-icon { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--ok); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--accent-2); }

/* ------------------------------------------------------------------ */
/*  Responsive                                                         */
/* ------------------------------------------------------------------ */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 1fr; }
  .stage-panel { position: static; min-height: 0; }
  .stage { min-height: 460px; }
  .auth-copy h1 { font-size: clamp(34px, 5vw, 52px); }
}

@media (max-width: 1080px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { min-height: 100dvh; padding: 26px; position: relative; }
  .auth-panel::before {
    content: "LUMEN · GPT IMAGE STUDIO";
    position: absolute;
    top: 26px;
    left: 30px;
    font-size: 9.5px;
    letter-spacing: 0.2em;
    color: var(--muted-2);
    font-weight: 700;
  }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .wide { grid-column: auto; }
  .settings-grid .wide .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    width: 78px;
    padding: 20px 12px 14px;
    align-items: center;
  }
  .sidebar .brand { padding: 0; }
  .brand-text { display: none; }
  .nav { width: 100%; margin-top: 26px; }
  .nav-item { justify-content: center; padding: 12px 8px; }
  .nav-item span { display: none; }
  .nav-item .nav-count { display: none; }
  .nav-item.active::before { left: -13px; }
  .mode-pill { padding: 8px; justify-content: center; width: 42px; }
  .mode-pill span { display: none; }
  .user-card { padding: 7px; flex-direction: column; gap: 6px; }
  .user-meta, .user-card .icon-btn { display: none; }
  .main { padding: 22px 24px 40px; }
  .banner { align-items: flex-start; flex-wrap: wrap; }
  .banner .btn { margin-left: 47px; }
}

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    height: 64px;
    flex-direction: row;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--line);
    background: rgba(9, 10, 15, 0.92);
    align-items: center;
    height: auto;
  }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; margin: 0; gap: 2px; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 9.5px; padding: 5px 8px; flex: 1; border-radius: 10px; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item span { display: block; }
  .nav-item.active::before { display: none; }
  .main { height: calc(100dvh - 64px); padding: 16px 15px 30px; }
  .topbar { margin-bottom: 16px; }
  .page-heading h1 { font-size: 21px; }
  .status-pill { display: none; }
  .top-actions .btn span { display: none; }
  .banner { padding: 11px 13px; }
  .banner .btn { margin-left: 47px; }
  .workspace { gap: 14px; }
  .panel { padding: 16px; border-radius: 15px; }
  .form-grid, .advanced-grid { grid-template-columns: 1fr; }
  .stage { min-height: 380px; }
  .result-media img { max-height: 46vh; }
  .gallery-toolbar { gap: 9px; }
  .search { max-width: none; width: 100%; }
  .gallery-total { display: none; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
  .gallery-prompt { -webkit-line-clamp: 1; font-size: 10.5px; }
  .gallery-meta { font-size: 8.5px; }
  .modal { grid-template-columns: 1fr; max-height: calc(100dvh - 24px); }
  .modal-media { min-height: 240px; padding: 14px; }
  .modal-media img { max-height: 46vh; }
  .modal-info { border-left: none; border-top: 1px solid var(--line); padding: 20px 18px; }
  .modal-backdrop { padding: 12px; }
  .modal-actions .btn { min-width: 0; }
  .settings-grid { gap: 12px; }
  .stat b { font-size: 19px; }
  .toasts { right: 12px; left: 12px; bottom: 76px; max-width: none; }
  .result-slide { max-height: 42vh; }
}

@media (max-width: 480px) {
  .main { padding: 14px 12px 26px; }
  .panel { padding: 14px; }
  .btn.lg { padding: 13px 16px; }
  .btn.primary kbd { display: none; }
  .stage { min-height: 330px; }
  .stage-empty { padding: 30px 16px; }
  .result-bar { flex-direction: column; align-items: flex-start; }
  .result-actions { width: 100%; }
  .result-actions .action-btn { flex: 1; justify-content: center; }
  .auth-panel { padding: 20px 14px; }
  .auth-card { padding: 22px 18px; border-radius: 18px; }
  .auth-heading h2 { font-size: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .settings-line b, .settings-line code { max-width: 55%; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Reduced motion */
@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;
  }
}
