/* ==========================================================
   JDMA Studio · Design Tokens (matching JDMA Dashboard)
   ========================================================== */
:root {
  --bg: #0a0a0c;
  --bg-grad:
    radial-gradient(1200px 600px at 80% -10%, rgba(230, 57, 70, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(230, 57, 70, 0.04), transparent 60%);

  --surface:  #111114;
  --surface2: #16161a;
  --surface3: #1c1c20;

  --border:        #1f1f24;
  --border-strong: #2a2a30;
  --border-light:  #34343c;

  --text:  #f0f0f2;
  --text2: #a8a8b0;
  --text3: #82828c;

  --red:       #e63946;
  --red-soft:  #f06873;
  --red-dark:  #b8202a;
  --red-glow:  rgba(230, 57, 70, 0.12);

  --green:      #22c55e;
  --green-glow: rgba(34, 197, 94, 0.12);

  --amber:     #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.12);

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-red: 0 8px 32px rgba(230, 57, 70, 0.25);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  text-rendering: optimizeLegibility;
}
body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
}
::selection { background: var(--red); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a30; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; outline: none; }
:focus-visible { outline: 2px solid var(--red-soft); outline-offset: 2px; }

/* Subtle film grain (kept, very faint) */
.grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

/* ==========================================================
   Topbar — JDMA Style (sticky pill header)
   ========================================================== */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  max-width: 980px;
  margin: 12px auto 24px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(17, 17, 20, 0.7);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-logo {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  /* Tight crop of the JD monogram (pre-cut from the brand master via sharp). */
  background: #000 url('jd-mark.jpg') no-repeat center / cover;
  box-shadow: 0 0 0 1px var(--border-strong), 0 4px 14px rgba(230, 57, 70, 0.18);
  flex-shrink: 0;
}
.brand-name { color: var(--text); }
.brand-name em { color: var(--red); font-style: normal; }

.topnav, .bottomnav { display: none !important; }
.topnav-deprecated { display: flex; gap: 4px; }
.navlink {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  letter-spacing: -0.005em;
}
.navlink:hover { color: var(--text2); background: var(--surface2); }
.navlink.active { color: var(--text); background: var(--surface2); }

.topright { display: flex; align-items: center; gap: 8px; }
.credits {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}
.credits-label { color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; font-size: 9px; }
.credits-value { color: var(--red-soft); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn-ghost {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all var(--t-fast);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface2); }

/* ==========================================================
   Main / Sections
   ========================================================== */
.main {
  position: relative; z-index: 2;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 28px 96px;
}

.section { margin-bottom: 56px; }
.section:last-child { margin-bottom: 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
}

.section-sub {
  color: var(--text3);
  font-size: 12.5px;
  max-width: 540px;
  line-height: 1.45;
}

/* ==========================================================
   Buttons
   ========================================================== */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--red);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-red);
  transition: all var(--t-fast);
}
.btn-primary:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 12px 28px rgba(230, 57, 70, 0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-icon { font-size: 14px; line-height: 1; font-weight: 800; }
.btn-primary-lg { padding: 11px 20px; font-size: 13px; margin-top: 16px; }

/* Hero generate button */
.btn-hero {
  position: relative;
  width: 100%;
  padding: 18px 20px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  border: 1px solid var(--red-dark);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-red);
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.btn-hero:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(230, 57, 70, 0.4); }
.btn-hero:not(:disabled):active { transform: translateY(0); }
.btn-hero:disabled { opacity: 0.45; cursor: not-allowed; }
.hero-glow { display: none; }
.hero-content { display: flex; align-items: center; justify-content: center; gap: 10px; }
.hero-icon { font-size: 18px; line-height: 1; }
.hero-text { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.hero-hint {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  font-weight: 500;
}
.hero-hint span { color: var(--text2); }

/* ==========================================================
   Models grid
   ========================================================== */
.models-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 720px) {
  .models-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* ===== Model card v2 — hero strip + body row ===== */
.mcv2 {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 0.85, 0.2, 1),
              border-color 0.18s,
              box-shadow 0.25s;
}
.mcv2:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 100, 115, 0.35);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 24px rgba(230, 57, 70, 0.12);
}
.mcv2:hover .mcv2-hero { transform: scale(1.04); }
.mcv2:hover .mcv2-cta { color: var(--text); }

/* ===== Hero strip — last_image background OR muted gradient ===== */
.mcv2-hero {
  position: relative;
  height: 130px;
  background-color: #15080b;
  background-image: radial-gradient(120% 80% at 50% 0%, #261016 0%, #100509 70%, #08030400 100%);
  background-size: cover;
  background-position: 50% 25%;
  transition: transform 0.6s cubic-bezier(0.2, 0.85, 0.2, 1);
}
.mcv2[data-trained="0"] .mcv2-hero {
  /* Subtle noise via overlapping gradients so the empty hero doesn't look flat. */
  background-image:
    radial-gradient(60% 60% at 30% 30%, rgba(255, 100, 115, 0.08), transparent 70%),
    radial-gradient(50% 50% at 80% 80%, rgba(230, 57, 70, 0.06), transparent 70%),
    linear-gradient(180deg, var(--surface3), var(--surface2) 65%, #0a0507);
}
.mcv2-hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(8, 3, 4, 0.85) 100%);
  pointer-events: none;
}

