/* ================================================================
   CamikaLabs Desktop — Persona 5 Theme
   Red / Yellow / Black  |  Sharp corners  |  Bold contrasts
   ================================================================ */

:root {
  /* ── Brand Colors ── */
  --p5-red: #e63946;
  --p5-red-light: #ff6b6b;
  --p5-red-dark: #c02836;
  --p5-yellow: #f5c518;
  --p5-yellow-dark: #d4a800;
  --p5-red-gradient: linear-gradient(135deg, #e63946, #ff6b6b);
  --p5-gold-gradient: linear-gradient(135deg, #f5c518, #ff8c00);

  /* ── Surface Colors (Dark) ──
     Neutralized from bluish (#16161d / #24242e) → pure black aligned with v4 reference.
     R≈G≈B curves, slight warmth instead of cold blue tint. */
  --p5-black: #0a0a0f;
  --p5-dark: #111118;           /* was #111118 */
  --p5-card: #16161d;           /* was #16161d — removed G/B tint */
  --p5-surface: #0a0a0f;        /* was #0a0a0f — merge with black */
  --p5-frame: #060609;          /* frame bg (header/sidebar) — one step darker than surface */
  --p5-border: #24242e;         /* was #24242e — neutralized blue-gray */
  --p5-input-bg: #16161d;       /* was #111118 — match card */
  --p5-shadow: rgba(0,0,0,0.4);
  --p5-overlay: rgba(0,0,0,0.75);

  /* ── Typography Colors (Dark) ──
     Neutralized from bluish (#b0b0c0 / #70708a) → R=G=B neutral gray to match v4 feel. */
  --p5-text: #e8e8e8;          /* was #e8e8ec — primary text, neutral */
  --p5-text-secondary: #b5b5b5; /* was #b0b0c0 — secondary, neutral */
  --p5-muted: #7a7a7a;          /* was #70708a — muted, neutral (lifted 10 units for contrast) */
  --p5-text-inverse: #0a0a0f;   /* Text on colored backgrounds */

  /* ── Typography Scale ── */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  /* Display font for menu labels / stepper / view titles — condensed industrial look, aligned with v4 reference.
     CJK chars fall through to the next font in the stack automatically. */
  --font-display: 'Oswald', 'Impact', 'Arial Narrow', var(--font-family);
  --text-xs: 11px;    /* Badges, timestamps */
  --text-sm: 12px;    /* Meta, captions, sidebar preview */
  --text-base: 14px;  /* Body text, cards, chat */
  --text-md: 16px;    /* Section titles, dialog headers */
  --text-lg: 18px;    /* Page titles, view headers */
  --text-xl: 22px;    /* Hero headings */
  --text-2xl: 28px;   /* Landing hero */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --leading-tight: 1.3;  /* Headings */
  --leading-normal: 1.6; /* Body text */
  --leading-relaxed: 1.8;/* Long-form reading */

  /* ── Dossier / Character File ── */
  --p5-dossier-bg: #15151c;
  --p5-dossier-grain: rgba(200,200,220,0.02);
  --p5-dossier-edge: rgba(120,125,160,0.25);
  --p5-dossier-stamp: rgba(230,57,70,0.7);

  /* ── Layout ── */
  --sidebar-width: 56px;
  --sidebar-expanded: 170px;
  --header-height: 48px;
}

/* ---- Light Theme ---- */
[data-theme="light"] {
  --p5-black: #f8f5f0;
  --p5-dark: #f0ede6;
  --p5-card: #ffffff;
  --p5-surface: #faf8f4;
  --p5-frame: #ece8e0;
  --p5-border: #d8d4cc;
  --p5-input-bg: #f0ede6;
  --p5-shadow: rgba(0,0,0,0.1);
  --p5-overlay: rgba(0,0,0,0.35);
  /* Typography Colors (Light) — neutralized from bluish */
  --p5-text: #1a1a1a;
  --p5-text-secondary: #4a4a4a; /* was #4a4a5a */
  --p5-muted: #8a8a8a;          /* was #8a8a9a */
  --p5-text-inverse: #ffffff;
}
[data-theme="light"] {
  --p5-dossier-bg: #edeef2;
  --p5-dossier-grain: rgba(100,100,130,0.04);
  --p5-dossier-edge: rgba(140,140,160,0.35);
  --p5-dossier-stamp: rgba(230,57,70,0.65);
}
[data-theme="light"] body {
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 40px, rgba(230,57,70,0.05) 40px, rgba(230,57,70,0.05) 41px);
}
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c0bdb5; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #a8a49c; }
[data-theme="light"] .dt-nav-item:hover { background: rgba(230,57,70,0.06); }
[data-theme="light"] .dt-sub-card {
  background: linear-gradient(135deg, rgba(245,197,24,0.15), rgba(230,57,70,0.1));
  border-color: rgba(245,197,24,0.35);
}
[data-theme="light"] .dt-sub-card:hover {
  background: linear-gradient(135deg, rgba(245,197,24,0.25), rgba(230,57,70,0.15));
}
[data-theme="light"] .dt-hero-bg::after {
  background: linear-gradient(180deg, rgba(248,245,240,0.4) 0%, rgba(248,245,240,0.85) 100%);
}
[data-theme="light"] .dt-hero-title {
  background: linear-gradient(135deg, #2a2a2a 30%, var(--p5-red) 100%);
  -webkit-background-clip: text;
}
[data-theme="light"] .dt-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.08); }
[data-theme="light"] .dt-discover-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.08); }
[data-theme="light"] .btn-google:hover { background: #f0ede6; }
[data-theme="light"] .dt-logo-img { filter: invert(1); }
[data-theme="light"] .login-modal-box { background: var(--p5-card); }
[data-theme="light"] .sub-modal .modal-box { background: var(--p5-card); }
[data-theme="light"] .confirm-modal-box { background: var(--p5-card); }
[data-theme="light"] .dt-pet-modal-box { background: var(--p5-card); }
[data-theme="light"] .btn-ref-copy:disabled { background: #d8d4cc; color: #999; }
[data-theme="light"] .btn-plan-current { background: #d8d4cc; }
[data-theme="light"] .plan-free { background: #d8d4cc; }
[data-theme="light"] .header-user-bar { background: transparent; }
[data-theme="light"] .header-user-bar:hover { background: transparent; }
[data-theme="light"] .tpl-search-bar { --tpl-search-bg: rgba(255,255,255,0.8); border-color: rgba(140,80,220,0.25); }
[data-theme="light"] #tpl-search-input { --tpl-search-ph: rgba(0,0,0,0.35); color: var(--p5-text); }
[data-theme="light"] #tpl-search-input::placeholder { color: rgba(0,0,0,0.35); }
[data-theme="light"] .sidebar-logo-short,
[data-theme="light"] .sidebar-logo-full { filter: invert(1); }
[data-theme="light"] .dt-pet-new-btn:hover { background: #d32f3f; }
[data-theme="light"] .shimmer-line {
  background: linear-gradient(90deg, var(--p5-dark) 25%, #e8e5de 37%, var(--p5-dark) 63%);
}
[data-theme="light"] .welcome-box {
  background: rgba(248,245,240,0.97);
  border-color: rgba(230,57,70,0.15);
}
[data-theme="light"] .welcome-box::before {
  background-image: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(230,57,70,0.03) 8px, rgba(230,57,70,0.03) 16px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: var(--p5-black);
  color: var(--p5-text);
  min-height: 100vh;
  overflow: hidden;
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 40px, rgba(230,57,70,0.03) 40px, rgba(230,57,70,0.03) 41px);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--p5-black); }
::-webkit-scrollbar-thumb { background: var(--p5-border); }
::-webkit-scrollbar-thumb:hover { background: var(--p5-muted); }

/* ================================================================
   GLOBAL BUTTON SYSTEM
   Base .dt-btn + variants: primary, ghost, icon, danger
   All buttons: border-radius:0, inline-flex, gap:6px, 13px font
   ================================================================ */
.dt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--p5-border); border-radius: 0;
  background: transparent; color: var(--p5-text-secondary);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.dt-btn svg { flex-shrink: 0; }

/* Primary — red gradient fill, white text */
.dt-btn-primary {
  background: var(--p5-red-gradient); border: none;
  color: #fff; font-weight: 600;
}
.dt-btn-primary:hover { opacity: 0.88; }
.dt-btn-primary:disabled { opacity: 0.4; }

/* Ghost — transparent bg, border, secondary text */
.dt-btn-ghost {
  background: transparent; border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
}
.dt-btn-ghost:hover { border-color: var(--p5-red); color: var(--p5-text); }

/* Outline-primary — transparent bg, red border+text, fills on hover */
.dt-btn-outline {
  background: transparent; border: 1px solid var(--p5-red);
  color: var(--p5-red);
}
.dt-btn-outline:hover { background: var(--p5-red); color: #fff; }

/* Danger — red text, fills red on hover */
.dt-btn-danger {
  background: transparent; border: 1px solid rgba(230,57,70,0.3);
  color: var(--p5-red);
}
.dt-btn-danger:hover { background: var(--p5-red); color: #fff; border-color: var(--p5-red); }

/* Icon-only button — no padding, no border */
.dt-btn-icon {
  background: none; border: 1px solid var(--p5-border);
  color: var(--p5-muted); padding: 6px;
}
.dt-btn-icon:hover { border-color: var(--p5-red); color: var(--p5-text); }

/* Size variants */
.dt-btn-sm { padding: 5px 14px; font-size: 11px; }
.dt-btn-lg { padding: 10px 22px; font-size: 14px; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.dt-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--p5-frame);
  border-right: 1px solid var(--p5-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.dt-sidebar:hover {
  width: var(--sidebar-expanded);
}

.dt-sidebar-logo {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
  overflow: hidden; white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
/* Collapsed: brand C mark (SVG) — signature glyph. */
.sidebar-logo-short {
  display: block;
  height: 24px;
  width: auto;
}
/* Expanded: full "Camika" wordmark (SVG) — white on dark frame. */
.sidebar-logo-full {
  display: none;
  height: 22px;
  width: auto;
}
.dt-sidebar:hover .sidebar-logo-short { display: none; }
.dt-sidebar:hover .sidebar-logo-full { display: block; }

.dt-sidebar-nav-top {
  flex-shrink: 0;
  padding: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dt-sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: none;
}
.dt-sidebar-nav::-webkit-scrollbar { display: none; }

.dt-nav-scroll-hint {
  display: flex;
  justify-content: center;
  padding: 4px 0;
  color: var(--p5-muted);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.dt-nav-scroll-hint.visible {
  opacity: 1;
  pointer-events: auto;
}
.dt-nav-scroll-hint:hover { color: var(--p5-text); }

.dt-sidebar-bottom {
  flex-shrink: 0;
  margin-top: auto;
}

.dt-sidebar-bottom .dt-nav-item.active {
  color: var(--p5-muted);
  background: none;
  border-left: none;
  padding-left: 20px;
}
.dt-sidebar-bottom .dt-nav-item.active:hover {
  color: var(--p5-text);
}

.dt-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--p5-muted);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, background .2s;
  text-align: left;
  position: relative;
}

.dt-nav-item svg:first-child { flex-shrink: 0; }

.dt-nav-item span {
  opacity: 0;
  transition: opacity .2s;
}

.dt-sidebar:hover .dt-nav-item span { opacity: 1; }

.dt-nav-item:hover {
  color: var(--p5-text);
  background: rgba(230,57,70,0.08);
}

.dt-nav-item.active {
  color: var(--p5-red);
  background: rgba(230,57,70,0.12);
  border-left: 3px solid var(--p5-red);
  padding-left: 17px;
}

.dt-nav-item.locked .lock-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--p5-muted);
  opacity: 0;
  transition: opacity .2s;
}

.dt-sidebar:hover .dt-nav-item.locked .lock-icon { opacity: 1; }

.dt-nav-divider {
  height: 1px;
  background: var(--p5-border);
  margin: 8px 16px;
}


/* Sidebar popover menu */
.dt-nav-popover-wrap {
  position: relative;
}

.dt-nav-popover {
  position: fixed;
  min-width: 180px;
  background: var(--p5-surface);
  border: 1px solid var(--p5-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  transition: opacity .2s, transform .2s, visibility .2s;
  z-index: 200;
  pointer-events: none;
}

.dt-nav-popover-wrap:hover .dt-nav-popover {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

.dt-nav-popover-title {
  padding: 6px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--p5-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--p5-border);
  margin-bottom: 4px;
  white-space: nowrap;
}

.dt-nav-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--p5-text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.dt-nav-popover-item:hover {
  background: var(--p5-hover);
}

.dt-nav-popover-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar theme toggle */
.dt-theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--p5-muted);
  font-size: 12px;
  transition: color .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.dt-theme-toggle:hover { color: var(--p5-text); }
.dt-theme-toggle svg { flex-shrink: 0; }
.dt-theme-toggle span {
  opacity: 0;
  transition: opacity .2s;
}
.dt-sidebar:hover .dt-theme-toggle span { opacity: 1; }

/* Sidebar subscription card */
.dt-sidebar-sub {
  padding: 8px;
  flex-shrink: 0;
  cursor: pointer;
}

.dt-sub-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px 0;
  background: linear-gradient(135deg, rgba(245,197,24,0.12), rgba(230,57,70,0.08));
  border: 1px solid rgba(245,197,24,0.25);
  color: var(--p5-yellow);
  font-size: 12px;
  font-weight: 600;
  transition: background .2s, border-color .2s, padding .25s;
  white-space: nowrap;
  overflow: hidden;
}

.dt-sidebar:hover .dt-sub-card {
  padding: 10px 12px;
  justify-content: center;
  gap: 10px;
}

.dt-sub-card span {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity .2s, width .25s;
}

.dt-sidebar:hover .dt-sub-card span { opacity: 1; width: auto; }

.dt-sub-card:hover {
  background: linear-gradient(135deg, rgba(245,197,24,0.2), rgba(230,57,70,0.15));
  border-color: var(--p5-yellow);
}

.dt-sub-card svg { flex-shrink: 0; color: var(--p5-yellow); }

/* ================================================================
   MAIN AREA
   ================================================================ */
.dt-main {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ================================================================
   HEADER
   ================================================================ */
.dt-header {
  position: relative;
  height: var(--header-height);
  background: var(--p5-frame);
  border-bottom: 2px solid var(--p5-red-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}
.dt-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--p5-red) 0%,
    var(--p5-red-dark) 30%,
    var(--p5-frame) 60%,
    var(--p5-red-dark) 90%,
    var(--p5-red) 100%
  );
  pointer-events: none;
}

.dt-header-left {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
  min-width: 0;
}

/* Breadcrumb — v5 .tcrumb style (mono uppercase, red current) */
.dt-crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 18px;
  margin-left: 18px;
  border-left: 1px solid var(--p5-border);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
  overflow: hidden;
  min-width: 0;
}
.dt-crumb:empty { display: none; }
.dt-crumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.dt-crumb-item.dt-crumb-current {
  color: var(--p5-red);
  font-weight: 700;
}
.dt-crumb-sep {
  color: var(--p5-border);
  user-select: none;
  flex-shrink: 0;
}

.dt-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
}
.dt-logo-img {
  height: 22px;
  width: auto;
  object-fit: contain;
}

.dt-header-right {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
  border-left: 1px solid var(--p5-border);
}
.dt-header-right > * {
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-right: 1px solid var(--p5-border);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--p5-text-secondary);
}
.dt-header-right > *:last-child { border-right: none; }
/* dt-header padding: let舱段 flush to right edge */
.dt-header { padding-right: 0; }

/* ================================================================
   CONTENT AREA
   ================================================================ */
.dt-content {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden; /* explicit — otherwise CSS promotes visible→auto, rendering an empty 15px horizontal scrollbar track when vertical scroll is active */
  padding: 0;
  position: relative; /* containing block for abs-positioned child views (e.g. games play panel) */
}

.dt-view { display: none; min-width: 0; }
.dt-view.active { display: block; }
#project-exec-view.active,
#gc-exec-view.active { display: flex; flex-direction: column; height: 100%; }

/* ================================================================
   INTERACTIVE GAMES VIEW
   ================================================================ */
.dt-games-view.active { display: block; position: relative; }
.games-list-panel { padding: 24px 32px 60px; }
.games-hero { margin-bottom: 28px; }
.games-hero-title { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--p5-text); margin: 0 0 8px; }
.games-hero-desc { font-size: var(--text-sm); color: var(--p5-muted); margin: 0; }

/* Game card */
.game-card {
  break-inside: avoid;
  margin-bottom: 20px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

.game-cover-wrap { position: relative; overflow: hidden; }
.game-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .4s;
}
.game-cover.loaded { opacity: 1; }
.game-cover-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, var(--p5-red), #16161d);
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-cover-placeholder span {
  font-size: 48px;
  font-weight: var(--weight-bold);
  color: rgba(255,255,255,.7);
}

/* Cover edit button — bottom-right overlay */
.game-cover-edit {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-card:hover .game-cover-edit { opacity: 1; }

.game-info { padding: 16px; }
.game-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--p5-text);
  margin: 0 0 8px;
}
.game-desc {
  font-size: var(--text-sm);
  color: var(--p5-text-secondary);
  line-height: var(--leading-normal);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.game-edit-desc {
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: var(--text-xs);
  padding: 4px 10px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.game-edit-desc:hover { color: var(--p5-red); border-color: var(--p5-red); }

/* Game modal — 85% screen overlay */
.games-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .25s;
}
.games-modal.active { opacity: 1; }
.games-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
}
.games-modal-container {
  position: relative;
  width: 85%;
  height: 85%;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}
.games-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  background: rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, border-color .2s;
}
.games-modal-close:hover {
  background: var(--p5-red);
  border-color: var(--p5-red);
}
#games-iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--p5-dark);
}

/* Footer */
.dt-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 24px;
  font-size: var(--text-xs);
  color: var(--p5-muted);
  border-top: 1px solid var(--p5-border);
  background: var(--p5-surface);
  flex-shrink: 0;
}
.dt-footer-sep {
  margin: 0 10px;
  opacity: .4;
}
.dt-footer a {
  color: var(--p5-muted);
  text-decoration: none;
  transition: color .2s;
}
.dt-footer a:hover {
  color: var(--p5-red);
}

/* ================================================================
   HOME VIEW — Hero
   ================================================================ */
.dt-hero {
  position: relative;
  padding: 56px 48px 40px;
  overflow: hidden;
  text-align: center;
}

.dt-hero-bg {
  position: absolute;
  inset: 0;
  background: url('/img/hero-bg-sm.webp') center/cover no-repeat;
  z-index: 0;
  transition: opacity .6s ease;
}

.dt-hero-bg.loaded {
  background-image: url('/img/hero-bg.webp');
}

.dt-hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,10,15,0.3) 0%, rgba(10,10,15,0.7) 100%);
}

.dt-hero-content {
  position: relative;
  z-index: 1;
  max-width: 90%;
  margin: 0 auto;
}

.dt-hero-title {
  font-size: 42px;
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fff 30%, var(--p5-yellow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.dt-hero-subtitle {
  font-size: 16px;
  color: var(--p5-muted);
  line-height: 1.6;
}

/* ================================================================
   HOME — Feature Cards
   ================================================================ */
.dt-features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 820px;
  margin: 0 auto 36px;
  padding: 0 48px;
}

.dt-feature-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 20px 16px;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.dt-feature-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--p5-red-gradient);
  opacity: 0;
  transition: opacity .2s;
}

.dt-feature-card:hover {
  transform: translateY(-3px);
  border-color: var(--p5-red);
  box-shadow: 0 6px 24px rgba(230,57,70,0.12);
}

.dt-feature-card:hover::before { opacity: 1; }

.dt-fc-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.dt-feature-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--p5-text);
  margin-bottom: 4px;
}

.dt-feature-card p {
  font-size: 12px;
  color: var(--p5-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Selected card */
.dt-feature-card.selected {
  border-color: var(--p5-red);
  background: rgba(230,57,70,0.08);
}
.dt-feature-card.selected::before { opacity: 1; }

/* Disabled card (Coming Soon) */
.dt-feature-card.disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.dt-coming-soon {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--p5-yellow);
  background: rgba(245,197,24,0.12);
  padding: 2px 8px;
  margin-top: 4px;
}

/* ================================================================
   HOME — Model Selector (for Quick Generate)
   ================================================================ */
.dt-model-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}

.dt-model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.dt-model-option:hover {
  border-color: #555;
  color: var(--p5-text);
}

.dt-model-option.active {
  border-color: var(--p5-red);
  color: var(--p5-text);
  background: rgba(230,57,70,0.08);
}

.dt-model-option svg { flex-shrink: 0; }

/* ================================================================
   HOME — Quick Input Section
   ================================================================ */
.dt-input-section {
  max-width: 680px;
  margin: 0 auto 48px;
  padding: 0 48px;
  text-align: center;
}

.dt-input-hint {
  display: none;
}

.dt-quick-input {
  display: flex;
  gap: 0;
  border: 2px solid var(--p5-border);
  transition: border-color .3s;
}

.dt-quick-input:focus-within {
  border-color: var(--p5-red);
}

.dt-quick-input input {
  flex: 1;
  padding: 18px 20px;
  background: var(--p5-dark);
  border: none;
  color: var(--p5-text);
  font-size: 16px;
  outline: none;
  height: 54px;
}

.dt-quick-input input::placeholder { color: var(--p5-muted); }
.dt-quick-input input[type="search"]::-webkit-search-decoration,
.dt-quick-input input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.dt-quick-go {
  padding: 0 28px;
  height: 54px;
  background: var(--p5-red-gradient);
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: opacity .2s;
}

.dt-quick-go:hover { opacity: 0.88; }

/* ================================================================
   HOME — Section Header
   ================================================================ */
.dt-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px 16px;
}

.dt-section-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--p5-text);
}

.dt-see-all {
  background: none;
  border: none;
  color: var(--p5-red);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .2s;
}

.dt-see-all:hover { color: var(--p5-red-light); }

/* ================================================================
   HOME — Preview Grid (limited items)
   ================================================================ */
.dt-preview-grid {
  /* Horizontal margin (not padding) — layoutMasonry places absolutely-positioned cards
     relative to this grid's padding-box, so horizontal padding would be ignored and
     cards would touch the viewport edges. Margin shrinks the grid's outer box instead. */
  margin: 0 48px;
  padding-bottom: 48px;
}

/* ================================================================
   DISCOVER / TEMPLATES VIEWS
   ================================================================ */
#discover-view, #templates-view {
  padding: 28px 48px 40px;
}

/* ================================================================
   FILTER BAR
   ================================================================ */
.dt-filter-bar {
  display: flex; gap: 8px; margin-bottom: 20px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dt-filter-bar::-webkit-scrollbar { display: none; }
.dt-filter-tab {
  padding: 6px 16px; font-size: 13px; font-weight: 500;
  background: transparent; color: var(--p5-muted); border: 1px solid var(--p5-border);
  cursor: pointer; white-space: nowrap; transition: all .2s;
}
.dt-filter-tab:hover { color: var(--p5-text); border-color: rgba(230,57,70,0.5); }
.dt-filter-tab.active {
  color: #fff; background: var(--p5-red); border-color: var(--p5-red);
}

/* ================================================================

/* ================================================================
   TEMPLATE HERO (gradient bg + title + search + pills)
   ================================================================ */
.tpl-hero {
  text-align: center;
  padding: 20px 48px 16px;
  margin: -28px -48px 20px;
  background: linear-gradient(135deg, rgba(230,57,70,0.10) 0%, rgba(230,57,70,0.04) 100%);
  border-bottom: 1px solid var(--p5-border);
}
.tpl-hero-title {
  font-family: var(--font-display);
  font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--p5-text);
  margin: 0 0 16px; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Search bar — centered, prominent */
.tpl-search-bar {
  position: relative; display: flex; align-items: center;
  max-width: 680px; margin: 0 auto 24px;
  background: var(--tpl-search-bg, rgba(18,18,24,0.7));
  border: 1.5px solid rgba(140,80,220,0.3);
  backdrop-filter: blur(10px);
  transition: border-color .25s, box-shadow .25s;
}
.tpl-search-bar:focus-within {
  border-color: var(--p5-red);
  box-shadow: 0 0 0 3px rgba(230,57,70,0.12);
}
.tpl-search-icon {
  position: absolute; left: 18px;
  color: var(--p5-muted); pointer-events: none;
}
#tpl-search-input {
  width: 100%; padding: 12px 42px 12px 50px;
  background: transparent; border: none; outline: none;
  color: var(--p5-text); font-size: var(--text-base);
}
#tpl-search-input::placeholder { color: var(--tpl-search-ph, rgba(255,255,255,0.35)); }
.tpl-search-clear {
  position: absolute; right: 14px;
  background: none; border: none; color: var(--p5-muted);
  cursor: pointer; padding: 4px; line-height: 0;
  transition: color .2s;
}
.tpl-search-clear:hover { color: var(--p5-text); }

/* Category pills — horizontal scrollable row with arrow navigation */
.tpl-categories-wrap {
  position: relative;
  display: flex; align-items: center; gap: 0;
}
.tpl-cat-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 2; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--p5-surface);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--p5-text-secondary); cursor: pointer;
  transition: opacity .2s, color .2s, border-color .2s, background .2s;
  opacity: 0; pointer-events: none;
}
.tpl-cat-arrow:hover { color: #fff; border-color: var(--p5-red); background: var(--p5-dark); }
.tpl-cat-arrow.visible { opacity: 1; pointer-events: auto; }
.tpl-cat-arrow-left { left: 0; }
.tpl-cat-arrow-right { right: 0; }
/* No fade gradients needed — page-based navigation hides overflow pills */
.tpl-categories {
  display: flex; gap: 10px;
  flex-wrap: nowrap; flex: 1; min-width: 0;
  overflow: hidden; padding: 0 36px;
}
.tpl-cat-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 0 0 calc((100% - 70px) / 8);
  min-width: 0; padding: 8px 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.65);
  font-family: var(--font-display);
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all .25s ease;
}
.tpl-cat-pill svg { flex-shrink: 0; transition: transform .25s ease; }

/* Hover */
.tpl-cat-pill:hover {
  border-color: rgba(230,57,70,0.45);
  color: #fff;
  background: rgba(230,57,70,0.08);
}

/* Active: red theme */
.tpl-cat-pill.active {
  border-color: var(--p5-red);
  color: #fff;
  background: rgba(230,57,70,0.15);
}
.tpl-cat-pill.active svg { stroke: rgba(180,140,255,0.9); }
[data-theme="light"] .tpl-cat-pill { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.10); color: rgba(0,0,0,0.55); }
[data-theme="light"] .tpl-cat-pill:hover { background: rgba(140,80,220,0.08); border-color: rgba(140,80,220,0.35); color: #1a1a1a; }
[data-theme="light"] .tpl-cat-pill.active { background: rgba(140,80,220,0.12); border-color: rgba(140,80,220,0.5); color: #1a1a1a; }

/* ---------- Secondary Toolbar (type switcher + model filter) ---------- */
.tpl-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin: 4px 0 10px;
}

/* Type switcher: blends with background, only red active block draws focus */
.tpl-type-switcher {
  display: inline-flex;
  gap: 0;
}
.tpl-type-seg {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: color .18s, background .18s;
  white-space: nowrap;
}
.tpl-type-seg + .tpl-type-seg { border-left: none; }
.tpl-type-seg:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tpl-type-seg.active {
  background: #e63946;
  border-color: #e63946;
  color: #fff;
  position: relative; z-index: 1;
}
.tpl-type-seg.active:hover {
  background: #d12f3c;
  border-color: #d12f3c;
}
[data-theme="light"] .tpl-type-seg { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.10); color: rgba(0,0,0,0.55); }
[data-theme="light"] .tpl-type-seg:hover { color: #1a1a1a; background: rgba(0,0,0,0.06); }
[data-theme="light"] .tpl-type-seg.active { background: #e63946; border-color: #e63946; color: #fff; }
[data-theme="light"] .tpl-model-btn { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.10); color: rgba(0,0,0,0.6); }
[data-theme="light"] .tpl-model-btn:hover { border-color: rgba(230,57,70,0.4); color: #1a1a1a; }
[data-theme="light"] .tpl-model-popover { background: #fff; border-color: rgba(0,0,0,0.12); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
[data-theme="light"] .tpl-model-opt { color: rgba(0,0,0,0.7); }
[data-theme="light"] .tpl-model-opt:hover { background: rgba(0,0,0,0.04); color: #1a1a1a; }
[data-theme="light"] .tpl-model-opt.active { background: rgba(230,57,70,0.08); color: #e63946; }

/* Model filter ghost button + dropdown — narrow, blends with background */
.tpl-model-filter { position: relative; }
.tpl-model-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.78);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color .18s, color .18s, background .18s;
  min-width: 0;
  justify-content: space-between;
}
.tpl-model-btn:hover {
  border-color: rgba(230,57,70,0.45);
  color: #fff;
}
.tpl-model-btn[aria-expanded="true"] {
  border-color: #e63946;
  color: #fff;
}
.tpl-model-btn-arrow { transition: transform .25s ease; flex-shrink: 0; }
.tpl-model-btn[aria-expanded="true"] .tpl-model-btn-arrow { transform: rotate(180deg); }

.tpl-model-popover {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px; max-width: 280px;
  background: #16161d;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 14px 36px rgba(0,0,0,0.55);
  z-index: 50;
  padding: 6px;
}
.tpl-model-popover-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 360px; overflow-y: auto;
}
.tpl-model-opt {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none;
  padding: 10px 12px;
  color: rgba(255,255,255,0.82);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.tpl-model-opt:hover { background: rgba(255,255,255,0.06); color: #fff; }
.tpl-model-opt.active {
  background: rgba(230,57,70,0.14);
  color: #fff;
}
.tpl-model-opt-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(230,57,70,0.85);
  flex-shrink: 0;
}
.tpl-model-opt-name { flex: 1; }
.tpl-model-opt .tpl-model-opt-check {
  opacity: 0;
  color: #e63946;
  flex-shrink: 0;
}
.tpl-model-opt.active .tpl-model-opt-check { opacity: 1; }

/* Infinite-scroll sentinel */
.tpl-load-sentinel {
  display: flex; align-items: center; justify-content: center;
  min-height: 60px; padding: 24px 0;
}
.tpl-load-spinner svg { animation: dt-spin 1s linear infinite; }
.tpl-load-end {
  color: var(--p5-muted);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
@keyframes dt-spin { to { transform: rotate(360deg); } }
/* ================================================================
   PINTEREST MASONRY (shared) — JS-positioned via layoutMasonry()
   Cards are position:absolute; container height set by JS.
   Column count: 3 (<1400) / 4 (1400-1799) / 5 (1800+) — mirrored in JS.
   ================================================================ */
.discover-grid {
  position: relative;
}

/* ================================================================
   DISCOVER CARDS
   ================================================================ */
.discover-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  overflow: hidden;
  cursor: default;
}
.source-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.3px; line-height: 18px;
  background: rgba(0,0,0,0.7); color: #ccc;
  border: 1px solid rgba(255,255,255,0.15);
}
.source-mj { color: #14b8a6; border-color: rgba(20,184,166,0.4); }
.source-nano { color: var(--p5-red-light); border-color: rgba(230,57,70,0.4); }
.source-xai { color: #a78bfa; border-color: rgba(167,139,250,0.4); }
.source-single { color: var(--p5-yellow); border-color: rgba(245,197,24,0.4); }
.source-gc { color: #fb923c; border-color: rgba(251,146,60,0.4); }

.discover-card .image-grid { width: 100%; }
.discover-card .image-grid.cols-1 img { width: 100%; display: block; max-height: 480px; object-fit: cover; }
.discover-card .image-grid.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.discover-card .image-grid.cols-2 img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.discover-card video { width: 100%; display: block; }

.discover-card .card-info { padding: 12px 14px; }

.prompt-text {
  font-size: 12px;
  color: var(--p5-text);
  opacity: 0.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  margin-bottom: 8px;
  word-break: break-word;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.author { font-size: 11px; color: var(--p5-muted); display: inline-flex; align-items: center; gap: 4px; }
.author-avatar-sm { width: 16px; height: 16px; object-fit: cover; }

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

.btn-like {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; color: var(--p5-muted);
  font-size: 12px; cursor: pointer; padding: 4px 6px;
  transition: color .2s;
}
.btn-like:hover { color: var(--p5-red); }
.btn-like.liked { color: var(--p5-red); }
.btn-like { position: relative; }
.btn-like svg {
  width: 16px;
  height: 16px;
  transform-origin: center;
  transition: transform .15s ease;
}

/* ── Heart pop: SVG-only elastic bounce ── */
@keyframes btn-like-heart-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.5); }
  55%  { transform: scale(0.85); }
  80%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes btn-like-heart-shrink {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.75); }
  100% { transform: scale(1); }
}
.btn-like.just-liked svg {
  animation: btn-like-heart-pop .6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-like.just-unliked svg {
  animation: btn-like-heart-shrink .3s ease-out;
}

/* ── Particle burst — 6 tiny dots radiating outward like confetti ── */
.btn-like.just-liked::after {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  pointer-events: none;
  /* Six sparks using a single element via radial box-shadow */
  box-shadow:
     0 -12px 0 0 #e63946,
     11px -6px 0 0 #f5c518,
     11px  6px 0 0 #ff6b6b,
     0  12px 0 0 #e63946,
    -11px  6px 0 0 #f5c518,
    -11px -6px 0 0 #ff6b6b;
  animation: btn-like-sparks .7s ease-out forwards;
}
@keyframes btn-like-sparks {
  0%   { transform: scale(0); opacity: 1; }
  60%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.btn-use {
  padding: 4px 12px;
  background: rgba(230,57,70,0.15);
  border: 1px solid rgba(230,57,70,0.3);
  color: var(--p5-red);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-use:hover { background: rgba(230,57,70,0.25); }

/* ================================================================
   TEMPLATE CARDS
   ================================================================ */
.tpl-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  overflow: hidden;
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .2s, box-shadow .2s;
}
.tpl-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.tpl-cover { width: 100%; display: block; max-height: 400px; object-fit: cover; }
.tpl-cover-placeholder {
  width: 100%; aspect-ratio: 16/10;
  background: linear-gradient(135deg, var(--p5-card), var(--p5-border));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 48px; font-weight: var(--weight-bold); letter-spacing: 0.04em;
  color: var(--p5-red);
}
.tpl-info { padding: 12px 14px; }
.tpl-category {
  display: inline-block; font-family: var(--font-display);
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--p5-yellow); background: rgba(245,197,24,0.12);
  padding: 2px 8px; margin-bottom: 6px;
}
.tpl-title {
  font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--p5-text);
  margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tpl-desc {
  font-size: var(--text-sm); color: var(--p5-muted); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.5;
}
.tpl-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tpl-tag { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; background: var(--p5-dark); border: 1px solid var(--p5-border); color: var(--p5-muted); }
.tpl-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(36,36,46,0.25);
}
.tpl-author { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--p5-muted); }
.tpl-author-avatar { width: 20px; height: 20px; object-fit: cover; display: block; }
.tpl-author-letter {
  width: 20px; height: 20px;
  background: var(--p5-red-gradient);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-xs); font-weight: var(--weight-bold); color: #fff;
}
.tpl-like { font-size: var(--text-sm); }

/* ================================================================
   PROJECT EXECUTION VIEW
   ================================================================ */
.dt-exec-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.dt-exec-input-panel {
  padding: 20px 24px;
  border-right: 1px solid var(--p5-border);
  overflow-y: auto;
  background: var(--p5-surface);
}

.dt-exec-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--p5-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 12px;
  transition: color .2s;
}

.dt-exec-back:hover { color: var(--p5-red); }

.dt-exec-input-panel .dt-gen-title {
  position: relative;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.dt-exec-input-panel .dt-gen-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 120px;
  height: 2px;
  background: var(--p5-red);
}
.dt-exec-summary {
  font-size: 12px;
  color: var(--p5-muted);
  margin: 0 0 20px;
  line-height: 1.6;
}

.dt-exec-input-panel .form-group { margin-bottom: 14px; }
.dt-exec-input-panel .form-group label { display: block; font-size: 12px; color: var(--p5-muted); margin-bottom: 4px; font-weight: 600; }
.dt-exec-input-panel textarea,
.dt-exec-input-panel input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.dt-exec-input-panel textarea:focus,
.dt-exec-input-panel input:focus { border-color: var(--p5-red); }

.dt-exec-model-info {
  font-size: 11px;
  color: var(--p5-muted);
  margin-bottom: 12px;
}

/* Execution history panel (right) */
.dt-exec-history-panel {
  padding: 24px;
  overflow-y: auto;
}

.dt-exec-history-panel h3,
.dt-gc-result-panel > h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--p5-text);
  margin-bottom: 16px;
}

.dt-exec-item {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  margin-bottom: 12px;
  transition: border-color .2s;
  cursor: pointer;
}

.dt-exec-item:hover { border-color: var(--p5-red); }

.dt-exec-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--p5-muted);
}

.dt-exec-item-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
}

.dt-exec-item-status.s-success { color: #22c55e; background: rgba(34,197,94,0.1); }
.dt-exec-item-status.s-failure { color: #ef4444; background: rgba(239,68,68,0.1); }
.dt-exec-item-status.s-generating_prompt, .dt-exec-item-status.s-running_model, .dt-exec-item-status.s-running { color: var(--p5-yellow); background: rgba(245,197,24,0.1); }

/* Optimistic pending card (inserted instantly on 运行 click, before any API round-trip)
   — gives user visual receipt that the click registered while safety-check + POST /execute
   are still in-flight (2-4s total). Replaced by dtLoadExecHistory when exec_id returns. */
.dt-exec-item-pending {
  border-left: 2px solid var(--p5-red);
  animation: dt-ehi-pending-pulse 1.2s ease-in-out infinite;
}
.dt-exec-item-status.s-running { display: inline-flex; align-items: center; gap: 6px; }
.dt-ehi-pending-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: dt-ehi-pending-spin .8s linear infinite;
}
@keyframes dt-ehi-pending-spin { to { transform: rotate(360deg); } }
@keyframes dt-ehi-pending-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.72; } }

.dt-exec-item-body {
  display: none;
  padding: 0 14px 14px;
}

.dt-exec-item.expanded .dt-exec-item-body { display: block; }

/* History item action icons */
.dt-ehi-eye, .dt-ehi-del {
  cursor: pointer; color: var(--p5-muted); display: inline-flex; align-items: center;
  transition: color .2s;
}
.dt-ehi-eye:hover { color: var(--p5-text); }
.dt-ehi-eye.active { color: var(--p5-red); }
.dt-ehi-del:hover { color: #ef4444; }

/* Prompt toggle row */
.dt-ehi-prompt-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--p5-red); cursor: pointer;
  padding: 6px 0; margin-top: 8px; user-select: none;
}
.dt-ehi-copy {
  background: none; border: 1px solid var(--p5-border); color: var(--p5-muted);
  cursor: pointer; padding: 4px 6px; display: inline-flex; align-items: center;
  transition: color .2s, border-color .2s;
}
.dt-ehi-copy:hover { color: var(--p5-red); border-color: var(--p5-red); }
.dt-ehi-prompt-text {
  font-size: 11px; color: var(--p5-muted); background: var(--p5-dark);
  padding: 10px; margin-top: 4px; white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--p5-border); max-height: 200px; overflow-y: auto;
}

/* PC: hide prompt toggle arrow (H5 only) */
.dt-exec-prompt-toggle { display: none; }
.dt-exec-prompt-header { cursor: default; }

.dt-exec-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.dt-exec-media-item { position: relative; }
.dt-exec-result-grid img {
  width: 100%;
  display: block;
  cursor: pointer;
}
.dt-exec-result-grid video {
  width: 100%;
  display: block;
}
.dt-exec-set-cover, .dt-gc-set-cover {
  position: absolute; bottom: 6px; right: 6px; padding: 5px 14px;
  font-size: 11px; letter-spacing: 0.3px;
  background: rgba(0,0,0,0.8); color: rgba(255,255,255,0.9); border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer; opacity: 0; transition: opacity .2s, background .15s;
  backdrop-filter: blur(4px);
}
.dt-exec-set-cover:hover, .dt-gc-set-cover:hover {
  background: var(--p5-red); border-color: var(--p5-red); color: #fff;
}
.dt-exec-media-item:hover .dt-exec-set-cover,
.dt-gc-media-item:hover .dt-gc-set-cover { opacity: 1; }

/* ================================================================
   TEMPLATE DETAIL VIEW
   ================================================================ */
.dt-tpl-detail { padding: 24px 32px; }

/* Template detail loading skeleton */
.dt-tpl-loading { padding: 20px 0; }
.dt-tpl-skel-cover { width: 100%; max-width: 360px; height: 240px; background: var(--p5-border); }
.dt-tpl-skel-lines { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.dt-tpl-skel-line { height: 16px; background: var(--p5-border); }
.dt-tpl-skel-line.w60 { width: 60%; }
.dt-tpl-skel-line.w90 { width: 90%; }
.dt-tpl-skel-line.w40 { width: 40%; }
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.dt-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--p5-muted); font-size: 13px;
  cursor: pointer; padding: 4px 0; margin-bottom: 16px;
}
.dt-back-btn:hover { color: var(--p5-text); }
.dt-tpl-hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-bottom: 28px;
}
.dt-tpl-cover-wrap {
  position: relative;
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  overflow: hidden; height: 400px;
}
.dt-tpl-cover { width: 100%; height: 100%; object-fit: contain; display: block; }
.dt-tpl-info { display: flex; flex-direction: column; gap: 12px; }
.dt-tpl-category {
  display: inline-block; padding: 2px 10px;
  font-family: var(--font-display);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--p5-yellow); border: 1px solid rgba(245,197,24,0.3);
  background: rgba(245,197,24,0.08); width: fit-content;
}
.dt-tpl-info h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl); font-weight: var(--weight-bold);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--p5-text); margin: 0; line-height: 1.2;
}
.dt-tpl-info p { font-size: var(--text-base); color: var(--p5-muted); margin: 0; line-height: 1.6; }
.dt-tpl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-tpl-tags span {
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--p5-text);
  background: var(--p5-dark); border: 1px solid var(--p5-border);
}
.dt-tpl-vars { font-size: var(--text-sm); color: var(--p5-muted); }
.dt-tpl-vars h4 {
  font-family: var(--font-display);
  color: var(--p5-text); font-size: var(--text-sm); font-weight: var(--weight-semibold);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin: 0 0 6px;
}
.dt-tpl-vars .var-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-tpl-vars .var-tag {
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--p5-yellow);
  background: rgba(245,197,24,0.08); border: 1px solid rgba(245,197,24,0.2);
}
.dt-tpl-author {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); color: var(--p5-muted);
}
.dt-tpl-author img { width: 28px; height: 28px; object-fit: cover; }
.dt-tpl-author .author-letter {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  font-family: var(--font-display);
  font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--p5-text);
}
.dt-tpl-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.dt-tpl-use-btn {
  padding: 10px 28px; background: var(--p5-red); color: #fff;
  border: none;
  font-family: var(--font-display);
  font-size: var(--text-base); font-weight: var(--weight-bold);
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
}
.dt-tpl-use-btn:hover { background: var(--p5-red-light); }
.dt-tpl-use-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dt-tpl-like {
  padding: 8px 12px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-muted); cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.dt-tpl-results { margin-top: 8px; }
.dt-tpl-results h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg); font-weight: var(--weight-bold);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--p5-text); margin: 0 0 16px;
}

/* Composite Landing Page Preview */
.dt-tpl-preview { margin-top: 32px; margin-bottom: 8px; max-width: 1100px; }
.dt-tpl-preview-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.dt-tpl-preview-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg); font-weight: var(--weight-bold);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--p5-text); margin: 0;
}
.dt-tpl-preview-expand {
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-muted); cursor: pointer; padding: 6px 8px;
  display: flex; align-items: center; transition: color .2s, border-color .2s;
}
.dt-tpl-preview-expand:hover { color: var(--p5-text); border-color: var(--p5-text); }
.dt-tpl-preview-body {
  border: 1px solid var(--p5-border); background: #fff;
  overflow: hidden; max-height: 700px;
}
.dt-tpl-preview-body iframe {
  display: block; width: 100%; min-height: 400px; border: none; background: #fff;
}
.preview-lb-content { width: 90vw; height: 90vh; background: #fff; }
.preview-lb-content iframe { width: 100%; height: 100%; border: none; background: #fff; }

/* ================================================================
   GROUPCOMBO EXECUTION VIEW
   ================================================================ */
.dt-gc-layout {
  display: grid;
  grid-template-columns: minmax(0, 520px) 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}
.dt-gc-input-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px 24px;
  border-right: 1px solid var(--p5-border);
  background: var(--p5-surface);
  overflow-y: auto;
}
.dt-gc-result-panel {
  overflow-y: auto;
  padding: 24px;
}
.dt-gc-type-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.dt-gc-type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: 11px; color: var(--p5-muted);
  border: 1px solid var(--p5-border); background: var(--p5-dark);
}

/* Scene variable fields */
.dt-gc-field-group { margin-bottom: 12px; }
.dt-gc-field-group label {
  display: block; font-size: 12px; color: var(--p5-red); font-weight: 600; margin-bottom: 6px;
}
.dt-gc-field-input {
  width: 100%; padding: 10px 12px; background: var(--p5-dark);
  border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 13px; outline: none;
}
.dt-gc-field-input:focus { border-color: var(--p5-red); }

/* Generic select — P5 themed, sharp corners, custom caret */
.dt-select {
  padding: 7px 28px 7px 10px;
  background-color: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23e63946' stroke-width='3'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 10px 10px;
  transition: border-color 0.15s;
}
.dt-select:hover { border-color: var(--p5-text-secondary); }
.dt-select:focus { border-color: var(--p5-red); }
.dt-select:disabled { opacity: 0.5; cursor: not-allowed; }
.dt-select option { background: var(--p5-dark); color: var(--p5-text); }
.dt-select-sm { padding: 5px 24px 5px 8px; font-size: 12px; background-size: 9px 9px; background-position: right 7px center; }

/* Image upload field */
/* Dynamic form multi-image */
.dt-dyn-img-previews { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.dt-dyn-img-thumb {
  position: relative; width: 72px; height: 72px;
}
.dt-dyn-img-thumb img { width: 72px; height: 72px; object-fit: cover; border: 1px solid var(--p5-border); }
.dt-dyn-img-remove {
  position: absolute; top: -4px; right: -4px; width: 16px; height: 16px;
  background: var(--p5-red); color: #fff; font-size: 10px; line-height: 16px;
  text-align: center; cursor: pointer; border: none; padding: 0;
}

.dt-gc-img-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.dt-gc-img-thumb {
  position: relative; width: 72px; height: 72px;
}
.dt-gc-img-thumb img { width: 72px; height: 72px; object-fit: cover; border: 1px solid var(--p5-border); }
.dt-gc-img-remove {
  position: absolute; top: -4px; right: -4px; width: 16px; height: 16px;
  background: var(--p5-red); color: #fff; font-size: 10px; line-height: 16px;
  text-align: center; cursor: pointer; border: none; padding: 0;
}
.dt-gc-upload-btn {
  padding: 6px 16px; background: var(--p5-dark); border: 1px dashed var(--p5-border);
  color: var(--p5-muted); cursor: pointer; font-size: 12px;
}
.dt-gc-upload-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }

/* Group structure cards */
.dt-gc-section-title {
  font-size: 14px; color: var(--p5-red); margin: 16px 0 10px; font-weight: 600;
}
.dt-gc-group-card {
  padding: 10px 12px; background: var(--p5-card); margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--p5-border);
}
.dt-gc-group-card:hover { border-color: var(--p5-red); }
.dt-gc-group-id { flex: 1; font-size: 13px; color: var(--p5-text); }
.dt-gc-group-model { font-size: 11px; color: var(--p5-muted); }
.dt-gc-group-desc {
  font-size: 11px; color: #888888; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-gc-pe-toggle { cursor: pointer; font-size: 11px; color: var(--p5-muted); }
.dt-gc-pe-toggle:hover { color: var(--p5-red); }
.dt-gc-pe-panel {
  margin-top: 8px; padding: 8px; background: var(--p5-dark);
  font-size: 11px; color: #888888; max-height: 200px; overflow: auto;
  border: 1px solid var(--p5-border);
}

/* Cost + Execute */
.dt-gc-cost-bar { margin: 16px 0 8px; }
.dt-gc-cost-text { font-size: 13px; color: var(--p5-muted); }
.dt-gc-exec-submit { max-width: none; }

/* Results */
.dt-gc-result-header {
  display: flex; align-items: center; gap: 8px; margin: 16px 0 8px;
}
.dt-gc-result-header h3 { font-size: 13px; color: var(--p5-red); margin: 0; }
.dt-gc-result-btn {
  padding: 3px 10px; font-size: 11px; border: 1px solid var(--p5-border);
  background: transparent; color: var(--p5-muted); cursor: pointer;
}
.dt-gc-result-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.dt-gc-result-tab { padding: 3px 10px; font-size: 11px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-muted); cursor: pointer; }
.dt-gc-result-tab:hover { border-color: var(--p5-red); color: var(--p5-red); }
.dt-gc-result-tab.active { border-color: var(--p5-red); color: var(--p5-red); }

/* Composite iframe */
.dt-gc-composite { margin-bottom: 12px; border: 1px solid var(--p5-border); }
.dt-gc-composite-header {
  padding: 5px 12px; background: var(--p5-dark); font-size: 10px; color: #888888;
  display: flex; justify-content: space-between; align-items: center;
}
.dt-gc-composite iframe {
  width: 100%; min-height: 600px; border: none; background: #fff;
}

/* Group result */
.dt-gc-group-result { margin-bottom: 12px; border: 1px solid var(--p5-border); }
.dt-gc-group-result-header {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--p5-dark); cursor: pointer;
}
.dt-gc-group-result-header:hover { background: var(--p5-card); }
.dt-gc-group-result-body { padding: 10px 12px; }

/* Media grid */
.dt-gc-media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px;
}
.dt-gc-media-item { position: relative; }
.dt-gc-media-item img {
  width: 100%; height: auto; cursor: pointer; border: 1px solid var(--p5-border);
}
.dt-gc-media-item img:hover { border-color: var(--p5-red); }
.dt-gc-media-item video { width: 100%; border: 1px solid var(--p5-border); }
/* dt-gc-set-cover styles merged with dt-exec-set-cover above */

/* Prompt editor */
.dt-gc-prompt-editor {
  margin-top: 8px; padding: 8px; background: var(--p5-black);
  border: 1px solid var(--p5-border);
}
.dt-gc-prompt-editor textarea {
  width: 100%; height: 80px; max-height: 200px; margin-bottom: 4px;
  padding: 6px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: #ccc; font-size: 10px; resize: vertical; outline: none;
  font-family: monospace; overflow-y: auto;
}

/* Text content in results */
.dt-gc-text-content {
  font-size: 12px; color: var(--p5-text); line-height: 1.6;
  max-height: 300px; overflow: auto; padding: 8px; background: var(--p5-dark);
}

/* History items */
.dt-gc-history-item {
  padding: 8px 12px; background: var(--p5-card); margin-bottom: 4px;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 12px; border: 1px solid transparent;
}
.dt-gc-history-item:hover { border-color: var(--p5-red); }
.dt-gc-history-item.active { border-color: var(--p5-red); background: rgba(230,57,70,0.06); }
.dt-gc-history-item.active .dt-gc-history-del { opacity: 1; }
.dt-gc-inline-result { border-left: 2px solid var(--p5-red); margin: 0 0 8px 12px; padding-left: 8px; }
.dt-gc-history-del {
  opacity: 0; padding: 2px 6px; border: none; background: transparent;
  color: var(--p5-muted); cursor: pointer; font-size: 14px; line-height: 1;
}
.dt-gc-history-item:hover .dt-gc-history-del { opacity: 1; }
.dt-gc-history-del:hover { color: var(--p5-red); }

/* GC Wizard: output type buttons (no checkbox) */
.dt-gc-otype-row { display: flex; gap: 8px; }
.dt-gc-otype-btn {
  flex: 1; padding: 10px 0; border: 1px solid var(--p5-border); background: transparent;
  color: var(--p5-muted); cursor: pointer; font-size: 13px; text-align: center;
}
.dt-gc-otype-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-gc-otype-btn.active {
  border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08);
}

/* GC Wizard: toggle buttons (no checkbox) */
.dt-gc-toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }
.dt-gc-toggle-btn {
  padding: 8px 14px; border: 1px solid var(--p5-border); background: transparent;
  color: var(--p5-muted); cursor: pointer; font-size: 12px; text-align: left;
}
.dt-gc-toggle-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-gc-toggle-btn.active {
  border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08);
}

/* GC Wizard: preset grid */
.dt-gc-preset-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px;
}
.dt-gc-preset-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--p5-border); background: transparent;
  color: var(--p5-muted); cursor: pointer; font-size: 11px;
}
.dt-gc-preset-item:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-gc-preset-item.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08); }

/* GC Wizard: content scale */
.dt-gc-scale-row { display: flex; gap: 8px; }
.dt-gc-scale-card {
  flex: 1; padding: 10px 12px; border: 1px solid var(--p5-border);
  background: transparent; cursor: pointer; text-align: center;
}
.dt-gc-scale-card:hover { border-color: var(--p5-red); }
.dt-gc-scale-card.active,
.dt-gc-scale-card:has(input:checked) {
  border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08);
}
.dt-gc-scale-card input { display: none; }
.dt-gc-scale-name { display: block; font-size: 13px; font-weight: 600; color: var(--p5-text); }
.dt-gc-scale-card.active .dt-gc-scale-name,
.dt-gc-scale-card:has(input:checked) .dt-gc-scale-name { color: var(--p5-red); }
.dt-gc-scale-desc { display: block; font-size: 10px; color: var(--p5-muted); margin-top: 2px; }

/* GC DAG progress in wizard */
.dt-gc-dag-pct { font-size: 11px; color: var(--p5-muted); text-align: right; margin-top: 4px; }

/* ================================================================
   WORKSHOP VIEW
   ================================================================ */
.dt-ws-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 36px 32px 16px;
}

.dt-ws-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dt-ws-hero-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 32px;
  font-weight: 800;
  color: var(--p5-text);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.dt-ws-hero-spark {
  color: var(--p5-yellow);
  fill: var(--p5-yellow);
  flex-shrink: 0;
}

.dt-ws-hero-subtitle {
  font-size: var(--text-md, 14px);
  color: var(--p5-muted);
  margin: 0;
  line-height: 1.6;
}

.dt-ws-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--p5-text);
}

/* Workshop head adopts Quick Generate visual — title + stats + red accent line
   Override jml's flex-column hero layout: restore flex row + space-between for our V4 head */
.dt-ws-header {
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0;
  padding: 24px 32px 16px;
}
.dt-ws-header .dt-ws-gen-head { margin-bottom: 0; padding-bottom: 10px; min-width: 180px; }

.dt-ws-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dt-ws-filter {
  display: flex;
  gap: 4px;
}

.dt-ws-filter .wf-btn, .dt-pet-filter .wf-btn {
  padding: 5px 14px;
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.dt-ws-filter .wf-btn:hover, .dt-pet-filter .wf-btn:hover { border-color: #555; color: var(--p5-text); }
.dt-ws-filter .wf-btn.active, .dt-pet-filter .wf-btn.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08); }

/* Workshop project grid */
.dt-ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}

.dt-ws-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  overflow: hidden;
  position: relative;
}

.dt-ws-card:hover {
  transform: translateY(-3px);
  border-color: var(--p5-red);
  box-shadow: 0 6px 24px rgba(230,57,70,0.12);
}

.dt-ws-card-cover {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  display: block;
}

.dt-ws-card-placeholder {
  width: 100%;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, var(--p5-dark), var(--p5-border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: rgba(255, 255, 255, 0.85);
}
.dt-ws-card-placeholder svg {
  width: 44px;
  height: 44px;
  opacity: 0.7;
  color: #fff;
}
/* Gradient rotation for cover-less cards — mirrors manga-drama poster style */
.dt-ws-card-placeholder.gg-0 { background: linear-gradient(135deg, #3a1420, #7a2030 50%, #c02836); }
.dt-ws-card-placeholder.gg-1 { background: linear-gradient(135deg, #0a0e18, #1a2340 55%, #405578); }
.dt-ws-card-placeholder.gg-2 { background: linear-gradient(135deg, #1a1a24, #3a2d38 55%, #f5b53d); }
.dt-ws-card-placeholder.gg-3 { background: linear-gradient(135deg, #1a0e2e, #4a1a6a 55%, #a560d0); }

.dt-ws-card-info {
  padding: 12px 14px;
}

.dt-ws-card-tags {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.dt-ws-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
}

.dt-ws-tag-single { background: rgba(230,57,70,0.15); color: var(--p5-red); }
.dt-ws-tag-combo { background: rgba(245,197,24,0.15); color: var(--p5-yellow); }
.dt-ws-tag-groupcombo { background: rgba(245,197,24,0.15); color: var(--p5-yellow); }
[data-theme="light"] .dt-ws-tag-single { background: rgba(230,57,70,0.1); }
[data-theme="light"] .dt-ws-tag-combo { background: rgba(245,197,24,0.12); }
[data-theme="light"] .dt-ws-tag-groupcombo { background: rgba(245,197,24,0.12); }

.dt-ws-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--p5-text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dt-ws-card-summary {
  font-size: 12px;
  color: var(--p5-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

/* Card action buttons (top-right overlay) */
.dt-ws-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 4px;
  z-index: 2;
}
.dt-ws-card:hover .dt-ws-card-actions { display: flex; }

.dt-ws-card-act {
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.dt-ws-card-act:hover { background: rgba(0,0,0,0.85); }

/* Publish button (rocket icon) */
.dt-ws-card-pub {
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}
.dt-ws-card-pub:hover { background: rgba(0,0,0,0.85); }
.dt-ws-card-pub.active { background: var(--p5-red); color: #fff; }

/* Delete button red on hover */
.dt-ws-card-del-act:hover { background: var(--p5-red); }

/* ================================================================
   BLOG VIEW
   ================================================================ */
#blog-view { padding: 28px 48px 40px; }

/* Header */
.blog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.blog-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--p5-text);
  margin: 0 0 4px;
}
.blog-subtitle {
  color: var(--p5-muted);
  font-size: var(--text-base);
  margin: 0;
}

/* Featured Banner Carousel */
.blog-featured {
  position: relative;
  margin-bottom: 28px;
}
.blog-featured-slide {
  display: none;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 32px 40px 48px;
  min-height: 240px;
  position: relative;
  overflow: hidden;
}
.blog-featured-slide.active { display: flex; align-items: center; gap: 40px; }
.blog-featured-content { flex: 1; z-index: 2; position: relative; max-width: 560px; }
.blog-featured-slide.has-cover .blog-featured-content { flex: 0 0 48%; max-width: 48%; }
.blog-featured-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 0 0 12px;
  line-height: 1.3;
}
.blog-featured-desc {
  font-size: var(--text-base);
  color: var(--p5-text-secondary);
  margin: 0 0 20px;
  line-height: 1.6;
  max-width: 600px;
}
.blog-featured-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--p5-red);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: background .2s;
}
.blog-featured-btn:hover { background: var(--p5-red-light); }
.blog-featured-visual {
  width: 260px;
  height: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--p5-muted);
  opacity: 0.15;
  z-index: 0;
}
/* When the slide has a cover, the big category label becomes a translucent overlay on the right */
.blog-featured-slide.has-cover .blog-featured-visual {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  height: auto;
  font-size: 88px;
  color: #fff;
  opacity: 0.35;
  text-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 2;
  pointer-events: none;
  letter-spacing: 1px;
}
/* Full-bleed blurred backdrop — gives the whole banner a color palette cohesive with the cover */
.blog-featured-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(40px) saturate(1.3);
  transform: scale(1.15);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
/* Darken left side over the blurred backdrop for text readability (alpha ramp, theme-agnostic) */
.blog-featured-slide.has-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.25) 45%, rgba(0,0,0,0) 70%);
  z-index: 1;
  pointer-events: none;
}
/* Light theme uses a white-tinted scrim instead of black */
[data-theme="light"] .blog-featured-slide.has-cover::after {
  background:
    linear-gradient(to right, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.5) 45%, rgba(255,255,255,0) 70%);
}
/* Right-half sharp cover image; left edge fades via alpha mask so it blends into the backdrop */
.blog-featured-cover {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 55%;
  object-fit: cover;
  display: block;
  z-index: 1;
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 100%);
          mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 100%);
}
.blog-featured-slide { cursor: pointer; }
.blog-featured-dots {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 3;
}
.blog-featured-dot {
  width: 8px;
  height: 8px;
  background: rgba(0,0,0,0.25);
  border: none;
  cursor: pointer;
  transition: background .2s, width .2s;
}
.blog-featured-dot.active {
  width: 24px;
  background: var(--p5-text);
}

/* Toolbar: filters + search */
.blog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.blog-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 1;
}
.blog-filter-bar::-webkit-scrollbar { display: none; }
.blog-search {
  position: relative;
  flex-shrink: 0;
}
.blog-search-input {
  width: 200px;
  padding: 7px 32px 7px 12px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color .2s;
}
.blog-search-input:focus { border-color: var(--p5-red); }
.blog-search-input::placeholder { color: var(--p5-muted); }
.blog-search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--p5-muted);
  pointer-events: none;
}

/* Card Grid */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.blog-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

/* Card thumbnail area */
.blog-card-thumbs {
  display: grid;
  gap: 2px;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--p5-dark);
}
.blog-card-thumbs.cols-1 { grid-template-columns: 1fr; }
.blog-card-thumbs.cols-2 { grid-template-columns: 1fr 1fr; }
.blog-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.blog-card-thumbs .blog-card-tag-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
}

/* Card thumbnail wrapper for tag overlay */
.blog-card-thumb-wrap {
  position: relative;
  overflow: hidden;
}

.blog-card-body { padding: 14px 16px; }

.blog-card-tag {
  display: inline-block;
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  backdrop-filter: blur(4px);
}

.blog-card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.blog-card-summary {
  font-size: var(--text-sm);
  color: var(--p5-text-secondary);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: var(--text-xs);
  color: var(--p5-muted);
}
.blog-card-meta svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }

/* Pagination */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}
.blog-page-btn {
  padding: 6px 14px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.blog-page-btn:hover { border-color: var(--p5-red); }
.blog-page-btn.active {
  background: var(--p5-red);
  border-color: var(--p5-red);
  color: #fff;
}
.blog-load-more {
  padding: 8px 24px;
  background: var(--p5-red);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
}
.blog-load-more:hover { background: var(--p5-red-light); }

/* Blog card enter animation */
.blog-card.card-enter { animation: fadeInUp .5s ease-out both; }

@media (max-width: 1024px) {
  .blog-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .blog-featured-slide.active { padding: 24px; }
  .blog-featured-visual { display: none; }
}
@media (max-width: 768px) {
  #blog-view { padding: 12px 12px 60px; }
  .blog-grid { grid-template-columns: 1fr; gap: 12px; }
  .blog-toolbar { flex-direction: column; align-items: stretch; }
  .blog-search-input { width: 100%; }
  .blog-featured-slide.active { padding: 20px; }
}

/* ---- Blog Detail View ---- */
#blog-detail-view { padding: 20px 48px 40px; }

.blog-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--p5-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-bottom: 20px;
  transition: color .2s;
}
.blog-detail-back:hover { color: var(--p5-text); }

.blog-detail-layout {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

/* Article content */
.blog-detail-content {
  flex: 1;
  min-width: 0;
  max-width: 800px;
}

.blog-detail-hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 0 0 16px;
  line-height: 1.35;
}

.blog-detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  font-size: var(--text-sm);
  color: var(--p5-muted);
  flex-wrap: wrap;
}

.blog-detail-author {
  display: flex;
  align-items: center;
  gap: 8px;
}

.blog-detail-avatar {
  width: 28px;
  height: 28px;
  background: var(--p5-red-gradient);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.blog-detail-tag {
  padding: 3px 12px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
}

.blog-detail-body h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 32px 0 12px;
  padding-top: 8px;
  line-height: 1.4;
}

.blog-detail-body h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--p5-text);
  margin: 24px 0 10px;
  line-height: 1.4;
}

.blog-detail-body p {
  font-size: var(--text-base);
  color: var(--p5-text-secondary);
  line-height: 1.8;
  margin: 0 0 16px;
}

.blog-detail-body img {
  max-width: 100%;
  margin: 16px 0;
  border: 1px solid var(--p5-border);
}

/* Code block */
.blog-code-block {
  position: relative;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  margin: 20px 0;
  overflow: hidden;
}

.blog-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--p5-border);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
}

.blog-code-copy {
  padding: 4px 12px;
  background: var(--p5-red);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s;
}
.blog-code-copy:hover { background: var(--p5-red-light); }

.blog-code-block pre {
  margin: 0;
  padding: 16px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: var(--text-sm);
  color: var(--p5-text);
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Right TOC sidebar */
.blog-detail-toc {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 16px;
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
}
.blog-detail-toc::-webkit-scrollbar { display: none; }

.blog-toc-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-text);
  margin: 0 0 12px;
}

.blog-toc-item {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: var(--text-xs);
  color: var(--p5-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  line-height: 1.5;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.blog-toc-item:hover { color: var(--p5-text); }
.blog-toc-item.active {
  color: #4ecdc4;
  border-left-color: #4ecdc4;
  font-weight: var(--weight-medium);
}

/* Share bar */
.blog-share {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-top: 1px solid var(--p5-border);
  margin-top: 32px;
}
.blog-share-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-muted);
}
.blog-share-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.blog-share-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }

/* Related articles */
.blog-related { margin-top: 24px; }
.blog-related-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 0 0 16px;
}
.blog-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.blog-related-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: border-color .2s;
}
.blog-related-card:hover { border-color: var(--p5-red); }
.blog-related-thumb {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  background: var(--p5-dark);
  object-fit: cover;
}
.blog-related-info { min-width: 0; }
.blog-related-info h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--p5-text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.blog-related-info span {
  font-size: var(--text-xs);
  color: var(--p5-muted);
}

@media (max-width: 1024px) {
  .blog-detail-toc { display: none; }
  .blog-related-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  #blog-detail-view { padding: 12px 12px 60px; }
  .blog-detail-hero-title { font-size: 20px; }
  .blog-related-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   GENERATE VIEW — Two Column Layout
   ================================================================ */
.dt-gen-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: 100%;
}

.dt-gen-input-panel {
  padding: 24px;
  border-right: 1px solid var(--p5-border);
  overflow-y: auto;
  background: var(--p5-surface);
}

/* Head — 仅主标题，下间距 20px + 红色过渡线（双层：currentColor 淡底 + 160px 红段） */
.dt-gen-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  position: relative;
}
.dt-gen-head::after {
  /* 全宽淡底线 — currentColor + opacity 自动适配双主题（dark 变浅灰，light 变深灰）*/
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  opacity: 0.15;
}
.dt-gen-head::before {
  /* 局部红色突出段 — 叠在淡底线上方 */
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 160px;
  height: 2px;
  background: var(--p5-red);
  z-index: 1;
}
.dt-gen-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--p5-text);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.dt-gen-title-ji {
  font-size: 13px;
  color: var(--p5-red);
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.08em;
}
.dt-gen-sub {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--p5-muted);
  text-transform: uppercase;
  margin-top: 6px;
  font-weight: 500;
}
.dt-gen-sub b { color: var(--p5-red); font-weight: 700; }

.dt-gen-section {
  margin-bottom: 16px;
}

.dt-gen-section label {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--p5-muted);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dt-gen-input-panel select {
  width: 100%;
  padding: 10px 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e63946' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.dt-gen-input-panel select:focus { border-color: var(--p5-red); }

.dt-gen-params {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.dt-gen-params .param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dt-gen-params .param-group label {
  font-size: 11px;
  color: var(--p5-muted);
  text-transform: none;
  letter-spacing: 0;
}

.dt-gen-params .param-group select,
.dt-gen-params .param-group input {
  width: 100%;
  padding: 8px 10px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 12px;
  outline: none;
}

.dt-gen-params .param-group select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e63946' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.dt-gen-params .param-group select:focus,
.dt-gen-params .param-group input:focus { border-color: var(--p5-red); }

/* Custom stepper for number params */
.dt-stepper {
  display: flex; align-items: stretch;
}
.dt-stepper input {
  flex: 1; text-align: center; border-left: none; border-right: none;
  min-width: 0;
}
.dt-step-btn {
  width: 36px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-text); font-size: 16px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, color .2s; user-select: none;
}
.dt-step-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.dt-step-btn:active { background: rgba(230,57,70,0.1); }

/* Ref images */
.dt-ref-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.dt-ref-thumb {
  position: relative;
  width: 56px;
  height: 56px;
}

.dt-ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dt-ref-thumb .ref-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--p5-red);
  border: none;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dt-upload-btn {
  display: inline-block;
  padding: 6px 14px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s;
}

.dt-upload-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }

/* Veo 3.1 Fast: refs only allowed at duration=8s — lock upload button with visual hint */
.dt-ref-locked .dt-upload-btn {
  opacity: 0.45;
  border-color: var(--p5-border);
  cursor: not-allowed;
}
.dt-ref-locked .dt-upload-btn:hover { border-color: var(--p5-border); color: var(--p5-muted); }
.dt-ref-locked .dt-ref-upload::after {
  content: attr(data-lock-hint);
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--p5-red);
  letter-spacing: 0.04em;
}

/* MJ Style picker button */
.dt-style-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px;
  background: var(--p5-dark); border: 1px dashed var(--p5-border);
  color: var(--p5-muted); font-size: 13px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.dt-style-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-style-btn.has-style { border-style: solid; border-color: var(--p5-red); color: var(--p5-red-light); }

/* Style Picker Modal */
.dt-style-modal {
  background: var(--p5-card); width: 1280px; max-width: 92vw; max-height: 85vh;
  display: flex; flex-direction: column; border: 1px solid var(--p5-border);
}
.dt-style-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--p5-border);
}
.dt-style-header h3 { font-size: 16px; color: var(--p5-text); }
.dt-style-header-btn {
  padding: 6px 14px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 12px; cursor: pointer;
}
.dt-style-header-btn:hover { color: var(--p5-text); border-color: var(--p5-red); }
.dt-style-close { font-size: 20px; line-height: 1; padding: 4px 10px; }
.dt-style-grid {
  display: grid; grid-template-columns: repeat(4, minmax(200px, 280px));
  gap: 30px; padding: 24px 32px; overflow-y: auto; justify-content: center; align-content: start;
}
@media (max-width: 1400px) { .dt-style-grid { grid-template-columns: repeat(3, minmax(200px, 280px)); } }
@media (max-width: 1000px) { .dt-style-grid { grid-template-columns: repeat(2, 1fr); } }

/* Style lightbox */
.dt-style-lightbox {
  position: fixed; inset: 0; z-index: 10002; background: rgba(0,0,0,0.92);
  display: none; align-items: center; justify-content: center;
}
.dt-style-lightbox.active { display: flex; }
.dt-style-lightbox img { max-width: 90vw; max-height: 85vh; object-fit: contain; }
.dt-slb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  font-size: 36px; width: 48px; height: 48px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.dt-slb-arrow:hover { background: rgba(255,255,255,0.2); }
.dt-slb-prev { left: 16px; }
.dt-slb-next { right: 16px; }
.dt-slb-counter {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: #999; font-size: 13px;
}

/* Prompt textarea */
.dt-gen-input-panel textarea {
  width: 100%;
  padding: 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 14px;
  outline: none;
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.dt-gen-input-panel textarea:focus { border-color: var(--p5-red); }

/* Submit button */
.dt-gen-submit {
  width: 100%;
  padding: 12px;
  background: var(--p5-red-gradient);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .2s;
  margin-bottom: 12px;
}

.dt-gen-submit:hover { opacity: 0.88; }
.dt-gen-submit:disabled { opacity: 0.5; cursor: default; }
.dt-gen-price { font-size: 12px; opacity: 0.8; }

/* Progress */
.dt-gen-progress {
  margin-top: 8px;
}

.dt-gen-progress-bar {
  height: 4px;
  background: var(--p5-border);
  margin-bottom: 6px;
}

.dt-gen-progress-fill {
  height: 100%;
  background: var(--p5-red-gradient);
  width: 0%;
  transition: width .3s;
}

.dt-gen-progress-label {
  font-size: 11px;
  color: var(--p5-muted);
}

/* Image selection overlay */
.dt-media-wrap { position: relative; }
.dt-sel-check {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  border: 2px solid rgba(255,255,255,0.6); background: rgba(0,0,0,0.3);
  color: #fff; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; z-index: 2;
}
.dt-sel-check:hover { border-color: var(--p5-red); background: rgba(230,57,70,0.4); }
.dt-sel-check.selected {
  border-color: var(--p5-red); background: var(--p5-red); color: #fff;
}
/* Hide 'add as reference' overlay for models that don't accept refImages
   (Midjourney / Music / etc). Toggled in JS via dtApplyGridRefselClass. */
#dt-gen-grid.no-refsel .dt-sel-check { display: none; }

/* Card action buttons */
.prompt-row { display: flex; align-items: start; gap: 6px; }
.prompt-row .prompt-text { flex: 1; min-width: 0; }
.dt-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dt-card-btn {
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  background: transparent; border: 1px solid rgba(230,57,70,0.3);
  color: var(--p5-red-light); cursor: pointer; white-space: nowrap;
}
.dt-card-btn:hover { border-color: var(--p5-red); color: #fff; }
.dt-btn-pub { color: #22c55e; border-color: rgba(34,197,94,0.3); }
.dt-btn-pub:hover { border-color: #22c55e; color: #fff; }
.dt-btn-published { color: var(--p5-muted); border-color: rgba(106,106,138,0.3); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dt-btn-published:hover { color: #ef4444; border-color: #ef4444; }
/* Heart pill inside the "Live" button showing current like count — subtle grace note */
.dt-btn-like-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px 1px 4px;
  background: rgba(230,57,70,0.1);
  color: var(--p5-red);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}
.dt-btn-like-pill svg { flex-shrink: 0; }
.dt-btn-del { color: #888; border-color: rgba(136,136,136,0.2); }
.dt-btn-del:hover { color: #ef4444; border-color: #ef4444; }

/* Confirm Dialog */
.dt-confirm-box {
  background: var(--p5-card); border: 1px solid var(--p5-red);
  padding: 28px 24px; width: 380px; max-width: 90vw;
  animation: modalIn .25s ease-out;
}
.dt-confirm-box p {
  font-size: 15px; color: var(--p5-text); margin-bottom: 20px; line-height: 1.5;
}
.dt-confirm-actions { display: flex; gap: 10px; }
.dt-confirm-ok {
  flex: 1; padding: 10px; background: var(--p5-red-gradient);
  border: none; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.dt-confirm-ok:hover { filter: brightness(1.1); }
.dt-confirm-cancel {
  flex: 1; padding: 10px; background: var(--p5-dark);
  border: 1px solid var(--p5-border); color: var(--p5-muted);
  font-size: 13px; cursor: pointer;
}
.dt-confirm-cancel:hover { border-color: var(--p5-text); color: var(--p5-text); }

/* Task Float Panel */
.dt-task-float {
  display: none; position: fixed; top: 72px; right: 24px; width: 360px;
  background: var(--p5-card); border: 1px solid var(--p5-red);
  z-index: 500; box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.dt-task-float.active { display: block; animation: modalIn .25s ease-out; }
.dt-tf-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--p5-border);
  font-size: 14px; font-weight: 600; color: var(--p5-text);
  cursor: grab; user-select: none;
}
.dt-tf-title-text { color: var(--p5-red); font-weight: 700; }
.dt-tf-count { color: var(--p5-muted); margin-left: 4px; }
.dt-tf-close {
  background: none; border: none; color: var(--p5-muted);
  font-size: 18px; cursor: pointer; line-height: 1; padding: 0;
}
.dt-tf-close:hover { color: var(--p5-red); }
.dt-tf-body { max-height: 400px; overflow-y: auto; overscroll-behavior: contain; }
.dt-tf-body:empty { display: none; }
.dt-task-float.no-tasks:not(.has-exec-title) .dt-tf-header span:first-child { visibility: hidden; }
.dt-tf-body:empty + .dt-ef-section { border-top: none; }
.dt-tf-item { padding: 12px 16px; border-bottom: 1px solid var(--p5-border); }
.dt-tf-item-top { display: flex; justify-content: space-between; align-items: start; margin-bottom: 4px; }
.dt-tf-prompt {
  font-size: 12px; color: #a0a0b0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}
.dt-tf-del {
  background: none; border: none; color: #555; font-size: 12px;
  cursor: pointer; padding: 0 0 0 8px; flex-shrink: 0; line-height: 1;
}
.dt-tf-del:hover { color: var(--p5-red); }
.dt-tf-meta { font-size: 11px; color: var(--p5-muted); margin-bottom: 6px; }
.dt-tf-bar { height: 3px; background: var(--p5-dark); overflow: hidden; margin-bottom: 4px; }
.dt-tf-bar-fill {
  height: 100%; background: var(--p5-red-gradient);
  transition: width .4s; width: 0%;
}
.dt-tf-bar-fill.indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg, transparent 0%, var(--p5-red) 40%, var(--p5-red-light) 60%, transparent 100%);
  background-size: 200% 100%;
  animation: tf-indeterminate 1.8s linear infinite;
}
@keyframes tf-indeterminate { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.dt-tf-bottom { display: flex; justify-content: space-between; align-items: center; }
.dt-tf-status { font-size: 12px; color: var(--p5-red); font-weight: 600; }
.dt-tf-timer { font-size: 11px; color: var(--p5-muted); font-variant-numeric: tabular-nums; }
.dt-tf-item.done .dt-tf-status { color: #22c55e; }
.dt-tf-item.done .dt-tf-bar-fill { background: #22c55e; }
.dt-tf-item.failed .dt-tf-status { color: #ef4444; }
.dt-tf-item.failed .dt-tf-bar-fill { background: #ef4444; }

/* Execution Section (inside unified task-float) */
.dt-ef-section { border-top: 1px solid var(--p5-border); }
.dt-ef-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--p5-border);
  font-size: 13px; font-weight: 600; color: var(--p5-text);
}
.dt-ef-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-ef-body { max-height: 240px; overflow-y: auto; padding: 8px 0; }
.dt-ef-footer { padding: 8px 16px 10px; }
.dt-ef-bar { height: 3px; background: var(--p5-dark); margin-bottom: 6px; }
.dt-ef-bar-fill { height: 100%; background: var(--p5-red-gradient); transition: width .4s; width: 0%; }
.dt-ef-footer-meta { display: flex; justify-content: space-between; align-items: center; }
.dt-ef-pct { color: var(--p5-red); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; }
.dt-ef-total { color: var(--p5-muted); font-variant-numeric: tabular-nums; font-size: 11px; }

/* Timeline steps */
.dt-ef-step { display: flex; align-items: flex-start; gap: 10px; padding: 6px 16px; font-size: 12px; }
.dt-ef-step-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--p5-muted); }
.dt-ef-step-label { flex: 1; color: var(--p5-muted); line-height: 20px; }
.dt-ef-step-timer { font-size: 11px; color: var(--p5-muted); font-variant-numeric: tabular-nums; margin-left: 6px; }
.dt-ef-step.s-running .dt-ef-step-icon { color: var(--p5-red); }
.dt-ef-step.s-running .dt-ef-step-label { color: var(--p5-text); }
.dt-ef-step.s-success .dt-ef-step-icon { color: #22c55e; }
.dt-ef-step.s-success .dt-ef-step-label { color: var(--p5-text); }
.dt-ef-step.s-failure .dt-ef-step-icon { color: #ef4444; }
.dt-ef-step.s-failure .dt-ef-step-label { color: #ef4444; }
/* Step sub-progress bar */
.dt-ef-step-progress { height: 2px; background: var(--p5-dark); margin-top: 4px; }
.dt-ef-step-progress-fill { height: 100%; background: var(--p5-red); transition: width .3s; }

/* Run actions area (vision checkbox + run button, stacked) */
.dt-exec-actions-row {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
}
.dt-exec-vision-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--p5-muted); cursor: pointer; user-select: none;
}
.dt-exec-actions-row .dt-gen-submit { width: 100%; }
.btn-price { font-size: 11px; opacity: 0.8; margin-left: 6px; }

/* History panel (right) */
.dt-gen-history-panel {
  padding: 24px;
  overflow-y: auto;
}

.dt-gen-history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.dt-gen-history-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--p5-text);
  flex-shrink: 0;
}

.dt-gen-filter {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.dt-gen-filter .wf-btn {
  padding: 4px 12px;
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.dt-gen-filter .wf-btn:hover { border-color: #555; color: var(--p5-text); }
.dt-gen-filter .wf-btn.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08); }

/* Fuzzy prompt search (right-aligned in history header) */
.dt-gen-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.dt-gen-search-icon {
  position: absolute;
  left: 10px;
  color: var(--p5-muted);
  pointer-events: none;
}
.dt-gen-search-input {
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 12px;
  padding: 6px 10px 6px 30px;
  width: 220px;
  outline: none;
  transition: border-color .15s, width .15s;
}
.dt-gen-search-input::placeholder { color: var(--p5-muted); }
.dt-gen-search-input:focus { border-color: var(--p5-red); width: 280px; }
/* Strip webkit native "search" cancel X so we match theme */
.dt-gen-search-input::-webkit-search-cancel-button { appearance: none; }

#dt-gen-grid {
  columns: 2;
  column-gap: 12px;
}

@media (min-width: 1400px) { #dt-gen-grid { columns: 3; } }
@media (min-width: 1800px) { #dt-gen-grid { columns: 4; } }

.dt-gen-loader {
  text-align: center; padding: 24px; column-span: all;
}
.dt-spinner {
  animation: dtSpin 0.8s linear infinite;
}
@keyframes dtSpin { to { transform: rotate(360deg); } }

.dt-load-more-btn {
  padding: 8px 24px;
  background: var(--p5-border);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  cursor: pointer;
  font-size: 12px;
  transition: border-color .2s;
}

.dt-load-more-btn:hover { border-color: var(--p5-red); }

/* Task card in generate history */
#dt-gen-grid .discover-card .placeholder {
  padding: 40px 16px;
  text-align: center;
  color: var(--p5-muted);
  font-size: 13px;
  background: var(--p5-dark);
}

#dt-gen-grid .discover-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--p5-muted);
  margin-top: 6px;
}

#dt-gen-grid .discover-card .status-success { color: #22c55e; }
#dt-gen-grid .discover-card .status-failure { color: #ef4444; }
#dt-gen-grid .discover-card .status-processing { color: var(--p5-yellow); }

/* ================================================================
   LOADING & EMPTY
   ================================================================ */
.load-more { text-align: center; padding: 30px; color: var(--p5-muted); font-size: 13px; column-span: all; }
.discover-grid:empty + .load-more { min-height: 40vh; display: flex; align-items: center; justify-content: center; }

.loader {
  display: inline-block; width: 24px; height: 24px;
  border: 2px solid #333; border-top-color: var(--p5-red);
  border-radius: 50%; animation: spin .8s linear infinite;
}

.empty-state { text-align: center; padding: 80px 20px; color: #555; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--p5-muted); }

/* ================================================================
   AUTH UI (header buttons)
   ================================================================ */
#auth-area {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  white-space: nowrap;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--p5-text-secondary);
}
#auth-area > * {
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-right: 1px solid var(--p5-border);
  background: transparent;
}
#auth-area > *:last-child { border-right: none; }

.header-ref-gift {
  background: none; border: none; cursor: pointer; line-height: 1;
  color: var(--p5-text-secondary);
  animation: giftBounce 2s ease-in-out infinite;
  font-size: 0; /* hide emoji */
}
.header-ref-gift::before {
  content: '';
  width: 16px; height: 16px; display: block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='8' width='18' height='13' rx='1'/><path d='M12 8v13M2 12h20M7 8a2.5 2.5 0 0 1 0-5c2.5 0 5 5 5 5s2.5-5 5-5a2.5 2.5 0 0 1 0 5'/></svg>") center/contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='8' width='18' height='13' rx='1'/><path d='M12 8v13M2 12h20M7 8a2.5 2.5 0 0 1 0-5c2.5 0 5 5 5 5s2.5-5 5-5a2.5 2.5 0 0 1 0 5'/></svg>") center/contain no-repeat;
}
.header-ref-gift:hover { color: var(--p5-red); transform: none; }
.user-badge { display: flex; align-items: center; gap: 8px; color: var(--p5-text); font-size: 13px; cursor: pointer; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--p5-red-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.header-avatar-img { width: 32px; height: 32px; object-fit: cover; display: block; }

.btn-header-login,
#auth-area > .btn-header-login {
  padding: 0 22px;
  background: var(--p5-red-gradient);
  border: none; color: #fff;
  font-family: var(--font-family);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0; text-transform: none;
  cursor: pointer; transition: opacity .2s;
  align-self: stretch;
  display: flex; align-items: center;
}
.btn-header-login:hover { opacity: 0.85; }

.btn-header-studio {
  padding: 8px 18px;
  background: var(--p5-gold-gradient);
  border: none; color: #000; font-size: 12px; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: opacity .2s;
  letter-spacing: 0.5px;
}
.btn-header-studio:hover { opacity: 0.88; }

/* Header user bar — seamless transparent control panel */
.header-user-bar,
#auth-area .header-user-bar {
  display: flex; align-items: stretch; gap: 0;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}
.header-user-bar > * {
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-right: 1px solid var(--p5-border);
}
.header-user-bar > *:last-child { border-right: none; }
.header-user-bar:hover { background: transparent; }

/* Notification bell */
.hub-notify {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--p5-text-secondary);
  cursor: pointer;
  transition: color .2s;
}
.hub-notify:hover { color: var(--p5-red); }
.hub-notify svg { width: 16px; height: 16px; }
.hub-notify-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--p5-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* Notification panel */
.hub-notify-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 480px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(20px);
  z-index: 10003;
  display: flex;
  flex-direction: column;
  animation: notifySlideIn .2s ease-out;
}
@keyframes notifySlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-notify-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--p5-border);
}
.hub-notify-title {
  font-size: 16px;
  font-weight: var(--weight-bold);
  color: var(--p5-text);
}
.hub-notify-read-all {
  background: none;
  border: none;
  color: var(--p5-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: color .2s;
}
.hub-notify-read-all:hover { color: var(--p5-text); }

.hub-notify-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.hub-notify-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--p5-border);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.hub-notify-item:hover { background: rgba(255,255,255,0.03); }
.hub-notify-item.unread { border-left: 3px solid #4ecdc4; padding-left: 17px; }

.hub-notify-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.hub-notify-body { flex: 1; min-width: 0; }
.hub-notify-body-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.hub-notify-body-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--p5-text);
  line-height: 1.3;
}
.hub-notify-body-time {
  font-size: var(--text-xs);
  color: var(--p5-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.hub-notify-body-desc {
  font-size: var(--text-xs);
  color: var(--p5-text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hub-notify-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--p5-border);
  text-align: center;
}
.hub-notify-view-all {
  background: none;
  border: none;
  color: var(--p5-text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: color .2s;
  width: 100%;
  padding: 6px;
}
.hub-notify-view-all:hover { color: var(--p5-text); }

@media (max-width: 768px) {
  .hub-notify-panel { width: 320px; right: -60px; }
}

/* Notification detail modal */
.notify-detail-modal {
  width: 560px;
  max-width: 92vw;
  max-height: 85vh;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notify-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--p5-border);
}
.notify-detail-label {
  font-size: 16px;
  font-weight: var(--weight-bold);
  color: var(--p5-text);
}

.notify-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
}

.notify-detail-body h3 {
  font-size: 18px;
  font-weight: var(--weight-bold);
  color: var(--p5-text);
  margin: 0 0 16px;
  line-height: 1.4;
}

.notify-detail-body p {
  font-size: var(--text-base);
  color: var(--p5-text-secondary);
  line-height: 1.8;
  margin: 0 0 12px;
}

.notify-detail-body a {
  color: #4ecdc4;
  text-decoration: none;
  font-weight: var(--weight-semibold);
}
.notify-detail-body a:hover { text-decoration: underline; }

.notify-detail-body img {
  max-width: 100%;
  margin: 16px 0;
  border: 1px solid var(--p5-border);
}

.notify-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--p5-border);
}
.notify-detail-time {
  font-size: var(--text-xs);
  color: var(--p5-muted);
}
.notify-detail-dismiss {
  padding: 8px 24px;
  background: var(--p5-red);
  border: none;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background .2s;
}
.notify-detail-dismiss:hover { background: var(--p5-red-light); }

/* Credits — metallic emboss + gold coin shimmer */
.hub-credits {
  gap: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--p5-text-secondary);
  cursor: pointer;
}
.hub-credits:hover { color: var(--p5-text); }
.hub-credits:hover::before { color: var(--p5-red); }
.hub-avatar-wrap { cursor: pointer; }
.hub-credits svg { display: none; }
.hub-credits::before {
  content: '¢';
  color: var(--p5-text-secondary);
  font-size: 13px; font-weight: 700;
  margin-right: 2px;
}
.hub-credits-num {
  background: none;
  -webkit-text-fill-color: initial;
  filter: none;
  color: var(--p5-red);
  font-family: inherit;
  font-size: 12px;
}
@keyframes coinShimmer {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(201,169,78,0.3)); opacity: 0.85; }
  50% { filter: drop-shadow(0 0 6px rgba(245,230,163,0.7)); opacity: 1; }
}

.hub-sep { display: none; }

.hub-plan {
  align-self: center;                /* don't stretch to header height */
  height: 24px;
  padding: 0 22px;                   /* +20px total width vs old 10px each side */
  display: inline-flex;
  align-items: center;
  justify-content: center;           /* text centered horizontally */
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  border: 1px solid;
  background: transparent;
  line-height: 1;
  cursor: pointer;
}
.hub-plan.plan-free { color: var(--p5-muted); border-color: var(--p5-border); }
.hub-plan.plan-standard { color: var(--p5-red); border-color: var(--p5-red); }
.hub-plan.plan-pro { color: var(--p5-red-light); border-color: var(--p5-red-light); }
.hub-plan.plan-max { color: var(--p5-yellow); border-color: var(--p5-yellow); }

/* Profile dropdown panel */
/* Profile hover mini-menu */
.profile-hover-menu {
  position: fixed; top: calc(var(--header-height) + 4px); right: 16px;
  z-index: 10003; opacity: 0; transform: translateY(-6px);
  transition: opacity .2s, transform .2s;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  padding: 6px;
  min-width: 160px;
}
.profile-hover-menu.active { opacity: 1; transform: translateY(0); }
.profile-hover-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: none; border: none; color: var(--p5-text);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.profile-hover-menu button:hover { background: rgba(255,255,255,0.06); }
.profile-hover-menu button svg { flex-shrink: 0; opacity: 0.5; }
.profile-hover-menu button:hover svg { opacity: 1; }
.profile-hover-menu .phm-divider { height: 1px; background: var(--p5-border); margin: 4px 0; }
.profile-hover-menu button:last-child { color: var(--p5-muted); }
.profile-hover-menu button:last-child:hover { color: var(--p5-red); }
.profile-hover-menu button:last-child:hover svg { stroke: var(--p5-red); }
[data-theme="light"] .profile-hover-menu { box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

.profile-dropdown {
  display: none; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 210; opacity: 0;
  transition: opacity .2s, transform .2s;
}
.profile-dropdown.active {
  display: block; opacity: 1; transform: translate(-50%, -50%) scale(1);
}
.profile-dropdown-inner {
  position: relative;
  width: 400px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.profile-dropdown-inner .dt-fixed-modal-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.pf-section { background: var(--p5-dark); border: 1px solid var(--p5-border); padding: 14px; margin-bottom: 18px; }
.pf-label { display: block; font-size: 12px; color: var(--p5-muted); margin-bottom: 4px; }
.pf-muted { color: var(--p5-muted); }
.pf-text { color: var(--p5-text); }
.pf-input { display: block; width: 100%; padding: 10px 12px; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 14px; outline: none; }
.pf-input:focus { border-color: var(--p5-red); }
.pf-readonly { color: var(--p5-muted); }

/* Avatar wrap in header bar — match plan badge height */
.hub-avatar-wrap { flex-shrink: 0; }
.hub-avatar-wrap .user-avatar,
.hub-avatar-wrap .header-avatar-img {
  width: 28px; height: 28px;
}
.hub-avatar-wrap .user-avatar { font-size: 11px; }

.btn-header-logout { display: none; }

/* Logout button inside profile dropdown */
.btn-profile-logout {
  width: 100%; padding: 10px; margin-top: 10px;
  background: none; border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 13px;
  cursor: pointer; transition: border-color .2s, color .2s;
}
.btn-profile-logout:hover { border-color: var(--p5-red); color: var(--p5-red); }

/* H5 header avatar (mobile only) */
.h5-header-avatar { cursor: pointer; }
.h5-header-avatar .user-avatar,
.h5-header-avatar .header-avatar-img { width: 32px; height: 32px; border-radius: 50%; }
.h5-header-avatar .user-avatar {
  background: var(--p5-red-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}

/* ================================================================
   H5 PROFILE PAGE
   ================================================================ */
.h5-profile-page {
  padding: 0 16px 80px;
  max-width: 480px;
  margin: 0 auto;
}
.h5-profile-back {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 0; color: var(--p5-text-secondary);
  font-size: 14px; cursor: pointer;
}
.h5-profile-back:hover { color: var(--p5-text); }
.h5-profile-user-card {
  display: flex; align-items: center; gap: 16px;
  padding: 24px 0 20px;
}
.h5-profile-avatar { flex-shrink: 0; position: relative; cursor: pointer; }
.h5-profile-avatar-img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; display: block;
}
.h5-profile-avatar-letter {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--p5-red-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
}
.h5-profile-avatar-edit-hint {
  position: absolute; bottom: 0; right: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,0.65); border: 2px solid var(--p5-surface);
  display: flex; align-items: center; justify-content: center;
}
.h5-profile-user-info { flex: 1; min-width: 0; }
.h5-profile-nickname-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.h5-profile-edit-btn {
  background: none; border: none; color: var(--p5-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center;
}
.h5-profile-edit-btn:hover { color: var(--p5-text); }
/* Inline nickname edit input */
.h5-profile-nickname-input {
  font-size: var(--text-md); font-weight: var(--weight-semibold);
  color: var(--p5-text); background: var(--p5-card);
  border: 1px solid var(--p5-red); padding: 4px 8px;
  width: 100%; max-width: 200px; outline: none;
}
.h5-profile-save-btn {
  padding: 4px 12px; font-size: 12px;
  background: var(--p5-red); color: #fff; border: none;
  cursor: pointer;
}
.h5-profile-nickname {
  font-size: var(--text-md); font-weight: var(--weight-semibold);
  color: var(--p5-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h5-profile-email {
  font-size: var(--text-sm); color: var(--p5-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Menu groups */
.h5-profile-menu {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  margin-bottom: 12px; overflow: hidden;
}
.h5-profile-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer;
  transition: background .15s;
}
.h5-profile-menu-item:not(:last-child) {
  border-bottom: 1px solid var(--p5-border);
}
.h5-profile-menu-item:active {
  background: rgba(255,255,255,0.03);
}
.h5-profile-menu-left {
  display: flex; align-items: center; gap: 12px;
  color: var(--p5-text); font-size: 14px;
}
.h5-profile-menu-left svg { color: var(--p5-text-secondary); flex-shrink: 0; }
.h5-profile-menu-right {
  display: flex; align-items: center; gap: 8px;
  color: var(--p5-muted); font-size: 12px;
}
.h5-profile-menu-right svg { color: var(--p5-muted); }
.h5-profile-plan-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  text-transform: uppercase;
}
.h5-profile-credits { font-size: 12px; color: var(--p5-text-secondary); }
.h5-profile-ref-progress { font-size: 12px; color: var(--p5-text-secondary); }
/* H5 Language Picker — bottom sheet */
.h5-lang-overlay {
  display: none; position: fixed; inset: 0; z-index: 10010;
  background: rgba(0,0,0,0.5);
}
.h5-lang-overlay.active { display: block; }
.h5-lang-sheet {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10011;
  background: var(--p5-card); max-height: 60vh; overflow-y: auto;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
}
.h5-lang-sheet.active { display: block; transform: translateY(0); }
.h5-lang-header {
  padding: 14px 16px; font-size: 15px; font-weight: 600; color: var(--p5-text);
  border-bottom: 1px solid var(--p5-border); text-align: center;
}
.h5-lang-item {
  padding: 14px 16px; font-size: 14px; color: var(--p5-text);
  border-bottom: 1px solid var(--p5-border); cursor: pointer;
  transition: background .15s;
}
.h5-lang-item:active { background: rgba(255,255,255,0.03); }
.h5-lang-item.active { color: var(--p5-red); font-weight: 600; }
.h5-profile-theme-label { font-size: 12px; color: var(--p5-text-secondary); }
/* Danger group (logout) */
.h5-profile-menu-danger .h5-profile-menu-left { color: var(--p5-red); }
.h5-profile-menu-danger .h5-profile-menu-left svg { color: var(--p5-red); }
/* Hide profile view on desktop — H5 only */
#profile-view { display: none !important; }
@media (max-width: 768px) {
  #profile-view { display: none; }
  #profile-view.active { display: block !important; }
}

/* ================================================================
   LANG SWITCHER
   ================================================================ */
/* Custom language dropdown (replaces native <select> in desktop header) */
.dt-lang-switcher {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}
.dt-lang-btn {
  background: transparent; border: none; padding: 0;
  color: var(--p5-muted);
  font-family: var(--font-display);  /* Oswald — match sidebar menu */
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  height: 100%;
  transition: color .15s ease;
}
.dt-lang-btn:hover { color: var(--p5-text); }
.dt-lang-btn svg { flex-shrink: 0; }

.dt-lang-menu {
  position: absolute;
  top: 100%; left: 0;
  min-width: 200px;
  background: var(--p5-surface);     /* pure black, match new tokens */
  border: 1px solid var(--p5-border);
  border-top: 2px solid var(--p5-red); /* red accent */
  z-index: 300;
  padding: 4px 0;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.dt-lang-menu[hidden] { display: none; }
.dt-lang-item {
  padding: 10px 12px 10px 5px;       /* text 5px from left as requested */
  background: transparent; border: none;
  color: var(--p5-text);
  font-family: var(--font-family);   /* body font — native names look natural */
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.dt-lang-item:hover { background: rgba(230,57,70,0.15); color: var(--p5-red); }
.dt-lang-item.active { background: var(--p5-red); color: #000; font-weight: 700; }

/* ================================================================
   MODALS (shared)
   ================================================================ */
.modal-overlay {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--p5-overlay);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
/* Style picker must sit above other modal overlays (z-index 200) */
#dt-style-overlay { z-index: 210; }
/* Voice picker sits above style picker */
#vt-overlay { z-index: 211; }
/* Confirm dialog must sit above topology overlay (z-index 9999) and lightbox (10001) */
#dt-confirm-dialog { z-index: 10002; }

/* ═══ Voice Picker — V2 Circle Avatar ═══ */
.vt-modal {
  background: var(--p5-card); width: 880px; max-width: 92vw;
  height: 85vh; max-height: 820px; min-height: 560px;
  display: flex; flex-direction: column; border: 1px solid var(--p5-border);
}
.vt-modal .dt-fixed-modal-header { display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px 16px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.vt-modal .dt-fixed-modal-header h3 { margin: 0; font-size: 18px; color: var(--p5-text); font-weight: 600; }
.vt-modal .dt-fixed-modal-body { flex: 1; overflow-y: auto; padding: 0; min-height: 0; }
.vt-header-actions { display: flex; gap: 8px; align-items: center; }
.vt-header-btn { background: none; border: 1px solid var(--p5-border); color: var(--p5-text-secondary);
  padding: 4px 12px; cursor: pointer; font-size: 13px; transition: all 0.2s; }
.vt-header-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.vt-close-btn { font-size: 20px; line-height: 1; padding: 2px 8px; }

/* Language tabs + gender pills */
.vt-lang-tabs { display: flex; justify-content: space-between; align-items: center;
  padding: 0 28px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; gap: 12px; }
.vt-tabs-left { display: flex; gap: 0; flex: 1; min-width: 0; overflow-x: auto;
  scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.vt-tabs-left::-webkit-scrollbar { height: 4px; }
.vt-tabs-left::-webkit-scrollbar-thumb { background: var(--p5-border); }
.vt-lang-tab { background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--p5-text-secondary); padding: 12px 12px; cursor: pointer; font-size: 13px;
  transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
.vt-lang-tab:hover { color: var(--p5-text); }
.vt-lang-tab.active { color: var(--p5-red); border-bottom-color: var(--p5-red); font-weight: 600; }
/* Gender filter pills */
.vt-gender-pills { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.vt-gender-pill { background: none; border: 1px solid var(--p5-border); color: var(--p5-text-secondary);
  padding: 4px 14px; cursor: pointer; font-size: 12px; transition: all 0.2s; white-space: nowrap; }
.vt-gender-pill:hover { border-color: var(--p5-red-light); color: var(--p5-text); }
.vt-gender-pill.active { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }

/* Voice grid — 4 columns */
.vt-grid { display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 24px; padding: 28px; overflow-y: auto; flex: 1; min-height: 0; align-content: start; }
@media (max-width: 1000px) { .vt-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .vt-grid { grid-template-columns: repeat(2, 1fr); } }
.vt-empty { color: var(--p5-muted); padding: 40px; text-align: center; grid-column: 1 / -1; }

/* Footer with confirm button */
.vt-footer { display: none; justify-content: space-between; align-items: center;
  padding: 14px 28px; border-top: 1px solid var(--p5-border); flex-shrink: 0; }
.vt-footer-info { display: flex; align-items: center; gap: 8px; }
.vt-footer-selected { color: var(--p5-text-secondary); font-size: 13px; }
.vt-confirm-btn { background: var(--p5-red); color: #fff; border: none; padding: 8px 32px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.vt-confirm-btn:hover { background: var(--p5-red-light); }

/* Voice card — circle avatar layout */
.vt-card { cursor: pointer; transition: all 0.25s; position: relative; text-align: center;
  padding: 16px 8px 14px; border: 2px solid transparent; background: var(--p5-surface); }
.vt-card:hover { border-color: var(--p5-red-light); transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.vt-card.selected { border-color: var(--p5-red);
  box-shadow: 0 0 0 3px rgba(230,57,70,0.35); }

/* Round avatar container */
.vt-avatar-wrap { width: 88px; height: 88px; margin: 0 auto 12px; position: relative; }
.vt-avatar-circle { width: 88px; height: 88px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.vt-avatar-circle img { width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.4s; }
.vt-avatar-circle img.loaded { opacity: 1; }
.vt-avatar-initials { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: rgba(255,255,255,0.9); letter-spacing: 1px; border-radius: 50%; }

/* Gender ring on avatar */
.vt-ring-female { box-shadow: 0 0 0 3px var(--p5-red); }
.vt-ring-male { box-shadow: 0 0 0 3px #2563eb; }

/* Play button — overlays the circle */
.vt-play-btn { position: absolute; top: 0; left: 0; width: 88px; height: 88px; border-radius: 50%;
  background: rgba(0,0,0,0.25); border: none;
  display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer;
  opacity: 0; transition: opacity 0.2s; z-index: 3; font-size: 20px; }
.vt-card:hover .vt-play-btn { opacity: 1; }
.vt-play-btn.vt-playing { opacity: 1; background: rgba(0,0,0,0.35); }
.vt-play-btn.vt-generating { opacity: 1; background: rgba(230,57,70,0.6); cursor: wait;
  animation: vtSpin 1.2s linear infinite; }
@keyframes vtSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Name & tag below avatar */
.vt-name { color: var(--p5-text); font-size: 14px; font-weight: 600; display: block; margin-bottom: 3px; }
.vt-tag { color: var(--p5-muted); font-size: 11px; display: block; }

/* Selection check — top right circle badge */
.vt-card .vt-check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  background: var(--p5-red); border-radius: 50%; display: none; align-items: center; justify-content: center; z-index: 4; }
.vt-card .vt-check svg { width: 12px; height: 12px; }
.vt-card.selected .vt-check { display: flex; }

/* Params panel */
.vt-params { border-top: 1px solid var(--p5-border); flex-shrink: 0; }
.vt-params-toggle { display: flex; align-items: center; gap: 8px; padding: 12px 28px;
  cursor: pointer; color: var(--p5-text-secondary); font-size: 13px; transition: color 0.2s; }
.vt-params-toggle:hover { color: var(--p5-text); }
.vt-params-toggle .vt-chevron { transition: transform 0.2s; }
.vt-params.expanded .vt-params-toggle .vt-chevron { transform: rotate(180deg); }
.vt-params-body { display: none; padding: 0 28px 16px; }
.vt-params.expanded .vt-params-body { display: flex; gap: 32px; }
.vt-param-row { display: flex; align-items: center; gap: 10px; }
.vt-param-row label { color: var(--p5-text-secondary); font-size: 13px; min-width: 50px; }
.vt-speed-slider { width: 160px; accent-color: var(--p5-red); }
.vt-speed-val { color: var(--p5-text); font-size: 13px; font-weight: 600; }
.vt-model-select { background: var(--p5-dark); color: var(--p5-text); border: 1px solid var(--p5-border);
  padding: 6px 10px; font-size: 13px; cursor: pointer; }

.login-modal {
  width: 400px; max-width: 90vw;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  padding: 36px 32px;
}

.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--p5-border); }
.auth-tab {
  flex: 1; padding: 10px 0; background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--p5-muted);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: color .2s, border-color .2s;
}
.auth-tab.active { color: var(--p5-red); border-bottom-color: var(--p5-red); }
.auth-tab:hover { color: var(--p5-text); }

.login-modal .auth-heading { font-size: 22px; font-weight: 700; color: var(--p5-text); margin: 0 0 24px; line-height: 1.3; }
.login-modal .form-group { margin-bottom: 14px; }
.login-modal label { display: block; font-size: 12px; color: var(--p5-muted); margin-bottom: 4px; }
.login-modal input:not([type="checkbox"]) {
  width: 100%; padding: 11px 14px; background: var(--p5-dark);
  border: 1px solid var(--p5-border); color: var(--p5-text);
  font-size: 14px; outline: none; transition: border-color .2s;
}
.login-modal input:not([type="checkbox"]):focus { border-color: var(--p5-red); }
.login-error { display: none; color: #ef4444; font-size: 12px; margin-bottom: 10px; }
.field-error { display: none; color: #ef4444; font-size: 11px; margin-top: 4px; }
.field-error.active { display: block; }
.form-group input.field-invalid { border-color: #ef4444 !important; }

.verify-code-row { display: flex; gap: 8px; }
.verify-code-row input { flex: 1; }
.btn-send-code {
  flex-shrink: 0; padding: 10px 14px; background: transparent;
  border: 1px solid var(--p5-red); color: var(--p5-red); font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: opacity .2s;
}
.btn-send-code:hover { opacity: 0.8; }
.btn-send-code:disabled { opacity: 0.5; cursor: not-allowed; border-color: #555; color: #888; }

.agree-terms {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; font-size: 13px; color: var(--p5-muted); line-height: 1;
}
.agree-terms input[type="checkbox"] { margin: 0; border-color: var(--p5-red); }
.agree-terms label { display: inline; font-size: 13px; color: var(--p5-muted); margin-bottom: 0; cursor: pointer; }
.agree-terms a { color: var(--p5-red); text-decoration: none; }
.agree-terms a:hover { text-decoration: underline; }

.btn-login {
  width: 100%; padding: 11px; background: var(--p5-red-gradient);
  border: none; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; margin-bottom: 12px; transition: opacity .2s;
}
.btn-login:hover { opacity: 0.85; }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--p5-muted); font-size: 12px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--p5-border); }

.btn-google {
  width: 100%; padding: 10px; background: var(--p5-dark);
  border: 1px solid var(--p5-border); color: var(--p5-text);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color .2s, background .2s;
}
.btn-google:hover { border-color: #4285F4; background: var(--p5-dark); }

.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; color: #666;
  font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--p5-text); }

/* ================================================================
   CREATE WIZARD MODAL
   ================================================================ */
.dt-wizard-modal {
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
}
.dt-wiz-header {
  flex-shrink: 0;
  padding: 32px 32px 0;
  background: var(--p5-card);
}
.dt-wiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 32px 32px;
}

/* Shared fixed-header modal pattern */
.dt-fixed-modal {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #16161d;
  border: 1px solid #24242e;
  position: relative;
}
.dt-fixed-modal-header {
  flex-shrink: 0;
  padding: 28px 28px 16px;
  background: var(--p5-card);
}
.dt-fixed-modal-header h2 { font-size: 20px; color: var(--p5-text); margin-bottom: 4px; }
.dt-fixed-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 28px;
}
.dt-fixed-modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 10;
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.dt-fixed-modal-close:hover { color: #e0e0e0; }

.dt-wiz-close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 10;
  background: none;
  border: none;
  color: var(--p5-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.dt-wiz-close-btn:hover { color: var(--p5-text); }

.dt-wizard-modal h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--p5-text);
  margin-bottom: 16px;
}

.dt-wiz-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--p5-border);
}

.dt-wiz-tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--p5-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  text-align: center;
}

.dt-wiz-tab.active { color: var(--p5-red); border-bottom-color: var(--p5-red); }
.dt-wiz-tab:hover { color: var(--p5-text); }

.dt-wiz-panel { display: none; }
.dt-wiz-panel.active { display: block; }

.dt-wizard-modal .form-group { margin-bottom: 14px; }
.dt-wizard-modal .form-group label { display: block; font-size: 12px; color: var(--p5-muted); margin-bottom: 4px; font-weight: 600; }

.dt-wizard-modal input[type="text"],
.dt-wizard-modal textarea,
.dt-wizard-modal select {
  width: 100%;
  padding: 10px 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.dt-wizard-modal input:focus,
.dt-wizard-modal textarea:focus,
.dt-wizard-modal select:focus { border-color: var(--p5-red); }

.dt-wizard-modal select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e63946' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.dt-wiz-radio-row {
  display: flex;
  gap: 8px;
}

.dt-wiz-radio {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.dt-wiz-radio:has(input:checked) {
  border-color: var(--p5-red);
  color: var(--p5-text);
}

.dt-wiz-radio input { accent-color: var(--p5-red); }

/* DAG Pipeline Visualization */
.dt-wiz-dag { margin: 16px 0; }
.dt-wiz-dag-list { display: flex; flex-direction: column; gap: 2px; }
.dt-wiz-dag-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  font-size: 12px; transition: background .2s;
}
.dt-wiz-dag-row[data-status="running"] { background: rgba(230,57,70,0.08); }
.dt-wiz-dag-row[data-status="done"] { opacity: 0.6; }
.dt-wiz-dag-row[data-status="failed"] { background: rgba(239,68,68,0.08); }
.dt-wiz-dag-row[data-status="skipped"] { opacity: 0.4; }
.dt-wiz-dag-icon { width: 16px; text-align: center; font-size: 11px; }
.dt-wiz-dag-row[data-status="running"] .dt-wiz-dag-icon { color: var(--p5-red); animation: tl-pulse 1.2s infinite; }
.dt-wiz-dag-row[data-status="done"] .dt-wiz-dag-icon { color: #22c55e; }
.dt-wiz-dag-row[data-status="failed"] .dt-wiz-dag-icon { color: #ef4444; }
.dt-wiz-dag-id { color: var(--p5-red); font-weight: 700; min-width: 24px; }
.dt-wiz-dag-label { flex: 1; color: var(--p5-muted); }
.dt-wiz-dag-status { color: var(--p5-muted); font-size: 11px; }
.dt-wiz-dag-progress { margin-top: 8px; }
@keyframes tl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Step 2: Variables list */
.dt-wiz-vars-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-wiz-var-tag {
  padding: 4px 10px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-yellow); font-size: 11px; font-family: monospace;
}

/* Review badge */
.dt-wiz-review { margin: 6px 0; font-size: 11px; padding: 4px 8px; display: inline-block; }
.dt-wiz-review.optimized { background: rgba(245,158,11,0.1); color: #f59e0b; }
.dt-wiz-review.passed { background: rgba(34,197,94,0.1); color: #4ade80; }

.dt-wiz-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Output Type radio cards */
.dt-wiz-otype-cards {
  display: flex; gap: 8px;
}
.dt-wiz-otype-card {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 10px 8px; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 13px; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.dt-wiz-otype-card input { display: none; }
.dt-wiz-otype-card:hover { border-color: #555; color: var(--p5-text); }
.dt-wiz-otype-card.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.10); }

/* Styled checkbox — universal */
.dt-cb { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 13px; color: var(--p5-muted); }
.dt-cb input { display: none; }
.dt-cb-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--p5-border); vertical-align: middle; }
.dt-cb-icon .dt-cb-check { opacity: 0; transition: opacity .15s; }
.dt-cb input:checked ~ .dt-cb-icon { color: var(--p5-red); }
.dt-cb input:checked ~ .dt-cb-icon rect { fill: var(--p5-red); stroke: var(--p5-red); }
.dt-cb input:checked ~ .dt-cb-icon .dt-cb-check { opacity: 1; color: #fff; }
/* Wizard checkbox — with border container */
.dt-wiz-checkbox { padding: 8px 14px; border: 1px solid var(--p5-border); transition: border-color .2s; }
.dt-wiz-checkbox:hover { border-color: #555; }
.dt-wiz-check-row { margin-bottom: 8px; }
/* Styled radio — universal */
.dt-rb { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 13px; color: var(--p5-muted); }
.dt-rb input { display: none; }
.dt-rb-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--p5-border); }
.dt-rb-icon .dt-rb-dot { transition: opacity .15s; }
.dt-rb input:checked ~ .dt-rb-icon { color: var(--p5-red); }
.dt-rb input:checked ~ .dt-rb-icon circle:first-child { stroke: var(--p5-red); }
.dt-rb input:checked ~ .dt-rb-icon .dt-rb-dot { opacity: 1; fill: var(--p5-red); }

/* Global native radio/checkbox override */
input[type="radio"] {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
  border: 1px solid var(--p5-border); border-radius: 50%; background: transparent;
  cursor: pointer; vertical-align: middle; position: relative; flex-shrink: 0; margin: 0 6px 0 0;
}
input[type="radio"]:checked { border-color: var(--p5-red); }
input[type="radio"]:checked::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--p5-red);
}
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
  border: 1px solid var(--p5-border); background: transparent; cursor: pointer;
  vertical-align: middle; position: relative; flex-shrink: 0; margin: 0 6px 0 0;
}
input[type="checkbox"]:checked { background: var(--p5-red); border-color: var(--p5-red); }
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
/* Re-hide inputs inside SVG-based custom labels (must be after global override) */
.dt-cb input, .dt-rb input { display: none !important; }
/* Also hide in card-style selectors */
.dt-wiz-otype-card input, .dt-gc-scale-card input { display: none !important; }

/* Global select option fix — prevent white-bg unreadable text in dark theme */
select option { background: var(--p5-dark); color: var(--p5-text); }

/* Use Template button */
.dt-wiz-use-tpl { background: linear-gradient(135deg, #24242e, #3a3a48) !important; }

/* New project card — single centered "+ icon + label" block (per reference mock 2026-04-20) */
.dt-ws-card-new {
  border-style: dashed;
  border-color: var(--p5-border);
  min-height: 240px;
}
.dt-ws-card-new:hover { border-color: var(--p5-red); border-style: dashed; }
/* .dt-ws-card is already position:relative — inner fills the card then flex-centers */
.dt-ws-new-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.dt-ws-new-iconbox {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: border-color .2s, box-shadow .2s;
}
.dt-ws-new-icon { color: var(--p5-muted); transition: color .2s; display: block; }
.dt-ws-new-label {
  font-size: var(--text-md, 14px);
  font-weight: 600;
  color: var(--p5-text);
  margin: 0;
  transition: color .2s;
}
.dt-ws-new-sub {
  font-size: var(--text-xs, 11px);
  color: var(--p5-muted);
  margin: 0;
  line-height: 1.5;
}
.dt-ws-card-new:hover .dt-ws-new-iconbox { border-color: var(--p5-red); box-shadow: 0 4px 14px rgba(230, 57, 70, 0.15); }
.dt-ws-card-new:hover .dt-ws-new-icon,
.dt-ws-card-new:hover .dt-ws-new-label { color: var(--p5-red); }

.dt-wiz-actions .btn-secondary {
  padding: 10px 20px;
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s;
}

.dt-wiz-actions .btn-secondary:hover { border-color: var(--p5-red); color: var(--p5-text); }

.dt-wiz-actions .btn-primary {
  padding: 10px 24px;
  background: var(--p5-red-gradient);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}

.dt-wiz-actions .btn-primary:hover { opacity: 0.88; }
.dt-wiz-actions .btn-primary:disabled { opacity: 0.5; cursor: default; }

/* ================================================================
   LIGHTBOX
   ================================================================ */
.lightbox {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92); z-index: 10020;
  align-items: center; justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox img, .lightbox video { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.lb-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 32px; cursor: pointer; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(230,57,70,0.3); border: none; color: #fff;
  font-size: 32px; width: 56px; height: 80px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lb-nav:hover { background: rgba(230,57,70,0.5); }
.lb-prev { left: calc(50% - 45vw - 28px); }
.lb-next { right: calc(50% - 45vw - 28px); }
@media (max-width: 768px) { .lb-prev { left: 8px; } .lb-next { right: 8px; } }
.lb-download {
  position: absolute; top: 16px; right: 60px;
  background: rgba(0,0,0,0.5); border: none; color: #fff;
  width: 40px; height: 40px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 301; transition: background .2s;
}
.lb-download:hover { background: rgba(230,57,70,0.5); }
.lb-download svg { width: 20px; height: 20px; }
.lb-counter { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: #aaa; font-size: 13px; }
.comic-lb-select-btn {
  position: absolute; top: 16px; right: 112px;
  min-width: 118px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--p5-red); color: #fff;
  border: 1px solid var(--p5-red);
  padding: 8px 20px; font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em; cursor: pointer;
  z-index: 302; transition: background .2s, color .2s;
  border-radius: 0; pointer-events: auto;
}
.comic-lb-select-btn:hover:not(.is-selected) { background: #ff4555; border-color: #ff4555; }
.comic-lb-select-btn.is-selected {
  background: rgba(0,0,0,0.72);
  color: #fff;
  border-color: var(--p5-red);
  cursor: default;
}
.comic-lb-select-btn.is-selected::before {
  content: '\2713'; font-weight: 700; color: var(--p5-red);
}
/* Kill global button:active scale(.96) inside lightbox — no "jump" on click.
   .lb-nav must preserve its translateY(-50%) centering; others have no base transform. */
.lightbox .lb-nav:active { transform: translateY(-50%) !important; }
.lightbox .lb-close:active,
.lightbox .lb-download:active,
#comic-lb-select-btn:active { transform: none !important; }
/* Buttons using translateY(-50%) for vertical centering must keep it on :active,
   otherwise global button:active { transform: scale(.96) } wipes the translate,
   the button jumps vertically, mouseup lands outside, and onclick never fires. */
.comic-nav-next:active,
.comic-char-info-toggle:active,
.md-char-info-toggle:active,
.md-video-prompt-edit:active,
.comic-pv-book-arrow:active { transform: translateY(-50%) !important; }

/* ================================================================
   REFERRAL FLOAT CARD
   ================================================================ */
.ref-float {
  position: fixed; right: 24px; bottom: 80px; z-index: 150;
  width: 200px; padding: 20px 16px 16px; text-align: center;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  animation: refFloatIn .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes refFloatIn {
  0% { opacity: 0; transform: translateX(100px); }
  100% { opacity: 1; transform: translateX(0); }
}
.ref-float-close {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; color: var(--p5-muted); font-size: 18px;
  cursor: pointer; padding: 2px 6px; line-height: 1;
}
.ref-float-close:hover { color: var(--p5-text); }
.ref-float-icon { font-size: 32px; margin-bottom: 6px; animation: giftBounce 2s ease-in-out infinite; }
.ref-float-title { font-size: 14px; font-weight: 700; color: var(--p5-text); margin-bottom: 6px; }
.ref-float-desc { font-size: 11px; color: var(--p5-muted); margin-bottom: 4px; line-height: 1.4; }
.ref-float-amount { color: var(--p5-red-light); font-weight: 700; font-size: 16px; }
.ref-float-progress { font-size: 10px; color: var(--p5-muted); margin-bottom: 10px; }
.ref-float-btn {
  width: 100%; padding: 8px 0; border: none; cursor: pointer;
  background: var(--p5-red); color: #fff; font-size: 12px; font-weight: 600;
  transition: opacity .2s;
}
.ref-float-btn:hover { opacity: .85; }

/* ================================================================
   TOAST
   ================================================================ */
.toast-container {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 10000;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 28px; background: var(--p5-card);
  border: 1px solid var(--p5-border); color: var(--p5-text);
  font-size: 14px; min-width: 240px; text-align: center;
  box-shadow: 0 4px 16px var(--p5-shadow);
  pointer-events: auto;
}
.toast-error { border-color: var(--p5-red); color: var(--p5-red-light); background: rgba(230,57,70,0.15); }
.toast-success { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.15); }
.toast-warning { border-color: var(--p5-yellow); color: var(--p5-yellow); background: rgba(245,197,24,0.15); }

/* ================================================================
   PROFILE / SUBSCRIPTION / WELCOME (same as discover)
   ================================================================ */
.profile-avatar-row { display: flex; align-items: center; gap: 12px; }
.profile-avatar-img { width: 48px; height: 48px; object-fit: cover; }
.profile-avatar-placeholder {
  width: 48px; height: 48px; background: var(--p5-red-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
}
.btn-upload-avatar {
  padding: 6px 14px; background: var(--p5-dark);
  border: 1px solid var(--p5-border); color: #aaa;
  font-size: 12px; cursor: pointer; transition: border-color .2s;
}
.btn-upload-avatar:hover { border-color: var(--p5-red); color: var(--p5-red); }
.btn-change-pwd {
  display: block; margin-top: 10px;
  padding: 6px 14px; background: transparent;
  border: 1px solid var(--p5-border); color: var(--p5-muted);
  font-size: 12px; cursor: pointer; transition: border-color .2s, color .2s;
}
.btn-change-pwd:hover { border-color: var(--p5-red); color: var(--p5-red); }
.btn-delete-account {
  display: block; width: 100%; margin-top: 10px;
  padding: 6px 0; background: transparent;
  border: none; color: #a85560;
  font-size: 12px; cursor: pointer; text-align: center;
  transition: color .2s;
}
.btn-delete-account:hover { color: var(--p5-red); text-decoration: underline; }

/* Subscription */
.sub-modal {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  padding: 32px; width: 900px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; position: relative;
}
.sub-modal .modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--p5-muted); font-size: 24px; cursor: pointer; z-index: 1; }
.sub-modal h2 { font-size: 22px; color: var(--p5-text); margin-bottom: 4px; text-align: center; }
.sub-subtitle { font-size: 13px; color: var(--p5-muted); margin-bottom: 20px; text-align: center; }
.sub-plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.sub-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 20px; gap: 20px; }
.sub-notice { font-size: 12px; color: var(--p5-muted); flex: 1; margin: 0; line-height: 1.5; }
.sub-specific-link { color: var(--p5-yellow); font-size: 12px; white-space: nowrap; text-decoration: none; font-weight: 600; }
.sub-specific-link:hover { text-decoration: underline; }
.sub-plan-card { background: var(--p5-dark); border: 1px solid var(--p5-border); padding: 20px 16px; display: flex; flex-direction: column; transition: border-color .2s; }
.sub-plan-card:hover { border-color: var(--p5-red); }
.sub-plan-card.current { border-color: var(--p5-yellow); background: rgba(245,197,24,0.04); }
.sub-plan-card h3 { font-size: 18px; margin-bottom: 12px; font-weight: 700; }
.sub-price { margin-bottom: 8px; }
.sub-price-main, .sub-price-discount { font-size: 28px; font-weight: 700; color: var(--p5-text); }
.sub-price-discount { color: var(--p5-red); }
.sub-price-original { font-size: 16px; color: var(--p5-muted); text-decoration: line-through; margin-left: 8px; }
.sub-price-period { font-size: 13px; color: var(--p5-muted); margin-left: 4px; }
.sub-first-month { font-size: 11px; color: var(--p5-red); margin-bottom: 8px; }
.sub-credits { font-size: 13px; color: var(--p5-red-light); font-weight: 600; margin-bottom: 8px; }
.sub-features { font-size: 12px; color: var(--p5-muted); line-height: 1.6; }
.sub-features ul { list-style: none; padding: 0; margin: 4px 0 0; }
.sub-features li { padding: 2px 0; }
.btn-plan-select { width: 100%; padding: 8px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; margin: 12px 0 8px; }
.btn-plan-select:hover { opacity: .85; }
.sub-plan-card.disabled { opacity: .5; pointer-events: none; }
.btn-plan-disabled { width: 100%; padding: 8px; background: #333; border: 1px solid var(--p5-border); color: #666; font-size: 13px; font-weight: 600; cursor: not-allowed; margin: 12px 0 8px; }
.sub-downgrade-hint { font-size: 11px; color: #e63946; text-align: center; margin-top: 4px; }
.btn-plan-current { width: 100%; padding: 8px; background: var(--p5-border); border: none; color: var(--p5-muted); font-size: 13px; cursor: default; margin: 12px 0 8px; }
.plan-badge { display: inline-block; padding: 3px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.plan-free { background: var(--p5-border); color: var(--p5-muted); }
.plan-standard { background: rgba(230,57,70,0.15); color: var(--p5-red); }
.plan-pro { background: rgba(255,107,107,0.15); color: var(--p5-red-light); }
.plan-max { background: rgba(245,197,24,0.15); color: var(--p5-yellow); }
.btn-upgrade { padding: 5px 14px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-upgrade:hover { opacity: .85; }
.btn-cancel-sub { display:block; margin-top:10px; padding:0; background:none; border:none; color:var(--p5-muted); font-size:12px; cursor:pointer; text-decoration:underline; }
.btn-cancel-sub:hover { color: var(--p5-red); }
.cancelled-tag { color: #e63946; font-size: 12px; font-weight: 600; margin-left: 6px; }

/* Confirm Modal */
.confirm-modal-box {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  padding: 32px; width: 400px; max-width: 90vw; text-align: center;
}
.confirm-icon { font-size: 36px; margin-bottom: 12px; }
.confirm-modal-box h3 { font-size: 18px; color: var(--p5-text); margin-bottom: 12px; }
.confirm-modal-box p { font-size: 14px; color: var(--p5-muted); line-height: 1.7; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }
.btn-confirm-cancel {
  padding: 10px 28px; background: transparent; border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 14px; cursor: pointer;
}
.btn-confirm-cancel:hover { border-color: var(--p5-muted); color: var(--p5-text); }
.btn-confirm-ok {
  padding: 10px 28px; background: var(--p5-red); border: none;
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-confirm-ok:hover { opacity: 0.85; }

.btn-ref-copy { padding: 6px 14px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-ref-copy:hover { opacity: .85; }
.btn-ref-copy:disabled { background: var(--p5-border); color: var(--p5-muted); cursor: default; }
.plan-name-free { color: var(--p5-muted); }
.plan-name-standard { color: var(--p5-red); }
.plan-name-pro { color: var(--p5-red-light); }
.plan-name-max { color: var(--p5-yellow); }

/* Welcome */
.welcome-modal { width: 440px; max-width: 92vw; position: relative; overflow: hidden; background: var(--p5-dark); border: 1px solid var(--p5-border); }
.welcome-bg { position: absolute; top: 0; left: 0; right: 0; height: 140px; background: linear-gradient(135deg, var(--p5-red) 0%, var(--p5-red-light) 40%, var(--p5-yellow) 70%, var(--p5-red) 100%); background-size: 200% 200%; animation: welcomeBgFlow 4s ease infinite; }
.welcome-bg::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255,255,255,0.04) 8px, rgba(255,255,255,0.04) 16px); }
.welcome-content { position: relative; padding: 32px 28px 28px; }
.welcome-gift { width: 64px; height: 64px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 36px; background: rgba(0,0,0,0.4); border: 2px solid rgba(255,255,255,0.15); animation: giftBounce 1.5s ease-in-out infinite; }
.welcome-title { text-align: center; font-size: 22px; color: #fff; font-weight: 700; margin-bottom: 4px; }
.welcome-subtitle { text-align: center; font-size: 13px; color: rgba(255,255,255,0.7); margin-bottom: 20px; }
.welcome-credits { display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(230,57,70,0.12); border: 1px solid rgba(230,57,70,0.3); padding: 14px 20px; margin-bottom: 20px; }
.welcome-credits-num { font-size: 36px; font-weight: 800; color: var(--p5-red-light); animation: creditsPulse 2s ease-in-out infinite; }
.welcome-credits-label { font-size: 14px; color: var(--p5-text); font-weight: 600; }
.welcome-features { margin-bottom: 24px; }
.welcome-feat { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 4px; background: rgba(255,255,255,0.03); transition: background .2s; }
.welcome-feat:hover { background: rgba(255,255,255,0.06); }
.welcome-feat-icon { width: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--p5-red); }
.welcome-feat span:last-child { font-size: 13px; color: var(--p5-text); }
.welcome-actions { display: flex; gap: 12px; }
.welcome-btn-upgrade { flex: 1; padding: 12px; border: 1px solid var(--p5-yellow); background: transparent; color: var(--p5-yellow); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s; }
.welcome-btn-upgrade:hover { background: rgba(245,197,24,0.1); }
.welcome-btn-ok { flex: 1; padding: 12px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.welcome-btn-ok:hover { opacity: 0.9; }

/* Paper text display */
.wf-paper { background: #fafaf8; color: #1a1a1a; padding: 40px 48px; max-height: 400px; overflow-y: auto; box-shadow: 0 2px 16px rgba(0,0,0,.3); font-family: 'Georgia', 'Noto Serif SC', serif; font-size: 14px; line-height: 2; position: relative; }
.wf-paper::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--p5-red); }
.wf-paper h1 { font-size: 20px; font-weight: 700; color: #111; text-align: center; margin: 0 0 20px; padding-bottom: 12px; border-bottom: 1px solid #e0ddd8; }
.wf-paper h2 { font-size: 16px; font-weight: 700; color: #222; margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 1px solid #e8e6e2; }
.wf-paper h3 { font-size: 14px; font-weight: 600; color: #333; margin: 14px 0 6px; }
.wf-paper p { margin: 6px 0; text-indent: 2em; }
.wf-paper blockquote { margin: 10px 0; padding: 8px 16px; border-left: 3px solid var(--p5-red); background: #f5f4f0; color: #555; font-style: italic; }

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes welcomeBgFlow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes giftBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes creditsPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Shimmer skeleton for image containers — RENAMED from `shimmer` to
   `skeleton-shimmer` to avoid @keyframes name collision with the highlight
   shimmer at L1759/L12000 (translateX pulse). Same-name @keyframes rules
   cause browsers to apply whichever appears last in doc order to ALL
   elements using that name — which was translating entire grid containers
   ±100% and making result cards drift across the screen. (E9 trap: CSS
   same-name collisions silently override.) */
@keyframes skeleton-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.image-grid, .dt-ws-card-cover-wrap, .dt-exec-result-grid {
  background: linear-gradient(90deg, var(--p5-dark) 25%, var(--p5-border) 37%, var(--p5-dark) 63%);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
/* Stop shimmer once content has loaded — include `video` because <video>
   elements don't carry a `.loaded` class like <img> does, but their mere
   presence means the result has arrived and no skeleton is needed. */
.image-grid:has(img.loaded),
.dt-exec-result-grid:has(img.loaded),
.dt-exec-result-grid:has(video) {
  animation: none; background: var(--p5-dark);
}

/* Universal image fade-in — all lazy images across the app */
.card-enter { animation: fadeInUp .5s ease-out both; }

.discover-card img:not(.tpl-author-avatar), .tpl-card img.tpl-cover,
.dt-ws-card-cover,
.dt-exec-result-grid img, #dt-gen-grid img {
  opacity: 0; transform: scale(1.02);
  transition: opacity .6s ease-out, transform .6s ease-out;
}
.discover-card img.loaded, .tpl-card img.tpl-cover.loaded,
.dt-ws-card-cover.loaded,
.dt-exec-result-grid img.loaded, #dt-gen-grid img.loaded {
  opacity: 1; transform: scale(1);
}

/* Button micro-interactions */
button, .btn-like, .btn-use, .btn-login, .dt-quick-go, .dt-tpl-use-btn {
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
}
button:active, .btn-like:active, .btn-use:active, .btn-login:active,
.dt-quick-go:active, .dt-tpl-use-btn:active { transform: scale(.96); }
.modal-overlay:active, .lightbox:active { transform: none !important; }

/* Card hover lift */
.discover-card, .tpl-card, .dt-ws-card {
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.discover-card:hover, .tpl-card:hover, .dt-ws-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  border-color: rgba(230,57,70,0.3);
}

/* Sidebar nav hover */
.dt-nav-item {
  transition: background .2s ease, color .2s ease, border-left-color .2s ease;
}

/* Feature card hover */
.dt-feature-card {
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.dt-feature-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Source badge entrance */
.source-badge {
  animation: fadeInUp .4s ease-out both;
}

/* Modal & lightbox */
.modal-overlay.active { animation: overlayIn .25s ease-out; }
.modal-overlay.active .login-modal, .modal-overlay.active .sub-modal, .modal-overlay.active > div { animation: modalIn .25s ease-out; }
.lightbox.active { animation: overlayIn .3s ease-out; }
.lightbox.active img, .lightbox.active video { animation: modalIn .3s ease-out; }

/* View switching */
.dt-view.active { animation: fadeInUp .3s ease-out; }

/* Toast entrance */
.toast { animation: fadeInUp .3s ease-out; }

/* Template detail hero info stagger */
/* Template detail info — no stagger animation for instant display */

/* ================================================================
   PE TEMPLATES VIEW
   ================================================================ */
.dt-pet-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 32px 16px; flex-wrap: wrap; gap: 12px; }
.dt-pet-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--p5-text); margin: 0; }
.dt-pet-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dt-pet-filter { display: flex; gap: 6px; }
.dt-pet-new-btn { display: flex; align-items: center; gap: 6px; background: var(--p5-red); color: #fff; border: none; padding: 8px 18px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.dt-pet-new-btn:hover { background: #d32f3f; }

/* PE Template card overlay actions */
.dt-pet-card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.dt-ws-card:hover .dt-pet-card-actions { opacity: 1; }
.dt-pet-act-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7); border: none; color: var(--p5-muted); cursor: pointer; }
.dt-pet-act-btn:hover { color: var(--p5-text); background: rgba(0,0,0,.9); }
.dt-pet-act-del:hover { color: var(--p5-red); }

/* Status badges */
.dt-pet-badge { font-size: .7rem; padding: 1px 6px; font-weight: 600; letter-spacing: .3px; }
.dt-pet-badge-pub { background: rgba(46,204,113,.15); color: #2ecc71; }
.dt-pet-badge-draft { background: rgba(255,255,255,.06); color: var(--p5-muted); }
.dt-pet-badge-official { background: rgba(230,57,70,.15); color: var(--p5-red); }

/* PE Template Modal */
.dt-pet-modal-box { background: var(--p5-card); width: 620px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; }
.dt-pet-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--p5-border); }
.dt-pet-modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--p5-text); }
.dt-pet-modal-close { background: none; border: none; color: var(--p5-muted); font-size: 1.6rem; cursor: pointer; line-height: 1; padding: 0 4px; }
.dt-pet-modal-close:hover { color: var(--p5-text); }
.dt-pet-modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.dt-pet-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--p5-border); }
.dt-pet-modal-footer .btn-secondary {
  padding: 10px 20px; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); font-size: 13px; cursor: pointer; transition: border-color .2s;
}
.dt-pet-modal-footer .btn-secondary:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-pet-modal-footer .btn-primary {
  padding: 10px 24px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.dt-pet-modal-footer .btn-primary:hover { opacity: 0.88; }

/* Modal form fields */
.dt-pet-field { margin-bottom: 14px; }
.dt-pet-field label { display: block; font-size: .8rem; color: var(--p5-muted); margin-bottom: 4px; }
.dt-pet-field input, .dt-pet-field textarea, .dt-pet-field select {
  width: 100%; background: var(--p5-dark); border: 1px solid var(--p5-border); color: var(--p5-text);
  padding: 8px 10px; font-size: .85rem; font-family: inherit; box-sizing: border-box; resize: vertical;
}
.dt-pet-field input:focus, .dt-pet-field textarea:focus, .dt-pet-field select:focus { border-color: var(--p5-red); outline: none; }
.dt-pet-field select { cursor: pointer; }

/* ================================================================
   H5-ONLY NAV ITEMS (hidden on desktop)
   ================================================================ */
.dt-nav-item[data-view="create"],
.dt-nav-item[data-view="profile"] { display: none; }

/* H5 Create Menu (hidden by default) */
.h5-create-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 999;
}
.h5-create-overlay.active { display: block; }
.h5-create-menu {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--p5-surface); z-index: 1000;
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  padding: 16px 16px 32px; transform: translateY(100%);
  transition: transform .25s ease;
}
.h5-create-menu.active { display: block; transform: translateY(0); }
.h5-create-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-size: 16px; font-weight: 700; color: var(--p5-text);
}
.h5-create-close {
  background: none; border: none; color: var(--p5-muted); font-size: 24px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.h5-create-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.h5-create-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; color: var(--p5-text);
  font-size: 11px; padding: 0;
}
.h5-create-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}

/* ================================================================
   MOBILE THEME TOGGLE (header, hidden on desktop)
   ================================================================ */
.dt-mobile-theme-btn {
  display: none;
  background: none; border: 1px solid var(--p5-border); color: var(--p5-muted);
  width: 36px; height: 36px; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.dt-mobile-theme-btn:hover { color: var(--p5-text); border-color: var(--p5-red); }

/* ================================================================
   H5 RESPONSIVE — TABLET (≤1024px)
   ================================================================ */
@media (max-width: 1024px) {
  .dt-hero { padding: 40px 24px 28px; }
  .dt-hero-title { font-size: 32px; }
  .dt-features { padding: 0 24px; max-width: 100%; }
  .dt-input-section { padding: 0 24px; }
  .dt-section-header { padding: 0 24px 16px; }
  .dt-preview-grid { margin: 0 24px; padding: 0 0 40px; }
  #discover-view, #templates-view { padding: 20px 24px 60px; }
  .dt-tpl-detail { padding: 20px 24px; }
  .dt-gc-layout { padding: 0; }
}

/* H5 page header with back button — hidden on desktop, shown in H5 media query */
.h5-page-header { display: none; }

/* ================================================================
   H5 RESPONSIVE — MOBILE (≤768px)
   ================================================================ */
@media (max-width: 768px) {

  /* ---- Mobile Theme Toggle visible ---- */
  .dt-mobile-theme-btn { display: flex; }

  /* ---- Sidebar → Bottom Tab Bar ---- */
  .dt-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    top: auto; width: 100% !important; height: 56px;
    flex-direction: row; justify-content: space-around;
    border-right: none;
    border-top: 1px solid var(--p5-border);
    z-index: 100; overflow: visible;
  }
  .dt-sidebar:hover { width: 100% !important; }
  .dt-sidebar-logo { display: none; }
  .dt-sidebar-nav-top,
  .dt-sidebar-nav {
    display: contents;
  }
  .dt-nav-item {
    flex-direction: column; padding: 6px 0; gap: 2px;
    font-size: 10px; flex: 1; justify-content: center;
    align-items: center; min-width: 0;
  }
  .dt-nav-item svg:first-child { width: 20px; height: 20px; }
  .dt-nav-item span { opacity: 1 !important; font-size: 10px; }
  .dt-nav-item.active {
    border-left: none; padding-left: 0;
    border-top: 2px solid var(--p5-red);
  }
  /* Hide all non-H5 nav items on mobile bottom bar */
  .dt-nav-item[data-view="generate"],
  .dt-nav-item[data-view="workshop"],
  .dt-nav-item[data-view="comic"],
  .dt-nav-item[data-view="manga-drama"],
  .dt-nav-item[data-view="asset-studio"],
  .dt-nav-item[data-view="image-studio"],
  .dt-nav-item[data-view="pe-templates"],
  .dt-nav-item[data-view="games"],
  .dt-nav-item[data-view="blog"],
  .dt-nav-item[data-view="song"],
  .dt-nav-item:not([data-view]) { display: none; }
  /* Show H5-only nav items */
  .dt-nav-item[data-view="create"],
  .dt-nav-item[data-view="profile"] { display: flex; }
  .dt-nav-popover-wrap { display: none; }
  .dt-nav-divider { display: none; }
  .lock-icon { display: none !important; }
  /* H5 bottom nav order: 首页, 发现, 创作, 模板, 我的 */
  .dt-nav-item[data-view="home"] { order: 1; }
  .dt-nav-item[data-view="discover"] { order: 2; }
  .dt-nav-item[data-view="create"] { order: 3; }
  .dt-nav-item[data-view="templates"] { order: 4; }
  .dt-nav-item[data-view="profile"] { order: 5; }
  /* Hide sidebar-only sections */
  .dt-theme-toggle { display: none; }
  .dt-sidebar-sub { display: none; }
  .dt-sidebar-bottom { display: none; }
  .dt-nav-scroll-hint { display: none; }

  /* ---- Main area: remove sidebar margin, add bottom padding ---- */
  .dt-main { margin-left: 0; padding-bottom: 56px; }

  /* ---- Header: H5 — Logo + Theme toggle + Login/Notify ---- */
  .dt-header { padding: 0 12px; height: 48px; }
  .dt-logo-img { height: 22px; }
  .lang-switcher { display: none; }
  .dt-mobile-theme-btn { display: flex !important; }
  .dt-mobile-theme-btn.h5-logged-hide { display: none !important; }
  .hub-notify { display: none; }
  .header-user-bar { display: none; }
  /* Override #auth-area .hub-plan/.hub-avatar-wrap (set via #auth-area .header-user-bar { display:flex })
     so plan badge + avatar stay hidden on H5 (credits + gift + bell remain visible) */
  #auth-area .hub-plan,
  #auth-area .hub-avatar-wrap { display: none; }
  .btn-header-logout { display: none; }
  .dt-header-right { gap: 8px; }

  /* ---- HOME: Hero ---- */
  .dt-hero { padding: 24px 16px 16px; }
  .dt-hero-title { font-size: 22px; white-space: normal; line-height: 1.25; }
  .dt-hero-subtitle { font-size: 13px; }

  /* ---- HOME: Feature Cards 4→2 col ---- */
  .dt-features {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; padding: 0 12px; max-width: 100%; margin-bottom: 24px;
  }
  .dt-feature-card { padding: 14px 12px; }
  .dt-feature-card:hover { transform: none; }
  .dt-fc-icon { width: 36px; height: 36px; margin-bottom: 8px; }
  .dt-feature-card h3 { font-size: 13px; }
  .dt-feature-card p { font-size: 11px; -webkit-line-clamp: 1; }

  /* ---- HOME: Model Selector ---- */
  .dt-model-selector { flex-wrap: wrap; gap: 6px; justify-content: center; }
  .dt-model-option { padding: 6px 10px; font-size: 12px; }

  /* ---- HOME: Quick Input ---- */
  .dt-input-section { padding: 0 12px; margin-bottom: 20px; max-width: 100%; }
  .dt-quick-input input { font-size: 16px; padding: 12px; height: 44px; } /* >=16px prevents iOS Safari auto-zoom */
  .dt-quick-go { padding: 0 14px; height: 44px; font-size: 13px; }
  .dt-quick-go span { display: none; }

  /* ---- HOME: Section Header + Preview Grid ---- */
  .dt-section-header { padding: 0 12px 12px; }
  .dt-section-header h2 { font-size: 16px; }
  .dt-preview-grid { margin: 0 12px; padding: 0 0 24px; }

  /* ---- DISCOVER / TEMPLATES: padding + grid ---- */
  #discover-view, #templates-view { padding: 12px 12px 60px; }
  .dt-filter-bar { gap: 6px; padding-bottom: 4px; margin-bottom: 12px; }
  .dt-filter-tab { padding: 5px 12px; font-size: 12px; }
  /* column count handled by JS masonry (see layoutMasonry in desktop.js) */

  /* ---- H5 page header (reusable) ---- */
  .h5-page-header {
    display: flex; align-items: center; gap: 6px;
    position: sticky; top: 0; z-index: 10;
    height: 44px; padding: 0 10px;
    background: var(--p5-card);
    font-size: 15px; font-weight: 600; color: var(--p5-text);
    flex-shrink: 0;
  }
  .h5-back-btn {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--p5-text); cursor: pointer;
  }
  .h5-page-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
  }

  /* ---- TEMPLATE DETAIL: H5 二级页面 (body class driven) ---- */
  /* Step 1: body.h5-tpl-open hides everything, shows template page */
  body.h5-tpl-open { overflow: hidden !important; }
  body.h5-tpl-open .dt-sidebar,
  body.h5-tpl-open .dt-header { display: none !important; }
  body.h5-tpl-open .dt-main { margin: 0 !important; padding: 0 !important; }
  body.h5-tpl-open .dt-content > *:not(.dt-tpl-modal) { display: none !important; }
  body.h5-tpl-open .dt-tpl-modal {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    padding: 0; margin: 0; overflow: hidden;
    background: var(--p5-card);
  }
  body.h5-tpl-open .dt-tpl-modal-backdrop { display: none !important; }
  body.h5-tpl-open .dt-tpl-modal-close { display: none !important; }
  body.h5-tpl-open .dt-tpl-modal-container {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    max-width: 100%; border: none; padding: 0; margin: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  /* Step 2: slide in */
  body.h5-tpl-visible .dt-tpl-modal-container { transform: translateX(0) !important; }

  /* Cover: edge-to-edge, no border */
  body.h5-tpl-open .dt-tpl-hero { display: block; margin: 0; }
  body.h5-tpl-open .dt-tpl-cover-wrap {
    height: auto; border: none !important; background: #000;
  }
  body.h5-tpl-open .dt-tpl-cover {
    width: 100%; height: auto; object-fit: contain; display: block;
  }
  body.h5-tpl-open .dt-tpl-category-overlay {
    top: 8px; left: 8px;
    padding: 2px 8px; font-size: 10px;
    background: rgba(0,0,0,0.5); border: none;
    backdrop-filter: blur(8px);
  }
  /* Info section */
  body.h5-tpl-open .dt-tpl-control { padding: 16px; gap: 10px; }
  body.h5-tpl-open .dt-tpl-control-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
  body.h5-tpl-open .dt-tpl-control-desc {
    font-size: 12px; line-height: 1.5;
    -webkit-line-clamp: unset;
    color: var(--p5-text-secondary);
  }
  /* Author */
  body.h5-tpl-open .dt-tpl-author { padding: 8px 0 0; gap: 8px; border: none; }
  body.h5-tpl-open .dt-tpl-author .tpl-avatar,
  body.h5-tpl-open .dt-tpl-author .author-letter { width: 28px; height: 28px; }
  body.h5-tpl-open .dt-tpl-author .tpl-author-name { font-size: 13px; }
  body.h5-tpl-open .dt-tpl-author .tpl-author-sub { font-size: 10px; }
  /* Hide non-essential on mobile */
  body.h5-tpl-open .dt-tpl-tech-row,
  body.h5-tpl-open .dt-tpl-tags,
  body.h5-tpl-open .dt-tpl-preview,
  body.h5-tpl-open .dt-tpl-spacer { display: none !important; }
  /* CTA sticky bottom */
  body.h5-tpl-open .dt-tpl-actions {
    position: sticky; bottom: 0; z-index: 5;
    padding: 10px 16px;
    background: var(--p5-card);
    border-top: 1px solid var(--p5-border);
    flex-wrap: nowrap; gap: 8px;
  }
  body.h5-tpl-open .dt-tpl-use-btn { width: 100%; text-align: center; padding: 12px; font-size: 15px; }
  body.h5-tpl-open .btn-like.dt-tpl-like { flex-shrink: 0; }
  /* Related & results */
  body.h5-tpl-open .dt-tpl-related { padding: 12px 16px; }
  body.h5-tpl-open .dt-tpl-results { padding: 0 16px 16px; }
  body.h5-tpl-open .dt-tpl-related h2,
  body.h5-tpl-open #dt-tpl-results-title { font-size: 15px; margin-bottom: 8px; }
  body.h5-tpl-open .dt-tpl-related-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }

  /* ---- WIZARD: H5 二级页面 ---- */
  body.h5-wiz-open { overflow: hidden !important; }
  body.h5-wiz-open .dt-sidebar,
  body.h5-wiz-open .dt-header { display: none !important; }
  body.h5-wiz-open #dt-create-wizard {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    padding: 0; margin: 0; overflow: hidden;
    background: var(--p5-card);
  }
  body.h5-wiz-open .dt-wizard-modal {
    position: absolute; inset: 0;
    width: 100% !important; max-width: none !important;
    height: 100%; margin: 0; border: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-wiz-visible .dt-wizard-modal { transform: translateX(0) !important; }
  body.h5-wiz-open .dt-wiz-close-btn { display: none !important; }
  body.h5-wiz-open .dt-wiz-header h2 { display: none; }
  body.h5-wiz-open .dt-wiz-header { padding: 0 16px 8px; border-bottom: none; }
  body.h5-wiz-open .dt-wiz-tabs { flex-wrap: wrap; gap: 6px; }
  body.h5-wiz-open .dt-wiz-body { padding: 12px 16px; }
  body.h5-wiz-open .form-group label { font-size: 13px; }
  body.h5-wiz-open .form-group input,
  body.h5-wiz-open .form-group textarea,
  body.h5-wiz-open .form-group select { font-size: 14px; }

  /* ---- GROUPCOMBO EXEC: H5 二级页面 ---- */
  body.h5-gc-open { overflow: hidden !important; }
  body.h5-gc-open .dt-sidebar,
  body.h5-gc-open .dt-header { display: none !important; }
  body.h5-gc-open .dt-content > *:not(#gc-exec-view) { display: none !important; }
  body.h5-gc-open #gc-exec-view {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-gc-visible #gc-exec-view { transform: translateX(0) !important; }
  body.h5-gc-open .dt-gc-layout { grid-template-columns: 1fr; }
  body.h5-gc-open .dt-exec-back { display: none; }
  body.h5-gc-open .dt-gc-input-panel { padding: 12px 16px; border: none; }
  body.h5-gc-open .dt-gc-result-panel { padding: 12px 16px; }

  /* ---- SUBSCRIPTION: H5 二级页面 ---- */
  body.h5-sub-open { overflow: hidden !important; }
  body.h5-sub-open .dt-sidebar,
  body.h5-sub-open .dt-header { display: none !important; }
  body.h5-sub-open #subscription-modal {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    padding: 0; overflow: hidden;
    background: var(--p5-card);
  }
  body.h5-sub-open .sub-modal {
    position: absolute; inset: 0;
    width: 100% !important; max-width: none !important;
    height: 100%; margin: 0; border: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card); padding: 0 0 16px;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-sub-visible .sub-modal { transform: translateX(0) !important; }
  body.h5-sub-open .sub-modal > .modal-close { display: none !important; }
  body.h5-sub-open .sub-modal > h2,
  body.h5-sub-open .sub-modal > .sub-subtitle { padding: 0 16px; }
  body.h5-sub-open .sub-plans-grid { padding: 0 16px; }

  /* ---- SPENDING: H5 二级页面 ---- */
  body.h5-spend-open { overflow: hidden !important; }
  body.h5-spend-open .dt-sidebar,
  body.h5-spend-open .dt-header { display: none !important; }
  body.h5-spend-open #spending-modal {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    padding: 0; overflow: hidden;
    background: var(--p5-card);
  }
  body.h5-spend-open .spending-modal {
    position: absolute; inset: 0;
    width: 100% !important; max-width: none !important;
    height: 100%; margin: 0; border: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-spend-visible .spending-modal { transform: translateX(0) !important; }
  body.h5-spend-open .dt-fixed-modal-header .dt-fixed-modal-close { display: none !important; }
  body.h5-spend-open .dt-fixed-modal-header h2 { font-size: 16px; }
  body.h5-spend-open .spending-table { font-size: 11px; }
  body.h5-spend-open .spending-table th,
  body.h5-spend-open .spending-table td { padding: 6px 4px; }

  /* ---- SINGLE EXEC: H5 二级页面 ---- */
  body.h5-exec-open { overflow: hidden !important; }
  body.h5-exec-open .dt-sidebar,
  body.h5-exec-open .dt-header { display: none !important; }
  body.h5-exec-open .dt-content > *:not(#project-exec-view) { display: none !important; }
  body.h5-exec-open #project-exec-view {
    display: block !important;
    position: fixed; inset: 0; z-index: 9999;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-exec-visible #project-exec-view { transform: translateX(0) !important; }
  body.h5-exec-open .dt-exec-layout { grid-template-columns: 1fr; }
  body.h5-exec-open .dt-exec-back { display: none; }
  body.h5-exec-open .dt-exec-input-panel { padding: 12px 16px; border: none; }
  body.h5-exec-open .dt-exec-history-panel { padding: 12px 16px; }

  /* ---- Exec prompt: collapsed by default on H5 ---- */
  .dt-exec-prompt-toggle { display: inline; font-size: 11px; transition: transform .2s; }
  #dt-exec-prompt-text {
    max-height: 1.6em !important; overflow: hidden !important;
    cursor: pointer; position: relative;
    transition: max-height .3s ease;
  }
  #dt-exec-prompt-text.h5-expanded { max-height: 200px !important; overflow-y: auto !important; }
  #dt-exec-prompt-text.h5-expanded + .dt-exec-prompt-toggle,
  .h5-expanded ~ .dt-exec-prompt-toggle { transform: rotate(90deg); }

  /* ---- LEGAL PAGE: H5 二级页面 (iframe) ---- */
  body.h5-legal-open { overflow: hidden !important; }
  body.h5-legal-open .dt-sidebar,
  body.h5-legal-open .dt-header { display: none !important; }
  #h5-legal-page {
    position: fixed; inset: 0; z-index: 9999;
    flex-direction: column;
    background: var(--p5-card);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  }
  body.h5-legal-visible #h5-legal-page { transform: translateX(0) !important; }

  /* ---- GENERATE VIEW: 2-col→stacked ---- */
  .dt-gen-layout {
    grid-template-columns: 1fr; height: auto;
  }
  .dt-gen-input-panel {
    border-right: none; border-bottom: 1px solid var(--p5-border);
    padding: 16px 12px;
  }
  .dt-gen-history-panel { padding: 16px 12px; max-height: none; }
  #dt-gen-grid { columns: 2 !important; column-gap: 10px; }
  /* H5 history header: stack h3 / filter / search vertically so filter has full width.
     Bump specificity via .mva3-tabs to override global `.dt-gen-filter.mva3-tabs { flex-wrap: wrap }` (L15998). */
  .dt-gen-history-header { flex-wrap: wrap; gap: 8px; }
  .dt-gen-history-header h3 { flex: 1 1 auto; }
  .dt-gen-filter.mva3-tabs {
    order: 3;
    flex: 1 1 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .dt-gen-filter.mva3-tabs::-webkit-scrollbar { display: none; }
  .dt-gen-filter .mva3-tab { flex-shrink: 0; }
  .dt-gen-search-wrap { margin-left: auto; }
  .dt-gen-search-input { width: 160px; }
  .dt-gen-search-input:focus { width: 180px; }

  /* ---- SINGLE EXEC VIEW: 2-col→stacked ---- */
  #project-exec-view.active,
  #gc-exec-view.active { display: block; min-height: auto; }
  .dt-exec-layout {
    grid-template-columns: 1fr; flex: none; overflow: visible;
  }
  .dt-exec-input-panel { }
  .dt-exec-input-panel {
    border-right: none; border-bottom: 1px solid var(--p5-border);
    padding: 16px 12px;
  }
  .dt-exec-history-panel { padding: 16px 12px; }

  /* ---- GC EXEC VIEW: 2-col→stacked ---- */
  .dt-gc-layout {
    grid-template-columns: 1fr; gap: 0; flex: none; overflow: visible;
  }
  .dt-gc-input-panel { border-right: none; padding: 16px 12px; }
  .dt-gc-result-panel { max-height: none; padding-right: 0; }
  .dt-gc-layout .dt-gen-title { font-size: 16px; line-height: 1.4; word-break: break-word; }
  .dt-gc-layout .dt-exec-summary { font-size: 11px; line-height: 1.5; word-break: break-word; }
  .dt-gc-section-title { font-size: 12px; margin: 12px 0 8px; }
  .dt-gc-field-group label { font-size: 11px; margin-bottom: 4px; word-break: break-word; }
  .dt-gc-field-input { font-size: 13px; padding: 8px 10px; }
  .dt-gc-group-card { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .dt-gc-group-desc { font-size: 11px; word-break: break-word; min-width: 0; }
  .dt-gc-upload-btn { font-size: 11px; padding: 5px 12px; }
  .dt-gc-type-badge { font-size: 10px; }
  .dt-gc-cost-bar { font-size: 12px; }

  /* ---- WORKSHOP GRID ---- */
  .dt-ws-header { padding: 16px 12px 12px; }
  .dt-ws-actions { flex-wrap: wrap; gap: 8px; }
  .dt-ws-grid { grid-template-columns: 1fr; gap: 12px; padding: 0 12px 60px; }

  /* ---- PE TEMPLATES ---- */
  .dt-pet-header { padding: 16px 12px 12px; }
  .dt-pet-actions { flex-wrap: wrap; }

  /* ---- WIZARD MODAL → fullscreen ---- */
  .dt-wizard-modal {
    width: 100vw !important; max-width: 100vw !important;
    height: 100vh; max-height: 100vh;
    margin: 0; border: none; padding: 20px 16px;
  }
  .dt-wiz-tabs { overflow-x: auto; }
  .dt-gc-scale-row { flex-direction: column; }
  .dt-gc-otype-row { flex-wrap: wrap; }
  .dt-wiz-radio-row { flex-wrap: wrap; }

  /* ---- LOGIN / SUBSCRIPTION / CONFIRM MODALS ---- */
  /* Mobile: top-align + scroll so keyboard doesn't cover the form */
  #login-modal.modal-overlay { align-items: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .login-modal { width: 100%; max-width: 100vw; padding: 24px 16px; margin-top: 10vh; margin-bottom: 40vh; }
  /* Prevent iOS auto-zoom on input focus (requires >= 16px) */
  .login-modal input, .login-modal select, .login-modal textarea { font-size: 16px; }
  .sub-modal { width: 100%; max-width: 100vw; padding: 24px 16px; }
  .sub-plans-grid { grid-template-columns: 1fr; gap: 10px; }
  .sub-plan-card { padding: 14px 16px; }
  .sub-plan-card.recommended { border-color: var(--p5-red); }
  .sub-h5-compact {
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 10px 16px;
  }
  .sub-h5-compact h3 { font-size: 14px; margin: 0; }
  .sub-h5-compact .btn-plan-current { margin: 0; width: auto; padding: 4px 12px; font-size: 11px; }
  .sub-h5-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .sub-h5-header h3 { font-size: 15px; margin-bottom: 0; }
  .sub-h5-header .sub-price { margin: 0; }
  .sub-h5-header .sub-price-main, .sub-h5-header .sub-price-discount { font-size: 20px; }
  .sub-h5-header .sub-price-period { font-size: 11px; }
  .sub-h5-header .sub-price-original { font-size: 13px; }
  .sub-h5-badge {
    display: inline-block; font-size: 10px; color: var(--p5-red); border: 1px solid var(--p5-red);
    padding: 1px 6px; margin-left: 6px; font-weight: 600; vertical-align: middle;
  }
  .sub-h5-details {
    font-size: 11px; color: var(--p5-muted); line-height: 1.5;
    border-top: 1px solid var(--p5-border); margin-top: 8px; padding-top: 8px;
  }
  .sub-h5-details ul { list-style: none; padding: 0; margin: 0; }
  .sub-h5-details li { padding: 1px 0; }
  .sub-h5-toggle {
    background: none; border: none; color: var(--p5-muted); font-size: 11px;
    cursor: pointer; padding: 4px 0; text-align: center; width: 100%;
  }
  .confirm-modal-box { width: 90vw; padding: 24px 16px; }

  /* ---- PE TEMPLATE MODAL ---- */
  .dt-pet-modal-box { width: 100vw; max-width: 100vw; max-height: 100vh; }
  .dt-pet-modal-header { padding: 14px 16px; }
  .dt-pet-modal-body { padding: 16px; }
  .dt-pet-modal-footer { padding: 12px 16px; }

  /* ---- STYLE PICKER MODAL ---- */
  .dt-style-modal { width: 100vw; max-width: 100vw; max-height: 85vh; }
  .dt-style-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px; }

  /* ---- FLOAT PANELS: centered modal on H5 ---- */
  .dt-task-float {
    right: 0; left: 0; top: 50%; bottom: auto;
    transform: translateY(-50%);
    width: 88%; max-width: 320px; max-height: 50vh;
    margin: 0 auto;
    z-index: 10000;
  }
  .dt-tf-header { padding: 8px 12px; font-size: 12px; }
  .dt-tf-body { max-height: 200px; }
  .dt-tf-item { padding: 8px 12px; }
  .dt-tf-prompt { font-size: 12px; }
  .dt-tf-meta { font-size: 10px; margin-bottom: 4px; }
  .dt-tf-status { font-size: 11px; }
  .dt-tf-timer { font-size: 10px; }
  .dt-pc-map { max-height: 120px; }

  /* ---- LIGHTBOX ---- */
  .lightbox img, .lightbox video { max-width: 96vw; max-height: 80vh; }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }

  /* ---- GC Wizard: preset + toggle ---- */
  .dt-gc-preset-grid { gap: 6px; }
  .dt-gc-toggle-row { flex-direction: column; gap: 6px; }
  .dt-gc-toggle-btn { font-size: 12px; }

  /* ---- Profile panel ---- */
  .profile-panel { width: 100vw; max-width: 100vw; }

  /* ---- Misc: disable hover transforms on touch ---- */
  .dt-discover-card:hover { transform: none; }
  .discover-card:hover { transform: none; }

  /* ---- body overflow fix for bottom-bar layout ---- */
  body { overflow: auto; }
  .dt-main { height: auto; min-height: 100vh; }
  .dt-content { overflow-y: visible; }
  .dt-footer { display: none; }

  /* ---- Templates View: H5 adjustments ---- */
  /* Hide hero title */
  .tpl-hero-title { display: none; }
  /* Compact hero padding */
  .tpl-hero { padding: 12px 16px 12px; margin: 0 -16px 12px; }
  /* Search bar full width */
  .tpl-search-bar { margin-bottom: 16px; }

  /* Category tabs: horizontal scroll with icon on top */
  .tpl-categories-wrap {
    overflow: visible;
    position: relative;
  }
  /* Right fade hint: signals more content to scroll */
  .tpl-categories-wrap::after {
    content: '';
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--p5-surface, #121218));
    pointer-events: none; z-index: 1;
  }
  .tpl-cat-arrow { display: none !important; }
  .tpl-categories {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 32px 0 0; gap: 0;
    scrollbar-width: none;
  }
  .tpl-categories::-webkit-scrollbar { display: none; }
  .tpl-cat-pill {
    flex: 0 0 auto !important;
    flex-direction: column;
    padding: 8px 14px;
    gap: 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 11px;
    min-width: 56px;
  }
  .tpl-cat-pill svg { width: 20px; height: 20px; }
  .tpl-cat-pill:hover {
    background: none; border-color: transparent;
    border-bottom-color: rgba(230,57,70,0.3);
  }
  .tpl-cat-pill.active {
    background: none;
    border-color: transparent;
    border-bottom: 2px solid var(--p5-red);
    color: var(--p5-red);
  }
  .tpl-cat-pill.active svg { stroke: var(--p5-red); }

  /* Toolbar compact — no wrap on mobile */
  .tpl-toolbar { padding: 0 16px; margin-bottom: 12px; flex-wrap: nowrap; gap: 8px; }
  .tpl-type-seg { padding: 6px 12px; font-size: 13px; }
  .tpl-model-btn { font-size: 12px; padding: 6px 10px; }
  .tpl-model-btn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

  /* Card grid: column count handled by JS masonry (single column on mobile). */
  .discover-grid { padding: 0 16px; }
  .discover-card { border-radius: 8px; }
  .discover-card .card-info { padding: 10px 12px; }
}

/* ================================================================
   H5 RESPONSIVE — SMALL PHONE (≤480px)
   ================================================================ */
@media (max-width: 480px) {
  .dt-hero-title { font-size: 19px; }
  .dt-features { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  /* .discover-grid / .dt-preview-grid column count handled by JS masonry */
  #dt-gen-grid { columns: 1 !important; }
  .dt-model-option span { font-size: 11px; }
}

/* ================================================================
   SPENDING HISTORY
   ================================================================ */
.btn-spending { padding: 5px 14px; background: transparent; border: 1px solid #24242e; color: #999; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-spending:hover { border-color: #e63946; color: #e0e0e0; }
#spending-modal.active { align-items: center; }
.spending-modal { background: #16161d; border: 1px solid #24242e; width: 700px; max-width: 95vw; height: 80vh; position: relative; }
.spending-modal .modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: #666; font-size: 24px; cursor: pointer; line-height: 1; z-index: 1; }
.spending-modal .modal-close:hover { color: #e0e0e0; }
.spending-modal h2 { font-size: 22px; color: #e0e0e0; margin-bottom: 4px; }
.spending-subtitle { font-size: 13px; color: #666; margin-bottom: 20px; }
.spending-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spending-table th { text-align: left; padding: 10px 8px; color: #888; font-weight: 600; border-bottom: 1px solid #24242e; font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; position: sticky; top: 0; background: #16161d; z-index: 1; }
.spending-footer { flex-shrink: 0; padding: 0 28px 20px; background: #16161d; }
.spending-table td { padding: 10px 8px; border-bottom: 1px solid rgba(36,36,46,0.5); color: #ccc; }
.spending-cell-time { white-space: nowrap; font-size: 12px; color: #888; }
.spending-cell-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spending-type-badge { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.spending-deduction { color: #e63946; }
.spending-refund { color: #4caf50; }
.spending-expired { color: #888; }
.spending-purchase { color: #ffa500; }
.spending-bonus { color: #4fc3f7; }
.spending-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding-top: 16px; border-top: 1px solid #24242e; }
.spending-page-btn { padding: 6px 16px; background: #111118; border: 1px solid #24242e; color: #ccc; font-size: 13px; cursor: pointer; }
.spending-page-btn:hover:not(:disabled) { border-color: #e63946; color: #fff; }
.spending-page-btn:disabled { opacity: 0.4; cursor: default; }
.spending-page-info { font-size: 13px; color: #888; }
@media (max-width: 600px) {
  .spending-modal { padding: 20px 12px; }
  .spending-cell-desc { max-width: 120px; }
}

/* ================================================================
   SONG STUDIO
   ================================================================ */
.song-panel { position: absolute; inset: 0; display: none; flex-direction: column; overflow: hidden; }
.song-panel.active { display: flex; }
.song-panel.has-stepper { top: 44px; }
#song-view.active { display: block; position: absolute; inset: 0; }

/* ===== MV Stepper (Phase 1) ===================================================
   顶部 stepper：BACK pill + 6 步 rail。仅在 MV project 流程内显示。
   v4 manga-drama 视觉骨架 + 项目 P5 token 映射。
   ============================================================================ */
.song-stepper { position: absolute; top: 0; left: 0; right: 0; z-index: 3; height: 44px; display: none; align-items: stretch; background: var(--p5-card); border-bottom: 1px solid var(--p5-border); overflow: hidden; }
.song-stepper.active { display: flex; }
.song-stepper-back { display: flex; align-items: center; gap: 8px; padding: 0 16px; flex-shrink: 0; border: 0; border-right: 1px solid var(--p5-border); background: transparent; font-family: var(--font-display); font-size: 11px; letter-spacing: 0.1em; color: var(--p5-text-secondary); text-transform: uppercase; cursor: pointer; font-weight: 600; transition: background 0.15s, color 0.15s; }
.song-stepper-back:hover { background: var(--p5-input-bg); color: var(--p5-text); }
.song-stepper-back svg { width: 12px; height: 12px; }

.song-step-rail { flex: 1; display: flex; align-items: stretch; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.song-step-rail::-webkit-scrollbar { display: none; }

.song-step { display: flex; align-items: center; gap: 10px; padding: 0 22px 0 0; flex-shrink: 0; color: var(--p5-muted); background: transparent; border: 0; cursor: pointer; white-space: nowrap; font-family: inherit; transition: color 0.15s; }
.song-step:hover { color: var(--p5-text); }
.song-step-idx { width: 26px; height: 26px; display: grid; place-items: center; background: var(--p5-input-bg); color: var(--p5-muted); font-weight: 700; font-size: 12px; margin-left: 18px; position: relative; transition: background 0.15s, color 0.15s, box-shadow 0.15s; }
.song-step.done .song-step-idx { background: var(--p5-red); color: #000; }
.song-step.done .song-step-idx::after { content: ''; position: absolute; inset: 4px; border: 1.5px solid #000; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(2px, -1px); width: 11px; height: 5.5px; }
.song-step.on .song-step-idx { background: var(--p5-red); color: #fff; box-shadow: 0 0 0 2px var(--p5-card), 0 0 0 3px var(--p5-red); }
.song-step.on { color: var(--p5-text); }
.song-step.done { color: var(--p5-text-secondary); }
.song-step-lb { font-family: var(--font-display); font-weight: 500; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.song-step-ji { font-size: 11px; color: var(--p5-red); opacity: 0; transition: opacity 0.15s; margin-left: 2px; letter-spacing: 0.05em; font-weight: 500; }
.song-step.on .song-step-ji, .song-step.done .song-step-ji { opacity: 0.85; }
.song-step-bar { width: 36px; height: 2px; background: var(--p5-input-bg); flex-shrink: 0; margin-left: 8px; transition: background 0.15s; }
.song-step.done .song-step-bar { background: var(--p5-red); }
.song-step.on .song-step-bar { background: linear-gradient(90deg, var(--p5-red) 50%, var(--p5-input-bg) 50%); }
.song-step:last-child .song-step-bar { display: none; }
.song-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.song-header h2 { font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--p5-text); margin: 0; }
.song-list { flex: 1; overflow-y: auto; padding: 16px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-content: start; }
.song-empty { grid-column: 1 / -1; text-align: center; color: var(--p5-muted); padding: 60px 0; }
.song-card { background: var(--p5-card); border: 1px solid var(--p5-border); border-radius: 0; cursor: pointer; overflow: hidden; transition: border-color 0.15s; }
.song-card:hover { border-color: var(--p5-red); }
.song-card-cover { height: 140px; background: var(--p5-input-bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.song-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.song-card-placeholder { font-size: 40px; color: var(--p5-muted); opacity: 0.3; }
.song-card-info { padding: 10px 12px; }
.song-card-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; font-size: var(--text-xs); color: var(--p5-muted); }
.song-card-status { padding: 1px 6px; border: 1px solid var(--p5-border); font-size: 10px; }
.song-card-status.done { color: #4caf50; border-color: #4caf50; }
.song-card-status.failed { color: var(--p5-red); border-color: var(--p5-red); }

/* =======================================================
   SONG MYWORK — v4 visual refactor (Step A, 2026-04-22)
   项目列表: large title + mono sub + 4-col grid (1:1 poster + fake waveform + info)
   ======================================================= */
.song-my-page { flex: 1; overflow-y: auto; padding: 28px; background: var(--p5-dark); }
.song-my-page::-webkit-scrollbar { width: 6px; }
.song-my-page::-webkit-scrollbar-thumb { background: var(--p5-input-bg); }

.song-my-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--p5-border); position: relative; }
.song-my-head::before { content: ''; position: absolute; left: 0; bottom: -1px; width: 160px; height: 2px; background: var(--p5-red); }
.song-my-head-left { min-width: 0; }
.song-my-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; color: var(--p5-text); margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.song-my-title-ji { font-size: 14px; color: var(--p5-red); font-weight: 700; font-style: normal; letter-spacing: 0.08em; }
.song-my-sub { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.1em; color: var(--p5-muted); text-transform: uppercase; margin-top: 6px; font-weight: 500; }
.song-my-sub b { color: var(--p5-red); font-weight: 700; }

.song-my-head-actions { display: flex; flex-shrink: 0; }
.song-my-new-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; background: var(--p5-red); color: #000; border: 0; font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer; transition: background 0.15s, color 0.15s; }
.song-my-new-btn:hover { background: #ff8080; color: #fff; }
.song-my-new-btn svg { width: 11px; height: 11px; }

.song-my-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; align-content: start; }
@media (max-width: 1600px) { .song-my-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1280px) { .song-my-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 980px)  { .song-my-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .song-my-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px)  { .song-my-grid { grid-template-columns: 1fr; } }

.song-my-empty { grid-column: 1 / -1; text-align: center; color: var(--p5-muted); padding: 80px 0; font-size: 13px; }

.song-my-card { border: 1px solid var(--p5-border); background: var(--p5-card); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; position: relative; overflow: hidden; }
.song-my-card:hover { border-color: var(--p5-red); }
.song-my-card.on { border-color: var(--p5-red); box-shadow: inset 0 0 0 1px var(--p5-red); }

.song-my-poster { aspect-ratio: 1/1; position: relative; overflow: hidden; background: var(--p5-input-bg); }
.song-my-poster::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.85)); pointer-events: none; z-index: 1; }
.song-my-poster-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.song-my-poster-fallback { position: absolute; inset: 0; background: linear-gradient(135deg, #2a1520, #4a1a2e 50%, #7a2030); display: grid; place-items: center; color: rgba(255,255,255,0.2); }
.song-my-poster-fallback svg { width: 48px; height: 48px; }
.song-my-tl { position: absolute; top: 8px; left: 8px; z-index: 2; font-size: 9px; padding: 2px 6px; background: #000; color: var(--p5-red); border: 1px solid var(--p5-red); letter-spacing: 0.08em; font-weight: 600; text-transform: uppercase; }
.song-my-tl.ready { color: #4caf50; border-color: #4caf50; }
.song-my-tr { position: absolute; top: 8px; right: 8px; z-index: 2; font-size: 10.5px; padding: 2px 7px; background: var(--p5-red); color: #000; letter-spacing: 0.08em; font-weight: 700; }
.song-my-play { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,0.15); z-index: 1; transition: color 0.15s; pointer-events: none; }
.song-my-card:hover .song-my-play { color: rgba(255,255,255,0.6); }
/* Interactive play button (Step B, only when audio available) */
.song-my-play-btn { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,0.55); z-index: 3; background: transparent; border: 0; cursor: pointer; transition: color 0.15s, background 0.15s, transform 0.15s; padding: 0; font-family: inherit; }
.song-my-play-btn:hover { color: #fff; background: rgba(0,0,0,0.35); transform: scale(1.08); }
.song-my-play-btn svg { filter: drop-shadow(0 2px 10px rgba(0,0,0,0.8)); }
.song-my-play-btn .song-my-icon-pause { display: none; }
.song-my-card.playing { border-color: var(--p5-red); box-shadow: inset 0 0 0 1px var(--p5-red); }
.song-my-card.playing .song-my-play-btn { color: #fff; }
.song-my-card.playing .song-my-play-btn .song-my-icon-play { display: none; }
.song-my-card.playing .song-my-play-btn .song-my-icon-pause { display: block; }

/* Waveform: 3 states — idle (subtle breathing) / hover (brighter + amped) / playing (red pulse) */
.song-my-wave { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 2px; padding: 10px; z-index: 2; align-items: flex-end; height: 36px; pointer-events: none; }
.song-my-wave span { flex: 1; background: rgba(255,255,255,0.55); transition: background 0.2s; transform-origin: bottom; animation: song-my-wave-idle 2.4s ease-in-out infinite; }
.song-my-wave span:nth-child(2n) { animation-delay: 0.15s; }
.song-my-wave span:nth-child(3n) { animation-delay: 0.3s; }
.song-my-wave span:nth-child(4n) { animation-delay: 0.45s; }
.song-my-wave span:nth-child(5n) { animation-delay: 0.6s; }
.song-my-wave span:nth-child(7n) { animation-delay: 0.9s; }
@keyframes song-my-wave-idle { 0%, 100% { opacity: 0.55; transform: scaleY(0.9); } 50% { opacity: 0.85; transform: scaleY(1.08); } }
.song-my-card:hover .song-my-wave span { background: var(--p5-red); animation-name: song-my-wave-hover; animation-duration: 1.4s; }
@keyframes song-my-wave-hover { 0%, 100% { opacity: 0.7; transform: scaleY(0.85); } 50% { opacity: 1; transform: scaleY(1.15); } }
.song-my-card.playing .song-my-wave span { background: var(--p5-red); animation-name: song-my-wave-pulse; animation-duration: 0.9s; }
@keyframes song-my-wave-pulse { 0%, 100% { opacity: 0.6; transform: scaleY(0.7); } 50% { opacity: 1; transform: scaleY(1.45); } }

.song-my-info { padding: 10px 11px; border-top: 1px solid var(--p5-border); position: relative; }
.song-my-info::before { content: ''; position: absolute; top: -1px; left: 0; width: 32px; height: 1px; background: var(--p5-red); }
.song-my-name { font-weight: 600; font-size: 13px; letter-spacing: 0.02em; margin: 0 0 6px; color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-my-info-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.song-my-open { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: transparent; border: 1px solid var(--p5-red); color: var(--p5-red); font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.song-my-open:hover { background: var(--p5-red); color: #fff; }
.song-my-open svg { display: block; }
.song-my-phase { font-size: 9px; letter-spacing: 0.08em; color: var(--p5-red); text-transform: uppercase; padding: 2px 5px; border: 1px solid var(--p5-red); display: inline-block; font-weight: 600; }
.song-my-phase.ready { color: #4caf50; border-color: #4caf50; }
.song-my-phase.mv { color: #ff9800; border-color: #ff9800; }
.song-my-tl.mv { color: #ff9800; border-color: #ff9800; }
.song-my-tag { font-size: 11px; color: var(--p5-text-secondary); line-height: 1.4; margin: 6px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-my-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--p5-border); font-size: 9px; color: var(--p5-muted); letter-spacing: 0.06em; }
.song-my-dur { color: var(--p5-red); font-weight: 700; }
.song-my-date { flex-shrink: 0; }

/* NEW SONG card — parity with project cards (poster + info),
   signature red-gold gradient to stand out as a create-action tile. */
.song-my-new { border: 1px solid var(--p5-border); background: var(--p5-card); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; position: relative; overflow: hidden; display: flex; flex-direction: column; color: var(--p5-text-secondary); }
.song-my-new:hover { border-color: var(--p5-red); box-shadow: inset 0 0 0 1px var(--p5-red); color: var(--p5-text); }
.song-my-new-poster {
  aspect-ratio: 1/1;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a0a10 0%, #3a1420 40%, #7a1f2a 75%, #c02836 100%);
  display: grid;
  place-items: center;
}
.song-my-new-poster::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}
.song-my-new-plus {
  position: relative;
  z-index: 1;
  font-size: 72px;
  font-weight: 200;
  line-height: 1;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
  transition: transform 0.2s, color 0.2s;
}
.song-my-new:hover .song-my-new-plus { transform: scale(1.1); color: #fff; }
.song-my-new-info {
  padding: 10px 11px;
  border-top: 1px solid var(--p5-border);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  justify-content: center;
  min-height: 60px;
}
.song-my-new-info::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 32px;
  height: 1px;
  background: var(--p5-red);
}
.song-my-new-lb { font-family: var(--font-display); font-weight: 500; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--p5-text); }
.song-my-new-ji { font-size: 10px; letter-spacing: 0.06em; font-weight: 500; color: var(--p5-muted); }
/* Waveform tuned for red gradient: white bars with higher opacity; hover intensifies to full white. */
.song-my-new-wave span { background: rgba(255,255,255,0.7); }
.song-my-new:hover .song-my-wave span { background: #fff; animation-name: song-my-wave-hover; animation-duration: 1.4s; }

/* =======================================================
   SONG WORKSPACE v3 — header chips + hero player + lyrics
   ======================================================= */
.song-ws-header { display: flex; align-items: center; gap: 14px; padding: 0 20px; height: 56px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; background: rgba(10,10,15,0.85); backdrop-filter: blur(8px); position: relative; z-index: 2; }
.song-ws-divider { width: 1px; height: 20px; background: var(--p5-border); flex-shrink: 0; }
.song-ws-chips { display: flex; gap: 8px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.song-ws-chips::-webkit-scrollbar { display: none; }
.song-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: rgba(255,255,255,0.04); border: 1px solid var(--p5-border); cursor: pointer; white-space: nowrap; transition: border-color 0.15s; }
.song-chip:hover { border-color: var(--p5-red); }
.song-chip-label { color: var(--p5-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; font-weight: var(--weight-semibold); }
.song-chip-select { background: transparent; border: none; color: var(--p5-text); font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 0; cursor: pointer; outline: none; font-family: inherit; }
.song-chip-select option { background: var(--p5-card); }

.song-layout { display: flex; flex: 1; min-height: 0; position: relative; }
.song-wallpaper-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity 0.6s; pointer-events: none; z-index: 0; }
.song-wallpaper-bg.active { opacity: 1; }
.song-wallpaper-bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.78) 80%); }
.song-layout > *:not(.song-wallpaper-bg) { position: relative; z-index: 1; }

/* LEFT: Idea editor + advanced + CTA */
.song-left { width: 320px; flex-shrink: 0; border-right: 1px solid var(--p5-border); display: flex; flex-direction: column; overflow-y: auto; padding: 16px; gap: 12px; background: rgba(10,10,15,0.75); backdrop-filter: blur(4px); }
.song-section-head { display: flex; align-items: baseline; justify-content: space-between; }
.song-section-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--p5-text-secondary); text-transform: uppercase; letter-spacing: 0.6px; }
.song-section-hint { font-size: 10px; color: var(--p5-muted); }

.song-textarea { width: 100%; background: var(--p5-input-bg); border: 1px solid var(--p5-border); border-radius: 0; color: var(--p5-text); padding: 10px 12px; font-size: var(--text-sm); font-family: inherit; resize: vertical; box-sizing: border-box; line-height: 1.5; }
.song-textarea:focus { outline: none; border-color: var(--p5-red); }
.song-idea-textarea { min-height: 180px; }
.song-prompt-input { font-size: var(--text-xs); min-height: 90px; }

.song-advanced { border: 1px solid var(--p5-border); background: rgba(22,22,29,0.6); }
.song-advanced-hd { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; cursor: pointer; user-select: none; }
.song-advanced-hd-left { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--p5-text-secondary); text-transform: uppercase; letter-spacing: 0.6px; }
.song-advanced-hd-right { color: var(--p5-muted); transition: transform 0.2s; display: flex; }
.song-advanced.open .song-advanced-hd-right { transform: rotate(180deg); }
.song-advanced-body { padding: 0 12px 12px; display: none; flex-direction: column; gap: 10px; }
.song-advanced.open .song-advanced-body { display: flex; }

.song-cta-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 12px; }
.song-cta-primary { width: 100%; justify-content: center; padding: 12px; font-size: var(--text-sm); }
.song-cta-secondary { width: 100%; justify-content: center; }
.song-cta-hint { display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: var(--p5-muted); padding: 0 4px; margin-top: -4px; }
.song-cta-hint .song-cta-cost { color: #ff6b6b; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.song-idea-counter { font-size: 10px; color: var(--p5-muted); font-variant-numeric: tabular-nums; }

.song-progress-inline { display: flex; align-items: center; gap: 8px; width: 100%; }
.song-progress-bar { flex: 1; height: 3px; background: var(--p5-input-bg); overflow: hidden; }
.song-progress-fill { height: 100%; background: var(--p5-red); width: 0; transition: width 0.3s; }
.song-progress-text { font-size: 11px; color: var(--p5-muted); white-space: nowrap; }

/* Lyrics-phase CTA sits directly below the idea textarea (phase-1 of the flow).
   Music CTA stays at the column bottom (phase-2). The two phases are separated
   so users understand lyrics-first, then music. */
.song-lyrics-cta-wrap { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* CENTER: Hero player + lyrics */
.song-center { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; z-index: 1; min-width: 0; }

.song-player-panel { flex-shrink: 0; padding: 20px 28px 16px; display: flex; gap: 20px; align-items: stretch; background: linear-gradient(180deg, rgba(0,0,0,0.15), transparent); }
.song-player-thumb {
  width: 168px; height: 168px; flex-shrink: 0; background: var(--p5-input-bg);
  overflow: hidden; position: relative; cursor: pointer;
  box-shadow:
    0 30px 60px -15px rgba(0,0,0,0.8),
    0 12px 24px -8px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
}
.song-player-thumb::before {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.22) 100%);
}
.song-player-thumb::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.song-player-thumb:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 36px 70px -15px rgba(0,0,0,0.85),
    0 16px 28px -8px rgba(0,0,0,0.65),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.2);
}
.song-player-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.song-player-thumb-overlay { position: absolute; inset: 0; z-index: 3; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; }
.song-player-thumb:hover .song-player-thumb-overlay, .song-player-thumb-overlay.playing { opacity: 1; }
.song-player-thumb-overlay svg { filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6)); }

.song-player-right { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 4px 0; }
.song-player-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.song-player-title-col { min-width: 0; flex: 1; }
.song-player-track-title { font-size: 22px; font-weight: var(--weight-bold); color: var(--p5-text); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.song-player-meta { margin-top: 6px; font-size: var(--text-xs); color: var(--p5-text-secondary); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.song-player-meta .dot { opacity: 0.4; }
.song-player-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.song-player-actions .dt-btn { background: rgba(0,0,0,0.3); }
.song-wp-picker { display: inline-flex; align-items: center; gap: 4px; }
.song-wp-num { width: 22px; height: 22px; border: 1px solid var(--p5-border); background: rgba(0,0,0,0.3); color: var(--p5-muted); font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.song-wp-num:hover { border-color: var(--p5-red); color: var(--p5-text); }
.song-wp-num.active { border-color: var(--p5-red); background: var(--p5-red); color: #fff; }
.song-wp-save { border: 1px solid var(--p5-border); background: rgba(0,0,0,0.3); color: var(--p5-muted); font-size: 11px; padding: 2px 8px; cursor: pointer; transition: all 0.15s; }
.song-wp-save:hover { border-color: var(--p5-red); color: var(--p5-text); }

.song-player-bottom { display: flex; align-items: center; gap: 14px; }
.song-player-time { font-size: 10px; color: var(--p5-muted); flex-shrink: 0; min-width: 30px; font-variant-numeric: tabular-nums; }
.song-player-seekbar { flex: 1; height: 4px; background: rgba(255,255,255,0.12); cursor: pointer; position: relative; }
.song-player-seekbar-fill { height: 100%; background: var(--p5-red-gradient); width: 0; pointer-events: none; transition: none; }
.song-player-seekbar-handle { position: absolute; top: 50%; width: 10px; height: 10px; background: #fff; transform: translate(-50%, -50%); left: 0; opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.song-player-seekbar:hover .song-player-seekbar-handle { opacity: 1; }
.song-visualizer { flex-shrink: 0; width: 200px; height: 44px; }

/* Rhythm score — chip below meta row */
.song-rhythm-score-strip { display: inline-flex; align-items: center; gap: 12px; padding: 8px 14px; background: rgba(230,57,70,0.12); border: 1px solid rgba(230,57,70,0.4); cursor: pointer; transition: all 0.15s; margin-top: 12px; line-height: 1; }
.song-rhythm-score-strip:hover { background: rgba(230,57,70,0.2); }
.song-rhythm-score-grade { font-size: 22px; font-weight: var(--weight-bold); color: #ffd700; letter-spacing: -0.5px; min-width: 20px; text-align: center; }
.song-rhythm-score-num { font-size: 18px; font-weight: var(--weight-bold); color: var(--p5-text); font-variant-numeric: tabular-nums; }
.song-rhythm-score-acc { font-size: 12px; color: var(--p5-text-secondary); font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.song-rhythm-score-best { font-size: 12px; color: var(--p5-text-secondary); padding-left: 10px; border-left: 1px solid rgba(230,57,70,0.3); font-weight: var(--weight-semibold); }
.song-rhythm-score-perfect { font-size: 12px; color: var(--p5-muted); font-weight: var(--weight-semibold); }

/* Lyrics display + rhythm overlay */
.song-content-area { flex: 1; overflow: hidden; position: relative; }
.song-lyrics-display { width: 100%; height: 100%; padding: 32px 40px 60px; overflow-y: auto; scroll-behavior: smooth; text-align: center; transition: opacity 0.3s; }
.song-lyrics-empty { color: var(--p5-text-secondary); font-size: var(--text-sm); padding: 40px 0; text-align: center; }
.song-lyrics-section { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--p5-red); margin: 22px 0 8px; letter-spacing: 1px; }
.song-lyrics-section:first-child { margin-top: 0; }
.song-lyrics-instrument { font-size: var(--text-xs); color: var(--p5-muted); font-style: italic; }
.song-lyrics-line {
  font-size: 16px;
  color: var(--p5-text);
  line-height: 2.3;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
}
.song-lyrics-line.active { color: var(--p5-red-2, #ff6b6b); font-weight: 600; }
/* Visual break between sections — replaces hidden [Section] markers */
.song-lyrics-spacer { height: 32px; }
.song-content-area.rhythm-on .song-lyrics-display { opacity: 0.15; }

/* ───── Karaoke v3 — group-level highlight (whisperx segment = 1 group) ─────
   Design:
     - Each whisperx vocal segment becomes a .sck-group containing N lyric lines
     - Whole group highlights together while playback is inside its time window
     - Past groups dim down, future groups muted; smooth scroll keeps active centered
     - No per-line timing drift — trust whisperx's accurate segment boundaries
     - Section spacer between groups with > 3s silence gap
*/
.sck-group {
  padding: 10px 0;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.45s ease, transform 0.45s ease, filter 0.45s ease;
}
.sck-group-line {
  font-size: 17px;
  line-height: 2.3;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  transition: color 0.45s ease, font-size 0.45s ease, font-weight 0.45s ease;
  padding: 2px 0;
}

/* Passed — dim grey (still readable after the song plays through) */
.sck-group-passed {
  opacity: 1;
  transform: scale(0.96);
}
.sck-group-passed .sck-group-line {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 400;
}

/* Active — warm gradient, larger, glowing */
.sck-group-active {
  opacity: 1;
  transform: scale(1.04);
  filter: drop-shadow(0 0 14px rgba(230, 57, 70, 0.45));
}
.sck-group-active .sck-group-line {
  font-size: 21px;
  font-weight: 600;
  background-image: linear-gradient(90deg, #ff6b6b 0%, #ff8844 50%, #ffb347 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Future (default) — muted white, same size as passed */
.sck-group:not(.sck-group-active):not(.sck-group-passed) {
  opacity: 0.65;
}

/* Fading — last N ms of an active section before the chain hands off to the
   next. Softens the visual cut so the crossover into the next group feels
   musical instead of abrupt. Applied *on top of* .sck-group-active. */
.sck-group-active.sck-group-fading {
  transform: scale(1.0);
  filter: drop-shadow(0 0 6px rgba(230, 57, 70, 0.18));
  transition: transform 260ms ease, filter 260ms ease;
}
.sck-group-active.sck-group-fading .sck-group-line {
  color: rgba(255, 255, 255, 0.55);
  background-image: none;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.55);
  transition: color 260ms ease;
}
.sck-group-inst.sck-group-active.sck-group-fading .sck-group-inst-marker {
  color: rgba(230, 57, 70, 0.55);
  border-color: rgba(230, 57, 70, 0.22);
  animation: none;
}

/* Section spacer (kept for > 3s silence gaps) */
.sck-spacer { height: 32px; }

/* ── Instrumental virtual groups (intro / outro / interlude, v4) ─────────
   Rendered as a centered ♪ + label marker. Compact vertical footprint so
   they don't dominate the lyric column. Still participate in the active
   state machine so playback in silent regions has a visible anchor. */
.sck-group-inst {
  padding: 14px 0;
  text-align: center;
}
.sck-group-inst-marker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.35s ease, border-color 0.35s ease, background 0.35s ease;
}
.sck-group-inst .sck-inst-icon { font-size: 16px; line-height: 1; }
.sck-group-inst.sck-group-passed .sck-group-inst-marker {
  color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.06);
  background: transparent;
}
.sck-group-inst.sck-group-active {
  transform: scale(1);
  filter: none;
}
.sck-group-inst.sck-group-active .sck-group-inst-marker {
  color: rgba(230, 57, 70, 0.95);
  border-color: rgba(230, 57, 70, 0.45);
  background: rgba(230, 57, 70, 0.06);
  animation: sckInstPulse 2.2s ease-in-out infinite;
}
@keyframes sckInstPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(230, 57, 70, 0); }
  50%      { box-shadow: 0 0 18px rgba(230, 57, 70, 0.25); }
}

.song-rhythm-panel { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.song-rhythm-panel canvas { display: block; width: 100%; height: 100%; }

/* Rhythm launch button — inside hero actions */
.song-rhythm-launch { position: relative; }
.song-rhythm-launch.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.12); }
.song-rhythm-diff-inline { display: inline-block; margin-left: 4px; padding-left: 8px; font-size: 10px; font-weight: var(--weight-semibold); color: var(--p5-muted); border-left: 1px solid var(--p5-border); letter-spacing: 0.5px; cursor: pointer; }
.song-rhythm-diff-inline:hover { color: var(--p5-red); }
.song-rhythm-launch.active .song-rhythm-diff-inline { color: #ff6b6b; border-left-color: rgba(230,57,70,0.4); }

/* RIGHT: Track history — wider with 64px covers */
.song-right-tracks { width: 300px; flex-shrink: 0; border-left: 1px solid var(--p5-border); display: flex; flex-direction: column; overflow: hidden; background: rgba(10,10,15,0.82); backdrop-filter: blur(4px); }
.song-tracks-header { padding: 10px 12px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--p5-text-secondary); text-transform: uppercase; letter-spacing: 0.6px; }
.song-tracks-filter { display: flex; }
.song-tracks-filter button { padding: 3px 8px; font-size: 10px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-muted); margin-left: -1px; cursor: pointer; font-family: inherit; text-transform: none; letter-spacing: 0; font-weight: var(--weight-semibold); }
.song-tracks-filter button:first-child { margin-left: 0; }
.song-tracks-filter button:hover { color: var(--p5-red); border-color: var(--p5-red); position: relative; z-index: 1; }
.song-tracks-filter button.active { background: var(--p5-red); color: #fff; border-color: var(--p5-red); position: relative; z-index: 1; }
.song-history { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; padding: 8px; }

/* Version group header (one per lyrics_version_id) */
.song-version-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin-top: 6px;
  border-left: 2px solid var(--p5-border);
  background: rgba(255,255,255,0.02);
  cursor: pointer; user-select: none;
  font-size: 11px;
  transition: all 0.15s;
}
.song-version-header:first-child { margin-top: 0; }
.song-version-header:hover { background: rgba(255,255,255,0.05); border-left-color: var(--p5-red); }
.song-version-header.active { border-left-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.song-version-seq { font-weight: var(--weight-bold); color: var(--p5-red); letter-spacing: 0.5px; font-size: 10px; min-width: 22px; }
.song-version-title { flex: 1; color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: var(--weight-semibold); }
.song-version-count { color: var(--p5-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.song-version-active-badge { padding: 1px 5px; background: var(--p5-red); color: #fff; font-size: 9px; font-weight: var(--weight-bold); letter-spacing: 0.5px; }
.song-version-header-orphan { border-left-color: var(--p5-muted); color: var(--p5-muted); cursor: default; }
.song-version-empty { padding: 6px 12px; color: var(--p5-muted); font-size: 10px; font-style: italic; }

.song-track-card { display: flex; gap: 10px; padding: 8px; border: 1px solid transparent; cursor: pointer; transition: all 0.15s; align-items: center; position: relative; }
.song-track-card:hover { background: rgba(255,255,255,0.03); border-color: var(--p5-border); }
.song-track-card.selected { border-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.song-track-cover { width: 64px; height: 64px; flex-shrink: 0; background: var(--p5-input-bg); overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; }
.song-track-cover img { width: 100%; height: 100%; object-fit: cover; }
.song-track-play-btn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.15s; border: none; cursor: pointer; }
.song-track-card:hover .song-track-play-btn, .song-track-card.selected .song-track-play-btn { opacity: 1; }

@keyframes songSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.song-spinner { animation: songSpin 1s linear infinite; }

/* Dedicated ASR button in right actions bar (next to download/delete) */
.song-track-asr-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 5px;
  font-size: 9px; font-weight: var(--weight-bold); letter-spacing: 0.4px;
  border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary);
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.song-track-asr-btn:hover:not([disabled]) { border-color: var(--p5-red); color: var(--p5-red); }
.song-track-asr-label { font-size: 9px; line-height: 1; }
.song-track-asr-btn-legacy      { border-color: rgba(245,197,24,0.5); color: var(--p5-yellow); }
.song-track-asr-btn-legacy:hover { border-color: var(--p5-yellow); background: rgba(245,197,24,0.12); color: var(--p5-yellow); }
.song-track-asr-btn-failed      { border-color: rgba(230,57,70,0.5); color: var(--p5-red); }
.song-track-asr-btn-failed:hover { border-color: var(--p5-red); background: rgba(230,57,70,0.12); color: var(--p5-red); }
.song-track-asr-btn-processing  { cursor: default; opacity: 0.8; color: var(--p5-text-secondary); }

/* ASR status chip (inline in track meta line) */
.song-asr-badge {
  display: inline-block; padding: 1px 5px; font-size: 9px;
  font-weight: var(--weight-semibold); letter-spacing: 0.4px;
}
.song-asr-badge-processing { background: rgba(176,176,192,0.2); color: var(--p5-text-secondary); }
.song-asr-badge-failed     { background: rgba(230,57,70,0.2); color: var(--p5-red); }
.song-track-info { flex: 1; min-width: 0; }
.song-track-title { font-size: var(--text-sm); color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: var(--weight-semibold); }
.song-track-meta { font-size: 10px; color: var(--p5-muted); margin-top: 3px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.song-track-now-badge { display: inline-block; padding: 1px 5px; background: var(--p5-red); color: #fff; font-size: 9px; font-weight: var(--weight-bold); letter-spacing: 0.5px; }
.song-track-best-badge { display: inline-flex; align-items: center; gap: 2px; padding: 1px 5px; background: rgba(255,215,0,0.12); color: #ffd700; font-size: 9px; font-weight: var(--weight-bold); letter-spacing: 0.5px; }
.song-track-actions { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.song-track-action-btn { background: transparent; border: none; color: var(--p5-muted); cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; transition: color 0.15s; opacity: 0; }
.song-track-card:hover .song-track-action-btn, .song-track-card.selected .song-track-action-btn { opacity: 1; }
.song-track-action-btn:hover { color: var(--p5-red); }
.song-track-delete-btn:hover { color: var(--p5-red); }

/* Hero MV button — red outline, always visible, prominent */
.song-btn-mv { font-weight: var(--weight-bold); letter-spacing: 0.5px; }
.song-btn-mv:hover { background: var(--p5-red); color: #fff; border-color: var(--p5-red); }

/* =======================================================
   SONG WORKSPACE v4 — 2026-04-22
   sec-head + fields on left, cover + audio-ctl in center, history panel on right.
   Aligned with mv-creation.html visual reference.
   ======================================================= */
.song-ws-layout {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── LEFT column ─── */
.song-ws-left {
  background: var(--p5-dark);
  border-right: 1px solid var(--p5-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.song-ws-sec-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--p5-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}
.song-ws-sec-lbl {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: var(--p5-text);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.song-ws-sec-ji {
  font-size: 10.5px;
  color: var(--p5-red);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.song-ws-sec-chip {
  font-family: var(--font-display);
  font-size: 9.5px;
  padding: 2px 7px;
  background: var(--p5-red);
  color: #000;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.song-ws-inputs {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.song-ws-inputs::-webkit-scrollbar { width: 4px; }
.song-ws-inputs::-webkit-scrollbar-thumb { background: var(--p5-border); }

.song-ws-field { display: flex; flex-direction: column; gap: 5px; }
.song-ws-field-inline {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
}
.song-ws-field-inline .song-ws-field-k { padding-top: 0; }
.song-ws-field-k {
  font-family: var(--font-display);
  font-size: 9.5px;
  color: var(--p5-red);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}
.song-ws-field-v {
  padding: 0;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  min-height: 34px;
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s;
}
.song-ws-field-v:hover { border-color: var(--p5-red); }
.song-ws-field-v::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--p5-muted);
  border-bottom: 1.5px solid var(--p5-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.song-ws-select {
  width: 100%;
  padding: 8px 28px 8px 10px;
  background: transparent;
  border: none;
  color: var(--p5-text);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.song-ws-select option { background: var(--p5-card); color: var(--p5-text); }

.song-ws-field-rich {
  padding: 10px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  gap: 6px;
}
.song-ws-field-rich:focus-within { border-color: var(--p5-red); }
.song-ws-field-rich .song-ws-field-k { padding-bottom: 2px; }
.song-ws-textarea {
  width: 100%;
  min-height: 90px;
  background: transparent;
  border: none;
  color: var(--p5-text);
  font-size: 13px;
  line-height: 1.55;
  font-family: inherit;
  resize: none;
  outline: none;
  padding: 0;
}
.song-ws-textarea::placeholder { color: var(--p5-muted); opacity: 0.7; }
.song-ws-field-ftr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: 9.5px;
  color: var(--p5-muted);
  letter-spacing: 0.06em;
  margin-top: 4px;
  text-transform: uppercase;
}

/* Left CTA buttons */
.song-ws-btn-secondary {
  padding: 10px 14px;
  background: var(--p5-input-bg);
  color: var(--p5-text);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--p5-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-weight: 600;
}
.song-ws-btn-secondary:hover { border-color: var(--p5-red); color: var(--p5-red); }
.song-ws-btn-secondary svg { width: 11px; height: 11px; }

.song-ws-ctl {
  padding: 14px 16px;
  border-top: 1px solid var(--p5-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--p5-dark);
}
.song-ws-btn-primary {
  padding: 13px 16px;
  background: var(--p5-red);
  color: #000;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.song-ws-btn-primary:hover { background: #c02836; color: #fff; }
.song-ws-btn-primary svg { width: 12px; height: 12px; }
.song-ws-cost-note {
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--p5-muted);
  text-align: center;
  text-transform: uppercase;
}
.song-ws-cost-note .song-cta-cost { color: var(--p5-red); font-weight: 700; }
.song-ws-cost-sep { margin: 0 4px; color: var(--p5-border); }

/* ─── CENTER column ─── */
.song-ws-center {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--p5-black);
}
.song-ws-cover {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  /* Default fallback gradient when no wallpaper — v4 "dust" red-gold. Preset class overrides. */
  background: linear-gradient(135deg, #1a0a10 0%, #4e1a28 40%, #c02836 75%, #f5b53d 100%);
}
/* v4 preset gradients — one assigned deterministically per project (project.id % 10).
   Shows through whenever wallpaper is hidden (no URL or cover-bg.active not set). */
.song-ws-cover.song-g-dust,    .gmc-cover.song-g-dust    { background: linear-gradient(135deg,#1a0a10 0%,#4e1a28 40%,#c02836 75%,#f5b53d 100%); }
.song-ws-cover.song-g-oasis,   .gmc-cover.song-g-oasis   { background: linear-gradient(135deg,#0f1e18,#1f4038 50%,#4a8072); }
.song-ws-cover.song-g-moon,    .gmc-cover.song-g-moon    { background: linear-gradient(135deg,#0a1220,#1e2e48 50%,#5a7aa6); }
.song-ws-cover.song-g-camp,    .gmc-cover.song-g-camp    { background: linear-gradient(180deg,#2a1a14,#6a2e1a 55%,#c84e20); }
.song-ws-cover.song-g-desert,  .gmc-cover.song-g-desert  { background: linear-gradient(180deg,#1c0e0a,#4a2418 55%,#d88040 100%); }
.song-ws-cover.song-g-night,   .gmc-cover.song-g-night   { background: linear-gradient(135deg,#050812,#141e36 50%,#3a4260); }
.song-ws-cover.song-g-jade,    .gmc-cover.song-g-jade    { background: linear-gradient(135deg,#0a1a18,#1e3e36 55%,#5ab8a0); }
.song-ws-cover.song-g-dawn,    .gmc-cover.song-g-dawn    { background: linear-gradient(180deg,#1a1028 0%,#4a2844 40%,#c8506a 75%,#f8b85a 100%); }
.song-ws-cover.song-g-amber,   .gmc-cover.song-g-amber   { background: linear-gradient(135deg,#1e1408,#5a3a18 55%,#e09a48); }
.song-ws-cover.song-g-glacier, .gmc-cover.song-g-glacier { background: linear-gradient(135deg,#0c1420,#203048 50%,#8aa0b4); }
.song-ws-cover-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.6s;
  z-index: 0;
}
.song-ws-cover-bg.active { opacity: 1; }
/* Readability mask — stronger base dim + vertical gradient (darker top/bottom) so lyrics legible on any wallpaper. */
.song-ws-cover-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.45) 25%, rgba(0,0,0,0.45) 75%, rgba(0,0,0,0.7) 100%),
    radial-gradient(ellipse at center, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.4) 100%);
}
/* Fallback tint when no wallpaper loaded (cover-bg hidden via opacity:0) — keeps solid black readable. */
/* Soft readability tint over gradient — darker at top/bottom (where actions/audio-ctl sit), lighter in middle (preserve gradient color). */
.song-ws-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.15) 30%, rgba(0,0,0,0.15) 70%, rgba(0,0,0,0.55) 100%);
  z-index: 1;
  pointer-events: none;
}

/* Cover meta (top-left) */
.song-ws-cover-meta {
  position: absolute;
  top: 18px;
  left: 22px;
  z-index: 3;
  max-width: calc(100% - 260px);
}
.song-ws-cover-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  margin: 0;
  line-height: 1.1;
}
.song-ws-cover-title:empty::before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,0.3);
}
.song-ws-cover-tags {
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase;
  margin-top: 6px;
}

/* Cover actions (top-right) */
.song-ws-cover-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.15);
  z-index: 3;
  background: rgba(6,6,9,0.88);
  backdrop-filter: blur(8px);
}
.song-ws-cover-act {
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(255,255,255,0.15);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  font-weight: 500;
}
.song-ws-cover-act:last-child { border-right: none; }
.song-ws-cover-act:hover { color: #fff; background: rgba(255,255,255,0.05); }
.song-ws-cover-act svg { width: 11px; height: 11px; }
.song-ws-cover-act-primary {
  background: var(--p5-red);
  color: #000;
  font-weight: 800;
  padding: 9px 14px;
}
.song-ws-cover-act-primary:hover { background: #c02836; color: #fff; }

/* Cover lyrics (center) — constrained to middle band so it doesn't overlap top actions or bottom audio ctl.
   Note: flex + justify-content:center + overflow:auto has a browser bug where top items clip when content overflows.
   Use block layout + asymmetric padding (small top, big bottom) so karaoke scroll can position active line near 15% from top. */
.song-ws-cover-lyrics {
  position: absolute;
  top: 80px;
  bottom: 16px;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 90px 48px 180px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  text-align: center;
}
.song-ws-cover-lyrics::-webkit-scrollbar { display: none; }
.song-ws-cover-lyrics .song-lyrics-empty {
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}
/* Lyrics line styling aligned with v4 reference — stronger text-shadow for wallpaper legibility. */
.song-ws-cover-lyrics .song-lyrics-line {
  font-family: 'Zen Kaku Gothic New', 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.1em;
  line-height: 2.2;
  text-align: center;
  transition: all 0.3s;
  padding: 4px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7), 0 0 2px rgba(0,0,0,0.9);
}
.song-ws-cover-lyrics .song-lyrics-line.active {
  color: #fff;
  font-size: 28px;
  text-shadow: 0 0 24px rgba(230,57,70,0.6);
  letter-spacing: 0.16em;
  font-weight: 700;
}
.song-ws-cover-lyrics .song-lyrics-line.prev,
.song-ws-cover-lyrics .song-lyrics-line.next { color: rgba(255,255,255,0.7); }
.song-ws-cover-lyrics .song-lyrics-line.active { text-shadow: 0 0 24px rgba(230,57,70,0.7), 0 2px 10px rgba(0,0,0,0.85); }

/* Rhythm panel overlay — sits on top of lyrics when active */
.song-ws-cover .song-rhythm-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(0,0,0,0.4);
}

/* ─── Bottom audio control ─── */
.song-ws-audio-ctl {
  flex-shrink: 0;
  height: 64px;
  background: #060609;
  border-top: 1px solid var(--p5-border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  z-index: 3;
  position: relative;
}
.song-ws-audio-play {
  width: 38px;
  height: 38px;
  background: var(--p5-red);
  color: #000;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: background 0.15s;
}
.song-ws-audio-play:hover { background: #c02836; }
.song-ws-audio-play img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.4; }
.song-ws-audio-play-overlay { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.song-ws-audio-play-overlay svg { width: 14px; height: 14px; }
.song-ws-audio-time {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--p5-text-secondary);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.song-ws-audio-track {
  flex: 1;
  height: 6px;
  background: var(--p5-border);
  position: relative;
  cursor: pointer;
  min-width: 0;
}
.song-ws-audio-track-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: var(--p5-red);
  pointer-events: none;
}
.song-ws-audio-track-handle {
  position: absolute;
  left: 0; top: -4px;
  width: 2px;
  height: 14px;
  background: #fff;
  transform: translateX(-50%);
  pointer-events: none;
}
.song-ws-audio-mini {
  height: 24px;
  width: 100px;
  flex-shrink: 0;
}

/* ─── RIGHT column: history ─── */
.song-ws-right {
  background: var(--p5-dark);
  border-left: 1px solid var(--p5-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.song-ws-history-panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.song-ws-history-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--p5-border);
}
.song-ws-history-tabs button {
  flex: 1;
  padding: 6px 0;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--p5-muted);
  text-transform: uppercase;
  border: 0;
  border-right: 1px solid var(--p5-border);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-weight: 600;
}
.song-ws-history-tabs button:last-child { border-right: none; }
.song-ws-history-tabs button:hover { color: var(--p5-text); }
.song-ws-history-tabs button.active { background: var(--p5-red); color: #000; font-weight: 800; }
.song-ws-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.song-ws-history-list::-webkit-scrollbar { width: 4px; }
.song-ws-history-list::-webkit-scrollbar-thumb { background: var(--p5-border); }

/* ================================================================
   ASSET STUDIO
   ================================================================ */
.as-layout { display: flex; height: 100%; }
.as-sidebar { width: 260px; border-right: 1px solid var(--p5-border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.as-sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--p5-border); }
.as-sidebar-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--p5-text); margin: 0; }
.as-collection-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.as-collection-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; cursor: pointer; border-left: 3px solid transparent; color: var(--p5-text-secondary); font-size: 13px; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.as-collection-item:hover { background: var(--p5-surface-hover); }
.as-collection-item.active { border-left-color: var(--p5-red); color: var(--p5-text); background: rgba(230,57,70,0.06); }
.as-collection-item .as-coll-count { font-size: 11px; color: var(--p5-muted); }
.as-collection-item .as-coll-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-inline-rename { background: var(--p5-surface); border: 1px solid var(--p5-red); color: var(--p5-text); font-size: 13px; padding: 4px 6px; width: 120px; outline: none; }
#asset-studio-view .dt-btn-icon { background: none; border: none; color: var(--p5-muted); padding: 2px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: color 0.15s; }
#asset-studio-view .dt-btn-icon:hover { color: var(--p5-text); }
.as-collection-item .as-coll-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.as-collection-item:hover .as-coll-actions { opacity: 1; }
.as-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.as-main-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--p5-border); gap: 12px; flex-shrink: 0; }
.as-type-tabs { display: flex; gap: 0; overflow-x: auto; }
.as-type-tab { padding: 8px 14px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--p5-muted); font-size: 13px; cursor: pointer; white-space: nowrap; transition: color 0.15s, border-color 0.15s; }
.as-type-tab:hover { color: var(--p5-text-secondary); }
.as-type-tab.active { border-bottom-color: var(--p5-red); color: var(--p5-red); font-weight: 500; }
.as-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding: 20px 24px; overflow-y: auto; flex: 1; align-content: start; }
.as-type-badge { display: inline-block; padding: 2px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; background: rgba(230,57,70,0.12); color: var(--p5-red); }
/* Modal overlay shared */
.as-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; }
.as-modal { background: var(--p5-surface); border: 1px solid var(--p5-border); width: 380px; max-height: 80vh; display: flex; flex-direction: column; }
.as-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 10px; flex-shrink: 0; border-bottom: 1px solid var(--p5-border); }
.as-modal-head h3 { margin: 0; font-size: var(--text-sm); color: var(--p5-text); }
.as-modal-close { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; transition: all .15s; }
.as-modal-close:hover { border-color: var(--p5-red); color: var(--p5-red); }
.as-modal-body { padding: 14px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.as-modal .as-field { margin-bottom: 10px; }
.as-modal .as-field label { display: block; font-size: 11px; color: var(--p5-text-secondary); margin-bottom: 3px; }
.as-modal .as-field input, .as-modal .as-field select, .as-modal .as-field textarea { width: 100%; padding: 6px 8px; background: var(--p5-bg); border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 12px; font-family: inherit; }
.as-modal .as-field textarea { resize: vertical; min-height: 48px; }
.as-modal-btns { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px; flex-shrink: 0; border-top: 1px solid var(--p5-border); }
.as-modal-btns button { padding: 6px 14px; font-size: 12px; cursor: pointer; border: 1px solid var(--p5-border); background: var(--p5-surface); color: var(--p5-text); }
.as-modal-btns .as-btn-primary { background: var(--p5-red); color: #fff; border-color: var(--p5-red); }
.as-modal-btns button:disabled { opacity: 0.5; cursor: not-allowed; }
.as-modal-btns .as-btn-primary:disabled:hover { background: var(--p5-red); }
.as-modal-btns .as-btn-back { margin-right: auto; }
/* Create modal: 2-step wizard */
.as-modal--create { width: 420px; }
.as-type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 0; }
.as-type-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 14px; background: var(--p5-bg); border: 1px solid var(--p5-border); cursor: pointer; transition: border-color 0.15s, background 0.15s; text-align: center; }
.as-type-card:hover { border-color: var(--p5-red); background: rgba(230,57,70,0.04); }
.as-type-card svg { width: 36px; height: 36px; color: var(--p5-muted); transition: color 0.15s; }
.as-type-card:hover svg { color: var(--p5-red); }
.as-type-card-title { font-size: 13px; font-weight: 600; color: var(--p5-text); }
.as-type-card-desc { font-size: 11px; color: var(--p5-muted); line-height: 1.4; }
.as-step-entering { animation: asStepFade 0.2s ease; }
@keyframes asStepFade { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
.as-step-back { animation: asStepBack 0.2s ease; }
@keyframes asStepBack { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
.as-advanced-section { margin-top: 14px; border-top: 1px solid var(--p5-border); }
.as-advanced-toggle { display: flex; align-items: center; gap: 6px; padding: 10px 0; font-size: 12px; color: var(--p5-muted); cursor: pointer; user-select: none; background: none; border: none; width: 100%; transition: color 0.15s; }
.as-advanced-toggle:hover { color: var(--p5-text); }
.as-advanced-toggle svg { transition: transform 0.2s; }
.as-advanced-section.collapsed .as-advanced-toggle svg { transform: rotate(-90deg); }
.as-advanced-section.collapsed .as-advanced-body { display: none; }
/* Asset studio 卡片整体 overflow:hidden,避免 shimmer 占位 + ✓ 徽章在重新生成期间溢出卡片边界。
   Comic Studio 的 .comic-char-card 是 overflow:visible(需要 dropdown 溢出),这里 scope 仅覆盖 Asset Studio */
#asset-studio-view .comic-char-card { overflow: hidden; }
/* Prompt 查看按钮(P):紧凑方形,不参与 .comic-char-actions button 的 flex:1 平分,
   次要样式(透明底 + 灰边),hover 变红对齐全站红色主题。仅在 mj_prompt / decompose_prompt 非空时渲染 */
#asset-studio-view .comic-char-actions .as-prompt-p-btn {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  transition: all 0.15s;
}
#asset-studio-view .comic-char-actions .as-prompt-p-btn:hover {
  border-color: var(--p5-red);
  color: var(--p5-red);
  background: rgba(230,57,70,0.06);
  opacity: 1;
}
/* Portrait 主立绘说明行:提示用户"选中图片 = 设主立绘",并告诉用户主立绘用于拆解 / 衍生。
   pending(未选):红色左边栏强调,引导选图;is-set(已选):灰色低存在感,表达"已完成" */
#asset-studio-view .as-portrait-hint {
  font-size: 11px;
  padding: 6px 10px;
  margin: 4px 0 6px;
  line-height: 1.45;
}
#asset-studio-view .as-portrait-hint.pending {
  color: var(--p5-red);
  background: rgba(230,57,70,0.06);
  border-left: 2px solid var(--p5-red);
}
#asset-studio-view .as-portrait-hint.is-set {
  color: var(--p5-muted);
  background: rgba(0,0,0,0.03);
  border-left: 2px solid var(--p5-border);
}
[data-theme="dark"] #asset-studio-view .as-portrait-hint.is-set {
  background: rgba(255,255,255,0.03);
}
/* Asset studio images: shimmer skeleton + fade-in。wrap 显式 aspect-ratio 让占位尺寸由 wrap 自己确定,
   不再依赖 img opacity:0 撑开(重新生成时 img 还没 loaded,占位形状才稳定) */
#asset-studio-view .comic-mj-img-wrap { position: relative; aspect-ratio: 3/4; background: linear-gradient(90deg, var(--p5-dark) 25%, var(--p5-border) 37%, var(--p5-dark) 63%); background-size: 800px 100%; animation: skeleton-shimmer 1.6s ease-in-out infinite; }
#asset-studio-view .comic-mj-img-wrap:has(img.loaded) { animation: none; background: var(--p5-dark); }
#asset-studio-view .comic-mj-img-wrap img { opacity: 0; transition: opacity 0.4s ease; }
#asset-studio-view .comic-mj-img-wrap img.loaded { opacity: 1; }
#asset-studio-view .char-header { display: flex; align-items: center; gap: 8px; }
/* Derive buttons on character card */
.as-derive-btns { display: flex; gap: 4px; padding: 6px 14px 0; flex-wrap: wrap; }
.as-derive-btn { padding: 3px 10px; font-size: 11px; background: rgba(230,57,70,0.08); color: var(--p5-red); border: 1px solid rgba(230,57,70,0.2); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.as-derive-btn:hover { background: rgba(230,57,70,0.18); border-color: var(--p5-red); }

@media (max-width: 768px) {
  .as-sidebar { display: none; }
  .as-cards-grid { grid-template-columns: 1fr; padding: 12px; }
  .as-main-header { flex-wrap: wrap; padding: 8px 12px; }
  .as-type-cards { grid-template-columns: 1fr; }
  .as-modal--create { width: 95vw; }
}

/* ── Asset Topology (fullscreen modal) ───────────────────── */
.as-topo-overlay { position: fixed; inset: 0; z-index: 9999; background: #0a0a0f; display: flex; }
.as-topo-container { display: flex; flex-direction: column; width: 100%; height: 100vh; }
.as-topo-header { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.as-topo-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--p5-text); }
.as-topo-view-toggle { display: flex; gap: 4px; margin-left: auto; }
.as-topo-view-btn { display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 12px; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; transition: all 0.15s; }
.as-topo-view-btn.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.06); }
.as-topo-close { background: none; border: none; color: var(--p5-muted); cursor: pointer; padding: 6px; transition: color 0.15s; }
.as-topo-close:hover { color: var(--p5-red); }
.as-topo-body { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }

/* Tree view */
.as-topo-tree { position: relative; padding: 32px 24px 100px; min-height: 400px; }
.as-topo-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.as-topo-level { display: flex; justify-content: center; gap: 24px; margin-bottom: 32px; position: relative; z-index: 1; flex-wrap: wrap; }
.as-topo-node { width: 140px; background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 8px; text-align: center; transition: border-color 0.15s; cursor: default; position: relative; }
.as-topo-node:hover { border-color: var(--p5-text-secondary); }
.as-topo-node img { width: 100%; aspect-ratio: 3/4; object-fit: cover; cursor: pointer; opacity: 0; transition: opacity 0.3s; }
.as-topo-node img.loaded { opacity: 1; }
.as-topo-root { border-color: var(--p5-red); }
.as-topo-node-label { font-size: var(--text-sm); color: var(--p5-text); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-topo-node-badge { font-size: var(--text-xs); color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.as-topo-node-empty { width: 100%; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--p5-muted); background: var(--p5-dark); border: 1px dashed var(--p5-border); }
.as-topo-node-progress { width: 100%; aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--p5-dark); position: relative; overflow: hidden; }
.as-topo-progress-fill { height: 3px; background: var(--p5-red); transition: width 0.3s; width: 0; }
.as-topo-node-progress > span { font-size: 11px; color: var(--p5-muted); }
.as-topo-node-timer { font-size: 10px; color: var(--p5-text-secondary); font-variant-numeric: tabular-nums; }
.as-topo-shimmer::after { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent 0%, rgba(230,57,70,0.06) 50%, transparent 100%); animation: as-topo-shimmer 2s infinite; pointer-events: none; }
@keyframes as-topo-shimmer { 0% { left: -100%; } 100% { left: 100%; } }
.as-topo-deriv-node.generating { border-color: var(--p5-red); box-shadow: 0 0 0 1px rgba(230,57,70,0.2); }
.as-topo-deriv-node.failed { border-color: rgba(230,57,70,0.4); }
.as-topo-node-failed { width: 100%; aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--p5-dark); }
.as-topo-node-failed span { font-size: 11px; color: var(--p5-red); }
.as-topo-img-select { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 100%; }
.as-topo-img-option { position: relative; cursor: pointer; overflow: hidden; }
.as-topo-img-option img { width: 100%; aspect-ratio: 1; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.as-topo-img-option img.loaded { opacity: 1; }
.as-topo-img-option:hover { outline: 2px solid var(--p5-red); outline-offset: -2px; }
.as-topo-img-select-btn { position: absolute; bottom: 2px; right: 2px; width: 20px; height: 20px; background: rgba(230,57,70,0.85); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.as-topo-img-option:hover .as-topo-img-select-btn { opacity: 1; }
.as-topo-cost { font-size: 11px; color: var(--p5-muted); white-space: nowrap; padding: 0 6px; }
.as-topo-prompt-overlay { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.as-topo-prompt-box { background: var(--p5-surface); border: 1px solid var(--p5-border); width: 90%; max-width: 640px; max-height: 70vh; display: flex; flex-direction: column; }
.as-topo-prompt-box-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--p5-border); font-size: 14px; font-weight: 600; color: var(--p5-text); flex-shrink: 0; }
.as-topo-prompt-text { flex: 1; overflow-y: auto; padding: 16px; margin: 0; font-size: 12px; line-height: 1.6; color: var(--p5-text-secondary); white-space: pre-wrap; word-break: break-word; background: var(--p5-dark); }
.as-topo-prompt-box .dt-btn { margin: 12px 16px; align-self: flex-start; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.as-topo-node-actions { display: flex; gap: 3px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.as-topo-node-actions .as-derive-btn { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; font-size: 10px; }
/* Node image wrapper with hover zoom + delete */
.as-topo-node-img { position: relative; overflow: hidden; }
.as-topo-node-img img { width: 100%; aspect-ratio: 3/4; object-fit: cover; cursor: pointer; opacity: 0; transition: opacity 0.3s; }
.as-topo-node-img img.loaded { opacity: 1; }
.as-topo-node-zoom, .as-topo-node-del { position: absolute; background: rgba(0,0,0,0.55); border: none; padding: 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; }
.as-topo-node-img:hover .as-topo-node-zoom, .as-topo-node-img:hover .as-topo-node-del { opacity: 1; }
.as-topo-node-zoom { top: 4px; right: 4px; }
.as-topo-node-del { top: 4px; left: 4px; }

/* Type selector row */
.as-topo-type-row { gap: 8px; }
.as-topo-type-btn { display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 12px; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; transition: all 0.15s; }
.as-topo-type-btn.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.06); }
.as-topo-type-btn:hover { border-color: var(--p5-text-secondary); color: var(--p5-text-secondary); }
.as-topo-empty { text-align: center; color: var(--p5-muted); font-size: 13px; padding: 40px 0; }
.as-topo-derivs-level { flex-wrap: wrap; }

/* Gallery view */
.as-topo-gallery-header { padding: 12px 24px 0; }
.as-topo-gallery-tabs { display: flex; gap: 0; flex-wrap: wrap; }
.as-topo-gtab { padding: 8px 16px; font-size: var(--text-base); background: none; border: none; border-bottom: 2px solid transparent; color: var(--p5-muted); cursor: pointer; transition: all 0.15s; }
.as-topo-gtab.active { border-bottom-color: var(--p5-red); color: var(--p5-red); }
.as-topo-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding: 16px 24px; }
.as-topo-gallery-item { position: relative; background: var(--p5-surface); border: 2px solid transparent; cursor: pointer; transition: border-color 0.15s; overflow: hidden; }
.as-topo-gallery-item:hover { border-color: var(--p5-border); }
.as-topo-gallery-item.checked { border-color: var(--p5-red); }
.as-topo-gallery-item.wide { grid-column: span 2; }
.as-topo-gallery-item img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.as-topo-gallery-item img.loaded { opacity: 1; }
.as-topo-gallery-check { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.as-topo-gallery-item.checked .as-topo-gallery-check { background: var(--p5-red); border-color: var(--p5-red); }
.as-topo-gallery-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 10px; font-size: var(--text-sm); color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-topo-gallery-zoom { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,0.5); border: none; padding: 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; }
.as-topo-gallery-del { position: absolute; bottom: 24px; right: 6px; background: rgba(0,0,0,0.5); border: none; padding: 4px; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; }
.as-topo-gallery-item:hover .as-topo-gallery-zoom, .as-topo-gallery-item:hover .as-topo-gallery-del { opacity: 1; }

/* Bottom input area */
.as-topo-input-area { flex-shrink: 0; border-top: 1px solid var(--p5-border); padding: 12px 24px; background: var(--p5-dark); }
.as-topo-refs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 8px; }
.as-topo-refs:empty { margin-bottom: 0; }
.as-topo-ref-thumb { position: relative; width: 48px; height: 48px; flex-shrink: 0; }
.as-topo-ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.as-topo-ref-remove { position: absolute; top: -4px; right: -4px; width: 18px; height: 18px; background: var(--p5-red); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.as-topo-input-row { display: flex; gap: 10px; align-items: center; }
.as-topo-derive-select { padding: 6px 10px; font-size: 13px; font-family: inherit; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text-secondary); cursor: pointer; }
.as-topo-prompt-input { flex: 1; padding: 7px 12px; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 13px; font-family: inherit; transition: border-color 0.15s; }
.as-topo-prompt-input:focus { border-color: var(--p5-red); outline: none; }
.as-topo-gen-btn { white-space: nowrap; padding: 7px 18px; font-size: 13px; font-weight: 600; background: var(--p5-red-gradient); border: none; color: #fff; cursor: pointer; transition: opacity 0.2s; }
.as-topo-gen-btn:hover { opacity: 0.88; }

@media (max-width: 768px) {
  .as-topo-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); padding: 12px; }
  .as-topo-input-row { flex-wrap: wrap; }
  .as-topo-prompt-input { min-width: 0; }
  .as-topo-node { width: 100px; }
}

/* ================================================================
   COMIC STUDIO
   ================================================================ */

/* Layout */
#comic-view { height: 100%; overflow: hidden; position: relative; }
.comic-panel { height: 100%; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#comic-view.dag-visible .comic-panel { padding-bottom: 50px; }
/* Comic V4 (2026-04-23): when stepper is active, view becomes flex column so stepper + panels stack */
#comic-view.dt-view.active { display: flex; flex-direction: column; }
#comic-view .comic-panel { flex: 1; min-height: 0; height: auto; }
/* Ref cards float above composer → needs relative parent */
#comic-chat .md-composer-inner { position: relative; }
/* Welcome book in script-scroll center (min-height so flex centering kicks in when scroll is shorter than content) */
#comic-chat .md-script-scroll > .comic-welcome-guide { min-height: 100%; }
#manga-drama-view { height: 100%; overflow: hidden; position: relative; }
.md-panel { height: 100%; display: none; flex-direction: column; min-height: 0; overflow: hidden; }
.md-panel.active { display: flex; }
#manga-drama-view.dag-visible .md-panel { padding-bottom: 50px; }

/* ── v2: Structured Act Cards ── */
.md-structured-act { padding: 0 !important; }
.md-act-heading { font-size: 18px; font-weight: var(--weight-bold); color: var(--p5-text); margin: 0 0 16px; padding: 12px 16px; border-bottom: 1px solid var(--p5-border); }

/* Role badges bar */
.md-role-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px 12px; border-bottom: 1px solid var(--p5-border); }
.md-role-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; font-size: var(--text-xs); border: 1px solid var(--p5-border); color: var(--p5-text-secondary); cursor: default; }
.md-role-badge small { opacity: 0.6; font-size: 10px; }
.md-role-protagonist { border-color: var(--p5-red); color: var(--p5-red); }
.md-role-antagonist { border-color: #9b59b6; color: #9b59b6; }
.md-role-supporting { border-color: var(--p5-muted); }

/* Main scene block */
.md-main-scene { margin: 12px 0; }
.md-ms-header { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(230,57,70,0.06); border-left: 3px solid var(--p5-red); }
.md-ms-id { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--p5-red); font-family: var(--font-mono); }
.md-ms-desc { flex: 1; font-size: var(--text-sm); color: var(--p5-text); }
.md-ms-tone { font-size: var(--text-xs); color: var(--p5-muted); padding: 2px 8px; border: 1px solid var(--p5-border); }

/* Sub-scene card */
.md-sub-scene { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--p5-border); }
.md-sub-scene:last-child { border-bottom: none; }
.md-ss-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.md-ss-id { font-size: 11px; font-weight: var(--weight-bold); color: var(--p5-muted); font-family: var(--font-mono); }
.md-ss-location { font-size: var(--text-sm); color: var(--p5-text); font-weight: var(--weight-semibold); }
.md-ss-scene-badge { font-size: 10px; padding: 1px 6px; font-family: var(--font-mono); }
.md-ss-scene-badge.new { background: var(--p5-red); color: #fff; }
.md-ss-scene-badge.reuse { background: var(--p5-surface-1); color: var(--p5-muted); border: 1px solid var(--p5-border); }
.md-ss-camera { font-size: 11px; color: var(--p5-muted); }

/* Narrative bridge */
.md-ss-bridge { font-size: var(--text-xs); color: var(--p5-muted); font-style: italic; margin-bottom: 6px; padding-left: 12px; border-left: 2px solid var(--p5-border); }

/* Story text (collapsible) */
.md-ss-story { font-size: var(--text-sm); line-height: 1.7; color: var(--p5-text-secondary); margin-bottom: 8px; }
.md-ss-story.collapsible { cursor: pointer; position: relative; }
.md-ss-story.collapsible.collapsed .md-ss-story-full { display: none; }
.md-ss-story.collapsible:not(.collapsed) .md-ss-story-preview { display: none; }
.md-ss-story.collapsible:not(.collapsed) .md-ss-expand { display: none; }
.md-ss-expand { display: block; font-size: 11px; color: var(--p5-red); margin-top: 4px; }

/* Voice lines */
.md-voice-lines { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.md-vl { display: flex; align-items: flex-start; gap: 6px; font-size: var(--text-sm); padding: 4px 8px; }
.md-vl-type { flex-shrink: 0; width: 32px; font-size: 10px; font-weight: var(--weight-bold); text-align: center; padding: 1px 0; font-family: var(--font-mono); }
.md-vl-dlg .md-vl-type { color: #3498db; background: rgba(52,152,219,0.1); }
.md-vl-mnl .md-vl-type { color: #9b59b6; background: rgba(155,89,182,0.1); }
.md-vl-nar .md-vl-type { color: #95a5a6; background: rgba(149,165,166,0.1); }
.md-vl-char { flex-shrink: 0; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--p5-text-secondary); min-width: 40px; }
.md-vl-content { flex: 1; color: var(--p5-text); }
.md-vl-mnl .md-vl-content { font-style: italic; color: #9b59b6; }
.md-vl-nar .md-vl-content { color: var(--p5-muted); }

/* Involved characters chips */
.md-ss-chars { display: flex; flex-wrap: wrap; gap: 4px; }
.md-char-chip { font-size: 10px; padding: 1px 6px; background: var(--p5-surface-1); color: var(--p5-muted); border: 1px solid var(--p5-border); }

/* Sidebar sub-scene count */
.md-sidebar-count { font-size: 10px; color: var(--p5-muted); opacity: 0.7; margin-left: 4px; }

/* Generating indicator */
.md-generating-indicator { color: var(--p5-red-light); font-size: var(--text-sm); animation: md-pulse 1.5s ease-in-out infinite; }
@keyframes md-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.md-gen-chars { color: var(--p5-red); font-weight: var(--weight-bold); font-family: var(--font-mono); }

/* Light theme overrides */
[data-theme="light"] .md-ms-header { background: rgba(230,57,70,0.04); }
[data-theme="light"] .md-vl-dlg .md-vl-type { background: rgba(52,152,219,0.08); }
[data-theme="light"] .md-vl-mnl .md-vl-type { background: rgba(155,89,182,0.08); }
[data-theme="light"] .md-vl-nar .md-vl-type { background: rgba(149,165,166,0.08); }

/* ── Manga Drama v2: Asset review, character, scene, storyboard panels ── */
.md-asset-review { padding: 20px 32px; height: 100%; overflow-y: auto; }

/* ── Manga Drama: Planning Mode Selector ── */
.md-mode-selector { display: flex; gap: 4px; }
.md-mode-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 6px; font-size: 11px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.md-mode-btn:hover { border-color: var(--p5-text); color: var(--p5-text); }
.md-mode-btn.active { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.06); }
.md-mode-btn svg { stroke: currentColor; }
.md-sb-acts-col .md-mode-selector { padding: 10px 10px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.md-sb-acts-col .md-mode-btn { flex: 1; min-width: 0; flex-direction: column; gap: 3px; padding: 6px 4px; }
.md-sb-acts-col .md-mode-btn span { white-space: nowrap; font-size: 11px; }

/* ── Manga Drama Storyboard V2: 3-column layout (2:3:5) ── */
.md-sb-body { display: grid; grid-template-columns: 18% 28% 54%; height: 100%; overflow: hidden; }
.md-sb-acts-col { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--p5-border); min-height: 0; }
.md-sb-acts { overflow-y: auto; padding: 12px; flex: 1; min-height: 0; }
.md-sb-pages { overflow-y: auto; padding: 12px; border-right: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.md-sb-detail { overflow-y: auto; padding: 16px 24px; }

/* Act list — left column */
.md-sb-act-card { padding: 10px 12px; border: 1px solid var(--p5-border); margin-bottom: 6px; cursor: pointer; background: var(--p5-card); transition: border-color 0.2s; }
.md-sb-act-card:hover { border-color: var(--p5-text-secondary); }
.md-sb-act-card.active { border-left: 3px solid var(--p5-red); background: rgba(230,57,70,0.04); }
.md-sb-act-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--p5-text); }
.md-sb-act-summary { font-size: 11px; color: var(--p5-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; line-height: 1.4; }
.md-sb-act-status { font-size: 10px; color: var(--p5-text-secondary); display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.md-sb-act-status .status-dot { width: 6px; height: 6px; display: inline-block; }
.md-sb-act-status .status-dot.empty { background: var(--p5-muted); }
.md-sb-act-status .status-dot.partial { background: #f59e0b; }
.md-sb-act-status .status-dot.done { background: #10b981; }
.md-sb-act-gen-btn { width: 100%; padding: 4px 0; font-size: 11px; border: 1px solid var(--p5-red); background: transparent; color: var(--p5-red); cursor: pointer; margin-top: 4px; transition: all 0.2s; }
.md-sb-act-gen-btn:hover { background: var(--p5-red); color: #fff; }
.md-sb-act-gen-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Page cards — middle column (vertical layout) */
.md-sb-page-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.md-sb-page-card { display: flex; flex-direction: column; border: 1px solid var(--p5-border); cursor: pointer; background: var(--p5-card); transition: all 0.2s; flex-shrink: 0; width: 100%; }
.md-sb-page-card:hover { border-color: var(--p5-text-secondary); }
.md-sb-page-card.active { border-color: var(--p5-red); background: rgba(230,57,70,0.04); }
/* Card layer 1: title + description */
.md-sb-page-card .page-card-title { font-size: 13px; font-weight: 600; color: var(--p5-text); padding: 10px 12px; border-bottom: 1px solid var(--p5-border); line-height: 1.4; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.md-sb-page-card .page-card-title > span { flex: 1; min-width: 0; word-break: break-word; }
.md-sb-page-card .page-card-delete { flex-shrink: 0; border: none; background: transparent; color: var(--p5-muted); cursor: pointer; padding: 2px 4px; opacity: 0; transition: opacity 0.15s, color 0.15s; display: inline-flex; align-items: center; }
.md-sb-page-card:hover .page-card-delete { opacity: 0.6; }
.md-sb-page-card .page-card-delete:hover { opacity: 1; color: var(--p5-red); }
/* Card layer 2: image */
.md-sb-page-card .page-card-img { width: 100%; display: block; }
.md-sb-page-card .page-card-placeholder { width: 100%; aspect-ratio: 16/9; background: var(--p5-surface); display: flex; align-items: center; justify-content: center; color: var(--p5-muted); font-size: 24px; font-weight: 600; }
/* Card layer 3: action buttons */
.md-sb-page-card .page-card-actions { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--p5-border); }
.md-sb-page-card .page-action-btn { flex: 1; font-size: 11px; padding: 4px 0; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.15s; }
.md-sb-page-card .page-action-btn:hover:not([disabled]) { border-color: var(--p5-red); color: var(--p5-red); }
.md-sb-page-card .page-action-btn.primary { border-color: var(--p5-red); color: var(--p5-red); background: rgba(230,57,70,0.08); }
.md-sb-page-card .page-action-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.md-sb-page-card .md-sb-generating { font-size: 11px; color: #fbbf24; padding: 4px 0; }
/* Card layer 4: status badges */
.md-sb-page-card .page-card-badges { display: flex; gap: 12px; padding: 4px 12px 8px; align-items: center; }
.md-sb-page-card .thumb-badge { font-size: 10px; padding: 0; border: none; background: transparent; color: var(--p5-muted); display: inline-flex; align-items: center; gap: 4px; letter-spacing: 0.02em; }
.md-sb-page-card .thumb-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.md-sb-page-card .thumb-badge.has-details { color: #60a5fa; }
.md-sb-page-card .thumb-badge.has-prompt { color: #34d399; }
.md-sb-page-card .thumb-badge.has-image { color: var(--p5-red); }
.md-sb-page-card .thumb-badge.warn { color: #fbbf24; }

/* Batch bar */
.md-sb-batch-bar { padding: 10px 12px; margin: 0 0 10px; background: var(--p5-card); border: 1px solid var(--p5-border); flex-shrink: 0; }
.md-sb-batch-bar .batch-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.md-sb-batch-bar .batch-progress-text { font-size: 11px; color: var(--p5-text-secondary); margin-bottom: 4px; }
.md-sb-batch-bar .batch-progress-track { height: 3px; background: var(--p5-border); overflow: hidden; }
.md-sb-batch-bar .batch-progress-fill { height: 100%; background: var(--p5-red); transition: width 0.3s; }

/* Detail panel — right column */
.md-sb-detail-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--p5-muted); font-size: 13px; }
.md-sb-detail-img-wrap { position: relative; max-width: 720px; margin-bottom: 12px; }
.md-sb-detail-img-wrap img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; border: 1px solid var(--p5-border); }
.md-sb-detail-img-wrap .img-zoom-btn { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.5); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.md-sb-detail-img-wrap .img-check { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; }
.md-sb-detail-img-wrap .img-check svg { stroke: #fff; }
.md-sb-detail-actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; align-items: center; }
.md-sb-btn-icon { padding: 5px 8px !important; display: inline-flex; align-items: center; justify-content: center; }
.md-sb-btn-icon:hover { border-color: var(--p5-red) !important; color: var(--p5-red) !important; }
/* Storyboard button styles — dt-btn inside storyboard area */
.md-sb-body .dt-btn, .md-sb-batch-bar .dt-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 14px; font-size: 11px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.2s; }
.md-sb-body .dt-btn:hover, .md-sb-batch-bar .dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.md-sb-body .dt-btn-primary, .md-sb-batch-bar .dt-btn-primary { border-color: var(--p5-red); color: var(--p5-red); background: transparent; }
.md-sb-body .dt-btn-primary:hover, .md-sb-batch-bar .dt-btn-primary:hover { background: var(--p5-red); color: #fff; }
.md-sb-body .dt-btn:disabled, .md-sb-batch-bar .dt-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.md-sb-detail-section { margin: 12px 0; }
.md-sb-detail-section-title { font-size: 11px; font-weight: 600; color: var(--p5-text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; border-left: 3px solid var(--p5-red); padding-left: 8px; }
.md-sb-detail-prompt { font-size: 12px; color: var(--p5-text-secondary); white-space: pre-wrap; line-height: 1.5; background: var(--p5-surface); padding: 10px; border: 1px solid var(--p5-border); max-height: 200px; overflow-y: auto; }
.md-sb-detail-prompt-edit { width: 100%; min-height: 120px; font-size: 12px; padding: 10px; border: 1px solid var(--p5-red); background: var(--p5-input-bg); color: var(--p5-text); resize: vertical; font-family: inherit; }
.md-sb-detail-panel-details { font-size: 11px; color: var(--p5-muted); white-space: pre-wrap; line-height: 1.5; background: var(--p5-surface); padding: 10px; border: 1px solid var(--p5-border); max-height: 300px; overflow-y: auto; }
/* V3 Shot metadata: voice/duration/variation */
.md-sb-shot-meta { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.md-sb-meta-badge { padding: 2px 8px; font-size: 10px; font-weight: 600; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); }
.md-sb-meta-duration { border-color: var(--p5-red); color: var(--p5-red); }
.md-sb-meta-variation { border-color: #ff9800; color: #ff9800; }
.md-sb-voice-list { display: flex; flex-direction: column; gap: 4px; }
.md-sb-voice-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--p5-text-secondary); padding: 4px 8px; background: var(--p5-surface); border: 1px solid var(--p5-border); }
.md-sb-voice-type { flex-shrink: 0; color: var(--p5-red); }
.md-sb-voice-speaker { font-weight: 600; color: var(--p5-text); font-size: 10px; padding: 1px 4px; border: 1px solid var(--p5-border); }
.md-sb-voice-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-sb-voice-range { flex-shrink: 0; font-size: 9px; color: var(--p5-muted); font-family: monospace; }

/* V3 Reference thumbnails (2× scale) */
.md-sb-ref-thumbs { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.md-sb-ref-thumb { position: relative; cursor: pointer; border: 1px solid var(--p5-border); overflow: hidden; transition: border-color 0.2s; }
.md-sb-ref-thumb:hover { border-color: var(--p5-red); }
.md-sb-ref-thumb img { width: 112px; height: 112px; object-fit: cover; display: block; }
.md-sb-ref-thumb.md-sb-ref-scene img { width: 160px; height: 90px; }
.md-sb-ref-thumb.md-sb-ref-empty { width: 112px; height: 112px; display: flex; align-items: center; justify-content: center; background: var(--p5-surface); cursor: default; }
.md-sb-ref-thumb.md-sb-ref-empty.md-sb-ref-scene { width: 160px; height: 90px; }
.md-sb-ref-label { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; color: #fff; background: rgba(0,0,0,0.65); text-align: center; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-sb-ref-thumb.md-sb-ref-empty .md-sb-ref-label { position: static; color: var(--p5-muted); background: none; font-size: 11px; }
.md-sb-ref-del { position: absolute; top: 0; right: 0; width: 20px; height: 20px; background: var(--p5-red); color: #fff; border: none; font-size: 14px; line-height: 20px; text-align: center; cursor: pointer; padding: 0; z-index: 3; opacity: 0; transition: opacity 0.15s; }
.md-sb-ref-thumb:hover .md-sb-ref-del { opacity: 1; }
.md-sb-ref-thumb.md-sb-ref-add { width: 112px; height: 112px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--p5-red); cursor: pointer; background: transparent; transition: background 0.2s; }
.md-sb-ref-thumb.md-sb-ref-add:hover { background: rgba(230,57,70,0.08); }

/* ── Reference Asset Picker Modal ── */
.md-ref-picker-overlay { position: fixed; inset: 0; z-index: 10003; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.md-ref-picker-modal { width: 60vw; height: 85vh; background: var(--p5-card); border: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.md-ref-picker-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--p5-border); font-size: 14px; font-weight: 600; color: var(--p5-text); flex-shrink: 0; }
.md-ref-picker-close { background: none; border: none; color: var(--p5-muted); font-size: 22px; cursor: pointer; line-height: 1; }
.md-ref-picker-close:hover { color: var(--p5-red); }
.md-ref-picker-chars { display: flex; gap: 20px; padding: 20px; flex-shrink: 0; overflow-x: auto; border-bottom: 1px solid var(--p5-border); }
.md-ref-picker-char-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; flex-shrink: 0; transition: opacity 0.15s; }
.md-ref-picker-char-item:hover { opacity: 0.8; }
.md-ref-picker-char-item.active { outline: 2px solid var(--p5-red); outline-offset: 2px; }
.md-ref-picker-char-item img { border: 1px solid var(--p5-border); }
.md-ref-picker-char-name { font-size: 10px; color: var(--p5-text-secondary); max-width: 56px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-ref-picker-topo { flex: 1; overflow-y: auto; padding: 20px; min-height: 0; }
.md-ref-picker-tree { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 16px 0; min-height: 200px; }
.md-ref-picker-tree .md-char-topo-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.md-ref-picker-tree .md-char-topo-level { display: flex; justify-content: center; gap: 20px; margin-bottom: 36px; position: relative; z-index: 1; flex-wrap: wrap; }
.md-ref-picker-node { width: 254px; background: var(--p5-surface); border: 2px solid var(--p5-border); padding: 8px; text-align: center; cursor: pointer; position: relative; transition: border-color 0.15s; }
.md-ref-picker-node:hover { border-color: rgba(230,57,70,0.5); }
.md-ref-picker-node.rp-selected { border-color: var(--p5-red); box-shadow: 0 0 0 3px rgba(230,57,70,0.25); }
.md-ref-picker-node img { width: 100%; object-fit: cover; cursor: pointer; opacity: 0; transition: opacity 0.3s; display: block; }
.md-ref-picker-node img.loaded { opacity: 1; }
.md-ref-picker-node .md-char-topo-node-label { font-size: 12px; color: var(--p5-text); margin-top: 6px; }
.md-ref-picker-node .md-char-topo-node-empty { width: 100%; aspect-ratio: 21/9; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--p5-muted); background: var(--p5-dark); border: 1px dashed var(--p5-border); }
.md-ref-picker-node .comic-mj-zoom { top: 6px; left: 6px; width: 24px; height: 24px; }
.md-rp-check-badge { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; z-index: 2; }
.md-ref-picker-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--p5-border); flex-shrink: 0; }
.md-ref-picker-footer .dt-btn { padding: 8px 20px; font-size: 13px; cursor: pointer; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); transition: all 0.15s; }
.md-ref-picker-footer .dt-btn:hover { border-color: var(--p5-text-secondary); color: var(--p5-text); }
.md-ref-picker-footer .dt-btn-primary { border-color: var(--p5-red); color: #fff; background: var(--p5-red); font-weight: 600; }
.md-ref-picker-footer .dt-btn-primary:hover { opacity: 0.88; }
.md-ref-picker-footer .dt-btn-primary:disabled { opacity: 0.4; cursor: default; }

/* ── Regen With New Chars Modal ── */
.md-regen-chars-box { width: 60vw; max-height: 80vh; background: var(--p5-card); border: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.md-regen-chars-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--p5-border); font-size: 14px; font-weight: 600; color: var(--p5-text); flex-shrink: 0; }
.md-regen-chars-notice { display: flex; align-items: flex-start; gap: 8px; padding: 14px 18px; background: rgba(230,57,70,0.06); border-bottom: 1px solid var(--p5-border); flex-shrink: 0; font-size: 12px; color: var(--p5-text-secondary); line-height: 1.5; }
.md-regen-chars-notice svg { flex-shrink: 0; margin-top: 1px; }
.md-regen-chars-textarea { flex: 1; min-height: 200px; margin: 12px 18px; padding: 12px; background: var(--p5-dark); color: var(--p5-text); border: 1px solid var(--p5-border); font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.6; resize: vertical; }
.md-regen-chars-textarea:focus { border-color: var(--p5-red); outline: none; }
.md-regen-chars-footer { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--p5-border); flex-shrink: 0; }
.md-regen-chars-footer .dt-btn { min-width: 80px; padding: 8px 20px; font-size: 13px; }
.md-regen-chars-footer .dt-btn-primary { background: var(--p5-red); color: #fff; border: 1px solid var(--p5-red); }
.md-regen-chars-footer .dt-btn-primary:hover { background: #c62d3a; }
.md-regen-chars-footer .dt-btn-secondary { background: transparent; color: var(--p5-text-secondary); border: 1px solid var(--p5-border); }
.md-regen-chars-footer .dt-btn-secondary:hover { border-color: var(--p5-text-secondary); color: var(--p5-text); }
/* Toggle switch */
.md-regen-ai-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.md-regen-ai-label { font-size: 12px; color: var(--p5-text-secondary); }
.md-regen-ai-toggle input { display: none; }
.md-regen-ai-slider { width: 36px; height: 20px; background: var(--p5-border); display: inline-block; position: relative; transition: background 0.2s; }
.md-regen-ai-slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--p5-text-secondary); transition: transform 0.2s, background 0.2s; }
.md-regen-ai-toggle input:checked + .md-regen-ai-slider { background: var(--p5-red); }
.md-regen-ai-toggle input:checked + .md-regen-ai-slider::after { transform: translateX(16px); background: #fff; }

/* V3 Card wrapper for shot metadata sections */
.md-sb-card { background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 12px; margin-top: 10px; }
.md-sb-card .md-sb-detail-section-title { margin-top: 0; }

/* V3 Shot info row + 4-frame timeline + collapsible sections */
.md-sb-shot-info { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.md-sb-meta-badge svg { vertical-align: -1px; margin-right: 2px; }
.md-sb-frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.md-sb-frame-card { padding: 8px; background: var(--p5-surface); border: 1px solid var(--p5-border); min-height: 60px; }
.md-sb-frame-time { font-size: 10px; font-weight: 600; color: var(--p5-red); margin-bottom: 4px; letter-spacing: 0.3px; }
.md-sb-frame-desc { font-size: 11px; color: var(--p5-text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.md-sb-detail-collapse { border: none; }
.md-sb-detail-collapse summary { font-size: 11px; font-weight: 600; color: var(--p5-text-secondary); text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; padding: 4px 0; border-left: 3px solid var(--p5-red); padding-left: 8px; list-style: none; }
.md-sb-detail-collapse summary::-webkit-details-marker { display: none; }
.md-sb-detail-collapse summary::before { content: '\25B6'; font-size: 8px; margin-right: 6px; display: inline-block; transition: transform 0.2s; }
.md-sb-detail-collapse[open] summary::before { transform: rotate(90deg); }
.md-sb-detail-collapse .md-sb-detail-panel-details,
.md-sb-detail-collapse .md-sb-detail-prompt { margin-top: 6px; }

/* ──────────────────────────────────────────────────────────────
   Storyboard V4 visual — .md-story-* namespace
   Layout: full-width md-story-top (Tabs) + 3-col story-pg (15/35/50)
────────────────────────────────────────────────────────────── */
.md-story-top {
  flex-shrink: 0;
  display: flex; justify-content: center; align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-dark);
}
.md-story-pg {
  display: grid;
  grid-template-columns: 15% 35% 50%;
  flex: 1; min-height: 0;
  overflow: hidden;
}
.md-story-acts {
  background: var(--p5-dark);
  border-right: 1px solid var(--p5-border);
  overflow-y: auto;
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
}
.md-story-acts::-webkit-scrollbar { width: 4px; }
.md-story-acts::-webkit-scrollbar-thumb { background: var(--p5-border); }

.md-story-act-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 22px 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}
.md-story-act-card:hover { border-color: rgba(230,57,70,0.5); }
.md-story-act-card.on {
  border-color: var(--p5-red);
  background: rgba(230,57,70,0.06);
  box-shadow: inset 3px 0 0 var(--p5-red);
  padding-left: 23px;
}
.md-story-act-card.done { border-color: rgba(16,185,129,0.35); }
.md-story-act-card.done.on { border-color: var(--p5-red); }
.md-story-act-title {
  margin: 0 0 20px 0;
  padding-right: 56px;               /* 留位置给右上角 tag */
  font-size: 13px; font-weight: 600;
  color: var(--p5-text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.md-story-act-tag {
  position: absolute;
  top: 22px;
  right: 20px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  background: var(--p5-input-bg);
  color: var(--p5-text-secondary);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.md-story-act-card.done .md-story-act-tag { background: rgba(16,185,129,0.14); color: #10b981; }
.md-story-act-card.on .md-story-act-tag { background: var(--p5-red); color: #000; }
.md-story-act-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; font-weight: 600;
  color: var(--p5-text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 22px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.md-story-act-dot {
  width: 6px; height: 6px;
  background: var(--p5-muted);
  flex-shrink: 0;
}
.md-story-act-dot.done { background: #10b981; }
.md-story-act-dot.partial { background: #f59e0b; }
.md-story-act-dot.empty { background: var(--p5-red); }
.md-story-act-gen-btn {
  display: block;
  width: auto;
  max-width: 90%;
  margin: 0 auto;
  padding: 9px 16px;
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: transparent;
  color: var(--p5-red);
  border: 1px solid var(--p5-red);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-story-act-gen-btn:hover:not(:disabled) { background: var(--p5-red); color: #fff; }
.md-story-act-gen-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Middle column: panels-col ────────────────────────────── */
.md-story-panels-col {
  background: var(--p5-surface);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.md-story-panels-head {
  flex-shrink: 0;
  display: flex; align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-dark);
}
.md-story-ti {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--p5-text);
}
/* Top header row — 3 Tabs centered, modeled on mva3-top (Characters tab bar) */
.md-story-mode-row {
  flex-shrink: 0;
  display: flex; justify-content: center; align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-dark);
}
.md-story-tabs {
  display: flex;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}
.md-story-tabs .mva3-tab { padding: 8px 22px; font-size: 12px; }
.md-story-tabs .mva3-tab svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Act full-content head — under tabs, above panels list */
.md-story-act-head {
  flex-shrink: 0;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-surface);
}
.md-story-act-h-title {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  color: var(--p5-text);
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.md-story-act-h-body {
  font-size: 12px;
  color: var(--p5-text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}
.md-story-act-h-body::-webkit-scrollbar { width: 4px; }
.md-story-act-h-body::-webkit-scrollbar-thumb { background: var(--p5-border); }

.md-story-panels-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 14px;
}
.md-story-panels-list::-webkit-scrollbar { width: 6px; }
.md-story-panels-list::-webkit-scrollbar-thumb { background: var(--p5-border); }

.md-story-panel-block {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  width: 90%;
  display: flex; flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
  overflow: hidden;
}
.md-story-panel-block:hover { border-color: rgba(230,57,70,0.5); }
.md-story-panel-block.active {
  border-color: var(--p5-red);
  box-shadow: 0 3px 10px rgba(230,57,70,0.22), 0 6px 20px rgba(0,0,0,0.45), inset 0 1px 0 rgba(230,57,70,0.15);
}
.md-story-ph {
  padding: 8px 12px;
  display: flex; align-items: center; gap: 10px;
  background: var(--p5-input-bg);
  border-bottom: 1px solid var(--p5-border);
}
.md-story-n {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  color: var(--p5-red);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.md-story-desc {
  font-size: 11.5px; color: var(--p5-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1; min-width: 0;
}
.md-story-imgs {
  width: 100%;
  background: var(--p5-dark);
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
}
.md-story-imgs img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.md-story-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--p5-muted);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px; letter-spacing: 0.08em;
}
.md-story-sub-act {
  display: flex;
  border-top: 1px solid var(--p5-border);
}
.md-story-act-btn {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  color: var(--p5-text-secondary);
  border: none;
  border-right: 1px solid var(--p5-border);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.15s, background 0.15s;
}
.md-story-act-btn:last-child { border-right: none; }
.md-story-act-btn:hover:not(:disabled) { color: var(--p5-text); background: var(--p5-input-bg); }
.md-story-act-btn.red { color: var(--p5-red); font-weight: 700; }
.md-story-act-btn.red:hover:not(:disabled) { background: var(--p5-red); color: #fff; }
.md-story-act-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Right column action bar — V4 style, consistent with panel sub-act and Tab */
.md-story-right-act {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
}
.md-story-right-act .md-story-act-btn { padding: 10px 0; }
.md-story-act-btn-icon { flex: 0 0 44px; display: flex; align-items: center; justify-content: center; }
.md-story-act-btn-icon:hover:not(:disabled) { color: var(--p5-red); background: var(--p5-input-bg); }

/* ── Right column: preview ────────────────────────────────── */
.md-story-preview {
  background: var(--p5-dark);
  border-left: 1px solid var(--p5-border);
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.md-story-preview::-webkit-scrollbar { width: 6px; }
.md-story-preview::-webkit-scrollbar-thumb { background: var(--p5-border); }

.md-story-preview-main {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
}
.md-story-preview-big {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--p5-dark);
  position: relative;
  overflow: hidden;
}
.md-story-preview-big img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.md-story-preview-big.md-story-preview-empty {
  display: flex; align-items: center; justify-content: center;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px; color: var(--p5-muted);
  padding: 10px;
  text-align: center;
  border: 1px dashed var(--p5-border);
  background: var(--p5-surface);
}
.md-story-preview-big .img-zoom-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.md-story-preview-big .img-zoom-btn:hover { background: var(--p5-red); }
.md-story-preview-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.md-story-sf {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
}
.md-story-sf:hover { border-color: var(--p5-red); }
.md-story-sf img { width: 100%; height: 100%; object-fit: cover; display: block; }
.md-story-sf .fl {
  position: absolute; top: 2px; left: 3px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px; font-weight: 700;
  color: #fff;
  padding: 1px 4px;
  background: rgba(0,0,0,0.65);
  z-index: 1;
  letter-spacing: 0.04em;
}

.md-story-history-strip {
  padding: 10px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
}
.md-story-history-strip h5 {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--p5-muted);
}
.md-story-history-strip .row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.md-story-hc {
  aspect-ratio: 16/9;
  background: var(--p5-dark);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  opacity: 0.7;
  transition: opacity 0.15s, border-color 0.15s;
}
.md-story-hc:hover { opacity: 1; }
.md-story-hc.on { border-color: var(--p5-red); opacity: 1; }
.md-story-hc img { width: 100%; height: 100%; object-fit: cover; display: block; }

.md-sb-detail-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.md-sb-detail-badge { padding: 2px 8px; font-size: 10px; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); }
.md-sb-detail-refs { display: flex; gap: 6px; flex-wrap: wrap; }
.md-sb-detail-refs img { width: 56px; height: 56px; object-fit: cover; border: 1px solid var(--p5-border); cursor: pointer; }
.md-sb-detail-refs img:hover { border-color: var(--p5-red); }
/* Sub-frame 4-grid row */
.md-sb-frames-row { display: flex; gap: 6px; max-width: 720px; margin: 8px 0; }
.md-sb-frame-cell { position: relative; flex: 1; cursor: pointer; overflow: hidden; border: 1px solid var(--p5-border); transition: border-color 0.2s; }
.md-sb-frame-cell:hover { border-color: var(--p5-red); }
.md-sb-frame-cell img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.md-sb-frame-label { position: absolute; top: 3px; left: 3px; font-size: 9px; font-weight: 600; background: rgba(0,0,0,0.6); color: #fff; padding: 1px 5px; letter-spacing: 0.3px; }
/* 4-frame split CSS-crop fallback — shown while real per-cell CDN URLs are being prepared.
   Silent: no pulse / hint text, because CSS-crop of the composite looks indistinguishable
   from the real 4 cells to the user, so any "loading" indicator reads as lying about state.
   Only semantic difference: cells are not yet clickable for per-frame editing. */
.md-sb-frames-row--loading .md-sb-frame-cell { cursor: default; pointer-events: none; }
.md-sb-frame-cell--preview { aspect-ratio: 16/9; background-size: 200% 200%; background-repeat: no-repeat; border: 1px solid var(--p5-border); }
.md-sb-frame-cell--preview[data-pos="0"] { background-position: 0% 0%; }
.md-sb-frame-cell--preview[data-pos="1"] { background-position: 100% 0%; }
.md-sb-frame-cell--preview[data-pos="2"] { background-position: 0% 100%; }
.md-sb-frame-cell--preview[data-pos="3"] { background-position: 100% 100%; }
/* Zoom button for thumbnails (mid column panel card + right column F1-F4).
   Needs parent position:relative (both .md-sb-frame-cell and .page-card-img-wrap have it). */
.md-sb-zoom-btn { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; transition: background 0.15s, border-color 0.15s; }
.md-sb-zoom-btn:hover { background: var(--p5-red); border-color: var(--p5-red); }
/* Preview cells disable pointer-events for editing, but zoom button must stay clickable. */
.md-sb-frames-row--loading .md-sb-frame-cell .md-sb-zoom-btn { pointer-events: auto; }
/* Mid column thumbnail wrapper */
.md-sb-page-card .page-card-img-wrap { position: relative; line-height: 0; }
/* Frame edit mode */
.md-sb-frame-edit-back { cursor: pointer; color: var(--p5-red); margin-bottom: 10px; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.md-sb-frame-edit-back:hover { text-decoration: underline; }
.md-sb-frame-history { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.md-sb-frame-history img { width: 100px; aspect-ratio: 16/9; object-fit: cover; cursor: pointer; border: 2px solid transparent; opacity: 0.6; transition: all 0.2s; }
.md-sb-frame-history img:hover { opacity: 1; border-color: var(--p5-text-secondary); }
.md-sb-frame-history img.active { opacity: 1; border-color: var(--p5-red); }

.md-sb-detail-history { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.md-sb-detail-history img { width: 80px; aspect-ratio: 16/9; object-fit: cover; border: 2px solid var(--p5-border); cursor: pointer; opacity: 0.6; transition: all 0.2s; }
.md-sb-detail-history img:hover { opacity: 1; border-color: var(--p5-text-secondary); }
.md-sb-detail-history img.active { opacity: 1; border-color: var(--p5-red); }
.md-sb-generating { font-size: 11px; color: var(--p5-red); display: flex; align-items: center; gap: 4px; }
.md-sb-generating::before { content: ''; width: 8px; height: 8px; background: var(--p5-red); animation: md-sb-pulse 1s infinite; }
@keyframes md-sb-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Prompt modal */
.md-prompt-modal-overlay { position: fixed; inset: 0; z-index: 10001; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.md-prompt-modal-overlay.active { opacity: 1; }
.md-prompt-modal-box { width: 720px; max-width: 90vw; max-height: 85vh; display: flex; flex-direction: column; background: var(--p5-card); border: 1px solid var(--p5-border); }
.md-prompt-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--p5-border); font-size: 14px; font-weight: 600; color: var(--p5-text); flex-shrink: 0; }
.md-prompt-modal-close { background: none; border: none; color: var(--p5-muted); cursor: pointer; padding: 4px; }
.md-prompt-modal-close:hover { color: var(--p5-text); }
.md-prompt-modal-body { flex: 1; padding: 16px 20px; overflow-y: auto; min-height: 0; }
.md-prompt-modal-body textarea { width: 100%; min-height: 320px; font-size: 13px; line-height: 1.6; padding: 14px; border: 1px solid var(--p5-border); background: var(--p5-input-bg); color: var(--p5-text); resize: vertical; font-family: inherit; }
.md-prompt-modal-body textarea:focus { outline: none; border-color: var(--p5-red); }
.md-prompt-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--p5-border); flex-shrink: 0; }
.md-prompt-modal-footer .dt-btn { padding: 6px 18px; font-size: 12px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; }
.md-prompt-modal-footer .dt-btn:hover { border-color: var(--p5-text-secondary); color: var(--p5-text); }
.md-prompt-modal-footer .dt-btn-primary { border-color: var(--p5-red); color: var(--p5-red); }
.md-prompt-modal-footer .dt-btn-primary:hover { background: var(--p5-red); color: #fff; }
/* Phase 1 barber-pole animation on progress track */
.batch-progress-track.md-sb-phase1-pulse { background: linear-gradient(90deg, var(--p5-border) 25%, transparent 25%, transparent 50%, var(--p5-border) 50%, var(--p5-border) 75%, transparent 75%); background-size: 20px 20px; animation: md-sb-barber 1s linear infinite; }
.batch-progress-track.md-sb-phase1-pulse .batch-progress-fill { background: var(--p5-red); opacity: 0.6; }
@keyframes md-sb-barber { to { background-position: 20px 0; } }
/* Skeleton cards during Phase 1 */
.md-sb-skeleton { pointer-events: none; opacity: 0.75; }
.skeleton-pulse { animation: md-sb-pulse 1.5s ease-in-out infinite; background: var(--p5-border); }
.skeleton-bar { height: 10px; background: var(--p5-border); animation: md-sb-pulse 1.5s ease-in-out infinite; margin-top: 4px; }
.skeleton-bar.w60 { width: 60%; }
.md-char-panel, .md-scene-panel { padding: 20px 32px; flex: 1; overflow-y: auto; min-height: 0; }
/* Character/Scene panels: fixed header + scrollable content */
#md-characters.active, #md-scenes.active, #md-storyboard.active { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#md-characters > .comic-chat-header, #md-scenes > .comic-chat-header, #md-storyboard > .comic-chat-header { flex-shrink: 0; }
.md-asset-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; min-height: 40px; }
.md-asset-header h2 { flex: 1; font-size: 18px; font-weight: var(--weight-bold); margin: 0; }
.md-nav-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); padding: 6px 14px; font-size: 13px; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.md-nav-btn:hover { color: var(--p5-text); border-color: var(--p5-red); background: rgba(230,57,70,0.06); }
.md-asset-section { margin-bottom: 24px; }
.md-asset-section h3 { font-size: 15px; font-weight: var(--weight-semibold); margin: 0 0 12px; color: var(--p5-text); }
.md-asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.md-asset-card { background: var(--p5-surface); padding: 14px; border: 1px solid var(--p5-border); }
.md-asset-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.md-asset-code { font-size: 10px; font-family: var(--font-mono); color: var(--p5-muted); background: var(--p5-hover); padding: 2px 6px; }
.md-asset-role, .md-asset-type { font-size: 11px; color: var(--p5-muted); margin-left: auto; }
.md-asset-card-body { font-size: 12px; color: var(--p5-text-secondary); }
.md-asset-detail { margin-bottom: 6px; line-height: 1.4; }
.md-asset-variants { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.md-asset-variants small { color: var(--p5-muted); margin-right: 4px; }
.md-variant-tag { font-size: 10px; padding: 2px 8px; background: rgba(230,57,70,0.1); color: var(--p5-red); }
.md-asset-acts small { color: var(--p5-muted); font-size: 11px; }
.md-char-grid, .md-scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ── Manga Drama: Character Studio 4-column layout ── */
.md-char-tab-bar { display: flex; gap: 24px; justify-content: center; padding: 0; flex-shrink: 0; }
.md-char-tab { padding: 8px 4px; font-size: 13px; font-weight: 600; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--p5-muted); cursor: pointer; transition: all 0.2s; }
.md-char-tab.active { color: var(--p5-red); border-bottom-color: var(--p5-red); }
.md-char-tab:hover:not(.active) { color: var(--p5-text); }

.md-char-studio { display: grid; grid-template-columns: 200px 252px 1fr auto; grid-template-rows: 1fr; flex: 1; min-height: 0; overflow: hidden; }
.md-char-studio > * { min-height: 0; min-width: 0; height: 100%; }
.md-char-info-wrap { width: 260px; }
@media (max-width: 1200px) { .md-char-studio { grid-template-columns: 180px 210px 1fr auto; } .md-char-info-wrap { width: 220px; } }
@media (max-width: 900px) { .md-char-studio { grid-template-columns: 140px 1fr; grid-template-rows: 1fr 1fr; } }

/* Left character list */
.md-char-list { background: var(--p5-surface); display: flex; flex-direction: column; overflow: hidden; }
.md-char-list-scroll { flex: 1; overflow-y: auto; padding: 4px 0; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.md-char-list-scroll::-webkit-scrollbar { width: 4px; }
.md-char-list-scroll::-webkit-scrollbar-track { background: transparent; }
.md-char-list-scroll::-webkit-scrollbar-thumb { background: var(--p5-border); }
.md-char-list-scroll::-webkit-scrollbar-thumb:hover { background: var(--p5-muted); }
.md-char-list-item { padding: 10px 12px 10px 32px; cursor: pointer; transition: all 0.15s; position: relative; }
.md-char-list-item:hover { background: rgba(230,57,70,0.04); }
.md-char-list-item.active { background: rgba(230,57,70,0.08); }
.md-char-list-item.active .md-char-list-name { padding-left: 10px; border-left: 3px solid var(--p5-red); }
.md-char-list-name { font-size: 13px; font-weight: 600; color: var(--p5-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-char-list-role { font-size: 11px; color: var(--p5-muted); margin-top: 2px; }
.md-char-list-thumb { width: 130px; aspect-ratio: 3/4; object-fit: cover; margin-top: 6px; display: block; border: 1px solid var(--p5-border); }
.md-char-list-thumb.loaded { opacity: 1; }
/* Portrait check badge — top-right corner, no full overlay */
.md-portrait-check-badge { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; z-index: 4; }
.md-char-portrait .comic-style-card.selected .style-check { display: none; }
.md-char-list-placeholder { width: 130px; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--p5-dark); border: 1px dashed var(--p5-border); color: var(--p5-muted); margin-top: 6px; }
.md-char-list-empty { padding: 20px 12px; text-align: center; font-size: 12px; color: var(--p5-muted); }

/* Portrait column */
.md-char-portrait { padding: 20px 12px 12px 20px; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: none; }
.md-char-portrait::-webkit-scrollbar { display: none; }
.md-char-portrait .comic-style-card { border: none; cursor: default; }
.md-char-portrait .comic-style-card:hover { transform: none; box-shadow: none; }
.md-portrait-empty { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--p5-dark); border: 2px dashed var(--p5-red); color: var(--p5-muted); font-size: 12px; flex-direction: column; gap: 8px; }
.md-portrait-dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0; flex-shrink: 0; }
.md-portrait-dot { width: 8px; height: 8px; background: var(--p5-border); cursor: pointer; transition: all 0.2s; border: none; padding: 0; }
.md-portrait-dot.active { background: var(--p5-red); }
.md-portrait-dot:hover:not(.active) { background: var(--p5-text-secondary); }
.md-portrait-actions { padding: 8px 0; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.md-portrait-actions button { width: 100%; padding: 6px 0; font-size: 12px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); cursor: pointer; transition: all 0.15s; }
.md-portrait-actions button.is-primary { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }
.md-portrait-actions button.is-primary:hover { background: #ff6b6b; border-color: #ff6b6b; }
.md-portrait-actions button:hover { border-color: var(--p5-red); color: #fff; background: var(--p5-red); }
.md-portrait-actions button:disabled { opacity: 0.4; cursor: default; }
.md-portrait-progress { aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--p5-dark); border: 1px solid var(--p5-border); position: relative; overflow: hidden; }
.md-portrait-progress::after { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent 0%, rgba(230,57,70,0.06) 50%, transparent 100%); animation: as-topo-shimmer 2s infinite; pointer-events: none; }
.md-portrait-progress span { font-size: 12px; color: var(--p5-muted); }

/* Style thumbnail at top of topo */
.md-style-thumb { position: relative; width: 70%; overflow: hidden; cursor: pointer; flex-shrink: 0; border: 1px solid var(--p5-border); margin: 8px auto; }
.md-style-thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.md-style-thumb img.loaded { opacity: 1; }
.md-style-thumb-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 8px 6px; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%); font-size: 11px; color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Topology tree column */
.md-char-topo { padding: 16px 12px; overflow: auto; display: flex; flex-direction: column; }
.md-char-topo-tree { position: relative; flex: 1; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 16px 0; max-width: 680px; width: 100%; margin-inline: auto; }
.md-char-topo-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.md-char-topo-level { display: flex; justify-content: center; gap: 16px; margin-bottom: 28px; position: relative; z-index: 1; flex-wrap: wrap; }
.md-char-topo-node { width: 273px; background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 6px; text-align: center; transition: border-color 0.15s; cursor: default; position: relative; }
.md-char-topo-node:hover { border-color: var(--p5-text-secondary); }
.md-char-topo-node.root { border-color: var(--p5-red); }
.md-char-topo-node img { width: 100%; object-fit: cover; cursor: pointer; opacity: 0; transition: opacity 0.3s; display: block; }
.md-char-topo-node img.loaded { opacity: 1; }
.md-char-topo-node-label { font-size: 11px; color: var(--p5-text); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-char-topo-node-badge { font-size: 10px; color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.md-char-topo-node-empty { width: 100%; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--p5-muted); background: var(--p5-dark); border: 1px dashed var(--p5-border); }
.md-char-topo-node-empty.portrait { aspect-ratio: 3/4; }
.md-char-topo-node-empty.decompose { aspect-ratio: 21/9; }
.md-char-topo-node-progress { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--p5-dark); position: relative; overflow: hidden; }
.md-char-topo-node-progress.portrait { aspect-ratio: 3/4; }
.md-char-topo-node-progress.decompose { aspect-ratio: 21/9; }
.md-char-topo-node-progress::after { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent 0%, rgba(230,57,70,0.06) 50%, transparent 100%); animation: as-topo-shimmer 2s infinite; pointer-events: none; }
.md-char-topo-progress-fill { height: 3px; background: var(--p5-red); transition: width 0.3s; width: 0; }
.md-char-topo-node-progress > span { font-size: 11px; color: var(--p5-muted); }
.md-char-topo-node-actions { display: flex; gap: 3px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.md-char-topo-btn { padding: 3px 8px; font-size: 10px; background: rgba(230,57,70,0.08); color: var(--p5-red); border: 1px solid rgba(230,57,70,0.2); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 3px; }
.md-char-topo-btn:hover { background: var(--p5-red); color: #fff; border-color: var(--p5-red); }
.md-char-topo-btn:disabled { opacity: 0.4; cursor: default; }
.md-char-topo-node .comic-mj-zoom { top: 4px; left: 4px; width: 20px; height: 20px; }
/* Decompose/variant image selection & history dots in topo tree */
.md-topo-decomp-wrap { border: 2px solid transparent; transition: border-color 0.15s; position: relative; }
.md-topo-decomp-wrap.is-selected { border-color: var(--p5-red); box-shadow: 0 0 0 2px rgba(230,57,70,0.25); }
.md-topo-decomp-wrap:hover { border-color: rgba(230,57,70,0.5); }
.md-topo-decomp-wrap:hover .comic-mj-zoom { opacity: 1; }
.md-topo-check-badge { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; z-index: 2; }
.md-topo-dots { display: flex; justify-content: center; gap: 5px; padding: 5px 0 2px; }
.md-topo-dot { width: 7px; height: 7px; border: none; background: var(--p5-border); cursor: pointer; padding: 0; transition: background 0.15s; }
.md-topo-dot.active { background: var(--p5-red); }
.md-topo-dot:hover { background: var(--p5-red); opacity: 0.7; }
.md-char-topo-prompt-overlay { position: fixed; inset: 0; z-index: 10005; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.md-char-topo-prompt-box { width: 90%; max-width: 600px; max-height: 70vh; background: var(--p5-card); border: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.md-char-topo-prompt-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--p5-border); font-size: 13px; font-weight: 600; color: var(--p5-text); }
.md-char-topo-prompt-close { background: none; border: none; color: var(--p5-muted); font-size: 18px; cursor: pointer; }
.md-char-topo-prompt-close:hover { color: var(--p5-red); }
.md-char-topo-prompt-text { flex: 1; overflow-y: auto; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--p5-text-secondary); line-height: 1.6; font-family: 'SF Mono', 'Fira Code', monospace; background: var(--p5-dark); margin: 8px 14px; }
.md-char-topo-prompt-textarea { flex: 1; overflow-y: auto; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--p5-text-secondary); line-height: 1.6; font-family: 'SF Mono', 'Fira Code', monospace; background: var(--p5-dark); margin: 8px 14px; border: 1px solid var(--p5-border); resize: vertical; min-height: 120px; width: calc(100% - 28px); }
.md-char-topo-prompt-textarea:not([readonly]) { background: var(--p5-surface); color: var(--p5-text); border-color: var(--p5-red); }
.md-char-topo-prompt-footer { display: flex; justify-content: flex-end; gap: 4px; padding: 8px 14px; border-top: 1px solid var(--p5-border); }

/* Right character info panel — collapsible */
.md-char-info-wrap { position: relative; display: flex; overflow: hidden; transition: width 0.25s ease; }
.md-char-info-wrap.collapsed { width: 14px !important; min-width: 14px; }
.md-char-info-wrap.collapsed .md-char-info { display: none; }
.md-char-info-toggle { position: absolute; top: 50%; right: 0; transform: translateY(-50%); width: 14px; height: 48px; background: var(--p5-red); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; opacity: 0.7; transition: opacity 0.15s; padding: 0; }
.md-char-info-toggle:hover { opacity: 1; }
.md-char-info { padding: 16px 20px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; flex: 1; scrollbar-width: none; }
.md-char-info::-webkit-scrollbar { display: none; }
.md-char-info-header { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--p5-border); }
.md-char-info-name { font-size: 16px; font-weight: 700; color: var(--p5-text); }
.md-char-info-role { display: inline-block; font-size: 11px; padding: 2px 8px; background: rgba(230,57,70,0.12); color: var(--p5-red); margin-top: 4px; }
.md-char-info .char-attr-row { margin-bottom: 6px; border-left: none; padding-left: 0; }
.md-char-info .char-attr-label { padding-left: 10px; border-left: 3px solid var(--p5-red); }
.md-char-info .char-attr-value { -webkit-line-clamp: unset; display: block; }
/* Decompose section — separated from portrait */
.md-decompose-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--p5-border); }
.comic-decompose-img-wrap { position: relative; overflow: hidden; margin: 8px 0; }
.comic-decompose-img-wrap img { width: 100%; aspect-ratio: 21/9; object-fit: cover; display: block; border: 1px solid var(--p5-border); cursor: pointer; }
.comic-decompose-img-wrap .comic-mj-zoom { position: absolute; top: 6px; left: 6px; }
.md-decompose-placeholder { display: flex; align-items: center; justify-content: center; padding: 20px; color: var(--p5-muted); background: var(--p5-surface); border: 1px dashed var(--p5-border); margin: 8px 0; min-height: 60px; }
.md-decompose-progress { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.md-decompose-progress-bar { width: 100%; height: 4px; background: var(--p5-border); overflow: hidden; }
.md-decompose-progress-fill { height: 100%; background: var(--p5-red); transition: width 0.5s ease; width: 0; }
.md-decompose-progress-text { font-size: 12px; color: var(--p5-red-light); }
.md-variant-progress { flex-shrink: 0; min-width: 100px; }
/* Costume change (换装) section */
.md-variant-section { margin-top: 12px; border-top: 1px solid var(--p5-border); padding-top: 8px; }
.md-variant-section summary { cursor: pointer; font-size: 12px; color: var(--p5-red-light); font-weight: var(--weight-semibold); }
.md-costume-card { padding: 10px 0; border-bottom: 1px solid var(--p5-border); }
.md-costume-card:last-child { border-bottom: none; }
.md-costume-name { font-size: 14px; font-weight: var(--weight-semibold); color: var(--p5-text); margin-bottom: 4px; }
.md-costume-desc { font-size: 12px; color: var(--p5-text-secondary); line-height: 1.5; margin-bottom: 8px; }
.md-variant-info { flex: 1; min-width: 0; }
.md-variant-info strong { font-size: 12px; display: block; }
.md-variant-info small { font-size: 11px; color: var(--p5-muted); }
.md-variant-thumb { width: 60px; height: 30px; object-fit: cover; cursor: pointer; }
.md-act-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.md-panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.comic-panel-card { background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 12px; }
.comic-panel-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.comic-panel-num { font-size: 14px; font-weight: var(--weight-bold); color: var(--p5-red); font-family: var(--font-mono); }
.comic-panel-desc { font-size: 12px; color: var(--p5-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-panel-prompt { font-size: 11px; color: var(--p5-muted); max-height: 60px; overflow: hidden; margin: 8px 0; line-height: 1.4; }
.comic-scene-desc { font-size: 12px; color: var(--p5-text-secondary); margin-bottom: 8px; line-height: 1.4; }

/* ── Manga Drama: Scene Layout (sidebar + board) ── */
.md-scene-layout { display: grid; grid-template-columns: 220px 1fr; flex: 1; min-height: 0; overflow: hidden; }

/* Left sidebar */
.md-scene-sidebar { background: var(--p5-surface); border-right: 1px solid var(--p5-border); overflow-y: auto; padding: 8px; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.md-scene-sidebar::-webkit-scrollbar { width: 4px; }
.md-scene-sidebar::-webkit-scrollbar-thumb { background: var(--p5-border); }
.md-sb-title { font-size: 10px; color: var(--p5-muted); letter-spacing: 2px; padding: 4px 8px 4px; }
.md-sb-stats { font-size: 11px; color: var(--p5-text-secondary); padding: 0 8px 8px; }
.md-sb-act { font-size: 10px; color: var(--p5-red); font-weight: 600; padding: 8px 8px 4px; margin-top: 4px; }
.md-sb-item { display: flex; flex-direction: column; padding: 6px 8px; cursor: pointer; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; margin-bottom: 4px; border: 1px solid transparent; }
.md-sb-item:hover { background: rgba(230,57,70,0.06); }
.md-sb-item.active { border-color: var(--p5-red); background: rgba(230,57,70,0.08); box-shadow: 0 0 0 1px rgba(230,57,70,0.3); }
.md-sb-info { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.md-sb-name { font-size: 11px; color: var(--p5-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.md-sb-status { font-size: 9px; color: var(--p5-muted); flex-shrink: 0; }
.md-sb-item.done .md-sb-status { color: #67c23a; }
.md-sb-item.pending .md-sb-status { color: #e6a23c; }
.md-sb-thumb { width: 100%; aspect-ratio: 16/9; overflow: hidden; background: var(--p5-surface); border: 1px solid var(--p5-border); display: flex; align-items: center; justify-content: center; }
.md-sb-item.done .md-sb-thumb { border-color: rgba(230,57,70,0.3); }
.md-sb-item.pending .md-sb-thumb { border-color: rgba(230,162,60,0.3); }
.md-sb-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.md-sb-thumb img.loaded { opacity: 1; }
.md-sb-empty-icon { color: var(--p5-muted); opacity: 0.4; }

/* ── Manga Drama: Scene Board Game Map ── */
.md-board { position: relative; overflow: visible; background-color: #0e1014; background-image: radial-gradient(circle, rgba(230,57,70,0.025) 1px, transparent 1px); background-size: 20px 20px; }

/* Map border frame — removed for adaptive height */
.md-board::before, .md-board::after { display: none; }
.md-board-corner { display: none; }

/* Floating particles */
.md-board-particle { position: absolute; width: 2px; height: 2px; background: rgba(230,57,70,0.2); pointer-events: none; z-index: 0; animation: board-float linear infinite; }
@keyframes board-float {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-120px) scale(0.5); opacity: 0; }
}

/* Path animation — ant march */
.md-board-paths { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; }
.md-board-paths path.walked { animation: path-march 0.8s linear infinite; filter: drop-shadow(0 0 3px rgba(230,57,70,0.4)); }
@keyframes path-march { to { stroke-dashoffset: -13; } }
.md-board-paths path.frontier { animation: path-march 1.2s linear infinite; filter: drop-shadow(0 0 3px rgba(230,162,60,0.3)); }
.md-board-paths path.unwalked { animation: path-flow 2s linear infinite; }
@keyframes path-flow { to { stroke-dashoffset: -13; } }

.md-board-nodes { position: absolute; top: 0; left: 0; z-index: 1; }

/* Board node */
.md-bnode { position: absolute; width: 156px; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: transform 0.2s; z-index: 2; }
.md-bnode:hover { transform: scale(1.08); z-index: 3; }

.md-bnode-ring { width: 114px; height: 114px; position: relative; display: flex; align-items: center; justify-content: center; border: 2px solid #2a2d37; background: rgba(20,20,24,0.85); transition: all 0.3s; margin: 0 auto; }
.md-bnode:hover .md-bnode-ring { border-color: rgba(230,57,70,0.5); }
.md-bnode.has-images .md-bnode-ring { border-color: #e6a23c; background: rgba(20,20,24,0.92); box-shadow: 0 0 12px rgba(230,162,60,0.15); }
.md-bnode.has-images .md-bnode-icon { color: #e6a23c; }
.md-bnode.has-images .md-bnode-label { color: #e6a23c; }
.md-bnode.done .md-bnode-ring { border-color: var(--p5-red); background: rgba(20,20,24,0.92); box-shadow: 0 0 16px rgba(230,57,70,0.15); }
.md-bnode.polling .md-bnode-ring { border-color: rgba(230,57,70,0.5); animation: bnode-glow 1.5s ease-in-out infinite; }
@keyframes bnode-glow { 0%,100% { box-shadow: 0 0 8px rgba(230,57,70,0.2); } 50% { box-shadow: 0 0 20px rgba(230,57,70,0.5); } }

.md-bnode-icon { width: 52px; height: 52px; color: #555; transition: color 0.2s; display: flex; align-items: center; justify-content: center; }
.md-bnode.done .md-bnode-icon { color: var(--p5-red); }
.md-bnode:hover .md-bnode-icon { color: #888; }
.md-bnode-icon svg { width: 100%; height: 100%; }

/* Pulse ring for generating */
.md-bnode-pulse { position: absolute; inset: -4px; border: 2px solid var(--p5-red); opacity: 0; animation: bnode-pulse 2s ease-out infinite; }
@keyframes bnode-pulse { 0% { opacity: 0.6; transform: scale(1); } 100% { opacity: 0; transform: scale(1.3); } }

/* Sidebar click → scroll highlight */
.md-bnode.highlight-pulse .md-bnode-ring { animation: sidebar-highlight 0.8s ease; }
@keyframes sidebar-highlight { 0%,100% { box-shadow: 0 0 0 rgba(230,57,70,0); } 25%,75% { box-shadow: 0 0 24px rgba(230,57,70,0.6), inset 0 0 12px rgba(230,57,70,0.15); } }

/* Thumbnail below ring — in normal flow */
.md-bnode-thumb { position: relative; width: 143px; height: 80px; overflow: hidden; border: 1px solid rgba(230,57,70,0.3); box-shadow: 0 4px 16px rgba(0,0,0,0.7); margin: 4px auto 0; }
.md-bnode-thumb.pending { border-color: rgba(230,162,60,0.4); animation: thumb-pending 2s ease-in-out infinite; }
@keyframes thumb-pending { 0%,100% { box-shadow: 0 2px 12px rgba(230,162,60,0.2); } 50% { box-shadow: 0 2px 16px rgba(230,162,60,0.4); } }
.md-bnode-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.md-bnode-thumb img.loaded { opacity: 1; }
.md-bnode-thumb-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px 4px 3px; background: linear-gradient(transparent, rgba(0,0,0,0.85)); font-size: 10px; color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* Node label */
.md-bnode-label { margin-top: 6px; font-size: 12px; color: var(--p5-text-secondary); text-align: center; max-width: 156px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-bnode.done .md-bnode-label { color: var(--p5-text); }
.md-bnode-shared { font-size: 9px; color: #e6a23c; background: rgba(230,162,60,0.12); padding: 0 4px; margin-top: 2px; }

/* Board overlay on node hover */
.md-board-nodes::before { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.7); opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 19; }
.md-board-nodes:has(.md-bnode:hover)::before { opacity: 1; }

/* Hover tooltip */
.md-bnode-tip { position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%) translateY(4px); width: 286px; background: rgba(14,16,20,0.96); border: 1px solid rgba(230,57,70,0.2); padding: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 30; backdrop-filter: blur(12px); box-shadow: 0 4px 20px rgba(0,0,0,0.6); }
/* Bridge gap between node and tooltip so mouse can travel down */
.md-bnode-tip::before { content: ''; position: absolute; bottom: 100%; left: 0; right: 0; height: 12px; }
.md-bnode:hover .md-bnode-tip { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.md-bnode:hover { z-index: 25; }
.md-bnode-tip::after { content: ''; position: absolute; bottom: calc(100% - 1px); left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-bottom-color: rgba(230,57,70,0.2); }
/* Lock polling nodes — prevent double clicks */
.md-bnode.polling { pointer-events: none; cursor: not-allowed; }
/* Nodes with historical images stay clickable even when polling flag is stuck
   (e.g. stale mj_task_id from a prior run) — user can still open the selector. */
.md-bnode.polling.done,
.md-bnode.polling.has-images { pointer-events: auto; cursor: pointer; }
.md-bnode-tip-name { font-size: 14px; font-weight: 600; color: var(--p5-text); margin-bottom: 6px; }
.md-bnode-tip-desc { font-size: 12px; color: var(--p5-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 8px; }
.md-bnode-tip-type { display: inline-block; font-size: 11px; padding: 2px 8px; background: rgba(230,57,70,0.1); color: var(--p5-red); margin-bottom: 8px; }
.md-bnode-tip-thumb { width: 100%; aspect-ratio: 16/9; overflow: hidden; border: 1px solid rgba(230,57,70,0.2); margin-bottom: 8px; }
.md-bnode-tip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.md-bnode-tip-btn { display: block; width: 100%; padding: 6px; background: rgba(230,57,70,0.15); border: 1px solid rgba(230,57,70,0.3); color: var(--p5-red); font-size: 12px; text-align: center; cursor: pointer; }
.md-bnode-tip-btn:hover { background: rgba(230,57,70,0.25); }

/* Act markers on the map */
/* Act group region — spans all scenes in an act */
.md-bact-region { position: absolute; border: 1px solid rgba(230,57,70,0.12); background: rgba(230,57,70,0.02); pointer-events: none; z-index: 0; }
.md-bact-header { position: absolute; top: -1px; left: -1px; display: flex; align-items: center; gap: 0; }
.md-bact-num { width: 26px; height: 26px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.md-bact-title { font-size: 12px; color: var(--p5-text-secondary); font-weight: 600; white-space: nowrap; padding: 0 10px; height: 26px; line-height: 26px; background: rgba(230,57,70,0.08); border-bottom: 1px solid rgba(230,57,70,0.12); }

/* Pixel pet */
.md-bpet { position: absolute; z-index: 10; pointer-events: none; animation: bpet-sway 3s ease-in-out infinite; }
@keyframes bpet-sway { 0%,100% { transform: translateX(0) rotate(0deg); } 25% { transform: translateX(-3px) rotate(-2deg); } 75% { transform: translateX(3px) rotate(2deg); } }
.md-bpet-body { width: 36px; height: 36px; background: var(--p5-red); border: 2px solid #ff6b6b; display: flex; align-items: center; justify-content: center; animation: bpet-bounce 1.5s ease-in-out infinite; }
@keyframes bpet-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.md-bpet-eyes { display: flex; gap: 6px; }
.md-bpet-eye { width: 4px; height: 5px; background: #fff; animation: bpet-blink 4s ease-in-out infinite; }
.md-bpet-eye:nth-child(2) { animation-delay: 0.1s; }
@keyframes bpet-blink { 0%,42%,50%,100% { height: 5px; } 45%,47% { height: 1px; } }
.md-bpet-shadow { width: 24px; height: 6px; background: rgba(230,57,70,0.25); margin: 2px auto 0; border-radius: 50%; animation: bpet-shadow 1.5s ease-in-out infinite; }
@keyframes bpet-shadow { 0%,100% { transform: scaleX(1); opacity: 0.25; } 50% { transform: scaleX(0.7); opacity: 0.15; } }
/* Scene complete effect — ring flash + particle burst */
.md-bnode.complete-burst .md-bnode-ring { animation: ring-complete 1.2s ease; }
@keyframes ring-complete { 0% { box-shadow: 0 0 0 rgba(230,57,70,0); } 20% { box-shadow: 0 0 30px rgba(230,57,70,0.7), inset 0 0 15px rgba(230,57,70,0.2); } 100% { box-shadow: 0 0 16px rgba(230,57,70,0.15); } }
.md-burst-particle { position: absolute; width: 4px; height: 4px; background: var(--p5-red); top: 50%; left: 50%; animation: burst-fly 0.8s ease-out forwards; }
@keyframes burst-fly { 0% { transform: translate(-50%,-50%) rotate(var(--angle)) translateY(0); opacity: 1; } 100% { transform: translate(-50%,-50%) rotate(var(--angle)) translateY(-60px); opacity: 0; } }

/* Pet celebrate when scene completes */
.md-bpet.celebrate { animation: bpet-celebrate 0.6s ease; }
@keyframes bpet-celebrate { 0% { transform: translateY(0); } 20% { transform: translateY(-18px) rotate(-8deg); } 40% { transform: translateY(-12px) rotate(8deg); } 60% { transform: translateY(-8px) rotate(-4deg); } 100% { transform: translateY(0) rotate(0); } }

/* Bottom progress bar */
.md-board-progress { position: sticky; bottom: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 8px 20px; background: rgba(20,20,24,0.85); border-top: 1px solid var(--p5-border); backdrop-filter: blur(8px); z-index: 5; font-size: 11px; color: var(--p5-muted); }
.md-bprog-bar { flex: 1; max-width: 240px; height: 3px; background: var(--p5-border); }
.md-bprog-fill { height: 100%; background: var(--p5-red); transition: width 0.5s; }
.md-bprog-count { color: var(--p5-red); font-weight: 600; }

/* Scene selector — left-right split */
.md-scene-selector { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.md-sel-box { width: 640px; max-width: 92vw; max-height: 88vh; background: var(--p5-card); border: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.md-sel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.md-sel-title { font-size: 15px; font-weight: 600; color: var(--p5-text); }
.md-sel-close { background: transparent; border: 0; color: var(--p5-muted); font-size: 22px; line-height: 1; cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; padding: 0; }
.md-sel-close:hover { color: var(--p5-text); }
.md-sel-body { padding: 12px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.md-sel-label { font-size: 12px; color: var(--p5-text-secondary); margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; }
.md-sel-label-hint { color: var(--p5-muted); font-size: 11px; font-weight: normal; }
.md-sel-prompt-ta { width: 100%; background: var(--p5-input-bg); border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 12px; padding: 8px 10px; min-height: 68px; max-height: 160px; resize: vertical; font-family: 'Consolas', 'Menlo', monospace; line-height: 1.5; margin-bottom: 12px; box-sizing: border-box; border-radius: 0; }
.md-sel-prompt-ta:focus { border-color: var(--p5-red); outline: none; }
.md-sel-candidates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.md-sel-candidate { position: relative; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s, box-shadow 0.2s; aspect-ratio: 16/9; overflow: hidden; background: var(--p5-input-bg); }
.md-sel-candidate:hover { border-color: var(--p5-red); box-shadow: 0 0 0 1px var(--p5-red), 0 0 14px rgba(230,57,70,0.35); }
.md-sel-candidate.selected { border-color: var(--p5-red); }
.md-sel-candidate img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.md-sel-candidate img.loaded { opacity: 1; }
.md-sel-check { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; background: var(--p5-red); display: none; align-items: center; justify-content: center; }
.md-sel-candidate.selected .md-sel-check { display: flex; }
.md-sel-pick { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 5px 18px; background: var(--p5-red); color: #fff; border: 0; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 0; letter-spacing: 0.5px; opacity: 0.95; transition: opacity 0.2s, background 0.2s; white-space: nowrap; }
.md-sel-pick:hover { opacity: 1; background: #ff4d5e; }
.md-sel-candidate.selected .md-sel-pick { display: none; }
/* Once any candidate is selected, hide the "选择" button on the other cards too
   — the check badge on the chosen card is the sole affordance. */
.md-sel-candidates:has(.md-sel-candidate.selected) .md-sel-pick { display: none; }
.md-sel-zoom { position: absolute; bottom: 6px; right: 6px; width: 28px; height: 28px; border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s, background 0.2s; padding: 0; border-radius: 0; }
.md-sel-candidate:hover .md-sel-zoom { opacity: 1; }
.md-sel-zoom:hover { background: rgba(0,0,0,0.8); border-color: var(--p5-red); }
.md-sel-footer { padding: 10px 18px; border-top: 1px solid var(--p5-border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.md-sel-dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 2px; flex-shrink: 0; }
.md-sel-dot { width: 8px; height: 8px; background: var(--p5-border); cursor: pointer; transition: background 0.2s; border: none; padding: 0; border-radius: 0; }
.md-sel-dot:hover { background: var(--p5-muted); }
.md-sel-dot.active { background: var(--p5-red); }

/* ── Workflow stepper (inline in header, centered) ── */
.comic-workflow-bar { display: none; align-items: center; gap: 0; flex-shrink: 0; position: absolute; left: 50%; transform: translateX(-50%); }
.comic-workflow-bar.visible { display: flex; }
.comic-wf-step { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.comic-wf-step.pending { cursor: default; }
.comic-wf-step.pending .comic-wf-num { border-color: var(--p5-border); color: var(--p5-text-secondary); }
.comic-wf-step.pending .comic-wf-label { color: var(--p5-text-secondary); }
.comic-wf-step.done:hover .comic-wf-label { color: var(--p5-text); }
.comic-wf-num { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; border: 1.5px solid var(--p5-border); color: var(--p5-muted); flex-shrink: 0; }
.comic-wf-step.active .comic-wf-num { border-color: var(--p5-red); background: var(--p5-red); color: #fff; box-shadow: 0 0 8px rgba(230,57,70,0.3); }
.comic-wf-step.done .comic-wf-num { border-color: #2d8; background: #2d8; color: #fff; }
.comic-wf-label { font-size: var(--text-sm); color: var(--p5-muted); white-space: nowrap; }
.comic-wf-step.active .comic-wf-label { color: var(--p5-text); font-weight: var(--weight-semibold); }
.comic-wf-step.done .comic-wf-label { color: var(--p5-text-secondary); }
.comic-wf-line { flex: 0 0 40px; height: 0; border-top: 1.5px dashed var(--p5-border); margin: 0 10px; }
.comic-wf-line.done { border-top-style: solid; border-top-color: #2d8; }
.comic-wf-line.active { border-top-style: solid; border-image: linear-gradient(90deg, #2d8 0%, var(--p5-red) 100%) 1; }
.comic-project-search-bar { display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--p5-input-bg); border: 1px solid transparent; transition: border-color 0.15s, background 0.15s; min-width: 240px; }
.comic-project-search-bar:hover { border-color: var(--p5-border); }
.comic-project-search-bar:focus-within { border-color: var(--p5-red); background: var(--p5-dark); }
.comic-project-search-bar svg { color: var(--p5-red); flex-shrink: 0; opacity: 0.7; transition: opacity 0.15s; }
.comic-project-search-bar:focus-within svg { opacity: 1; }
.comic-project-search-bar input { flex: 1; padding: 0; background: transparent; border: none; color: var(--p5-text); font-size: var(--text-sm); font-weight: 500; outline: none; letter-spacing: 0.02em; }
.comic-project-search-bar input::placeholder { color: var(--p5-muted); font-weight: 400; letter-spacing: 0.04em; }
.as-main-header .dt-btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.as-main-header .dt-btn-primary:hover { opacity: 0.88; }
.comic-empty-center .dt-btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 10px 22px; background: var(--p5-red-gradient); border: none; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.comic-empty-center .dt-btn-primary:hover { opacity: 0.88; }

/* ── Empty state: centered on screen ── */
.comic-empty-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; color: var(--p5-muted); min-height: calc(100vh - 200px); }
.comic-empty-center svg { opacity: 0.3; }
.comic-empty-center p { font-size: 14px; max-width: 300px; line-height: 1.6; }
.comic-empty-center .dt-btn { margin-top: 8px; }

/* ── Comic project grid (V4 aligned, 2026-05-01) — cards use shared .md-proj-card ──
   Aligned with manga-drama .md-proj-grid (3 col fluid 1fr) so wide screens fill edge-to-edge. */
.comic-proj-grid-v2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-content: start; }
@media (max-width: 1100px) { .comic-proj-grid-v2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } }
@media (max-width: 720px)  { .comic-proj-grid-v2 { grid-template-columns: 1fr; gap: 12px; } }

/* Character avatar hover popup — body-level floating portrait (shared by comic + manga-drama) */
.comic-char-popup-float { position: fixed; z-index: 9999; width: 140px; background: #16161d; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 8px 24px rgba(0,0,0,0.4); display: flex; flex-direction: column; overflow: hidden; opacity: 0; transform: scale(0.85); transition: opacity 0.15s, transform 0.15s; pointer-events: none; }
.comic-char-popup-float.visible { opacity: 1; transform: scale(1); }
[data-theme="light"] .comic-char-popup-float { background: #fff; border-color: rgba(0,0,0,0.1); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.comic-char-popup-float img { width: 100%; aspect-ratio: 3/4; object-fit: cover; object-position: center top; display: block; }
.comic-char-popup-float .char-popup-name { padding: 4px 8px; font-size: 11px; font-weight: 600; color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="light"] .comic-char-popup-float .char-popup-name { color: var(--p5-text); }
.comic-char-popup-float .char-popup-placeholder { width: 100%; aspect-ratio: 3/4; background: var(--p5-dark); display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--p5-muted); font-weight: 700; }

/* Card opening — glow summon effect (migrated from .comic-project-card 2026-05-01, now attached to .md-proj-card shared by comic + manga-drama) */
.md-proj-card.card-opening { pointer-events: none; animation: cardSummonFloat 0.6s ease-out forwards; z-index: 10; position: relative; }
.md-proj-card.card-opening::after { content: ''; position: absolute; inset: -3px; z-index: 7; border: 2px solid var(--p5-red); animation: cardGlowPulse 0.5s ease-in-out infinite alternate; pointer-events: none; }
@keyframes cardSummonFloat { 0% { transform: scale(1); } 100% { transform: scale(1.06) translateY(-4px); } }
@keyframes cardGlowPulse { 0% { box-shadow: 0 0 8px rgba(230,57,70,0.4), 0 0 20px rgba(230,57,70,0.15); } 100% { box-shadow: 0 0 20px rgba(230,57,70,0.7), 0 0 50px rgba(230,57,70,0.25), 0 0 80px rgba(230,57,70,0.1); } }
/* Light sweep scanning over card */
.md-proj-card.card-opening .card-opening-overlay { position: absolute; inset: 0; z-index: 8; overflow: hidden; pointer-events: none; }
.md-proj-card.card-opening .card-summon-beam { position: absolute; top: -100%; left: -50%; width: 200%; height: 60%; background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.08) 40%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.08) 60%, transparent 100%); transform: rotate(-15deg); animation: cardBeamSweep 0.8s ease-in-out infinite; }
[data-theme="light"] .md-proj-card.card-opening .card-summon-beam { background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.3) 40%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0.3) 60%, transparent 100%); }
@keyframes cardBeamSweep { 0% { top: -60%; } 100% { top: 100%; } }
/* Stardust particles */
.card-stardust { position: absolute; width: var(--sz, 4px); height: var(--sz, 4px); background: var(--clr, #e63946); border-radius: 50%; z-index: 9; pointer-events: none; opacity: 0; animation: stardustFloat var(--dur, 1s) var(--del, 0s) ease-out forwards; box-shadow: 0 0 var(--sz, 4px) var(--clr, #e63946); }
@keyframes stardustFloat { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 60% { opacity: 0.8; } 100% { opacity: 0; transform: translate(var(--tx, 30px), var(--ty, -40px)) scale(0.2); } }

/* ── Chat header ── */
.comic-chat-header { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; position: relative; }
.comic-chat-header h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; flex-shrink: 0; }
.comic-chat-header .dt-btn-icon { background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.comic-chat-header .dt-btn-icon:hover { border-color: var(--p5-red); color: var(--p5-text); }

/* ── Chat body: sidebar + content grid ── */
.comic-chat-body { display: grid; grid-template-columns: 180px 1fr; flex: 1; min-height: 0; overflow: hidden; }
.comic-chat-body.no-sidebar { grid-template-columns: 0 1fr; }
.comic-chat-body.no-sidebar .comic-chapter-sidebar { overflow: hidden; width: 0; min-width: 0; padding: 0; border: none; }

/* ── Chapter sidebar ── */
.comic-chapter-sidebar { border-right: 1px solid var(--p5-border); padding: 16px 0; overflow-y: auto; background: var(--p5-surface); min-height: 0; }
.comic-chapter-list { display: flex; flex-direction: column; gap: 2px; }
.comic-chapter-item { padding: 8px 16px; cursor: pointer; color: var(--p5-muted); transition: all 0.15s; border-left: 3px solid transparent; }
.comic-chapter-item:hover { color: var(--p5-text); background: rgba(255,255,255,0.03); }
.comic-chapter-item.active { color: var(--p5-text); border-left-color: var(--p5-red); background: rgba(230,57,70,0.06); }
.comic-chapter-item.active .chapter-title { font-weight: 600; }
.comic-chapter-item.locked { opacity: 0.5; pointer-events: none; }
.comic-chapter-item .chapter-title { font-size: var(--text-sm); color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-chapter-item .chapter-preview { font-size: var(--text-xs); color: var(--p5-text-secondary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-chapter-divider { height: 1px; background: var(--p5-border); margin: 8px 16px; }

/* ── Chat right column (messages + input) ── */
.comic-chat-right { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* ── Chat messages area ── */
.comic-chat-messages { flex: 1; overflow-y: auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 24px; min-height: 0; }
.comic-chat-messages.empty-chat { justify-content: center; align-items: center; text-align: center; }
.comic-chat-messages.empty-chat > * { width: auto; max-width: 500px; }
.comic-chat-messages > * { max-width: 780px; width: 100%; margin: 0 auto; }

/* ── Section anchors ── */
.comic-section { scroll-margin-top: 16px; margin-top: 8px; }
.comic-section-label { font-size: var(--text-sm); color: var(--p5-text-secondary); letter-spacing: 0.5px; padding: 8px 0 8px; border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, var(--p5-red), transparent) 1; margin-bottom: 12px; font-weight: var(--weight-medium); animation: comicFadeIn 0.4s ease; }

/* ── Chat bubbles ── */
.comic-msg { padding: 16px 24px; font-size: var(--text-base); line-height: var(--leading-relaxed); color: var(--p5-text); }
.comic-msg.user { background: transparent; border: none; padding: 0; display: flex; justify-content: flex-end; }
.comic-user-bubble { max-width: 66%; padding: 12px 16px; background: var(--p5-card); color: var(--p5-text); border: 1px solid var(--p5-border); border-left: 3px solid var(--p5-red); font-size: var(--text-base); line-height: var(--leading-normal); }
.comic-action-bubble { display: inline-flex; align-items: center; gap: 6px; border-left-color: var(--p5-muted); font-size: var(--text-sm); color: var(--p5-text-secondary); padding: 8px 16px; }
.comic-msg.assistant { align-self: center; background: rgba(255,255,255,0.03); color: var(--p5-text); border: 1px solid rgba(255,255,255,0.06); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 2px 16px rgba(0,0,0,0.2); transition: box-shadow 0.3s, border-color 0.3s; animation: comicFadeIn 0.4s ease; }
.comic-msg.assistant:hover { box-shadow: 0 4px 24px rgba(0,0,0,0.3); border-color: rgba(255,255,255,0.10); }
.comic-msg.assistant h2 { font-size: var(--text-md); margin: 14px 0 6px; color: var(--p5-red-light); font-weight: var(--weight-bold); }
.comic-msg.assistant h3 { font-size: var(--text-base); margin: 10px 0 4px; color: var(--p5-text); font-weight: var(--weight-semibold); }
.comic-msg.assistant strong { color: var(--p5-red-light); }
.comic-msg.assistant ul, .comic-msg.assistant ol { padding-left: 20px; margin: 6px 0; }
.comic-msg.assistant li { margin-bottom: 2px; }
.comic-msg.system { align-self: center; background: rgba(230,57,70,0.06); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(230,57,70,0.12); color: var(--p5-text); font-size: var(--text-base); padding: 10px 24px; text-align: center; max-width: 600px; margin: 4px auto; }

/* ── Comic welcome guide (empty state) ── */
/* ── Magic Book welcome ── */
.comic-welcome-guide { display: flex; align-items: center; justify-content: center; padding: 0; width: 100% !important; height: 100%; max-width: 100% !important; }

/* Book container + open animation */
.comic-book { display: flex; width: min(92%, 1200px); height: min(72vh, 560px); animation: comicBookOpen 0.8s cubic-bezier(.22,.68,.36,1) forwards, comicBookGlow 4s ease-in-out 1s infinite; transform-origin: center center; box-shadow: 0 0 40px rgba(230,57,70,0.15), 0 0 80px rgba(230,57,70,0.06), 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(230,57,70,0.18); position: relative; }
@keyframes comicBookGlow { 0%, 100% { box-shadow: 0 0 40px rgba(230,57,70,0.12), 0 0 80px rgba(230,57,70,0.06), 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(230,57,70,0.15); } 50% { box-shadow: 0 0 50px rgba(230,57,70,0.18), 0 0 100px rgba(230,57,70,0.08), 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(230,57,70,0.22); } }
[data-theme="light"] .comic-book { box-shadow: 0 16px 48px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.08); }
@keyframes comicBookOpen { 0% { transform: perspective(1200px) rotateY(-12deg) scale(0.9); opacity: 0; } 100% { transform: perspective(1200px) rotateY(0) scale(1); opacity: 1; } }

/* Left page — title + description */
.comic-book-left { flex: 0 0 46%; padding: 52px 48px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; min-width: 0; }
.comic-book-left { background: #1d1a26; border: 1px solid rgba(230,57,70,0.12); border-right: none; }
[data-theme="light"] .comic-book-left { background: linear-gradient(160deg, #fffcf8 0%, #fdf6ee 50%, #faf5ef 100%); border-color: rgba(0,0,0,0.06); }
/* Inner page shadow — fold crease (light theme only) */
.comic-book-left::after { content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 30px; background: none; pointer-events: none; }
[data-theme="light"] .comic-book-left::after { background: linear-gradient(90deg, transparent, rgba(0,0,0,0.03)); }

/* Corner marks — hidden */
.comic-book-left .book-corner { display: none; }

/* Left page content */
.comic-book-icon { margin-bottom: 24px; color: var(--p5-red); opacity: 0.8; }
.comic-book-left h3 { font-size: 28px; font-weight: 700; color: #fff; margin: 0 0 18px; letter-spacing: 1px; line-height: 1.3; text-align: left; white-space: nowrap; }
[data-theme="light"] .comic-book-left h3 { color: var(--p5-text); }
.comic-book-left p { font-size: 14px; line-height: 1.8; color: rgba(255,255,255,0.4); margin: 0; text-align: left; }
[data-theme="light"] .comic-book-left p { color: var(--p5-muted); }

/* Spine */
.comic-book-spine { width: 10px; flex-shrink: 0; background: linear-gradient(180deg, #c1272d 0%, #8b1a22 30%, #e63946 50%, #8b1a22 70%, #c1272d 100%); box-shadow: -3px 0 12px rgba(230,57,70,0.15), 3px 0 12px rgba(230,57,70,0.15), 0 0 20px rgba(230,57,70,0.3), -8px 0 25px rgba(230,57,70,0.08), 8px 0 25px rgba(230,57,70,0.08); position: relative; }
[data-theme="light"] .comic-book-spine { box-shadow: -1px 0 4px rgba(0,0,0,0.08), 1px 0 4px rgba(0,0,0,0.08), 0 0 8px rgba(230,57,70,0.1); }
/* Spine stitch marks */
.comic-book-spine::before { content: ''; position: absolute; top: 20px; bottom: 20px; left: 50%; width: 1px; border-left: 1px dashed rgba(255,255,255,0.15); transform: translateX(-50%); }

/* Right page — input */
.comic-book-right { flex: 1; padding: 32px 36px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.comic-book-right { background: linear-gradient(160deg, #1c1926 0%, #191620 50%, #16131e 100%); border: 1px solid rgba(230,57,70,0.1); border-left: none; }
[data-theme="light"] .comic-book-right { background: linear-gradient(160deg, #fdfaf5 0%, #faf6f0 50%, #f8f3ec 100%); border-color: rgba(0,0,0,0.06); }
/* Inner page shadow — fold crease */
.comic-book-right::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 30px; background: none; pointer-events: none; z-index: 1; }
[data-theme="light"] .comic-book-right::before { background: linear-gradient(270deg, transparent, rgba(0,0,0,0.03)); }

/* Right page header with icon */
.comic-book-right .book-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.comic-book-right .book-header svg { color: rgba(255,255,255,0.25); flex-shrink: 0; }
[data-theme="light"] .comic-book-right .book-header svg { color: var(--p5-muted); }
.comic-book-right .book-header span { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.3); letter-spacing: 0.5px; }
[data-theme="light"] .comic-book-right .book-header span { color: var(--p5-muted); }

/* Inspiration tags */
.comic-book-right .book-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.comic-book-right .book-tag { padding: 5px 12px; font-size: 12px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03); color: rgba(255,255,255,0.45); cursor: pointer; transition: all 0.2s; }
.comic-book-right .book-tag:hover { border-color: rgba(230,57,70,0.4); color: var(--p5-red); background: rgba(230,57,70,0.06); }
[data-theme="light"] .comic-book-right .book-tag { border-color: rgba(0,0,0,0.08); background: rgba(0,0,0,0.02); color: var(--p5-text-secondary); }
[data-theme="light"] .comic-book-right .book-tag:hover { border-color: rgba(230,57,70,0.3); color: var(--p5-red); background: rgba(230,57,70,0.04); }

/* Input area inside book — lined paper effect */
.comic-book-right .book-input-wrap { flex: 1; position: relative; display: flex; flex-direction: column; min-height: 0; }
.comic-book-right .book-textarea { flex: 1; width: 100%; padding: 16px 18px; font-size: 14px; font-family: inherit; resize: none; outline: none; line-height: 28px; background-image: repeating-linear-gradient(transparent, transparent 27.5px, rgba(255,255,255,0.045) 27.5px, rgba(255,255,255,0.045) 28px); background-position: 0 16px; }
.comic-book-right .book-textarea { background-color: transparent; border: 1px solid rgba(255,255,255,0.06); color: var(--p5-text); }
[data-theme="light"] .comic-book-right .book-textarea { background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(0,0,0,0.04) 27px, rgba(0,0,0,0.04) 28px); border-color: rgba(0,0,0,0.07); }
.comic-book-right .book-textarea:focus { border-color: rgba(230,57,70,0.3); }
.comic-book-right .book-textarea::placeholder { color: rgba(255,255,255,0.15); }
[data-theme="light"] .comic-book-right .book-textarea::placeholder { color: var(--p5-muted); }

/* Send row */
.comic-book-right .book-send-row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.comic-book-right .book-char-count { font-size: 11px; color: rgba(255,255,255,0.2); }
[data-theme="light"] .comic-book-right .book-char-count { color: var(--p5-muted); }
.comic-book-right .book-send-btn { background: var(--p5-red); border: none; color: #fff; padding: 10px 26px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
.comic-book-right .book-send-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.comic-book-right .book-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.comic-book-right .book-send-btn:disabled:hover { opacity: 0.5; transform: none; }

/* ============================================================
   漫剧新建页 · 方案 C · 时间线创作台(Scheme C Timeline Workbench)
   复用 .comic-welcome-guide / .comic-book / .comic-book-left / .comic-book-spine / .comic-book-right 骨架
   仅左页内容换为 DAW timeline + 书脊 dark 黑底红激光扫描 / light C4 拉链斜纹
   ============================================================ */
/* 书整体偏长(像翻开的书)+ 左右页等宽(grid 强制)+ 响应式 aspect-ratio 1.46:1 锁定比例,playhead 跟高联动 */
.md-welcome-timeline.comic-welcome-guide .comic-book,
.md-welcome-timeline .comic-book {
  --md-book-w: clamp(680px, 62vw, 1400px);
  --md-book-h: calc(var(--md-book-w) / 1.46);
  width: var(--md-book-w);
  height: var(--md-book-h);
  max-height: 86vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
}

.md-welcome-timeline .comic-book-left { padding: clamp(20px, 1.8vw, 38px) clamp(22px, 2vw, 42px) clamp(22px, 2vw, 42px) clamp(14px, 1.3vw, 28px); justify-content: flex-start; gap: clamp(3px, 0.3vw, 8px); text-align: left; min-width: 0; }
.md-welcome-timeline .comic-book-right { min-width: 0; }
/* timecode + label 左对齐 */
.md-welcome-timeline .md-timecode { text-align: left; }
.md-welcome-timeline .md-timecode-label { text-align: left; }
/* subtitle(你的故事·空轨道)推到左页最底部 */
.md-welcome-timeline .md-left-subtitle { margin-top: auto; margin-bottom: 4px; }
/* Playhead 红线延伸到书页底部 */
.md-welcome-timeline .md-tracks { overflow: visible; }
/* playhead 延伸到 subtitle 上方:min() 双公式约束(vw 外推管大屏,book-h*0.45 管小屏 tracks-clamp-min 场景),两端都不越过 subtitle;max 100px 兜底极小屏 */
.md-welcome-timeline .md-playhead::after { content: ''; position: absolute; top: 100%; left: 0; width: 2px; height: max(100px, min(calc(20vw - 60px), calc(var(--md-book-h) * 0.45), 460px)); background: var(--p5-red); box-shadow: 0 0 8px var(--p5-red), 0 0 16px rgba(230,57,70,0.5); }
[data-theme="light"] .md-welcome-timeline .comic-book-left { background: linear-gradient(160deg, #fffcf8 0%, #fdf6ee 50%, #faf5ef 100%); }

.md-welcome-timeline .md-timecode { font-family: 'Consolas','Courier New',monospace; font-size: clamp(28px, 2.2vw, 52px); font-weight: 700; letter-spacing: clamp(2px, 0.2vw, 5px); color: var(--p5-red); margin-bottom: clamp(3px, 0.3vw, 7px); line-height: 1.1; text-shadow: 0 0 18px rgba(230,57,70,0.4); }
[data-theme="light"] .md-welcome-timeline .md-timecode { text-shadow: none; }

.md-welcome-timeline .md-timecode-label { font-family: 'Consolas','Courier New',monospace; font-size: clamp(9px, 0.75vw, 14px); letter-spacing: clamp(2px, 0.2vw, 4px); color: var(--p5-muted); margin-bottom: clamp(10px, 1vw, 22px); opacity: 0.8; }

.md-welcome-timeline .md-ruler { height: clamp(20px, 1.7vw, 32px); background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; position: relative; margin-bottom: clamp(6px, 0.6vw, 14px); }
[data-theme="light"] .md-welcome-timeline .md-ruler { background: rgba(0,0,0,0.08); }
.md-welcome-timeline .md-ruler-tick { flex: 1; border-left: 1px solid rgba(255,255,255,0.15); height: clamp(7px, 0.7vw, 12px); font-size: clamp(7px, 0.6vw, 11px); color: rgba(255,255,255,0.4); padding-left: 2px; line-height: 1; font-family: 'Consolas',monospace; }
[data-theme="light"] .md-welcome-timeline .md-ruler-tick { border-color: rgba(0,0,0,0.2); color: rgba(0,0,0,0.45); }
.md-welcome-timeline .md-ruler-tick:nth-child(4n+1) { height: clamp(14px, 1.3vw, 22px); }

.md-welcome-timeline .md-tracks { flex: 0 0 auto; display: flex; flex-direction: column; gap: clamp(4px, 0.4vw, 9px); position: relative; min-height: 0; }
.md-welcome-timeline .md-track { height: clamp(36px, 3.2vw, 62px); }
.md-welcome-timeline .md-playhead { position: absolute; top: 0; bottom: 0; left: 28%; width: 2px; background: var(--p5-red); box-shadow: 0 0 8px var(--p5-red), 0 0 16px rgba(230,57,70,0.5); z-index: 5; pointer-events: none; }
.md-welcome-timeline .md-playhead::before { content: ''; position: absolute; top: -4px; left: -4px; width: 10px; height: 7px; background: var(--p5-red); }
.md-welcome-timeline .md-track { min-height: 36px; flex: 1; display: flex; align-items: center; background: rgba(0,0,0,0.5); }
[data-theme="light"] .md-welcome-timeline .md-track { background: rgba(0,0,0,0.08); }
.md-welcome-timeline .md-track-name { width: clamp(72px, 5.8vw, 110px); font-size: clamp(8px, 0.7vw, 12px); letter-spacing: 0.6px; padding: 0 clamp(4px, 0.35vw, 8px); opacity: 0.7; flex-shrink: 0; font-family: 'Consolas','Courier New',monospace; white-space: nowrap; overflow: hidden; text-overflow: clip; }
[data-theme="light"] .md-welcome-timeline .md-track-name { color: var(--p5-text-secondary); }
.md-welcome-timeline .md-wave { flex: 1; height: 100%; position: relative; overflow: hidden; }
.md-welcome-timeline .md-wave-v { background: linear-gradient(180deg, rgba(140,90,230,0.3), rgba(100,60,200,0.15)); }
.md-welcome-timeline .md-wave-d { background: linear-gradient(180deg, rgba(80,200,130,0.3), rgba(60,170,110,0.15)); }
.md-welcome-timeline .md-wave-b { background: linear-gradient(180deg, rgba(255,160,60,0.3), rgba(230,130,40,0.15)); }
.md-welcome-timeline .md-wave-s { background: rgba(0,0,0,0.2); }
[data-theme="light"] .md-welcome-timeline .md-wave-s { background: rgba(0,0,0,0.05); }
.md-welcome-timeline .md-wave-s::after { content: 'waiting…'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 10px; opacity: 0.35; letter-spacing: 2px; font-family: 'Consolas',monospace; }
.md-welcome-timeline .md-wave svg { width: 100%; height: 100%; display: block; }

.md-welcome-timeline .md-left-subtitle { font-size: clamp(10px, 0.85vw, 14px); opacity: 0.55; letter-spacing: clamp(1.5px, 0.15vw, 3px); margin-top: auto; margin-bottom: 4px; text-align: center; color: var(--p5-text-secondary); }

/* 右页副标题(在 "写下你的灵感" 下方,inputbox 上方) */
.md-welcome-timeline .book-subtitle { font-size: clamp(11px, 0.9vw, 15px); line-height: 1.7; color: rgba(255,255,255,0.35); margin: clamp(-8px, -0.6vw, -4px) 0 clamp(10px, 1.1vw, 20px); letter-spacing: 0.3px; text-align: left; }
[data-theme="light"] .md-welcome-timeline .book-subtitle { color: var(--p5-muted); }

/* 右页 padding + h3 + textarea + send-btn + char-count 响应式 */
.md-welcome-timeline .comic-book-right { padding: clamp(20px, 1.8vw, 40px) clamp(22px, 2.2vw, 48px) clamp(22px, 2vw, 42px); }
.md-welcome-timeline .comic-book-right .book-header { margin-bottom: clamp(10px, 1vw, 20px); gap: clamp(8px, 0.7vw, 14px); }
.md-welcome-timeline .comic-book-right .book-header h3 { font-size: clamp(15px, 1.2vw, 22px); font-weight: 600; margin: 0; letter-spacing: 0.5px; color: var(--p5-text); }
.md-welcome-timeline .comic-book-right .book-header svg { width: clamp(14px, 1.1vw, 20px); height: clamp(14px, 1.1vw, 20px); }
.md-welcome-timeline .comic-book-right .book-textarea { font-size: clamp(12px, 1vw, 17px); padding: clamp(12px, 1vw, 20px) clamp(14px, 1.2vw, 22px); }
.md-welcome-timeline .comic-book-right .book-send-row { margin-top: clamp(10px, 1vw, 20px); }
.md-welcome-timeline .comic-book-right .book-char-count { font-size: clamp(10px, 0.8vw, 13px); }
.md-welcome-timeline .comic-book-right .book-send-btn { padding: clamp(8px, 0.75vw, 14px) clamp(20px, 1.9vw, 36px); font-size: clamp(12px, 1vw, 16px); }
.md-welcome-timeline .comic-book-right .book-send-btn svg { width: clamp(12px, 1vw, 18px); height: clamp(12px, 1vw, 18px); }

/* === 书脊(DARK 默认): 纯黑底 + 红色激光扫描动画 === */
.md-welcome-timeline .comic-book-spine { background: #000; overflow: hidden; position: relative; width: 12px; flex: 0 0 12px; }
.md-welcome-timeline .comic-book-spine::before,
.md-welcome-timeline .comic-book-spine::after { content: ''; position: absolute; left: 0; right: 0; }
.md-welcome-timeline .comic-book-spine::after { top: -20%; height: 30%; background: linear-gradient(180deg, transparent, var(--p5-red), transparent); filter: blur(3px); box-shadow: 0 0 15px var(--p5-red); animation: mdSpineLaser 2s linear infinite; }
@keyframes mdSpineLaser { 0% { top: -30%; } 100% { top: 120%; } }

/* === 书脊 LIGHT: C4 拉链斜纹(45° 细密斜线,胶片齿痕质感)=== */
[data-theme="light"] .md-welcome-timeline .comic-book-spine { background: repeating-linear-gradient(45deg, rgba(0,0,0,0.1) 0 2px, transparent 2px 5px), linear-gradient(180deg, #ddd5c6, #d0c7b5 50%, #ddd5c6); }
[data-theme="light"] .md-welcome-timeline .comic-book-spine::after { display: none; }

/* === 右页右上小字 V1 · DRAFT,右上 counter 字体等距 === */
.md-welcome-timeline .comic-book-right { padding-top: 28px; }
.md-welcome-timeline .book-char-count { font-family: 'Consolas','Courier New',monospace; font-weight: 600; letter-spacing: 1px; }

.comic-welcome-hint {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); color: var(--p5-muted);
  margin-top: 8px;
}

/* ── Chat action buttons (inside assistant card) ── */
.comic-actions { display: flex; gap: 10px; justify-content: center; padding: 16px 0 4px; margin-top: 16px; border-top: 1px solid var(--p5-border); }
.comic-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; font-size: var(--text-sm); font-weight: var(--weight-medium); border: 1px solid var(--p5-border); background: var(--p5-card); color: var(--p5-text); cursor: pointer; transition: all 0.2s; }
.comic-actions button:hover { border-color: var(--p5-red); color: #fff; background: var(--p5-dark); }
.comic-actions button.primary { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }
.comic-actions button.primary:hover { background: var(--p5-red-light); border-color: var(--p5-red-light); }
.comic-actions button svg { flex-shrink: 0; }

/* ── Streaming indicator ── */
.comic-typing { display: flex; gap: 5px; padding: 12px 16px; align-self: center; }
.comic-typing span { width: 7px; height: 7px; background: var(--p5-muted); display: inline-block; animation: comicBounce 1.4s infinite; }
.comic-typing span:nth-child(2) { animation-delay: 0.2s; }
.comic-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes comicBounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes comicFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Input bar: unified container (selector + textarea + send) ── */
.comic-chat-input-bar { flex-shrink: 0; padding: 10px 20px 12px; border-top: 1px solid var(--p5-border); }
.comic-input-container { position: relative; max-width: 780px; margin: 0 auto; background: var(--p5-input-bg); border: 1px solid var(--p5-red); display: flex; flex-direction: column; transition: border-color 0.2s; }
.comic-input-container:focus-within { border-color: var(--p5-red); }
.comic-revision-close { position: absolute; top: 6px; right: 6px; background: none; border: none; color: var(--p5-muted); cursor: pointer; padding: 4px; z-index: 1; }
.comic-revision-close:hover { color: var(--p5-red); }
.comic-input { flex: 1; resize: none; background: transparent; border: none; color: var(--p5-text); padding: 10px 16px 6px; font-size: var(--text-base); font-family: inherit; line-height: var(--leading-normal); min-height: 40px; max-height: 120px; outline: none; }
.comic-input::placeholder { color: var(--p5-muted); }
.comic-input-footer { display: flex; align-items: center; gap: 10px; padding: 4px 10px 6px; }
.comic-char-count { font-size: var(--text-xs); color: var(--p5-muted); font-variant-numeric: tabular-nums; margin-left: auto; margin-right: 6px; }
.comic-char-count.near-limit { color: var(--p5-red); }
.comic-mode-select { padding: 5px 10px; background: var(--p5-card); border: 1px solid var(--p5-border); color: var(--p5-muted); font-size: 12px; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2370708a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }
.comic-mode-select:hover { border-color: var(--p5-red); color: var(--p5-text); }
.comic-mode-select option { background: var(--p5-card); color: var(--p5-text); padding: 6px 10px; }
/* ── Character attribute cards ── */
.comic-char-card { margin: 4px 0; padding: 6px 12px; background: rgba(230,57,70,0.04); border-left: 3px solid var(--p5-red); }
.comic-char-attr { display: flex; gap: 8px; padding: 2px 0; }
.comic-char-label { color: var(--p5-red-light); font-weight: 600; white-space: nowrap; min-width: 2.5em; flex-shrink: 0; font-size: var(--text-sm); }
.comic-char-value { color: var(--p5-text); flex: 1; line-height: 1.4; font-size: var(--text-sm); }
[data-theme="light"] .comic-char-card { background: rgba(230,57,70,0.05); }
[data-theme="light"] .comic-msg.assistant { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.06); box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
[data-theme="light"] .comic-msg.assistant:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.10); border-color: rgba(0,0,0,0.10); }

.comic-send-btn { margin-left: 0; width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; background: var(--p5-red); border: none; color: #fff; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.comic-send-btn:hover { background: var(--p5-red-light); }
.comic-send-btn:disabled { opacity: 0.4; cursor: default; }

.comic-no-asset-hint { font-size: var(--text-xs); color: var(--p5-red); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; opacity: 0.85; transition: opacity 0.2s; }
.comic-no-asset-hint:hover { opacity: 1; }

/* ── Asset Ref Cards (stacked deck) ── */
.comic-ref-cards { position: absolute; left: 6px; bottom: 100%; display: flex; align-items: flex-end; height: 80px; pointer-events: none; z-index: 10; }
.comic-ref-cards:empty { display: none; }
.comic-ref-card { position: absolute; left: 0; bottom: 0; width: 48px; height: 64px; overflow: hidden; border: 1px solid var(--p5-border); cursor: pointer; pointer-events: auto; box-shadow: 0 2px 8px rgba(0,0,0,0.3); transition: transform 0.5s cubic-bezier(0.25,0.1,0.25,1), box-shadow 0.4s, z-index 0s; transform-origin: bottom left; }
.comic-ref-card:nth-child(1) { z-index: 5; transform: rotate(-8deg); }
.comic-ref-card:nth-child(2) { z-index: 4; transform: rotate(-3deg) translateX(18px); }
.comic-ref-card:nth-child(3) { z-index: 3; transform: rotate(4deg) translateX(36px); }
.comic-ref-card:nth-child(4) { z-index: 2; transform: rotate(9deg) translateX(54px); }
.comic-ref-card:nth-child(5) { z-index: 1; transform: rotate(13deg) translateX(72px); }
.comic-ref-card:hover { transform: translateY(-20px) rotate(0deg) scale(1.15) !important; box-shadow: 0 8px 24px rgba(230,57,70,0.35); z-index: 20 !important; }
.comic-ref-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comic-ref-card-del { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; background: rgba(0,0,0,0.6); color: #fff; font-size: 10px; line-height: 16px; text-align: center; cursor: pointer; opacity: 0; transition: opacity 0.2s; z-index: 3; }
.comic-ref-card:hover .comic-ref-card-del { opacity: 1; }
.comic-ref-card-del:hover { background: var(--p5-red); }
.comic-ref-card-name { position: absolute; bottom: 0; left: 0; right: 0; padding: 1px 3px; background: linear-gradient(transparent, rgba(0,0,0,0.7)); color: #fff; font-size: 8px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity 0.25s; }
.comic-ref-card:hover .comic-ref-card-name { opacity: 1; }

/* ── Asset Ref Toggle ── */
.comic-ref-toggle { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--p5-muted); cursor: pointer; user-select: none; transition: color 0.2s; }
.comic-ref-toggle:hover { color: var(--p5-text); }
.comic-ref-toggle:has(input:checked) { color: var(--p5-red); }
.comic-ref-toggle:has(input:checked) svg { stroke: var(--p5-red); }
.comic-ref-toggle input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--p5-red); margin: 0; cursor: pointer; }
.comic-ref-toggle svg { flex-shrink: 0; }

/* ── @ Mention Picker ── */
.comic-at-picker { position: fixed; z-index: 200; background: var(--p5-surface); border: 1px solid var(--p5-border); box-shadow: 0 -4px 20px rgba(0,0,0,0.25); max-height: 360px; display: flex; flex-direction: column; overflow: hidden; }
.comic-at-header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.comic-at-search { flex: 1; border: 1px solid var(--p5-border); background: var(--p5-bg); color: var(--p5-text); padding: 5px 8px; font-size: 12px; outline: none; }
.comic-at-search:focus { border-color: var(--p5-red); }
.comic-at-back { background: none; border: none; color: var(--p5-muted); cursor: pointer; padding: 2px; display: flex; }
.comic-at-back:hover { color: var(--p5-text); }
.comic-at-title { font-size: 12px; font-weight: 600; color: var(--p5-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-at-list { flex: 1; overflow-y: auto; min-height: 0; }
.comic-at-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 12px; color: var(--p5-text); transition: background 0.15s; }
.comic-at-item:hover { background: var(--p5-hover); }
.comic-at-thumb { width: 32px; height: 32px; object-fit: cover; flex-shrink: 0; }
.comic-at-type-icon { flex-shrink: 0; color: var(--p5-muted); }
.comic-at-count { margin-left: auto; font-size: 11px; color: var(--p5-muted); }
.comic-at-deriv-count { font-size: 10px; color: var(--p5-red); background: rgba(230,57,70,0.1); padding: 1px 5px; }
.comic-at-expand { background: none; border: none; color: var(--p5-muted); cursor: pointer; margin-left: auto; padding: 4px; display: flex; }
.comic-at-expand:hover { color: var(--p5-red); }
.comic-at-empty { padding: 20px; text-align: center; font-size: 12px; color: var(--p5-muted); }
.comic-at-divider { padding: 6px 10px 4px; font-size: 10px; color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; border-top: 1px solid var(--p5-border); margin-top: 4px; }
.comic-at-refs { padding-bottom: 4px; }
.comic-at-ref-item { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px; color: var(--p5-text); transition: background 0.15s; }
.comic-at-ref-item:hover { background: var(--p5-hover); }
.comic-at-ref-item.checked { background: rgba(230,57,70,0.06); }
.comic-at-ref-item input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--p5-red); margin: 0; flex-shrink: 0; cursor: pointer; }
.comic-at-ref-thumb { width: 40px; height: 40px; object-fit: cover; flex-shrink: 0; }
.comic-at-footer { padding: 8px 10px; border-top: 1px solid var(--p5-border); flex-shrink: 0; display: flex; justify-content: flex-end; }

/* ── Reopen Progress Button (top-right float) ── */
.comic-reopen-float {
  position: fixed; top: 110px; right: 24px; z-index: 100;
  display: none; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--p5-red); color: #fff;
  border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 8px rgba(230,57,70,0.3);
  animation: comicReopenPulse 2s ease-in-out infinite;
}
.comic-reopen-float:hover { background: #d32f3f; }
.comic-reopen-float::before { content: '■'; font-size: 10px; color: rgba(255,255,255,0.8); }
@keyframes comicReopenPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(230,57,70,0.3); }
  50% { box-shadow: 0 2px 16px rgba(230,57,70,0.5); }
}

/* ── DAG Progress Panel (floating bottom bar, shared across sub-panels) ── */
.comic-dag { position: absolute; bottom: 0; left: 0; right: 0; z-index: 20; border-top: 1px solid var(--p5-border); background: var(--p5-surface); }
.comic-dag-header { display: flex; align-items: center; gap: 8px; padding: 8px 20px; cursor: pointer; font-size: 13px; color: var(--p5-text-secondary); user-select: none; transition: color 0.2s; }
.comic-dag-header:hover { color: var(--p5-text); }
.comic-dag-header svg { transition: transform 0.2s; }
.comic-dag.collapsed .comic-dag-header svg { transform: rotate(-90deg); }
.comic-dag.collapsed .comic-dag-steps { display: none; }
.comic-dag-steps { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 10px; max-width: 780px; margin: 0 auto; }
.comic-dag-step { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--p5-card); border: 1px solid var(--p5-border); font-size: 13px; color: var(--p5-text-secondary); transition: all 0.3s; min-width: 0; }
.comic-dag-step[data-status="running"] { border-color: var(--p5-red); color: var(--p5-red); animation: comicPulse 1.5s infinite; }
.comic-dag-step[data-status="done"] { border-color: #2d8; color: #2d8; }
.comic-dag-step[data-status="failed"] { border-color: #ff6b6b; color: #ff6b6b; }
.comic-dag-step .dag-icon { width: 16px; height: 16px; flex-shrink: 0; }
.comic-dag-step .dag-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-dag-step .dag-timer { font-family: monospace; font-size: 12px; opacity: 0.8; margin-left: auto; }
.comic-dag-step[data-status="running"] .dag-timer { color: var(--p5-red); opacity: 1; }
.comic-dag-step[data-status="done"] .dag-timer { color: #2d8; }
@keyframes comicPulse { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 0 2px rgba(230,57,70,0.15); } }

/* Style search bar */
.comic-style-search { display: flex; align-items: center; justify-content: center; padding: 16px 32px 12px; flex-shrink: 0; }
.comic-style-search .style-search-wrap { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 400px; padding: 8px 16px; background: var(--p5-input-bg); border: 1px solid var(--p5-border); transition: border-color 0.2s; }
.comic-style-search .style-search-wrap:focus-within { border-color: var(--p5-red); }
.comic-style-search svg { color: var(--p5-muted); flex-shrink: 0; }
.comic-style-search input { flex: 1; padding: 0; background: transparent; border: none; color: var(--p5-text); font-size: var(--text-sm); outline: none; }
.comic-style-search input::placeholder { color: var(--p5-muted); }

/* Style selection grid — hero + mini floating cards */
.comic-style-grid { display: grid; grid-template-columns: repeat(4, minmax(200px, 280px)); gap: 30px; padding: 24px 32px; overflow-y: auto; flex: 1; align-content: start; justify-content: center; }
@media (max-width: 1400px) { .comic-style-grid { grid-template-columns: repeat(3, minmax(200px, 280px)); } }
@media (max-width: 1000px) { .comic-style-grid { grid-template-columns: repeat(2, 1fr); } }
/* Loader for style panel */
.comic-loader-wrap { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; min-height: 300px; }
.comic-style-card { background: var(--p5-card); border: 2px solid var(--p5-border); cursor: pointer; transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s; position: relative; }
.comic-style-card:hover { border-color: var(--p5-red-light); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.comic-style-card.selected { border-color: var(--p5-red); box-shadow: 0 0 0 3px rgba(230,57,70,0.35), 0 8px 24px rgba(230,57,70,0.15); }
.comic-style-card.pending { border-color: var(--p5-red); }
/* Hero image area */
.style-card-visual { position: relative; overflow: hidden; }
.style-hero-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; transition: opacity 0.4s; opacity: 0; background: var(--p5-dark); }
.style-hero-img.loaded { opacity: 1; }
/* Bottom gradient overlay + name on image */
.style-card-visual::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 45%; background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.35) 50%, transparent 100%); pointer-events: none; z-index: 1; }
.style-overlay-name { position: absolute; bottom: 0; left: 0; right: 0; z-index: 3; padding: 10px 12px 8px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.style-overlay-name .style-name { flex: 1; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.style-overlay-name .style-select-btn { pointer-events: auto; flex-shrink: 0; padding: 3px 10px; font-size: 11px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.4); color: #fff; cursor: pointer; transition: all 0.2s; backdrop-filter: blur(4px); }
.style-overlay-name .style-select-btn:hover { background: rgba(230,57,70,0.7); border-color: var(--p5-red); }
.comic-style-card.selected .style-select-btn { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }
/* Zoom button — top-left */
.style-zoom-btn { position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); border: none; color: #fff; cursor: pointer; opacity: 0; transition: opacity 0.25s, background 0.2s; z-index: 3; backdrop-filter: blur(4px); }
.comic-style-card:hover .style-zoom-btn { opacity: 1; }
.style-zoom-btn:hover { background: rgba(230,57,70,0.8); }
/* Mini card stack — bottom-right, above gradient */
.style-mini-stack { position: absolute; bottom: 36px; right: 8px; width: 100px; height: 100px; z-index: 3; }
.style-mini-card { position: absolute; bottom: 0; right: 0; width: 58px; height: 76px; border: 2px solid rgba(0,0,0,0.7); box-shadow: 0 3px 10px rgba(0,0,0,0.5); cursor: pointer; transition: transform 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease; overflow: hidden; background: var(--p5-dark); }
[data-theme="light"] .style-mini-card { border-color: rgba(255,255,255,0.8); }
.style-mini-card::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.3); transition: opacity 0.6s ease; pointer-events: none; z-index: 1; }
.style-mini-card:hover::after { opacity: 0; }
/* Stacked state — collapsed */
.style-mini-card:nth-child(1) { transform: translate(-28px, -24px) rotate(-8deg); z-index: 1; }
.style-mini-card:nth-child(2) { transform: translate(-12px, -10px) rotate(-2deg); z-index: 2; }
.style-mini-card:nth-child(3) { transform: translate(0, 0) rotate(5deg); z-index: 3; }
/* Hover on stack → fan out, no rotation */
.style-mini-stack:hover .style-mini-card:nth-child(1) { transform: translate(-76px, -8px) rotate(0deg); }
.style-mini-stack:hover .style-mini-card:nth-child(2) { transform: translate(-38px, -4px) rotate(0deg); }
.style-mini-stack:hover .style-mini-card:nth-child(3) { transform: translate(0, 0) rotate(0deg); }
/* Individual card hover — NO position change, only glow highlight */
.style-mini-card:hover { border-color: rgba(255,255,255,0.8); box-shadow: 0 0 12px rgba(255,255,255,0.3), 0 4px 12px rgba(0,0,0,0.5); z-index: 10 !important; }
.style-mini-card img { width: 100%; height: 100%; object-fit: cover; }
/* Selection overlay — covers visual area only */
.comic-style-card .style-check { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(230,57,70,0.22); display: none; align-items: center; justify-content: center; z-index: 4; pointer-events: none; }
.comic-style-card .style-check svg { width: 48px; height: 48px; stroke: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6)); }
.comic-style-card.selected .style-check { display: flex; }
.comic-style-footer { padding: 12px 20px; border-top: 1px solid var(--p5-border); display: flex; justify-content: flex-end; flex-shrink: 0; background: var(--p5-surface); }
.comic-next-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 28px; background: var(--p5-red); border: none; color: #fff; font-size: var(--text-base); font-weight: var(--weight-semibold); cursor: pointer; transition: opacity 0.2s; }
.comic-next-btn:hover { opacity: 0.85; }
.comic-next-btn svg { flex-shrink: 0; }

/* Character / Scene cards area */
.comic-tab-bar { display: flex; justify-content: center; align-items: center; gap: 2px; padding: 8px 0; flex-shrink: 0; background: var(--p5-bg); position: relative; }
.comic-tab-bar-inner { display: flex; gap: 2px; background: var(--p5-surface); padding: 3px; border: 1px solid var(--p5-border); }
.comic-nav-next { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; font-size: 12px; font-weight: 600; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); cursor: pointer; transition: all 0.15s; }
.comic-nav-next:hover { border-color: var(--p5-red); color: var(--p5-red); }
.comic-tab { padding: 5px 20px; font-size: 12px; background: transparent; border: none; color: var(--p5-muted); cursor: pointer; transition: all 0.2s; font-weight: 500; letter-spacing: 0.5px; }
.comic-tab:hover { color: var(--p5-text); background: rgba(255,255,255,0.04); }
.comic-tab.active { color: #fff; background: var(--p5-red); }
.comic-cards-area { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-content: start; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.comic-cards-area::-webkit-scrollbar { width: 4px; }
.comic-cards-area::-webkit-scrollbar-track { background: transparent; }
.comic-cards-area::-webkit-scrollbar-thumb { background: var(--p5-border); }
.comic-cards-area::-webkit-scrollbar-thumb:hover { background: var(--p5-muted); }

/* ── Scene Flat Cards (片场卡片) ── */
.comic-scenes-summary { width: 100%; padding: 0 0 4px; font-size: 11px; color: var(--p5-muted); letter-spacing: 0.3px; }
.comic-scene-cards { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; overflow-y: auto; align-items: stretch; align-content: flex-start; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.comic-scene-cards::-webkit-scrollbar { width: 4px; }
.comic-scene-cards::-webkit-scrollbar-thumb { background: var(--p5-border); }

.comic-scene-card { width: calc(33.333% - 11px); min-width: 280px; border: 1px solid var(--p5-border); background: var(--p5-card); display: flex; flex-direction: column; }
.comic-scene-card-header { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.comic-scene-card-header h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--p5-text); flex: 1; }
.comic-scene-prompt-icon { width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; transition: all 0.2s; }
.comic-scene-prompt-icon:hover { border-color: var(--p5-red); color: var(--p5-red); }
.comic-scene-type-badge { font-size: 11px; color: var(--p5-muted); padding: 2px 8px; border: 1px solid var(--p5-border); flex-shrink: 0; }

.comic-scene-desc-wrap { position: relative; margin: 0 10px 8px; cursor: default; }
.comic-scene-card-desc { border-left: 3px solid var(--p5-red); font-size: 11px; color: var(--p5-text-secondary); line-height: 1.5; padding: 0 10px; margin: 0; max-height: calc(11px * 1.5 * 2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.comic-scene-card-desc-tip { display: none; position: absolute; left: 0; top: 100%; z-index: 20; width: 100%; padding: 8px 10px; background: var(--p5-card); border: 1px solid var(--p5-border); box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-size: 11px; color: var(--p5-text); line-height: 1.5; white-space: normal; }
.comic-scene-desc-wrap:hover .comic-scene-card-desc-tip { display: block; }

.comic-scene-card-progress { padding: 0 10px 8px; }
.comic-scene-progress-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; }
.comic-scene-progress-overlay .char-gen-progress-bar { width: 60%; }
.comic-scene-progress-overlay .char-generating-text { color: #fff; }

.comic-scene-batch-nav { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px 6px; }
.comic-scene-batch-btn { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text); cursor: pointer; transition: all 0.2s; }
.comic-scene-batch-btn:hover:not(:disabled) { border-color: var(--p5-red); color: var(--p5-red); }
.comic-scene-batch-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.comic-scene-batch-label { font-size: 11px; color: var(--p5-text-secondary); min-width: 70px; text-align: center; }
.comic-scene-card-images { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 0 10px 8px; }
.comic-scene-card-empty { display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; color: var(--p5-muted); min-height: 120px; }

.comic-scene-card-actions { padding: 0 10px 10px; margin-top: auto; }
.comic-scene-card-actions button { width: 100%; padding: 6px; font-size: 11px; cursor: pointer; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text); transition: all 0.2s; }
.comic-scene-card-actions button:hover { border-color: var(--p5-red); color: var(--p5-red); }
.comic-scene-card-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.comic-scene-card-actions button.is-primary { border-color: var(--p5-red); color: #fff; background: var(--p5-red); }

/* Character card */
.comic-char-card { background: var(--p5-card); border: 1px solid var(--p5-border); overflow: visible; transition: border-color 0.3s; display: flex; flex-direction: column; }
.comic-char-card.generating { border-color: rgba(230,57,70,0.4); }
.comic-char-card .char-header { padding: 10px 12px; border-bottom: 1px solid var(--p5-border); display: flex; align-items: center; gap: 10px; }
.comic-char-card .char-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--p5-red); font-size: 15px; font-weight: 700; overflow: hidden; background: rgba(230,57,70,0.12); border: 1px solid rgba(230,57,70,0.25); }
.comic-char-card .char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comic-char-card .char-header-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.comic-char-card .char-name { font-size: 13px; font-weight: 600; color: var(--p5-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-char-card .char-role { font-size: 10px; color: var(--p5-muted); }
.scene-act-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px; margin-top: 4px; }
.scene-act-tag { font-size: 10px; padding: 1px 6px; color: var(--p5-muted); border: 1px solid var(--p5-border); white-space: nowrap; }
.comic-char-asset-tag { font-size: 10px; padding: 1px 6px; background: rgba(230,57,70,0.15); color: var(--p5-red); border: 1px solid rgba(230,57,70,0.3); white-space: nowrap; margin-left: auto; }
.comic-char-card.from-asset { border-left: 3px solid var(--p5-red); }
.comic-sync-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.comic-sync-btn svg { flex-shrink: 0; }
.comic-char-card .char-body { padding: 8px 12px; flex: 1; display: flex; flex-direction: column; }

/* ── Hero Section (left side of char-body) ── */
.char-hero-section { width: 200px; min-width: 170px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.char-hero-stack { position: relative; width: 100%; max-width: 175px; aspect-ratio: 2/3; }
/* ── Dossier stack cards ── */
.char-stack-card { position: absolute; inset: 0; overflow: hidden; border: 1px solid var(--p5-dossier-edge); background: var(--p5-dossier-bg); }
.char-stack-card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.7; }
.char-stack-card[data-si="0"] { transform: rotate(-3deg) translate(-5px, 3px); z-index: 1; }
.char-stack-card[data-si="1"] { transform: rotate(2.5deg) translate(5px, -2px); z-index: 2; }
.char-stack-card[data-si="2"] { transform: rotate(-1deg) translate(-3px, 5px); z-index: 0; }
/* ── Hero card — dossier frame ── */
.char-hero-card { position: relative; z-index: 3; width: 100%; height: 100%; overflow: hidden; border: 2px solid var(--p5-dossier-edge);
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, transparent 6%, transparent 94%, rgba(0,0,0,0.06) 100%),
    radial-gradient(ellipse at 65% 25%, rgba(120,125,160,0.04) 0%, transparent 55%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, var(--p5-dossier-grain) 2px, var(--p5-dossier-grain) 3px),
    var(--p5-dossier-bg);
}
.char-hero-card.has-selected { border-color: var(--p5-red); }
/* ── Has image: photo pinned to dossier ── */
.char-hero-img { width: calc(100% - 8px); height: calc(100% - 8px); object-fit: cover; object-position: center top; display: block; cursor: pointer; margin: 4px; }
.char-hero-card:not(.no-image)::before { content: ''; position: absolute; top: -1px; left: 50%; transform: translateX(-50%); width: 8px; height: 8px; background: var(--p5-red); border-radius: 50%; z-index: 5; }
/* ── No image: sealed dossier placeholder ── */
.char-hero-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--p5-muted); position: relative;
  background: linear-gradient(135deg, transparent 88%, rgba(0,0,0,0.1) 88%, rgba(0,0,0,0.15) 100%);
}
.char-hero-placeholder svg { opacity: 0.12; width: 64px; height: 64px; border: 2px dashed var(--p5-dossier-edge); padding: 12px; }
/* String closure on sealed dossier */
.char-hero-card.no-image::after { content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; border: 2px solid var(--p5-dossier-edge); border-radius: 50%; box-shadow: 0 14px 0 -5px var(--p5-dossier-edge), -6px 26px 0 -5px var(--p5-dossier-edge), 6px 26px 0 -5px var(--p5-dossier-edge); z-index: 4; }
.char-hero-check { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; background: #4caf50; display: flex; align-items: center; justify-content: center; z-index: 4; }
.char-hero-select-btn { position: absolute; bottom: 8px; right: 8px; padding: 4px 12px; font-size: 11px; font-weight: 700; background: var(--p5-red); border: none; color: #fff; cursor: pointer; z-index: 4; transition: opacity 0.2s; }
.char-hero-select-btn:hover { opacity: 0.85; }
/* Hero info row: name + select */
.char-hero-info { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 210px; margin-top: 6px; gap: 6px; }
[data-theme="light"] .char-hero-img { background: linear-gradient(135deg, #f5f5f5 0%, rgba(230,57,70,0.05) 100%); }

/* ── Thumbnail Selection Strip ── */
.char-thumb-strip { display: flex; gap: 4px; padding: 8px 0; align-items: center; flex-wrap: nowrap; position: relative; }
.char-thumb-strip-inner { display: flex; gap: 4px; overflow: hidden; flex: 1; min-width: 0; }
.char-thumb-arrow { width: 20px; height: 52px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; padding: 0; transition: color 0.2s, border-color 0.2s; }
.char-thumb-arrow:hover { color: var(--p5-text); border-color: var(--p5-text-secondary); }
.char-thumb-arrow.hidden { opacity: 0.15; pointer-events: none; }
.char-thumb-wrap { position: relative; width: 52px; height: 52px; flex-shrink: 0; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s; overflow: hidden; }
.char-thumb-wrap:hover { border-color: var(--p5-red-light); }
.char-thumb-wrap.is-selected { border-color: var(--p5-red); }
.char-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.char-thumb-wrap .comic-mj-zoom { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; padding: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); border: none; cursor: pointer; z-index: 2; opacity: 0; transition: opacity 0.2s; }
.char-thumb-wrap .comic-mj-zoom svg { width: 10px; height: 10px; }
.char-thumb-wrap:hover .comic-mj-zoom { opacity: 1; }
.char-thumb-check { display: none; position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; background: var(--p5-red); align-items: center; justify-content: center; z-index: 2; }
.char-thumb-check svg { width: 10px; height: 10px; }
.char-thumb-wrap.is-selected .char-thumb-check { display: flex; }

/* ── Character Profile Section ── */
.char-profile-section { margin-top: 12px; }
.char-profile-header { font-size: 10px; font-weight: 700; color: var(--p5-red); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.char-profile-header::after { content: ''; flex: 1; height: 1px; background: var(--p5-border); }

/* ── MJ Prompt Collapsible ── */
.char-prompt-section.collapsible .char-prompt-text { display: none; }
.char-prompt-section.collapsible.expanded .char-prompt-text { display: -webkit-box; }
.char-prompt-toggle { background: none; border: none; color: var(--p5-muted); cursor: pointer; padding: 0; font-size: 10px; transition: transform 0.2s; display: inline-flex; align-items: center; }
.char-prompt-section.collapsible.expanded .char-prompt-toggle { transform: rotate(90deg); }
.char-prompt-label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ── Character Studio 4-column layout (matches manga-drama) ── */
.comic-char-studio { display: grid; grid-template-columns: 200px 252px 1fr auto; flex: 1; min-height: 0; overflow: hidden; }
@media (max-width: 1200px) { .comic-char-studio { grid-template-columns: 180px 210px 1fr auto; } .comic-char-info-wrap { width: 220px; } }
@media (max-width: 900px) { .comic-char-studio { grid-template-columns: 140px 1fr; grid-template-rows: 1fr 1fr; } }
/* Left character list */
.comic-char-list { background: var(--p5-surface); display: flex; flex-direction: column; overflow: hidden; }
.comic-char-list-scroll { flex: 1; overflow-y: auto; padding: 4px 0; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.comic-char-list-scroll::-webkit-scrollbar { width: 4px; }
.comic-char-list-scroll::-webkit-scrollbar-track { background: transparent; }
.comic-char-list-scroll::-webkit-scrollbar-thumb { background: var(--p5-border); }
.comic-char-list-scroll::-webkit-scrollbar-thumb:hover { background: var(--p5-muted); }
/* Character list items */
.comic-char-list-item { padding: 10px 12px 10px 32px; cursor: pointer; transition: all 0.15s; position: relative; }
.comic-char-list-item:hover { background: rgba(230,57,70,0.04); }
.comic-char-list-item.active { background: rgba(230,57,70,0.08); }
.comic-char-list-item.active .comic-char-list-name { padding-left: 10px; border-left: 3px solid var(--p5-red); }
.comic-char-list-name { font-size: 13px; font-weight: 600; color: var(--p5-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-char-list-thumb { width: 130px; aspect-ratio: 3/4; object-fit: cover; margin-top: 6px; display: block; border: 1px solid var(--p5-border); }
.comic-char-list-thumb.loaded { opacity: 1; }
.comic-char-list-placeholder { width: 130px; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--p5-dark); border: 1px dashed var(--p5-border); color: var(--p5-muted); margin-top: 6px; }
.comic-char-list-empty { padding: 20px 12px; text-align: center; font-size: 12px; color: var(--p5-muted); }

/* Portrait column */
.comic-char-portrait { padding: 20px 12px 12px 20px; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: none; }
.comic-char-portrait::-webkit-scrollbar { display: none; }
.comic-char-portrait .comic-style-card { border: none; cursor: default; }
.comic-char-portrait .comic-style-card:hover { transform: none; box-shadow: none; }
.comic-portrait-empty { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--p5-dark); border: 2px dashed var(--p5-red); color: var(--p5-muted); font-size: 12px; flex-direction: column; gap: 8px; }
.comic-portrait-dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0; flex-shrink: 0; }
.comic-portrait-dot { width: 8px; height: 8px; background: var(--p5-border); cursor: pointer; transition: all 0.2s; border: none; padding: 0; }
.comic-portrait-dot.active { background: var(--p5-red); }
.comic-portrait-dot:hover:not(.active) { background: var(--p5-text-secondary); }
.comic-portrait-actions { padding: 8px 0; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.comic-portrait-actions button { width: 100%; padding: 6px 0; font-size: 12px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); cursor: pointer; transition: all 0.15s; }
.comic-portrait-actions button.is-primary { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }
.comic-portrait-actions button.is-primary:hover { background: #ff6b6b; border-color: #ff6b6b; }
.comic-portrait-actions button:hover { border-color: var(--p5-red); color: #fff; background: var(--p5-red); }
.comic-portrait-actions button:disabled { opacity: 0.4; cursor: default; }
.comic-portrait-progress { aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--p5-dark); border: 1px solid var(--p5-border); position: relative; overflow: hidden; }
.comic-portrait-progress::after { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent 0%, rgba(230,57,70,0.06) 50%, transparent 100%); animation: as-topo-shimmer 2s infinite; pointer-events: none; }
.comic-portrait-progress span { font-size: 12px; color: var(--p5-muted); }
.comic-portrait-check-badge { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; z-index: 4; }
.comic-char-portrait .comic-style-card.selected .style-check { display: none; }

/* Topology tree column */
.comic-char-topo { padding: 16px 12px; overflow: auto; display: flex; flex-direction: column; }
/* Style thumbnail in info panel */
.comic-style-thumb { position: relative; width: 70%; overflow: hidden; cursor: pointer; flex-shrink: 0; border: 1px solid var(--p5-border); margin: 8px auto; }
.comic-style-thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.comic-style-thumb img.loaded { opacity: 1; }
.comic-style-thumb-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 8px 6px; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%); font-size: 11px; color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Decompose/variant selection & history dots in topo tree */
.comic-topo-decomp-wrap { border: 2px solid transparent; transition: border-color 0.15s; position: relative; }
.comic-topo-decomp-wrap.is-selected { border-color: var(--p5-red); box-shadow: 0 0 0 2px rgba(230,57,70,0.25); }
.comic-topo-decomp-wrap:hover { border-color: rgba(230,57,70,0.5); }
.comic-topo-decomp-wrap:hover .comic-mj-zoom { opacity: 1; }
.comic-topo-check-badge { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; z-index: 2; }
.comic-topo-dots { display: flex; justify-content: center; gap: 5px; padding: 5px 0 2px; }
.comic-topo-dot { width: 7px; height: 7px; border: none; background: var(--p5-border); cursor: pointer; padding: 0; transition: background 0.15s; }
.comic-topo-dot.active { background: var(--p5-red); }
.comic-topo-dot:hover { background: var(--p5-red); opacity: 0.7; }

/* Right character info panel — collapsible */
.comic-char-info-wrap { width: 260px; position: relative; display: flex; overflow: hidden; transition: width 0.25s ease; }
.comic-char-info-wrap.collapsed { width: 14px !important; min-width: 14px; }
.comic-char-info-wrap.collapsed .comic-char-info { display: none; }
.comic-char-info-toggle { position: absolute; top: 50%; right: 0; transform: translateY(-50%); width: 14px; height: 48px; background: var(--p5-red); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; opacity: 0.7; transition: opacity 0.15s; padding: 0; }
.comic-char-info-toggle:hover { opacity: 1; }
.comic-char-info { padding: 16px 20px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; flex: 1; scrollbar-width: none; }
.comic-char-info::-webkit-scrollbar { display: none; }
.comic-char-info-header { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--p5-border); }
.comic-char-info-name { font-size: 16px; font-weight: 700; color: var(--p5-text); }
.comic-char-info-role { display: inline-block; font-size: 11px; padding: 2px 8px; background: rgba(230,57,70,0.12); color: var(--p5-red); margin-top: 4px; }
.comic-char-info .char-attr-row { margin-bottom: 6px; border-left: none; padding-left: 0; }
.comic-char-info .char-attr-label { padding-left: 10px; border-left: 3px solid var(--p5-red); }
.comic-char-info .char-attr-value { -webkit-line-clamp: unset; display: block; }

/* Character attribute rows */
.char-attr-row { padding: 5px 8px; background: rgba(230,57,70,0.04); border-left: 2px solid var(--p5-red); margin-bottom: 3px; }
.char-attr-label { color: var(--p5-red-light); font-weight: 600; font-size: var(--text-xs); margin-bottom: 1px; display: flex; align-items: center; gap: 4px; }
.char-attr-label svg { flex-shrink: 0; stroke: var(--p5-red-light); }
.char-attr-value { color: var(--p5-text); line-height: 1.5; font-size: var(--text-xs); cursor: default; }
.char-attr-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.char-attr-clamp.expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
.char-attr-expand { background: none; border: none; color: var(--p5-red); font-size: 11px; cursor: pointer; padding: 2px 0; margin-top: 2px; }
.char-attr-tags { }
.char-tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.char-tag { display: inline-block; padding: 1px 8px; font-size: 10px; background: transparent; color: var(--p5-text-secondary); border: 1px solid var(--p5-border); }
[data-theme="light"] .char-attr-row { background: rgba(230,57,70,0.06); }

/* Appearance icon items */
.char-attr-value:has(.comic-appear-item) { display: flex; flex-direction: column; gap: 0; }
.comic-appear-item { display: flex; align-items: flex-start; gap: 6px; padding: 4px 0; }
.comic-appear-item + .comic-appear-item { border-top: 1px solid rgba(255,255,255,0.04); }
[data-theme="light"] .comic-appear-item + .comic-appear-item { border-top-color: rgba(0,0,0,0.05); }
.comic-appear-icon { flex-shrink: 0; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: var(--p5-red); opacity: 0.7; margin-top: 1px; }
.comic-appear-icon svg { width: 13px; height: 13px; }

/* Select button pulse when no image selected */
.comic-hint-pulse {
  animation: comicHintPulse 1.8s ease-in-out infinite;
}
@keyframes comicHintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,70,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(230,57,70,0); }
}

/* MJ Prompt display */
.char-prompt-section { margin-top: 10px; padding: 8px 10px; background: var(--p5-surface); border: 1px solid var(--p5-border); position: relative; }
.char-prompt-label { font-size: 11px; font-weight: 600; color: var(--p5-red-light); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.char-prompt-text { font-size: 12px; color: var(--p5-text-secondary); line-height: 1.5; word-break: break-word; font-family: 'SF Mono', 'Fira Code', monospace; max-height: 4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.char-prompt-edit { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; display: flex; align-items: center; justify-content: center; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-muted); cursor: pointer; transition: all 0.2s; }
.char-prompt-edit:hover { border-color: var(--p5-red); color: var(--p5-red); }

/* Prompt editor modal */
.comic-prompt-modal-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.comic-prompt-modal { width: 600px; max-width: 90vw; max-height: 80vh; background: var(--p5-card); border: 1px solid var(--p5-border); display: flex; flex-direction: column; }
.comic-prompt-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--p5-border); font-size: 14px; font-weight: 600; color: var(--p5-text); }
.comic-prompt-modal-close { background: none; border: none; color: var(--p5-muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
.comic-prompt-modal-close:hover { color: var(--p5-red); }
.comic-prompt-modal-label { font-size: 11px; color: var(--p5-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 12px 16px 6px; }
.comic-prompt-modal-context { background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 10px; font-size: 12px; color: var(--p5-text-secondary); max-height: 80px; overflow-y: auto; line-height: 1.6; margin: 0 16px; }
.comic-prompt-modal-textarea { flex: 1; margin: 4px 16px 12px; padding: 12px; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text); font-size: 13px; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.6; resize: vertical; min-height: 200px; }
.comic-prompt-modal-textarea:focus { outline: none; border-color: var(--p5-red); }
.comic-prompt-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--p5-border); }
/* Edit prompt modal — ref image cards */
.comic-epm-ref-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0; }
.comic-epm-ref-card { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; flex-shrink: 0; }
.comic-epm-ref-img { width: 120px; overflow: hidden; border: 1px solid var(--p5-border); display: flex; align-items: center; justify-content: center; background: var(--p5-surface); cursor: pointer; transition: border-color 0.2s; }
.comic-epm-ref-img:hover { border-color: var(--p5-red); }
.comic-epm-ref-img img { width: 100%; height: auto; display: block; }
.comic-epm-ref-img.is-empty { width: 120px; height: 68px; padding: 0; border: 1.5px dashed var(--p5-red); cursor: default; opacity: 0.7; }
.comic-epm-ref-img.is-empty:hover { border-color: var(--p5-red); }
.comic-epm-ref-name { font-size: 11px; color: var(--p5-text); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.comic-epm-ref-tag { font-size: 9px; padding: 1px 6px; border: 1px solid var(--p5-border); color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.ref-tag-char { border-color: var(--p5-red); color: var(--p5-red); }
.ref-tag-scene { border-color: #4a9eff; color: #4a9eff; }
.ref-tag-missing { border-color: var(--p5-muted); color: var(--p5-muted); }
.comic-epm-go-create { font-size: 9px; padding: 2px 8px; background: var(--p5-red); color: #fff; border: none; cursor: pointer; transition: opacity 0.2s; white-space: nowrap; margin-top: 2px; }
.comic-epm-go-create:hover { opacity: 0.8; }
.comic-epm-textarea { width: 100%; min-height: 180px; resize: vertical; background: var(--p5-surface); color: var(--p5-text); border: 1px solid var(--p5-border); padding: 12px; font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.6; }
.comic-epm-textarea:focus { outline: none; border-color: var(--p5-red); }
.comic-prompt-modal-cancel { padding: 6px 16px; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text); cursor: pointer; font-size: 13px; }
.comic-prompt-modal-cancel:hover { border-color: var(--p5-muted); }
.comic-prompt-modal-save { padding: 6px 16px; background: var(--p5-red); border: 1px solid var(--p5-red); color: #fff; cursor: pointer; font-size: 13px; }
.comic-prompt-modal-save:hover { background: var(--p5-red-light); }
.comic-prompt-modal-save:disabled { opacity: 0.5; cursor: default; }

/* Scene image hover Select button */
.comic-img-select-btn { position: absolute; bottom: 6px; left: 0; right: 0; margin: 0 auto; width: fit-content; padding: 2px 14px; background: var(--p5-red); color: #fff; border: none; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity 0.2s; z-index: 3; }
.comic-mj-img-wrap:hover .comic-img-select-btn { opacity: 1; }
.comic-mj-img-wrap.is-selected .comic-img-select-btn { display: none; }
.comic-img-select-btn.comic-hint-pulse { animation: comicHintPulse 2s ease-in-out infinite; opacity: 1; }

/* Placeholder icon when no image yet */
.char-placeholder { display: flex; align-items: center; justify-content: center; height: 80px; margin: 8px 0; background: var(--p5-surface); border: 1px dashed var(--p5-border); color: var(--p5-muted); opacity: 0.4; }
.scene-placeholder, .scene-generating-placeholder { flex: 1; min-height: 120px; }
.scene-generating-placeholder { flex-direction: column; gap: 8px; opacity: 1; padding: 16px; }

/* Generation progress bar */
.char-generating-area { margin-top: 12px; padding: 12px 10px; }
.char-gen-progress-bar { height: 4px; background: var(--p5-border); margin-bottom: 8px; }
.char-gen-progress-fill { height: 100%; background: var(--p5-red-gradient); width: 0%; transition: width .4s ease; }
.char-gen-progress-fill.indeterminate { width: 100% !important; background: linear-gradient(90deg, transparent 0%, var(--p5-red) 40%, var(--p5-red-light) 60%, transparent 100%); background-size: 200% 100%; animation: tf-indeterminate 1.8s linear infinite; }
.char-generating-text { text-align: center; font-size: 12px; color: var(--p5-muted); animation: pulse-text 2s ease-in-out infinite; }
@keyframes pulse-text { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* MJ 4-image selector */
.comic-mj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 6px 0; }
.comic-mj-img-wrap { position: relative; overflow: hidden; }
.comic-mj-img-wrap img { width: 100%; aspect-ratio: 3/4; object-fit: cover; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; opacity: 0; display: block; }
.comic-mj-img-wrap img.loaded { opacity: 1; }
.comic-mj-img-wrap img:hover { border-color: var(--p5-red-light); }
.comic-mj-img-wrap.is-selected img { border-color: var(--p5-red); }
.comic-mj-grid.has-selection .comic-mj-img-wrap:not(.is-selected) img.loaded { opacity: 0.4; }
/* Zoom preview button */
.comic-mj-zoom { position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; padding: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); border: none; cursor: pointer; z-index: 2; opacity: 0; transition: opacity 0.2s; }
.comic-mj-zoom:hover { background: var(--p5-red); }
.comic-mj-img-wrap:hover .comic-mj-zoom { opacity: 1; }
/* Selection checkmark badge */
.comic-mj-check { display: none; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; background: var(--p5-red); align-items: center; justify-content: center; z-index: 2; }
.comic-mj-img-wrap.is-selected .comic-mj-check { display: flex; }
/* Set as Cover overlay button */
.comic-mj-cover-btn { display: none; position: absolute; bottom: 8px; right: 8px; padding: 3px 8px; background: rgba(0,0,0,0.72); border: 1px solid rgba(255,255,255,0.15); color: #fff; font-size: 10px; cursor: pointer; z-index: 2; white-space: nowrap; transition: background 0.2s; }
.comic-mj-cover-btn:hover { background: var(--p5-red); border-color: var(--p5-red); }
.comic-mj-img-wrap.is-selected .comic-mj-cover-btn { display: block; }
/* Dot pagination for multiple generations */
.comic-mj-dots { display: flex; gap: 6px; justify-content: center; padding: 8px 0 2px; }
.comic-mj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--p5-border); cursor: pointer; transition: all 0.2s; }
.comic-mj-dot.active { background: var(--p5-red); transform: scale(1.3); }
[data-theme="light"] .comic-mj-dot { background: rgba(0,0,0,0.15); }
[data-theme="light"] .comic-mj-dot.active { background: var(--p5-red); }

/* Decompose image preview */
.comic-decompose { margin-top: 10px; }
.comic-decompose img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border: 1px solid var(--p5-border); }

/* Character card action buttons */
.comic-char-actions { padding: 8px 12px; display: flex; gap: 6px; }
.comic-char-actions button { flex: 1; padding: 8px 0; font-size: 12px; font-weight: 700; border: none; background: var(--p5-red-gradient); color: #fff; cursor: pointer; transition: opacity 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.comic-char-actions button:hover { opacity: 0.88; }
.comic-char-actions button:disabled { opacity: 0.4; cursor: default; background: var(--p5-dark); border: 1px solid var(--p5-border); color: var(--p5-muted); }
.comic-char-actions button.generating { opacity: 0.7; pointer-events: none; }
.comic-char-actions button.comic-sync-btn { background: var(--p5-dark); border: 1px solid var(--p5-border); color: var(--p5-text); font-weight: 500; }
.comic-char-actions button.comic-sync-btn:hover { border-color: var(--p5-red); color: var(--p5-red); opacity: 1; }

/* Inline action row between character images and decompose */
.comic-char-inline-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.comic-char-inline-actions button { padding: 5px 14px; font-size: 12px; border: 1px solid var(--p5-border); background: var(--p5-dark); color: var(--p5-text); cursor: pointer; transition: all 0.2s; }
.comic-char-inline-actions button:hover { border-color: var(--p5-red); color: #fff; }
.comic-char-inline-actions button.generating { background: var(--p5-red); border-color: var(--p5-red); color: #fff; pointer-events: none; }
.comic-inline-hint { font-size: 11px; color: var(--p5-muted); }

/* Decompose sheet — inside character card, between images and action buttons */
/* Asset summary */
.comic-asset-summary { padding: 12px 0; }
.comic-asset-summary h3 { font-size: var(--text-md); color: var(--p5-red); margin: 0 0 12px; }
.asset-section { margin-bottom: 14px; }
.asset-section-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--p5-text); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--p5-border); }
.asset-item { padding: 6px 0; font-size: var(--text-sm); color: var(--p5-text); border-bottom: 1px dashed var(--p5-border); }
.asset-item:last-child { border-bottom: none; }
.asset-item strong { color: var(--p5-text); }
.asset-detail { color: var(--p5-text-secondary); font-size: var(--text-xs); }
.asset-meta { color: var(--p5-muted); font-size: var(--text-xs); }

.comic-decompose-section { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--p5-border); }
.comic-decompose-placeholder { display: flex; align-items: center; justify-content: center; height: 80px; margin-top: 6px; background: var(--p5-surface); border: 1px dashed var(--p5-border); color: var(--p5-muted); opacity: 0.35; }
.comic-decompose-img-wrap { position: relative; overflow: hidden; margin-top: 6px; }
.comic-decompose-img-wrap img { width: 100%; aspect-ratio: 21/9; object-fit: cover; border: 1px solid var(--p5-border); cursor: pointer; opacity: 0; transition: opacity 0.3s; display: block; }
.comic-decompose-img-wrap img.loaded { opacity: 1; }
.comic-decompose-img-wrap .comic-mj-zoom { opacity: 0; }
.comic-decompose-img-wrap:hover .comic-mj-zoom { opacity: 1; }
.comic-decompose-img-wrap.is-selected img { border-color: var(--p5-red); }
.comic-decompose-img-wrap .comic-mj-check { display: none; }
.comic-decompose-img-wrap.is-selected .comic-mj-check { display: flex; }

/* ─── Variant Decompose Panel ────────────────────────── */
.comic-variants-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--p5-border); }
.comic-variants-header { cursor: pointer; padding: 6px 0; font-size: 13px; color: var(--p5-muted); user-select: none; display: flex; align-items: center; gap: 6px; }
.comic-variants-header:hover { color: var(--p5-text); }
.comic-variants-arrow { font-size: 10px; transition: transform 0.2s; }
.comic-variants-section.expanded .comic-variants-arrow { transform: rotate(90deg); }
.comic-variants-body { display: none; }
.comic-variants-section.expanded .comic-variants-body { display: block; }
.comic-variant-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); align-items: flex-start; }
.variant-info { flex: 1; min-width: 0; }
.variant-info strong { font-size: 13px; color: var(--p5-text); }
.variant-scenes { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0; }
.variant-scene-tag { font-size: 10px; padding: 1px 5px; background: var(--p5-red); color: #fff; white-space: nowrap; }
.variant-clothing { font-size: 12px; color: var(--p5-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.variant-decompose { width: 140px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.variant-decomp-img { margin-top: 0; }
.variant-decomp-img img { aspect-ratio: 21/9; }
.variant-decompose-btn { width: 100%; padding: 5px 0; font-size: 12px; background: var(--p5-surface); border: 1px solid var(--p5-border); color: var(--p5-text); cursor: pointer; }
.variant-decompose-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.variant-decompose-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.variant-gen-area { width: 100%; }
[data-theme="light"] .comic-variant-row { border-bottom-color: rgba(0,0,0,0.06); }

/* ─── Character Topology Tree ────────────────────────── */
.comic-topo-tree { position: relative; padding: 20px 0 40px; flex: 1; min-width: 0; }
.comic-topo-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.comic-topo-level { display: flex; justify-content: center; gap: 16px; margin-bottom: 28px; position: relative; z-index: 1; flex-wrap: wrap; }
.comic-topo-node { width: 273px; background: var(--p5-surface); border: 1px solid var(--p5-border); padding: 6px; text-align: center; position: relative; transition: border-color 0.2s; }
.comic-topo-node:hover { border-color: var(--p5-text-secondary); }
.comic-topo-node.is-root { border-color: var(--p5-red); }
.comic-topo-node-img { position: relative; overflow: hidden; }
.comic-topo-node-img img { width: 100%; display: block; opacity: 0; transition: opacity 0.3s; }
.comic-topo-node-img img.loaded { opacity: 1; }
.comic-topo-node-img .portrait-img { aspect-ratio: 3/4; object-fit: cover; }
.comic-topo-node-img .decompose-img { aspect-ratio: 21/9; object-fit: cover; }
.comic-topo-node-zoom { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; background: rgba(0,0,0,0.6); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.comic-topo-node-img:hover .comic-topo-node-zoom { opacity: 1; }
.comic-topo-node-check { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; background: var(--p5-red); display: flex; align-items: center; justify-content: center; }
.comic-topo-node-label { font-size: var(--text-sm); color: var(--p5-text); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-topo-node-badge { font-size: var(--text-xs); color: var(--p5-muted); letter-spacing: 0.5px; }
.comic-topo-node-actions { display: flex; gap: 3px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.comic-topo-btn { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; font-size: 10px; background: transparent; border: 1px solid var(--p5-red); color: var(--p5-red); cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.comic-topo-btn:hover { background: var(--p5-red); color: #fff; }
.comic-topo-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.comic-topo-node-empty { width: 100%; height: 72px; display: flex; align-items: center; justify-content: center; background: var(--p5-dark); border: 1px dashed var(--p5-border); color: var(--p5-muted); font-size: 11px; }
.comic-topo-node-progress { width: 100%; aspect-ratio: 21/9; position: relative; background: var(--p5-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; }
.comic-topo-progress-bar { width: 80%; height: 3px; background: rgba(255,255,255,0.1); }
.comic-topo-progress-fill { height: 100%; background: var(--p5-red); transition: width 0.3s; }
.comic-topo-progress-fill.indeterminate { width: 40% !important; animation: as-topo-shimmer 2s infinite; }
.comic-topo-progress-text { font-size: 10px; color: var(--p5-muted); }
.comic-topo-node .comic-mj-dots { margin-top: 3px; }
.comic-topo-node .comic-mj-dot { width: 6px; height: 6px; }

/* Topology right-panel additions */
.char-profile-variants { margin-top: 6px; }
.char-profile-variants-label { font-size: 11px; font-weight: 700; color: var(--p5-red); margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }
.char-profile-variants-label .count-badge { background: var(--p5-red); color: #fff; font-size: 10px; padding: 0 5px; font-weight: 400; }
.char-profile-variants-list { font-size: 12px; color: var(--p5-muted); line-height: 1.5; }
.char-profile-style-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--p5-border); }
.char-profile-style-label { font-size: 11px; font-weight: 700; color: var(--p5-red); margin-bottom: 6px; }
.char-profile-style-card { border: 1px solid var(--p5-border); overflow: hidden; }
.char-profile-style-card img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; }
.char-profile-style-name { font-size: 11px; color: var(--p5-text); padding: 4px 6px; text-align: center; background: var(--p5-surface); }

/* Hero name in info row */
.char-hero-name { font-size: 13px; font-weight: 700; color: var(--p5-text); margin: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-hero-role { font-weight: 400; font-size: 11px; color: var(--p5-muted); }
.char-hero-section .comic-char-actions { width: 100%; max-width: 210px; padding: 4px 0; }
.char-hero-section .char-thumb-strip { max-width: 230px; justify-content: center; }
.char-hero-section .comic-mj-dots { max-width: 210px; }
.char-hero-section .char-generating-area { width: 100%; max-width: 210px; }

/* Prompt popup overlay */
.comic-prompt-overlay { position: fixed; inset: 0; z-index: 10001; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.comic-prompt-popup { background: var(--p5-card); border: 1px solid var(--p5-border); width: 420px; max-width: 90vw; max-height: 60vh; display: flex; flex-direction: column; }
.comic-prompt-popup-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--p5-border); font-size: 13px; font-weight: 600; color: var(--p5-text); }
.comic-prompt-popup-body { flex: 1; overflow-y: auto; padding: 12px; font-size: 12px; color: var(--p5-text-secondary); line-height: 1.6; white-space: pre-wrap; word-break: break-word; margin: 0; font-family: inherit; }
.comic-prompt-popup-actions { padding: 8px 12px; border-top: 1px solid var(--p5-border); display: flex; justify-content: flex-end; }

/* ─── Storyboard Panel Layout ────────────────────────── */
.comic-storyboard-body { display: grid; grid-template-columns: 200px 1fr; gap: 0; flex: 1; overflow: hidden; }
.comic-storyboard-sidebar { overflow-y: auto; padding: 12px; border-right: 1px solid var(--p5-border); }
.comic-storyboard-main { overflow-y: auto; padding: 8px 16px; position: relative; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.comic-storyboard-main::-webkit-scrollbar { width: 6px; }
.comic-storyboard-main::-webkit-scrollbar-track { background: transparent; }
.comic-storyboard-main::-webkit-scrollbar-thumb { background: var(--p5-border); }

/* Act selector cards in sidebar */
.comic-act-card { padding: 12px; margin-bottom: 8px; border: 1px solid var(--p5-border); background: var(--p5-card); cursor: pointer; transition: all 0.2s; }
.comic-act-card:hover { border-color: var(--p5-muted); }
.comic-act-card.active { border-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.comic-act-card .act-num { font-size: 13px; font-weight: 700; color: var(--p5-text); }
.comic-act-card .act-title { font-size: 11px; color: var(--p5-muted); margin-top: 4px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comic-act-card .act-badge { display: inline-block; margin-top: 6px; padding: 1px 8px; font-size: 10px; border: 1px solid var(--p5-border); color: var(--p5-muted); }
.comic-act-card .act-badge.done { border-color: #2d8; color: #2d8; }
.comic-act-card .act-badge.partial { border-color: var(--p5-red); color: var(--p5-red); }

/* Panel action bar at top of main area */
.comic-panel-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--p5-border); }
.comic-panel-actions button { padding: 6px 16px; font-size: 12px; border: 1px solid var(--p5-border); background: var(--p5-dark); color: var(--p5-text); cursor: pointer; transition: all 0.2s; }
.comic-panel-actions button:hover { border-color: var(--p5-red); color: #fff; }
.comic-panel-actions button.primary { background: var(--p5-red); border-color: var(--p5-red); color: #fff; }
.comic-panel-actions button:disabled { opacity: 0.4; cursor: default; }
.comic-panel-actions .act-info { font-size: 13px; color: var(--p5-text); margin-right: auto; }
.comic-scroll-nav { position: fixed; right: 24px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.comic-scroll-btn { width: 32px; height: 32px; padding: 0; border: 1px solid var(--p5-border); background: var(--p5-card); color: var(--p5-text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; pointer-events: auto; opacity: 0.7; }
.comic-scroll-btn:hover { border-color: var(--p5-red); color: var(--p5-red); opacity: 1; }

/* Panel cards grid */
.comic-panels-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .comic-panels-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px)  { .comic-panels-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .comic-panels-grid { grid-template-columns: 1fr; } }
.comic-panel-card { border: 1px solid var(--p5-border); background: var(--p5-card); overflow: hidden; display: flex; flex-direction: column; }
.comic-panel-card .panel-header { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--p5-border); }
.comic-panel-card .panel-num { font-size: 13px; font-weight: 700; color: var(--p5-red); flex-shrink: 0; }
/* Panel ref avatars — poker hand fan, spread on hover */
.panel-ref-avatars { position: relative; flex: 1; min-width: 0; height: 44px; cursor: pointer; display: flex; align-items: center; }
.panel-ref-avatar { width: 34px; height: 42px; overflow: hidden; border: 1.5px solid var(--p5-border); display: flex; align-items: center; justify-content: center; cursor: pointer; background: var(--p5-card); box-shadow: 0 1px 4px rgba(0,0,0,0.5); position: absolute; left: 0; transform-origin: center center; transition: transform 0.45s ease, left 0.45s ease, border-color 0.3s ease, box-shadow 0.3s ease; }
.panel-ref-avatar.no-img { background: var(--p5-surface); }
.panel-ref-avatar.ref-missing { border-color: var(--p5-red); border-style: dashed; opacity: 0.7; width: 42px; height: 24px; }
.panel-ref-avatar img { width: 100%; height: 100%; object-fit: cover; }
.panel-ref-avatar.ref-decompose, .panel-ref-avatar.ref-variant { width: 42px; height: 24px; }
.panel-ref-avatar.ref-scene { width: 42px; height: 24px; }
/* Poker hand: fan from bottom-left, each card rotated more */
.panel-ref-avatar:nth-child(1) { z-index: 5; transform: rotate(-3deg); }
.panel-ref-avatar:nth-child(2) { z-index: 4; left: 8px; transform: rotate(-1deg); }
.panel-ref-avatar:nth-child(3) { z-index: 3; left: 16px; transform: rotate(1deg); }
.panel-ref-avatar:nth-child(4) { z-index: 2; left: 24px; transform: rotate(3deg); }
.panel-ref-avatar:nth-child(5) { z-index: 1; left: 32px; transform: rotate(5deg); }
/* Spread flat on hover */
.panel-ref-avatars:hover .panel-ref-avatar { transform: rotate(0deg); box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.panel-ref-avatars:hover .panel-ref-avatar:nth-child(1) { left: 0; }
.panel-ref-avatars:hover .panel-ref-avatar:nth-child(2) { left: 38px; }
.panel-ref-avatars:hover .panel-ref-avatar:nth-child(3) { left: 76px; }
.panel-ref-avatars:hover .panel-ref-avatar:nth-child(4) { left: 114px; }
.panel-ref-avatars:hover .panel-ref-avatar:nth-child(5) { left: 152px; }
.panel-ref-avatar:hover { border-color: var(--p5-red) !important; box-shadow: 0 0 10px rgba(230,57,70,0.4) !important; z-index: 10 !important; }
.panel-prompt-btn { background: none; border: 1px solid var(--p5-border); color: var(--p5-muted); width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: all 0.2s; }
.panel-prompt-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.comic-panel-card .panel-body { padding: 10px 12px; display: flex; flex-direction: column; }
.comic-panel-card .panel-desc { font-size: 12px; color: var(--p5-text); line-height: 1.5; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; max-height: calc(12px * 1.5 * 3); flex-shrink: 0; }
.comic-panel-card .panel-desc.expanded { -webkit-line-clamp: unset; }

/* Page image — single Nano output, 3:4 aspect ratio */
.comic-page-img-wrap { position: relative; overflow: hidden; }
.comic-page-img-wrap img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border: 1px solid var(--p5-border); cursor: pointer; opacity: 0; transition: opacity 0.3s; display: block; }
.comic-page-img-wrap img.loaded { opacity: 1; }
.comic-page-img-wrap .comic-mj-zoom { opacity: 0; }
.comic-page-img-wrap:hover .comic-mj-zoom { opacity: 1; }
.comic-page-img-wrap.is-selected img { border-color: var(--p5-red); }
.comic-page-img-wrap .comic-mj-check { display: none; }
.comic-page-img-wrap.is-selected .comic-mj-check { display: flex; }

/* Panel prompt section */
/* panel-prompt removed — now uses panel-prompt-btn icon in header */

/* Panel generating state */
.comic-panel-card .panel-generating { display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 3/4; background: var(--p5-surface); border: 1px dashed var(--p5-border); }
.comic-panel-card .panel-gen-bar { width: 60%; height: 3px; background: var(--p5-border); margin-top: 8px; overflow: hidden; }
.comic-panel-card .panel-gen-fill { height: 100%; width: 0; background: var(--p5-red); transition: width 0.3s; }
.comic-panel-card .panel-gen-text { font-size: 11px; color: var(--p5-text-secondary); margin-top: 6px; }

/* Panel placeholder (no images yet) */
.comic-panel-card .panel-placeholder { display: flex; align-items: center; justify-content: center; aspect-ratio: 3/4; background: var(--p5-surface); border: 1px dashed var(--p5-border); color: var(--p5-text-secondary); font-size: 11px; }

/* Panel card actions */
.comic-panel-card .panel-actions { padding: 8px 12px; border-top: 1px solid var(--p5-border); display: flex; gap: 6px; }
.comic-panel-card .panel-actions button { flex: 1; padding: 5px 0; font-size: 11px; border: 1px solid var(--p5-border); background: var(--p5-dark); color: var(--p5-text); cursor: pointer; transition: all 0.2s; }
.comic-panel-card .panel-actions button:hover { border-color: var(--p5-red); color: #fff; }
.comic-panel-card .panel-actions button.generating { background: var(--p5-red); border-color: var(--p5-red); color: #fff; pointer-events: none; }
.panel-thumb-strip-wrap { display: flex; align-items: center; gap: 2px; padding: 6px 4px; border-top: 1px solid var(--p5-border); }
.panel-thumb-arrow { flex-shrink: 0; background: none; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.panel-thumb-arrow:hover { color: var(--p5-red); border-color: var(--p5-red); }
.panel-thumb-strip { display: flex; gap: 4px; overflow: hidden; scrollbar-width: none; flex: 1; min-width: 0; }
.panel-thumb-strip-wrap:not(.has-overflow) .panel-thumb-arrow { display: none; }
.panel-thumb-strip::-webkit-scrollbar { display: none; }
.panel-thumb { width: 48px; height: 64px; flex-shrink: 0; cursor: pointer; position: relative; border: 2px solid transparent; opacity: 0.6; transition: all 0.2s; }
.panel-thumb:hover { opacity: 1; }
.panel-thumb.active { border-color: var(--p5-text); opacity: 1; }
.panel-thumb.is-selected { border-color: var(--p5-red); opacity: 1; }
.panel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel-thumb-zoom { position: absolute; bottom: 1px; right: 1px; background: rgba(0,0,0,0.6); border: none; width: 18px; height: 18px; display: none; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.panel-thumb-zoom svg { width: 10px; height: 10px; }
.panel-thumb:hover .panel-thumb-zoom { display: flex; }
.panel-thumb-check { position: absolute; top: 1px; right: 1px; background: var(--p5-red); width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; }
.panel-thumb-check svg { width: 10px; height: 10px; }

/* Missing assets dialog */
.comic-missing-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--p5-surface); border: 1px solid var(--p5-border); font-size: 13px; color: var(--p5-text); }
.comic-missing-item svg { flex-shrink: 0; }
.dt-fixed-modal-footer { display: flex; gap: 12px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--p5-border); }
.dt-fixed-modal-footer .dt-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; font-size: 13px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.2s; }
.dt-fixed-modal-footer .dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.dt-fixed-modal-footer .dt-btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; font-size: 13px; font-weight: 600; border: none; background: var(--p5-red-gradient); color: #fff; cursor: pointer; transition: opacity 0.2s; }
.dt-fixed-modal-footer .dt-btn-primary:hover { opacity: 0.88; }

/* Decompose loading state */
.comic-storyboard-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--p5-muted); gap: 12px; }
.comic-storyboard-empty { text-align: center; padding: 60px 20px; color: var(--p5-muted); }
.comic-storyboard-empty p { margin-top: 12px; font-size: 13px; }

/* Preview button in sidebar */
.comic-preview-btn-wrap { padding: 12px; border-top: 1px solid var(--p5-border); display: flex; flex-direction: column; gap: 8px; }
.comic-preview-btn { width: 100%; padding: 8px 0; font-size: 12px; border: 1px solid var(--p5-red); background: transparent; color: var(--p5-red); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s; }
.comic-preview-btn:hover { background: var(--p5-red); color: #fff; }
.comic-export-btn { border-color: var(--p5-border); color: var(--p5-text-secondary); }
.comic-export-btn:hover { border-color: var(--p5-red); background: transparent; color: var(--p5-red); }
/* Export modal act list */
.comic-export-act-list { display: flex; flex-direction: column; gap: 2px; }
.comic-export-act-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; transition: background 0.15s; }
.comic-export-act-row:hover { background: var(--p5-surface); }
.comic-export-act-row input[type="checkbox"] { display: none; }
.comic-export-act-check { width: 18px; height: 18px; border: 2px solid var(--p5-border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.comic-export-act-row input:checked ~ .comic-export-act-check { border-color: var(--p5-red); background: var(--p5-red); }
.comic-export-act-row input:checked ~ .comic-export-act-check::after { content: ''; display: block; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.comic-export-act-label { flex: 1; font-size: 13px; color: var(--p5-text); }
.comic-export-act-count { font-size: 11px; color: var(--p5-muted); flex-shrink: 0; }
.comic-export-progress-bar { width: 100%; height: 6px; background: var(--p5-surface); margin-bottom: 12px; overflow: hidden; }
.comic-export-progress-fill { height: 100%; width: 0; background: var(--p5-red); transition: width 0.3s ease; }
.comic-export-progress-text { font-size: var(--text-sm); color: var(--p5-text-secondary); }

/* ══════════════════════════════════════════════════════════════
   Manga Drama Step 5 · VIDEO — V4 visual (2026-04-30)
   Top bar (SHOT LIST 一覧 + REFRESH) + 3-col shell (280 / 1fr / 320)
   Mirrors manga-drama-v4.html SCREEN 5.
   ══════════════════════════════════════════════════════════════ */

/* ── Top bar (replaces old comic-chat-header) ──────────────── */
.md-video-top {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-dark);
}
.md-video-top-l { display: flex; align-items: center; gap: 12px; }
.md-video-top-lbl {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--p5-red);
}
.md-video-top-ji {
  font-family: 'Noto Serif JP', 'Noto Serif SC', serif;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--p5-text-secondary);
  margin-left: 6px;
  font-style: normal;
}
.md-video-top-chip {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  background: var(--p5-input-bg);
  color: var(--p5-text-secondary);
}
.md-video-top-r { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── 3-col shell ───────────────────────────────────────────── */
.md-video-pg {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  flex: 1; min-height: 0;
  overflow: hidden;
}

/* ── Left column: shot list by act ─────────────────────────── */
.md-video-left {
  background: var(--p5-dark);
  border-right: 1px solid var(--p5-border);
  overflow-y: auto;
  padding: 10px;
}
.md-video-act-group { margin-bottom: 14px; }
.md-video-act-group:last-child { margin-bottom: 0; }
.md-video-act-label {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 600;
  color: var(--p5-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 4px 8px;
}
.md-video-shot-card {
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.md-video-shot-card:hover { border-color: rgba(230,57,70,0.5); }
.md-video-shot-card.active {
  border-color: var(--p5-red);
  box-shadow: inset 0 0 0 1px var(--p5-red);
}
.md-video-shot-card .sh-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}
.md-video-shot-card .sh-head .id {
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  color: var(--p5-red);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.md-video-shot-card .sh-head .title {
  font-size: 10.5px; font-weight: 500;
  color: var(--p5-text-secondary);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.md-video-shot-card .sh-head .d {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.md-video-shot-card.active .sh-head .d { color: var(--p5-red); }
.md-video-shot-card .sh-head .tick {
  width: 14px; height: 14px;
  background: var(--p5-red);
  display: none;
  place-items: center;
  flex-shrink: 0;
}
.md-video-shot-card .sh-head .tick::after {
  content: '';
  width: 7px; height: 3px;
  border: 1.5px solid #000;
  border-top: none; border-right: none;
  transform: rotate(-45deg) translate(0, -1px);
}
.md-video-shot-card.is-done .sh-head .tick { display: grid; }
.md-video-shot-card .sh-img {
  aspect-ratio: 16/9;
  background: var(--p5-surface);
  overflow: hidden;
  position: relative;
}
.md-video-shot-card .sh-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s;
}
.md-video-shot-card .sh-img img.loaded { opacity: 1; }
.md-video-shot-card .sh-img.placeholder {
  border-top: 1px dashed var(--p5-border);
}
.md-video-shot-card .sh-status {
  position: absolute; top: 6px; right: 6px;
  display: flex; align-items: center;
  z-index: 2;
}
.md-video-status-dot { width: 8px; height: 8px; background: var(--p5-red); border-radius: 50%; }
.md-video-status-dot.pulsing { animation: md-video-pulse 1.5s ease-in-out infinite; }
@keyframes md-video-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Middle column: viewer (breadcrumb + big canvas + meta + prompt + history) ── */
.md-video-mid-v4 {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--p5-surface);
  overflow: hidden;
}
.md-video-viewer-top {
  flex-shrink: 0;
  padding: 10px 18px;
  border-bottom: 1px solid var(--p5-border);
  display: flex; align-items: center; gap: 14px;
  background: var(--p5-dark);
}
.md-video-crumb {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--p5-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.md-video-crumb b { color: var(--p5-red); font-weight: 700; }
.md-video-sub {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--p5-text);
  flex: 1; min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-video-viewer-top .md-video-vm-btn { flex-shrink: 0; margin-left: auto; }

.md-video-viewer-body {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column;
  min-height: 0;
}

/* Canvas (video / storyboard image / placeholder) — aspect-ratio on CHILD, not wrapper,
   to avoid aspect-ratio + max-height conflict that clipped native <video> controls (2026-04-30 fix) */
.md-video-viewer-canvas {
  flex-shrink: 0;
  background: #000;
  border-bottom: 1px solid var(--p5-border);
  position: relative;
}
.md-video-viewer-canvas video,
.md-video-viewer-canvas img {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
  background: #000;
}
.md-video-canvas-fn {
  position: absolute; top: 12px; left: 12px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  background: #000;
  color: var(--p5-red);
  border: 1px solid var(--p5-red);
  z-index: 2;
}
.md-video-canvas-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  color: var(--p5-muted);
  font-size: 12px;
  width: 100%;
  aspect-ratio: 16/9;
}
.md-video-canvas-placeholder svg { stroke: var(--p5-border); }

/* Meta row — mono chip fields + action buttons (V4 viewer-meta) */
.md-video-meta {
  flex-shrink: 0;
  padding: 10px 18px;
  background: var(--p5-dark);
  border-bottom: 1px solid var(--p5-border);
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.md-video-meta-field {
  display: flex; align-items: center; gap: 8px;
  position: relative;
}
.md-video-meta-field .k {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--p5-muted);
  text-transform: uppercase;
}
.md-video-meta-field .v {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--p5-text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.md-video-meta-field .v:hover { border-color: var(--p5-red); color: var(--p5-red); }
.md-video-meta-field .v svg { width: 9px; height: 9px; color: var(--p5-muted); flex-shrink: 0; }

/* Custom dropdown (replaces native <select>; mirrors dt-lang-menu pattern) */
.md-video-dd {
  position: absolute;
  top: 100%; left: 0;
  margin-top: 2px;
  min-width: 120px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--p5-surface);
  border: 1px solid var(--p5-border);
  border-top: 2px solid var(--p5-red);
  z-index: 300;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
}
.md-video-dd[hidden] { display: none; }
.md-video-dd.flip-up {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 2px;
  border-top: 1px solid var(--p5-border);
  border-bottom: 2px solid var(--p5-red);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
}
.md-video-dd-item {
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: var(--p5-text);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.md-video-dd-item:hover { background: var(--p5-input-bg); color: var(--p5-red); }
.md-video-dd-item.active { color: var(--p5-red); font-weight: 700; }

.md-video-meta-actions { margin-left: auto; display: flex; gap: 6px; }
.md-video-vm-btn {
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--p5-text-secondary);
  background: transparent;
  border: 1px solid var(--p5-border);
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.md-video-vm-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.md-video-vm-btn.red {
  background: var(--p5-red);
  color: #fff;
  border-color: var(--p5-red);
  font-weight: 700;
}
.md-video-vm-btn.red:hover { background: #c22030; border-color: #c22030; color: #fff; }
.md-video-vm-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.md-video-vm-btn svg { width: 11px; height: 11px; flex-shrink: 0; }

/* Prompt row (full-width strip under meta) */
.md-video-prompt-row {
  flex-shrink: 0;
  padding: 10px 18px;
  background: var(--p5-card);
  border-bottom: 1px solid var(--p5-border);
  display: flex; align-items: center; gap: 12px;
}
.md-video-prompt-row .k {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--p5-red);
  text-transform: uppercase;
  font-weight: 700;
  flex-shrink: 0;
}
.md-video-prompt-row .txt {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--p5-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.md-video-prompt-row .txt.placeholder {
  color: var(--p5-muted);
  font-style: italic;
}
.md-video-prompt-row .edit {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--p5-red);
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--p5-red);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.md-video-prompt-row .edit:hover { background: var(--p5-red); color: #fff; }

/* History grid (moved to right column 2026-04-30) — 2-col thumbnail cards with V# + ACTIVE badge */
.md-video-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.md-video-hist-card {
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: flex; flex-direction: column;
}
.md-video-hist-card:hover {
  border-color: var(--p5-red);
  transform: translateY(-1px);
}
.md-video-hist-card.active {
  border-color: var(--p5-red);
  box-shadow: inset 0 0 0 1px var(--p5-red), 0 3px 10px rgba(230, 57, 70, 0.2);
}
.md-video-hist-card .hist-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
}
.md-video-hist-card .hist-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.md-video-hist-card .hist-active-badge {
  position: absolute;
  top: 5px; right: 5px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  background: var(--p5-red);
  color: #fff;
  z-index: 2;
}
.md-video-hist-card .hist-meta {
  display: flex; align-items: center;
  padding: 6px 10px;
  border-top: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}
.md-video-hist-card .v-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  color: var(--p5-text-secondary);
  letter-spacing: 0.06em;
}
.md-video-hist-card.active .v-num { color: var(--p5-red); }

/* ── Right column: shot info + ri sections ─────────────────── */
.md-video-ri {
  background: var(--p5-dark);
  border-left: 1px solid var(--p5-border);
  height: 100%;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.md-video-ri-head {
  padding: 20px 18px;
  border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
  position: relative;
  background: var(--p5-dark);
}
.md-video-ri-head::before {
  content: '';
  position: absolute;
  left: 0; top: 20px; bottom: 20px;
  width: 3px;
  background: var(--p5-red);
}
.md-video-ri-head .lb {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--p5-red);
  text-transform: uppercase;
  padding-left: 12px;
}
.md-video-ri-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 0.02em;
  padding-left: 12px;
  margin: 4px 0 0;
  line-height: 1.1;
  color: var(--p5-text);
}
.md-video-ri-head h2 em {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  color: var(--p5-red);
  font-weight: 700;
  font-style: normal;
  margin-left: 4px;
  text-transform: lowercase;
}
.md-video-ri-head .desc {
  font-size: 11.5px;
  color: var(--p5-text-secondary);
  line-height: 1.5;
  padding-left: 12px;
  margin-top: 8px;
}

.md-video-ri-sec {
  padding: 22px 18px;
  border-bottom: 1px solid var(--p5-border);
}
.md-video-ri-sec:last-child { border-bottom: none; }
.md-video-ri-sec h3 {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--p5-red);
  text-transform: uppercase;
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 700;
}
.md-video-ri-sec h3::before {
  content: '';
  width: 10px; height: 10px;
  background: var(--p5-red);
  flex-shrink: 0;
}

/* 4-frame timeline grid */
.md-video-timeline-4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.md-video-tl-frame {
  border: 1px solid var(--p5-border);
  padding: 8px;
  background: var(--p5-card);
  transition: border-color 0.15s;
}
.md-video-tl-frame:hover { border-color: var(--p5-red); }
.md-video-tl-frame .hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.md-video-tl-frame .hd .id {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  color: var(--p5-red);
  letter-spacing: 0.05em;
}
.md-video-tl-frame .hd .t {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  color: var(--p5-muted);
  letter-spacing: 0.04em;
}
.md-video-tl-frame p {
  font-size: 10.5px;
  color: var(--p5-text-secondary);
  line-height: 1.45;
  margin: 0;
}

/* Voice & subtitle section */
.md-video-voice-list {
  display: flex; flex-direction: column; gap: 8px;
}
.md-video-voice-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  font-size: 11.5px;
  flex-wrap: wrap;
}
.md-video-voice-type {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--p5-red);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.md-video-voice-speaker {
  font-size: 11px;
  color: var(--p5-text);
  padding: 1px 7px;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
  flex-shrink: 0;
}
.md-video-voice-text {
  flex: 1 1 100%;
  font-size: 11.5px;
  color: var(--p5-text-secondary);
  line-height: 1.5;
  margin-top: 4px;
}
.md-video-voice-range {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  margin-left: auto;
  flex-shrink: 0;
}
.md-video-play-btn {
  background: transparent;
  border: 1px solid var(--p5-red);
  color: var(--p5-red);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.md-video-play-btn:hover { background: var(--p5-red); color: #fff; }
.md-video-nar-badge {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  padding: 2px 8px;
  background: rgba(230, 57, 70, 0.1);
  color: var(--p5-red);
  border: 1px solid rgba(230, 57, 70, 0.3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.md-video-voice-empty {
  font-size: 11px;
  color: var(--p5-muted);
  padding: 10px 0;
  text-align: center;
}
.md-video-dub-row {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.md-video-dub-voice {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--p5-text-secondary);
}
.md-video-dub-voice img {
  width: 22px; height: 22px;
  object-fit: cover;
  border: 1px solid var(--p5-border);
}
.md-video-dub-history {
  display: flex; gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Production stats 2x2 (only real data: Duration + Variation) */
.md-video-ri-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--p5-border);
  border: 1px solid var(--p5-border);
}
.md-video-ri-stats .st {
  padding: 10px 12px;
  background: var(--p5-card);
  display: flex; flex-direction: column; gap: 4px;
}
.md-video-ri-stats .st .k {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--p5-muted);
  text-transform: uppercase;
}
.md-video-ri-stats .st .v {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--p5-text);
  letter-spacing: 0.02em;
}
.md-video-ri-stats .st .v em {
  color: var(--p5-red);
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  font-style: normal;
  margin-left: 2px;
  font-weight: 700;
}
.md-video-ri-stats .st .v.small { font-size: 13px; letter-spacing: 0.04em; }

/* ══════════════════════════════════════════════════════════════
   Step 6: Assembly (合片) — V4 视觉重构
   Ported from camikalabs-UI/project/manga-drama-v4.html Screen 6
   Replaces legacy .md-comp-* family
   ══════════════════════════════════════════════════════════════ */

/* ── Top bar (REFRESH + EXPORT, aligned to .md-video-top) ─── */
.md-asm-top {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--p5-border);
  background: var(--p5-dark);
  min-height: 48px;
}
.md-asm-top-r {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* ── Main grid: 280px 1fr / 1fr 210px ─────────────────────── */
.md-asm-pg {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

/* ── Left rail: shot list, spans both rows ────────────────── */
.md-asm-shots {
  grid-row: 1 / -1; grid-column: 1;
  border-right: 1px solid var(--p5-border);
  background: var(--p5-dark);
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--p5-border) transparent;
  display: flex; flex-direction: column; gap: 10px;
}
.md-asm-shot {
  flex-shrink: 0; /* E14 */
  padding: 8px;
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
  cursor: pointer;
  position: relative;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    0 4px 16px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.04);
}
.md-asm-shot:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.55), 0 8px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
}
.md-asm-shot.on {
  border-color: var(--p5-red);
  box-shadow:
    0 3px 10px rgba(230,57,70,0.25),
    0 6px 20px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(230,57,70,0.15);
}
.md-asm-sh-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.md-asm-sh-id {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 800;
  color: var(--p5-red);
  letter-spacing: 0.08em;
}
.md-asm-sh-dur {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  color: var(--p5-muted);
  padding: 1px 6px;
  border: 1px solid var(--p5-border);
  letter-spacing: 0.04em;
}
.md-asm-sh-tick {
  margin-left: auto;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #4caf50;
}
/* First-frame thumbnail (uses <video> metadata preload to render actual frame 0; img fallback) */
.md-asm-thumb {
  aspect-ratio: 16/9;
  background: var(--p5-surface);
  border: 1px solid var(--p5-border);
  overflow: hidden;
  position: relative;
}
.md-asm-thumb img,
.md-asm-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.md-asm-thumb img {
  opacity: 0;
  transition: opacity .25s;
}
.md-asm-thumb img.loaded { opacity: 1; }

/* ── Viewer (grid row 1, col 2) ────────────────────────────── */
.md-asm-viewer {
  grid-row: 1; grid-column: 2;
  background: #000;
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 0;
}
.md-asm-canvas {
  flex: 1;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  min-height: 0;
  overflow: hidden;
}
/* E18: aspect-ratio on media element, wrapper stays visual-only */
.md-asm-canvas video,
.md-asm-canvas img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  background: #000;
}
.md-asm-canvas-placeholder {
  width: 72%;
  aspect-ratio: 16/9;
  background: #0a0a0a;
  border: 1px solid rgba(230,57,70,0.2);
  display: flex; align-items: center; justify-content: center;
  color: var(--p5-muted);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.md-asm-ts {
  position: absolute;
  top: 28px; left: 28px;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700;
  color: var(--p5-red);
  background: #000;
  border: 1px solid var(--p5-red);
  padding: 3px 8px;
  letter-spacing: 0.08em;
  z-index: 2;
}
.md-asm-tag {
  position: absolute;
  top: 28px; right: 28px;
  display: flex; align-items: center; gap: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 600;
  color: var(--p5-text);
  background: rgba(0,0,0,0.72);
  padding: 4px 8px;
  letter-spacing: 0.08em;
  z-index: 2;
}
.md-asm-tag .dot {
  width: 6px; height: 6px;
  background: var(--p5-red);
}
/* Subtitle overlay on viewer canvas — bottom-center, 30px from bottom (Need #2) */
.md-asm-subtitle {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  letter-spacing: 0.02em;
  /* Layered shadow for readability on any background without a solid box */
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.95),
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.7);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  /* Chunks are pre-split in JS; this only catches extreme cases (no punctuation) */
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.md-asm-subtitle.on { opacity: 1; }

/* ── Slim play bar: ▶ + time only ─────────────────────────── */
.md-asm-play {
  padding: 8px 18px;
  background: var(--p5-dark);
  border-top: 1px solid var(--p5-border);
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0;
}
.md-asm-play-btn {
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.md-asm-play-btn:hover {
  border-color: var(--p5-red);
  color: var(--p5-red);
}
.md-asm-time {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 700;
  color: var(--p5-text);
  letter-spacing: 0.06em;
}
.md-asm-time .sep {
  color: var(--p5-muted);
  margin: 0 6px;
}
.md-asm-scrub {
  flex: 1;
  height: 3px;
  background: var(--p5-input-bg);
  position: relative;
  cursor: pointer;
  margin-right: 6px;
}
.md-asm-scrub-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--p5-red);
  width: 0;
  pointer-events: none;
}
.md-asm-scrub-head {
  position: absolute;
  left: 0;
  top: 50%;
  width: 11px; height: 11px;
  margin-left: -5.5px;
  transform: translateY(-50%);
  background: var(--p5-red);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(230,57,70,0.5);
  pointer-events: none;
}

/* ── Timeline (grid row 2, col 2, height 210px) ───────────── */
.md-asm-tl {
  grid-row: 2; grid-column: 2;
  height: 210px;
  background: var(--p5-dark);
  border-top: 1px solid var(--p5-border);
  display: flex; flex-direction: column;
  overflow: hidden;
  user-select: none;
  position: relative;
}

/* Ruler — header row, 22px */
.md-asm-tl-header {
  flex-shrink: 0;
  display: flex;
  height: 22px;
  background: #000;
  border-bottom: 1px solid var(--p5-border);
}
.md-asm-tl-label-col {
  flex: 0 0 70px;
  border-right: 1px solid var(--p5-border);
  background: var(--p5-card);
}
.md-asm-tl-ruler {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.md-asm-tl-tick {
  position: absolute;
  top: 0; height: 100%;
}
.md-asm-tl-tick.major {
  border-left: 1px solid rgba(255,255,255,0.12);
}
.md-asm-tl-tick.major span {
  position: absolute;
  top: 4px; left: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  color: var(--p5-muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.md-asm-tl-tick.minor {
  border-left: 1px solid rgba(255,255,255,0.05);
}

/* Tracks body — 4 tracks stretch to fill remaining height */
.md-asm-tl-body {
  flex: 1;
  display: flex; flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--p5-border) transparent;
  min-height: 0;
}
.md-asm-tl-track {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.md-asm-tl-track:last-child { border-bottom: none; }
.md-asm-tl-track-label {
  flex: 0 0 70px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--p5-card);
  border-right: 1px solid var(--p5-border);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  color: var(--p5-text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.md-asm-tl-track-label svg {
  width: 11px; height: 11px;
  color: var(--p5-red);
  flex-shrink: 0;
}
.md-asm-tl-track-content {
  position: relative;
  flex: 1;
  min-width: 100%;
  background: #0c0c12;
}

/* Video clips — red filled with hatched overlay (V4 style) */
.md-asm-tl-clip {
  position: absolute;
  top: 4px; bottom: 4px;
  display: flex; align-items: stretch;
  background: rgba(230,57,70,0.22);
  border: 1px solid var(--p5-red);
  cursor: grab;
  overflow: hidden;
  transition: background .15s;
}
.md-asm-tl-clip::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 3px, transparent 3px 6px);
  pointer-events: none;
}
.md-asm-tl-clip:hover { background: rgba(230,57,70,0.32); }
.md-asm-tl-clip.dragging { opacity: 0.7; z-index: 5; cursor: grabbing; }
.md-asm-tl-clip-body {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  min-width: 0;
  overflow: hidden;
}
.md-asm-tl-clip-label {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.md-asm-tl-clip-dur {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px; font-weight: 600;
  color: rgba(255,255,255,0.75);
  margin-left: auto;
  white-space: nowrap;
}

/* Trim handles — subtle by default, highlight on clip hover (no pointer-events toggle, E8) */
.md-asm-tl-clip-handle {
  flex: 0 0 8px;
  cursor: ew-resize;
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.md-asm-tl-clip-handle::after {
  content: '';
  width: 2px; height: 14px;
  background: rgba(255,255,255,0.7);
}
.md-asm-tl-clip:hover .md-asm-tl-clip-handle {
  opacity: 1;
  background: rgba(230,57,70,0.5);
}
.md-asm-tl-clip-handle:hover { background: rgba(230,57,70,0.8) !important; }
.md-asm-tl-clip-handle:hover::after { background: #fff; }
.md-asm-tl-clip-handle:active { background: rgba(230,57,70,0.95) !important; }

/* Subtitle blocks — grey/neutral */
.md-asm-tl-sub {
  position: absolute;
  top: 4px; bottom: 4px;
  display: flex; align-items: center;
  padding: 0 8px;
  background: rgba(120,125,160,0.2);
  border: 1px solid rgba(120,125,160,0.5);
  overflow: hidden;
  cursor: grab;
  transition: background .15s, border-color .15s;
}
.md-asm-tl-sub:hover {
  background: rgba(120,125,160,0.35);
  border-color: rgba(180,185,215,0.7);
}
.md-asm-tl-sub span {
  font-size: 10px;
  color: var(--p5-text);
  letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Dub blocks — green */
.md-asm-tl-dub {
  position: absolute;
  top: 4px; bottom: 4px;
  display: flex; align-items: center; gap: 5px;
  padding: 0 8px;
  background: #1a4a38;
  border: 1px solid #2a6a52;
  overflow: hidden;
  cursor: grab;
  transition: background .15s;
}
.md-asm-tl-dub:hover { background: #236a4c; }
.md-asm-tl-dub span {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 600;
  color: #c6f2d6;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* BGM track — placeholder button (awaiting mp3 library import) */
.md-asm-tl-bgm-placeholder {
  position: absolute;
  top: 4px; bottom: 4px;
  left: 8px;
  min-width: 140px;
  padding: 0 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255,193,7,0.04);
  border: 1px dashed rgba(255,193,7,0.35);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.md-asm-tl-bgm-placeholder:hover {
  background: rgba(255,193,7,0.1);
  border-color: rgba(255,193,7,0.65);
}
.md-asm-tl-bgm-placeholder span {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  color: rgba(255,193,7,0.85);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.md-asm-tl-bgm-placeholder svg { color: rgba(255,193,7,0.85); }
.md-asm-tl-bgm-bar {
  position: absolute;
  top: 4px; bottom: 4px;
  display: flex; align-items: center;
  padding: 0 10px;
  background: rgba(255,193,7,0.15);
  border: 1px solid rgba(255,193,7,0.4);
}
.md-asm-tl-bgm-bar span {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 600;
  color: rgba(255,193,7,0.95);
  letter-spacing: 0.04em;
}

/* Playhead — red (V4 style), draggable across timeline */
.md-asm-tl-playhead {
  position: absolute;
  top: 0; bottom: 0;
  width: 11px; margin-left: -5px;
  z-index: 10;
  cursor: col-resize;
  pointer-events: auto;
}
.md-asm-tl-playhead-head {
  width: 11px; height: 11px;
  background: var(--p5-red);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}
.md-asm-tl-playhead-line {
  width: 1px;
  height: calc(100% - 11px);
  background: var(--p5-red);
  margin-left: 5px;
  box-shadow: 0 0 6px rgba(230,57,70,0.6);
}

/* Empty state */
.md-asm-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--p5-muted);
  font-size: 13px;
}
.md-asm-empty svg {
  color: var(--p5-border);
  margin-bottom: 12px;
}

/* Subtitle edit modal buttons (carried over from legacy, still used) */
#md-sub-edit-modal .dt-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 18px; font-size: 12px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.2s; }
#md-sub-edit-modal .dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
#md-sub-edit-modal .dt-btn-primary { border-color: var(--p5-red); color: var(--p5-red); }
#md-sub-edit-modal .dt-btn-primary:hover { background: var(--p5-red); color: #fff; }

/* Comic Preview Overlay — full-screen manga reader */
/* ── Comic Preview Overlay ── */
.comic-preview-overlay { position: fixed; inset: 0; z-index: 9999; background: #0a0a0a; display: flex; flex-direction: column; }
.comic-pv-header { flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #111; border-bottom: 1px solid #222; }
.comic-pv-brand { font-size: 15px; font-weight: 700; color: var(--p5-red); letter-spacing: 0.5px; flex-shrink: 0; }
.comic-pv-header-title { font-size: 14px; font-weight: 600; color: #fff; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-pv-close { background: none; border: none; color: #666; font-size: 28px; cursor: pointer; line-height: 1; padding: 0 4px; }
.comic-pv-close:hover { color: #fff; }
.comic-pv-body { flex: 1; display: flex; min-height: 0; }

/* ── TOC Sidebar ── */
.comic-pv-toc { width: 180px; min-width: 180px; background: #111; border-right: 1px solid #222; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.comic-pv-toc-title { font-size: 12px; font-weight: 700; color: #555; padding: 0 16px 12px; letter-spacing: 1px; text-transform: uppercase; border-bottom: 1px solid #1a1a1a; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-pv-toc-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; color: #888; font-size: 13px; text-decoration: none; border-left: 2px solid transparent; transition: all 0.2s; cursor: pointer; }
.comic-pv-toc-item:hover { color: #ccc; background: rgba(255,255,255,0.03); }
.comic-pv-toc-item.active { color: #fff; border-left-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.comic-pv-toc-act { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-pv-toc-count { font-size: 11px; color: #555; flex-shrink: 0; margin-left: 8px; }
.comic-pv-toc-item.active .comic-pv-toc-count { color: var(--p5-red); }

/* ── Scroll Content — uses webtoon cs-* classes from comic-share.css for visual parity with /c/:slug ── */
.comic-pv-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; background: #0a0a0f; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.comic-pv-scroll .cs-main { max-width: 720px; width: 100%; margin: 0 auto; padding: 0 0 48px; }
/* Preview-only: page-number label overlay on each panel (share page doesn't show labels) */
.cs-panel { position: relative; }
.cs-panel .comic-pv-page-label { position: absolute; top: 6px; left: 6px; padding: 2px 8px; background: rgba(0,0,0,0.7); color: #fff; font-size: 11px; font-weight: 600; z-index: 1; pointer-events: none; }
/* Empty state when no acts at all */
.comic-pv-empty { display: flex; align-items: center; justify-content: center; flex: 1; color: #555; font-size: 14px; padding: 48px; }

/* Preview-specific TOC override — compact flex row showing "Act N | Title | x/y" inline (share page stacks vertically) */
.comic-pv-toc .cs-toc-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 10px 14px; text-decoration: none; color: #888; border-left: 2px solid transparent; transition: color 0.15s, border-color 0.15s, background 0.15s; }
.comic-pv-toc .cs-toc-item:hover { color: #ccc; background: rgba(255,255,255,0.03); }
.comic-pv-toc .cs-toc-item.active { color: #fff; border-left-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.comic-pv-toc .cs-toc-act-num { font-size: 10px; color: #555; letter-spacing: 1px; text-transform: uppercase; flex-shrink: 0; margin: 0; display: inline; }
.comic-pv-toc .cs-toc-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comic-pv-toc .comic-pv-toc-count { font-size: 11px; color: #555; flex-shrink: 0; }
.comic-pv-toc .cs-toc-item.active .comic-pv-toc-count,
.comic-pv-toc .cs-toc-item.active .cs-toc-act-num { color: var(--p5-red); }

/* Preview — view toggle + quality toggle */
.comic-pv-view-toggle, .comic-pv-quality-toggle { display: flex; gap: 2px; background: #1a1a1a; padding: 2px; }
.comic-pv-toggle-btn, .comic-pv-quality-btn { background: none; border: none; color: #555; padding: 5px 10px; cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 12px; transition: all 0.2s; }
.comic-pv-toggle-btn:hover, .comic-pv-quality-btn:hover { color: #aaa; }
.comic-pv-toggle-btn.active, .comic-pv-quality-btn.active { background: #333; color: #fff; }

/* Preview — book mode (single page + arrows) */
.comic-pv-book { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; padding: 24px 60px; overflow: hidden; min-height: 0; }
.comic-pv-book-spread { display: flex; align-items: center; justify-content: center; height: 100%; }
.comic-pv-book-page { position: relative; display: flex; align-items: center; justify-content: center; height: 100%; }
.comic-pv-book-page img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; cursor: pointer; transition: opacity 0.2s; }
.comic-pv-book-page img:hover { opacity: 0.92; }
.comic-pv-book-spine { width: 2px; background: linear-gradient(to bottom, transparent, #333, #333, transparent); flex-shrink: 0; }
.comic-pv-book-blank { background: #0d0d0d; }
.comic-pv-book-empty { border: 1px dashed #333; }
.comic-pv-book-empty span { color: #444; font-size: 14px; }
.comic-pv-book-arrow { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.05); border: 1px solid #333; color: #888; width: 40px; height: 60px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; z-index: 2; }
.comic-pv-book-arrow:hover { background: rgba(230,57,70,0.15); border-color: var(--p5-red); color: #fff; }
.comic-pv-book-arrow.disabled { opacity: 0.2; pointer-events: none; }
.comic-pv-book-prev { left: 16px; }
.comic-pv-book-next { right: 16px; }
.comic-pv-book-counter { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #555; }

/* ═══════════════════════════════════════════════════════
   Pixel Character — Workshop Map + Mini Avatar
   ═══════════════════════════════════════════════════════ */
/* Embedded in task float — shown/hidden by JS */
.dt-pc-embed {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.dt-pc-embed.active { display: block !important; animation: pcFadeIn .3s ease-out; }

/* ── Map ── */
.dt-pc-map {
  position: relative; width: 100%; aspect-ratio: 16/9;
  overflow: hidden; cursor: grab;
}
.dt-pc-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* Character sprite */
.dt-pc-sprite {
  position: absolute; width: 64px; height: 64px;
  transition: left 0.6s ease-in-out, top 0.6s ease-in-out;
  z-index: 10; image-rendering: pixelated;
}
/* Sprite animation — pixel-based background-position steps */
.dt-pc-sprite[data-state="idle"]        { background: url('/images/character/sprite_idle.png') 0 0 / auto 100% no-repeat; animation: pc-walk-6 1.08s steps(6) infinite; }
.dt-pc-sprite[data-state="working"]     { background: url('/images/character/sprite_working.png') 0 0 / auto 100% no-repeat; animation: pc-walk-6 0.72s steps(6) infinite; }
.dt-pc-sprite[data-state="thinking"]    { background: url('/images/character/sprite_thinking.png') 0 0 / auto 100% no-repeat; animation: pc-walk-6 0.9s steps(6) infinite; }
.dt-pc-sprite[data-state="searching"]   { background: url('/images/character/sprite_searching.png') 0 0 / auto 100% no-repeat; animation: pc-walk-6 0.84s steps(6) infinite; }
.dt-pc-sprite[data-state="celebrating"] { background: url('/images/character/sprite_celebrating.png') 0 0 / auto 100% no-repeat; animation: pc-walk-6 0.72s steps(6) infinite; }
.dt-pc-sprite[data-state="failed"]      { background: url('/images/character/sprite_failed.png') 0 0 / auto 100% no-repeat; animation: pc-walk-4 0.88s steps(4) infinite; }

@keyframes pc-walk-6 { from { background-position: 0 0; } to { background-position: -384px 0; } }
@keyframes pc-walk-4 { from { background-position: 0 0; } to { background-position: -256px 0; } }

/* Bubble */
.dt-pc-bubble {
  position: absolute; top: 6px; left: 15%; right: 15%;
  background: rgba(20,20,20,0.88); border-radius: 12px;
  padding: 4px 12px; z-index: 20; text-align: center;
  opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.dt-pc-bubble.show { opacity: 1; }
.dt-pc-bubble-text {
  color: #f0f0f0; font-size: 12px; font-weight: 700;
  line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}

/* Collapse button */
@keyframes pcFadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Light theme ── */
[data-theme="light"] .dt-pc-embed { border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .dt-pc-bubble { background: rgba(40,40,40,0.92); }

/* ═══════════════════════════════════════════════════════
   HomePet — Home view pet
   ═══════════════════════════════════════════════════════ */
.dt-home-pet {
  position: fixed; top: 50%; right: 40px; transform: translateY(-50%); z-index: 100;
  display: flex; flex-direction: column; align-items: flex-end;
  cursor: grab; touch-action: none; user-select: none;
}
.dt-home-pet-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(18,18,18,0.85);
  overflow: hidden; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.dt-home-pet-avatar:hover { border-color: rgba(255,255,255,0.3); }
.dt-home-pet-sprite {
  width: 48px; height: 48px; image-rendering: pixelated;
  background: url('/images/character/sprite_idle.png') 0 0 / auto 100% no-repeat;
  animation: pc-pet-6 1.2s steps(6) infinite;
}
@keyframes pc-pet-6 { to { background-position: -288px 0; } }
@keyframes pc-pet-4 { to { background-position: -192px 0; } }

/* Character switcher dots */
.dt-home-pet-dots {
  display: flex; gap: 5px; justify-content: center;
  margin-top: 4px; cursor: pointer; padding: 2px;
}
.dt-pet-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.2); transition: all .2s;
}
.dt-pet-dot.active { background: var(--p5-red); transform: scale(1.3); }
[data-theme="light"] .dt-pet-dot { background: rgba(0,0,0,0.15); }
[data-theme="light"] .dt-pet-dot.active { background: var(--p5-red); }

.dt-home-pet-tip {
  background: rgba(20,20,20,0.9); border: 1px solid #555;
  border-radius: 10px; padding: 8px 14px;
  width: max-content; max-width: 220px;
  position: absolute; bottom: calc(100% + 6px); right: 0;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.dt-home-pet-tip.show { opacity: 1; }
.dt-home-pet-tip-text { color: #e0e0e0; font-size: 13px; font-weight: 600; line-height: 18px; }
.dt-home-pet-tip-tail {
  position: absolute; bottom: -6px; right: 14px;
  width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid rgba(20,20,20,0.9);
}
/* Pet feedback button — pixel-style speech bubble */
.dt-pet-feedback-btn {
  background: rgba(20,20,20,0.88); color: #e0e0e0;
  border: 1.5px solid #555; padding: 4px 10px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px;
  cursor: pointer; margin-top: 4px;
  opacity: 0; transform: translateY(-4px) scale(0.9);
  transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap;
  image-rendering: pixelated;
  font-family: 'Courier New', monospace;
}
.dt-pet-feedback-btn.show {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
.dt-pet-feedback-btn:hover {
  background: rgba(230,57,70,0.85); color: #fff;
  border-color: var(--p5-red);
}
[data-theme="light"] .dt-pet-feedback-btn {
  background: rgba(40,40,40,0.85); border-color: #666;
}

[data-theme="light"] .dt-home-pet-avatar { background: rgba(245,240,235,0.95); border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .dt-home-pet-tip { background: rgba(40,40,40,0.92); }

/* HomePet celebrate bounce */
@keyframes hp-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-10px) scale(1.08); }
  50% { transform: translateY(-4px) scale(1.03); }
  70% { transform: translateY(-7px) scale(1.05); }
}
.hp-bounce { animation: hp-bounce 0.6s ease; }

/* ═══════════════════════════════════════════════════════
   Pet Living Room Map
   ═══════════════════════════════════════════════════════ */
.dt-pet-map-wrap {
  max-width: 600px; width: 100%; margin: 0 auto 24px;
  animation: pcFadeIn .3s ease-out;
}
.dt-pet-map {
  position: relative; width: 100%; aspect-ratio: 16/9;
  overflow: hidden; border: 1px solid rgba(255,255,255,0.08);
}
.dt-pet-bg {
  width: 100%; height: 100%; object-fit: cover;
  image-rendering: pixelated;
}
.pet-sprite {
  position: absolute; width: 80px; height: 80px;
  image-rendering: pixelated;
  transition: left 0.8s ease-in-out, top 0.8s ease-in-out;
  z-index: 10;
}
.pet-sprite .pet-emoji-bubble {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 16px; opacity: 0; transition: opacity .3s;
  pointer-events: none;
}
.pet-sprite .pet-emoji-bubble.show { opacity: 1; }
[data-theme="light"] .dt-pet-map { border-color: rgba(0,0,0,0.10); }

/* ═══════════════════════════════════════════════════════
   Quest System V2 — Full-screen immersive onboarding
   ═══════════════════════════════════════════════════════ */

/* Quest indicator on HomePet avatar */
.quest-indicator {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px;
  background: var(--p5-red); color: #fff;
  font-size: 12px; font-weight: 800;
  text-align: center; line-height: 20px;
  border: 2px solid #000;
  animation: quest-pulse 1.2s ease infinite;
  z-index: 2;
}
@keyframes quest-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Full-screen Quest Overlay */
.quest-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: #0a0a0a;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 8px,
    rgba(230,57,70,0.04) 8px, rgba(230,57,70,0.04) 16px
  );
  animation: quest-sparkle-scroll 2s linear infinite;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s;
}
.quest-overlay--dim { background-color: rgba(5,5,8,0.5); background-image: none; animation: none; }
.quest-overlay--clear { background-color: transparent; background-image: none; animation: none; }
/* Scene base */
.quest-scene {
  text-align: center; max-width: 560px; width: 90vw;
  animation: quest-fadeIn .4s ease-out;
}
@keyframes quest-fadeIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* NPC — Large (intro/reward/complete scenes) */
.quest-npc-large { margin-bottom: 24px; text-align: center; }
.quest-npc-sprite-lg {
  width: 80px; height: 80px; margin: 0 auto 16px;
  image-rendering: pixelated;
  background: url('/images/character/sprite_idle.png') 0 0 / auto 100% no-repeat;
  animation: quest-npc-anim 1.2s steps(6) infinite;
}
@keyframes quest-npc-anim { from { background-position: 0 0; } to { background-position: -480px 0; } }

/* Speech bubble */
.quest-npc-bubble {
  background: #151515; border: 2px solid var(--p5-red);
  padding: 10px 20px; margin: 0 auto 16px;
  font-size: 14px; color: #ddd; line-height: 1.6;
  position: relative; white-space: pre-line; text-align: center;
  box-shadow: 4px 4px 0 rgba(230,57,70,0.3);
  letter-spacing: 0.5px;
  display: inline-block;
}
.quest-npc-bubble::after {
  content: ''; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  border-left: 10px solid transparent; border-right: 10px solid transparent;
  border-bottom: 10px solid var(--p5-red);
}
.quest-npc-bubble-sm {
  font-size: 13px; color: #999; font-style: italic; max-width: 240px;
}

/* Buttons */
.quest-btn-primary {
  background: var(--p5-red); color: #fff;
  font-size: 16px; font-weight: 700;
  border: none; padding: 14px 40px; cursor: pointer;
  transition: filter .15s; display: inline-block;
  box-shadow: 3px 3px 0 rgba(230,57,70,0.4);
}
.quest-btn-primary:hover { filter: brightness(1.15); }
.quest-btn-skip {
  background: none; border: none;
  color: #555; font-size: 13px; cursor: pointer;
  margin-top: 16px; display: inline-block;
  transition: color .15s;
}
.quest-btn-skip:hover { color: #999; }

/* Welcome gift — bounced up by NPC */
.quest-welcome-gift {
  animation: quest-gift-bumped 1.6s ease-in-out infinite;
}
@keyframes quest-gift-bumped {
  0%, 100% { transform: translateY(0) scale(1); }
  20% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-18px) scale(1.1); }
  50% { transform: translateY(-6px) scale(1); }
  65% { transform: translateY(0) scale(1); }
}
.quest-welcome-gift .quest-reward-credits-big {
  text-shadow: 0 0 24px rgba(230,57,70,0.5), 0 0 48px rgba(230,57,70,0.2);
}
/* NPC bounce — jumps up to bump the credits */
.quest-scene-welcome .quest-npc-sprite-lg {
  animation: quest-npc-anim 1.2s steps(6) infinite, quest-npc-jump 1.6s ease-in-out infinite;
}
@keyframes quest-npc-jump {
  0%, 100% { transform: translateY(0); }
  15% { transform: translateY(4px); }
  30% { transform: translateY(-14px); }
  45% { transform: translateY(0); }
  55% { transform: translateY(2px); }
  65% { transform: translateY(0); }
}

/* Reward credits */
.quest-reward-credits-big {
  font-size: 56px; font-weight: 900; color: var(--p5-red);
  line-height: 1; margin: 8px 0;
  text-shadow: 0 0 24px rgba(230,57,70,0.5);
  animation: quest-credits-pop .5s ease-out;
}
@keyframes quest-credits-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.quest-reward-sub {
  font-size: 14px; color: #777; font-weight: 600; margin-bottom: 16px;
}
.quest-reward-sparkle {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 8px,
    rgba(230,57,70,0.04) 8px, rgba(230,57,70,0.04) 16px
  );
  animation: quest-sparkle-scroll 2s linear infinite;
}
@keyframes quest-sparkle-scroll { from { background-position: 0 0; } to { background-position: 32px 32px; } }

/* Complete Scene Summary */
.quest-complete-summary {
  margin-bottom: 24px;
  animation: quest-fadeIn .5s ease-out .2s both;
}
.quest-complete-badge {
  margin: 0 auto 12px; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--p5-red);
  animation: quest-badge-pop .5s ease-out .4s both;
}
@keyframes quest-badge-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.quest-complete-label {
  font-size: 18px; font-weight: 700; color: #eee;
  letter-spacing: 1px; text-transform: uppercase;
}

/* Quest: Complete Panel (floating beside highlighted card) */
.quest-complete-panel {
  position: fixed; z-index: 802;
  background: none; border: none;
  padding: 24px 28px; text-align: center;
  max-width: 340px; width: 90vw;
  animation: quest-fadeIn .4s ease-out;
}
.quest-complete-panel .quest-creation-label {
  font-size: var(--text-sm); color: var(--p5-muted);
  letter-spacing: 0.5px; margin-bottom: 16px;
}
/* Highlighted card in history grid */
.quest-highlight-card {
  position: relative !important; z-index: 801 !important;
  box-shadow: 0 0 0 4px rgba(230,57,70,0.7), 0 0 30px rgba(230,57,70,0.4) !important;
  animation: guideGlowPulse 2s ease-in-out infinite !important;
}
/* Dim non-publish buttons inside highlighted card */
.quest-highlight-card .dt-card-btn:not(.quest-glow-btn) {
  opacity: 0.25 !important; pointer-events: none !important;
}
/* Glowing publish button inside highlighted card */
.quest-glow-btn {
  border: 2px solid var(--p5-red) !important;
  color: var(--p5-red) !important;
  box-shadow: 0 0 8px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3) !important;
  animation: questBtnGlow 1.5s ease-in-out infinite !important;
}
@keyframes questBtnGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3); }
  50% { box-shadow: 0 0 14px rgba(230,57,70,0.9), 0 0 30px rgba(230,57,70,0.5); }
}

/* Mode Selection Cards */
.quest-mode-cards {
  display: flex; gap: 20px; justify-content: center;
  margin-bottom: 28px;
}
.quest-mode-card {
  background: #151515; border: 2px solid #333;
  padding: 28px 24px; width: 220px; cursor: pointer;
  transition: border-color .2s, box-shadow .3s, transform .2s;
  text-align: center;
  position: relative;
}
.quest-mode-card:hover {
  border-color: #555;
}
.quest-mode-card.selected {
  border: 3px solid var(--p5-red);
  background: #1a1218;
  box-shadow: 0 0 16px rgba(230,57,70,0.4), 0 0 40px rgba(230,57,70,0.15);
  animation: quest-mode-float 2.8s ease-in-out infinite;
}
@keyframes quest-mode-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.quest-mode-card.selected::before {
  content: ''; position: absolute; top: -3px; left: -3px; right: -3px; bottom: -3px;
  border: 1px solid rgba(230,57,70,0.2);
  pointer-events: none;
}
.quest-mode-icon {
  color: #555; margin-bottom: 16px;
  transition: color .2s;
}
.quest-mode-icon svg { width: 36px; height: 36px; }
.quest-mode-card.selected .quest-mode-icon { color: #eee; }
.quest-mode-card:hover .quest-mode-icon { color: #888; }
.quest-mode-info { min-width: 0; }
.quest-mode-title {
  font-size: 18px; font-weight: 700; color: #b5b5b5;
  margin-bottom: 8px; transition: color .2s;
}
.quest-mode-card.selected .quest-mode-title { color: #eee; }
.quest-mode-desc {
  font-size: 13px; color: #666; line-height: 1.5; transition: color .2s;
}
.quest-mode-card.selected .quest-mode-desc { color: #999; }
.quest-mode-confirm {
  animation: quest-fadeIn .3s ease-out;
}

/* Quest Category Picker */
.quest-cat-grid {
  display: grid; grid-template-columns: repeat(2, 180px);
  gap: 14px; justify-content: center;
  margin-bottom: 24px;
  transition: opacity .25s ease;
}
.quest-cat-card {
  background: #151515; border: 2px solid #333;
  padding: 24px 16px; cursor: pointer;
  text-align: center;
  transition: border-color .2s, box-shadow .3s, transform .2s;
}
.quest-cat-card:hover {
  border-color: var(--p5-red);
  box-shadow: 0 0 12px rgba(230,57,70,0.3);
  transform: translateY(-3px);
}
.quest-cat-icon {
  color: #888; margin-bottom: 10px;
  transition: color .2s;
}
.quest-cat-icon svg { width: 32px; height: 32px; }
.quest-cat-card:hover .quest-cat-icon { color: var(--p5-red); }
.quest-cat-label {
  font-size: 14px; font-weight: 600; color: #b5b5b5;
  transition: color .2s;
}
.quest-cat-card:hover .quest-cat-label { color: #eee; }
.quest-cat-shuffle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid #444; color: #888;
  padding: 8px 18px; cursor: pointer; font-size: 13px;
  transition: border-color .2s, color .2s;
}
.quest-cat-shuffle:hover {
  border-color: var(--p5-red); color: #ccc;
}
.quest-cat-shuffle svg { flex-shrink: 0; }

/* Quest Marker — pulsing arrow for active quest steps */
.quest-marker {
  position: fixed; z-index: 900;
  width: 32px; height: 32px;
  pointer-events: none;
  animation: quest-marker-bounce 0.8s ease infinite;
}
.quest-marker-arrow {
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 16px solid var(--p5-red);
  margin: 0 auto;
  filter: drop-shadow(0 2px 6px rgba(230,57,70,0.6));
}
@keyframes quest-marker-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Feature Guide Scene */
.quest-feature-grid {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  max-width: 640px; margin: 0 auto 24px;
}
.quest-feature-card {
  background: var(--p5-surface); border: 1px solid var(--p5-border);
  padding: 24px 20px; flex: 1; min-width: 160px; max-width: 190px;
  text-align: center; transition: border-color .2s;
}
.quest-feature-card:hover { border-color: var(--p5-red); }
.quest-feature-icon { margin-bottom: 12px; }
.quest-feature-icon svg { stroke: var(--p5-red); }
.quest-feature-title { font-size: 15px; font-weight: 700; color: #eee; margin-bottom: 8px; }
.quest-feature-desc { font-size: 13px; color: var(--p5-text-secondary); line-height: 1.5; }

/* Pet Intro Scene */
.quest-pet-showcase { margin-bottom: 16px; }
.quest-pet-sprite {
  width: 120px; height: 120px; margin: 0 auto;
  image-rendering: pixelated;
  background: url('/images/character/sprite_idle.png') 0 0 / auto 100% no-repeat;
  animation: quest-npc-jump 1.6s ease-in-out infinite;
}
.quest-pet-features {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 400px; margin: 0 auto 24px; text-align: left;
}
.quest-pet-feature {
  display: flex; align-items: center; gap: 10px;
  background: var(--p5-surface); border: 1px solid var(--p5-border);
  padding: 14px 18px; font-size: 14px; color: var(--p5-text-secondary);
}

/* Invite Friends Scene */
.quest-invite-card {
  background: var(--p5-surface); border: 1px solid var(--p5-border);
  padding: 24px 28px; max-width: 440px; margin: 0 auto 20px;
}
.quest-invite-reward {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; color: #f5e6a3; margin-bottom: 20px; font-weight: 600;
}
.quest-invite-amount { font-size: 24px; color: var(--p5-red); font-weight: 700; }
.quest-invite-progress { color: #888; font-size: 13px; margin-left: 4px; }
.quest-invite-link-row {
  display: flex; gap: 8px; align-items: center;
}
.quest-invite-link {
  flex: 1; background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary); padding: 10px 12px; font-size: 13px;
  outline: none; cursor: default;
}
.quest-btn-copy {
  background: var(--p5-red); color: #fff; border: none;
  padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: filter .15s;
  box-shadow: 2px 2px 0 rgba(230,57,70,0.3);
}
.quest-btn-copy:hover { filter: brightness(1.15); }
.quest-scene-actions { margin-top: 12px; }

/* Subscription Intro Scene */
.quest-sub-grid {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  max-width: 640px; margin: 0 auto 20px;
}
.quest-sub-card {
  background: var(--p5-surface); border: 1px solid var(--p5-border);
  padding: 20px 24px; min-width: 180px; flex: 1; max-width: 200px;
  text-align: center; transition: border-color .2s;
}
.quest-sub-card:hover { border-color: var(--p5-red); }
.quest-sub-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.quest-sub-price { font-size: 14px; color: var(--p5-text-secondary); margin-bottom: 6px; }
.quest-sub-discount { font-size: 20px; font-weight: 700; color: var(--p5-red); margin-right: 6px; }
.quest-sub-original { text-decoration: line-through; color: #666; font-size: 13px; }
.quest-sub-period { color: #666; font-size: 12px; }
.quest-sub-credits { font-size: 13px; color: #f5e6a3; }

/* Mobile */
@media (max-width: 768px) {
  /* ── Quest Overlay Scenes — H5 compact ── */
  .quest-scene { width: 95vw; padding: 20px 16px; }
  .quest-npc-large { transform: scale(0.75); transform-origin: center center; }
  .quest-npc-bubble { padding: 14px 18px; font-size: 13px; max-width: 90vw; }
  .quest-reward-credits-big { font-size: 36px; }
  .quest-welcome-gift { margin-bottom: 16px; }
  .quest-btn-primary { padding: 12px 28px; font-size: 14px; }
  .quest-btn-skip { font-size: 12px; }
  .quest-mode-cards { flex-direction: column; align-items: center; gap: 12px; }
  .quest-mode-card {
    width: 280px; padding: 14px 16px;
    display: flex; align-items: center; gap: 14px;
    text-align: left;
  }
  .quest-mode-card .quest-mode-icon { margin-bottom: 0; }
  .quest-mode-card .quest-mode-icon svg { width: 28px; height: 28px; }
  .quest-mode-card.selected::before { top: -3px; left: -3px; right: -3px; bottom: -3px; }
  .quest-mode-title { font-size: 15px; margin-bottom: 4px; }
  .quest-mode-desc { font-size: 12px; line-height: 1.4; }
  .quest-cat-grid { grid-template-columns: repeat(2, 140px); gap: 10px; }
  .quest-cat-card { padding: 16px 10px; }
  .quest-cat-icon svg { width: 24px; height: 24px; }
  .quest-cat-label { font-size: 12px; }
  .quest-feature-grid { flex-direction: column; align-items: center; gap: 10px; }
  .quest-feature-card { max-width: 280px; width: 100%; padding: 14px; }
  /* H5: hide "new template" card — these features are accessed via Create menu on H5 */
  .quest-feature-card:last-child { display: none; }
  .quest-sub-grid { flex-direction: column; align-items: center; }
  .quest-sub-card { max-width: 280px; width: 100%; }
  .quest-invite-card { padding: 16px 20px; }
  .quest-invite-link { font-size: 12px; }
  .quest-pet-showcase { margin-bottom: 12px; transform: scale(0.6); transform-origin: center center; }

  /* ── Guide Tooltip — H5 narrower + compact ── */
  .dt-guide-tooltip {
    min-width: 240px;
    max-width: calc(100vw - 32px);
    padding: 12px 14px;
  }
  .dt-guide-tooltip-avatar { width: 28px; height: 28px; }
  .dt-guide-tooltip-text { font-size: 13px; line-height: 18px; }
  .dt-guide-tooltip-nav { margin-top: 10px; padding-top: 10px; }
  .dt-guide-skip { font-size: 12px; }
  .dt-guide-next { font-size: 12px; padding: 5px 12px; }

  /* ── z-index: guide elements above H5 second-level pages (z:9999) ── */
  body.guide-active .dt-guide-overlay { z-index: 10000 !important; }
  body.guide-active .dt-guide-tooltip { z-index: 10001 !important; }
  body.guide-active .guide-highlight,
  body.guide-active .guide-highlight-interactive,
  body.guide-active .guide-highlight-fixed { z-index: 10001 !important; }
  body.guide-active .guide-zboost { z-index: 10001 !important; }
  body.guide-active #dt-task-float { z-index: 10002 !important; }
  body.guide-active .toast-container { z-index: 10003 !important; }
  body.guide-active #dt-confirm-dialog { z-index: 10003 !important; }
  body.guide-active #login-modal { z-index: 10003 !important; }
  body.guide-active.h5-sub-open #subscription-modal { z-index: 10003 !important; }

  /* ── H5 second-level pages must be above guide overlay when guide is active ── */
  body.guide-active.h5-exec-open #project-exec-view { z-index: 10001 !important; }
  body.guide-active.h5-tpl-open .dt-tpl-modal-container { z-index: 10001 !important; }
  body.guide-active.h5-wiz-open .dt-wizard-modal { z-index: 10001 !important; }
  body.guide-active.h5-gc-open #gc-exec-view { z-index: 10001 !important; }

  /* ── guide-free-scroll: lock bottom nav (same .dt-sidebar element) ── */
  body.guide-active.guide-free-scroll .dt-sidebar { z-index: 0 !important; }
}

/* ═══════════════════════════════════════════════════════
   Legacy Guide (deprecated, kept for cleanup)
   ═══════════════════════════════════════════════════════ */
.dt-guide-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.55);
  pointer-events: auto; display: none;
  opacity: 0; transition: opacity .35s ease;
}
.dt-guide-overlay.active { display: block; opacity: 1; }
/* Highlighted element — punch through the overlay */
/* When guide is active, suppress view animations and lock ALL scroll containers */
body.guide-active { overflow: hidden !important; }
body.guide-active .dt-content { overflow: hidden !important; }
body.guide-active.guide-free-scroll { overflow: auto !important; }
body.guide-active.guide-free-scroll .dt-content { overflow-y: auto !important; }
body.guide-active.guide-free-scroll .dt-sidebar { pointer-events: none !important; opacity: 0.3 !important; z-index: 602 !important; }
body.guide-active.guide-free-scroll .dt-header { pointer-events: none !important; opacity: 0.3 !important; z-index: 602 !important; }
body.guide-active.guide-free-scroll .dt-guide-overlay { pointer-events: none !important; opacity: 0 !important; }
body.guide-active.guide-free-scroll .dt-view.active { position: relative !important; z-index: 601 !important; pointer-events: auto !important; }
body.guide-active.guide-free-scroll .tpl-type-seg[data-type="combo"] { pointer-events: none !important; opacity: 0.3 !important; cursor: not-allowed !important; }
body.guide-active .dt-view.active { animation: none !important; }
body.guide-active .dt-tpl-info.animate > * { animation: none !important; }
/* Feature guide: force sidebar expanded + elevated above overlay */
body.quest-sidebar-guide .dt-sidebar {
  width: 170px !important;
  z-index: 801 !important;
  pointer-events: none !important;
  opacity: 1 !important;
}
body.quest-sidebar-guide .dt-sidebar .dt-nav-item span { opacity: 1 !important; }
body.quest-sidebar-guide .dt-sidebar .dt-nav-item.locked .lock-icon { opacity: 1 !important; }
body.quest-sidebar-guide .dt-sidebar .sidebar-logo-short { display: none !important; }
body.quest-sidebar-guide .dt-sidebar .sidebar-logo-full { display: block !important; }
/* Temporarily boost a positioned ancestor above the overlay */
.guide-zboost { z-index: 601 !important; }
.guide-zboost-pos { position: relative !important; }
.guide-highlight {
  position: relative !important; z-index: 601 !important;
  box-shadow: 0 0 0 4px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3) !important;
  pointer-events: none !important;
  animation: guideGlowPulse 2s ease-in-out infinite !important;
}
.guide-highlight-interactive {
  position: relative !important; z-index: 601 !important;
  box-shadow: 0 0 0 4px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3) !important;
  pointer-events: auto !important;
  animation: guideGlowPulse 2s ease-in-out infinite !important;
}
/* Allow interaction when guide step needs user input */
.guide-highlight.guide-interactive {
  pointer-events: auto !important;
}
.guide-highlight.guide-interactive * {
  pointer-events: auto !important;
}
.guide-highlight-fixed {
  z-index: 601 !important;
  box-shadow: 0 0 0 4px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3) !important;
  pointer-events: none !important;
  animation: guideGlowPulse 2s ease-in-out infinite !important;
}
@keyframes guideGlowPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(230,57,70,0.6), 0 0 20px rgba(230,57,70,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(230,57,70,0.8), 0 0 32px rgba(230,57,70,0.5); }
}
/* Tooltip */
.dt-guide-tooltip {
  position: fixed; z-index: 602;
  background: #1a1a1a; border: 2px solid #e63946;
  border-radius: 12px; padding: 16px 20px;
  width: auto; min-width: 300px; max-width: min(460px, calc(100vw - 40px));
  pointer-events: auto;
  box-shadow: 0 0 24px 4px rgba(230,57,70,0.5), 0 0 60px rgba(230,57,70,0.2);
  animation: guideTooltipIn .25s ease-out;
}
.dt-guide-tooltip-content {
  display: flex; align-items: flex-start; gap: 12px;
}
.dt-guide-tooltip-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  image-rendering: pixelated;
  background: url('/images/character/sprite_idle.png') 0 0 / auto 100% no-repeat;
  animation: guide-avatar-idle 1.08s steps(6) infinite;
}
@keyframes guide-avatar-idle { from { background-position: 0 0; } to { background-position: -216px 0; } }
.dt-guide-tooltip-text {
  color: #f0f0f0; font-size: 14px; font-weight: 600; line-height: 21px;
}
/* Tooltip nav */
.dt-guide-tooltip-nav {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-wrap: nowrap;
}
.dt-guide-skip { color: #888; font-size: 13px; font-weight: 600; cursor: pointer; background: none; border: none; padding: 4px 8px; white-space: nowrap; flex-shrink: 0; }
.dt-guide-skip:hover { color: #bbb; }
.dt-guide-dots { display: flex; gap: 3px; align-items: center; flex: 1; justify-content: center; min-width: 0; overflow: hidden; }
.dt-guide-dot { width: 5px; height: 5px; border-radius: 3px; background: #555; flex-shrink: 0; transition: all .2s; }
.dt-guide-dot.active { background: var(--p5-red); width: 10px; }
.dt-guide-next {
  display: flex; align-items: center; gap: 4px; white-space: nowrap; flex-shrink: 0;
  background: var(--p5-red); color: #fff; font-size: 13px; font-weight: 700;
  border: none; padding: 6px 14px; cursor: pointer;
}
.dt-guide-next:hover { filter: brightness(1.1); }
/* Tooltip arrow */
.dt-guide-tooltip-arrow {
  position: absolute; width: 0; height: 0;
}
.dt-guide-tooltip-arrow.arrow-top {
  top: -8px; left: 50%; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(20,20,20,0.96);
}
.dt-guide-tooltip-arrow.arrow-bottom {
  bottom: -8px; left: 50%; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-top: 8px solid rgba(20,20,20,0.96);
}
.dt-guide-tooltip-arrow.arrow-left {
  left: -8px; top: 24px;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  border-right: 8px solid rgba(20,20,20,0.96);
}
.dt-guide-tooltip-arrow.arrow-right {
  right: -8px; top: 24px;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  border-left: 8px solid rgba(20,20,20,0.96);
}
@keyframes guideTooltipIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
/* Sticky tooltip transition when scrolling */
.dt-guide-tooltip.quest-tooltip-sticky { transition: top .15s ease-out; }
/* HomePet above guide overlay — toggled by JS only on pet step */
.dt-home-pet.guide-above { z-index: 601; }
[data-theme="light"] .dt-guide-tooltip { background: rgba(40,40,40,0.96); }
[data-theme="light"] .dt-guide-tooltip-arrow.arrow-top { border-bottom-color: rgba(40,40,40,0.96); }
[data-theme="light"] .dt-guide-tooltip-arrow.arrow-bottom { border-top-color: rgba(40,40,40,0.96); }
[data-theme="light"] .dt-guide-tooltip-arrow.arrow-left { border-right-color: rgba(40,40,40,0.96); }
[data-theme="light"] .dt-guide-tooltip-arrow.arrow-right { border-left-color: rgba(40,40,40,0.96); }

/* ================================================================
   PUBLISH MODAL — split layout: cover preview + meta + category grid
   ================================================================ */
.dt-pub-modal-box {
  position: relative;
  background: var(--p5-card);
  width: 980px; max-width: 96vw;
  height: 620px; max-height: 92vh;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.dt-pub-modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  transition: background .2s, color .2s;
}
.dt-pub-modal-close:hover { background: var(--p5-card); color: var(--p5-text); }
.dt-pub-modal-body {
  display: flex; flex: 1; min-height: 0;
}
/* Left: Result Preview (60%) — intentionally dark backdrop in both themes for image gallery feel */
.dt-pub-preview {
  flex: 0 0 60%; width: 60%;
  background: #2B2B2B;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; min-height: 0;
}
.dt-pub-preview img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.dt-pub-empty {
  color: #888; font-size: 13px; text-align: center;
}
/* Right: Configuration (40%) */
.dt-pub-config {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 28px 28px 24px;
  background: var(--p5-card);
  overflow-y: auto;
}
.dt-pub-modal-title {
  margin: 0 0 18px;
  font-size: 16px; font-weight: 600;
  color: var(--p5-text);
}
.dt-pub-meta-section { margin-bottom: 16px; }
.dt-pub-field { margin-bottom: 12px; }
.dt-pub-field label {
  display: block;
  font-size: 11px; font-weight: 500;
  color: var(--p5-muted);
  margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.dt-pub-field input,
.dt-pub-field textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  color: var(--p5-text); font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.dt-pub-field input:focus,
.dt-pub-field textarea:focus {
  border-color: var(--p5-red);
  box-shadow: 0 0 0 3px rgba(230,57,70,.12);
}
.dt-pub-field textarea { min-height: 50px; line-height: 1.45; }

/* Category section */
.dt-pub-cat-section { margin-bottom: 16px; }
.dt-pub-cat-label {
  display: block;
  font-size: 11px; font-weight: 500;
  color: var(--p5-muted);
  margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .04em;
}
.dt-pub-cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.dt-pub-cat-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  font-family: inherit;
  min-height: 64px;
}
.dt-pub-cat-btn:hover {
  border-color: var(--p5-red);
  color: var(--p5-text);
}
.dt-pub-cat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
}
.dt-pub-cat-name {
  font-size: 11px; font-weight: 500; line-height: 1.2;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.dt-pub-cat-check {
  position: absolute; top: 4px; right: 4px;
  display: none;
  color: var(--p5-red);
}
.dt-pub-cat-btn.active {
  background: rgba(230,57,70,.12);
  border-color: var(--p5-red);
  color: var(--p5-red);
}
.dt-pub-cat-btn.active .dt-pub-cat-check { display: inline-flex; }

/* Footer */
.dt-pub-footer {
  display: flex; gap: 10px; margin-top: auto;
}
.dt-pub-cancel-btn {
  flex: 0 0 auto;
  padding: 11px 22px;
  background: transparent; border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.dt-pub-cancel-btn:hover { border-color: var(--p5-muted); color: var(--p5-text); }
.dt-pub-confirm-btn {
  flex: 1;
  padding: 11px 22px;
  background: var(--p5-red); border: 1px solid var(--p5-red);
  color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.dt-pub-confirm-btn:hover { opacity: .9; }
.dt-pub-unpublish-row {
  margin-top: 10px;
  text-align: center;
}
.dt-pub-unpublish-link {
  background: none; border: none;
  color: var(--p5-muted); font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.dt-pub-unpublish-link:hover { color: var(--p5-red); }

/* ================================================================
   GENERATE PUBLICATION MODAL — for tasks.publications (separate from workshop dt-pub-modal)
   Visual style mirrors dt-pub-modal: split layout, light surface, red accent, sharp corners.
   ================================================================ */
/* ═══════════════════════════════════════════════════════════════════
   Publish Modal — "Floating Canvas" + dual theme support
   All colors use var(--p5-*) tokens for automatic dark/light switching.
   ═══════════════════════════════════════════════════════════════════ */
.dt-gen-pub-box {
  position: relative;
  background: var(--p5-card);
  width: 900px; max-width: 96vw;
  height: 640px; max-height: 92vh;
  box-shadow: 0 30px 80px var(--p5-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.dt-gen-pub-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  color: var(--p5-muted); font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  transition: background .2s, color .2s;
}
.dt-gen-pub-close:hover { color: var(--p5-text); }

.dt-gen-pub-body { display: flex; flex: 1 1 0; min-height: 0; overflow: hidden; }

/* ─── Left: Floating Canvas — cover preview + thumbs (55%) ─── */
.dt-gen-pub-left {
  flex: 0 0 55%; width: 55%;
  background: var(--p5-surface);
  display: flex; flex-direction: column; min-height: 0;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--p5-border);
}
/* Dot grid — Figma-style canvas texture */
.dt-gen-pub-left::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--p5-border) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}
/* Radial vignette — draws eye to center */
.dt-gen-pub-left::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, var(--p5-surface) 100%);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.dt-gen-pub-cover-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 28px 28px 16px;
  overflow: hidden;
  position: relative; z-index: 1;
}
.dt-gen-pub-cover-wrap img,
.dt-gen-pub-cover-wrap video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  /* Multi-layer shadow: contact + depth + red ambient glow */
  box-shadow:
    0 2px 8px rgba(0,0,0,0.2),
    0 12px 40px rgba(0,0,0,0.3),
    0 0 60px -10px rgba(230,57,70,0.08);
  transition: box-shadow .3s ease, transform .3s ease;
}
.dt-gen-pub-cover-wrap img:hover,
.dt-gen-pub-cover-wrap video:hover {
  box-shadow:
    0 4px 12px rgba(0,0,0,0.25),
    0 20px 50px rgba(0,0,0,0.35),
    0 0 80px -10px rgba(230,57,70,0.14);
  transform: translateY(-2px);
}
.dt-gen-pub-empty {
  color: var(--p5-muted); font-size: 13px; text-align: center;
  position: relative; z-index: 1;
}

/* MJ 4-image 2×2 grid mode */
.dt-gen-pub-cover-wrap.dt-gen-pub-grid-mode {
  padding: 16px;
  align-items: stretch;
}
.dt-gen-pub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%; height: 100%;
  position: relative; z-index: 1;
}
.dt-gen-pub-grid-item {
  overflow: hidden;
}
.dt-gen-pub-grid-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .3s;
}
.dt-gen-pub-grid-item img.loaded { opacity: 1; }

/* Thumbnail strip */
.dt-gen-pub-thumbs {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  padding: 0 28px 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-height: 0;
  position: relative; z-index: 1;
}
.dt-gen-pub-thumbs::-webkit-scrollbar { height: 4px; }
.dt-gen-pub-thumbs::-webkit-scrollbar-track { background: transparent; }
.dt-gen-pub-thumbs::-webkit-scrollbar-thumb { background: var(--p5-border); }
.dt-gen-pub-thumb {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  padding: 0;
  background: var(--p5-dark);
  border: 2px solid var(--p5-border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.dt-gen-pub-thumb:hover {
  border-color: var(--p5-muted);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--p5-shadow);
}
.dt-gen-pub-thumb.active {
  border-color: var(--p5-red);
  box-shadow: 0 0 0 2px rgba(230,57,70,0.2), 0 4px 12px var(--p5-shadow);
}
.dt-gen-pub-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* ─── Right: form config (45%) ─── */
.dt-gen-pub-right {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 26px 26px 22px;
  background: var(--p5-card);
  overflow-y: auto;
}
.dt-gen-pub-title-text {
  margin: 0 0 16px;
  font-size: 16px; font-weight: 600;
  color: var(--p5-text);
}
.dt-gen-pub-field { margin-bottom: 12px; }
.dt-gen-pub-field > label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--p5-text-secondary);
  margin-bottom: 5px;
}
.dt-gen-pub-required { color: var(--p5-red); font-weight: 600; }
.dt-gen-pub-field input[type="text"],
.dt-gen-pub-field textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  color: var(--p5-text); font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.dt-gen-pub-field input[type="text"]:focus,
.dt-gen-pub-field textarea:focus {
  border-color: var(--p5-red);
  box-shadow: 0 0 0 3px rgba(230,57,70,.12);
}
.dt-gen-pub-field textarea { min-height: 48px; line-height: 1.45; }
.dt-gen-pub-counter {
  display: block;
  text-align: right;
  font-size: 10px;
  color: var(--p5-muted);
  margin-top: 3px;
}

/* Read-only prompt preview */
.dt-gen-pub-prompt-preview {
  padding: 8px 11px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  font-size: 13px;
  line-height: 1.5;
  max-height: 72px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin-bottom: 6px;
}

/* Checkbox row */
.dt-gen-pub-checkbox {
  display: flex; align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--p5-text-secondary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin-top: 6px;
}
.dt-gen-pub-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--p5-red);
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Publish targets — bottom bar */
.dt-gen-pub-targets {
  flex-shrink: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--p5-border);
  background: var(--p5-card);
}
.dt-gen-pub-targets-label {
  font-size: 11px; font-weight: 500;
  color: var(--p5-muted);
  margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .04em;
}
.dt-gen-pub-targets-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.dt-gen-pub-target-btn {
  flex: 1 1 0; min-width: 0;
  padding: 10px 14px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: border-color .15s, background .15s, color .15s, transform .15s;
  white-space: nowrap;
}
.dt-gen-pub-target-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--p5-shadow);
}
.dt-gen-pub-target-btn svg { flex-shrink: 0; }

/* Brand hover colors per platform */
.dt-gen-pub-target-btn.dt-gen-pub-target-x:hover {
  border-color: var(--p5-text); color: var(--p5-text);
}
.dt-gen-pub-target-btn.dt-gen-pub-target-fb:hover {
  border-color: #1877F2; color: #1877F2; background: rgba(24,119,242,0.06);
}
.dt-gen-pub-target-btn.dt-gen-pub-target-tg:hover {
  border-color: #26A5E4; color: #26A5E4; background: rgba(38,165,228,0.06);
}
/* Copy link button — dashed border to distinguish from social platforms */
.dt-gen-pub-target-btn.dt-gen-pub-target-copy {
  border-style: dashed;
  color: var(--p5-muted);
}
.dt-gen-pub-target-btn.dt-gen-pub-target-copy:hover {
  border-style: solid;
  border-color: var(--p5-red);
  color: var(--p5-red);
  background: rgba(230,57,70,0.06);
}

/* Discover button — red outline, matches other buttons */
.dt-gen-pub-target-btn.dt-gen-pub-target-primary {
  border-color: var(--p5-red);
  color: var(--p5-red);
}
.dt-gen-pub-target-btn.dt-gen-pub-target-primary:hover {
  background: rgba(230,57,70,0.08);
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(230,57,70,0.2);
}

/* Edit-mode footer (save changes + retract) */
/* Save button wrapper — above share section, full width */
.dt-gen-pub-save-wrap {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
/* Retract link — inside bottom targets bar */
.dt-gen-pub-retract-wrap {
  margin-top: 8px;
  text-align: center;
}
.dt-gen-pub-save-btn {
  width: 100%;
  padding: 10px 22px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-red);
  color: var(--p5-red);
  font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.dt-gen-pub-save-btn:hover { background: rgba(230,57,70,0.06); }
.dt-gen-pub-retract-link {
  background: none; border: none;
  color: var(--p5-muted); font-size: 11px;
  cursor: pointer; text-decoration: underline;
  font-family: inherit; padding: 4px;
  align-self: center;
}
.dt-gen-pub-retract-link:hover { color: var(--p5-red); }

@media (max-width: 780px) {
  .dt-gen-pub-box { width: 96vw; height: 92vh; }
  .dt-gen-pub-body { flex-direction: column; }
  .dt-gen-pub-left { flex: 0 0 40%; width: 100%; }
  .dt-gen-pub-right { padding: 20px; }
  .dt-gen-pub-targets { padding: 10px 16px; }
  .dt-gen-pub-targets-row { gap: 6px; }
  .dt-gen-pub-target-btn { padding: 8px 6px; font-size: 11px; }
  .dt-gen-pub-target-btn span { display: none; }
  .dt-gen-pub-target-btn.dt-gen-pub-target-primary span { display: inline; }
}

/* ─── View stats — frosted glass pill, top-left overlay ─── */
.dt-gen-pub-view-stats {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  padding: 8px 14px;
  background: rgba(10,10,15,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
}
.dt-gen-pub-view-stats .vstat-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--p5-red-light);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.dt-gen-pub-view-stats .vstat-total {
  font-weight: 700;
  color: #fff;
  margin-right: 3px;
  font-size: 13px;
}
.dt-gen-pub-view-stats .vstat-item {
  padding-left: 8px;
  margin-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.15);
}
.dt-gen-pub-view-stats .vstat-item:first-of-type {
  padding-left: 0;
  margin-left: 0;
  border-left: none;
}
/* Light theme */
[data-theme="light"] .dt-gen-pub-view-stats {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.55);
}
[data-theme="light"] .dt-gen-pub-view-stats .vstat-header { color: var(--p5-red); }
[data-theme="light"] .dt-gen-pub-view-stats .vstat-total { color: rgba(0,0,0,0.85); }
[data-theme="light"] .dt-gen-pub-view-stats .vstat-item { border-left-color: rgba(0,0,0,0.12); }

/* ─── Edit-mode status card ─── */
.dt-gen-pub-status-card {
  margin: 4px 0 14px;
  padding: 12px 14px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  border-left: 3px solid var(--p5-red);
  display: flex; align-items: center; gap: 12px;
}
.dt-gen-pub-status-row {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
.dt-gen-pub-status-dot {
  width: 10px; height: 10px; flex-shrink: 0;
  background: var(--p5-muted);
}
.dt-gen-pub-status-dot.active {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
}
.dt-gen-pub-status-text { flex: 1; min-width: 0; }
.dt-gen-pub-status-title {
  font-size: 12px; font-weight: 600;
  color: var(--p5-text); line-height: 1.3;
}
.dt-gen-pub-status-desc {
  font-size: 11px; color: var(--p5-muted);
  margin-top: 2px; line-height: 1.3;
}
.dt-gen-pub-status-action-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-red);
  color: var(--p5-red);
  font-size: 12px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  white-space: nowrap; transition: background .15s;
}
.dt-gen-pub-status-action-btn:hover { background: rgba(230,57,70,0.06); }

/* Discover card — description under title (fallback-friendly: renders only if pub.description present) */
.dt-pub-card-desc {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--p5-text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
}


/* Mobile: stack vertically */
@media (max-width: 760px) {
  .dt-pub-modal-box { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; }
  .dt-pub-modal-body { flex-direction: column; }
  .dt-pub-preview { flex: 0 0 38%; width: 100%; padding: 16px; }
  .dt-pub-config { padding: 18px 18px 16px; }
  .dt-pub-cat-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .dt-pub-cat-btn { min-height: 56px; padding: 8px 4px; }
  .dt-pub-cat-name { font-size: 10px; }
}


/* ================================================================
   TEMPLATE DETAIL MODAL (overlay)
   ================================================================ */
.dt-tpl-modal {
  display: none; position: fixed; inset: 0;
  z-index: 250; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

/* Template detail loading skeleton (used inside modal hero before content loads) */
.dt-tpl-loading { padding: 20px 0; }
.dt-tpl-skel-cover { width: 100%; max-width: 360px; height: 240px; background: var(--p5-border); }
.dt-tpl-skel-lines { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.dt-tpl-skel-line { height: 16px; background: var(--p5-border); }
.dt-tpl-skel-line.w60 { width: 60%; }
.dt-tpl-skel-line.w90 { width: 90%; }
.dt-tpl-skel-line.w40 { width: 40%; }
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.dt-tpl-modal.active { display: flex; }
.dt-tpl-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  z-index: 0;
}
.dt-tpl-modal-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 900px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 28px 28px 24px;
  margin: auto;
}
.dt-tpl-modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-text); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.dt-tpl-modal-close:hover {
  background: var(--p5-red); border-color: var(--p5-red); color: #fff;
}

/* H5 page header with back button — reusable for slide-in pages */
/* ---- Left: Visual ---- */
.dt-tpl-canvas { display: flex; flex-direction: column; }
/* dt-tpl-cover-wrap base style defined at line ~1617, not duplicated here */
.dt-tpl-cover-ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(140,80,220,0.12) 0%, rgba(60,120,230,0.08) 100%);
  color: rgba(255,255,255,0.15);
}
/* Category badge overlay (top-left) */
.dt-tpl-category-overlay {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  padding: 5px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: #fff; background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
}
/* ---- Right: Info & CTA ---- */
.dt-tpl-control {
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
/* Title */
.dt-tpl-control-title {
  font-size: 22px; font-weight: 800; color: var(--p5-text);
  margin: 0; line-height: 1.25;
  letter-spacing: -0.2px;
}
/* Description */
.dt-tpl-control-desc {
  font-size: 14px; color: var(--p5-muted); margin: 0; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
/* Author */
.dt-tpl-author {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--p5-border);
  border-bottom: 1px solid var(--p5-border);
}
.dt-tpl-author .tpl-avatar {
  width: 42px; height: 42px; object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--p5-border);
}
.dt-tpl-author .author-letter {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  font-size: 16px; font-weight: 700; color: var(--p5-text); flex-shrink: 0;
}
.dt-tpl-author .tpl-author-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dt-tpl-author .tpl-author-name { font-size: 14px; font-weight: 700; color: var(--p5-text); }
.dt-tpl-author .tpl-author-sub { font-size: 11px; color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; }
/* Tags */
.dt-tpl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-tpl-tags .tpl-tag {
  padding: 4px 11px; font-size: 11px; font-weight: 500;
  color: var(--p5-muted); background: var(--p5-dark);
  border: 1px solid var(--p5-border);
}
/* Tech params */
.dt-tpl-tech-row {
  display: flex; flex-wrap: wrap; column-gap: 18px; row-gap: 4px;
  font-size: 12px; color: var(--p5-muted);
}
.dt-tpl-tech-label { color: var(--p5-muted); }
.dt-tpl-tech-row strong { color: var(--p5-text); font-weight: 700; }
/* Spacer */
.dt-tpl-spacer { flex: 1; min-height: 8px; }
/* Actions row — beefy CTA */
.dt-tpl-actions {
  display: flex; gap: 10px; align-items: stretch;
  padding-top: 6px;
}
.dt-tpl-use-btn {
  flex: 1; padding: 14px 20px; font-size: 14px; font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff; background: var(--p5-red); border: 1px solid var(--p5-red);
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
  text-transform: uppercase;
}
.dt-tpl-use-btn:hover { background: #d62836; border-color: #d62836; }
.dt-tpl-use-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.dt-tpl-like {
  width: 60px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--p5-dark); border: 1px solid var(--p5-border); color: var(--p5-muted);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.dt-tpl-like svg { width: 22px; height: 22px; }
.dt-tpl-like:hover { color: var(--p5-red); border-color: var(--p5-red); }
.dt-tpl-like.liked { color: var(--p5-red); border-color: var(--p5-red); }

/* ---- More Like This — full-width waterfall ---- */
.dt-tpl-related {
  margin-top: 8px; padding-top: 28px;
  border-top: 1px solid var(--p5-border);
}
.dt-tpl-related h2 {
  font-size: 18px; font-weight: 700; color: var(--p5-text);
  margin: 0 0 20px;
  letter-spacing: -0.2px;
}
.dt-tpl-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.dt-tpl-related-grid .tpl-rel-card {
  display: block;
}

/* ---- Results gallery ---- */
.dt-tpl-results { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--p5-border); }
.dt-tpl-results h2 { font-size: 16px; color: var(--p5-text); margin: 0 0 16px; }
.tpl-rel-card {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  cursor: pointer; overflow: hidden;
  transition: transform .2s, border-color .2s;
}
.tpl-rel-card:hover { transform: translateY(-3px); border-color: rgba(140,80,220,0.4); }
.tpl-rel-cover { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.tpl-rel-cover-ph {
  width: 100%; aspect-ratio: 16/10;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(140,80,220,0.10) 0%, rgba(60,120,230,0.06) 100%);
  color: rgba(255,255,255,0.12);
}
.tpl-rel-info { padding: 10px 12px; }
.tpl-rel-cat {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  color: var(--p5-yellow); letter-spacing: 0.5px;
}
.tpl-rel-title {
  font-size: 13px; font-weight: 600; color: var(--p5-text);
  margin: 4px 0 6px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tpl-rel-meta {
  display: flex; gap: 12px; font-size: 11px; color: var(--p5-muted);
}
.tpl-rel-meta span { display: inline-flex; align-items: center; gap: 3px; }

/* Composite Landing Page Preview */
.dt-tpl-preview { margin-top: 32px; margin-bottom: 8px; max-width: 1100px; }
.dt-tpl-preview-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.dt-tpl-preview-header h2 { font-size: 18px; color: var(--p5-text); margin: 0; }
.dt-tpl-preview-expand {
  background: var(--p5-dark); border: 1px solid var(--p5-border);
  color: var(--p5-muted); cursor: pointer; padding: 6px 8px;
  display: flex; align-items: center; transition: color .2s, border-color .2s;
}
.dt-tpl-preview-expand:hover { color: var(--p5-text); border-color: var(--p5-text); }
.dt-tpl-preview-body {
  border: 1px solid var(--p5-border); background: #fff;
  overflow: hidden; max-height: 700px;
}
.dt-tpl-preview-body iframe {
  display: block; width: 100%; min-height: 400px; border: none; background: #fff;
}
.preview-lb-content { width: 90vw; height: 90vh; background: #fff; }
.preview-lb-content iframe { width: 100%; height: 100%; border: none; background: #fff; }

/* ================================================================ */
/* IMAGE STUDIO V1                                                  */
/* ================================================================ */
.is-layout { padding: 24px 32px; }
.is-header {
  margin-bottom: 20px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.is-header-left { flex: 0 0 auto; }
.is-header-right {
  display: flex; align-items: center; gap: 12px;
  flex: 1 1 auto; justify-content: flex-end; flex-wrap: wrap;
}
.is-title { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--p5-text); margin: 0 0 4px; }
.is-subtitle { color: var(--p5-text-secondary); font-size: var(--text-sm); margin: 0; }

/* Search bar — compact pill in the top-right of is-header */
.is-search-bar {
  position: relative; display: flex; align-items: center;
  width: 260px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  transition: border-color .2s;
}
.is-search-bar:focus-within { border-color: var(--p5-red); }
.is-search-icon {
  position: absolute; left: 10px;
  color: var(--p5-text-secondary); pointer-events: none;
}
#is-search-input {
  width: 100%; padding: 8px 30px 8px 32px;
  background: transparent; border: none; outline: none;
  color: var(--p5-text); font-size: 13px;
}
#is-search-input::placeholder { color: var(--p5-text-secondary); }
.is-search-clear {
  position: absolute; right: 8px;
  background: none; border: none; color: var(--p5-text-secondary);
  cursor: pointer; padding: 2px; line-height: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s;
}
.is-search-clear:hover { color: var(--p5-red); }

/* Category filter — match Workshop .wf-btn outlined pill style */
.is-categories { display: flex; gap: 4px; flex-wrap: wrap; }
.is-cat-pill {
  padding: 5px 14px;
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .2s, color .2s, background .2s;
}
.is-cat-pill:hover { border-color: #555; color: var(--p5-text); }
.is-cat-pill.active {
  border-color: var(--p5-red);
  color: var(--p5-red);
  background: rgba(230,57,70,0.08);
}

.is-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.is-card {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.is-card:hover { border-color: var(--p5-red); transform: translateY(-2px); }
.is-card-cover {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  background: var(--p5-input-bg);
  display: block;
}
.is-card-placeholder {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16/9;
}
.is-card-meta { padding: 10px 12px; }
.is-card-name {
  font-size: var(--text-sm); color: var(--p5-text); font-weight: var(--weight-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
.is-card-bottom {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--text-xs); color: var(--p5-muted);
}
.is-card-status { padding: 2px 6px; border: 1px solid var(--p5-border); }
.is-status-success { color: #10b981; border-color: #10b981; }
.is-status-failure { color: #ef4444; border-color: #ef4444; }
.is-status-processing,
.is-status-generating_prompt,
.is-status-prompt_ready,
.is-status-submitting { color: #f59e0b; border-color: #f59e0b; }

.is-card-create {
  background: transparent;
  border: 2px dashed var(--p5-border);
  min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--p5-muted);
  transition: border-color 0.2s, color 0.2s;
}
.is-card-create:hover { border-color: var(--p5-red); color: var(--p5-red); transform: none; }
.is-card-plus { margin-bottom: 8px; }
.is-card-create-label { font-size: var(--text-sm); font-weight: var(--weight-medium); }

.is-empty { text-align: center; padding: 64px 32px; color: var(--p5-muted); }
.is-empty svg { margin-bottom: 16px; opacity: 0.5; }
.is-empty p { font-size: var(--text-base); margin-bottom: 20px; }

/* Detail View */
.is-detail-wrap { padding: 24px 32px; max-width: 1200px; }
.is-detail-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.is-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--p5-border);
  color: var(--p5-text); padding: 8px 14px; font-size: var(--text-sm);
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.is-back-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.is-detail-title {
  flex: 1; margin: 0; font-size: var(--text-xl); color: var(--p5-text); font-weight: var(--weight-semibold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-detail-actions { display: flex; gap: 8px; }
.dt-btn-danger {
  background: transparent; border: 1px solid #ef4444; color: #ef4444;
  padding: 8px 14px; font-size: var(--text-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s;
}
.dt-btn-danger:hover { background: #ef4444; color: #fff; }

.is-detail-body {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 24px;
}
.is-detail-image-wrap {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  min-height: 400px; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.is-detail-img { max-width: 100%; max-height: 720px; display: block; cursor: zoom-in; }
.is-detail-loader {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  color: var(--p5-muted); padding: 48px;
}
.is-loader-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--p5-border);
  border-top-color: var(--p5-red);
  animation: is-spin 0.9s linear infinite;
}
@keyframes is-spin { to { transform: rotate(360deg); } }

.is-detail-meta {
  background: var(--p5-card); border: 1px solid var(--p5-border); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  align-self: start;
}
.is-meta-row {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 10px; border-bottom: 1px solid var(--p5-border);
}
.is-meta-row:last-child { border-bottom: none; padding-bottom: 0; }
.is-meta-label {
  font-size: var(--text-xs); color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.is-meta-value { font-size: var(--text-sm); color: var(--p5-text); word-break: break-word; }

/* Create Modal */
.is-create-box {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  width: 90%; max-width: 620px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px var(--p5-shadow);
}
.is-create-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--p5-border);
}
.is-create-header h3 {
  margin: 0; font-size: var(--text-lg); color: var(--p5-text); font-weight: var(--weight-semibold);
}
.is-create-close {
  background: transparent; border: none; color: var(--p5-muted);
  font-size: 24px; cursor: pointer; padding: 0; width: 28px; height: 28px;
}
.is-create-close:hover { color: var(--p5-text); }
.is-create-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.is-form-section { margin-bottom: 16px; }
.is-form-section label {
  display: block; font-size: var(--text-xs); color: var(--p5-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.is-form-section input, .is-form-section textarea, .is-form-section select {
  width: 100%; background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  color: var(--p5-text); padding: 10px 12px; font-size: var(--text-sm);
  font-family: inherit; border-radius: 0;
}
.is-form-section input::placeholder, .is-form-section textarea::placeholder {
  color: var(--p5-muted);
}
.is-form-section input:focus, .is-form-section textarea:focus, .is-form-section select:focus {
  outline: none; border-color: var(--p5-red);
}
.is-form-section textarea { resize: vertical; min-height: 80px; }
.is-form-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }

.is-progress {
  background: var(--p5-input-bg); border: 1px solid var(--p5-border);
  padding: 14px; margin-top: 14px;
}
.is-progress-steps { display: flex; flex-direction: column; gap: 6px; }
.is-progress-step {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); color: var(--p5-text-secondary);
}
.is-step-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--p5-muted);
  flex-shrink: 0;
}
.is-step-R .is-step-dot, .is-step-I .is-step-dot, .is-step-P .is-step-dot, .is-step-E .is-step-dot {
  background: var(--p5-red);
}
.is-step-done .is-step-dot { background: #10b981; }
.is-step-error .is-step-dot { background: #ef4444; }
.is-step-error .is-step-msg { color: #ef4444; }

.is-prompt-preview {
  margin-top: 12px; padding: 10px 12px;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  font-size: var(--text-xs); color: var(--p5-text-secondary);
  max-height: 120px; overflow-y: auto; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

.is-create-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-top: 1px solid var(--p5-border);
}
.is-price-tag { font-size: var(--text-sm); color: var(--p5-muted); }
.is-footer-actions { display: flex; gap: 10px; }

/* Footer buttons — copied from .dt-wiz-actions workshop style */
.is-footer-actions .dt-btn {
  padding: 10px 20px;
  background: none;
  border: 1px solid var(--p5-border);
  color: var(--p5-muted);
  font-size: 13px;
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: border-color .2s, color .2s;
  border-radius: 0;
  font-family: inherit;
}
.is-footer-actions .dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.is-footer-actions .dt-btn-primary {
  padding: 10px 24px;
  background: var(--p5-red-gradient);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: var(--weight-semibold);
  transition: opacity .2s;
}
.is-footer-actions .dt-btn-primary:hover { opacity: 0.88; border-color: transparent; color: #fff; }
.is-footer-actions .dt-btn-primary:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 768px) {
  .is-layout, .is-detail-wrap { padding: 16px; }
  .is-detail-body { grid-template-columns: 1fr; }
  .is-form-row { grid-template-columns: 1fr; }
  .is-cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .is-header { flex-direction: column; align-items: stretch; }
  .is-header-right { justify-content: flex-start; }
  .is-search-bar { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   MV Script Styles (.mvs-*)
   ═══════════════════════════════════════════════════════════════ */

.mvs-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.mvs-header-title { margin: 0; font-size: var(--text-md); color: var(--p5-text); font-weight: 600; }
.mvs-header-step {
  margin-left: auto; font-size: var(--text-sm); color: var(--p5-text-secondary);
  padding: 4px 12px; border: 1px solid var(--p5-border); border-radius: 0;
}
.mvs-header-step.mvs-confirmed { border-color: var(--p5-red); color: var(--p5-red); }

.mvs-body { flex: 1; overflow-y: auto; padding: 20px; min-height: 0; }

/* Loading / Progress */
.mvs-loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; }
.mvs-loading-text { color: var(--p5-text-secondary); font-size: var(--text-sm); }
.mvs-progress-steps { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 400px; }
.mvs-step { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--p5-text-secondary); }
.mvs-step-dot {
  width: 8px; height: 8px; border-radius: 0; flex-shrink: 0;
  background: var(--p5-border);
}
.mvs-step-running .mvs-step-dot { background: var(--p5-red); animation: mvsPulse 1s infinite; }
.mvs-step-done .mvs-step-dot { background: #4caf50; }
.mvs-step-error .mvs-step-dot { background: #f44336; }
@keyframes mvsPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Concept Card */
.mvs-concept-card { display: flex; flex-direction: column; gap: 16px; }
.mvs-concept-section {
  padding: 12px 16px; background: var(--p5-card); border: 1px solid var(--p5-border); border-radius: 0;
}
.mvs-concept-label {
  font-size: var(--text-xs); color: var(--p5-red); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.mvs-concept-value { font-size: var(--text-sm); color: var(--p5-text); line-height: 1.5; }
.mvs-concept-actions {
  display: flex; gap: 12px; justify-content: flex-end; padding: 16px 20px;
  border-top: 1px solid var(--p5-border); flex-shrink: 0;
}

/* Color Palette */
.mvs-palette-grid { display: flex; flex-direction: column; gap: 6px; }
.mvs-palette-row { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); }
.mvs-palette-label { color: var(--p5-text-secondary); min-width: 70px; font-size: var(--text-xs); text-transform: capitalize; }
.mvs-palette-colors { color: var(--p5-text); }
.mvs-palette-tone { color: var(--p5-muted); font-size: var(--text-xs); }

/* Visual Motifs */
.mvs-motifs-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mvs-motif-chip {
  padding: 3px 10px; font-size: var(--text-xs); color: var(--p5-red);
  border: 1px solid var(--p5-red); border-radius: 0; background: transparent;
}

/* Scenes Layout */
.mvs-scenes-layout {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.mvs-section-sidebar {
  width: 260px; flex-shrink: 0; border-right: 1px solid var(--p5-border);
  overflow-y: auto; padding: 8px 0;
}
.mvs-scene-detail { flex: 1; overflow-y: auto; padding: 16px 20px; min-height: 0; }
.mvs-scenes-footer {
  padding: 12px 20px; border-top: 1px solid var(--p5-border);
  display: flex; justify-content: flex-end; flex-shrink: 0;
}

/* Section Sidebar Items */
.mvs-section-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  cursor: pointer; transition: background 0.15s;
}
.mvs-section-item:hover { background: var(--p5-hover); }
.mvs-section-item.active { background: var(--p5-hover); border-left: 3px solid var(--p5-red); }
.mvs-section-icon { color: var(--p5-text-secondary); flex-shrink: 0; display: flex; }
.mvs-section-info { flex: 1; min-width: 0; }
.mvs-section-label { font-size: var(--text-sm); color: var(--p5-text); font-weight: 600; }
.mvs-section-preview { font-size: var(--text-xs); color: var(--p5-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mvs-section-check { flex-shrink: 0; display: flex; }
.mvs-section-item.done .mvs-section-label { color: var(--p5-text); }

/* Sub-scene Cards */
.mvs-subscene-card {
  padding: 14px 16px; margin-bottom: 12px;
  background: var(--p5-card); border: 1px solid var(--p5-border); border-radius: 0;
}
.mvs-subscene-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mvs-subscene-num { font-size: var(--text-xs); color: var(--p5-red); font-weight: 600; text-transform: uppercase; }
.mvs-subscene-dur { font-size: var(--text-xs); color: var(--p5-muted); }
.mvs-subscene-field { margin-bottom: 8px; }
.mvs-field-label { font-size: var(--text-xs); color: var(--p5-text-secondary); margin-bottom: 2px; display: block; }
.mvs-field-value { font-size: var(--text-sm); color: var(--p5-text); line-height: 1.5; }

/* Meta Chips */
.mvs-subscene-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.mvs-meta-chip {
  padding: 2px 8px; font-size: 11px; border-radius: 0;
  background: var(--p5-input-bg); color: var(--p5-text-secondary);
  border: 1px solid var(--p5-border);
}

/* Scene Lyrics Block */
.mvs-scene-lyrics {
  padding: 12px 16px; margin-bottom: 16px;
  background: var(--p5-input-bg); border-left: 3px solid var(--p5-red);
}
.mvs-lyrics-label { font-size: var(--text-xs); color: var(--p5-red); font-weight: 600; margin-bottom: 4px; }
.mvs-lyrics-text { font-size: var(--text-sm); color: var(--p5-text-secondary); line-height: 1.6; }

.mvs-scene-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Confirm Page */
.mvs-confirm-section {
  margin-bottom: 16px; padding: 14px 16px;
  background: var(--p5-card); border: 1px solid var(--p5-border); border-radius: 0;
}
.mvs-confirm-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mvs-confirm-label { font-size: var(--text-sm); color: var(--p5-red); font-weight: 600; }
.mvs-confirm-type { font-size: var(--text-xs); color: var(--p5-muted); text-transform: capitalize; }
.mvs-confirm-lyrics {
  font-size: var(--text-xs); color: var(--p5-text-secondary); line-height: 1.5;
  padding: 8px 12px; margin-bottom: 8px; background: var(--p5-input-bg); border-left: 2px solid var(--p5-border);
}
.mvs-confirm-subscene { margin-bottom: 8px; }
.mvs-confirm-desc { font-size: var(--text-sm); color: var(--p5-text); line-height: 1.5; margin-bottom: 4px; }
.mvs-confirm-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.mvs-confirm-badge {
  text-align: center; padding: 12px; margin-top: 20px;
  color: var(--p5-red); font-weight: 600; font-size: var(--text-sm);
  border: 1px solid var(--p5-red); border-radius: 0;
}

.mvs-empty { text-align: center; color: var(--p5-muted); padding: 40px 0; font-size: var(--text-sm); }

/* ═══════════════════════════════════════════════════════════════
   MV Script Workspace V2 (.mvsw-*) — unified one-page workspace
   Replaces old .mvs-concept/scenes/confirm panel styles.
   ═══════════════════════════════════════════════════════════════ */

/* Shared panel header (used by Assets / Storyboard / Compositing; removed from Script in V2) */
.mvsw-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.mvsw-title { margin: 0; font-size: var(--text-md); color: var(--p5-text); font-weight: 600; }
.mvsw-header-actions { margin-left: auto; display: flex; gap: 8px; }

.mvsw-body { flex: 1; overflow-y: auto; min-height: 0; position: relative; }

/* Empty state (hero CTA) */
.mvsw-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; gap: 16px; text-align: center; min-height: 500px;
}
.mvsw-empty-icon { color: var(--p5-red); opacity: 0.5; }
.mvsw-empty-title { margin: 0; font-size: 20px; color: var(--p5-text); font-weight: 600; }
.mvsw-empty-desc { margin: 0; max-width: 420px; font-size: var(--text-sm); color: var(--p5-text-secondary); line-height: 1.6; }
/* Match song-ws-btn-primary visual: solid red + black text (default) → darker red + white text (hover) */
.mvsw-empty-cta {
  padding: 13px 32px !important;
  background: var(--p5-red) !important;
  color: #000 !important;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 0 !important;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mvsw-empty-cta:hover {
  background: #c02836 !important;
  color: #fff !important;
  opacity: 1 !important;
}
.mvsw-empty-cta svg { width: 14px; height: 14px; }

/* Loading (progress overlay) */
.mvsw-loading {
  display: flex; flex-direction: column; gap: 12px;
  padding: 40px 32px; max-width: 640px; margin: 40px auto;
}
.mvsw-loading-header {
  display: flex; align-items: center; gap: 12px;
}
.mvsw-loading-phase {
  flex: 1; font-size: var(--text-md); color: var(--p5-text); font-weight: 500;
}
.mvsw-loading-bar {
  height: 3px; background: var(--p5-border); overflow: hidden;
}
.mvsw-loading-bar-fill {
  height: 100%; background: var(--p5-red); transition: width 0.4s;
}
.mvsw-loading-steps {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
  max-height: 200px; overflow-y: auto;
}
.mvsw-step { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--p5-text-secondary); }
.mvsw-step-dot {
  width: 6px; height: 6px; flex-shrink: 0; background: var(--p5-border);
}
.mvsw-step-running .mvsw-step-dot { background: var(--p5-red); animation: mvsPulse 1s infinite; }
.mvsw-step-done .mvsw-step-dot { background: #4caf50; }
.mvsw-step-error .mvsw-step-dot { background: #f44336; }

/* ═══════════════════════════════════════════════════════════════ */
/* SCRIPT V2 (ref: camikalabs-UI/project/mv-creation.html Screen 2)   */
/* Hero + 6 sections, 640px centered, no right-side stats panel       */
/* ═══════════════════════════════════════════════════════════════ */

.mvsw-content {
  padding: 22px 20px 48px;
  max-width: 860px;
  margin: 0 auto;
}

/* Hero · MV CONCEPT — red accent bar + red icon box + paragraph */
.mv2-hero {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px;
  background: var(--p5-card);
  border: 1px solid rgba(230, 57, 70, 0.35);
  margin-bottom: 22px;
  position: relative;
}
.mv2-hero::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--p5-red);
}
.mv2-hero-icon {
  width: 28px; height: 28px;
  background: var(--p5-red); color: #000;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 800; font-size: 14px;
}
.mv2-hero-body { flex: 1; min-width: 0; }
.mv2-hero-label {
  font-family: var(--font-display);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--p5-red);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.mv2-hero-text {
  font-size: 12.5px; line-height: 1.6;
  color: var(--p5-text-secondary);
}

/* Section block */
.mv2-sec { margin-bottom: 22px; }
.mv2-sec-hd {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--p5-border);
}
.mv2-sec-tag {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  padding: 2px 6px;
  background: var(--p5-red); color: #000;
  font-weight: 700; letter-spacing: 0.08em;
}
.mv2-sec-h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600; font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--p5-text);
  text-transform: uppercase;
}
.mv2-sec-meta {
  margin-left: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mv2-sec p {
  font-size: 13px; line-height: 1.85;
  color: var(--p5-text-secondary);
  margin: 0 0 6px 0;
}
.mv2-sec p em {
  color: var(--p5-red); font-style: normal; font-weight: 600;
  background: rgba(230, 57, 70, 0.08);
  padding: 0 3px;
}
.mv2-sec p strong { color: var(--p5-text); font-weight: 700; }

/* Chips — grid 2/3/4 cols depending on modifier */
.mv2-chips {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 4px;
}
.mv2-chips.cols-2 { grid-template-columns: repeat(2, 1fr); }
.mv2-chips.cols-4 { grid-template-columns: repeat(4, 1fr); }
.mv2-chip {
  padding: 10px 12px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s;
}
.mv2-chip.on {
  border-color: var(--p5-red);
  background: rgba(230, 57, 70, 0.08);
}
.mv2-chip-tg {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  color: var(--p5-red);
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}
.mv2-chip-ti {
  font-family: var(--font-display);
  font-weight: 500; font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--p5-text);
}
.mv2-chip p {
  font-size: 10.5px; color: var(--p5-muted);
  line-height: 1.4; margin: 0;
}

/* Character rows — grid: 140px | 1fr, red left accent */
.mv2-chars {
  display: flex; flex-direction: column; gap: 10px;
}
.mv2-char {
  padding: 12px 14px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  position: relative;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: flex-start;
}
.mv2-char::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--p5-red);
}
.mv2-char-nm h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600; font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--p5-text);
}
.mv2-char-role {
  display: inline-block; margin-top: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px; letter-spacing: 0.08em;
  color: var(--p5-red); text-transform: uppercase;
  padding: 2px 5px;
  border: 1px solid var(--p5-red);
}
.mv2-char-desc {
  font-size: 12.5px; line-height: 1.65;
  color: var(--p5-text-secondary);
}
.mv2-char-desc em {
  color: var(--p5-text); font-style: normal; font-weight: 600;
}

/* Beat rows — grid: 86px label | 1fr body | auto time */
.mv2-beats {
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
}
.mv2-beat {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--p5-border);
  align-items: flex-start;
}
.mv2-beat:last-child { border-bottom: none; }
.mv2-beat-t {
  font-family: var(--font-display);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--p5-red);
  text-transform: uppercase;
  padding-top: 1px;
}
.mv2-beat-body {
  font-size: 12px; line-height: 1.55;
  color: var(--p5-text-secondary);
}
.mv2-beat-body em {
  color: var(--p5-text); font-style: normal; font-weight: 600;
}
.mv2-beat-lyric {
  color: var(--p5-muted); font-style: italic;
  font-size: 11px; margin-top: 3px; line-height: 1.5;
}
.mv2-beat-time {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  letter-spacing: 0.04em;
  padding-top: 2px;
  white-space: nowrap;
}

/* MV button in track card — hover only, red outline */
.song-track-mv-btn {
  padding: 3px 8px; font-size: 10px; font-weight: 700;
  color: var(--p5-red); border: 1px solid var(--p5-red);
  background: transparent; cursor: pointer; border-radius: 0;
  transition: all 0.15s; letter-spacing: 0.5px; opacity: 0;
  font-family: inherit;
}
.song-track-card:hover .song-track-mv-btn,
.song-track-card.selected .song-track-mv-btn { opacity: 1; }
.song-track-mv-btn:hover { background: var(--p5-red); color: #fff; }

/* ═══════════════════════════════════════════════════════════════ */
/* MV Assets Workspace V3 (ref: manga-drama-v4 3-col + mv-creation V5 tabs) */
/* ═══════════════════════════════════════════════════════════════ */
#song-mv-assets { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#song-mv-assets.active { display: flex; }

.mva-body {
  flex: 1; overflow: hidden; min-height: 0; display: flex; flex-direction: column;
  position: relative;
}

/* ── Top bar: tabs (L) + style badge & regenerate (R) ─────────── */
.mva3-top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0; background: var(--p5-surface);
}
.mva3-tabs {
  display: flex; gap: 0;
  border: 1px solid var(--p5-border);
}
.mva3-tab {
  padding: 7px 18px;
  font-family: var(--font-display);
  font-weight: 500; font-size: 12px; letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--p5-muted);
  background: transparent; border: none;
  border-right: 1px solid var(--p5-border);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.15s, background 0.15s;
}
.mva3-tab:last-child { border-right: none; }
.mva3-tab:hover { color: var(--p5-text); }
.mva3-tab.on { background: var(--p5-red); color: #000; font-weight: 700; }
.mva3-tab-n {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px; padding: 1px 5px;
  background: var(--p5-border); color: var(--p5-muted);
  letter-spacing: 0.04em;
}
.mva3-tab.on .mva3-tab-n { background: #000; color: var(--p5-red); }
.mva3-top-r { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.mva3-top-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--p5-text-secondary);
  background: transparent; border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.mva3-top-btn:hover { color: var(--p5-red); border-color: var(--p5-red); }

/* ── Content wrapper (fills remaining mva-body height) ───────── */
.mva-content {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Main 3-col grid (compact rail + wide canvas + detail) ───── */
.mva3-pg {
  display: grid;
  grid-template-columns: 200px 1fr 270px;   /* rail +21% / detail -10% for map view */
  flex: 1; min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Left rail: cast-thumb list ──────────────────────────────── */
.mva3-rail {
  border-right: 1px solid var(--p5-border);
  background: var(--p5-dark);
  overflow-y: auto;
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.mva3-rail::-webkit-scrollbar { width: 4px; }
.mva3-rail::-webkit-scrollbar-thumb { background: var(--p5-border); }

.mva3-thumb {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 5px;                           /* uniform matte so red .on border has gap on all sides */
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  position: relative;
  /* Depth: drop shadow + subtle top-edge highlight */
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 4px 16px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.mva3-thumb:hover {
  border-color: rgba(230, 57, 70, 0.55);
  transform: translateY(-1px);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.55),
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.mva3-thumb.on {
  border-color: var(--p5-red);
  box-shadow:
    0 0 0 1px var(--p5-red) inset,
    0 3px 10px rgba(230, 57, 70, 0.2),
    0 6px 20px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(230, 57, 70, 0.15);
}

.mva3-thumb-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  background: var(--p5-input-bg);
  border-bottom: 1px solid var(--p5-border);
}
.mva3-thumb-nm {
  font-family: var(--font-display);
  font-weight: 600; font-size: 12px;
  color: var(--p5-text);
  letter-spacing: 0.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mva3-thumb-tag {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 8.5px; font-weight: 700;
  padding: 1px 5px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.mva3-thumb-tag.tag-lead { background: var(--p5-red); color: #000; }
.mva3-thumb-tag.tag-sup  { background: #f5ebcc; color: #000; }
.mva3-thumb-tag.tag-sym  { background: #f5b53d; color: #000; }
.mva3-thumb-tag.tag-scene { background: var(--p5-text-secondary); color: #000; }

.mva3-thumb-portrait {
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
.mva3-thumb-portrait.ratio-16-9 { aspect-ratio: 16 / 9; }
.mva3-thumb-portrait img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
}
.mva3-thumb-portrait::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.7));
  pointer-events: none;
}
.mva3-thumb-fig {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(255, 255, 255, 0.2);
  font-family: var(--font-display);
  font-size: 36px; font-weight: 700;
  letter-spacing: 0.08em;
}
.mva3-thumb-busy {
  position: absolute; top: 4px; right: 4px;
  z-index: 2;
  width: 18px; height: 18px;
  background: rgba(0, 0, 0, 0.7);
  display: grid; place-items: center;
  color: var(--p5-red);
}
.mva3-thumb-dot {
  position: absolute; top: 4px; right: 4px;
  z-index: 2;
  width: 8px; height: 8px;
  background: var(--p5-red);
  border-radius: 50%;
  animation: mva3-pulse 1.4s ease-in-out infinite;
}
@keyframes mva3-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.mva3-rail-empty {
  font-size: 11px; color: var(--p5-muted);
  text-align: center; padding: 24px 12px;
  font-style: italic;
}

/* ── Rail section group (scenes tab) ─────────────────────────── */
.mva3-rail-sec { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.mva3-rail-sec-hd {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--p5-red);
  text-transform: uppercase;
  font-weight: 700;
  padding: 6px 4px 4px;
  border-bottom: 1px solid var(--p5-border);
  margin: 4px 0 2px;
  display: flex; align-items: center; gap: 6px;
}
.mva3-rail-sec-hd .sec-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; font-size: 10px; font-weight: 700;
  background: var(--p5-red); color: #000;
}
.mva3-rail-sec-hd .sec-label {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mva3-rail-sec-hd .sec-cnt {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  font-weight: 600;
}
.mva3-thumb-alsoin {
  padding: 4px 8px 6px;
  background: var(--p5-input-bg);
  border-top: 1px solid var(--p5-border);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  color: var(--p5-muted);
  letter-spacing: 0.06em;
  display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
}
.mva3-thumb-alsoin-lbl { color: var(--p5-red); font-weight: 700; }
.mva3-thumb-alsoin-tag {
  padding: 1px 5px;
  background: rgba(230, 57, 70, 0.08);
  color: var(--p5-text-secondary);
  border: 1px solid rgba(230, 57, 70, 0.2);
}

/* ══════════════════════════════════════════════════════════════
   Scene Board Map (scenes tab only, inside .mva3-canvas)
   Ported from manga-drama md-board* with mva3- prefix.
   ══════════════════════════════════════════════════════════════ */
.mva3-map {
  position: relative;
  min-height: 480px;
  overflow: visible;    /* allow tooltip to escape map box; canvas handles outer scroll */
  background-color: #0e1014;
  background-image: radial-gradient(circle, rgba(230, 57, 70, 0.025) 1px, transparent 1px);
  background-size: 20px 20px;
  margin-top: 8px;
  border: 1px solid var(--p5-border);
}
.mva3-map-particle {
  position: absolute; width: 2px; height: 2px;
  background: rgba(230, 57, 70, 0.2);
  pointer-events: none; z-index: 0;
  animation: mva3-map-float linear infinite;
}
@keyframes mva3-map-float {
  0%   { transform: translate(0, 0); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(20px, -40px); opacity: 0; }
}
.mva3-map-paths {
  position: absolute; top: 0; left: 0;
  pointer-events: none; z-index: 0;
}
.mva3-map-paths path.walked {
  animation: mva3-path-march 0.8s linear infinite;
  filter: drop-shadow(0 0 3px rgba(230, 57, 70, 0.4));
}
.mva3-map-paths path.frontier {
  animation: mva3-path-march 1.2s linear infinite;
  filter: drop-shadow(0 0 3px rgba(230, 162, 60, 0.3));
}
.mva3-map-paths path.unwalked { animation: mva3-path-flow 2s linear infinite; }
@keyframes mva3-path-march { to { stroke-dashoffset: -13; } }
@keyframes mva3-path-flow  { to { stroke-dashoffset: -13; } }

.mva3-map-nodes { position: absolute; top: 0; left: 0; z-index: 1; }

/* Act region box (section group) */
.mva3-mact {
  position: absolute;
  border: 1px solid rgba(230, 57, 70, 0.12);
  background: rgba(230, 57, 70, 0.02);
  pointer-events: none;
  z-index: 0;
}
.mva3-mact-hd {
  position: absolute; top: -1px; left: -1px;
  display: flex; align-items: center; gap: 0;
}
.mva3-mact-num {
  width: 26px; height: 26px;
  background: var(--p5-red);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.mva3-mact-title {
  font-family: var(--font-display);
  font-size: 12px; color: var(--p5-text-secondary);
  font-weight: 700; letter-spacing: 0.08em;
  white-space: nowrap;
  padding: 0 10px; height: 26px; line-height: 26px;
  background: rgba(230, 57, 70, 0.08);
  border-bottom: 1px solid rgba(230, 57, 70, 0.12);
  text-transform: uppercase;
}

/* Scene node */
.mva3-mnode {
  position: absolute;
  width: 156px;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 2;
}
.mva3-mnode:hover { transform: scale(1.08); z-index: 25; }
.mva3-mnode-ring {
  width: 114px; height: 114px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #2a2d37;
  background: rgba(20, 20, 24, 0.85);
  transition: all 0.3s;
  margin: 0 auto;
}
.mva3-mnode:hover .mva3-mnode-ring { border-color: rgba(230, 57, 70, 0.5); }
.mva3-mnode.has-images .mva3-mnode-ring {
  border-color: #e6a23c;
  background: rgba(20, 20, 24, 0.92);
  box-shadow: 0 0 12px rgba(230, 162, 60, 0.15);
}
.mva3-mnode.has-images .mva3-mnode-icon  { color: #e6a23c; }
.mva3-mnode.has-images .mva3-mnode-label { color: #e6a23c; }
.mva3-mnode.done .mva3-mnode-ring {
  border-color: var(--p5-red);
  background: rgba(20, 20, 24, 0.92);
  box-shadow: 0 0 16px rgba(230, 57, 70, 0.15);
}
.mva3-mnode.polling .mva3-mnode-ring {
  border-color: rgba(230, 57, 70, 0.5);
  animation: mva3-mnode-glow 1.5s ease-in-out infinite;
}
@keyframes mva3-mnode-glow {
  0%, 100% { border-color: rgba(230, 57, 70, 0.5); box-shadow: 0 0 8px rgba(230, 57, 70, 0.2); }
  50%      { border-color: var(--p5-red);         box-shadow: 0 0 16px rgba(230, 57, 70, 0.4); }
}
.mva3-mnode.selected .mva3-mnode-ring {
  border-color: var(--p5-red);
  border-width: 3px;
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.4), inset 0 0 12px rgba(230, 57, 70, 0.1);
}

.mva3-mnode-icon {
  width: 52px; height: 52px;
  color: #555;
  transition: color 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.mva3-mnode.done .mva3-mnode-icon { color: var(--p5-red); }
.mva3-mnode:hover .mva3-mnode-icon { color: #888; }
.mva3-mnode.selected .mva3-mnode-icon { color: var(--p5-red); }
.mva3-mnode-icon svg { width: 100%; height: 100%; }

.mva3-mnode-pulse {
  position: absolute; inset: -4px;
  border: 2px solid var(--p5-red);
  opacity: 0;
  animation: mva3-mnode-pulse 2s ease-out infinite;
}
@keyframes mva3-mnode-pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.3); }
}

.mva3-mnode-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--p5-text-secondary);
  text-align: center;
  max-width: 156px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mva3-mnode.done .mva3-mnode-label     { color: var(--p5-text); }
.mva3-mnode.selected .mva3-mnode-label { color: var(--p5-red); font-weight: 700; }

/* Hover tooltip */
.mva3-map-nodes::before {
  content: ''; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  z-index: 19;
}
.mva3-map-nodes:has(.mva3-mnode:hover)::before { opacity: 1; }

.mva3-mnode-tip {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 286px;
  background: rgba(14, 16, 20, 0.96);
  border: 1px solid rgba(230, 57, 70, 0.2);
  padding: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}
.mva3-mnode-tip::before {
  content: ''; position: absolute;
  bottom: 100%; left: 0; right: 0; height: 12px;
}
.mva3-mnode-tip::after {
  content: ''; position: absolute;
  bottom: calc(100% - 1px); left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: rgba(230, 57, 70, 0.2);
}
.mva3-mnode:hover .mva3-mnode-tip {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.mva3-mnode.polling { cursor: not-allowed; }
.mva3-mnode-tip-name {
  font-size: 14px; font-weight: 600;
  color: var(--p5-text);
  margin-bottom: 6px;
}
.mva3-mnode-tip-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(230, 57, 70, 0.1);
  color: var(--p5-red);
  margin-bottom: 8px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}
.mva3-mnode-tip-desc {
  font-size: 12px; color: var(--p5-muted);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.mva3-mnode-tip-thumb {
  width: 100%; aspect-ratio: 16/9;
  overflow: hidden;
  border: 1px solid rgba(230, 57, 70, 0.2);
  margin-bottom: 8px;
}
.mva3-mnode-tip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mva3-mnode-tip-btn {
  display: block; width: 100%;
  padding: 6px;
  background: rgba(230, 57, 70, 0.15);
  border: 1px solid rgba(230, 57, 70, 0.3);
  color: var(--p5-red);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}
.mva3-mnode-tip-btn:hover { background: rgba(230, 57, 70, 0.25); }
.mva3-mnode-tip-alsoin {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--p5-muted);
  padding-top: 8px;
  border-top: 1px dashed rgba(230, 57, 70, 0.15);
  margin-top: 8px;
}
.mva3-mnode-tip-alsoin strong { color: var(--p5-red); font-weight: 700; }

/* Complete burst effect */
.mva3-mnode.complete-burst .mva3-mnode-ring {
  animation: mva3-ring-complete 1.2s ease;
}
@keyframes mva3-ring-complete {
  0%   { transform: scale(1);    box-shadow: 0 0 0    rgba(230, 57, 70, 0); }
  30%  { transform: scale(1.15); box-shadow: 0 0 40px rgba(230, 57, 70, 0.8); }
  100% { transform: scale(1);    box-shadow: 0 0 16px rgba(230, 57, 70, 0.15); }
}
.mva3-map-burst-particle {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--p5-red);
  top: 50%; left: 50%;
  pointer-events: none;
  animation: mva3-burst 0.8s ease-out;
  --angle: 0deg;
}
@keyframes mva3-burst {
  0%   { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0)     scale(1);   opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-60px) scale(0.3); opacity: 0; }
}

/* Pixel pet */
.mva3-map-pet {
  position: absolute; width: 36px; height: 36px;
  pointer-events: none; z-index: 4;
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1), top 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  animation: mva3-pet-bob 1.2s ease-in-out infinite;
}
@keyframes mva3-pet-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.mva3-map-pet-body {
  width: 36px; height: 36px;
  background: linear-gradient(180deg, #ff6b6b, var(--p5-red));
  position: relative;
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
  border-radius: 6px 6px 4px 4px;
}
.mva3-map-pet-eyes {
  position: absolute; top: 12px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}
.mva3-map-pet-eye { width: 5px; height: 7px; background: #fff; }
.mva3-map-pet-shadow {
  position: absolute; bottom: -4px; left: 8px; right: 8px;
  height: 4px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.5), transparent 70%);
}
.mva3-map-pet.celebrate { animation: mva3-pet-celebrate 0.6s ease; }
@keyframes mva3-pet-celebrate {
  0%   { transform: translateY(0)     scale(1); }
  30%  { transform: translateY(-10px) scale(1.15); }
  60%  { transform: translateY(-4px)  scale(1.05); }
  100% { transform: translateY(0)     scale(1); }
}

/* Empty state for map */
.mva3-map-empty {
  display: flex; align-items: center; justify-content: center;
  padding: 80px 20px;
  color: var(--p5-muted);
  font-size: 13px;
  font-style: italic;
}

/* ── Center canvas: topology tree ────────────────────────────── */
.mva3-canvas {
  background: var(--p5-surface);
  overflow-y: auto;
  overflow-x: auto;             /* fallback scroll if decompose/variants sheet exceeds width */
  padding: 20px 24px 40px;
  position: relative;
}
.mva3-canvas::-webkit-scrollbar { width: 6px; }
.mva3-canvas::-webkit-scrollbar-thumb { background: var(--p5-border); }

.mva3-canvas-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  font-size: 12px; color: var(--p5-muted);
  font-style: italic;
}

/* Canvas head: character/scene name + role + basic descriptor (ref: mv-creation detail-head) */
.mva3-canvas-head {
  margin: 0 auto 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--p5-border);
  position: relative;
  max-width: 760px;
}
.mva3-canvas-head::after {
  content: '';
  position: absolute;
  left: 0; bottom: -1px;
  width: 120px; height: 2px;
  background: var(--p5-red);
}
.mva3-canvas-name {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-weight: 700; font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--p5-text);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.mva3-canvas-nm-sub {
  font-family: Georgia, 'Zen Kaku Gothic New', serif;
  font-size: 13px;
  color: var(--p5-red);
  font-weight: 600;
  font-style: italic;
}
.mva3-canvas-role-badge {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  padding: 3px 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.mva3-canvas-role-badge.tag-lead  { background: var(--p5-red); color: #000; }
.mva3-canvas-role-badge.tag-sup   { background: #f5ebcc; color: #000; }
.mva3-canvas-role-badge.tag-sym   { background: #f5b53d; color: #000; }
.mva3-canvas-role-badge.tag-scene { background: var(--p5-text-secondary); color: #000; }
.mva3-canvas-desc {
  font-size: 12.5px;
  color: var(--p5-text-secondary);
  line-height: 1.6;
}
.mva3-canvas-active-sep { height: 1px; background: var(--p5-border); margin: 14px 0 12px; opacity: 0.5; }
.mva3-canvas-active-title { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.mva3-canvas-active-name {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  color: var(--p5-text); letter-spacing: 0.01em;
}
.mva3-canvas-active-type {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px;
  letter-spacing: 0.1em;
  background: var(--p5-input-bg);
  color: var(--p5-red);
  border: 1px solid var(--p5-red);
}
.mva3-canvas-active-desc {
  font-size: 12px;
  color: var(--p5-muted);
  line-height: 1.6;
  white-space: pre-wrap;
}
/* Scenes tab: head spans full canvas width to align with board (no 760px reading column) */
.mva3-pg-scenes .mva3-canvas-head { max-width: none; }
/* Red underline follows padding-left (set via --head-underline-left in JS) to align with 片场地图 title */
.mva3-pg-scenes .mva3-canvas-head::after { left: var(--head-underline-left, 0); }

.mva3-tree {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-top: 16px;
}
.mva3-tree-row {
  display: grid;
  justify-items: center;
  position: relative;
  gap: 20px;
}
.mva3-tree-row.r1 { grid-template-columns: 180px; }          /* ~25% smaller portrait */
.mva3-tree-row.r2 { grid-template-columns: 560px; }           /* ~3× portrait — matches blue-box target */
.mva3-tree-row.r3 {
  grid-template-columns: repeat(var(--r3-cols, 3), 180px);
  position: relative;
}
/* Connectors: vertical line below r1 + r2 */
.mva3-tree-row.r1::after,
.mva3-tree-row.r2::after {
  content: '';
  position: absolute;
  bottom: -24px; left: 50%;
  width: 1px; height: 24px;
  background: var(--p5-red);
  transform: translateX(-0.5px);
}
/* Horizontal bar above r3 + short vertical stubs on each child */
.mva3-tree-row.r3::before {
  content: '';
  position: absolute;
  top: -24px; left: 15%; right: 15%;
  height: 1px;
  background: var(--p5-red);
}
.mva3-tree-row.r3 > .mva3-tree-node::before {
  content: '';
  position: absolute;
  top: -24px; left: 50%;
  width: 1px; height: 24px;
  background: var(--p5-red);
  transform: translateX(-0.5px);
}

.mva3-tree-node {
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  padding: 6px;                           /* uniform matte so all children sit away from border */
  width: 100%;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
  /* Depth: stronger than rail thumbs since nodes are the main content */
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.mva3-tree-node:hover {
  border-color: rgba(230, 57, 70, 0.55);
  transform: translateY(-2px);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.6),
    0 12px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.mva3-tree-node.on {
  border-color: var(--p5-red);
  box-shadow:
    0 4px 14px rgba(230, 57, 70, 0.22),
    0 10px 28px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(230, 57, 70, 0.18);
}
.mva3-tree-node.on::before,
.mva3-tree-node.on::after {
  z-index: 2;
}
.mva3-tree-node.on::before {
  top: 0; left: 0;
  width: 0; height: 0;
  border-left: 16px solid var(--p5-red);
  border-bottom: 16px solid transparent;
}
.mva3-tree-node.on::after {
  content: '✓';
  position: absolute;
  top: 1px; left: 2px;
  color: #000; font-size: 10px; font-weight: 800;
  z-index: 3;
}

.mva3-node-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--p5-input-bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

/* Version carousel pill — sits top-right of image/canvas-head, shown when >1 version exists */
.mva3-ver-pill {
  position: absolute;
  top: 6px; right: 6px;
  display: inline-flex; align-items: center;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(230, 57, 70, 0.4);
  padding: 2px;
  gap: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.mva3-canvas-head .mva3-ver-pill { position: static; margin-left: auto; }
.mva3-canvas-head .mva3-canvas-name { display: flex; align-items: center; gap: 8px; }

.mva3-ver-btn {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0;
  color: var(--p5-text-secondary);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  transition: color 0.12s, background 0.12s;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.mva3-ver-btn:hover { color: var(--p5-red); background: rgba(230, 57, 70, 0.15); }
.mva3-ver-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.mva3-ver-lbl {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700;
  color: var(--p5-text);
  padding: 0 6px;
  letter-spacing: 0.05em;
}
.mva3-node-img.ratio-21-9 { aspect-ratio: 21 / 9; }
.mva3-node-img.ratio-16-9 { aspect-ratio: 16 / 9; }
.mva3-node-img img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
}
/* Decompose / variant sheets often exceed 21:9 (4 views + wardrobe row) — use contain so full image visible */
.mva3-node-img.ratio-21-9 img { object-fit: contain; background: var(--p5-input-bg); }
.mva3-node-img .mva3-node-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--p5-muted);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 8px; text-align: center; line-height: 1.4;
}
.mva3-node-img.loading::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg,
    rgba(230,57,70,0.06) 0 8px, rgba(230,57,70,0.12) 8px 16px);
  animation: mva3-shimmer 1.8s linear infinite;
}
@keyframes mva3-shimmer {
  0% { background-position: 0 0; }
  100% { background-position: 32px 32px; }
}

.mva3-node-label {
  padding: 7px 10px;
  font-family: var(--font-display);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--p5-text);
  text-transform: uppercase;
  border-top: 1px solid var(--p5-border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px;
}
.mva3-node-label .mva3-node-sub {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 8.5px;
  color: var(--p5-red);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.mva3-node-actions {
  display: flex; gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
}
.mva3-node-btn {
  flex: 1;
  padding: 4px 8px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
  background: transparent;
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.mva3-node-btn:hover:not(:disabled) { color: var(--p5-red); border-color: var(--p5-red); }
.mva3-node-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mva3-node-btn.primary { color: var(--p5-red); border-color: var(--p5-red); }
.mva3-node-btn.primary:hover:not(:disabled) { background: var(--p5-red); color: #000; }

/* Decompose 4x2 wardrobe grid inside tree-node */
.mva3-wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1px;
  background: var(--p5-border);
  aspect-ratio: 2 / 1;
  overflow: hidden;
}
.mva3-wardrobe-cell {
  background: var(--p5-input-bg);
  position: relative;
  overflow: hidden;
}
.mva3-wardrobe-cell.on { background: var(--p5-red); }
.mva3-wardrobe-cell img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Variant ADD node (+ button) */
.mva3-tree-node.add-node {
  border-style: dashed;
  align-items: center; justify-content: center;
  min-height: 160px;
  padding: 20px 12px;
  color: var(--p5-muted);
}
.mva3-tree-node.add-node:hover { color: var(--p5-red); border-color: var(--p5-red); }
.mva3-tree-node.add-node .mva3-add-icon {
  font-size: 24px; font-weight: 300; margin-bottom: 6px;
}
.mva3-tree-node.add-node .mva3-add-label {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

/* ── Right detail: .mva3-sec blocks with kv ─────────────────── */
.mva3-detail {
  border-left: 1px solid var(--p5-border);
  background: var(--p5-dark);
  overflow-y: scroll;              /* always show track for visual rail, content scrolls when exceeds */
  padding: 18px 18px 40px;
}
.mva3-detail::-webkit-scrollbar { width: 6px; }
.mva3-detail::-webkit-scrollbar-track { background: var(--p5-input-bg); }
.mva3-detail::-webkit-scrollbar-thumb {
  background: var(--p5-border);
  border: 1px solid var(--p5-surface);
}
.mva3-detail::-webkit-scrollbar-thumb:hover { background: var(--p5-red); }

.mva3-detail-empty {
  font-size: 11px; color: var(--p5-muted);
  text-align: center; padding: 40px 12px;
  font-style: italic;
}

.mva3-sec {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--p5-border);
}
.mva3-sec:last-child { border-bottom: none; }
.mva3-sec h4 {
  margin: 0 0 10px 0;
  font-family: var(--font-display);
  font-weight: 600; font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--p5-red);
  text-transform: uppercase;
  position: relative;
  padding-left: 10px;
}
.mva3-sec h4::before {
  content: '';
  position: absolute;
  left: 0; top: 2px;
  width: 3px; height: 12px;
  background: var(--p5-red);
}

.mva3-kv {
  margin: 0;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 6px 10px;
  font-size: 11.5px;
  line-height: 1.55;
}
.mva3-kv dt {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  color: var(--p5-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 2px;
}
.mva3-kv dd {
  margin: 0;
  color: var(--p5-text-secondary);
}
.mva3-kv dd em {
  color: var(--p5-red); font-style: normal; font-weight: 600;
}

.mva3-sec p {
  margin: 0;
  font-size: 11.5px;
  color: var(--p5-text-secondary);
  line-height: 1.55;
}
.mva3-sec .mva3-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 2px;
}
.mva3-chip {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  padding: 2px 6px;
  background: transparent;
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  letter-spacing: 0.04em;
}

.mva3-style-sel {
  display: flex; gap: 10px; align-items: center;
}
.mva3-style-sel-sw {
  width: 44px; height: 60px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.mva3-style-sel-sw img { width: 100%; height: 100%; object-fit: cover; }
.mva3-style-sel-bd {
  font-size: 11.5px; color: var(--p5-text);
  flex: 1; min-width: 0;
}
.mva3-style-sel-bd .mva3-style-sel-nm { font-weight: 600; margin-bottom: 4px; }
.mva3-style-sel-bd .mva3-style-sel-st {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  color: var(--ok, #4ade80);
  letter-spacing: 0.08em;
}

/* ── Tone strip for scenes (color_tone gradient) ──────────── */
.mva3-tone-strip {
  width: 100%; height: 18px;
  border: 1px solid var(--p5-border);
  margin-top: 4px;
}

/* ── 12 portrait gradient presets ─────────────────────────── */
.pg-01 { background: linear-gradient(135deg, #2a1520 0%, #5b2838 50%, #1a0810 100%); }
.pg-02 { background: linear-gradient(135deg, #1a2838 0%, #3b5378 50%, #0a1220 100%); }
.pg-03 { background: linear-gradient(135deg, #2a2015 0%, #5b4828 50%, #1a1008 100%); }
.pg-04 { background: linear-gradient(135deg, #152028 0%, #284858 50%, #081018 100%); }
.pg-05 { background: linear-gradient(135deg, #2a1a10 0%, #5b3828 50%, #1a0a05 100%); }
.pg-06 { background: linear-gradient(135deg, #151a2a 0%, #28385b 50%, #080a1a 100%); }
.pg-07 { background: linear-gradient(135deg, #2a152a 0%, #5b285b 50%, #1a081a 100%); }
.pg-08 { background: linear-gradient(135deg, #1a2a15 0%, #385b28 50%, #081a08 100%); }
.pg-09 { background: linear-gradient(135deg, #2a1515 0%, #5b2828 50%, #1a0808 100%); }
.pg-10 { background: linear-gradient(135deg, #15252a 0%, #28485b 50%, #08141a 100%); }
.pg-11 { background: linear-gradient(135deg, #2a2a15 0%, #5b5b28 50%, #1a1a08 100%); }
.pg-12 { background: linear-gradient(135deg, #252515 0%, #48482a 50%, #14140a 100%); }

/* Style badge (header, matches .mva3-top-btn REGENERATE look) */
.mva-style-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px; border-radius: 0;
  background: transparent; border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary); font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
  font-family: inherit; max-width: 200px;
}
.mva-style-badge:hover,
.mva-style-badge.mva-style-badge-active:hover { border-color: var(--p5-red); color: var(--p5-red); }
/* Active state stays gray — indistinguishable from default, matches REGENERATE look */
.mva-style-badge.mva-style-badge-active { border-color: var(--p5-border); color: var(--p5-text-secondary); }
.mva-style-badge-swatch {
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--p5-card); font-size: 12px; flex-shrink: 0;
}
.mva-style-badge-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Loading overlay */
.mva-loading {
  position: absolute; inset: 0; z-index: 5; background: var(--p5-bg);
  display: flex; flex-direction: column; gap: 12px;
  padding: 40px 32px; max-width: 640px; margin: 40px auto;
  height: fit-content;
}

/* Empty state */
.mva-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 14px; text-align: center;
}
.mva-empty-ctas { display: flex; gap: 12px; margin-top: 8px; }

/* Scene 4-pick overlay modal (reuses .mva-select-overlay/modal shell) */
.mva-select-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,0.75);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.mva-select-overlay.active { display: flex; }
.mva-select-modal {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  max-width: 1100px; width: 100%; max-height: 90vh;
  display: flex; flex-direction: column;
}
.mva-select-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0;
}
.mva-select-header h3 { margin: 0; font-size: var(--text-md); color: var(--p5-text); }
.mva-select-grid {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px; align-content: start;
}
.mva-scene-select-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.mva-char-select-grid  { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mva-char-select-grid .mva-select-item { aspect-ratio: 3/4; }
.mva-select-item {
  position: relative; aspect-ratio: 16/9;
  border: 2px solid var(--p5-border); cursor: pointer; overflow: hidden;
  transition: border-color 0.15s;
}
.mva-select-item:hover { border-color: var(--p5-red); }
.mva-select-item.selected { border-color: var(--p5-red); box-shadow: inset 0 0 0 2px var(--p5-red); }
.mva-select-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mva-select-check {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: var(--p5-red); color: #fff; font-weight: 700; font-size: 14px;
}
.mva-select-zoom {
  position: absolute; bottom: 6px; right: 6px;
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); color: #fff;
  border: none; cursor: pointer; opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.mva-select-item:hover .mva-select-zoom { opacity: 1; }
.mva-select-zoom:hover { background: var(--p5-red); }
.mva-scene-empty { color: var(--p5-muted); }
.mva-scene-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.mva-scene-name { font-size: var(--text-sm); font-weight: 600; color: var(--p5-text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mva-scene-type-chip {
  padding: 1px 6px; font-size: 10px; font-weight: 600;
  background: var(--p5-red); color: #fff; flex-shrink: 0;
}
.mva-scene-desc { font-size: 11px; color: var(--p5-text-secondary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mva-scene-tone {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--p5-muted);
}
.mva-tone-strip {
  display: inline-block; width: 28px; height: 8px;
  border: 1px solid var(--p5-border); flex-shrink: 0;
}
.mva-scene-motifs, .mva-scene-sections {
  display: flex; flex-wrap: wrap; gap: 3px;
}
.mva-chip {
  display: inline-block; padding: 1px 6px; font-size: 10px;
  background: var(--p5-input-bg); border: 1px solid var(--p5-border); color: var(--p5-text-secondary);
}
.mva-scene-actions { display: flex; margin-top: auto; }
.mva-scene-actions .dt-btn { flex: 1; justify-content: center; }

/* ===================== Content Safety Modal ===================== */
/* Theme-aware: overrides the hardcoded dark colors in .dt-fixed-modal so the safety
   modal follows the app's light/dark theme consistently. */
.dt-safety-box {
  background: var(--p5-card) !important;
  border-color: var(--p5-border) !important;
  color: var(--p5-text);
}
.dt-safety-box .dt-fixed-modal-header { background: var(--p5-card); }
.dt-safety-box .dt-fixed-modal-header h2 { color: var(--p5-text); }
.dt-safety-box .dt-fixed-modal-close { color: var(--p5-muted); }
.dt-safety-box .dt-fixed-modal-close:hover { color: var(--p5-text); }
.dt-safety-footer { border-top: 1px solid var(--p5-border); }

.dt-safety-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.dt-safety-tag {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(230, 57, 70, 0.15);
  border: 1px solid rgba(230, 57, 70, 0.4);
  color: #e63946;
  font-size: 12px;
  font-weight: 600;
  border-radius: 0;
  line-height: 1;
}
.dt-safety-block { margin: 10px 0; font-size: 13px; color: var(--p5-text-secondary); }
.dt-safety-block b { display: block; font-size: 12px; color: var(--p5-muted); margin-bottom: 4px; font-weight: 500; }
.dt-safety-part {
  padding: 6px 10px;
  margin: 4px 0;
  background: var(--p5-input-bg);
  border-left: 3px solid #e63946;
  color: var(--p5-text);
  font-size: 13px;
  font-style: italic;
  word-break: break-word;
}
.dt-safety-explanation {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  font-size: 13px;
  line-height: 1.6;
  border-radius: 0;
}
.dt-safety-sugg {
  padding: 8px 10px;
  background: rgba(230, 57, 70, 0.06);
  border: 1px dashed rgba(230, 57, 70, 0.35);
  color: #e63946;
  font-size: 13px;
  line-height: 1.5;
}
=======
/* ── Comic Preview Share Button + Dialog ────────────────────────────── */
.comic-pv-share-btn {
  background: none;
  border: none;
  color: #888;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.comic-pv-share-btn:hover { color: var(--p5-red); }

.comic-share-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.comic-share-dialog {
  background: #111;
  border: 1px solid #2a2a2a;
  width: 90%;
  max-width: 480px;
  color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.comic-share-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.comic-share-dialog-close {
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.comic-share-dialog-close:hover { color: #fff; }
.comic-share-dialog-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.comic-share-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.comic-share-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--p5-red);
  cursor: pointer;
}
.comic-share-toggle-label {
  font-size: 14px;
  color: #ddd;
}
.comic-share-toggle.comic-share-toggle-sub {
  margin-left: 24px;
  margin-top: -4px;
}
.comic-share-toggle.comic-share-toggle-sub .comic-share-toggle-label {
  font-size: 13px;
  color: var(--p5-muted);
}
.comic-share-toggle.comic-share-toggle-sub.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.comic-share-toggle.comic-share-toggle-sub.is-disabled input[type="checkbox"] {
  cursor: not-allowed;
}
.comic-share-url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.comic-share-url-row input {
  flex: 1;
  min-width: 0;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #ccc;
  padding: 8px 10px;
  font-size: 12px;
  font-family: monospace;
  user-select: all;
}
.comic-share-url-row input:focus {
  outline: none;
  border-color: var(--p5-red);
}
.comic-share-copy-btn {
  background: var(--p5-red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.comic-share-copy-btn:hover { background: #ff6b6b; }
.comic-share-socials {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.comic-share-socials-label {
  color: var(--p5-text-secondary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.comic-share-socials-btns {
  display: inline-flex;
  gap: 8px;
}
.comic-share-social-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--p5-text-secondary);
  border: 1px solid var(--p5-border);
  border-radius: 0;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  padding: 0;
}
.comic-share-social-btn:hover { color: var(--p5-red); border-color: var(--p5-red); }
.comic-share-hint {
  color: #888;
  font-size: 12px;
  line-height: 1.5;
}

/* ── Storyboard Generate Confirm Modal ─────────────────────────────── */
.comic-gen-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.comic-gen-confirm-dialog {
  background: #111;
  border: 1px solid #2a2a2a;
  width: 90%;
  max-width: 460px;
  color: #e0e0e0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.comic-gen-confirm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.comic-gen-confirm-close {
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.comic-gen-confirm-close:hover { color: #fff; }
.comic-gen-confirm-body {
  padding: 20px;
}
.comic-gen-confirm-intro {
  color: #ccc;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}
.comic-gen-confirm-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  border: 1px solid rgba(230, 57, 70, 0.3);
  background: rgba(230, 57, 70, 0.06);
}
.comic-gen-confirm-list li {
  padding: 10px 14px;
  font-size: 13px;
  color: #eee;
  border-bottom: 1px solid rgba(230, 57, 70, 0.15);
}
.comic-gen-confirm-list li:last-child { border-bottom: 0; }
.comic-gen-confirm-list li::before {
  content: '\26A0';
  color: var(--p5-red);
  margin-right: 8px;
}
.comic-gen-confirm-hint {
  color: #888;
  font-size: 12px;
  line-height: 1.5;
}
.comic-gen-confirm-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #222;
  justify-content: flex-end;
}
.comic-gen-confirm-btn-secondary,
.comic-gen-confirm-btn-primary {
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.comic-gen-confirm-btn-secondary {
  background: #1a1a1a;
  color: #ccc;
  border: 1px solid #333;
}
.comic-gen-confirm-btn-secondary:hover {
  background: #222;
  color: #fff;
  border-color: var(--p5-red);
}
.comic-gen-confirm-btn-primary {
  background: var(--p5-red);
  color: #fff;
}
.comic-gen-confirm-btn-primary:hover { background: #ff6b6b; }

/* ============================================================
 * MV Storyboard Workspace (mvsb-*)  — per-region planning + 2×2 grid nano
 * Layout: readiness banner + 3-column (regions 22% / shots 30% / detail 48%)
 * Align with .md-sb-* for visual parity with manga-drama storyboard.
 * ============================================================ */

#song-mv-storyboard.active { flex-direction: column; height: 100%; overflow: hidden; }
.mvsb-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; }

/* Readiness banner (shown when assets not ready). Red thin strip. */
.mvsb-readiness-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--p5-border);
  background: rgba(230, 57, 70, 0.08); color: var(--p5-text);
  font-size: 12px;
}
.mvsb-readiness-banner .mvsb-banner-label {
  color: var(--p5-red); font-weight: 600;
}
.mvsb-readiness-banner .mvsb-banner-detail {
  flex: 1; color: var(--p5-text-secondary);
}

/* 3-col grid */
.mvsb-content {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 22% 30% 48%;
  overflow: hidden;
}
.mvsb-col { min-height: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--p5-border); }
.mvsb-col:last-child { border-right: none; }

.mvsb-col-head {
  padding: 10px 14px; border-bottom: 1px solid var(--p5-border);
  display: flex; flex-direction: column; gap: 2px; flex-shrink: 0;
}
.mvsb-col-title { font-size: 13px; font-weight: 600; color: var(--p5-text); }
.mvsb-col-sub { font-size: 11px; color: var(--p5-text-secondary); }
.mvsb-col-hint {
  padding: 24px 16px; color: var(--p5-text-secondary);
  font-size: 12px; text-align: center; line-height: 1.6;
}

/* Left column: regions list */
.mvsb-col-regions { overflow-y: auto; padding: 8px; gap: 6px; }
.mvsb-region {
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--p5-border); background: var(--p5-surface);
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 6px;
}
.mvsb-region:hover { border-color: var(--p5-red); }
.mvsb-region-sel { border-color: var(--p5-red); background: rgba(230,57,70,0.05); }
.mvsb-region-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.mvsb-region-role {
  font-size: 12px; font-weight: 600; color: var(--p5-text);
  text-transform: capitalize;
}
.mvsb-region-state {
  font-size: 10px; padding: 2px 6px; border: 1px solid;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.mvsb-region-mid { font-size: 11px; color: var(--p5-text-secondary); }
.mvsb-region-bot { display: flex; justify-content: flex-end; }
.mvsb-region-bot .dt-btn {
  padding: 4px 10px; font-size: 11px;
}

/* State chips — shared across region + shot */
.mvsb-state-pending     { color: var(--p5-text-secondary); border-color: var(--p5-border); }
.mvsb-state-planned     { color: #eab308; border-color: rgba(234,179,8,0.4); background: rgba(234,179,8,0.08); }
.mvsb-state-partial     { color: #f97316; border-color: rgba(249,115,22,0.4); background: rgba(249,115,22,0.08); }
.mvsb-state-image_ready { color: #22c55e; border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.mvsb-state-absorbed    { color: var(--p5-text-secondary); border-color: var(--p5-border); opacity: 0.6; }
.mvsb-state-generating  { color: var(--p5-red); border-color: var(--p5-red); background: rgba(230,57,70,0.08); }
.mvsb-state-failed      { color: #ef4444; border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }

/* Storyboard header progress badge: "图 X/Y · 视频 A/B" + 全部完成 ✓ */
.mvsb-progress-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; margin-left: 8px;
  font-size: var(--text-xs); color: var(--p5-text-secondary);
  background: var(--p5-card); border: 1px solid var(--p5-border);
  line-height: 1;
}
.mvsb-progress-badge:empty { display: none; }
.mvsb-progress-badge .mvsb-pb-chunk    { display: inline-flex; align-items: center; gap: 4px; }
.mvsb-progress-badge .mvsb-pb-chunk b  { color: var(--p5-text); font-weight: 600; }
.mvsb-progress-badge .mvsb-pb-chunk.mvsb-pb-ok   { color: #22c55e; }
.mvsb-progress-badge .mvsb-pb-chunk.mvsb-pb-ok b { color: inherit; }
.mvsb-progress-badge .mvsb-pb-sep      { color: var(--p5-border); }
.mvsb-progress-badge .mvsb-pb-check {
  display: inline-flex; align-items: center; gap: 4px;
  color: #22c55e; font-weight: 600;
}
.mvsb-progress-badge.mvsb-pb-complete {
  border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08);
}

/* Failed placeholder in shot thumb + detail hero */
.mvsb-shot-thumb-failed { color: #ef4444; }
.mvsb-detail-hero.mvsb-hero-failed {
  border: 2px dashed rgba(239,68,68,0.5); color: #ef4444;
  flex-direction: column; gap: 10px;
  background: rgba(239,68,68,0.04);
}
.mvsb-detail-hero.mvsb-hero-failed .mvsb-hero-fail-title { font-weight: 600; font-size: var(--text-sm); }
.mvsb-detail-hero.mvsb-hero-failed .mvsb-hero-fail-hint  { font-size: var(--text-xs); color: var(--p5-text-secondary); }

/* Middle column: shot list */
.mvsb-shots-list { flex: 1; overflow-y: auto; padding: 8px; }
.mvsb-shot-card {
  display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 8px;
  margin-bottom: 6px; border: 1px solid var(--p5-border); background: var(--p5-surface);
  cursor: pointer; transition: all 0.15s;
}
.mvsb-shot-card:hover { border-color: var(--p5-red); }
.mvsb-shot-sel { border-color: var(--p5-red); background: rgba(230,57,70,0.05); }
.mvsb-shot-thumb {
  width: 72px; aspect-ratio: 16/9; overflow: hidden;
  background: #0a0a0a; border: 1px solid var(--p5-border);
  display: flex; align-items: center; justify-content: center;
}
.mvsb-shot-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.mvsb-shot-thumb-state { color: var(--p5-text-secondary); }
.mvsb-shot-thumb-empty { opacity: 0.35; }
.mvsb-shot-info { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.mvsb-shot-info-top { display: flex; gap: 6px; align-items: center; }
.mvsb-shot-gidx { font-size: 11px; color: var(--p5-red); font-weight: 600; }
.mvsb-shot-role {
  font-size: 10px; color: var(--p5-text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mvsb-shot-info-bot {
  font-size: 11px; color: var(--p5-text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Right column: shot detail */
.mvsb-col-detail { overflow: hidden; }
.mvsb-detail-scroll { flex: 1; overflow-y: auto; padding: 14px 18px; }
.mvsb-detail-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--p5-text-secondary); gap: 10px; padding: 40px;
}
.mvsb-detail-empty-title { font-size: 13px; }
.mvsb-detail-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--p5-border);
}
.mvsb-detail-gidx { font-size: 16px; font-weight: 700; color: var(--p5-red); }
.mvsb-detail-role {
  font-size: 11px; color: var(--p5-text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mvsb-detail-dur { margin-left: auto; font-size: 11px; color: var(--p5-text-secondary); }

/* Hero 2×2 grid */
.mvsb-detail-hero {
  aspect-ratio: 16/9; width: 100%; margin-bottom: 12px;
  position: relative; overflow: hidden; background: #0a0a0a;
  border: 1px solid var(--p5-border); cursor: zoom-in;
}
.mvsb-detail-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mvsb-detail-hero-grid {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  opacity: 0.15;
}
.mvsb-detail-hero-grid > div { border: 1px solid #fff; }
.mvsb-detail-hero-empty {
  display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center;
  color: var(--p5-text-secondary); cursor: default;
}
.mvsb-detail-hero-empty span { font-size: 11px; }

.mvsb-detail-actions { display: flex; gap: 8px; margin-bottom: 14px; }

/* Shared KV rows (pe41 structure block) */
.mvsb-detail-section {
  margin-bottom: 12px; background: var(--p5-surface); border: 1px solid var(--p5-border);
  padding: 10px 12px;
}
.mvsb-detail-section-title {
  font-size: 12px; font-weight: 600; color: var(--p5-text);
  cursor: pointer; padding: 2px 0; list-style: none;
}
.mvsb-detail-section-title::marker { display: none; }
.mvsb-detail-section-title::-webkit-details-marker { display: none; }
.mvsb-detail-section[open] .mvsb-detail-section-title { margin-bottom: 10px; }
.mvsb-detail-section-meta { color: var(--p5-text-secondary); font-weight: normal; font-size: 10px; }

.mvsb-kv-block { display: flex; flex-direction: column; gap: 6px; }
.mvsb-kv { display: grid; grid-template-columns: 82px 1fr; gap: 8px; font-size: 11px; }
.mvsb-kv-k { color: var(--p5-text-secondary); text-transform: capitalize; }
.mvsb-kv-v { color: var(--p5-text); word-break: break-word; }

/* 4-frame state grid */
.mvsb-frames {
  margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.mvsb-frame { display: flex; flex-direction: column; gap: 4px; }
.mvsb-frame-num {
  font-size: 10px; color: var(--p5-red); font-weight: 600;
  letter-spacing: 0.5px;
}
.mvsb-frame-img {
  aspect-ratio: 16/9; overflow: hidden; background: #0a0a0a;
  border: 1px solid var(--p5-border);
}
.mvsb-frame-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.mvsb-frame-empty {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--p5-text-secondary); opacity: 0.35;
}
.mvsb-frame-state {
  font-size: 11px; color: var(--p5-text-secondary); line-height: 1.4;
}

/* Refs row */
.mvsb-refs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
}
.mvsb-ref {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--p5-border); background: #0a0a0a; padding: 6px;
}
.mvsb-ref-num { font-size: 10px; color: var(--p5-red); font-weight: 600; }
.mvsb-ref-img { aspect-ratio: 1/1; overflow: hidden; background: #000; }
.mvsb-ref-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.mvsb-ref-empty {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--p5-text-secondary); opacity: 0.35;
}
.mvsb-ref-meta { min-height: 22px; }
.mvsb-ref-name {
  font-size: 11px; color: var(--p5-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mvsb-ref-sub {
  font-size: 10px; color: var(--p5-text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Composition panel_details (PE43 raw text) */
.mvsb-composition-pre {
  width: 100%; margin: 0; padding: 10px;
  background: #0a0a0a; color: var(--p5-text-secondary);
  border: 1px solid var(--p5-border);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 360px; overflow-y: auto;
}

/* Elapsed timer (shown on generating hero) */
.mvsb-elapsed {
  display: inline-block; margin-left: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--p5-red); font-weight: 600;
}

/* Nano prompt block */
.mvsb-prompt-wrap { position: relative; }
.mvsb-prompt-textarea {
  width: 100%; min-height: 140px; max-height: 320px;
  background: #0a0a0a; color: var(--p5-text); border: 1px solid var(--p5-border);
  padding: 8px 10px; font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11px; line-height: 1.5; resize: vertical;
}
.mvsb-prompt-copy {
  position: absolute; top: 6px; right: 6px;
  padding: 3px 8px; font-size: 10px;
}

/* Lyrics block in detail head area */
.mvsb-detail-lyrics {
  padding: 8px 12px; margin-bottom: 12px;
  border-left: 2px solid var(--p5-red); background: rgba(230,57,70,0.04);
}
.mvsb-detail-lyrics-label {
  font-size: 10px; color: var(--p5-text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px;
}
.mvsb-detail-lyrics-body { font-size: 12px; color: var(--p5-text); line-height: 1.55; }

/* Spinner animation (shared shape with mva-spinner) */
.mvsb-spinner { animation: mvsbSpin 1s linear infinite; }
@keyframes mvsbSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Warn modal */
.mvsb-warn-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.mvsb-warn-dialog {
  width: 520px; max-width: 92vw; background: var(--p5-surface);
  border: 1px solid var(--p5-border); display: flex; flex-direction: column;
}
.mvsb-warn-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--p5-border);
  color: var(--p5-red);
}
.mvsb-warn-head h3 { margin: 0; font-size: 14px; color: var(--p5-text); }
.mvsb-warn-body-wrap { padding: 14px 18px; color: var(--p5-text); font-size: 12px; line-height: 1.6; }
.mvsb-warn-body-wrap p { margin: 0 0 10px 0; }
.mvsb-warn-list {
  margin: 0; padding: 0 0 0 18px; color: var(--p5-text-secondary);
}
.mvsb-warn-list li { margin-bottom: 4px; }
.mvsb-warn-sub { color: var(--p5-text); font-size: 11px; }
.mvsb-warn-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--p5-border);
}

/* ── Video generation section (below 2×2 grid hero) ── */
.mvsb-video-section { border-left: 2px solid rgba(230,57,70,0.35); padding-left: 10px; }
.mvsb-video-pacing {
  display: inline-block; padding: 2px 7px; margin-left: 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--p5-text); background: rgba(255,255,255,0.06); border: 1px solid var(--p5-border);
}
.mvsb-pacing-calm      { background: rgba(99, 155, 255, 0.12); border-color: rgba(99,155,255,0.35); color: #8cb5ff; }
.mvsb-pacing-steady    { background: rgba(119, 221, 170, 0.10); border-color: rgba(119,221,170,0.30); color: #9be5bf; }
.mvsb-pacing-building  { background: rgba(255, 195, 89, 0.12); border-color: rgba(255,195,89,0.35); color: #ffd07a; }
.mvsb-pacing-dynamic   { background: rgba(255, 120, 97, 0.14); border-color: rgba(255,120,97,0.38); color: #ff9881; }
.mvsb-pacing-escalated { background: rgba(230, 57, 70, 0.16); border-color: rgba(230,57,70,0.45); color: #ff6b78; }
.mvsb-pacing-peak      { background: rgba(230, 57, 70, 0.25); border-color: rgba(230,57,70,0.6);  color: #ff3a50; }
.mvsb-pacing-bridge    { background: rgba(180, 120, 255, 0.14); border-color: rgba(180,120,255,0.38); color: #c9a0ff; }

.mvsb-video-res-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0 4px 0;
}
.mvsb-video-res-label { font-size: 11px; color: var(--p5-text-secondary); }
.mvsb-video-res-opt {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 11px; color: var(--p5-text);
}
.mvsb-video-res-opt input { margin: 0; accent-color: var(--p5-red); }

.mvsb-video-actions { display: flex; gap: 8px; margin: 6px 0 10px 0; flex-wrap: wrap; }

.mvsb-video-progress {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; margin: 4px 0 10px 0;
  font-size: 11px; color: var(--p5-text-secondary);
  background: rgba(255,195,89,0.06); border: 1px solid rgba(255,195,89,0.25);
}
.mvsb-video-error {
  padding: 6px 10px; margin: 4px 0 10px 0;
  font-size: 11px; color: #ff6b78;
  background: rgba(230,57,70,0.08); border: 1px solid rgba(230,57,70,0.35);
}

.mvsb-video-player-wrap { margin: 6px 0 10px 0; }
.mvsb-video-player {
  width: 100%; max-width: 768px; aspect-ratio: 16/9;
  background: #000; border: 1px solid var(--p5-border); display: block;
}

.mvsb-video-history {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 0 0 10px 0; font-size: 10px; color: var(--p5-text-secondary);
}
.mvsb-video-history-label { margin-right: 4px; }
.mvsb-video-history-item {
  padding: 3px 8px; cursor: pointer;
  background: transparent; color: var(--p5-text-secondary);
  border: 1px solid var(--p5-border);
  font-family: inherit; font-size: 10px;
}
.mvsb-video-history-item:hover { border-color: var(--p5-red); color: var(--p5-text); }
.mvsb-video-history-sel { background: rgba(230,57,70,0.12); border-color: var(--p5-red); color: var(--p5-text); }

.mvsb-video-prompt-details { margin-top: 4px; }
.mvsb-video-prompt-details > summary {
  cursor: pointer; font-size: 11px; color: var(--p5-text-secondary);
  padding: 4px 0; list-style: none;
}
.mvsb-video-prompt-details > summary::marker,
.mvsb-video-prompt-details > summary::-webkit-details-marker { display: none; }

/* ════════════════════════════════════════════════════════════════
   MV Storyboard V4 visual refresh (2026-04-28 wangqun)
   Inspired by camikalabs-UI/project/manga-drama-v4.html Screen 4.
   Extends existing .mvsb-* rules — later declarations win cascade.
   Rules applied: E11 (grep before delete), E12 (matte), D (dual-theme).
   ════════════════════════════════════════════════════════════════ */

/* Hide Video UI while feature-flagged off — see MV_VIDEO_UI_ENABLED in JS. */
body.mv-video-hidden .mvsb-video-section,
body.mv-video-hidden .mvsb-detail-actions .mvsb-btn-video,
body.mv-video-hidden .mvsb-video-history,
body.mv-video-hidden .mvsb-video-player-wrap,
body.mv-video-hidden .mvsb-video-actions,
body.mv-video-hidden .mvsb-video-progress,
body.mv-video-hidden .mvsb-video-error,
body.mv-video-hidden .mvsb-video-res-row,
body.mv-video-hidden .mvsb-video-pacing { display: none !important; }

/* ── Top bar: info L (title + version chip + progress) / actions R ── */
.mvsw-header.mvsb-v4-top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--p5-surface);
  border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.mvsb-v4-top-l {
  display: flex; align-items: center; gap: 14px;
  flex: 1; min-width: 0;
}
.mvsb-v4-top-r {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center;
}

/* ── Region card v4 ── label + tag + status dot + always-visible gen-btn */
.mvsb-col-regions { padding: 10px; gap: 0; }
.mvsb-region {
  position: relative;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--p5-card);
  border: 1px solid var(--p5-border);
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.04);
  cursor: pointer;
}
.mvsb-region:hover {
  border-color: rgba(230,57,70,0.4);
}
.mvsb-region.mvsb-region-sel {
  border-color: var(--p5-red);
  box-shadow:
    0 3px 10px rgba(230,57,70,0.2),
    0 6px 20px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(230,57,70,0.15);
}
.mvsb-region-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px;
}
.mvsb-region-role {
  font-family: var(--font-display);
  font-weight: 600; font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--p5-text);
}
.mvsb-region-tag {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  padding: 2px 6px;
  background: var(--p5-red);
  color: #000;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.mvsb-region-mid {
  font-size: 11px;
  color: var(--p5-text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}
.mvsb-region-status {
  display: flex; align-items: center; gap: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
  margin-bottom: 8px;
}
.mvsb-region-status .mvsb-region-dot {
  width: 6px; height: 6px;
  background: var(--p5-red);
  flex-shrink: 0;
}
.mvsb-region.mvsb-region-done .mvsb-region-status { color: #22c55e; }
.mvsb-region.mvsb-region-done .mvsb-region-dot    { background: #22c55e; }
.mvsb-region-bot { display: block; margin-top: 4px; }
.mvsb-region .mvsb-gen-btn {
  display: block; width: 100%;
  padding: 7px 10px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--p5-text-secondary);
  background: transparent;
  border: 1px solid var(--p5-border);
  text-align: center;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.mvsb-region .mvsb-gen-btn:hover:not(:disabled) {
  color: var(--p5-red);
  border-color: var(--p5-red);
}
.mvsb-region.mvsb-region-sel .mvsb-gen-btn:not(:disabled) {
  background: var(--p5-red);
  color: #000;
  border-color: var(--p5-red);
  font-weight: 700;
}
.mvsb-region .mvsb-gen-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mvsb-region .mvsb-gen-btn svg { vertical-align: middle; margin-right: 4px; }

/* ── Shot panel block v4 ── 2×2 real Nano aspect + in-card history + 2 action rows */
.mvsb-shots-list { padding: 10px; }
.mvsb-shot-block {
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
  padding: 5px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.5),
    0 4px 16px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.04);
}
.mvsb-shot-block:hover {
  transform: translateY(-1px);
  border-color: rgba(230,57,70,0.4);
}
.mvsb-shot-block.mvsb-shot-sel {
  border-color: var(--p5-red);
  box-shadow:
    0 3px 10px rgba(230,57,70,0.2),
    0 6px 20px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(230,57,70,0.15);
}
.mvsb-shot-ph {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--p5-border);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--p5-text);
}
.mvsb-shot-ph-n {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--p5-red);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.mvsb-shot-ph-role {
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
}
.mvsb-shot-ph-dur {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--p5-text-secondary);
  margin-left: auto;
}
.mvsb-shot-ph-tick {
  width: 14px; height: 14px;
  background: var(--p5-red);
  display: none; place-items: center;
  flex-shrink: 0;
}
.mvsb-shot-block.mvsb-shot-sel .mvsb-shot-ph-tick { display: grid; }
.mvsb-shot-ph-tick svg { width: 8px; height: 8px; color: #000; }

/* 2×2 true Nano grid — wrap keeps 16:9 outer, cells auto halve ≈ 8:9 each */
.mvsb-shot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: #000;
  aspect-ratio: 16/9;
  overflow: hidden;
}
.mvsb-shot-grid-cell {
  position: relative;
  overflow: hidden;
  background: #000;
}
.mvsb-shot-grid-cell img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.mvsb-shot-grid-cell .mvsb-shot-grid-fn {
  position: absolute; top: 4px; left: 4px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 9px;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  background: #000;
  color: var(--p5-red);
  border: 1px solid var(--p5-red);
  z-index: 2;
}
.mvsb-shot-grid-cell-empty {
  display: grid; place-items: center;
  color: var(--p5-text-secondary);
  opacity: 0.35;
}
.mvsb-shot-grid-placeholder {
  aspect-ratio: 16/9;
  background: var(--p5-input-bg);
  border: 1px dashed var(--p5-border);
  display: grid; place-items: center;
  color: var(--p5-text-secondary);
  gap: 6px;
  grid-auto-flow: row;
}
.mvsb-shot-grid-placeholder.mvsb-shot-grid-generating {
  border-color: var(--p5-red);
  color: var(--p5-red);
}
.mvsb-shot-grid-placeholder.mvsb-shot-grid-failed {
  border-color: rgba(239,68,68,0.5);
  color: #ef4444;
}
.mvsb-shot-grid-ptext {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* In-card history strip — below grid, above actions */
.mvsb-shot-history {
  display: flex; gap: 4px;
  padding: 6px 8px;
  background: var(--p5-surface);
  border-top: 1px solid var(--p5-border);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--p5-border) transparent;
}
.mvsb-shot-history::-webkit-scrollbar { height: 4px; }
.mvsb-shot-history::-webkit-scrollbar-thumb { background: var(--p5-border); }
.mvsb-shot-history-label {
  flex-shrink: 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--p5-red);
  align-self: center;
  padding-right: 6px;
  border-right: 1px solid var(--p5-border);
  margin-right: 4px;
  font-weight: 700;
}
.mvsb-shot-history-item {
  width: 60px;
  aspect-ratio: 16/9;
  border: 1px solid var(--p5-border);
  background: var(--p5-input-bg);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  transition: border-color .15s;
}
.mvsb-shot-history-item:hover { border-color: rgba(230,57,70,0.5); }
.mvsb-shot-history-item.mvsb-shot-history-sel { border-color: var(--p5-red); }
.mvsb-shot-history-item img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* Action rows — 1 or 2 rows separated by 1px black gutter */
.mvsb-shot-actions {
  display: flex; gap: 1px;
  background: #000;
  border-top: 1px solid var(--p5-border);
}
.mvsb-shot-action {
  flex: 1;
  padding: 6px 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p5-text-secondary);
  background: var(--p5-card);
  border: none;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.mvsb-shot-action:hover:not(:disabled) {
  background: var(--p5-input-bg);
  color: var(--p5-text);
}
.mvsb-shot-action.mvsb-shot-action-primary {
  background: var(--p5-red);
  color: #000;
  font-weight: 700;
}
.mvsb-shot-action.mvsb-shot-action-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}
.mvsb-shot-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* ───────────────────────────────────────────────────────────────
   MV Compositing (Step 11) — ported from .md-comp-* with 4-track
   timeline (Video / Subtitle / Dub / BGM). Song drives playback.
   ─────────────────────────────────────────────────────────────── */

#song-mv-compositing { display: none; flex-direction: column; width: 100%; height: 100%; overflow: hidden; }
#song-mv-compositing.active { display: flex; }

.mvc-header {
  flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 8px 20px; border-bottom: 1px solid var(--p5-border);
  background: var(--p5-card); min-height: 44px;
}
.mvc-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--p5-text); }
.mvc-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Progress badge — "X/Y clips · M:SS / M:SS" */
.mvc-progress-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; font-size: 11px; font-family: 'Courier New', monospace;
  color: var(--p5-text-secondary); border: 1px solid var(--p5-border);
  background: var(--p5-surface);
}
.mvc-progress-badge.mvc-pb-ok { color: #4caf50; border-color: rgba(76,175,80,0.5); }
.mvc-progress-badge .mvc-pb-sep { color: var(--p5-muted); }

/* Body grid — sidebar:main = 20:80 */
.mvc-body { flex: 1; display: grid; grid-template-columns: 20% 80%; height: 100%; overflow: hidden; min-height: 0; }
.mvc-sidebar { overflow-y: auto; padding: 10px; border-right: 1px solid var(--p5-border); scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }
.mvc-main { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* Shot cards in sidebar */
.mvc-shot-card { padding: 10px; margin-bottom: 10px; border: 1px solid var(--p5-border); cursor: pointer; transition: border-color 0.2s; border-left: 3px solid transparent; }
.mvc-shot-card:hover { border-color: var(--p5-text-secondary); }
.mvc-shot-card.active { border-color: var(--p5-red); border-left-color: var(--p5-red); }
.mvc-shot-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mvc-shot-num { font-size: 13px; font-weight: 700; color: var(--p5-red); }
.mvc-shot-dur { font-size: 11px; color: var(--p5-muted); padding: 1px 6px; border: 1px solid var(--p5-border); }
.mvc-shot-role { font-size: 9px; color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-left: auto; }
.mvc-shot-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; opacity: 0; transition: opacity 0.3s; border: 1px solid var(--p5-border); }
.mvc-shot-card img.loaded { opacity: 1; }
.mvc-shot-placeholder { width: 100%; aspect-ratio: 16/9; background: var(--p5-surface); border: 1px dashed var(--p5-border); display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--p5-muted); }
.mvc-sidebar-empty { padding: 20px; text-align: center; font-size: 12px; color: var(--p5-muted); }

/* Player area */
.mvc-player-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 10px 24px 6px; min-height: 0; }
.mvc-player-wrap { flex: 1; display: flex; flex-direction: column; background: #0a0a0a; border: 1px solid #333; min-height: 0; overflow: hidden; max-height: 90%; position: relative; }
.mvc-video { flex: 1; width: 100%; object-fit: contain; background: #000; min-height: 0; }

.mvc-lyric-overlay {
  position: absolute; left: 0; right: 0; bottom: 48px;
  text-align: center; padding: 0 24px; pointer-events: none;
  font-size: 18px; font-weight: 600; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.85), 0 0 2px rgba(0,0,0,1);
  opacity: 0; transition: opacity 0.15s; line-height: 1.4;
}
.mvc-lyric-overlay.show { opacity: 1; }

.mvc-player-controls { flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 6px 16px; background: #111; border-top: 1px solid #333; }
.mvc-play-btn { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; display: flex; align-items: center; }
.mvc-play-btn:hover { color: var(--p5-red); }
.mvc-time-display { font-family: 'Courier New', monospace; font-size: 12px; color: #aaa; white-space: nowrap; min-width: 110px; }
.mvc-volume-wrap { margin-left: auto; display: flex; align-items: center; gap: 6px; color: #aaa; }
.mvc-volume-slider { width: 80px; height: 4px; cursor: pointer; accent-color: var(--p5-red); }

.mvc-body .dt-btn, .mvc-header .dt-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 14px; font-size: 11px; border: 1px solid var(--p5-border); background: transparent; color: var(--p5-text-secondary); cursor: pointer; transition: all 0.2s; }
.mvc-body .dt-btn:hover, .mvc-header .dt-btn:hover { border-color: var(--p5-red); color: var(--p5-text); }
.mvc-body .dt-btn-primary, .mvc-header .dt-btn-primary { border-color: var(--p5-red); color: var(--p5-red); }
.mvc-body .dt-btn-primary:hover, .mvc-header .dt-btn-primary:hover { background: var(--p5-red); color: #fff; }

/* Timeline area */
.mvc-timeline-area { flex-shrink: 0; height: 200px; overflow: hidden; border-top: 1px solid var(--p5-border); }
.mvc-tl { position: relative; height: 100%; display: flex; flex-direction: column; overflow: hidden; user-select: none; }

.mvc-tl-header { display: flex; flex-shrink: 0; height: 28px; border-bottom: 1px solid var(--p5-border); background: var(--p5-card); }
.mvc-tl-label-col { flex: 0 0 56px; }
.mvc-tl-ruler { position: relative; flex: 1; overflow: hidden; height: 28px; cursor: pointer; }
.mvc-tl-tick { position: absolute; top: 0; height: 100%; }
.mvc-tl-tick.major { border-left: 1px solid var(--p5-border); }
.mvc-tl-tick.major span { position: absolute; top: 4px; left: 4px; font-size: 9px; color: var(--p5-muted); white-space: nowrap; font-family: 'Courier New', monospace; }
.mvc-tl-tick.minor { border-left: 1px solid rgba(255,255,255,0.05); }

.mvc-tl-body { flex: 1; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent; }

.mvc-tl-track { display: flex; height: 36px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.mvc-tl-track-label { flex: 0 0 56px; display: flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 10px; font-weight: 600; color: var(--p5-muted); text-transform: uppercase; letter-spacing: 0.5px; border-right: 1px solid var(--p5-border); }
.mvc-tl-track-content { position: relative; flex: 1; min-width: 100%; cursor: pointer; }

/* Video clip (red) */
.mvc-tl-clip { position: absolute; top: 3px; height: 30px; display: flex; align-items: center; background: rgba(230,57,70,0.15); border: 1px solid rgba(230,57,70,0.4); cursor: grab; transition: background 0.15s; }
.mvc-tl-clip:hover { background: rgba(230,57,70,0.25); }
.mvc-tl-clip.dragging { opacity: 0.7; z-index: 5; cursor: grabbing; }
.mvc-tl-clip-body { flex: 1; display: flex; align-items: center; gap: 6px; padding: 0 8px; overflow: hidden; min-width: 0; }
.mvc-tl-clip-label { font-size: 11px; font-weight: 600; color: var(--p5-red); white-space: nowrap; }
.mvc-tl-clip-dur { font-size: 9px; color: var(--p5-muted); white-space: nowrap; }

.mvc-tl-clip-handle { flex: 0 0 12px; height: 100%; cursor: ew-resize; transition: background 0.15s; position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; background: rgba(230,57,70,0.25); }
.mvc-tl-clip-handle::after { content: ''; display: block; width: 2px; height: 18px; background: rgba(255,255,255,0.4); box-shadow: -3px 0 0 rgba(255,255,255,0.25), 3px 0 0 rgba(255,255,255,0.25); }
.mvc-tl-clip-handle:hover { background: rgba(230,57,70,0.5); }
.mvc-tl-clip-handle:hover::after { background: #fff; box-shadow: -3px 0 0 rgba(255,255,255,0.7), 3px 0 0 rgba(255,255,255,0.7); }
.mvc-tl-clip-handle:active { background: rgba(230,57,70,0.7); }
.mvc-tl-clip-handle.left { border-right: 2px solid rgba(230,57,70,0.8); }
.mvc-tl-clip-handle.right { border-left: 2px solid rgba(230,57,70,0.8); }

/* Subtitle (blue) — shows lyric text + click to edit */
.mvc-tl-sub { position: absolute; top: 4px; height: 28px; display: flex; align-items: center; padding: 0 6px; background: rgba(100,149,237,0.2); border: 1px solid rgba(100,149,237,0.4); overflow: hidden; cursor: grab; transition: background 0.15s; }
.mvc-tl-sub:hover { background: rgba(100,149,237,0.35); border-color: rgba(100,149,237,0.7); }
.mvc-tl-sub span { font-size: 9px; color: rgba(100,149,237,0.95); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Dub (green) — empty placeholder in v1 */
.mvc-tl-dub { position: absolute; top: 4px; height: 28px; display: flex; align-items: center; gap: 4px; padding: 0 6px; background: rgba(76,175,80,0.2); border: 1px solid rgba(76,175,80,0.4); overflow: hidden; cursor: grab; transition: background 0.15s; }
.mvc-tl-dub:hover { background: rgba(76,175,80,0.35); }
.mvc-tl-dub-empty { position: absolute; top: 4px; left: 4px; right: 4px; height: 28px; display: flex; align-items: center; justify-content: center; border: 1px dashed rgba(76,175,80,0.25); }
.mvc-tl-dub-empty span { font-size: 10px; color: rgba(76,175,80,0.5); }

/* BGM (yellow) — song locked, full width */
.mvc-tl-bgm-bar { position: absolute; top: 4px; height: 28px; display: flex; align-items: center; padding: 0 8px; background: rgba(255,193,7,0.15); border: 1px solid rgba(255,193,7,0.4); overflow: hidden; }
.mvc-tl-bgm-bar span { font-size: 9px; color: rgba(255,193,7,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Playhead */
.mvc-tl-playhead { position: absolute; top: 0; bottom: 0; width: 11px; margin-left: -5px; z-index: 10; cursor: col-resize; pointer-events: auto; }
.mvc-tl-playhead-head { width: 12px; height: 12px; margin-left: 0; background: #00e5ff; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.mvc-tl-playhead-line { width: 1px; height: calc(100% - 12px); background: #00e5ff; margin-left: 5px; box-shadow: 0 0 4px rgba(0,229,255,0.5); }

/* Lyric edit modal */
.mvc-lyric-overlay-modal {
  position: fixed; inset: 0; z-index: 10020;
  background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
}
.mvc-lyric-dialog {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  padding: 24px; width: 480px; max-width: 90vw; display: flex; flex-direction: column; gap: 14px;
}
.mvc-lyric-dialog h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--p5-text); }
.mvc-lyric-dialog textarea {
  background: var(--p5-surface); color: var(--p5-text); border: 1px solid var(--p5-border);
  padding: 10px; font-size: 13px; font-family: inherit; resize: vertical; width: 100%;
}
.mvc-lyric-time-row { display: flex; gap: 14px; }
.mvc-lyric-time-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--p5-muted); }
.mvc-lyric-time-row input {
  background: var(--p5-surface); color: var(--p5-text); border: 1px solid var(--p5-border);
  padding: 6px 8px; font-size: 12px; font-family: 'Courier New', monospace;
}
.mvc-lyric-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Track card compositing shortcut button (dt-song) */
.song-track-comp-btn { color: var(--p5-red); }
.song-track-comp-btn:hover { background: var(--p5-red); color: #fff; }

/* Storyboard header [合片 →] outline button hover */
#mvsb-to-comp-btn { border-color: var(--p5-red); color: var(--p5-red); }
#mvsb-to-comp-btn:hover { background: var(--p5-red); color: #fff; }

/* ───────────────────────────────────────────────────────────────
   MV Storyboard versioning UI (sql/103) — version chip + dropdown
   menu + manager modal. Placed in mvsw-header next to title.
   ─────────────────────────────────────────────────────────────── */
.mvsb-version-switch { position: relative; display: inline-block; }
.mvsb-version-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; font-size: 11px; font-weight: 600;
  color: var(--p5-red); background: transparent;
  border: 1px solid var(--p5-red); cursor: pointer; transition: all 0.15s;
  font-family: 'Courier New', monospace;
}
.mvsb-version-chip:hover { background: var(--p5-red); color: #fff; }
.mvsb-version-chip[aria-expanded="true"] { background: var(--p5-red); color: #fff; }
.mvsb-version-label { letter-spacing: 0.5px; }

.mvsb-version-menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 1000;
  min-width: 280px; max-width: 360px; max-height: 420px; overflow-y: auto;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent;
}
.mvsb-version-item {
  padding: 10px 12px; cursor: pointer; transition: background 0.1s;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.mvsb-version-item:hover { background: rgba(230,57,70,0.08); }
.mvsb-version-item.active { background: rgba(230,57,70,0.12); border-left: 3px solid var(--p5-red); padding-left: 9px; }
.mvsb-version-item-row1 {
  display: flex; align-items: center; gap: 6px; margin-bottom: 3px;
}
.mvsb-version-item-seq { font-size: 11px; font-weight: 700; color: var(--p5-red); font-family: 'Courier New', monospace; min-width: 32px; }
.mvsb-version-item-label { font-size: 12px; color: var(--p5-text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvsb-version-item-check { color: var(--p5-red); font-size: 13px; }
.mvsb-version-item-row2 {
  display: flex; align-items: center; gap: 10px; font-size: 10px; color: var(--p5-muted);
  font-family: 'Courier New', monospace;
}
.mvsb-version-item-meta { display: inline-flex; align-items: center; gap: 3px; }
.mvsb-version-menu-divider { height: 1px; background: var(--p5-border); margin: 4px 0; }
.mvsb-version-menu-footer {
  padding: 8px 12px; font-size: 11px; color: var(--p5-text-secondary);
  cursor: pointer; text-align: center;
}
.mvsb-version-menu-footer:hover { background: rgba(230,57,70,0.08); color: var(--p5-red); }

/* Version manager modal */
.mvsb-ver-overlay {
  position: fixed; inset: 0; z-index: 10030;
  background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
}
.mvsb-ver-dialog {
  background: var(--p5-card); border: 1px solid var(--p5-border);
  width: 600px; max-width: 92vw; max-height: 80vh; display: flex; flex-direction: column;
}
.mvsb-ver-head {
  display: flex; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--p5-border);
}
.mvsb-ver-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--p5-text); flex: 1; }
.mvsb-ver-close {
  background: none; border: none; color: var(--p5-muted); cursor: pointer; font-size: 16px; padding: 4px 8px;
}
.mvsb-ver-close:hover { color: var(--p5-red); }
.mvsb-ver-list {
  flex: 1; overflow-y: auto; padding: 8px;
  scrollbar-width: thin; scrollbar-color: var(--p5-border) transparent;
}
.mvsb-ver-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border: 1px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.mvsb-ver-row.active { border-color: var(--p5-red); background: rgba(230,57,70,0.06); }
.mvsb-ver-seq { font-family: 'Courier New', monospace; font-size: 13px; font-weight: 700; color: var(--p5-red); }
.mvsb-ver-info { min-width: 0; }
.mvsb-ver-name {
  font-size: 12px; color: var(--p5-text); display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mvsb-ver-name-input {
  width: 100%; background: var(--p5-surface); color: var(--p5-text);
  border: 1px solid var(--p5-border); padding: 4px 6px; font-size: 12px; font-family: inherit;
}
.mvsb-ver-stats {
  font-size: 10px; color: var(--p5-muted); font-family: 'Courier New', monospace;
  margin-top: 2px; display: flex; gap: 10px;
}
.mvsb-ver-actions { display: flex; gap: 4px; }
.mvsb-ver-btn {
  background: none; border: 1px solid var(--p5-border); color: var(--p5-text-secondary);
  padding: 4px 8px; font-size: 10px; cursor: pointer; transition: all 0.15s;
}
.mvsb-ver-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }
.mvsb-ver-btn.mvsb-ver-btn-danger:hover { border-color: #e85c4a; color: #e85c4a; background: rgba(232,92,74,0.1); }
.mvsb-ver-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mvsb-ver-empty { padding: 40px 20px; text-align: center; color: var(--p5-muted); font-size: 12px; }

/* MV Compositing — version mismatch banner (storyboard switched after comp built) */
.mvc-mismatch-banner {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; background: rgba(255,193,7,0.12);
  border-bottom: 1px solid rgba(255,193,7,0.35);
  color: rgba(255,193,7,0.95); font-size: 12px;
}
.mvc-mismatch-text { flex: 1; }
.mvc-mismatch-dismiss {
  background: none; border: none; color: rgba(255,255,255,0.45); cursor: pointer;
  padding: 4px 8px; font-size: 13px; line-height: 1;
}
.mvc-mismatch-dismiss:hover { color: #fff; }

/* ============================================================ */
/* Manga Drama Homepage V2 (2026-04-26)                          */
/* Ref: camikalabs-UI/project/manga-drama-v4.html Screen 0        */
/* Pattern shared with song-my-page (MV Song Studio)              */
/* ============================================================ */

.md-my-page { flex: 1; overflow-y: auto; padding: 28px; background: var(--p5-dark); }
.md-my-page::-webkit-scrollbar { width: 6px; }
.md-my-page::-webkit-scrollbar-thumb { background: var(--p5-input-bg); }

.md-my-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--p5-border); position: relative; }
.md-my-head::before { content: ''; position: absolute; left: 0; bottom: -1px; width: 160px; height: 2px; background: var(--p5-red); }
.md-my-head-left { min-width: 0; }
.md-my-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; color: var(--p5-text); margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.md-my-title-ji { font-size: 14px; color: var(--p5-red); font-weight: 700; font-style: normal; letter-spacing: 0.08em; }
.md-my-sub { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.1em; color: var(--p5-muted); text-transform: uppercase; margin-top: 6px; font-weight: 500; }
.md-my-sub b { color: var(--p5-red); font-weight: 700; }

.md-my-head-actions { display: flex; flex-shrink: 0; gap: 12px; align-items: stretch; }
.md-my-new-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; background: var(--p5-red); color: #000; border: 0; font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer; transition: background 0.15s, color 0.15s; }
.md-my-new-btn:hover { background: #ff8080; color: #fff; }
.md-my-new-btn svg { width: 11px; height: 11px; }

/* Grid — fixed columns per rules-ui-global E5 */
.md-proj-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-content: start; }
@media (max-width: 1100px) { .md-proj-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } }
@media (max-width: 720px)  { .md-proj-grid { grid-template-columns: 1fr; gap: 12px; } }

/* Card shell */
.md-proj-card { border: 1px solid var(--p5-border); background: var(--p5-card); transition: border-color 0.15s, box-shadow 0.15s; cursor: pointer; position: relative; overflow: hidden; }
.md-proj-card:hover { border-color: var(--p5-red); box-shadow: 0 6px 18px rgba(230,57,70,0.12); }

/* Poster — 16:10 + gradient fallback + bottom scrim */
.md-proj-card .poster { aspect-ratio: 16/10; position: relative; overflow: hidden; background: var(--p5-dark); }
.md-proj-card .poster::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,0.85)); pointer-events: none; z-index: 1; }
.md-proj-card .poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }

/* Gradient fallback (4 presets rotated by project id) */
.md-proj-card .poster.g-red    { background: linear-gradient(135deg, #3a1420, #7a2030 50%, #c02836); }
.md-proj-card .poster.g-noir   { background: linear-gradient(135deg, #0a0e18, #1a2340 55%, #405578); }
.md-proj-card .poster.g-sunset { background: linear-gradient(135deg, #1a1a24, #3a2d38 55%, #f5b53d); }
.md-proj-card .poster.g-violet { background: linear-gradient(135deg, #1a0e2e, #4a1a6a 55%, #a560d0); }

/* Center camera icon (visible only when no cover image) */
.md-proj-card .poster .icon { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,0.5); z-index: 1; pointer-events: none; }
.md-proj-card .poster .icon svg { width: 56px; height: 56px; stroke-width: 1.2; }

/* Badges */
.md-proj-card .badge-tl { position: absolute; top: 10px; left: 10px; z-index: 3; font-family: var(--font-display); font-size: 10px; padding: 3px 7px; background: #000; color: var(--p5-red); border: 1px solid var(--p5-red); letter-spacing: 0.08em; font-weight: 600; }
[data-theme="light"] .md-proj-card .badge-tl { background: var(--p5-card); }
.md-proj-card .badge-tr { position: absolute; top: 10px; right: 10px; z-index: 3; font-family: var(--font-display); font-size: 11px; padding: 3px 8px; background: var(--p5-red); color: #000; letter-spacing: 0.08em; font-weight: 700; }
.md-proj-card .badge-tr.is-done { background: #f5c518; color: #000; }
.md-proj-card .badge-tr.is-draft { background: transparent; color: var(--p5-text-secondary); border: 1px solid var(--p5-border); }
.md-proj-card .badge-tr.is-v3 { background: var(--p5-card); color: var(--p5-text); border: 1px solid var(--p5-border); }

/* Right-side character avatars — matte picture frame (rules-ui-global E12) */
.md-proj-card .card-chars { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 4; opacity: 0; transition: opacity 0.3s; }
.md-proj-card:hover .card-chars { opacity: 1; }
.md-proj-card .card-char-avatar {
  width: 42px; height: 42px; padding: 3px;
  background: var(--p5-card); border: 1px solid var(--p5-border);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 4px 14px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
}
.md-proj-card .card-char-avatar:hover {
  transform: translateX(-2px);
  border-color: var(--p5-red);
  box-shadow: 0 3px 10px rgba(230,57,70,0.25), 0 6px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(230,57,70,0.15);
}
.md-proj-card .card-char-avatar > img { position: absolute; top: 3px; left: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; object-position: center top; display: block; }
.md-proj-card .card-char-avatar > span { font-family: var(--font-display); font-size: 12px; font-weight: 700; color: var(--p5-text); letter-spacing: 0.04em; }
[data-theme="light"] .md-proj-card .card-char-avatar {
  box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.6);
}
[data-theme="light"] .md-proj-card .card-char-avatar:hover {
  box-shadow: 0 3px 10px rgba(230,57,70,0.18), 0 6px 16px rgba(0,0,0,0.1), inset 0 1px 0 rgba(230,57,70,0.08);
}
[data-theme="light"] .md-proj-card .card-char-avatar > span { color: var(--p5-text-secondary); }

.md-proj-card .card-char-more {
  width: 42px; height: 42px;
  background: var(--p5-red); border: 1px solid var(--p5-red);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  color: #fff; letter-spacing: 0.04em; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(230,57,70,0.35), 0 4px 14px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
}
[data-theme="light"] .md-proj-card .card-char-more {
  box-shadow: 0 2px 6px rgba(230,57,70,0.2), 0 4px 10px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* Action buttons (delete + cover upload) — bottom of poster, hover reveal */
.md-proj-card .card-cover-btn, .md-proj-card .card-delete { position: absolute; bottom: 8px; z-index: 4; opacity: 0; transition: opacity 0.2s, color 0.2s, background 0.2s; background: rgba(0,0,0,0.55); border: none; color: #fff; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.md-proj-card .card-cover-btn { left: 8px; }
.md-proj-card .card-delete { right: 8px; color: #ff6b6b; }
.md-proj-card .card-cover-btn span { display: none; }
[data-theme="light"] .md-proj-card .card-cover-btn, [data-theme="light"] .md-proj-card .card-delete { background: rgba(255,255,255,0.7); }
[data-theme="light"] .md-proj-card .card-delete { color: var(--p5-red); }
.md-proj-card:hover .card-cover-btn, .md-proj-card:hover .card-delete { opacity: 1; }
.md-proj-card .card-cover-btn:hover { background: rgba(230,57,70,0.85); color: #fff; }

/* Share button — top-right corner (left of tier badge), always visible. Hidden when no panels exist. */
.md-proj-card .card-share {
  position: absolute;
  top: 10px;
  right: 78px;
  z-index: 4;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--p5-border);
  color: #fff;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.md-proj-card .card-share:hover {
  background: rgba(230,57,70,0.85);
  border-color: var(--p5-red);
  color: #fff;
}
.md-proj-card .card-share.active {
  background: var(--p5-red);
  border-color: var(--p5-red);
  color: #fff;
}
[data-theme="light"] .md-proj-card .card-share {
  background: rgba(255,255,255,0.85);
  color: var(--p5-text);
  border-color: var(--p5-border);
}
[data-theme="light"] .md-proj-card .card-share.active {
  background: var(--p5-red);
  color: #fff;
  border-color: var(--p5-red);
}

/* Info region below poster */
.md-proj-card .info { padding: 14px; position: relative; border-top: 1px solid var(--p5-border); }
.md-proj-card .info::before { content: ''; position: absolute; top: -1px; left: 0; width: 36px; height: 1px; background: var(--p5-red); }
.md-proj-card .info h4 { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0.02em; color: var(--p5-text); margin: 0 0 4px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.md-proj-card .info h4:hover { color: var(--p5-red); }
.md-proj-card .info h4 .card-rename-icon { width: 12px; height: 12px; opacity: 0.35; flex-shrink: 0; display: inline-flex; align-items: center; transition: opacity 0.2s; }
.md-proj-card .info h4:hover .card-rename-icon { opacity: 0.9; }
.md-proj-card .card-title-input { width: 100%; background: transparent; border: none; border-bottom: 1.5px solid var(--p5-red); color: var(--p5-text); font-size: 15px; font-weight: 600; padding: 0 0 2px; outline: none; font-family: inherit; }
.md-proj-card .info .phase { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.08em; color: var(--p5-red); text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--p5-red); display: inline-block; margin-top: 2px; }
.md-proj-card .info .phase.is-done { color: #f5c518; border-color: #f5c518; }
.md-proj-card .info .desc { font-size: 11.5px; color: var(--p5-text-secondary); line-height: 1.5; margin: 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-proj-card .info .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--p5-border); font-family: var(--font-display); font-size: 10px; color: var(--p5-muted); letter-spacing: 0.06em; }

/* ============================================================ */
/* Manga Drama Script Page V2 (2026-04-26)                       */
/* Ref: camikalabs-UI/project/manga-drama-v4.html Screen 1        */
/* ============================================================ */

/* View-level: stepper + panel flex stack */
#manga-drama-view.dt-view.active { display: flex; flex-direction: column; height: 100%; }
#manga-drama-view .md-panel.active { flex: 1; min-height: 0; height: auto; }

/* Stepper (independent md- namespace; E11) */
.md-stepper { height: 44px; display: none; align-items: stretch; background: var(--p5-card); border-bottom: 1px solid var(--p5-border); flex-shrink: 0; overflow: hidden; }
.md-stepper.active { display: flex; }
.md-stepper-back { display: flex; align-items: center; gap: 8px; padding: 0 16px; flex-shrink: 0; border: 0; border-right: 1px solid var(--p5-border); background: transparent; font-family: var(--font-display); font-size: 11px; letter-spacing: 0.1em; color: var(--p5-text-secondary); text-transform: uppercase; cursor: pointer; font-weight: 600; transition: background 0.15s, color 0.15s; }
.md-stepper-back:hover { background: var(--p5-input-bg); color: var(--p5-text); }
.md-stepper-back svg { width: 12px; height: 12px; }

.md-step-rail { flex: 1; display: flex; align-items: stretch; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.md-step-rail::-webkit-scrollbar { display: none; }

.md-step { display: flex; align-items: center; gap: 10px; padding: 0 22px 0 0; flex-shrink: 0; color: var(--p5-muted); background: transparent; border: 0; cursor: pointer; white-space: nowrap; font-family: inherit; transition: color 0.15s; }
.md-step:hover:not(.locked) { color: var(--p5-text); }
.md-step.locked { cursor: not-allowed; opacity: 0.4; }
.md-step-idx { width: 26px; height: 26px; display: grid; place-items: center; background: var(--p5-input-bg); color: var(--p5-muted); font-weight: 700; font-size: 12px; margin-left: 18px; position: relative; transition: background 0.15s, color 0.15s, box-shadow 0.15s; }
.md-step.done .md-step-idx { background: var(--p5-red); color: #000; }
.md-step.done .md-step-idx::after { content: ''; position: absolute; inset: 4px; border: 1.5px solid #000; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(2px, -1px); width: 11px; height: 5.5px; }
.md-step.on .md-step-idx { background: var(--p5-red); color: #fff; box-shadow: 0 0 0 2px var(--p5-card), 0 0 0 3px var(--p5-red); }
.md-step.invite { color: var(--p5-red); }
.md-step.invite .md-step-idx { background: var(--p5-red); color: #fff; animation: mdStepInvite 1.5s ease-out infinite; }
.md-step.invite .md-step-lb { color: var(--p5-red); font-weight: 700; }
.md-step.invite .md-step-ji { opacity: 0.85; }
@keyframes mdStepInvite { 0%, 100% { box-shadow: 0 0 0 0 rgba(230,57,70,0.55); } 50% { box-shadow: 0 0 0 8px rgba(230,57,70,0); } }
.md-step-lb { font-family: var(--font-display); font-weight: 500; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.md-step-ji { font-size: 11px; color: var(--p5-red); opacity: 0; transition: opacity 0.15s; margin-left: 2px; letter-spacing: 0.05em; font-weight: 500; }
.md-step.on .md-step-ji, .md-step.done .md-step-ji { opacity: 0.85; }
.md-step-bar { width: 36px; height: 2px; background: var(--p5-input-bg); flex-shrink: 0; margin-left: 8px; transition: background 0.15s; }
.md-step.done .md-step-bar { background: var(--p5-red); }
.md-step.on .md-step-bar { background: linear-gradient(90deg, var(--p5-red) 50%, var(--p5-input-bg) 50%); }
.md-step:last-child .md-step-bar { display: none; }

/* Script-stage layout — 280px left + 1fr right */
.md-script-stage { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; overflow: hidden; }
@media (max-width: 980px) { .md-script-stage { grid-template-columns: 220px 1fr; } }

/* LEFT: acts-panel */
.md-acts-panel { border-right: 1px solid var(--p5-border); background: var(--p5-dark); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.md-framework { padding: 16px 14px; border-bottom: 1px solid var(--p5-border); flex-shrink: 0; }
.md-framework .ttl { font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: 0.12em; color: var(--p5-text); text-transform: uppercase; margin-bottom: 6px; }
.md-framework .sub { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.06em; color: var(--p5-muted); line-height: 1.4; }

.md-acts-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.md-acts-list::-webkit-scrollbar { width: 4px; }
.md-acts-list::-webkit-scrollbar-thumb { background: var(--p5-input-bg); }
.md-act-item { padding: 12px 14px; border-left: 3px solid transparent; cursor: pointer; transition: background 0.15s, border-left-color 0.15s; }
.md-act-item:hover:not(.locked) { background: var(--p5-card); }
.md-act-item.on { background: var(--p5-card); border-left-color: var(--p5-red); }
.md-act-item.done { border-left-color: var(--p5-red); }
.md-act-item.locked { opacity: 0.4; cursor: default; }
.md-act-item .n { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.12em; color: var(--p5-red); font-weight: 700; margin-bottom: 4px; }
.md-act-item.locked .n { color: var(--p5-muted); }
.md-act-item .ti { font-size: 13px; color: var(--p5-text); margin-bottom: 4px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-act-item.locked .ti { color: var(--p5-muted); }
.md-act-item p { font-size: 11px; color: var(--p5-muted); line-height: 1.4; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* DAG monitor — bottom-left of acts-panel */
.md-dag-monitor { flex-shrink: 0; border-top: 1px solid var(--p5-border); background: var(--p5-card); padding: 10px 12px; font-family: var(--font-display); display: none; }
.md-dag-monitor.active { display: block; }
.md-dag-mon-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.md-dag-mon-lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--p5-red); text-transform: uppercase; }
.md-dag-mon-timer { font-size: 11px; color: var(--p5-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.md-dag-mon-steps { display: flex; flex-direction: column; gap: 4px; }
.md-dag-mon-step { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--p5-muted); letter-spacing: 0.04em; }
.md-dag-mon-step .dot { width: 6px; height: 6px; background: var(--p5-border); flex-shrink: 0; }
.md-dag-mon-step[data-status="running"] { color: var(--p5-red); }
.md-dag-mon-step[data-status="running"] .dot { background: var(--p5-red); animation: mdDagPulse 1s infinite; }
.md-dag-mon-step[data-status="done"] { color: var(--p5-text-secondary); }
.md-dag-mon-step[data-status="done"] .dot { background: var(--p5-red); }
.md-dag-mon-step[data-status="failed"] { color: #ff6b6b; }
.md-dag-mon-step[data-status="failed"] .dot { background: #ff6b6b; }
.md-dag-mon-step .label { flex: 1; }
.md-dag-mon-step .timer { font-variant-numeric: tabular-nums; color: var(--p5-muted); }
@keyframes mdDagPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* RIGHT: script-main (scroll + composer stuck to bottom in flex flow) */
.md-script-main { display: flex; flex-direction: column; min-height: 0; background: var(--p5-dark); }
.md-script-scroll { flex: 1; overflow-y: auto; padding: 24px 36px 24px; scroll-behavior: smooth; }
.md-script-scroll::-webkit-scrollbar { width: 6px; }
.md-script-scroll::-webkit-scrollbar-thumb { background: var(--p5-input-bg); }
@media (max-width: 980px) { .md-script-scroll { padding: 20px 24px; } }

/* User message card — right-aligned with floating USER INPUT badge */
.md-script-scroll .msg-user { background: var(--p5-input-bg); border: 1px solid var(--p5-border); padding: 12px 16px; max-width: 620px; margin: 0 0 22px auto; position: relative; }
.md-script-scroll .msg-user::before { content: 'USER INPUT'; position: absolute; top: -9px; right: 10px; font-family: var(--font-display); font-size: 9px; letter-spacing: 0.12em; color: var(--p5-muted); padding: 2px 6px; background: var(--p5-dark); border: 1px solid var(--p5-border); }
.md-script-scroll .msg-user p { font-size: 13.5px; color: var(--p5-text); line-height: 1.6; margin: 0; }

/* Structured-block card — V4 two-tone (hd slightly lighter than bd) */
.md-script-scroll .sb-block { background: var(--p5-card); border: 1px solid var(--p5-border); margin-bottom: 16px; position: relative; overflow: hidden; max-width: 100%; }
.md-script-scroll .sb-block .hd { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--p5-input-bg); border-bottom: 1px solid var(--p5-border); flex-wrap: nowrap; }
.md-script-scroll .sb-block .hd .tag { font-family: var(--font-display); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #000; background: var(--p5-red); padding: 2px 7px; flex-shrink: 0; align-self: center; }
.md-script-scroll .sb-block .hd h3 { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: 0.06em; color: var(--p5-text); margin: 0; text-transform: uppercase; flex: 1 1 auto; min-width: 0; }
.md-script-scroll .sb-block .hd h3 em { font-size: 12px; color: var(--p5-red); font-weight: 700; font-style: normal; letter-spacing: 0.04em; margin-left: 6px; }
.md-script-scroll .sb-block .hd .dr { font-family: var(--font-display); font-size: 10px; letter-spacing: 0.06em; color: var(--p5-muted); text-transform: uppercase; margin-left: auto; }
.md-script-scroll .sb-block .bd { padding: 14px 18px; font-size: 13px; line-height: 1.75; color: var(--p5-text-secondary); }
.md-script-scroll .sb-block .bd p { margin: 0 0 10px; }
.md-script-scroll .sb-block .bd p:last-child { margin-bottom: 0; }
.md-script-scroll .sb-block .bd em { color: var(--p5-red); font-style: normal; font-weight: 600; background: rgba(230,57,70,0.08); padding: 1px 4px; }
.md-script-scroll .sb-block .bd strong { color: var(--p5-text); font-weight: 700; }
.md-script-scroll .sb-block .bd h3, .md-script-scroll .sb-block .bd h4 { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: 0.04em; color: var(--p5-text); margin: 12px 0 6px; text-transform: uppercase; }
.md-script-scroll .sb-block .bd ul, .md-script-scroll .sb-block .bd ol { margin: 4px 0 10px 18px; }
.md-script-scroll .sb-block .bd li { margin-bottom: 3px; }
[data-theme="light"] .md-script-scroll .sb-block .bd em { background: rgba(230,57,70,0.12); }

/* Char-card (nested in sb-block.bd) */
.md-script-scroll .char-card { border: 1px solid var(--p5-border); background: var(--p5-dark); padding: 12px 16px; margin-bottom: 12px; }
.md-script-scroll .char-card:last-child { margin-bottom: 0; }
.md-script-scroll .char-card .nm { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--p5-border); }
.md-script-scroll .char-card .nm h4 { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--p5-text); margin: 0; }
.md-script-scroll .char-card .nm .role { font-family: var(--font-display); font-size: 10px; color: var(--p5-red); letter-spacing: 0.08em; text-transform: uppercase; }
.md-script-scroll .char-card .nm .role.ant { color: #f5c518; }
.md-script-scroll .char-card .nm .role.sup { color: var(--p5-text-secondary); }
.md-script-scroll .char-card .nm .id { font-family: var(--font-display); font-size: 10px; color: var(--p5-muted); letter-spacing: 0.08em; margin-left: auto; }
.md-script-scroll .char-card .kv { display: flex; flex-direction: column; gap: 8px; }
.md-script-scroll .char-card .kv .row { display: grid; grid-template-columns: 50px 1fr; gap: 10px; font-size: 12px; line-height: 1.6; }
.md-script-scroll .char-card .kv .row .k { font-family: var(--font-display); font-size: 10px; color: var(--p5-red); letter-spacing: 0.08em; padding-top: 2px; font-weight: 600; }
.md-script-scroll .char-card .kv .row .v { color: var(--p5-text-secondary); }
.md-script-scroll .char-card .kv .row .v em { color: var(--p5-text); font-style: normal; font-weight: 700; }

/* Stream bubble (during SSE streaming) */
.md-script-scroll .md-stream-bubble { background: var(--p5-card); border: 1px dashed var(--p5-border); border-left: 3px solid var(--p5-red); padding: 14px 18px; margin: 0 auto 16px; max-width: 860px; font-size: 13px; line-height: 1.6; color: var(--p5-text); }
.md-stream-bubble .md-typing { display: inline-flex; align-items: center; gap: 4px; }
.md-stream-bubble .md-typing span { width: 6px; height: 6px; background: var(--p5-red); animation: mdTyping 1.2s infinite; }
.md-stream-bubble .md-typing span:nth-child(2) { animation-delay: 0.2s; }
.md-stream-bubble .md-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mdTyping { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* Actions card (inline confirm/revise buttons at end of scroll) */
.md-script-scroll .md-actions-card { max-width: 860px; margin: 0 auto 16px; display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 0; justify-content: center; }
.md-script-scroll .md-actions-card button { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.md-script-scroll .md-actions-card button:hover { background: var(--p5-input-bg); color: var(--p5-text); border-color: var(--p5-text-secondary); }
.md-script-scroll .md-actions-card button.primary { background: var(--p5-red); color: #000; border-color: var(--p5-red); }
.md-script-scroll .md-actions-card button.primary:hover { background: #ff8080; color: #fff; }

/* Composer — matte frame stuck to bottom in flex flow (no leak below, tight bottom gap) */
.md-composer { flex-shrink: 0; margin: 0 36px 8px; background: var(--p5-input-bg); border: 1px solid var(--p5-red); padding: 2px; }
@media (max-width: 980px) { .md-composer { margin: 0 24px 6px; } }
.md-composer-inner { background: var(--p5-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.md-composer textarea { width: 100%; background: transparent; border: 0; color: var(--p5-text); padding: 0; font-size: 13.5px; line-height: 1.55; resize: none; min-height: 48px; max-height: 140px; font-family: inherit; outline: none; }
.md-composer textarea::placeholder { color: var(--p5-muted); }
.md-composer-bar { display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid var(--p5-border); }
/* Mode select hidden — kept in DOM for JS, defaults to requirement */
.md-input-mode { display: none; }
.md-composer .md-hint { font-family: var(--font-display); font-size: 9.5px; color: var(--p5-text-secondary); letter-spacing: 0.08em; text-transform: uppercase; }
.md-send { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: var(--p5-red); color: #000; border: 0; font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: background 0.15s, color 0.15s; }
.md-send:hover:not(:disabled) { background: #ff8080; color: #fff; }
.md-send:disabled { background: var(--p5-border); color: var(--p5-muted); cursor: not-allowed; }
.md-send svg { width: 10px; height: 10px; }

/* ============================================================ */
/* MD Characters panel V2 — MD-specific tweaks on mva3-* shell   */
/* ============================================================ */

/* Card aspect lock (total card = 3:4) + flex-shrink:0 so overflow scrolls instead of squishing cards */
#md-char-list-scroll.mva3-rail .mva3-thumb { aspect-ratio: 3 / 4; display: flex; flex-direction: column; flex-shrink: 0; }
#md-char-list-scroll.mva3-rail .mva3-thumb .mva3-thumb-portrait { flex: 1; aspect-ratio: auto; }
/* Comic char rail — same E14 fix, added 2026-04-23 */
#comic-char-list-scroll.mva3-rail .mva3-thumb { aspect-ratio: 3 / 4; display: flex; flex-direction: column; flex-shrink: 0; }
#comic-char-list-scroll.mva3-rail .mva3-thumb .mva3-thumb-portrait { flex: 1; aspect-ratio: auto; }

/* Canvas content centering for MD (since we're outputting single-row portrait without MV's multi-row tree) */
#md-char-canvas { display: flex; flex-direction: column; align-items: center; padding: 20px 24px 40px; overflow-y: auto; background: var(--p5-surface); }
#md-char-canvas-head { align-self: stretch; max-width: 860px; margin: 0 auto 24px; }
#md-char-portrait-col, #md-char-topo-col { align-self: center; }

/* R1 tree row for MD — center, 180px fixed */
#md-char-portrait-col .mva3-tree-row.r1 { display: flex; justify-content: center; }
#md-char-portrait-col .mva3-tree-node { width: 180px; }

/* Comic char canvas — same centering + 180px node width (mirror of MD rules above, added 2026-04-23)
   Without these id-scoped rules the R1 row is only 180px wide + aligned left in a wider col,
   so the vertical connector below r1::after doesn't line up with r2's horizontal center. */
#comic-char-canvas { display: flex; flex-direction: column; align-items: center; padding: 20px 24px 40px; overflow-y: auto; background: var(--p5-surface); }
#comic-char-canvas-head { align-self: stretch; max-width: 860px; margin: 0 auto 24px; }
#comic-char-portrait-col, #comic-char-topo-col { align-self: center; }
#comic-char-portrait-col .mva3-tree-row.r1 { display: flex; justify-content: center; }
#comic-char-portrait-col .mva3-tree-node { width: 180px; }

/* 4-image picker under portrait (when batch has no selection yet) */
.mva3-node-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; width: 180px; }
.mva3-node-pick { aspect-ratio: 3 / 4; overflow: hidden; cursor: pointer; border: 1px solid var(--p5-border); transition: border-color 0.15s, transform 0.15s; }
.mva3-node-pick:hover { border-color: var(--p5-red); transform: translateY(-1px); }
.mva3-node-pick img { width: 100%; height: 100%; object-fit: cover; }
.mva3-node-pick-hint { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-family: var(--font-display); font-size: 9px; letter-spacing: 0.1em; color: var(--p5-red); background: rgba(0,0,0,0.7); padding: 3px 0; text-transform: uppercase; pointer-events: none; }

/* Single action button (Generate / Regenerate) under portrait node */
.mva3-node-action { margin-top: 10px; padding: 6px 14px; background: transparent; border: 1px solid var(--p5-border); color: var(--p5-text-secondary); font-family: var(--font-display); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; transition: all 0.15s; display: block; width: 100%; }
.mva3-node-action:hover:not(:disabled) { background: var(--p5-red); color: #000; border-color: var(--p5-red); }
.mva3-node-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* Label left group: P button + name inline (keeps space-between for sub on right) */
.mva3-node-label .mva3-node-label-left { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.mva3-node-label .mva3-node-label-left > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Compact P button variant for label-inline context */
.mva3-node-label .md-char-topo-btn { padding: 1px 6px; font-size: 10px; line-height: 1.2; min-width: 20px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   Quick Generate — Music Module (suno_music)
   Borrows .song-ws-* for param panel; adds .dt-music-progress + .gmc-* for result card
   ═══════════════════════════════════════════════════════════════ */

/* Param panel container (wraps song-ws-field rows) */
.dt-music-params { display: flex; flex-direction: column; gap: 10px; }

/* Inline progress (shown while LLM+Suno submit is in flight) */
.dt-music-progress {
  margin-top: 12px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
}
.dt-music-progress-bar {
  height: 4px;
  background: var(--p5-dark);
  overflow: hidden;
  position: relative;
}
.dt-music-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--p5-red-gradient, var(--p5-red));
  transition: width .35s ease-out;
}
.dt-music-progress-text {
  font-size: 11px;
  color: var(--p5-text-secondary);
  letter-spacing: 0.3px;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
}

/* Music result — one card per track (见 _dtRenderMusicTrackCard) */
.gen-music-card { display: flex; flex-direction: column; }
.gen-music-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }

/* Title row: 标题 + 时长同行，title 单行省略 */
.gmc-title-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.gmc-title {
  font-size: 13px; font-weight: 600;
  color: var(--p5-text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1; min-width: 0;
}
.gmc-styles {
  display: flex; flex-wrap: wrap; gap: 3px;
}
.gmc-chip {
  font-size: 9px;
  padding: 1px 6px;
  background: var(--p5-input-bg);
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  letter-spacing: 0.2px;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  line-height: 1.4;
}

/* Cover — 5:3 比例（比原 1:1 矮约 40%）+ 渐变打底 */
.gmc-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(135deg, var(--p5-dark), var(--p5-card));
}
.gmc-cover img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  transition: transform .2s;
}
.gmc-cover:hover img { transform: scale(1.03); }

/* Track index badge (#1 / #2) — top-right corner */
.gmc-track-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 10px;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
  z-index: 3;
}

/* Waveform — 24 bars bottom overlay (learned from .song-my-wave) */
.gmc-wave {
  position: absolute;
  left: 0; right: 0;
  bottom: 4px;
  display: flex;
  gap: 2px;
  padding: 0 10px;
  align-items: flex-end;
  height: 34px;
  pointer-events: none;
  z-index: 2;
}
.gmc-wave span {
  flex: 1;
  background: rgba(255, 255, 255, 0.55);
  transition: background 0.2s;
  transform-origin: bottom;
  animation: gmc-wave-idle 2.4s ease-in-out infinite;
}
.gmc-wave span:nth-child(2n) { animation-delay: 0.15s; }
.gmc-wave span:nth-child(3n) { animation-delay: 0.3s; }
.gmc-wave span:nth-child(4n) { animation-delay: 0.45s; }
.gmc-wave span:nth-child(5n) { animation-delay: 0.6s; }
.gmc-wave span:nth-child(7n) { animation-delay: 0.9s; }

.gmc-cover:hover .gmc-wave span {
  background: var(--p5-red);
  animation-name: gmc-wave-hover;
  animation-duration: 1.4s;
}
.gen-music-card.playing .gmc-wave span {
  background: var(--p5-red);
  animation-name: gmc-wave-pulse;
  animation-duration: 0.9s;
}

@keyframes gmc-wave-idle {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.55); }
}
@keyframes gmc-wave-hover {
  0%, 100% { transform: scaleY(0.9); }
  50%      { transform: scaleY(1.15); }
}
@keyframes gmc-wave-pulse {
  0%, 100% { transform: scaleY(0.7); }
  50%      { transform: scaleY(1.2); }
}

/* Duration progress bar — thin line at bottom of cover */
.gmc-progress {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 3;
  pointer-events: none;
}
.gmc-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--p5-red);
  transition: width 0.15s linear;
}

/* Play / Pause button — 常驻可见；playing 态红色脉冲 */
.gmc-play-btn {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(230, 57, 70, 0.85);
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 1;
  transition: background .15s, box-shadow .15s;
  border-radius: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  z-index: 2;
}
.gmc-cover:hover .gmc-play-btn { background: var(--p5-red); box-shadow: 0 3px 10px rgba(230,57,70,0.5); }
.gmc-play-btn.playing { background: var(--p5-red); }
/* Preserve translate on :active (E3 rule) */
.gmc-play-btn:active { transform: translate(-50%, -50%) !important; }

/* Meta row: duration + download (bottom of card info) */
.gmc-meta-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.gmc-duration {
  font-size: 12px;
  font-family: 'Oswald', sans-serif;
  color: var(--p5-text-secondary);
  letter-spacing: 0.8px;
}
.gmc-dl-btn {
  background: transparent;
  border: 1px solid var(--p5-border);
  color: var(--p5-text-secondary);
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  transition: border-color .15s, color .15s;
  border-radius: 0;
}
.gmc-dl-btn:hover { border-color: var(--p5-red); color: var(--p5-red); }

/* Music card info block uses .card-info shared styles — but needs gap for our stacked rows */
.gen-music-card .card-info.gen-music-info {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
}

/* History tabs — adopt .mva3-tabs (Assets-style filter tabs) */
.dt-gen-filter.mva3-tabs { flex-wrap: wrap; }
.dt-gen-filter .mva3-tab { padding: 6px 14px; font-size: 11px; }

/* Quick Generate Music 参数区：.dt-gen-input-panel select 已有红色 chevron，
   隐藏 .song-ws-field-v::after 的灰色 chevron 避免重叠 */
.dt-gen-input-panel .song-ws-field-v::after { display: none; }

/* ═══════════════════════════════════════════════════════════════
   Model dropdown — custom (icon + label) to replace native <select>
   借鉴 .dt-lang-btn / .dt-lang-menu 模式
   ═══════════════════════════════════════════════════════════════ */
.dt-model-dropdown { position: relative; width: 100%; }

.dt-model-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--p5-dark);
  border: 1px solid var(--p5-border);
  color: var(--p5-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s ease;
  border-radius: 0;
  text-align: left;
}
.dt-model-btn:hover { border-color: var(--p5-red); }
.dt-model-icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--p5-red);
}
.dt-model-icon svg { display: block; }
.dt-model-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-model-caret {
  flex-shrink: 0;
  color: var(--p5-red);
  transition: transform .15s ease;
}
.dt-model-dropdown:has(.dt-model-menu:not([hidden])) .dt-model-caret { transform: rotate(180deg); }

.dt-model-menu {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--p5-surface);
  border: 1px solid var(--p5-border);
  border-top: 2px solid var(--p5-red);
  z-index: 300;
  padding: 4px 0;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  max-height: 360px;
  overflow-y: auto;
}
.dt-model-menu[hidden] { display: none !important; }

.dt-model-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--p5-text);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.dt-model-item-icon {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--p5-text-secondary);
  transition: color .12s ease;
}
.dt-model-item-icon svg { display: block; }
.dt-model-item-label { flex: 1; min-width: 0; }

.dt-model-item:hover { background: rgba(230,57,70,0.12); color: var(--p5-red); }
.dt-model-item:hover .dt-model-item-icon { color: var(--p5-red); }
.dt-model-item.active {
  background: var(--p5-red);
  color: #000;
  font-weight: 700;
}
.dt-model-item.active .dt-model-item-icon { color: #000; }

/* ================================================================
   DISCOVER — COMIC CARDS + PREVIEW MODAL
   ================================================================ */

/* Comic card override — single-image cover with hover CTA */
.discover-card.comic-card { cursor: pointer; }
.discover-card.comic-card .comic-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--p5-card);
}
.discover-card.comic-card .comic-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .35s ease;
}
.discover-card.comic-card .comic-card-media img.loaded { opacity: 1; }
.discover-card.comic-card .comic-card-cover-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: repeating-linear-gradient(-45deg, var(--p5-card) 0 10px, var(--p5-dark) 10px 20px);
  color: var(--p5-muted);
}
.discover-card.comic-card .comic-card-panels {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  z-index: 2;
}

/* Hover preview CTA — PC only */
.discover-card.comic-card .comic-card-preview-btn {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  padding: 10px 20px;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
  z-index: 3;
  white-space: nowrap;
}
.discover-card.comic-card .comic-card-preview-btn:hover { color: var(--p5-red); border-color: var(--p5-red); }
.discover-card.comic-card:hover .comic-card-preview-btn {
  opacity: 1;
  transform: scale(1);
}
.discover-card.comic-card:hover .comic-card-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2;
}

.source-badge.source-comic { color: var(--p5-red-light); border-color: rgba(230,57,70,0.4); }

/* PC preview modal */
.comic-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,0.78);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s ease;
}
.comic-preview-modal.active { opacity: 1; }
.comic-preview-modal-body {
  position: relative;
  width: min(1100px, 94vw);
  height: min(92vh, 960px);
  background: var(--p5-dark);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--p5-border);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.comic-preview-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--p5-card);
  border-bottom: 1px solid var(--p5-border);
  flex-shrink: 0;
}
.comic-preview-modal-header .h5-back-btn { display: none; }
.comic-preview-modal-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--p5-text);
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comic-preview-modal-create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--p5-red);
  color: #fff;
  border: none;
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background .2s ease;
}
.comic-preview-modal-create:hover { background: var(--p5-red-light, #ff6b6b); }
.comic-preview-modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--p5-muted);
  border: 1px solid var(--p5-border);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.comic-preview-modal-close:hover { color: var(--p5-red); border-color: var(--p5-red); }

/* Like button in preview modal header */
.comic-preview-modal-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  color: var(--p5-text);
  border: 1px solid var(--p5-border);
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
  font-variant-numeric: tabular-nums;
}
.comic-preview-modal-like:hover {
  color: var(--p5-red);
  border-color: var(--p5-red);
}
.comic-preview-modal-like.liked {
  color: var(--p5-red);
  border-color: var(--p5-red);
  background: rgba(230,57,70,0.08);
}
.comic-preview-modal-like svg {
  transition: fill .2s ease, stroke .2s ease;
}
.comic-preview-like-count { min-width: 14px; text-align: left; }

/* Author block at TOP of TOC — PC only. Hidden on H5 (media query below). */
.cp-author-toc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--p5-border);
  margin-bottom: 6px;
  color: var(--p5-text);
  font-size: 13px;
  font-weight: 600;
}
.cp-author-toc-avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--p5-red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.cp-author-toc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cp-author-toc-avatar.cp-author-toc-avatar-letter {
  background: linear-gradient(135deg, #e63946, #ff6b6b);
}
.cp-author-toc-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* Author overlay inside reader — bottom-left floating badge.
   Hidden on PC by default (TOC block takes over). Shown on H5 via media query. */
.cp-author-overlay {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  max-width: 60%;
}
.cp-author-avatar {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--p5-red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.cp-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cp-author-avatar.cp-author-avatar-letter {
  background: linear-gradient(135deg, #e63946, #ff6b6b);
}
.cp-author-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .cp-author-overlay {
  background: rgba(255,255,255,0.92);
  border-color: var(--p5-border);
  color: var(--p5-text);
}

/* Native preview body — left TOC + right book reader (no iframe, no scrollbar) */
.cp-content {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--p5-dark);
  overflow: hidden;
}
.cp-toc {
  width: 220px;
  flex-shrink: 0;
  padding: 18px 0;
  overflow-y: auto;
  border-right: 1px solid var(--p5-border);
  background: var(--p5-card);
}
.cp-toc::-webkit-scrollbar { width: 6px; }
.cp-toc::-webkit-scrollbar-thumb { background: var(--p5-border); }
.cp-toc-item {
  display: block;
  padding: 12px 18px;
  color: var(--p5-muted);
  font-size: 13px;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  cursor: pointer;
}
.cp-toc-item:hover { color: var(--p5-text); background: rgba(230,57,70,0.06); }
.cp-toc-item.active {
  color: var(--p5-red);
  border-left-color: var(--p5-red);
  background: rgba(230,57,70,0.08);
}
.cp-toc-act-num {
  display: block;
  font-size: 10px;
  color: var(--p5-muted-2, #555);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.cp-toc-item.active .cp-toc-act-num { color: var(--p5-red); }
.cp-toc-title {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cp-reader {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.cp-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--p5-border);
  border-top-color: var(--p5-red);
  animation: cpSpin .8s linear infinite;
}
@keyframes cpSpin { to { transform: rotate(360deg); } }
.cp-empty, .cp-notfound {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--p5-muted);
  font-size: 14px;
  padding: 40px 24px;
  text-align: center;
}
.cp-book {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px 16px;
}
.cp-nav {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 1px solid var(--p5-border);
  background: var(--p5-card);
  color: var(--p5-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, border-color .2s, color .2s, opacity .2s;
}
.cp-nav:hover:not(:disabled) {
  background: var(--p5-red);
  border-color: var(--p5-red);
  color: #fff;
}
.cp-nav:disabled {
  opacity: .28;
  cursor: not-allowed;
}
.cp-stage {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.cp-act-label {
  font-size: 11px;
  color: var(--p5-red);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-img {
  max-width: 100%;
  max-height: calc(100% - 60px);
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  background: #0a0a0a;
  display: block;
}
.cp-counter {
  font-size: 12px;
  color: var(--p5-muted);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
/* Lightbox */
.cp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.cp-lightbox[hidden] { display: none; }
.cp-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
}
.cp-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  font-size: 28px;
  color: #fff;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-lightbox-close:hover { background: var(--p5-red); border-color: var(--p5-red); }

/* H5 secondary page (slide-in) for comic preview */
body.h5-comic-pv-open { overflow: hidden !important; }
body.h5-comic-pv-open .dt-sidebar,
body.h5-comic-pv-open .dt-header,
body.h5-comic-pv-open .h5-bottom-nav { display: none !important; }
body.h5-comic-pv-open #comic-preview-modal {
  display: block !important;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--p5-card);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.32,.72,.37,1.01);
  opacity: 1;
  padding: 0;
}
body.h5-comic-pv-visible #comic-preview-modal { transform: translateX(0) !important; }
body.h5-comic-pv-open #comic-preview-modal .comic-preview-modal-body {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  border: none;
  box-shadow: none;
}

@media (max-width: 768px) {
  .comic-preview-modal-header .h5-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--p5-text);
    border: none;
    cursor: pointer;
  }
  .comic-preview-modal-close { display: none; }
  .comic-preview-modal-create {
    padding: 6px 10px;
    font-size: 11px;
  }
  .comic-preview-modal-create span { display: none; }
  .comic-preview-modal-header { padding: 10px 12px; gap: 6px; }
  .comic-preview-modal-like {
    padding: 6px 8px;
    font-size: 11px;
  }
  /* H5: hide TOC author block (it becomes a chip in horizontal scroll on mobile); show the floating overlay on image instead */
  .cp-author-toc { display: none !important; }
  .cp-author-overlay {
    display: inline-flex;
    left: 10px;
    bottom: 10px;
    padding: 4px 10px 4px 4px;
    font-size: 12px;
  }
  .cp-author-avatar { width: 24px; height: 24px; font-size: 11px; }
  .discover-card.comic-card .comic-card-preview-btn { display: none; }

  /* Native preview — H5: TOC collapses to horizontal chips above reader */
  .cp-content { flex-direction: column; }
  .cp-toc {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--p5-border);
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }
  .cp-toc-item {
    display: inline-flex;
    flex-direction: column;
    padding: 6px 12px;
    border-left: none;
    border-bottom: 2px solid transparent;
    flex-shrink: 0;
  }
  .cp-toc-item.active {
    border-left: none;
    border-bottom-color: var(--p5-red);
    background: transparent;
  }
  .cp-toc-act-num { font-size: 11px; letter-spacing: 1px; margin-bottom: 0; }
  /* H5 TOC: hide act name, show only "ACT N" chip per user spec 2026-04-23 */
  .cp-toc-title { display: none; }
  .cp-book { gap: 8px; padding: 12px 8px; }
  .cp-nav { width: 40px; height: 40px; }
  .cp-nav svg { width: 22px; height: 22px; }
  .cp-act-label { font-size: 10px; letter-spacing: 1.5px; }
  .cp-counter { font-size: 11px; }
}