/* ===== Body row ===== */
.mcv2-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 16px;
}
.mcv2-avatar {
  position: relative;
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface3), var(--surface2));
  border: 1px solid var(--border-strong);
  overflow: hidden;
  margin-top: -38px; /* lifts avatar over the hero/fade boundary */
  display: grid; place-items: center;
  color: var(--text3);
  font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: border-color 0.18s, box-shadow 0.25s;
}
.mcv2-avatar::before { content: attr(data-init); }
.mcv2-avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}
.mcv2[data-trained="1"] .mcv2-avatar {
  border-color: rgba(255, 100, 115, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 18px rgba(230, 57, 70, 0.22);
}

.mcv2-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mcv2-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcv2[data-trained="0"] .mcv2-name { color: var(--text2); }
.mcv2-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--text3);
  min-width: 0;
}
.mcv2-niche {
  font-style: italic;
  color: var(--text3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcv2-stats {
  font-variant-numeric: tabular-nums;
  color: var(--text2);
}
.mcv2-today {
  color: #4ade80;
  font-weight: 600;
}

.mcv2-cta {
  flex-shrink: 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text3);
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s, transform 0.15s;
}
.mcv2-cta[data-action="train"] { color: var(--text2); }
.mcv2[data-trained="1"] .mcv2-cta { color: rgba(255, 130, 145, 0.85); }

/* Training-in-progress state: pulse the avatar + shimmer the hero */
.mcv2[data-training] .mcv2-avatar {
  border-color: rgba(255, 200, 80, 0.65);
  animation: mcv2-pulse 1.6s ease-in-out infinite;
}
.mcv2[data-training] .mcv2-hero {
  background-image: linear-gradient(110deg, rgba(255, 200, 80, 0.08) 0%, rgba(255, 200, 80, 0.18) 50%, rgba(255, 200, 80, 0.08) 100%);
  background-size: 200% 100%;
  animation: mcv2-shimmer 2.4s linear infinite;
}
.mcv2[data-training] .mcv2-cta { color: #ffc850; }
@keyframes mcv2-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(255, 200, 80, 0.5); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(255, 200, 80, 0); }
}
@keyframes mcv2-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.mcv2-cta:hover { transform: translateX(2px); }
.mcv2-cta:active { transform: translateX(0); opacity: 0.7; }

.model-card-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 24px;
  border-style: dashed;
  border-color: var(--border-strong);
  cursor: default;
  background: var(--surface);
}
.model-card-empty::before { display: none; }
.model-card-empty:hover { transform: none; box-shadow: none; border-color: var(--border-strong); }

.model-card-empty h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.015em;
}
.model-card-empty > p {
  color: var(--text3);
  font-size: 12.5px;
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}

.model-empty-art {
  position: relative;
  width: 64px; height: 64px;
  margin: 0 auto 18px;
}
.empty-circle {
  position: absolute; inset: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}
.empty-circle-2 { transform: scale(0.7); border-color: rgba(230, 57, 70, 0.3); }
.empty-circle-3 {
  transform: scale(0.4);
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 16px rgba(230, 57, 70, 0.5);
}

/* ==========================================================
   Generate Panel
   ========================================================== */
.generate-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.gen-left, .gen-right { display: flex; flex-direction: column; }

.field-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 6px;
  margin-top: 14px;
  font-weight: 700;
}
.field-label:first-child { margin-top: 0; }

.field-help {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

.input, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
.input::placeholder { color: var(--text3); }

.select-wrap { position: relative; }
.select { appearance: none; padding-right: 32px; cursor: pointer; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px; top: 50%;
  width: 10px; height: 6px;
  transform: translateY(-50%);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23a0a0a8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center;
  pointer-events: none;
}

.range-wrap {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 0;
}
.range {
  -webkit-appearance: none; appearance: none;
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  background: var(--red);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 4px var(--red-glow);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.range::-webkit-slider-thumb:hover { box-shadow: 0 0 0 6px var(--red-glow); transform: scale(1.08); }
.range-value {
  min-width: 28px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--red-soft);
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gen-actions { margin-top: 24px; }

/* Pipeline panel */
.gen-right {
  background: var(--surface2);
  border-radius: var(--r-md);
  padding: 18px;
  border: 1px solid var(--border);
}
.pipeline-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--text3);
  margin-bottom: 14px;
  font-weight: 700;
}
.pipeline {
  list-style: none;
  display: flex; flex-direction: column;
  position: relative;
}
.pipeline::before {
  content: '';
  position: absolute;
  left: 13px; top: 12px; bottom: 12px;
  width: 1px;
  background: linear-gradient(to bottom, var(--border-strong), transparent);
}
.pipe-step {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  position: relative;
}
.pipe-num {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--surface3);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  font-weight: 700;
  z-index: 1;
  transition: all var(--t-base);
}
.pipe-step.active .pipe-num {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-glow);
}
.pipe-step.done .pipe-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.pipe-body { display: flex; flex-direction: column; gap: 1px; }
.pipe-body strong {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.pipe-desc { font-size: 11px; color: var(--text3); line-height: 1.4; }
.pipe-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  padding-top: 5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pipe-step.active .pipe-status { color: var(--red-soft); }
.pipe-step.done .pipe-status { color: var(--green); }

/* ==========================================================
   Gallery
   ========================================================== */
.gallery-filters { display: flex; gap: 6px; }
.chip {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  transition: all var(--t-fast);
  letter-spacing: -0.005em;
}
.chip:hover { background: var(--surface2); color: var(--text2); border-color: var(--border-strong); }
.chip-active {
  background: var(--red-glow);
  color: var(--text);
  border-color: var(--red);
}

.gallery-empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 64px 24px;
  text-align: center;
  color: var(--text3);
}
.empty-icon {
  font-size: 36px;
  color: var(--text3);
  margin-bottom: 14px;
  display: block;
  opacity: 0.6;
}
.gallery-empty h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.gallery-empty p { font-size: 12px; color: var(--text3); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

/* ==========================================================
   Modal — JDMA editor style
   ========================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadein 0.12s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideup 0.15s ease-out;
  box-shadow: var(--shadow-lg);
}
@keyframes slideup {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  font-size: 16px;
  transition: color var(--t-fast), background var(--t-fast);
}
.modal-close:hover { background: var(--surface2); color: var(--red); }

.modal-body { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

/* Upload zone (matches JDMA upload-area) */
.upload-zone {
  margin-top: 4px;
  padding: 24px 18px;
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-base), background var(--t-base), color var(--t-base);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--red);
  background: var(--red-glow);
}
.upload-zone strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.upload-zone p { font-size: 11px; color: var(--text3); line-height: 1.4; }
.upload-art { margin-bottom: 10px; }
.upload-icon {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--red-soft);
  font-size: 16px;
  font-weight: 700;
}

.upload-list {
  margin-top: 10px;
  max-height: 180px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.upload-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
}
.upload-item-name { flex: 1; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.upload-item-size { color: var(--text3); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ==========================================================
   Profile picker (pre-app login screen)
   Asymmetric composition, spring easing, tinted glow on tiles.
   ========================================================== */
.profile-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 600px at 15% 25%, rgba(230, 57, 70, 0.10), transparent 60%),
    radial-gradient(700px 500px at 85% 80%, rgba(230, 57, 70, 0.06), transparent 60%);
  overflow-y: auto;
  animation: psFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.profile-screen[hidden] { display: none; }
body.ps-open { overflow: hidden; }
.profile-screen[data-state="leaving"] {
  animation: psFadeOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  pointer-events: none;
}
.profile-screen .ms-grad {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 50% 45%, rgba(230, 57, 70, 0.10), transparent 65%),
    radial-gradient(700px 500px at 50% 85%, rgba(230, 57, 70, 0.05), transparent 70%);
}

.ms-frame {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 40px 24px;
}

/* ---- Header ---- */
.ms-head {
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: -0.015em;
}
.ms-brand { display: flex; align-items: center; gap: 16px; }
.ms-brand-mark {
  display: inline-block;
  width: 64px; height: 64px;
  border-radius: 12px;
  background: #000 url('jd-brand.jpg') no-repeat center / cover;
  box-shadow: 0 0 0 1px var(--border-strong), 0 6px 18px rgba(230, 57, 70, 0.22);
}
.ms-brand-product {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.ms-add-top {
  position: relative;
  display: inline-flex; align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 6px 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(28, 16, 20, 0.7), rgba(15, 6, 8, 0.5));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  isolation: isolate;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    transform 0.22s cubic-bezier(0.2, 0.85, 0.2, 1),
    border-color 0.22s ease,
    box-shadow 0.32s cubic-bezier(0.2, 0.85, 0.2, 1);
}
/* Soft red ring that ramps up on hover — feels like the chip is heating */
.ms-add-top::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, transparent 30%, rgba(230, 57, 70, 0.6) 50%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.32s ease;
  pointer-events: none;
}
.ms-add-top:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 32px rgba(230, 57, 70, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.ms-add-top:hover::before { opacity: 1; }
.ms-add-top:active { transform: translateY(0) scale(0.98); }
.ms-add-top:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(230, 57, 70, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.5);
}

.ms-add-icon {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ff5b6a, #c81d2b 70%);
  color: white;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 6px 16px rgba(230, 57, 70, 0.45),
    0 0 0 1px rgba(255, 100, 115, 0.35);
  transition:
    transform 0.36s cubic-bezier(0.2, 0.85, 0.2, 1),
    box-shadow 0.32s ease;
}
.ms-add-icon svg { width: 14px; height: 14px; }
.ms-add-top:hover .ms-add-icon {
  transform: rotate(90deg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 8px 22px rgba(230, 57, 70, 0.55),
    0 0 0 1px rgba(255, 120, 135, 0.5);
}
.ms-add-label {
  background: linear-gradient(180deg, var(--text), var(--text2));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
/* ---- Body ---- */
.ms-body {
  align-self: center;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  justify-items: center;
  gap: 36px;
  padding: 16px 0;
}

.ms-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 0;
}

/* ---- Carousel ---- */
.ms-carousel {
  position: relative;
  width: 100%;
  max-width: 1280px;
  height: 280px;
  perspective: 1400px;
}
.ms-card-skeleton {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 160px; height: 160px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--surface2), var(--surface3));
  opacity: 0.5;
}

.ms-card {
  position: absolute;
  top: 50%; left: 50%;
  width: 140px; height: 140px;
  margin: -70px 0 0 -70px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: linear-gradient(170deg, #1c1014, #0f0608 65%, #08030400);
  cursor: pointer;
  display: grid; place-items: center;
  isolation: isolate;
  transition:
    transform 0.55s cubic-bezier(0.2, 0.85, 0.2, 1),
    opacity   0.45s cubic-bezier(0.2, 0.85, 0.2, 1),
    box-shadow 0.45s cubic-bezier(0.2, 0.85, 0.2, 1),
    border-color 0.3s cubic-bezier(0.2, 0.85, 0.2, 1),
    background 0.45s linear,
    filter 0.45s cubic-bezier(0.2, 0.85, 0.2, 1);
}
/* Position rules — JS sets data-pos in {-2,-1,0,1,2,hidden} */
.ms-card[data-pos="0"]  { transform: translateX(0)      scale(1.55); z-index: 6; }
.ms-card[data-pos="-1"] { transform: translateX(-180px) scale(1.05); z-index: 4; }
.ms-card[data-pos="1"]  { transform: translateX( 180px) scale(1.05); z-index: 4; }
.ms-card[data-pos="-2"] { transform: translateX(-330px) scale(0.8); z-index: 2; opacity: 0.5; filter: blur(0.5px); }
.ms-card[data-pos="2"]  { transform: translateX( 330px) scale(0.8); z-index: 2; opacity: 0.5; filter: blur(0.5px); }
.ms-card[data-pos="hidden"] {
  transform: translateX(0) scale(0.4);
  opacity: 0; pointer-events: none; z-index: 0;
}

/* Trained = red wash; intensity scales by position */
.ms-card.is-trained {
  background: linear-gradient(170deg, #2e0b10, #160508 70%);
  border-color: rgba(230, 57, 70, 0.25);
}
/* Center tile always gets the red glow — marks focus, not training */
.ms-card[data-pos="0"] {
  /* Tilt vars driven by JS mousemove; default zero. */
  --ms-tx: 0deg;
  --ms-ty: 0deg;
  transform: translateX(0) scale(1.55) rotateY(var(--ms-tx)) rotateX(var(--ms-ty));
  background:
    radial-gradient(60% 60% at 50% 45%, rgba(255, 90, 105, 0.55), rgba(180, 30, 44, 0.7) 60%, #2a0408 100%);
  border-color: rgba(255, 100, 115, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 100, 115, 0.5),
    0 0 24px 6px rgba(230, 57, 70, 0.5),
    0 0 60px 14px rgba(230, 57, 70, 0.35),
    0 0 120px 30px rgba(230, 57, 70, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: ms-breathe 3.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  transform-style: preserve-3d;
  transition:
    transform 0.12s cubic-bezier(0.2, 0.85, 0.2, 1),
    opacity 0.45s, box-shadow 0.45s, border-color 0.3s, background 0.45s, filter 0.45s;
}
/* Rotating aurora halo behind the center tile */
.ms-card[data-pos="0"]::after {
  content: '';
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    rgba(255, 90, 105, 0)    0deg,
    rgba(255, 90, 105, 0.35) 70deg,
    rgba(230, 57, 70, 0.55)  150deg,
    rgba(255, 120, 130, 0.4) 220deg,
    rgba(255, 90, 105, 0)    320deg
  );
  filter: blur(22px);
  opacity: 0.85;
  z-index: -1;
  animation: ms-rotate 9s linear infinite;
  pointer-events: none;
}
.ms-card[data-pos="-1"].is-trained,
.ms-card[data-pos="1"].is-trained {
  background: linear-gradient(170deg, #5a151c, #25080c 65%);
  box-shadow:
    0 16px 40px rgba(230, 57, 70, 0.18),
    0 0 40px rgba(230, 57, 70, 0.12);
}

/* Side tiles: hover lifts + brightens */
.ms-card[data-pos="-1"]:hover,
.ms-card[data-pos="1"]:hover {
  transform: translateX(var(--ms-x, 0)) scale(1.15);
  filter: brightness(1.15);
  border-color: rgba(255, 100, 115, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(230, 57, 70, 0.25);
}
.ms-card[data-pos="-1"]:hover { --ms-x: -180px; }
.ms-card[data-pos="1"]:hover  { --ms-x:  180px; }
.ms-card[data-pos="-2"]:hover,
.ms-card[data-pos="2"]:hover {
  opacity: 0.85;
  filter: blur(0px) brightness(1.1);
}

/* Click feedback */
.ms-card:active { transition-duration: 0.08s; }
.ms-card[data-pos="0"]:active { transform: translateX(0) scale(1.48); }

@keyframes ms-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 100, 115, 0.5),
      0 0 24px 6px rgba(230, 57, 70, 0.5),
      0 0 60px 14px rgba(230, 57, 70, 0.35),
      0 0 120px 30px rgba(230, 57, 70, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 120, 135, 0.65),
      0 0 32px 10px rgba(230, 57, 70, 0.62),
      0 0 80px 22px rgba(230, 57, 70, 0.45),
      0 0 160px 44px rgba(230, 57, 70, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .ms-card[data-pos="0"] { animation: none; }
  .ms-card[data-pos="0"]::after { animation: none; }
}

.ms-card-init {
  font-size: 42px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.ms-card[data-pos="0"] .ms-card-init { font-size: 46px; }

.ms-card-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
  border-radius: 50%;
}

/* "TRAINED" badge — sits just above the circle top edge */
.ms-card-badge {
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(10, 10, 12, 0.65);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  z-index: 2;
}
.ms-card-badge::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}

/* Name strip under each carousel tile (small, only visible for ±1, ±2) */
.ms-card-name {
  position: absolute;
  top: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--text3);
  white-space: nowrap;
  letter-spacing: -0.005em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.ms-card[data-pos="-1"] .ms-card-name,
.ms-card[data-pos="1"]  .ms-card-name { opacity: 0.85; color: var(--text2); }
.ms-card[data-pos="-2"] .ms-card-name,
.ms-card[data-pos="2"]  .ms-card-name { opacity: 0.5; }

/* ---- Active info ---- */
.ms-active {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  text-align: center;
}
.ms-active-name {
  font-size: clamp(34px, 4.5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--text);
}
.ms-stats {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 28px;
  margin-top: 18px;
}
.ms-stat {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.005em;
}
.ms-stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.ms-stat-status.is-trained .ms-stat-dot {
  background: #4ade80;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.55);
}
.ms-stat-count { color: var(--text); font-variant-numeric: tabular-nums; }
.ms-stat-count .ms-count { color: var(--text); font-weight: 600; }
.ms-stat-muted { color: var(--text3); }
.ms-stat-muted .ms-count { color: var(--text2); font-weight: 500; }

/* ---- Actions ---- */
.ms-actions {
  display: flex; align-items: center; gap: 14px;
}
.ms-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 48px;
  padding: 0 26px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.2, 0.85, 0.2, 1),
    background 0.18s linear,
    box-shadow 0.18s cubic-bezier(0.2, 0.85, 0.2, 1);
}
.ms-btn-primary {
  background: var(--red);
  color: white;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 24px rgba(230, 57, 70, 0.4);
}
.ms-btn-primary:hover { background: var(--red-soft); transform: translateY(-1px); }
.ms-btn-primary:active { transform: translateY(0); }
.ms-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.ms-btn-ghost:hover { border-color: var(--border-light); background: rgba(255, 255, 255, 0.03); }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .ms-card[data-pos="-2"], .ms-card[data-pos="2"] { opacity: 0; }
  .ms-card[data-pos="-1"] { transform: translateX(-160px) scale(0.95); }
  .ms-card[data-pos="1"]  { transform: translateX( 160px) scale(0.95); }
  .ms-card[data-pos="0"]  { transform: scale(1.4); }
}
@media (max-width: 720px) {
  .ms-frame { padding: 20px 18px; }
  .ms-carousel { height: 220px; }
  .ms-card { width: 110px; height: 110px; margin: -55px 0 0 -55px; }
  .ms-card[data-pos="-1"] { transform: translateX(-130px) scale(0.9); }
  .ms-card[data-pos="1"]  { transform: translateX( 130px) scale(0.9); }
  .ms-card[data-pos="0"]  { transform: scale(1.35); }
  .ms-card-init { font-size: 30px; }
  .ms-card[data-pos="0"] .ms-card-init { font-size: 34px; }
  .ms-stats { gap: 16px; }
  .ms-stat { font-size: 12px; }
  .ms-actions { width: 100%; flex-direction: column; gap: 10px; }
  .ms-btn { width: 100%; justify-content: center; }
}

@keyframes psFadeIn  { from { opacity: 0; }                          to { opacity: 1; } }
@keyframes psFadeOut { from { opacity: 1; }                          to { opacity: 0; transform: scale(1.01); } }

/* ==========================================================
   Gallery grid (live image tiles)
   ========================================================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.gal-tile {
  position: relative;
  display: block;
  aspect-ratio: 9/16;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-base);
}
.gal-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.gal-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 10px 8px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.78));
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}
.gal-model {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.005em;
}
.gal-score {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  background: var(--red);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-size: 10px;
}
@keyframes galTileIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.gal-tile-new { animation: galTileIn .32s ease-out; }

/* ==========================================================
   Toast
   ========================================================== */
#toast-host {
  position: fixed;
  bottom: 80px; right: 16px;
  z-index: 80;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 11px 16px;
  background: rgba(17, 17, 20, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  max-width: 360px;
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast-out { opacity: 0; transition: opacity .35s ease; }
@media (max-width: 900px) {
  #toast-host { left: 12px; right: 12px; bottom: 90px; }
  .toast { max-width: none; }
}

/* ==========================================================
   Bottom Nav (mobile only)
   ========================================================== */
.bottomnav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 12, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 6px 6px;
  border-radius: var(--r-md);
  color: var(--text3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  transition: color var(--t-fast), background var(--t-fast);
  min-height: 48px; /* tap target */
}
.bn-item svg { width: 22px; height: 22px; opacity: 0.9; }
.bn-item:hover { color: var(--text2); }
.bn-item.active {
  color: var(--red-soft);
  background: rgba(230, 57, 70, 0.08);
}
.bn-item.active svg { opacity: 1; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 900px) {
  .topbar {
    margin: 8px 12px 20px;
    padding: 11px 14px;
    gap: 10px;
    top: 8px;
  }
  .topnav { display: none; }
  .brand-name { font-size: 15px; }
  .brand-name em { display: inline; }
  .credits { padding: 5px 9px; gap: 6px; }
  .credits-label { display: none; } /* keep just the value, label is redundant on mobile */
  .credits-value { font-size: 13px; }
  .btn-ghost { padding: 7px 11px; font-size: 12px; }

  .bottomnav { display: flex; gap: 6px; }
  .main { padding: 0 16px 96px; }
  .section { margin-bottom: 40px; scroll-margin-top: 78px; }
  .section-title { font-size: 20px; }
  .section-sub { font-size: 12px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-head > div + * { width: 100%; }

  .models-grid { gap: 12px; }
  .mcv2-hero { height: 110px; }
  .mcv2-body { padding: 12px 14px 14px; gap: 10px; }
  .mcv2-avatar { width: 48px; height: 48px; margin-top: -32px; font-size: 14px; }
  .mcv2-name { font-size: 14px; }
  .mcv2-meta { font-size: 11.5px; }
  .mcv2-cta { font-size: 11.5px; }

  .generate-panel { grid-template-columns: 1fr; padding: 16px; gap: 18px; }

  /* Pipeline collapsible on mobile */
  .pipeline-title {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .pipeline-title::after {
    content: '▾';
    font-size: 11px;
    color: var(--text3);
    transition: transform var(--t-fast);
  }
  .gen-right.collapsed .pipeline { display: none; }
  .gen-right.collapsed .pipeline-title::after { transform: rotate(-90deg); }

  .btn-hero { min-height: 56px; font-size: 16px; }
  .gallery-filters { flex-wrap: wrap; }
}

@media (max-width: 380px) {
  .brand-name em { display: none; }
  .credits { display: none; }
}

/* ============================================================
   Picker v6 — atmospheric effects
   ============================================================ */

/* ---- Active-info crossfade on switch ---- */
.ms-active {
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}
.ms-active.is-changing {
  opacity: 0;
  transform: translateY(4px);
}

/* ---- Floating embers behind carousel ---- */
.ms-embers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.ms-ember {
  position: absolute;
  bottom: -40px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 120, 130, 0.95), rgba(230, 57, 70, 0.5) 55%, rgba(230, 57, 70, 0) 75%);
  filter: blur(3px);
  opacity: 0;
  will-change: transform, opacity;
}
.ms-ember:nth-child(1) { left:  8%; animation: ms-rise 14s ease-in   1.0s infinite; }
.ms-ember:nth-child(2) { left: 18%; animation: ms-rise 16s ease-in   3.6s infinite; width: 10px; height: 10px; }
.ms-ember:nth-child(3) { left: 30%; animation: ms-rise 12s ease-in   0.2s infinite; width: 18px; height: 18px; }
.ms-ember:nth-child(4) { left: 45%; animation: ms-rise 18s ease-in   6.0s infinite; }
.ms-ember:nth-child(5) { left: 58%; animation: ms-rise 13s ease-in   2.4s infinite; width: 12px; height: 12px; }
.ms-ember:nth-child(6) { left: 72%; animation: ms-rise 17s ease-in   5.2s infinite; width: 16px; height: 16px; }
.ms-ember:nth-child(7) { left: 84%; animation: ms-rise 15s ease-in   1.8s infinite; }
.ms-ember:nth-child(8) { left: 92%; animation: ms-rise 19s ease-in   8.0s infinite; width: 9px; height: 9px; }

@keyframes ms-rise {
  0%   { transform: translate3d(0, 0, 0)        scale(0.6); opacity: 0; }
  15%  { opacity: 0.7; }
  50%  { transform: translate3d(20px, -50vh, 0) scale(1);   opacity: 0.5; }
  85%  { opacity: 0.25; }
  100% { transform: translate3d(-10px, -110vh, 0) scale(0.4); opacity: 0; }
}

/* ---- Keyboard hints pill ---- */
.ms-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  margin-top: 28px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3, #777);
  opacity: 0.85;
}
.ms-key-group { display: inline-flex; align-items: center; gap: 6px; }
.ms-keys kbd {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  color: var(--text2);
  font-family: inherit;
  font-size: 11px;
}

@media (max-width: 560px) {
  .ms-keys { gap: 14px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .ms-ember { animation: none; }
}

/* ============================================================
   Per-Model Dashboard (.md) — opens on profile-card click
   ============================================================ */
.md { padding-top: 0; }
.md-back-row { padding: 8px 0 18px; }
.md-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.md-back:hover {
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateX(-2px);
}

/* Hero */
.md-hero {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background-color: #15080b;
  background-image: radial-gradient(120% 80% at 50% 0%, #2a1117 0%, #100509 70%, #08030400 100%);
  background-size: cover;
  background-position: 50% 25%;
  min-height: 240px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--border);
}
.md-hero-fade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,3,4,0) 30%, rgba(8,3,4,0.92) 100%);
  pointer-events: none;
}
.md-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 28px 32px;
  width: 100%;
}
.md-hero-avatar {
  position: relative;
  width: 110px; height: 110px;
  border-radius: 50%;
  border: 2px solid rgba(255, 100, 115, 0.55);
  overflow: hidden;
  background: var(--surface2);
  display: grid; place-items: center;
  color: var(--text2);
  font-size: 32px; font-weight: 800;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 28px rgba(230, 57, 70, 0.25);
  flex-shrink: 0;
}
.md-hero-avatar::before { content: attr(data-init); }
.md-hero-avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}
.md-hero-titles { min-width: 0; }
.md-hero-eyebrow {
  display: inline-block;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255, 130, 145, 0.85);
  margin-bottom: 6px;
}
.md-hero-name {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 0 0 8px;
  color: var(--text);
}
.md-hero-niche {
  margin: 0;
  font-size: 14px;
  font-style: italic;
  color: var(--text2);
}

/* Stats strip — 5-col, breathing, no card-chrome */
.md-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 18px 0 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 18px 4px;
}
.md-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
}
.md-stat:last-child { border-right: 0; }
.md-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.md-stat-num.is-active { color: #4ade80; }
.md-stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
}
.md-stat-link {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 130, 145, 0.9);
  text-decoration: none;
  line-height: 1.2;
}
.md-stat-link:hover { color: rgba(255, 150, 165, 1); }

/* Two-col row: Generate + Linked Accounts */
.md-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 900px) {
  .md-row { grid-template-columns: 1fr; }
  .md-stats { grid-template-columns: repeat(2, 1fr); }
  .md-stat:nth-child(2n) { border-right: 0; }
}

.md-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}
/* Stand-alone cards (not inside .md-row's grid) need their own spacing. */
.md > .md-card,
#model-dashboard > .md-card {
  margin-bottom: 18px;
}
.md > .md-card:last-of-type,
#model-dashboard > .md-card:last-of-type {
  margin-bottom: 0;
}
/* Also tighten the gap between the stats strip and the row below it. */
.md-stats + .md-row { margin-top: 4px; }
.md-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.md-card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.md-card-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.md-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text3);
  font-style: italic;
}

/* Generate sub-panel inside md-card */
.md-gen-body[data-disabled="1"] { opacity: 0.6; }
.md-gen-body .field-label { margin-top: 14px; }
.md-gen-body .field-label:first-child { margin-top: 0; }
.md-gen-body .btn-hero { margin-top: 18px; width: 100%; }

/* Linked accounts list */
.md-acc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.md-acc {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  font-size: 13px;
}
.md-acc-platform {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
}
.md-acc-platform[data-p="instagram"] { color: #e1306c; }
.md-acc-platform[data-p="tiktok"]    { color: #25f4ee; }
.md-acc-platform[data-p="facebook"]  { color: #4267b2; }
.md-acc-handle {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.md-acc-handle:hover { color: rgba(255, 130, 145, 1); }
.md-acc-op {
  font-size: 11px;
  color: var(--text3);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

/* Per-model gallery */
.md-gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.md-gal-tile {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface2);
  transition: transform 0.18s;
}
.md-gal-tile:hover { transform: translateY(-2px); }
.md-gal-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.md-gal-score {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.7);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

/* ============================================================
   Niche presets, Lightbox, Run-History, Gallery filters, Heart
   ============================================================ */

/* Niche preset chips */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}
.preset-chip {
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.preset-chip:hover {
  border-color: rgba(255, 100, 115, 0.45);
  color: var(--text);
}
.preset-chip.is-active {
  background: rgba(230, 57, 70, 0.18);
  border-color: rgba(255, 100, 115, 0.55);
  color: rgba(255, 150, 165, 1);
}
.preset-chip:disabled { opacity: 0.5; cursor: not-allowed; }

/* Soul-ID picker row in settings card */
.md-soul-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}
.md-soul-row .select { flex: 1; }
.md-soul-row .btn-primary { flex-shrink: 0; padding: 0 22px; }
.md-settings code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11.5px;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text2);
}

/* Run history */
.md-run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.md-run {
  display: grid;
  grid-template-columns: 110px 50px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.15s;
  font-family: var(--mono, ui-monospace, monospace);
}
.md-run:hover { background: var(--surface2); }
.md-run.is-active { background: rgba(230, 57, 70, 0.12); }
.md-run-date { color: var(--text3); }
.md-run-count { color: var(--text); font-weight: 600; }
.md-run-focus { color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-run-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.md-run-status-done    { background: rgba(74, 222, 128, 0.12); color: #4ade80; }
.md-run-status-running { background: rgba(255, 200, 80, 0.12); color: #ffc850; }
.md-run-status-failed  { background: rgba(230, 57, 70, 0.18); color: #ff8a95; }
.md-run-status-unknown { background: var(--surface2); color: var(--text3); }

/* Gallery filter toggles + heart icon on tiles */
.md-gal-filters { display: inline-flex; align-items: center; gap: 8px; }
.md-gal-filter {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.md-gal-filter:hover { color: var(--text); border-color: var(--border-strong); }
.md-gal-filter.is-active {
  background: rgba(230, 57, 70, 0.18);
  border-color: rgba(255, 100, 115, 0.55);
  color: rgba(255, 150, 165, 1);
}
.md-gal-fav {
  position: absolute;
  top: 6px; left: 6px;
  font-size: 14px;
  color: #ff8a95;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.md-gal-tile {
  background: var(--surface2);
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

/* Lightbox */
.lbx {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 3, 4, 0.92);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: 1fr 380px;
  align-items: stretch;
  animation: lbx-in 0.18s ease-out;
}
@keyframes lbx-in { from { opacity: 0; } to { opacity: 1; } }
.lbx-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, transform 0.15s;
}
.lbx-close:hover { background: rgba(255, 255, 255, 0.12); transform: scale(1.05); }
.lbx-stage {
  display: grid; place-items: center;
  padding: 40px;
  min-height: 0;
  overflow: hidden;
}
.lbx-img {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}
.lbx-side {
  background: rgba(15, 6, 9, 0.85);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.lbx-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.lbx-model {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.lbx-virality {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  color: rgba(255, 130, 145, 0.9);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(255, 100, 115, 0.3);
}
.lbx-prompt-wrap .field-label { margin-bottom: 6px; }
.lbx-prompt {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text2);
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.lbx-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}
.lbx-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.lbx-btn:hover { background: var(--surface3); border-color: var(--border-strong); }
.lbx-btn-primary {
  grid-column: 1 / -1;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.lbx-btn-primary:hover { background: var(--accent); opacity: 0.9; }
.lbx-btn.is-fav { color: #ff8a95; border-color: rgba(255, 100, 115, 0.55); background: rgba(230, 57, 70, 0.12); }

@media (max-width: 860px) {
  .lbx { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lbx-side { border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.06); max-height: 50vh; }
  .lbx-stage { padding: 20px; }
}

/* ============================================================
   Topbar Logout button (replaces old profile pill)
   ============================================================ */
#btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
#btn-logout:hover {
  color: rgba(255, 130, 145, 1);
  border-color: rgba(255, 100, 115, 0.45);
}
#btn-logout.is-firing {
  background: var(--accent, #e63946);
  color: white;
  border-color: var(--accent, #e63946);
  box-shadow: 0 0 0 6px rgba(230, 57, 70, 0.25), 0 0 24px rgba(230, 57, 70, 0.5);
  animation: logout-flash 0.6s ease-out;
}
@keyframes logout-flash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ============================================================
   Picker edit mode — rename + delete overlays on tiles
   ============================================================ */
.ms-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.ms-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(28, 16, 20, 0.7), rgba(15, 6, 8, 0.5));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    transform 0.22s cubic-bezier(0.2, 0.85, 0.2, 1),
    background 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    box-shadow 0.32s cubic-bezier(0.2, 0.85, 0.2, 1);
}
.ms-edit-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.ms-edit-toggle:active { transform: translateY(0) scale(0.98); }
.ms-edit-toggle:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(230, 57, 70, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.5);
}
.ms-edit-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(230, 57, 70, 0.95), rgba(190, 40, 55, 0.95));
  border-color: rgba(255, 130, 145, 0.6);
  color: #fff;
  box-shadow:
    0 8px 24px rgba(230, 57, 70, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.ms-edit-toggle .ms-edit-label { text-transform: uppercase; }

/* Overlay buttons appear only when body.ps-edit is set */
.ms-edit-overlay { display: none; }
body.ps-edit .ms-edit-overlay {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 8;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px;
  pointer-events: none;
}
body.ps-edit .ms-tile-act {
  pointer-events: auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 6, 9, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
body.ps-edit .ms-tile-act:hover { transform: scale(1.12); }
body.ps-edit .ms-tile-rename:hover { background: rgba(255, 200, 80, 0.25); border-color: rgba(255, 200, 80, 0.55); }
body.ps-edit .ms-tile-delete:hover { background: rgba(230, 57, 70, 0.7); border-color: rgba(255, 100, 115, 0.9); }
/* In edit mode, tone the tiles down so the action buttons read clearly */
body.ps-edit .ms-card[data-pos]:not([data-pos="hidden"]) {
  cursor: default;
}

/* ---- Avatar picker in new-model modal ---- */
.avatar-pick {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 18px;
}
.avatar-pick-circle {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 1.5px dashed var(--border-strong);
  background: var(--surface2);
  display: grid; place-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.avatar-pick-circle:hover {
  border-color: rgba(255, 100, 115, 0.55);
  transform: scale(1.04);
}
.avatar-pick-hint {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.avatar-pick-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
}
.avatar-pick-meta strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.avatar-pick-meta .field-help { margin: 0; }


/* ==========================================================
   Curation Mode (gallery review · JDMA editorial look)
   ========================================================== */
.swipe {
  position: fixed; inset: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  z-index: 100;
  display: flex; flex-direction: column;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.swipe-head {
  display: flex; align-items: center; gap: 24px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
}
.swipe-head-left { display: flex; align-items: center; gap: 14px; }
.swipe-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.swipe-close:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface2); }

.swipe-title { display: flex; flex-direction: column; line-height: 1.2; }
.swipe-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--red);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.swipe-model { font-size: 15px; color: var(--text); font-weight: 500; }

.swipe-progress {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}
.swipe-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text2);
}
.swipe-count b { color: var(--text); font-weight: 600; }
.swipe-count-sep { margin: 0 4px; color: var(--text3); }
.swipe-bar {
  height: 3px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}
.swipe-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red-dark), var(--red));
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.swipe-stats { display: flex; gap: 10px; }
.swipe-stat {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  padding: 4px 0;
  letter-spacing: 0.04em;
}
.swipe-stat span { font-weight: 600; }
.swipe-stat-keep span { color: var(--green); }
.swipe-stat-del span  { color: var(--red); }
.swipe-stat + .swipe-stat::before {
  content: '·';
  margin-right: 10px;
  color: var(--border-strong);
}

/* Stage with edge-glow indicators (no rotated stamps) */
.swipe-stage {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  min-height: 0;
}
.swipe-edge {
  position: absolute;
  top: 0; bottom: 0;
  width: 120px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.swipe-edge-del  { left: 0;  background: linear-gradient(to right, var(--red-glow), transparent); border-left:  1px solid var(--red); }
.swipe-edge-keep { right: 0; background: linear-gradient(to left,  var(--green-glow), transparent); border-right: 1px solid var(--green); }

.swipe-msg {
  color: var(--text3);
  font-size: 14px;
  font-family: var(--mono);
}

.swipe-card {
  position: absolute;
  width: min(540px, 92vw);
  max-height: calc(100vh - 260px);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-strong);
  transition: transform var(--t-base), opacity var(--t-base);
  cursor: grab;
  touch-action: pan-y;
  display: flex; flex-direction: column;
}
.swipe-card.is-dragging { transition: none; cursor: grabbing; }
.swipe-card[data-stack="0"] { z-index: 2; }
.swipe-card[data-stack="1"] {
  z-index: 1;
  transform: scale(0.97) translateY(10px);
  opacity: 0.5;
  pointer-events: none;
  filter: blur(1px);
}

.swipe-card-img {
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.swipe-card-img img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 360px);
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.swipe-card-meta {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.swipe-meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swipe-meta-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.swipe-meta-pill-fav { color: var(--red-soft); border-color: rgba(230, 57, 70, 0.4); background: var(--red-glow); }
.swipe-meta-prompt {
  font-size: 12.5px;
  color: var(--text3);
  line-height: 1.45;
  font-family: var(--mono);
  max-height: 3.6em;
  overflow: hidden;
}

/* Bottom action bar — JDMA pill buttons with keyboard hints, no Tinder circles */
.swipe-actions {
  display: flex; align-items: stretch; justify-content: center;
  gap: 10px;
  padding: 16px 16px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.swipe-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.swipe-btn:hover { background: var(--surface3); border-color: var(--border-light); }
.swipe-btn:active { transform: translateY(1px); }
.swipe-btn-key {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text3);
  min-width: 22px;
  text-align: center;
}
.swipe-btn-label { letter-spacing: 0.01em; }
.swipe-btn-del:hover {
  color: var(--red);
  border-color: rgba(230, 57, 70, 0.5);
  background: var(--red-glow);
}
.swipe-btn-del:hover .swipe-btn-key { color: var(--red); border-color: rgba(230, 57, 70, 0.4); }
.swipe-btn-keep:hover {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.5);
  background: var(--green-glow);
}
.swipe-btn-keep:hover .swipe-btn-key { color: var(--green); border-color: rgba(34, 197, 94, 0.4); }
.swipe-btn-skip { color: var(--text2); }

.swipe-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background: var(--bg);
  text-align: center;
  padding: 32px;
  z-index: 4;
}
.swipe-empty h3 { font-size: 20px; font-weight: 500; }
.swipe-empty p { color: var(--text2); font-family: var(--mono); font-size: 13px; }
.swipe-empty p b { color: var(--text); }
.swipe-btn-done {
  margin-top: 16px;
  background: var(--red);
  color: white;
  border: none;
  padding: 11px 24px;
  border-radius: var(--r-md);
  font-weight: 500;
  cursor: pointer;
  font-size: 13.5px;
  letter-spacing: 0.02em;
}
.swipe-btn-done:hover { background: var(--red-soft); }

.md-gal-swipe { color: var(--text2); }
.md-gal-swipe:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 600px) {
  .swipe-head { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px 18px 14px; }
  .swipe-progress { grid-template-columns: auto 1fr; }
  .swipe-stats { grid-column: 1 / -1; justify-content: flex-start; }
  .swipe-btn-label { display: none; }
  .swipe-btn { padding: 11px 14px; }
}

/* ==========================================================
   Hero Actions (regenerate · pick from gallery)
   ========================================================== */
.md-hero { position: relative; }
.md-hero-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 3;
}
.md-hero-act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.md-hero-act:hover {
  background: rgba(230, 57, 70, 0.4);
  border-color: var(--red);
}
.md-hero-act:disabled { opacity: 0.55; cursor: progress; }
.md-hero-act svg { stroke: currentColor; }

/* ==========================================================
   Hero Picker (full-screen image chooser)
   ========================================================== */
.hero-picker {
  position: fixed; inset: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  z-index: 99;
  display: flex; flex-direction: column;
  user-select: none;
}
.hero-picker-head {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
}
.hero-picker-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  font-size: 16px;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.hero-picker-close:hover { color: var(--text); background: var(--surface2); border-color: var(--border-strong); }
.hero-picker-title { display: flex; flex-direction: column; line-height: 1.2; }
.hero-picker-eyebrow { font-family: var(--mono); font-size: 10.5px; color: var(--red); letter-spacing: 0.18em; text-transform: uppercase; }
.hero-picker-model { font-size: 15px; color: var(--text); font-weight: 500; }
.hero-picker-hint {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.04em;
}
.hero-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.hero-picker-msg {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 13px;
  padding: 60px 20px;
}
.hero-picker-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.hero-picker-tile:hover {
  transform: translateY(-2px);
  border-color: var(--red);
  box-shadow: 0 8px 24px rgba(230, 57, 70, 0.25);
}
.hero-picker-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-picker-fav {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--red-soft);
  padding: 3px 8px;
  font-size: 12px;
  border-radius: var(--r-pill);
}
.hero-picker-tile.is-loading { opacity: 0.5; pointer-events: none; cursor: wait; }
.hero-picker-tile.is-loading::after {
  content: 'Setze…';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* ==========================================================
   Topographie · Vibe Card
   ========================================================== */
.md-topo-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 4px 0 2px;
}
.md-topo-vibe { display: flex; flex-direction: column; gap: 6px; }
.md-topo-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--red);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.md-topo-vibe-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
  margin: 0;
}
.md-topo-aesthetic {
  font-size: 12.5px;
  color: var(--text2);
  font-family: var(--mono);
  line-height: 1.5;
  margin: 0;
}
.md-topo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
}
.md-topo-cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  display: flex; flex-direction: column; gap: 2px;
}
.md-topo-cell dt {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.md-topo-cell dd {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
}
@media (max-width: 720px) {
  .md-topo-body { grid-template-columns: 1fr; gap: 16px; }
  .md-hero-actions { top: 10px; right: 10px; gap: 6px; }
  .md-hero-act span { display: none; }
  .md-hero-act { padding: 8px; }
}

/* ==========================================================
   Collapsible cards (Letzte Läufe etc.)
   ========================================================== */
.md-card-head-toggle {
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: color var(--t-fast);
}
.md-card-head-toggle:hover h2 { color: var(--red-soft); }
.md-card-head-toggle:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
  border-radius: var(--r-sm);
}
.md-collapse-chevron {
  margin-left: auto;
  color: var(--text3);
  transition: transform var(--t-base), color var(--t-fast);
}
.md-card-head-toggle:hover .md-collapse-chevron { color: var(--text); }
.md-collapsible.is-collapsed .md-collapse-chevron { transform: rotate(-90deg); }
.md-collapsible .md-collapse-body {
  overflow: hidden;
  transition: max-height var(--t-slow), opacity var(--t-base), margin-top var(--t-base), padding var(--t-base);
  max-height: 4000px;
}
.md-collapsible.is-collapsed .md-collapse-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}
.md-collapsible.is-collapsed .md-card-head { border-bottom: 0; padding-bottom: 6px; }
