/* ══════════════════════════════════════════════════════════════
   🍊 橘子戏曲家 — 三主题设计系统 · 五妹出品
   主题切换: body.theme-yuanqu | body.theme-globe | body.theme-sunshine
   默认: 元曲·戏台
   ══════════════════════════════════════════════════════════════ */

/* ===== FONT IMPORTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700&display=swap');

/* ===== SVG ICON LIBRARY (all emoji replaced by line-style SVG) ===== */
:root {
  --icon-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M12 5l7 7-7 7'/%3E%3C/svg%3E");
  --icon-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E");
  --icon-save: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z'/%3E%3Cpolyline points='17 21 17 13 7 13 7 21'/%3E%3Cpolyline points='7 3 7 8 15 8'/%3E%3C/svg%3E");
  --icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1'/%3E%3C/svg%3E");
  --icon-book: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5A2.5 2.5 0 016.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z'/%3E%3C/svg%3E");
  --icon-book-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 014 4v14a3 3 0 00-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 00-4 4v14a3 3 0 013-3h7z'/%3E%3C/svg%3E");
  --icon-edit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7'/%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z'/%3E%3C/svg%3E");
  --icon-script: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cpolyline points='10 9 9 9 8 9'/%3E%3C/svg%3E");
  --icon-list: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E");
  --icon-lightning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2'/%3E%3C/svg%3E");
  --icon-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='currentColor' stroke='none'%3E%3Cpolygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/%3E%3C/svg%3E");
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  --icon-settings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06A1.65 1.65 0 0019.4 9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z'/%3E%3C/svg%3E");
  --icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");
  --icon-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  --icon-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z'/%3E%3Cpath d='M19 10v2a7 7 0 01-14 0v-2'/%3E%3Cline x1='12' y1='19' x2='12' y2='23'/%3E%3Cline x1='8' y1='23' x2='16' y2='23'/%3E%3C/svg%3E");
  --icon-volume: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='11 5 6 9 2 9 2 15 6 15 11 19 11 5'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
  --icon-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
  --icon-eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  --icon-rotate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='23 4 23 10 17 10'/%3E%3Cpath d='M20.49 15a9 9 0 11-2.12-9.36L23 10'/%3E%3C/svg%3E");
  --icon-map: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E");
  --icon-layers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 2 22 8.5 12 15 2 8.5 12 2'/%3E%3Cpolyline points='2 15.5 12 22 22 15.5'/%3E%3C/svg%3E");
  --icon-users: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 00-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 010 7.75'/%3E%3C/svg%3E");
  --icon-feather: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.24 12.24a6 6 0 00-8.49-8.49L5 10.5V19h8.5z'/%3E%3Cline x1='16' y1='8' x2='2' y2='22'/%3E%3Cline x1='17.5' y1='15' x2='9' y2='15'/%3E%3C/svg%3E");
  --icon-clipboard: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2'/%3E%3Crect x='8' y='2' width='8' height='4' rx='1' ry='1'/%3E%3C/svg%3E");
  --icon-message: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z'/%3E%3C/svg%3E");
  --icon-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z'/%3E%3C/svg%3E");
  --icon-shield: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
  --icon-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='currentColor' stroke='none'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E");
  --icon-theater: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12V8H4v4'/%3E%3Cpath d='M2 12h20'/%3E%3Cpath d='M4 16h16'/%3E%3Cpath d='M6 20h12'/%3E%3C/svg%3E");
}

/* icon base class */
.icon { display: inline-block; width: 18px; height: 18px; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* icon utility: apply SVG as mask (inherits color) */
.icon-mask {
  display: inline-block; width: 18px; height: 18px; vertical-align: middle; flex-shrink: 0;
  background: currentColor; -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
}

/* ===== COMMON VARIABLES ===== */
:root {
  /* spacing */
  --space-unit: 8px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --gap: var(--space-md);

  /* radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-round: 50%;
  --radius: var(--radius-md);

  /* transitions */
  --transition-fast: 150ms ease-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* easing */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* shadows (overridden per theme) */
  --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-elevated: 0 8px 30px rgba(0,0,0,0.1);
  --shadow-pressed: 0 2px 6px rgba(0,0,0,0.08);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  font-size: var(--text-base, 16px);
  font-weight: var(--font-weight-medium, 500);
  line-height: var(--line-height-normal, 1.65);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background var(--transition-slow), color var(--transition-slow);
}

body * {
  transition: background var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), box-shadow var(--transition-fast);
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 750;
  line-height: var(--line-height-tight, 1.3);
  letter-spacing: -0.01em;
}
h1 { letter-spacing: -0.02em; }

::selection {
  background: var(--accent);
  color: var(--color-text-on-primary, #fff);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════ */

/* ===== TOPBAR ===== */
#topbar {
  display: flex; align-items: center; gap: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative; z-index: 10;
}

.logo {
  font-family: var(--font-display);
  font-size: var(--text-lg, 18px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--accent);
  letter-spacing: 0.02em;
}

.tb-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm, 14px);
  font-family: var(--font-ui);
}

.tb-btn:hover {
  color: var(--text);
  background: var(--card-bg);
}

.tb-btn.active {
  color: var(--accent2);
  border-color: var(--accent2);
  background: var(--color-primary-light, rgba(15,171,181,.1));
}

/* theme swapper */
#theme-swapper {
  display: flex; gap: 4px; margin-left: auto; align-items: center;
}
.theme-dot {
  width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all var(--transition-fast);
  flex-shrink: 0;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--color-primary-light); }
.theme-dot.yuanqu  { background: #E8703A; }
.theme-dot.globe   { background: #C9A96E; }
.theme-dot.sunshine{ background: #FFB482; }

.topbar-status {
  margin-left: 0; font-size: var(--text-xs, 13px);
  color: var(--text-muted); white-space: nowrap;
}

/* ===== TAB PAGES ===== */
.tab-page {
  display: flex; gap: var(--gap); padding: var(--gap); flex: 1; overflow: hidden;
}
#main-app { display: flex; }

/* ===== STATUS DOT (CSS LED) ===== */
#status-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.status-led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-led.ok { background: #4caf50; box-shadow: 0 0 6px rgba(76,175,80,0.5); }
.status-led.busy { background: #f5a623; box-shadow: 0 0 6px rgba(245,166,35,0.5); animation: pulse 1.5s infinite; }
.status-led.error { background: #e94560; box-shadow: 0 0 6px rgba(233,69,96,0.5); }

/* icon button polish */
#script-tools button .icon-mask, .tool-btn .icon-mask { opacity: 0.65; margin-right: 2px; }
#script-tools button:hover .icon-mask, .tool-btn:hover .icon-mask { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   LEFT PANEL: CONFIG
   ══════════════════════════════════════════════════════════════ */

#panel-config {
  width: 290px; flex-shrink: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-sm);
}

/* ===== STAGE HERO (center panel — theatrical marquee) ===== */
#stage-hero {
  position: sticky; top: 0; z-index: 50; background: var(--bg);
  margin: 0; padding: var(--space-lg) var(--space-md);
  width: 100%;
}
/* spotlight — dramatic radial glow */
#stage-hero .stage-spotlight {
  position: absolute; top: -60%; left: 50%; transform: translateX(-50%);
  width: 100%; height: 200%;
  background: radial-gradient(ellipse at 50% 40%, var(--color-primary-light) 0%, transparent 70%);
  pointer-events: none; opacity: 0.5; z-index: 0;
}

/* tagline */
.hero-tagline {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--text); margin-bottom: 4px; position: relative; z-index: 1;
  letter-spacing: 0.04em;
}
.hero-subtitle {
  font-size: 14px; color: var(--text-muted); margin-bottom: var(--space-lg);
  position: relative; z-index: 1; font-family: var(--font-ui);
}

/* input row */
#stage-hero #hero-input {
  display: flex; gap: var(--space-sm); align-items: center;
  background: var(--bg); border-radius: var(--radius-lg);
  padding: 6px 6px 6px 18px; border: 2px solid var(--border);
  position: relative; z-index: 1; width: 100%;
  transition: all var(--transition-base);
}
#stage-hero #hero-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 8px var(--color-primary-light), 0 0 50px rgba(0,0,0,0.06);
}
.hero-input-icon { font-size: 20px; flex-shrink: 0; opacity: 0.7; }
#stage-hero #hero-prompt {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 1.1rem; padding: 10px 4px; outline: none;
  font-family: var(--font-display); text-align: left;
  font-weight: 500;
}
#stage-hero #hero-prompt::placeholder { color: var(--text-muted); opacity: 0.55; font-style: italic; }

/* button — bigger, text label */
#stage-hero #btn-hero-go {
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  border: none; border-radius: var(--radius-md); padding: 10px 22px;
  font-size: 15px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  font-family: var(--font-ui); white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); transition: all var(--transition-fast);
}
#stage-hero #btn-hero-go:hover {
  transform: translateY(-1px); box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  filter: brightness(1.08);
}
#stage-hero #btn-hero-go:active { transform: translateY(0); }

#stage-hero #hero-hint {
  text-align: center; font-size: 12px; color: var(--text-muted);
  margin-top: 12px; position: relative; z-index: 1;
  font-family: var(--font-ui); min-height: 18px;
}

/* sidebar keyword input: visually secondary */
.cfg-core-row #cfg-keywords {
  font-size: 12px; opacity: 0.7;
}
.cfg-core-row #cfg-keywords:focus { opacity: 1; }

/* ===== SIDEBAR PRESETS (vertical) ===== */
#presets-section {
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px 10px;
}
#presets-section h3 {
  font-size: 12px; margin-bottom: 8px; color: var(--text);
  display: flex; justify-content: space-between; align-items: center;
}
#presets-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 360px; overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════════
   CHAT PANEL (conversational creation interface)
   ══════════════════════════════════════════════════════════════ */

#chat-panel {
  display: flex; flex-direction: column; min-height: 35vh;
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
#chat-header {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted);
  flex-shrink: 0;
}
#chat-header > span:first-child { flex: 1; font-weight: 600; color: var(--text); font-family: var(--font-display); }
#grill-toggle {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 11px; color: var(--text-muted);
  padding: 3px 8px; border: 1px solid var(--border);
  border-radius: 12px; transition: all var(--transition-fast); user-select: none;
}
#grill-toggle:has(input:checked) {
  background: var(--color-primary-light); border-color: var(--accent2); color: var(--accent2);
}
#grill-toggle input { display: none; }
#btn-voice {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; padding: 4px 8px; font-size: 14px;
  transition: all var(--transition-fast);
}
#btn-voice:hover { border-color: var(--accent2); color: var(--accent2); }
#btn-voice.recording {
  background: #e94560; border-color: #e94560; color: #fff;
  animation: pulse 1.2s infinite;
}
#voice-status { font-size: 11px; color: var(--text-muted); min-width: 60px; }

/* messages area */
#chat-messages {
  flex: 1; overflow-y: auto; padding: var(--space-md);
  display: flex; flex-direction: column; gap: var(--space-md);
  scroll-behavior: smooth;
}
/* fade-out hint at bottom */
#chat-messages::after {
  content: ''; position: sticky; bottom: 0; left: 0; right: 0; height: 30px;
  background: linear-gradient(transparent, var(--panel-bg));
  pointer-events: none; flex-shrink: 0;
}

/* chat message rows */
.chat-msg { display: flex; gap: 8px; max-width: 85%; animation: slideUp .3s var(--ease-smooth); }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.assistant { align-self: flex-start; }
.chat-msg .chat-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.chat-msg.assistant .chat-avatar { background: var(--color-primary-light); }
.chat-msg.user .chat-avatar { background: var(--accent); color: #fff; }

/* bubbles */
.chat-bubble {
  padding: 10px 14px; border-radius: var(--radius-md);
  font-size: var(--text-sm, 14px); line-height: 1.7;
  word-break: break-word;
}
.chat-msg.assistant .chat-bubble {
  background: var(--bg); border-left: 3px solid var(--accent2);
  border-radius: 4px var(--radius-md) var(--radius-md) 4px;
}
.chat-msg.user .chat-bubble {
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  border-radius: var(--radius-md) 4px 4px var(--radius-md);
}
.chat-bubble small { opacity: 0.7; }
.chat-bubble em { font-style: italic; border-bottom: 1px dashed var(--accent2); cursor: pointer; }

/* timestamps */
.chat-time {
  font-size: 10px; color: var(--text-muted); margin-top: 2px;
  opacity: 0; transition: opacity .2s;
}
.chat-msg:hover .chat-time { opacity: 1; }

/* typing indicator */
.chat-typing {
  align-self: flex-start; display: flex; gap: 3px; padding: 8px 12px;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .16s; }
.chat-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* streaming cursor */
.streaming-cursor::after {
  content: '|'; animation: blink 1s infinite; color: var(--accent); font-weight: 700;
}
@keyframes blink { 0%,50%{opacity:1} 51%,100%{opacity:0} }

/* input row */
#chat-input-row {
  display: flex; gap: var(--space-sm); align-items: flex-end;
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
#chat-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
#chat-input {
  flex: 1; resize: none; border: none; background: transparent;
  color: var(--text); font-size: var(--text-sm, 14px);
  font-family: var(--font-body); line-height: 1.6;
  padding: 6px 0; outline: none; max-height: 120px;
}
#chat-input::placeholder { color: var(--text-muted); opacity: 0.5; }
#btn-chat-send {
  width: 36px; height: 36px; border: none; border-radius: var(--radius-round);
  background: var(--accent); color: #fff; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--ease-spring) .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
#btn-chat-send:hover { transform: scale(1.1); box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
#btn-chat-send:active { transform: scale(0.92); }
#btn-chat-send .icon-mask { width: 18px; height: 18px; }
#chat-hint { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 16px 8px; }

/* intent preview bar */
#intent-preview {
  padding: 6px 16px; display: flex; flex-wrap: wrap; gap: 4px;
  border-top: 1px solid var(--border); background: var(--bg);
  font-size: 11px; animation: slideUp .25s ease-out;
}
#intent-preview .intent-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 10px;
  background: var(--color-primary-light); color: var(--accent);
  font-weight: 500;
}
#intent-preview .intent-chip .intent-x {
  cursor: pointer; opacity: 0.5; font-weight: 700; margin-left: 2px;
}
#intent-preview .intent-chip .intent-x:hover { opacity: 1; }

/* file drop overlay */
#file-drop-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-bg-overlay, rgba(0,0,0,.5));
  backdrop-filter: blur(6px); border-radius: inherit;
  font-size: 18px; color: #fff; flex-direction: column; gap: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#file-drop-overlay.show { opacity: 1; pointer-events: auto; }
#file-drop-overlay .icon-mask { width: 48px; height: 48px; opacity: 0.8; }

/* TTS progress bar */
#tts-progress {
  height: 3px; background: var(--border); flex-shrink: 0;
}
#tts-progress-bar {
  height: 100%; background: var(--accent);
  transition: width .3s linear;
}

/* ===== CONFIG PANEL (compact) ===== */
.cfg-core-row { display: flex; gap: var(--space-sm); align-items: center; margin-bottom: 6px; }
.cfg-core-row #cfg-keywords { flex: 1; }
.cfg-dur-inline {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 11px; color: var(--text-muted);
}
.cfg-dur-inline #cfg-dur-val { font-size: 18px; font-weight: 700; color: var(--accent); font-family: var(--font-display); }
.cfg-dur-inline input[type=range] { width: 60px; }

/* collapsible chip-group cards */
.cfg-fold {
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px 12px;
  transition: border-color var(--transition-fast);
}
.cfg-fold:hover { border-color: var(--border-strong, var(--accent2)); }
.cfg-fold summary {
  font-size: 12px; color: var(--text); cursor: pointer;
  padding: 2px 0; font-family: var(--font-ui);
  display: flex; align-items: center; gap: 6px;
}
.cfg-fold summary small { color: var(--text-muted); font-weight: 400; }
.cfg-fold summary::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: 0.5; flex-shrink: 0;
}
.cfg-fold:hover summary::before { opacity: 1; }
.cfg-fold[open] summary::before { background: var(--accent2); }
.cfg-fold .multi-chip-row { margin-top: 8px; padding-bottom: 4px; }
.cfg-fold input[type=text] {
  width: 100%; padding: 4px 8px; font-size: 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}

/* generate button prominence */
.btn-generate-main {
  width: 100%; padding: 13px 20px; font-size: 15px; font-weight: 600;
  margin-top: var(--space-sm); letter-spacing: 0.06em;
  animation: btnPulse 3s infinite ease-in-out;
}
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50%      { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* ===== THEME LABELS ===== */
.theme-labels { display: flex; gap: 4px; margin-left: 2px; }
.theme-labels small { font-size: 9px; color: var(--text-muted); width: 16px; text-align: center; }

/* ===== RIGHT PANEL ONBOARDING ===== */
.teach-onboard {
  display: flex; flex-direction: column; gap: var(--space-md);
  padding: var(--space-sm) 0;
}
.onboard-step {
  display: flex; gap: var(--space-md); align-items: flex-start;
  padding: var(--space-sm); border-radius: var(--radius-md);
  background: var(--bg); border: 1px solid transparent;
  transition: border-color var(--transition-fast);
}
.onboard-step:hover { border-color: var(--border); }
.onboard-step .gs-num {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-round);
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  font-family: var(--font-display);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.onboard-step strong { font-size: 13px; display: block; margin-bottom: 2px; }
.onboard-step div { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ===== REMOVE OLD SIDEBAR HERO ===== */
#panel-config > #hero-input { display: none; }

/* ===== INPUT MODE TABS ===== */
#input-mode-tabs { display: flex; gap: 2px; margin-bottom: var(--space-sm); }

.im-tab {
  flex: 1; font-size: 11px; padding: 5px 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  text-align: center; font-family: var(--font-ui);
}
.im-tab:hover { color: var(--text); background: var(--card-bg); }
.im-tab.active {
  color: var(--accent); border-color: var(--accent);
  background: var(--color-primary-light);
}

.imode-panel textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: var(--space-sm); border-radius: var(--radius-sm);
  font-size: var(--text-sm, 13px); resize: vertical; font-family: var(--font-body);
  line-height: var(--line-height-normal, 1.6);
}
.imode-panel textarea:focus { border-color: var(--accent2); outline: none; }

/* ===== FORM LABELS ===== */
#imode-form label, .imode-panel > label {
  font-size: 11px; color: var(--text-muted); display: block;
  margin: 8px 0 4px; font-weight: var(--font-weight-medium, 500);
  letter-spacing: 0.02em; text-transform: uppercase;
}
#imode-form label:first-child { margin-top: 0; }

/* ===== INPUTS & SELECTS ===== */
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: var(--text-sm, 13px); font-family: var(--font-body);
}
input[type=text]:focus, input[type=number]:focus, select:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ===== DURATION SLIDER ===== */
.cfg-row { margin: 8px 0; }
.cfg-row label { font-size: 12px; color: var(--text-muted); }
#cfg-dur-val { color: var(--accent); font-family: var(--font-display); }
#cfg-dur-desc { font-size: 10px; color: var(--color-warm, var(--accent3)); margin-top: 2px; min-height: 14px; }

/* ══════════════════════════════════════════════════════════════
   CHIPS — MODE / STYLE / TAG / KW
   ══════════════════════════════════════════════════════════════ */

/* mode chips */
#cfg-mode-group { display: flex; gap: var(--space-xs); }
.mode-chip {
  flex: 1; font-size: 12px; padding: 7px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; text-align: center;
  font-family: var(--font-ui); transition: all var(--transition-fast);
  color: var(--text-muted); background: var(--card-bg);
}
.mode-chip:hover { border-color: var(--accent2); color: var(--accent2); }
.mode-chip:has(input:checked) {
  background: color-mix(in srgb, var(--accent2) 48%, #000 52%);
  color: #fff; border-color: var(--accent2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.mode-chip input { display: none; }

/* style chips (2-col grid) */
#cfg-style-group { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
.style-chip {
  font-size: 11px; padding: 5px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; text-align: center;
  font-family: var(--font-ui); transition: all var(--transition-fast);
  color: var(--text-muted); background: var(--card-bg);
}
.style-chip:hover { border-color: var(--accent2); color: var(--accent2); }
.style-chip:has(input:checked) {
  background: color-mix(in srgb, var(--accent2) 48%, #000 52%);
  color: #fff; border-color: var(--accent2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.style-chip input { display: none; }

/* tag chips (pov/grade/scene) */
#cfg-pov-group, #cfg-grade-group { display: flex; flex-wrap: wrap; gap: 2px; }

.tag-chip {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 3px;
  margin: 2px; user-select: none;
  font-family: var(--font-ui); transition: all var(--transition-fast);
  color: var(--text-muted); background: var(--card-bg);
}
.tag-chip:hover { border-color: var(--accent2); color: var(--accent2); }
.tag-chip:has(input:checked) {
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  border-color: var(--accent);
}
.tag-chip input { display: none; }

/* multi-chip row (type group) */
.multi-chip-row { display: flex; flex-wrap: wrap; gap: 3px; }

/* keyword chips */
.quick-kw-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: 4px; }
.kw-chip {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-muted); cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-ui); transition: all var(--transition-fast);
}
.kw-chip:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--color-primary-light);
}

/* scene tags */
.scene-tags-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.scene-tag { font-size: 10px; padding: 2px 6px; }

/* ══════════════════════════════════════════════════════════════
   GLOBAL HAPTIC FEEDBACK
   ══════════════════════════════════════════════════════════════ */

button, .btn-primary, .btn-sm, .btn-xs,
.tb-btn, .im-tab, .tag-chip, .style-chip, .mode-chip, .kw-chip,
.preset-card, .tool-btn, .exp-tab, .identity-opt {
  -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled),
.btn-primary:active:not(:disabled),
.btn-sm:active:not(:disabled),
.btn-xs:active:not(:disabled),
.tb-btn:active, .im-tab:active, .tag-chip:active,
.style-chip:active, .mode-chip:active, .kw-chip:active,
.preset-card:active, .tool-btn:active, .exp-tab:active,
.identity-opt:active {
  transform: scale(0.96) !important;
  transition: transform 0.08s ease-out !important;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */

.btn-primary {
  padding: 10px 24px; border: none; border-radius: var(--radius-md);
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  font-size: var(--text-base, 14px); font-family: var(--font-ui);
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer; transition: all var(--ease-smooth) .25s;
  letter-spacing: 0.02em;
}
.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: var(--shadow-elevated);
}
.btn-primary:active { transform: translateY(1px); box-shadow: var(--shadow-pressed); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-xs  {
  padding: 2px 8px; font-size: 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-bg);
  color: var(--text); cursor: pointer; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
.btn-xs:hover { border-color: var(--accent2); color: var(--accent2); }

/* ══════════════════════════════════════════════════════════════
   PRESETS
   ══════════════════════════════════════════════════════════════ */

.preset-card {
  background: var(--panel-bg); border: 1px solid var(--border-strong, var(--border));
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius-md); padding: 10px 12px; cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.preset-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  transform: translateX(3px);
  box-shadow: var(--shadow-elevated);
}

.pc-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.pc-meta  { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; }

/* my presets */
#my-presets-section { margin-top: var(--space-sm); }
#my-presets-section h3 { font-size: 13px; margin-bottom: 6px; }
#my-presets-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.my-preset { position: relative; }
.preset-del {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0 4px;
  transition: color var(--transition-fast);
}
.preset-del:hover { color: var(--accent); }

/* cfg status */
#cfg-status { font-size: 12px; color: var(--text-muted); min-height: 18px; margin-top: 4px; }
.hint-text { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ══════════════════════════════════════════════════════════════
   ADVANCED PARAMS
   ══════════════════════════════════════════════════════════════ */

#advanced-params {
  background: var(--bg); border-radius: var(--radius-md);
  padding: 8px 12px; margin: var(--space-sm) 0;
  border: 1px solid var(--border);
}
#advanced-params summary {
  font-size: 12px; color: var(--text-muted); cursor: pointer;
  padding: 4px 0; font-family: var(--font-ui);
}
.adv-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm);
  margin: var(--space-sm) 0;
}
.adv-grid label { font-size: 11px; color: var(--text-muted); }
.adv-grid input {
  width: 100%; padding: 4px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-bg);
  color: var(--text); font-size: 12px; font-family: var(--font-ui);
}
.adv-grid input[type=range] { accent-color: var(--accent); padding: 0; }

/* ══════════════════════════════════════════════════════════════
   CENTER PANEL: SCRIPT
   ══════════════════════════════════════════════════════════════ */

#panel-script {
  flex: 1; background: var(--panel-bg); border-radius: var(--radius-lg);
  padding: var(--space-lg); overflow-y: auto;
  border: 1px solid var(--border);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.empty-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.7; }
.empty-state p {
  font-family: var(--font-display);
  font-size: var(--text-lg, 18px);
  color: var(--text);
  margin-bottom: 4px;
}
.hint { font-size: var(--text-sm, 13px); color: var(--text-muted); margin-top: 8px; }

/* ===== SCRIPT TOOLBAR ===== */
#script-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--space-md); gap: var(--space-md); flex-wrap: wrap;
}

#script-title {
  font-family: var(--font-display);
  font-size: var(--text-xl, 24px); font-weight: var(--font-weight-bold, 700);
  outline: none; padding: 4px 8px; border-radius: var(--radius-sm);
  min-width: 200px; border: 1px solid transparent;
  color: var(--text);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
#script-title:focus { border-color: var(--accent2); background: var(--bg); }

#script-badges { display: flex; gap: var(--space-sm); margin-top: 6px; flex-wrap: wrap; }
#script-badges span {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-muted);
  font-family: var(--font-ui);
}

#script-tools { display: flex; gap: var(--space-sm); }
#script-tools button {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text); cursor: pointer;
  font-size: 12px; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
#script-tools button:hover {
  border-color: var(--accent2); color: var(--accent2);
  transform: translateY(-1px);
}

/* ===== CHARACTERS ===== */
#characters-section {
  background: var(--bg); border-radius: var(--radius-lg);
  padding: var(--space-md); margin-bottom: var(--space-md);
  border: 1px solid var(--border);
}
#characters-section summary {
  font-weight: 600; font-size: var(--text-base, 14px);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); color: var(--text);
}

.char-list { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-top: 10px; }
.char-card {
  background: var(--panel-bg); border: 1px solid var(--border-strong, var(--border));
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-md); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; min-width: 140px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.char-card:hover {
  border-color: var(--accent2);
  border-top-color: var(--accent2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
}
.char-card input {
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 13px; padding: 2px 4px; border-radius: 3px; width: 100%;
  font-family: var(--font-body);
}
.char-card input:focus { border-color: var(--accent2); background: var(--bg); outline: none; }
.char-card .c-name { font-weight: 600; font-size: 14px; font-family: var(--font-display); }
.char-card .c-role { font-size: 12px; color: var(--accent2); }
.char-card .c-personality { font-size: 11px; color: var(--text-muted); }

.char-del {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0 3px;
  transition: color var(--transition-fast);
}
.char-del:hover { color: var(--accent); }

/* ===== SCENES ===== */
#scenes-header-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-sm);
}
#scenes-header-bar h3 {
  font-size: var(--text-base, 14px);
  font-family: var(--font-display); color: var(--text);
}

.scene-block {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-bottom: var(--space-sm); overflow: hidden;
  transition: border-color var(--transition-fast);
  min-height: 80px;
}
.scene-block:hover { border-color: var(--border-strong, var(--accent2)); }

/* scene background overlays */
.scene-block.scene-bg-classroom,
.scene-block.scene-bg-rooftop,
.scene-block.scene-bg-courtyard {
  position: relative;
}
.scene-block.scene-bg-classroom .scene-body,
.scene-block.scene-bg-rooftop .scene-body,
.scene-block.scene-bg-courtyard .scene-body {
  position: relative; z-index: 1;
  background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
  margin: 6px; border-radius: var(--radius-sm);
}

.scene-header {
  background: var(--card-bg); padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
}

.scene-drag { color: var(--text-muted); cursor: grab; font-size: 12px; user-select: none; }

.s-name-inp, .s-location-inp {
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 13px; padding: 3px 6px; border-radius: var(--radius-sm);
  font-family: var(--font-body);
}
.s-name-inp { font-weight: 600; flex: 1; font-family: var(--font-display); }
.s-location-inp { width: 120px; font-size: 12px; color: var(--text-muted); }
.s-name-inp:focus, .s-location-inp:focus { border-color: var(--accent2); background: var(--bg); outline: none; }

.scene-toggle, .scene-del {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 12px; padding: 0 4px;
  transition: color var(--transition-fast);
}
.scene-del:hover { color: var(--accent); }

.scene-body {
  padding: var(--space-sm) var(--space-md);
  max-height: 3000px; overflow: hidden;
  transition: max-height .4s var(--ease-smooth), padding .4s var(--ease-smooth);
}
.scene-body.collapsed {
  max-height: 0; padding-top: 0; padding-bottom: 0;
}

.scene-props-row, .scene-kp-row {
  display: flex; align-items: center; gap: var(--space-sm); margin-bottom: 8px;
}
.scene-props-row label, .scene-kp-row label {
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
  font-family: var(--font-ui);
}
.scene-props-row input, .scene-kp-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-family: var(--font-body);
}

/* ===== DIALOGUE LINES ===== */
.dialogue-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.dialogue-line {
  display: flex; gap: var(--space-sm); align-items: center;
  padding: 4px 0; border-bottom: 1px dotted transparent;
}
.dialogue-line:hover { border-bottom-color: var(--border); }

.dl-speaker {
  width: 80px; background: transparent; border: 1px solid transparent;
  color: var(--accent); font-size: 13px; font-weight: 600;
  padding: 3px 4px; border-radius: var(--radius-sm); text-align: right;
  font-family: var(--font-display);
}
.dl-speaker:focus { border-color: var(--accent2); background: var(--bg); outline: none; }

.dl-emotion {
  font-size: 11px; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--card-bg); cursor: pointer; white-space: nowrap;
  min-width: 36px; text-align: center; user-select: none;
  font-family: var(--font-ui); transition: all var(--transition-fast);
}
.dl-emotion:hover { filter: brightness(1.2); transform: scale(1.05); }

.dl-line {
  flex: 1; background: transparent; border: 1px solid transparent;
  color: var(--text); font-size: 13px; padding: 4px 8px; border-radius: var(--radius-sm);
  font-family: var(--font-body); line-height: var(--line-height-normal, 1.6);
}
.dl-line:focus { border-color: var(--accent2); background: var(--bg); outline: none; }

.dl-del {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 15px; padding: 0 2px; flex-shrink: 0;
  transition: color var(--transition-fast);
}
.dl-del:hover { color: var(--accent); }

.btn-add-dialogue { margin-top: 2px; }

/* ===== KNOWLEDGE POINTS ===== */
.scene-kp { margin-top: 6px; }
.kp-tag {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--color-primary-light); color: var(--accent);
  margin-right: 4px; display: inline-block; margin-top: 3px;
  font-family: var(--font-ui);
}

/* ===== SAVE STATUS ===== */
#save-status-bar { margin-top: var(--space-md); display: flex; align-items: center; }
#save-status { font-size: 13px; color: var(--accent2); font-family: var(--font-ui); }

/* ===== TOOLS RESULT (INLINE) ===== */
#tools-result {
  background: var(--bg); border: 1px solid var(--accent2);
  border-radius: var(--radius-md); padding: var(--space-md); margin-bottom: var(--space-sm);
}
#tools-result-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-sm);
}
#tools-result-title { font-weight: 600; color: var(--accent2); font-family: var(--font-display); }
#tools-result-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px;
}
#tools-result-close:hover { color: var(--accent); }
#tools-result-body { font-size: var(--text-sm, 13px); line-height: 1.8; }

/* ===== BLANK SCRIPT BTN ===== */
#btn-blank-script { display: block; margin: 16px auto 0; }

/* ===== SCRIPT READ MODE (toggle: edit ↔ read) ===== */
#btn-read-mode {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text); cursor: pointer;
  font-size: 12px; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
#btn-read-mode:hover { border-color: var(--accent2); color: var(--accent2); }
#btn-read-mode.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }

/* read mode: suppress editing UI, reveal theatrical formatting */
.script-read-mode #script-tools { display: none !important; }
.script-read-mode #tools-bar { display: none !important; }
.script-read-mode #tools-result { display: none !important; }
.script-read-mode .dl-del,
.script-read-mode .scene-del,
.script-read-mode .scene-toggle,
.script-read-mode .scene-drag,
.script-read-mode .char-del,
.script-read-mode #btn-add-dialogue,
.script-read-mode #btn-add-char,
.script-read-mode #btn-add-scene,
.script-read-mode #characters-section .btn-xs { display: none !important; }

.script-read-mode .dl-speaker,
.script-read-mode .dl-line,
.script-read-mode .dl-emotion,
.script-read-mode .s-name-inp,
.script-read-mode .s-location-inp,
.script-read-mode .char-card input,
.script-read-mode .scene-props-row input,
.script-read-mode .scene-kp-row input {
  border-color: transparent !important;
  background: transparent !important;
  cursor: default;
}
.script-read-mode .dl-speaker {
  text-align: left; font-size: var(--text-base, 16px); width: auto;
  min-width: 60px; padding: 0;
  font-family: var(--font-display); color: var(--accent);
}
.script-read-mode .dl-emotion {
  font-style: italic; background: transparent !important;
  font-size: 11px; color: var(--text-muted) !important;
  border: none !important; box-shadow: none !important;
  filter: none !important; transform: none !important;
}
.script-read-mode .dl-line {
  font-size: var(--text-base, 16px); line-height: 2;
  padding: 2px 0;
}
.script-read-mode .dialogue-line {
  display: grid; grid-template-columns: auto auto 1fr;
  gap: 4px var(--space-sm); padding: 8px 0;
  border-bottom: 1px dotted var(--border);
  align-items: baseline;
}
.script-read-mode .dl-speaker { grid-column: 1; }
.script-read-mode .dl-emotion { grid-column: 2; font-size: 10px; white-space: nowrap; }
.script-read-mode .dl-line { grid-column: 1 / -1; padding-left: 0; }

.script-read-mode .scene-header { justify-content: center; padding: 14px 12px; }
.script-read-mode .s-name-inp { text-align: center; font-size: var(--text-lg, 18px); }
.script-read-mode .s-location-inp { text-align: center; font-size: 13px; }
.script-read-mode .scene-block { margin-bottom: var(--space-lg); }

.script-read-mode #characters-section summary { font-size: var(--text-lg, 16px); }
.script-read-mode .char-card { min-width: 100px; }

.script-read-mode #script-title {
  font-size: var(--text-2xl, 32px); text-align: center; width: 100%;
}
.script-read-mode #script-badges { justify-content: center; }

/* ══════════════════════════════════════════════════════════════
   RIGHT PANEL: TEACHING
   ══════════════════════════════════════════════════════════════ */

#panel-teaching {
  width: 280px; flex-shrink: 0; background: var(--panel-bg);
  border-radius: var(--radius-lg); padding: var(--space-md);
  overflow-y: auto; border: 1px solid var(--border);
}
#panel-teaching h2 {
  font-size: var(--text-base, 15px); margin-bottom: var(--space-sm);
  font-family: var(--font-display);
}
.teach-block { margin-bottom: var(--space-md); }
.teach-block h3 {
  font-size: 13px; margin-bottom: 6px; color: var(--accent2);
  font-family: var(--font-display);
}
.teach-block ol, .teach-block ul { padding-left: 18px; }
.teach-block li {
  font-size: 12px; line-height: 1.9; color: var(--text);
  margin-bottom: 2px;
}

/* ══════════════════════════════════════════════════════════════
   LIBRARY PAGE
   ══════════════════════════════════════════════════════════════ */

#lib-header { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-md); }
#lib-header h2 { font-size: var(--text-xl, 18px); font-family: var(--font-display); }
#lib-count { font-size: 13px; color: var(--text-muted); }

#lib-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.lib-card {
  background: var(--panel-bg); border: 1px solid var(--border-strong, var(--border));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg); padding: var(--space-md);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.lib-card:hover {
  border-color: var(--accent2);
  border-left-color: var(--accent2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-elevated);
}

.lc-title { font-size: var(--text-base, 15px); font-weight: 600; margin-bottom: 6px; font-family: var(--font-display); }
.lc-meta  { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.lc-actions { display: flex; gap: var(--space-xs); }
.lc-actions button {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--text); cursor: pointer; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
.lc-actions button:hover { border-color: var(--accent2); color: var(--accent2); }
.lc-actions .danger { color: var(--accent); border-color: var(--color-primary-light); }
.lc-actions .danger:hover { background: var(--color-primary-light); }

/* ══════════════════════════════════════════════════════════════
   TOOLS BAR (14 TOOLS)
   ══════════════════════════════════════════════════════════════ */

#tools-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 0; margin-bottom: var(--space-sm);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tool-btn {
  font-size: 11px; padding: 4px 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  white-space: nowrap; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
.tool-btn:hover {
  color: var(--text); background: var(--card-bg);
  border-color: var(--border); transform: translateY(-1px);
}
.tool-btn.primary-tool {
  font-weight: 600; font-size: 12px; padding: 5px 10px;
  color: var(--text);
}
.tool-btn.primary-tool:hover {
  border-color: var(--accent2); color: var(--accent2);
}
#btn-more-tools {
  font-size: 14px; font-weight: 700; padding: 2px 6px;
  letter-spacing: 1px;
}
.tools-sep { color: var(--border); font-size: 11px; margin: 0 2px; }

/* extended tool row */
#tools-bar-extended {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 6px 0 10px; border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-sm);
  animation: slideUp .2s ease-out;
}

/* contextual recommendation bar */
#tools-recommend {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: var(--space-sm);
  background: var(--color-primary-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  font-size: 12px; color: var(--text);
  animation: slideUp .3s var(--ease-smooth);
}
#tools-recommend .rec-label { font-weight: 600; color: var(--accent); white-space: nowrap; }
#tools-recommend .rec-btn {
  font-size: 11px; padding: 3px 8px; border: 1px solid var(--accent);
  border-radius: var(--radius-sm); background: transparent;
  color: var(--accent); cursor: pointer; font-family: var(--font-ui);
}
#tools-recommend .rec-btn:hover { background: var(--accent); color: #fff; }

/* ══════════════════════════════════════════════════════════════
   GUIDE PAGE
   ══════════════════════════════════════════════════════════════ */

#guide-content { display: flex; flex-direction: column; gap: var(--space-lg); padding-bottom: 40px; }

.guide-hero { text-align: center; padding: 30px 0 20px; }
.guide-hero h1 {
  font-size: var(--text-2xl, 32px); color: var(--accent);
  font-family: var(--font-display); margin-bottom: 8px;
}
.guide-subtitle {
  font-size: var(--text-base, 15px); color: var(--text-muted);
  font-family: var(--font-display);
}

.guide-card {
  background: var(--panel-bg); border: 1px solid var(--border-strong, var(--border));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg); padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}
.guide-card:hover {
  border-color: var(--accent2);
  border-left-color: var(--accent2);
  box-shadow: var(--shadow-elevated);
}
.guide-card h2 {
  font-size: var(--text-lg, 16px); margin-bottom: 10px;
  color: var(--accent2); font-family: var(--font-display);
}
.guide-card p, .guide-card li {
  font-size: var(--text-sm, 13px); line-height: 1.9; color: var(--text);
}
.guide-card ul { padding-left: 20px; }
.guide-card li { margin-bottom: 4px; }

/* guide steps */
.guide-steps { display: flex; flex-direction: column; gap: var(--space-md); }
.guide-step { display: flex; gap: var(--space-md); align-items: flex-start; }
.gs-num {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-round);
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  font-family: var(--font-display);
}

/* guide table */
.guide-table { width: 100%; border-collapse: collapse; }
.guide-table td, .guide-table th {
  padding: 10px 14px; font-size: var(--text-sm, 13px);
  border-bottom: 1px solid var(--border); text-align: left;
  line-height: 1.7; vertical-align: top;
}
.guide-table th {
  color: var(--accent2); font-weight: 600; white-space: nowrap;
  font-family: var(--font-display);
}
.guide-table td:first-child {
  white-space: nowrap; color: var(--color-warm, var(--accent3));
  font-weight: 600; font-family: var(--font-ui);
}

.guide-footer {
  text-align: center; color: var(--text-muted);
  font-size: 12px; line-height: 2.2; padding: 20px 0;
  font-family: var(--font-display);
}

/* ══════════════════════════════════════════════════════════════
   IDENTITY MODAL
   ══════════════════════════════════════════════════════════════ */

#identity-modal {
  position: fixed; inset: 0; z-index: 1000; display: flex;
  align-items: center; justify-content: center;
  background: var(--color-bg-overlay, rgba(0,0,0,.6));
  backdrop-filter: blur(6px);
  animation: fadeIn .3s ease-out;
}

#identity-card {
  background: var(--panel-bg); border-radius: var(--radius-lg);
  padding: var(--space-xl); max-width: 460px; width: 90%;
  text-align: center; border: 1px solid var(--border);
  box-shadow: var(--shadow-elevated);
  animation: slideUp .4s var(--ease-smooth);
}

#identity-card h2 {
  font-size: var(--text-xl, 24px); margin-bottom: 8px;
  font-family: var(--font-display); color: var(--accent);
}
#identity-card p {
  font-size: var(--text-sm, 13px); margin-bottom: var(--space-sm);
  line-height: 1.7;
}

#identity-options { display: flex; flex-direction: column; gap: var(--space-sm); margin: var(--space-md) 0; }
.identity-opt {
  display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer; text-align: left;
  transition: all var(--transition-fast);
}
.identity-opt:hover {
  border-color: var(--accent);
  transform: translateX(4px);
  box-shadow: var(--shadow-card);
}
.identity-opt strong { font-size: var(--text-base, 14px); font-family: var(--font-display); }
.identity-opt small { font-size: 11px; color: var(--text-muted); }

#identity-skip { margin-top: 8px; }

/* ══════════════════════════════════════════════════════════════
   TOOLS DRAWER
   ══════════════════════════════════════════════════════════════ */

#tools-drawer {
  position: fixed; top: 0; right: 0; width: 400px; max-width: 90vw; height: 100vh; z-index: 960;
  background: var(--panel-bg); border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(0,0,0,.3);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideRight .3s var(--ease-smooth);
}
/* pin button */
#tools-drawer-header { gap: 6px; }
#tools-drawer-pin {
  background: none; border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-muted); cursor: pointer; font-size: 11px; padding: 2px 6px;
}
#tools-drawer-pin:hover { border-color: var(--accent2); color: var(--accent2); }
#tools-drawer-pin.pinned { background: var(--accent2); color: #fff; border-color: var(--accent2); }

/* shortcut help overlay */
#shortcut-help {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: center; justify-content: center;
  background: var(--color-bg-overlay, rgba(0,0,0,.5));
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease-out;
}
#shortcut-help .help-inner {
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-xl);
  max-width: 400px; width: 90%;
  box-shadow: var(--shadow-elevated);
}
#shortcut-help h3 { font-size: var(--text-lg); margin-bottom: var(--space-md); font-family: var(--font-display); }
#shortcut-help table { width: 100%; border-collapse: collapse; }
#shortcut-help td { padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--border); }
#shortcut-help td:first-child { white-space: nowrap; }
#shortcut-help kbd {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 6px; font-size: 11px; font-family: monospace;
}

#tools-drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-md); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#tools-drawer-title {
  font-weight: 600; font-size: var(--text-base, 14px);
  color: var(--accent2); font-family: var(--font-display);
}
#tools-drawer-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; cursor: pointer; padding: 0 4px;
  transition: color var(--transition-fast);
}
#tools-drawer-close:hover { color: var(--accent); }
#tools-drawer-body { flex: 1; overflow-y: auto; padding: var(--space-md); }

/* ══════════════════════════════════════════════════════════════
   ORANGE MASCOT
   ══════════════════════════════════════════════════════════════ */

#orange-mascot {
  position: fixed; bottom: 24px; right: 28px; z-index: 999;
  display: flex; align-items: flex-end; gap: var(--space-sm);
  animation: slideUp .4s var(--ease-spring);
}
#mascot-avatar { font-size: 32px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
#mascot-bubble {
  max-width: 300px; background: var(--panel-bg); border: 1px solid var(--accent2);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
  padding: var(--space-sm) 14px; font-size: 12px; line-height: 1.7;
  color: var(--text); box-shadow: var(--shadow-elevated);
  font-family: var(--font-body);
}

/* ===== EMOTIONAL RESONANCE ===== */
#emotional-resonance {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 998;
  display: flex; align-items: center; gap: 8px;
  background: var(--color-warning-bg, rgba(245,166,35,.15));
  border: 1px solid var(--color-warm, var(--accent3));
  border-radius: 24px; padding: 10px 22px;
  font-size: 12px; color: var(--color-warm, var(--accent3));
  max-width: 520px; font-family: var(--font-display);
  animation: slideUp .5s var(--ease-spring);
}

/* ===== CHARACTER FOCUS BAR ===== */
#char-focus-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: var(--space-md); padding: 10px 16px;
  background: var(--card-bg); border: 1px solid var(--accent2);
  border-radius: var(--radius-md); margin-bottom: var(--space-md);
  font-size: var(--text-sm, 13px); font-weight: 600;
  font-family: var(--font-display);
}
#char-focus-export {
  font-size: 11px; padding: 4px 12px; border: 1px solid var(--accent2);
  border-radius: var(--radius-sm); background: transparent;
  color: var(--accent2); cursor: pointer; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
#char-focus-export:hover { background: var(--color-primary-light); }
#char-focus-emotion {
  font-size: 11px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg);
  color: var(--text); font-family: var(--font-ui);
}
#char-focus-emotion-apply {
  font-size: 11px; padding: 3px 8px; border: 1px solid var(--accent2);
  border-radius: var(--radius-sm); background: transparent;
  color: var(--accent2); cursor: pointer;
}
#char-focus-emotion-apply:hover { background: var(--accent2); color: #fff; }
#char-focus-off {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  transition: color var(--transition-fast);
}
#char-focus-off:hover { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   STREAM PREVIEW
   ══════════════════════════════════════════════════════════════ */

#stream-preview {
  padding: var(--space-xl); position: relative; z-index: 1;
}
#stream-content {
  font-size: var(--text-lg, 18px); line-height: 2.2;
  color: var(--text); max-height: 60vh; overflow-y: auto;
  font-family: var(--font-display);
  text-align: center;
}

/* intro: big reveal */
.stream-intro {
  font-size: var(--text-2xl, 32px); font-weight: 700; color: var(--accent);
  text-align: center; padding: var(--space-xl) 0;
  animation: inkSpread 1s var(--ease-smooth) forwards;
}

/* stage cards */
.stream-card {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 14px 20px; margin: 10px auto; max-width: 500px;
  background: var(--panel-bg); border: 1px solid var(--border);
  border-left: 4px solid var(--accent2);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  text-align: left; font-family: var(--font-body);
  font-size: var(--text-sm, 15px);
  animation: slideUp .5s var(--ease-smooth);
  opacity: 0; animation-fill-mode: forwards;
}
.stream-card:nth-child(2) { animation-delay: 0.08s; }
.stream-card:nth-child(3) { animation-delay: 0.16s; }
.stream-card:nth-child(4) { animation-delay: 0.24s; }
.stream-card:nth-child(5) { animation-delay: 0.32s; }

.stream-card .sc-icon { font-size: 22px; flex-shrink: 0; }
.stream-card .sc-msg  { flex: 1; }
.stream-card.first {
  font-size: var(--text-lg, 19px); font-weight: 600;
  border-left-color: var(--accent);
  background: linear-gradient(135deg, var(--color-primary-light), transparent);
}

/* stage progress bar */
#stream-preview::after {
  content: ''; position: absolute; bottom: 10px; left: 15%; right: 15%; height: 3px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
#stream-preview::before {
  content: ''; position: absolute; bottom: 10px; left: 15%; height: 3px;
  background: var(--accent); border-radius: 2px; z-index: 2;
  animation: progressSlide 4s infinite ease-in-out;
}
@keyframes progressSlide {
  0%   { width: 0%; }
  50%  { width: 75%; }
  100% { width: 75%; }
}

/* dark overlay on stage-hero during generation */
#stage-hero.generating {
  position: relative;
}
#stage-hero.generating::after {
  content: ''; position: absolute; inset: 0; z-index: 2;
  background: rgba(0,0,0,0.12); border-radius: inherit;
  pointer-events: none;
  animation: fadeIn .4s ease-out;
}
@keyframes progressSlide {
  0%   { width: 0%; }
  50%  { width: 70%; }
  100% { width: 70%; }
}

/* ══════════════════════════════════════════════════════════════
   DIAGNOSTICS / DYNAMIC CONTENT
   ══════════════════════════════════════════════════════════════ */

.diag-section {
  background: var(--panel-bg); border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md); margin-bottom: 8px;
  border: 1px solid var(--border);
}
.diag-section h4 { font-size: 12px; color: var(--accent2); margin-bottom: 4px; font-family: var(--font-display); }
.diag-section ol, .diag-section ul { padding-left: 18px; }
.diag-section li { font-size: 12px; line-height: 1.8; margin-bottom: 2px; }
.diag-score { text-align: center; padding: var(--space-sm); }
.persp-card {
  background: var(--card-bg); border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md); margin: 6px 0;
  font-size: 12px; line-height: 1.7;
}
.km-node { font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.03); }
.km-cat  { font-size: 10px; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--card-bg); color: var(--accent3); }
.km-conn { font-size: 11px; padding: 4px 10px; margin: 3px 0; border-left: 2px solid var(--accent2); }

/* export tabs */
.export-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.exp-tab {
  font-size: 12px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); cursor: pointer; font-family: var(--font-ui);
  transition: all var(--transition-fast);
}
.exp-tab:hover { border-color: var(--accent2); color: var(--accent2); }
.exp-tab.active {
  background: color-mix(in srgb, var(--accent2) 48%, #000 52%);
  color: #fff; border-color: var(--accent2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.export-pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-md);
  font-size: 13px; line-height: 1.9; max-height: 300px;
  overflow-y: auto; white-space: pre-wrap; margin-bottom: 10px;
  font-family: var(--font-body);
}

blockquote {
  border-left: 3px solid var(--accent2); padding: 6px 12px; margin: 8px 0;
  font-style: italic; background: var(--color-primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-display);
}

.loading { text-align: center; padding: 30px; color: var(--text-muted); }
.error   { color: var(--accent); padding: var(--space-sm); }

/* ===== REF SCRIPT SELECT ===== */
#cfg-ref-script {
  width: 100%; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 12px; margin-top: 4px;
}

/* ===== CUSTOM TYPE ===== */
#cfg-custom-type {
  width: 100%; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 13px; margin-top: 4px;
}

/* ===== STYLE PREVIEW ===== */
#cfg-style-preview { font-size: 11px; color: var(--accent3); margin-left: 4px; }

/* ══════════════════════════════════════════════════════════════
   KEYFRAMES (do NOT rename — referenced by JS)
   ══════════════════════════════════════════════════════════════ */

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* additional */
@keyframes curtainOpen {
  from { clip-path: inset(0 50% 0 50%); }
  to   { clip-path: inset(0 0 0 0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ══════════════════════════════════════════════════════════════
   THEME: 元曲·戏台 (default)
   关汉卿市井温暖 + 宣纸 + 水墨
   ══════════════════════════════════════════════════════════════ */

.theme-yuanqu {
  /* core */
  --bg:            #FBF7F0;
  --panel-bg:      #FFFFFF;
  --card-bg:       #F5EFE4;
  --text:          #2E2E2E;
  --text-muted:    #555555;
  --accent:        #D15E2A;
  --accent2:       #3D6B5E;
  --accent3:       #B88958;
  --border:        #D5CCBE;
  --border-strong: #B8A98E;

  /* extended */
  --color-primary:        var(--accent);
  --color-primary-hover:  #C05522;
  --color-primary-active: #A8481C;
  --color-primary-light:  rgba(209, 94, 42, 0.1);
  --color-bg-base:       var(--bg);
  --color-bg-elevated:   var(--panel-bg);
  --color-bg-inset:      var(--card-bg);
  --color-bg-overlay:    rgba(74, 74, 74, 0.4);
  --color-text-primary:    var(--text);
  --color-text-secondary:  var(--text-muted);
  --color-text-disabled:   #B0A99D;
  --color-text-on-primary: #FFFFFF;
  --color-border:         var(--border);
  --color-border-strong:  var(--border-strong);
  --color-warm:           #D4A373;
  --color-conflict:       #5D4E6D;
  --color-warning-bg:     #FAE8E8;
  --color-warning-text:   #B33A3A;
  --color-success:        #4A7C6F;

  /* fonts */
  --font-display: "Noto Serif SC", "KaiTi", "STKaiti", "AR PL UKai CN", serif;
  --font-body:   "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-ui:     "PingFang SC", "Microsoft YaHei", "Xiaolai Wenkai", sans-serif;

  /* typography scale */
  --text-xs:   0.8125rem;
  --text-sm:   0.9375rem;
  --text-base: 1.0625rem;
  --text-lg:   1.1875rem;
  --text-xl:   1.625rem;
  --text-2xl:  2.5rem;
  --text-3xl:  3.25rem;
  --font-weight-normal: 400;
  --font-weight-medium: 520;
  --font-weight-bold:   700;
  --line-height-tight:   1.3;
  --line-height-normal:  1.7;
  --line-height-relaxed: 1.9;

  /* shadows */
  --shadow-card:     0 2px 12px rgba(0,0,0,0.04);
  --shadow-elevated: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-pressed:  0 1px 4px rgba(0,0,0,0.06);

  /* decorative */
  --deco-pattern: none;
}

/* 元曲: card warmth */
.theme-yuanqu .preset-card,
.theme-yuanqu .lib-card,
.theme-yuanqu .guide-card {
  border-left-color: var(--accent);
  box-shadow: 0 2px 16px rgba(60,40,20,0.05);
}
.theme-yuanqu .preset-card:hover,
.theme-yuanqu .lib-card:hover,
.theme-yuanqu .guide-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(60,40,20,0.1);
}

/* 元曲 background: rice-paper fiber + ink dots */
.theme-yuanqu body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg width='300' height='300' viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)' opacity='0.025'/%3E%3C/svg%3E"),
    radial-gradient(circle at 25% 35%, rgba(212,163,115,0.06) 0%, transparent 40%),
    radial-gradient(circle at 75% 65%, rgba(186,80,50,0.04) 0%, transparent 35%);
}
/* yuanqu: warm sepia vignette */
.theme-yuanqu body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,240,220,0.08) 0%, transparent 60%);
}

/* ══════════════════════════════════════════════════════════════
   THEME: 环球剧场·侧幕
   勃艮第帷幕 + 暗夜舞台 + 黄铜金点缀
   ══════════════════════════════════════════════════════════════ */

.theme-globe {
  /* core */
  --bg:            #151D28;
  --panel-bg:      #1E2A38;
  --card-bg:       #18212E;
  --text:          #F5E8B8;
  --text-muted:    #C4B690;
  --accent:        #A04050;
  --accent2:       #D4B378;
  --accent3:       #EBDBBE;
  --border:        #354150;
  --border-strong: #556575;

  /* extended */
  --color-primary:        var(--accent2);
  --color-primary-hover:  #E0C080;
  --color-primary-active: #C4A068;
  --color-primary-light:  rgba(212, 179, 120, 0.12);
  --color-bg-base:       var(--bg);
  --color-bg-elevated:   var(--panel-bg);
  --color-bg-inset:      var(--card-bg);
  --color-bg-overlay:    rgba(0, 0, 0, 0.65);
  --color-text-primary:    var(--text);
  --color-text-secondary:  var(--text-muted);
  --color-text-disabled:   #706858;
  --color-text-on-primary: #151D28;
  --color-border:         var(--border);
  --color-border-strong:  var(--border-strong);
  --color-warm:           #D4B378;
  --color-conflict:       #B8505A;
  --color-warning-bg:     #3D2424;
  --color-warning-text:   #F5B8B8;
  --color-success:        #78B898;
  --color-wood:           #5C4033;

  /* fonts */
  --font-display: "Georgia", "Times New Roman", "KaiTi", "Noto Serif SC", serif;
  --font-body:   "IBM Plex Serif", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-ui:     "Lato", "PingFang SC", "Microsoft YaHei", sans-serif;

  /* typography */
  --text-xs:   0.8125rem;
  --text-sm:   0.9375rem;
  --text-base: 1.0625rem;
  --text-lg:   1.1875rem;
  --text-xl:   1.625rem;
  --text-2xl:  2.5rem;
  --text-3xl:  3.25rem;
  --font-weight-normal: 400;
  --font-weight-medium: 520;
  --font-weight-bold:   700;
  --line-height-tight:   1.3;
  --line-height-normal:  1.7;
  --line-height-relaxed: 1.9;

  /* shadows — harder for dark theme */
  --shadow-card:     0 4px 16px rgba(0,0,0,0.3);
  --shadow-elevated: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-pressed:  0 2px 4px rgba(0,0,0,0.3);
}

/* 环球剧场 background: dark stage with subtle grain */
.theme-globe body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='gf'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23gf)' opacity='0.03'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 30%, rgba(201,169,110,0.06) 0%, transparent 50%);
}
/* 环球剧场 topbar curtain effect */
.theme-globe #topbar {
  background: linear-gradient(180deg, #5F1F29 0%, var(--panel-bg) 100%);
  border-bottom: 2px solid var(--accent2);
}

/* ══════════════════════════════════════════════════════════════
   THEME: 暖阳·社工站
   燕麦暖黄 + 圆润 + 手绘温度
   ══════════════════════════════════════════════════════════════ */

.theme-sunshine {
  /* core */
  --bg:            #F5E6D3;
  --panel-bg:      #FFFBF5;
  --card-bg:       #F0E4D0;
  --text:          #3D302C;
  --text-muted:    #5E5048;
  --accent:        #E07A3E;
  --accent2:       #557AA6;
  --accent3:       #6DA88E;
  --border:        #DDCCB8;
  --border-strong: #C4AF98;

  /* extended */
  --color-primary:        var(--accent);
  --color-primary-hover:  #D06A2E;
  --color-primary-active: #C05820;
  --color-primary-light:  rgba(224, 122, 62, 0.14);
  --color-bg-base:       var(--bg);
  --color-bg-elevated:   var(--panel-bg);
  --color-bg-inset:      var(--card-bg);
  --color-bg-overlay:    rgba(75, 61, 56, 0.3);
  --color-text-primary:    var(--text);
  --color-text-secondary:  var(--text-muted);
  --color-text-disabled:   #9E8E80;
  --color-text-on-primary: #FFFFFF;
  --color-border:         var(--border);
  --color-border-strong:  var(--border-strong);
  --color-link:           #557AA6;
  --color-link-hover:     #446888;
  --color-warm:           #E07A3E;
  --color-conflict:       #A8604A;
  --color-warning-bg:     #F0D8CC;
  --color-warning-text:   #9A3A20;
  --color-success:        #5E9C80;
  --color-mint:           #7EB89E;

  /* fonts */
  --font-display: "PingFang SC", "Microsoft YaHei", "Rounded Mplus 1c", sans-serif;
  --font-body:   "Source Han Serif SC", "Georgia", "STSong", serif;
  --font-ui:     "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;

  /* typography — slightly larger, more relaxed */
  --text-xs:   0.875rem;
  --text-sm:   1rem;
  --text-base: 1.125rem;
  --text-lg:   1.25rem;
  --text-xl:   1.75rem;
  --text-2xl:  2.75rem;
  --text-3xl:  3.5rem;
  --font-weight-normal: 400;
  --font-weight-medium: 520;
  --font-weight-bold:   700;
  --line-height-tight:   1.35;
  --line-height-normal:  1.75;
  --line-height-relaxed: 2.1;

  /* shadows — soft */
  --shadow-card:     0 8px 30px rgba(75, 61, 56, 0.08);
  --shadow-elevated: 0 12px 40px rgba(75, 61, 56, 0.12);
  --shadow-pressed:  0 2px 6px rgba(75, 61, 56, 0.06);

  /* extra radius for the friendly feel */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
}

/* 暖阳 background: soft scattered light spots */
.theme-sunshine body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(163,201,183,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 55%, rgba(255,180,130,0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 85%, rgba(107,139,182,0.06) 0%, transparent 40%);
}
.theme-sunshine body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg width='250' height='250' viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sf'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='250' height='250' filter='url(%23sf)' opacity='0.02'/%3E%3C/svg%3E");
  opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════
   THEME-SPECIFIC OVERRIDES
   ══════════════════════════════════════════════════════════════ */

/* 环球剧场: cards pop with gold accents + elevated surface */
.theme-globe .preset-card,
.theme-globe .lib-card,
.theme-globe .guide-card,
.theme-globe .char-card,
.theme-globe .scene-block {
  background: #2A3647;
  border-color: #4A5568;
  border-left: 3px solid var(--accent2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.theme-globe .preset-card:hover,
.theme-globe .lib-card:hover,
.theme-globe .guide-card:hover,
.theme-globe .char-card:hover {
  border-color: var(--accent2);
  border-left-color: #E0C880;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.theme-globe .identity-opt {
  background: #2A3647;
  border-color: #4A5568;
}
.theme-globe .identity-opt:hover {
  border-color: var(--accent2);
  background: #303E50;
}

/* 环球剧场: gold primary buttons */
.theme-globe .btn-primary,
.theme-globe #btn-hero-go,
.theme-globe #btn-blank-script {
  background: var(--accent2);
  color: var(--bg);
  font-weight: 600;
  border-radius: 4px;
}
.theme-globe .btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 16px rgba(201, 169, 110, 0.3);
}

/* 环球剧场: wood slider */
.theme-globe input[type=range] {
  accent-color: var(--color-wood, #5C4033);
}

/* 环球剧场: chip selected (dark bg + gold text > gold bg + white) */
.theme-globe .mode-chip:has(input:checked),
.theme-globe .style-chip:has(input:checked),
.theme-globe .exp-tab.active {
  background: #2A2520;
  color: var(--accent2);
  text-shadow: none;
  border-color: var(--accent2);
}

/* 暖阳: round buttons */
.theme-sunshine .btn-primary {
  border-radius: var(--radius-round);
  padding: 12px 28px;
  box-shadow: 0 4px 14px rgba(255, 180, 130, 0.3);
}
.theme-sunshine .btn-primary:active {
  transform: scale(0.97);
}

/* 暖阳: round card corners + soft glow */
.theme-sunshine .preset-card,
.theme-sunshine .lib-card,
.theme-sunshine .guide-card,
.theme-sunshine .char-card,
.theme-sunshine .scene-block {
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(75,61,56,0.07);
  border-color: var(--border-strong, var(--border));
}
.theme-sunshine .preset-card:hover,
.theme-sunshine .lib-card:hover,
.theme-sunshine .guide-card:hover,
.theme-sunshine .char-card:hover {
  box-shadow: 0 10px 32px rgba(75,61,56,0.12);
}

/* 暖阳: emotion chips like post-its */
.theme-sunshine .dl-emotion {
  transform: rotate(-1deg);
  box-shadow: 1px 2px 4px rgba(0,0,0,0.06);
}

/* 暖阳: rounded inputs */
.theme-sunshine input[type=text],
.theme-sunshine input[type=number],
.theme-sunshine textarea,
.theme-sunshine select {
  border-radius: var(--radius-lg);
}

/* 暖阳: tools drawer from bottom on mobile handled in responsive */

/* ══════════════════════════════════════════════════════════════
   CHAT THEME OVERRIDES
   ══════════════════════════════════════════════════════════════ */

/* 元曲: warm paper chat */
.theme-yuanqu .chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #E8703A, #D15E2A);
  color: #fff;
}
.theme-yuanqu .chat-msg.assistant .chat-bubble {
  background: #FFFBF5; border-left-color: #4A7C6F;
}
.theme-yuanqu #chat-panel { background: #FFFAF3; }
.theme-yuanqu #chat-input-row { background: #FBF7F0; }

/* 环球: dramatic dark chat */
.theme-globe .chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #C9A96E, #B8995E);
  color: #1E2A38; font-weight: 500;
}
.theme-globe .chat-msg.assistant .chat-bubble {
  background: #2A3647; border-left-color: #C9A96E; color: #F3E5AB;
}
.theme-globe #chat-panel { background: #1E2A38; border-color: #3E4A58; }
.theme-globe #chat-header { border-bottom-color: #3E4A58; }
.theme-globe #chat-input-row { background: #19212C; border-top-color: #3E4A58; }
.theme-globe #chat-messages::after { background: linear-gradient(transparent, #1E2A38); }

/* 暖阳: soft round chat */
.theme-sunshine .chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #FFB482, #FFA066);
  color: #fff; border-radius: 18px 6px 18px 18px;
}
.theme-sunshine .chat-msg.assistant .chat-bubble {
  background: #FFFBF5; border-left-color: #6B8BB6;
  border-radius: 6px 18px 18px 18px;
}
.theme-sunshine #chat-panel { border-radius: 24px; }
.theme-sunshine #btn-chat-send { border-radius: 50%; box-shadow: 0 4px 14px rgba(255,180,130,0.3); }
.theme-sunshine #chat-input-row { background: #FFFBF5; border-radius: 0 0 24px 24px; }

/* ══════════════════════════════════════════════════════════════
   PURE-CODE VISUAL ASSETS — 无图片·纯CSS作画
   ══════════════════════════════════════════════════════════════ */

/* ===== SVG NOISE TEXTURE (data URI, zero external deps) ===== */
.paper-texture {
  background-image:
    url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
}
/* apply to yuanqu theme */
.theme-yuanqu .paper-texture,
.theme-yuanqu #panel-script {
  background-image:
    url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E"),
    var(--deco-pattern, none);
  background-color: var(--panel-bg);
}
.theme-globe #panel-script {
  background-image:
    url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='ng'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23ng)' opacity='0.02'/%3E%3C/svg%3E");
}

/* ===== EMPTY STATE ART (Qwen-generated ink silhouettes) ===== */
.empty-art {
  width: 100%; max-width: 480px; height: 100px; margin: 0 auto 12px;
  background: center/contain no-repeat;
  opacity: 0.65; filter: grayscale(0.3);
}
/* dark-theme friendly */
.theme-globe .empty-art { opacity: 0.45; filter: grayscale(0.6) brightness(1.3); }

/* ===== CHARACTER SILHOUETTES (CSS-only fallback, kept for inline use) ===== */
.css-char {
  position: relative; display: inline-flex; flex-direction: column;
  align-items: center; width: 80px; height: 120px;
  --ink: var(--color-ink, var(--text));
  opacity: 0.55;
}

.css-char .c-head {
  width: 26px; height: 30px; background: var(--ink);
  border-radius: 50% 50% 45% 45%; position: relative; flex-shrink: 0;
}
.css-char .c-head::after {
  content: ''; position: absolute; top: -3px; left: -5px;
  width: 36px; height: 16px; background: var(--ink); border-radius: 50%;
}

.css-char .c-body {
  width: 28px; height: 40px; background: var(--ink);
  margin-top: -2px; border-radius: 8px 8px 18px 18px; opacity: 0.82;
}

.css-char .c-arms { position: absolute; top: 42px; width: 100%; height: 0; }
.css-char .c-arm {
  position: absolute; width: 5px; height: 32px; background: var(--ink);
  border-radius: 3px; top: 0;
}
.css-char .c-arm.l { left: 18px; transform: rotate(-6deg); }
.css-char .c-arm.r { right: 18px; transform: rotate(6deg); }

.css-char .c-legs {
  width: 18px; height: 24px; background: var(--ink);
  margin-top: 0; border-radius: 5px 5px 2px 2px; opacity: 0.78;
}

/* variant: shy (hunched) */
.css-char.shy .c-body { height: 34px; border-radius: 10px 10px 14px 14px; opacity: 0.7; }
.css-char.shy .c-arm { height: 28px; top: 2px; }
.css-char.shy .c-arm.l { left: 14px; transform: rotate(-15deg); }
.css-char.shy .c-arm.r { right: 14px; transform: rotate(15deg); }
.css-char.shy .c-head { margin-bottom: 0; }

/* variant: outgoing (wide arms) */
.css-char.outgoing .c-arm { height: 36px; }
.css-char.outgoing .c-arm.l { left: 10px; transform: rotate(-40deg); transform-origin: top center; }
.css-char.outgoing .c-arm.r { right: 10px; transform: rotate(40deg); transform-origin: top center; }

/* variant: confident (straight, taller) */
.css-char.confident { height: 130px; opacity: 0.65; }
.css-char.confident .c-body { height: 46px; }
.css-char.confident .c-arm { height: 34px; }

/* empty-state character cluster */
.empty-characters {
  display: flex; justify-content: center; align-items: flex-end;
  gap: var(--space-md); margin-bottom: var(--space-lg);
}
.empty-characters .css-char:nth-child(2) { opacity: 0.4; }
.empty-characters .css-char:nth-child(3) { opacity: 0.28; }

/* ===== EMOTION STAMPS (朱砂印 / 情绪印章) ===== */
.dl-emotion.stamped {
  width: auto; min-width: 28px; height: 28px; padding: 0 8px;
  line-height: 28px; text-align: center; border-radius: var(--radius-round);
  font-size: 12px; font-weight: 700;
  background: color-mix(in srgb, currentColor 55%, #000 45%);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.15), 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent);
  transform: rotate(-3deg);
  font-family: 'KaiTi', 'STKaiti', serif;
  cursor: pointer; user-select: none;
  transition: transform var(--ease-spring) .2s, filter .2s, box-shadow .2s;
}
.dl-emotion.stamped:hover {
  transform: rotate(2deg) scale(1.15);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.25), 0 0 0 3px color-mix(in srgb, currentColor 40%, transparent);
  filter: brightness(1.1);
}
.dl-emotion.stamped:active { transform: rotate(0deg) scale(0.93); }

/* globe theme stamp: intense color on dark */
.theme-globe .dl-emotion.stamped {
  background: color-mix(in srgb, currentColor 60%, var(--bg) 40%);
  color: var(--text);
  text-shadow: none; font-weight: 600;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.4), 0 0 0 2px rgba(212,179,120,0.3);
  border-radius: 3px; transform: none;
  font-family: var(--font-display);
}

/* sunshine theme stamp: vivid soft sticker */
.theme-sunshine .dl-emotion.stamped {
  background: color-mix(in srgb, currentColor 55%, var(--text) 45%);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: var(--radius-lg);
  transform: rotate(-2deg);
  font-family: var(--font-ui); font-weight: 600;
}

/* ===== SCENE BACKGROUNDS (CSS gradient painting) ===== */

/* classroom: wooden floor + chalkboard wall */
.scene-bg-classroom {
  position: relative; width: 100%; min-height: 160px; overflow: hidden;
  background:
    linear-gradient(to bottom, #3B4A3B 0%, #4A5C4A 35%, transparent 35%),
    linear-gradient(to bottom, #F5EDE0 60%, #E8DCC8 100%);
  border-radius: var(--radius-md);
}
.scene-bg-classroom::before {
  content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 70%; height: 18%; background: #2C3A2C;
  border-radius: 4px; border: 3px solid #5A6B5A;
}
.scene-bg-classroom::after {
  content: ''; position: absolute; top: 20px; left: 10%; right: 10%;
  height: 2px; background: rgba(255,255,240,0.15);
  box-shadow: 0 8px 0 rgba(255,255,240,0.1), 0 16px 0 rgba(255,255,240,0.06);
}
/* beam of light */
.scene-bg-classroom .light-beam {
  position: absolute; top: 0; left: 30%; width: 100px; height: 100%;
  background: linear-gradient(to bottom, rgba(255,240,210,0.35) 0%, rgba(255,240,210,0.03) 100%);
  transform: skewX(-10deg); pointer-events: none;
}

/* rooftop: sky + railing */
.scene-bg-rooftop {
  position: relative; width: 100%; min-height: 160px; overflow: hidden;
  background: linear-gradient(to bottom, #C4D7E6 40%, #A8BFD0 55%, var(--bg, #f5f0eb) 55%);
  border-radius: var(--radius-md);
}
.scene-bg-rooftop::before {
  content: ''; position: absolute; bottom: 30px; left: 0; right: 0; height: 5px;
  background: #6B7B8D;
  box-shadow:
    0 16px 0 0 #6B7B8D, 0 32px 0 0 #6B7B8D,
    24px 0 0 0 #6B7B8D, 80px 0 0 0 #6B7B8D, 160px 0 0 0 #6B7B8D,
    24px 16px 0 0 #6B7B8D, 80px 16px 0 0 #6B7B8D, 160px 16px 0 0 #6B7B8D,
    24px 32px 0 0 #6B7B8D, 80px 32px 0 0 #6B7B8D, 160px 32px 0 0 #6B7B8D;
}

/* courtyard: ground + tree silhouette */
.scene-bg-courtyard {
  position: relative; width: 100%; min-height: 160px; overflow: hidden;
  background: linear-gradient(to bottom, #E8D5B0 20%, #D5C098 55%, #C4B080 55%, #8B7B60 100%);
  border-radius: var(--radius-md);
}
.scene-bg-courtyard::before {
  content: ''; position: absolute; top: 15px; right: 15%;
  width: 24px; height: 70px; background: #5A6040; border-radius: 4px 4px 0 0;
  box-shadow: -5px 8px 0 0 color-mix(in srgb, #5A6040 70%, transparent);
}
.scene-bg-courtyard::after {
  content: ''; position: absolute; top: 10px; right: calc(15% - 3px);
  width: 50px; height: 35px; background: #5A6B40; border-radius: 50%;
}

/* ===== CURTAIN COMPONENT (generation reveal) ===== */
.stage-wrapper {
  position: relative; overflow: hidden;
  width: 100%; border-radius: var(--radius-lg);
}
.stage-curtain {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex;
}
.stage-curtain .curtain-panel {
  flex: 1; height: 100%;
  background: linear-gradient(180deg, #5F1F29 0%, #7B2D3B 30%, #8B3A48 100%);
  transition: transform 1s cubic-bezier(0.7, 0, 0.84, 0);
}
.stage-curtain .curtain-panel.left  { transform-origin: left center; }
.stage-curtain .curtain-panel.right { transform-origin: right center; }
.stage-curtain.open .curtain-panel.left  { transform: scaleX(0.06); }
.stage-curtain.open .curtain-panel.right { transform: scaleX(0.06); }

/* curtain fold lines */
.stage-curtain .curtain-panel::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 2px;
  background: rgba(0,0,0,0.2);
}
.stage-curtain .curtain-panel.left::after  { right: 30%; }
.stage-curtain .curtain-panel.right::after { left: 30%; }

/* golden tassel at bottom */
.theme-globe .stage-curtain .curtain-panel {
  background: linear-gradient(180deg, #8B2D3B 0%, #7B2D3B 60%, #5F1F29 100%);
  border-bottom: 3px solid var(--accent2);
}

/* ===== INK REVEAL (text emerges from ink wash) ===== */
.ink-reveal {
  animation: inkSpread 1.2s var(--ease-smooth) forwards;
  position: relative;
}
@keyframes inkSpread {
  0%   { clip-path: circle(0% at 50% 50%); opacity: 0; }
  60%  { clip-path: circle(45% at 50% 50%); opacity: 0.8; }
  100% { clip-path: circle(100% at 50% 50%); opacity: 1; }
}

/* ===== DESK COMPONENT ===== */
.css-desk {
  position: relative; width: 180px; height: 14px;
  background: #8B7355; border-radius: 3px; margin: 0 auto;
  box-shadow: 0 5px 8px rgba(0,0,0,0.08);
}
.css-desk::after {
  content: ''; position: absolute; top: 14px; left: 22px;
  width: 5px; height: 42px; background: #6B5740;
  box-shadow: 120px 0 0 0 #6B5740, 0 20px 0 0 rgba(0,0,0,0.04);
}

/* empty-state scene row */
.empty-scene-row {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-sm); margin-bottom: var(--space-md);
  opacity: 0.6;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* <1280px: 2-col (drop right teaching panel) */
@media (max-width: 1279px) {
  #panel-teaching { display: none; }
  #panel-config { width: 260px; }
}

/* <1024px: single col — config compacts to row above script */
@media (max-width: 1023px) {
  .tab-page { flex-direction: column; padding: var(--space-sm); }
  #panel-config {
    width: 100%; max-height: 35vh; flex-shrink: 0;
    flex-direction: row; flex-wrap: wrap; gap: var(--space-sm);
    overflow-y: auto; padding-bottom: var(--space-sm);
  }
  #panel-config > * { flex: 1 1 140px; min-width: 0; }
  #hero-input { width: 100%; flex-basis: 100%; }
  #presets-section { width: 100%; flex-basis: 100%; }
  #input-mode-tabs { width: 100%; flex-basis: 100%; }

  #panel-script { flex: 1; min-height: 50vh; }
  #tools-bar { overflow-x: auto; flex-wrap: nowrap; }
  #tools-bar .tools-sep { display: none; }

  #panel-teaching { width: 100%; max-height: 30vh; margin-top: var(--space-sm); }

  #tools-drawer {
    width: 100vw; top: auto; bottom: 0;
    height: 60vh; border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp .3s var(--ease-smooth);
  }

  #script-title { font-size: var(--text-lg, 18px); }

  #lib-list { grid-template-columns: 1fr; }
}

/* config toggle button (mobile only) */
#btn-config-toggle {
  background: var(--accent); color: var(--color-text-on-primary, #fff);
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  padding: 4px 10px; font-size: 12px; font-family: var(--font-ui);
  white-space: nowrap;
}

/* <768px: full mobile */
@media (max-width: 767px) {
  #topbar { padding: var(--space-sm); gap: var(--space-sm); flex-wrap: wrap; }
  .logo { font-size: var(--text-base, 16px); }

  .tb-btn { padding: 4px 10px; font-size: 12px; }

  #theme-swapper { margin-left: auto; }
  #btn-config-toggle { display: inline-flex !important; align-items: center; gap: 3px; }

  .tab-page { padding: var(--space-xs); gap: var(--space-xs); }

  /* config panel → bottom drawer */
  #panel-config {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
    max-height: 60vh; width: 100%;
    background: var(--panel-bg);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
    padding: var(--space-md);
    padding-top: 20px;
    flex-direction: column; flex-wrap: nowrap;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .35s var(--ease-smooth);
  }
  #panel-config.open { transform: translateY(0); }

  /* drag handle */
  #panel-config::before {
    content: ''; display: block; width: 36px; height: 4px;
    background: var(--border); border-radius: 2px;
    margin: 0 auto 12px; flex-shrink: 0;
  }

  #panel-script { padding: var(--space-sm); }

  #guide-content { gap: var(--space-sm); }
  .guide-hero h1 { font-size: var(--text-xl, 22px); }
  .guide-card { padding: var(--space-md); }

  #script-tools { flex-wrap: wrap; }
  .char-card { min-width: 110px; }
  .dialogue-line { flex-wrap: wrap; }
  .dl-speaker { width: 60px; font-size: 12px; }

  #orange-mascot { bottom: 12px; right: 12px; }
  #mascot-bubble { max-width: 220px; font-size: 11px; }
}

/* ══════════════════════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════════════════════ */

@media print {
  body {
    background: #fff !important; color: #000 !important;
    font-family: "STSong", "SimSun", "Noto Serif SC", serif !important;
  }
  #topbar, #panel-config, #panel-teaching, #tools-bar,
  #tools-drawer, #orange-mascot, #emotional-resonance,
  #btn-save, #btn-export, #btn-copy, #char-focus-bar,
  #script-tools, #tools-result, #theme-swapper,
  #btn-add-char, #btn-add-scene, #btn-add-dialogue,
  .scene-drag, .scene-toggle, .scene-del, .dl-del {
    display: none !important;
  }
  #script-empty { display: none !important; }
  #script-content { display: block !important; }
  #characters-section { display: block !important; }
  #characters-section[open] summary { display: block; }
  #panel-script {
    border: none !important; background: #fff !important;
    padding: 0 !important; overflow: visible !important;
  }
  .scene-block { break-inside: avoid; border: 1px solid #ccc !important; }
  .scene-body { display: block !important; }
  .dialogue-line { border-bottom: 1px dotted #ccc !important; }
  #script-title { font-size: 24pt !important; }
  #script-badges span { background: #eee !important; color: #333 !important; }
}

/* ══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 滑动抽屉（剧本库/指南）── */
.slide-drawer{position:fixed;top:0;right:0;width:420px;max-width:90vw;height:100vh;z-index:950;background:var(--panel-bg);border-left:1px solid var(--border);box-shadow:-8px 0 30px rgba(0,0,0,0.2);display:flex;flex-direction:column;overflow:hidden;animation:slideRight .25s ease-out;}
.drawer-header{display:flex;align-items:center;gap:8px;padding:14px 18px;border-bottom:1px solid var(--border);flex-shrink:0;}
.drawer-header h2{font-size:16px;flex:1;}
.drawer-close{background:none;border:none;color:var(--text-muted);font-size:22px;cursor:pointer;padding:0 4px;}
.drawer-close:hover{color:var(--accent);}
#library-drawer #lib-list{flex:1;overflow-y:auto;padding:14px 18px;}
#library-drawer #lib-count{font-size:12px;color:var(--text-muted);}
#guide-drawer #guide-content{flex:1;overflow-y:auto;padding:14px 18px;}
#topbar-actions{display:flex;gap:2px;margin-left:8px;}
#topbar-actions button{background:none;border:1px solid transparent;border-radius:6px;color:var(--text-muted);cursor:pointer;font-size:16px;padding:4px 8px;transition:all .15s;}
#topbar-actions button:hover{color:var(--text);background:var(--card-bg);border-color:var(--border);}

/* 舞台预设 — 横向卡片 */
#stage-presets { position:relative; z-index:1; margin-top:var(--space-md); }
.presets-horizontal { display:flex; gap:8px; flex-wrap:wrap; justify-content:center; }
.presets-horizontal .preset-card {
  background:var(--card-bg); border:1px solid var(--border);
  border-radius:var(--radius-md); padding:10px 16px; cursor:pointer;
  font-size:13px; white-space:nowrap; transition:all var(--transition-fast);
  font-family:var(--font-ui);
}
.presets-horizontal .preset-card:hover {
  border-color:var(--accent2); transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,0.1);
}
.presets-horizontal .pc-title { font-weight:600; }
.presets-horizontal .pc-meta { display:none; }

/* ── 对话式创作台 ── */
#grill-toggle input { margin:0; accent-color:var(--accent2); }
#btn-voice { background:none; border:1px solid var(--border); border-radius:4px; cursor:pointer; padding:3px 8px; font-size:14px; }
#voice-status { font-size:12px; color:var(--accent); }
#chat-messages { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.chat-msg { display:flex; max-width:85%; }
.chat-msg.user { align-self:flex-end; }
.chat-msg.assistant { align-self:flex-start; }
.chat-bubble { padding:10px 14px; border-radius:12px; font-size:13px; line-height:1.7; }
.chat-msg.user .chat-bubble { background:var(--accent); color:#fff; border-bottom-right-radius:4px; }
.chat-msg.assistant .chat-bubble { background:var(--card-bg); color:var(--text); border-bottom-left-radius:4px; }
#chat-input-row { display:flex; gap:6px; padding:8px 12px; border-top:1px solid var(--border); flex-shrink:0; }
#chat-input { flex:1; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); color:var(--text); padding:8px 12px; font-size:13px; outline:none; }
#chat-input:focus { border-color:var(--accent2); }
#btn-chat-send { background:var(--accent); color:#fff; border:none; border-radius:50%; width:36px; height:36px; font-size:16px; cursor:pointer; flex-shrink:0; }
#btn-chat-send:disabled { opacity:0.4; }
#chat-hint { text-align:center; font-size:10px; color:var(--text-muted); padding:4px; flex-shrink:0; min-height:16px; }

/* TTS播放按钮 */
.scene-play, .dl-play { background:none; border:none; cursor:pointer; font-size:13px; padding:0 3px; opacity:0.5; transition:opacity .15s; flex-shrink:0; }
.scene-play:hover, .dl-play:hover { opacity:1; }
.scene-play { font-size:15px; margin-right:4px; }

/* 意图预览 */
#intent-preview { min-height:18px; padding:2px 12px; display:flex; gap:4px; align-items:center; flex-shrink:0; }
.intent-tag { font-size:10px; padding:1px 7px; border-radius:8px; background:var(--color-primary-light); color:var(--accent2); font-weight:600; }

/* 输入框自动长高 */
#chat-input { resize:none; overflow-y:auto; min-height:36px; max-height:160px; line-height:1.5; }

/* 文件拖入 */
#file-drop-overlay {
  display:none; position:absolute; inset:0; z-index:10;
  align-items:center; justify-content:center;
  background:rgba(15,171,181,.12); border:3px dashed var(--accent2);
  border-radius:var(--radius-lg); font-size:18px; font-weight:700;
  color:var(--accent2); pointer-events:none;
}

/* TTS进度条 */
#tts-progress{height:3px;background:var(--border);flex-shrink:0;}
#tts-progress-bar{height:100%;width:0;background:var(--accent2);animation:tts-slide 1.5s ease-in-out infinite;}
@keyframes tts-slide{0%{width:0;margin-left:0}50%{width:60%;margin-left:0}100%{width:0;margin-left:100%}}

/* ══════════════════════════════════════════════════════════════
   RIGHT PANEL STATE SYSTEM
   ══════════════════════════════════════════════════════════════ */
.teach-state{display:none;animation:teachFadeIn .35s var(--ease-smooth)}
.teach-state.active{display:block}
@keyframes teachFadeIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.teach-generating{padding:var(--space-md)}
.teach-generating .gen-title{font-size:var(--text-sm);font-weight:var(--font-weight-medium);margin-bottom:var(--space-md);display:flex;align-items:center;gap:6px}
.teach-generating .gen-title .pulse-dot{width:8px;height:8px;border-radius:50%;background:var(--accent);animation:pulseDot 1.2s infinite}
@keyframes pulseDot{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.6)}}
.gen-checklist{list-style:none;padding:0;margin:0}
.gen-checklist li{display:flex;align-items:center;gap:8px;padding:6px 0;font-size:var(--text-sm);color:var(--text-muted);transition:color .3s}
.gen-checklist li .check-icon{width:20px;height:20px;border-radius:50%;border:2px solid var(--border);display:flex;align-items:center;justify-content:center;font-size:11px;transition:all .3s}
.gen-checklist li.done{color:var(--text)}
.gen-checklist li.done .check-icon{background:var(--color-success);border-color:var(--color-success);color:#fff}
.gen-checklist li.active{color:var(--accent);font-weight:var(--font-weight-medium)}
.gen-checklist li.active .check-icon{border-color:var(--accent);animation:pulseDot 1s infinite}
.gen-progress-bar{margin-top:var(--space-md);height:4px;border-radius:2px;background:var(--border);overflow:hidden}
.gen-progress-bar-fill{height:100%;border-radius:2px;background:var(--accent);transition:width .5s var(--ease-smooth)}
.teach-notice{padding:var(--space-md);text-align:center;color:var(--text-muted);font-size:var(--text-sm)}
.teach-notice .notice-icon{font-size:32px;margin-bottom:8px}

/* ══════════════════════════════════════════════════════════════
   TOAST SYSTEM
   ══════════════════════════════════════════════════════════════ */
#toast-container{position:fixed;top:72px;right:20px;z-index:9999;display:flex;flex-direction:column;gap:8px;pointer-events:none}
.toast{pointer-events:auto;display:flex;align-items:center;gap:10px;padding:12px 18px;border-radius:var(--radius-md);background:var(--panel-bg);box-shadow:0 6px 24px rgba(0,0,0,.12);font-size:var(--text-sm);font-weight:var(--font-weight-medium);min-width:200px;max-width:360px;animation:toastSlideIn .35s var(--ease-spring);border-left:4px solid}
.toast.removing{animation:toastSlideOut .25s ease-in forwards}
@keyframes toastSlideIn{from{opacity:0;transform:translateX(80px) scale(.95)}to{opacity:1;transform:translateX(0) scale(1)}}
@keyframes toastSlideOut{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(60px)}}
.toast.success{border-left-color:#4A8C6F}.toast.success .toast-icon{color:#4A8C6F}
.toast.pending{border-left-color:#D4A373}.toast.pending .toast-icon{color:#D4A373}
.toast.error{border-left-color:#C04A3A}.toast.error .toast-icon{color:#C04A3A}
.toast-icon{font-size:18px;flex-shrink:0}
.toast-body{flex:1;color:var(--text)}
.toast-action{font-size:var(--text-xs);color:var(--accent);cursor:pointer;white-space:nowrap;padding:2px 8px;border-radius:4px;transition:background .2s}
.toast-action:hover{background:var(--color-primary-light)}

/* ══════════════════════════════════════════════════════════════
   EMPTY STAGE SCENE (pure CSS)
   ══════════════════════════════════════════════════════════════ */
.empty-stage{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--space-2xl) var(--space-lg);min-height:220px;position:relative;overflow:hidden}
.empty-stage-spotlight{position:absolute;top:-30px;left:50%;transform:translateX(-50%);width:180px;height:280px;background:radial-gradient(ellipse at 50% 0%,rgba(255,240,210,.4) 0%,rgba(255,240,210,.1) 40%,transparent 70%);animation:spotlightFlicker 4s ease-in-out infinite}
@keyframes spotlightFlicker{0%,100%{opacity:.6}50%{opacity:1}}
.empty-stage-curtains{position:absolute;top:0;left:0;right:0;height:30px;background:linear-gradient(180deg,var(--accent) 0%,var(--accent) 60%,transparent 100%);opacity:.15}
.empty-stage-floor{position:absolute;bottom:0;left:0;right:0;height:40%;background:linear-gradient(to bottom,transparent 0%,rgba(139,115,85,.06) 20%,rgba(139,115,85,.2) 100%)}
.empty-stage-chair{position:relative;z-index:2;margin-bottom:var(--space-md);display:flex;flex-direction:column;align-items:center}
.empty-stage-chair .chair-back{width:50px;height:55px;border:3px solid var(--text-muted);border-radius:4px 4px 0 0;opacity:.35}
.empty-stage-chair .chair-seat{width:60px;height:8px;background:var(--text-muted);border-radius:2px;opacity:.3}
.empty-stage-chair .chair-legs{display:flex;justify-content:space-between;width:50px}
.empty-stage-chair .chair-leg{width:4px;height:28px;background:var(--text-muted);border-radius:1px;opacity:.25}
.empty-stage-text{position:relative;z-index:2;font-family:var(--font-display);font-size:var(--text-lg);color:var(--text-muted);text-align:center;line-height:var(--line-height-relaxed)}

/* ══════════════════════════════════════════════════════════════
   PRESET BADGES
   ══════════════════════════════════════════════════════════════ */
.preset-badge{display:inline-block;font-size:10px;padding:1px 6px;border-radius:10px;font-weight:var(--font-weight-bold);text-transform:uppercase;letter-spacing:.5px}
.preset-badge.new{background:var(--accent);color:#fff;animation:badgePulse 2s ease-in-out infinite}
.preset-badge.frequent{background:var(--color-primary-light);color:var(--accent)}
@keyframes badgePulse{0%,100%{opacity:1}50%{opacity:.7}}
.preset-card.preset-frequent{border-left-color:var(--accent)}
.preset-card-header{display:flex;align-items:center;gap:6px;margin-bottom:3px}

/* ══════════════════════════════════════════════════════════════
   SCRIPT SWITCH TRANSITIONS
   ══════════════════════════════════════════════════════════════ */
#script-scenes{transition:opacity .3s var(--ease-smooth),transform .3s var(--ease-smooth)}
#script-scenes.switching-out{opacity:0;transform:translateY(12px)}
#script-scenes.switching-in{animation:scriptSwitchIn .35s var(--ease-smooth)}
@keyframes scriptSwitchIn{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}
#script-meta{transition:opacity .25s var(--ease-smooth)}
#script-meta.switching{opacity:.4}
#script-characters{transition:opacity .3s var(--ease-smooth)}
#script-characters.switching-out{opacity:0}

/* ══════════════════════════════════════════════════════════════
   CHARACTER COLOR SYSTEM
   ══════════════════════════════════════════════════════════════ */
.char-avatar{width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:var(--font-weight-bold);flex-shrink:0}
.char-info{flex:1;min-width:0}
.char-name{font-weight:var(--font-weight-medium);font-size:var(--text-sm)}
.char-role{font-size:var(--text-xs);color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.char-card{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-md);border-radius:var(--radius-md);background:var(--panel-bg);border:1px solid var(--border);transition:all .2s;min-width:140px}
.char-card:hover{border-color:var(--accent2);box-shadow:var(--shadow-card)}
.char-focus-btn{background:none;border:1px solid transparent;border-radius:var(--radius-sm);color:var(--text-muted);cursor:pointer;font-size:13px;padding:2px 6px;transition:all .15s}
.char-focus-btn:hover{border-color:var(--accent2);color:var(--accent2)}

/* ══════════════════════════════════════════════════════════════
   THEME SWITCHER ENHANCED
   ══════════════════════════════════════════════════════════════ */
#theme-swapper{display:flex;gap:6px;align-items:center}
.theme-option{display:flex;flex-direction:column;align-items:center;gap:2px;cursor:pointer;padding:3px 5px;border-radius:var(--radius-sm);transition:all .2s;border:2px solid transparent}
.theme-option.active{border-color:var(--accent);background:var(--color-primary-light)}
.theme-preview-pill{width:32px;height:14px;border-radius:7px;display:flex;overflow:hidden}
.theme-preview-pill .pill-seg{flex:1}
.theme-preview-label{font-size:9px;color:var(--text-muted);white-space:nowrap}
.theme-option.active .theme-preview-label{color:var(--accent);font-weight:var(--font-weight-medium)}
.preview-yuanqu{background:#D15E2A}.theme-globe .preview-yuanqu{background:#D15E2A}.theme-sunshine .preview-yuanqu{background:#D15E2A}
.preview-globe{background:#A04050}.theme-yuanqu .preview-globe{background:#A04050}.theme-sunshine .preview-globe{background:#A04050}
.preview-sunshine{background:#E07A3E}.theme-yuanqu .preview-sunshine{background:#E07A3E}.theme-globe .preview-sunshine{background:#E07A3E}

/* ══════════════════════════════════════════════════════════════
   SEARCH OVERLAY
   ══════════════════════════════════════════════════════════════ */
#global-search-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--color-bg-overlay);z-index:3000;display:flex;justify-content:center;padding-top:15vh;animation:searchOverlayIn .2s ease-out}
@keyframes searchOverlayIn{from{opacity:0}to{opacity:1}}
#global-search-box{width:520px;max-width:90vw;background:var(--panel-bg);border-radius:var(--radius-lg);box-shadow:0 16px 48px rgba(0,0,0,.2);overflow:hidden;max-height:60vh;display:flex;flex-direction:column}
#global-search-input-row{display:flex;align-items:center;padding:var(--space-md);border-bottom:1px solid var(--border);gap:var(--space-sm)}
#global-search-input{flex:1;border:none;background:transparent;font-size:var(--text-lg);outline:none;font-family:inherit;color:var(--text)}
#global-search-close{background:none;border:none;font-size:20px;cursor:pointer;color:var(--text-muted)}
#global-search-results{overflow-y:auto;max-height:400px;padding:var(--space-sm)}
.search-result-item{padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm);cursor:pointer;transition:background .15s;border-left:3px solid transparent}
.search-result-item:hover,.search-result-item.selected{background:var(--color-primary-light);border-left-color:var(--accent)}
.search-result-title{font-weight:var(--font-weight-medium);font-size:var(--text-sm)}
.search-result-preview{font-size:var(--text-xs);color:var(--text-muted)}
.search-no-results{text-align:center;padding:var(--space-xl);color:var(--text-disabled,var(--text-muted))}
#global-search-count{font-size:var(--text-xs);color:var(--text-muted);padding:4px var(--space-md)}

/* ══════════════════════════════════════════════════════════════
   MOBILE TAB BAR
   ══════════════════════════════════════════════════════════════ */
@media(max-width:767px){
  #main-app{flex-direction:column;padding-bottom:64px}
  #panel-config,#panel-teaching{display:none;position:fixed;top:48px;left:0;right:0;bottom:64px;z-index:100;background:var(--bg);overflow-y:auto;padding:var(--space-md)}
  #panel-config.mobile-visible,#panel-teaching.mobile-visible{display:block}
  #panel-script{flex:1;overflow-y:auto;padding-bottom:8px}
  #chat-panel{padding-bottom:72px}
  #stage-hero{padding-bottom:80px}
  #mobile-tab-bar{position:fixed;bottom:0;left:0;right:0;height:64px;background:var(--panel-bg);border-top:1px solid var(--border);display:flex;z-index:200;padding-bottom:env(safe-area-inset-bottom,0)}
  .mobile-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--text-muted);font-size:11px;transition:color .2s;border:none;background:none;cursor:pointer}
  .mobile-tab.active{color:var(--accent)}
  .mobile-tab-icon{font-size:22px}
  #orange-mascot{bottom:80px;right:12px;transform:scale(.85)}
  #toast-container{top:56px;right:8px}
  #toast-container .toast{max-width:260px;font-size:12px}
}
@media(min-width:768px){#mobile-tab-bar{display:none}}

/* ══════════════════════════════════════════════════════════════
   SCRIPT READING — paper typography
   ══════════════════════════════════════════════════════════════ */
#script-scenes{max-width:680px;margin:0 auto;padding:var(--space-xl) var(--space-lg);font-family:var(--font-body);line-height:var(--line-height-relaxed);position:relative}
.scene-card{position:relative;margin-bottom:var(--space-2xl);padding:var(--space-xl) var(--space-lg) var(--space-lg);background:var(--panel-bg);border-radius:4px;box-shadow:0 1px 3px rgba(0,0,0,.04),0 8px 30px rgba(0,0,0,.06),inset 0 0 0 1px rgba(0,0,0,.03)}
.scene-card::after{content:'';position:absolute;bottom:-6px;left:6px;right:6px;height:12px;background:var(--panel-bg);border-radius:0 0 3px 3px;box-shadow:0 4px 12px rgba(0,0,0,.05);z-index:-1;opacity:.6}
.scene-title{font-family:var(--font-display);font-size:var(--text-xl);color:var(--accent);margin-bottom:var(--space-lg);padding-bottom:var(--space-sm);border-bottom:1px dotted var(--border-strong);letter-spacing:.05em}
.dialogue-line{display:grid;grid-template-columns:90px 1fr;gap:var(--space-sm);padding:var(--space-sm) 0;border-left:3px solid transparent;padding-left:var(--space-md);margin-left:calc(-1*var(--space-md) - 3px);transition:border-color .3s,background .3s,transform .2s var(--ease-spring);border-radius:0 6px 6px 0;cursor:default}
.dialogue-line:hover{background:rgba(0,0,0,.015);transform:translateX(2px)}
.dialogue-line.editing{background:rgba(232,112,58,.06);border-left-color:var(--accent)!important;box-shadow:inset 0 0 0 1px rgba(232,112,58,.15);border-radius:0 8px 8px 0}
.dialogue-speaker{font-family:var(--font-display);font-weight:var(--font-weight-bold);font-size:var(--text-sm);text-align:right;padding-top:4px;letter-spacing:.03em}
.dialogue-text{font-size:var(--text-base);line-height:1.9;padding:4px 0;position:relative}
.dialogue-text[contenteditable=true]:focus{outline:none;background:rgba(232,112,58,.04);border-radius:4px;padding:4px 8px;margin:-4px -8px}

/* pivot line — soul line with seal-red glow */
.dialogue-line.pivot-line{position:relative;border-left:3px solid #C04A3A!important;background:linear-gradient(90deg,rgba(192,74,58,.06) 0%,rgba(192,74,58,.02) 60%,transparent 100%);padding:var(--space-md) var(--space-lg);margin:var(--space-md) 0;border-radius:0 8px 8px 0}
.dialogue-line.pivot-line .dialogue-text{font-family:var(--font-display);font-size:var(--text-lg);letter-spacing:.05em}
.dialogue-line.pivot-line::before{content:'◆';position:absolute;left:-11px;top:50%;transform:translateY(-50%);color:#C04A3A;font-size:8px}
.script-epigraph{text-align:center;font-family:var(--font-display);font-size:var(--text-lg);color:var(--text-muted);font-style:italic;padding:var(--space-xl) var(--space-2xl);margin-bottom:var(--space-xl);position:relative;line-height:1.8}
.script-epigraph::before,.script-epigraph::after{content:'"';font-size:48px;color:var(--accent);opacity:.2;font-family:Georgia,serif;position:absolute}
.script-epigraph::before{top:0;left:16px}
.script-epigraph::after{bottom:-20px;right:16px}

/* knowledge tags — seal stamp style */
.knowledge-tag{display:inline-flex;align-items:center;gap:4px;padding:3px 12px;border-radius:3px;font-family:'KaiTi','STKaiti',serif;font-size:var(--text-xs);color:#C04A3A;background:rgba(192,74,58,.06);border:1px solid rgba(192,74,58,.2);position:relative;box-shadow:inset 0 0 0 1px rgba(192,74,58,.08),0 1px 2px rgba(0,0,0,.04)}
.knowledge-tag .tag-source{font-size:9px;color:var(--text-muted);margin-left:2px}
.knowledge-tag.law{color:#4A6B8A;background:rgba(74,107,138,.06);border-color:rgba(74,107,138,.2)}

/* 18 emotion stamps */
.emotion-tag{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;font-family:'KaiTi','STKaiti',serif;font-size:13px;font-weight:var(--font-weight-bold);color:#fff;position:relative;user-select:none;cursor:pointer;transition:all .2s var(--ease-spring);box-shadow:inset 0 1px 3px rgba(255,255,255,.3),inset 0 -2px 4px rgba(0,0,0,.15),0 2px 6px rgba(0,0,0,.1)}
.emotion-tag:hover{transform:scale(1.15) rotate(-5deg)}
.emotion-tag:active{transform:scale(.92)}
.emotion-tag.warm{background:#E8A87C}.emotion-tag.soft{background:#D4A373}.emotion-tag.gold{background:#C9A96E}
.emotion-tag.bright{background:#E8C97C}.emotion-tag.calm{background:#A3C9B7}.emotion-tag.mint{background:#8BBBA5}
.emotion-tag.rose{background:#D4A0A0}.emotion-tag.blue{background:#8BA4C0}.emotion-tag.slate{background:#8B9DAF}
.emotion-tag.dust{background:#B5A898}.emotion-tag.mauve{background:#B898A8}.emotion-tag.amber{background:#E0A860}
.emotion-tag.red{background:#C06A5A}.emotion-tag.grey{background:#8A7A7A}.emotion-tag.plum{background:#9B6B8A}
.emotion-tag.lilac{background:#A08AB8}.emotion-tag.teal{background:#6A8A8A}.emotion-tag.rust{background:#B8705A}
.dialogue-emotion-bubble{display:inline-block;font-size:var(--text-xs);padding:2px 10px;border-radius:12px;background:rgba(0,0,0,.04);color:var(--text-muted);margin-left:6px;font-style:italic;letter-spacing:.03em}

/* ══════════════════════════════════════════════════════════════
   GENERATION STAGE ANIMATION
   ══════════════════════════════════════════════════════════════ */
.generation-stage{position:absolute;inset:0;background:radial-gradient(ellipse at 50% 30%,#2a1f1a 0%,#0d0b09 100%);z-index:10;display:flex;flex-direction:column;align-items:center;justify-content:center;animation:stageDarken .5s ease-out}
@keyframes stageDarken{from{opacity:0}to{opacity:1}}
.generation-curtains{position:absolute;inset:0;display:flex;z-index:11}
.gen-curtain{flex:1;background:linear-gradient(180deg,#5a1a1a 0%,#7B2D3B 30%,#6B2535 70%,#4a1520 100%);position:relative;transition:transform 1.2s cubic-bezier(.7,0,.84,0)}
.gen-curtain.left{transform-origin:left center}
.gen-curtain.right{transform-origin:right center}
.gen-curtain::after{content:'';position:absolute;inset:0;background:repeating-linear-gradient(90deg,transparent,transparent 18px,rgba(0,0,0,.12) 18px,rgba(0,0,0,.12) 20px)}
.curtain-open .gen-curtain.left{transform:scaleX(.08)}
.curtain-open .gen-curtain.right{transform:scaleX(.08)}
.generation-spotlight{position:absolute;top:-40px;left:50%;transform:translateX(-50%);width:200px;height:350px;background:radial-gradient(ellipse at 50% 0%,rgba(255,235,200,.25) 0%,rgba(255,220,170,.06) 45%,transparent 70%);z-index:12;animation:spotlightBreath 3s infinite ease-in-out;pointer-events:none}
@keyframes spotlightBreath{0%,100%{opacity:.5}50%{opacity:1}}
.gen-stage-text{position:relative;z-index:15;text-align:center;color:rgba(255,240,210,.9);font-family:var(--font-display)}
.gen-stage-icon{font-size:48px;margin-bottom:var(--space-md);animation:genIconFloat 2s infinite ease-in-out}
@keyframes genIconFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
.gen-stage-title{font-size:var(--text-lg);letter-spacing:.08em;margin-bottom:4px}
.gen-stage-subtitle{font-size:var(--text-sm);color:rgba(255,240,210,.5);font-style:italic}
.gen-character-peek{position:absolute;bottom:20%;z-index:13;display:flex;gap:40px;opacity:0;transition:all .6s var(--ease-smooth)}
.gen-character-peek.visible{opacity:1;bottom:25%}
.gen-char-card{text-align:center;color:rgba(255,240,210,.8)}
.gen-char-silhouette{width:48px;height:72px;margin:0 auto 8px;background:rgba(255,240,210,.15);border-radius:50% 50% 10% 10%;position:relative;animation:charAppear .5s var(--ease-spring) both}
.gen-char-name{font-size:var(--text-xs);letter-spacing:.05em}
@keyframes charAppear{from{opacity:0;transform:translateY(20px) scale(.8)}to{opacity:1;transform:translateY(0) scale(1)}}

/* ══════════════════════════════════════════════════════════════
   PURE-CSS EMPTY STAGE (replaces char-silhouettes.webp)
   ══════════════════════════════════════════════════════════════ */
.empty-stage-css{position:relative;width:100%;max-width:420px;height:260px;margin:0 auto;overflow:hidden;border-radius:var(--radius-lg);background:radial-gradient(ellipse at 50% 35%,#2a2018 0%,#0f0c08 100%)}
.stage-dust{position:absolute;inset:0;pointer-events:none}
.dust-particle{position:absolute;width:2px;height:2px;background:rgba(255,235,200,.4);border-radius:50%;animation:dustFloat 6s infinite ease-in-out}
@keyframes dustFloat{0%,100%{transform:translateY(0) scale(1);opacity:.4}25%{transform:translateY(-20px) scale(1.8);opacity:.9}50%{transform:translateY(-10px) scale(1);opacity:.5}75%{transform:translateY(-28px) scale(1.4);opacity:.7}}
.empty-spotlight{position:absolute;top:-20px;left:50%;transform:translateX(-50%);width:160px;height:280px;background:radial-gradient(ellipse at 50% 0%,rgba(255,235,200,.2) 0%,rgba(255,220,170,.05) 40%,transparent 70%);animation:spotlightSlow 4s infinite ease-in-out}
@keyframes spotlightSlow{0%,100%{opacity:.6}50%{opacity:1}}
.empty-floor{position:absolute;bottom:0;left:50%;transform:translateX(-50%);width:260px;height:30px;perspective:200px}
.floor-line{position:absolute;bottom:0;left:50%;transform:translateX(-50%) rotateX(60deg);width:100%;height:1px;background:rgba(255,235,200,.08)}
.floor-line:nth-child(2){bottom:12px;width:70%}
.floor-line:nth-child(3){bottom:22px;width:40%}
.empty-chair-css{position:absolute;bottom:45px;left:50%;transform:translateX(-50%);z-index:5}
.chair-backrest{width:44px;height:52px;border:2px solid rgba(255,235,200,.25);border-radius:3px 3px 0 0;margin:0 auto;position:relative}
.chair-backrest::after{content:'';position:absolute;top:8px;bottom:0;left:50%;transform:translateX(-50%);width:1px;background:rgba(255,235,200,.12);box-shadow:-8px 0 0 rgba(255,235,200,.12),8px 0 0 rgba(255,235,200,.12)}
.chair-seat-css{width:52px;height:6px;background:rgba(255,235,200,.18);border-radius:2px;margin:0 auto}
.chair-leg-css{position:absolute;bottom:-28px;width:3px;height:28px;background:rgba(255,235,200,.15);border-radius:1px}
.chair-leg-css.l{left:12px}
.chair-leg-css.r{right:12px}
.empty-main-text{position:absolute;bottom:8px;left:50%;transform:translateX(-50%);z-index:6;font-family:var(--font-display);font-size:var(--text-sm);color:rgba(255,235,200,.6);white-space:nowrap;letter-spacing:.06em}
.empty-sub-text{text-align:center;color:var(--text-muted);font-size:var(--text-xs);margin-top:var(--space-sm)}

/* ══════════════════════════════════════════════════════════════
   MASCOT ACTIVATION
   ══════════════════════════════════════════════════════════════ */
#orange-mascot{position:fixed;bottom:24px;right:24px;z-index:500;display:flex;flex-direction:column;align-items:flex-end;gap:8px;transition:transform .3s var(--ease-spring)}
#orange-mascot:hover{transform:translateY(-4px)}
#mascot-avatar{width:52px;height:52px;border-radius:50%;background:linear-gradient(135deg,#FFB482 0%,#E88944 100%);display:flex;align-items:center;justify-content:center;font-size:30px;cursor:pointer;box-shadow:0 4px 16px rgba(232,112,58,.3);transition:all .3s var(--ease-spring);animation:mascotIdle 3s infinite ease-in-out;position:relative}
#mascot-avatar::before{content:'';position:absolute;inset:4px;border-radius:50%;background:radial-gradient(ellipse at 40% 35%,rgba(255,255,255,.3) 0%,transparent 60%)}
#mascot-avatar::after{content:'🍃';position:absolute;top:-12px;right:2px;font-size:16px;animation:leafWiggle 2s infinite ease-in-out}
@keyframes leafWiggle{0%,100%{transform:rotate(0)}25%{transform:rotate(8deg)}75%{transform:rotate(-5deg)}}
@keyframes mascotIdle{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
#mascot-bubble{max-width:260px;padding:var(--space-sm) var(--space-md);background:var(--panel-bg);border-radius:16px 16px 4px 16px;box-shadow:0 6px 24px rgba(0,0,0,.1);font-size:var(--text-sm);color:var(--text);line-height:1.5;position:relative;animation:bubblePop .4s var(--ease-spring)}
@keyframes bubblePop{from{opacity:0;transform:scale(.8) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}
#mascot-bubble::after{content:'';position:absolute;bottom:0;right:-6px;width:12px;height:12px;background:var(--panel-bg);clip-path:polygon(0 100%,100% 0,100% 100%)}
#mascot-bubble.fading{animation:bubbleFadeOut .5s ease-in forwards}
@keyframes bubbleFadeOut{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9) translateY(-4px)}}

/* ══════════════════════════════════════════════════════════════
   MICRO-INTERACTIONS
   ══════════════════════════════════════════════════════════════ */
.btn-primary{transition:all .2s var(--ease-spring);position:relative}
.btn-primary:active{transform:scale(.96)}
.btn-primary::after{content:'';position:absolute;inset:0;border-radius:inherit;background:rgba(255,255,255,.2);opacity:0;transition:opacity .3s}
.btn-primary:active::after{opacity:1;transition:opacity 0s}
input[type=text]:focus,textarea:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--color-primary-light),0 4px 16px rgba(0,0,0,.04);transition:all .35s var(--ease-smooth)}
.tool-btn{transition:all .2s var(--ease-spring)}
.tool-btn:hover{transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.08)}
.tool-btn:active{transform:translateY(0)}
#save-status{display:inline-flex;align-items:center;gap:6px;font-size:var(--text-xs);color:var(--text-muted);transition:color .3s}
#save-status::before{content:'';width:7px;height:7px;border-radius:50%;background:var(--color-success)}
#save-status.saving::before{background:#D4A373;animation:pulseDot .8s infinite}
#save-status.error::before{background:#C04A3A}
#save-status.saved::before{background:var(--color-success);animation:savedFlash .6s ease-out}
@keyframes savedFlash{0%{box-shadow:0 0 0 0 rgba(74,140,111,.6)}100%{box-shadow:0 0 0 8px rgba(74,140,111,0)}}
.preset-card{transition:all .3s var(--ease-spring);cursor:pointer}
.preset-card:hover{transform:translateY(-3px);box-shadow:0 8px 24px rgba(0,0,0,.1);border-color:var(--accent)}
.preset-card:active{transform:translateY(-1px) scale(.98)}

/* ══════════════════════════════════════════════════════════════
   SCENE MOOD BORDERS + THEME DECORATIONS
   ══════════════════════════════════════════════════════════════ */
.scene-card[data-location=教室]{border-top:3px solid #A3C9B7}
.scene-card[data-location=操场]{border-top:3px solid #D4A373}
.scene-card[data-location=天台]{border-top:3px solid #8BA4C0}
.scene-card[data-location=网络空间]{border-top:3px solid #9B8AB8}
.scene-card[data-location=家里]{border-top:3px solid #E8A87C}
.scene-card[data-location=咨询室]{border-top:3px solid #8BBBA5}
.scene-title::before{content:attr(data-icon);margin-right:6px}
.theme-yuanqu .scene-card{background-image:linear-gradient(rgba(251,247,240,.6) 1px,transparent 1px);background-size:100% 28px}
.theme-globe .scene-card{border-left:2px solid var(--accent2)}
.theme-sunshine .scene-card{border-radius:var(--radius-lg)}

/* ══════════════════════════════════════════════════════════════
   FOCUS MODE
   ══════════════════════════════════════════════════════════════ */
body.focus-mode #panel-config,body.focus-mode #panel-teaching,body.focus-mode #topbar,
body.focus-mode #orange-mascot,body.focus-mode #mobile-tab-bar{display:none!important}
body.focus-mode #panel-script{max-width:780px;margin:0 auto;padding:var(--space-2xl)}
body.focus-mode #main-app{padding:0}
.focus-progress{position:fixed;top:0;left:0;height:3px;background:var(--accent);z-index:9999;transition:width .1s linear}
.focus-exit-btn{position:fixed;top:16px;right:16px;z-index:10000;opacity:0;transition:opacity .3s;background:var(--panel-bg);border:1px solid var(--border);border-radius:var(--radius-md);padding:6px 12px;cursor:pointer;font-size:var(--text-xs);color:var(--text-muted)}
.focus-exit-btn.visible{opacity:1}
body.focus-mode #script-scenes{max-width:680px;margin:0 auto}

/* ══════════════════════════════════════════════════════════════
   WELCOME WIZARD
   ══════════════════════════════════════════════════════════════ */
.welcome-overlay{position:fixed;inset:0;z-index:10000;display:flex;align-items:center;justify-content:center;background:rgba(15,12,8,.85);animation:welcomeDarken .6s ease-out}
@keyframes welcomeDarken{from{opacity:0}to{opacity:1}}
.welcome-card{background:var(--panel-bg);border-radius:var(--radius-lg);padding:var(--space-2xl);max-width:420px;width:90vw;text-align:center;box-shadow:0 24px 64px rgba(0,0,0,.3);animation:welcomeCardIn .5s var(--ease-spring) .2s both}
@keyframes welcomeCardIn{from{opacity:0;transform:translateY(30px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}
.welcome-dot{width:8px;height:8px;border-radius:50%;background:var(--border);transition:all .3s;display:inline-block;margin:0 4px}
.welcome-dot.active{background:var(--accent);width:24px;border-radius:4px}
.welcome-dot.done{background:var(--color-success)}
.welcome-cta{display:flex;flex-direction:column;gap:var(--space-sm);margin-top:var(--space-lg)}
.welcome-choice{display:block;width:100%;padding:10px 16px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg);color:var(--text);cursor:pointer;font-size:var(--text-sm);transition:all .2s;font-family:var(--font-ui)}
.welcome-choice:hover{border-color:var(--accent);background:var(--color-primary-light);color:var(--accent)}

/* ══════════════════════════════════════════════════════════════
   SHORTCUTS PANEL
   ══════════════════════════════════════════════════════════════ */
.shortcuts-overlay{position:fixed;inset:0;z-index:5000;display:flex;align-items:center;justify-content:center;background:var(--color-bg-overlay);animation:fadeIn .2s}
.shortcuts-card{background:var(--panel-bg);border-radius:var(--radius-lg);padding:var(--space-xl);max-width:380px;width:90vw;box-shadow:var(--shadow-elevated)}
.shortcuts-card h3{font-size:var(--text-lg);margin-bottom:var(--space-md);font-family:var(--font-display)}
.shortcuts-grid{display:flex;flex-direction:column;gap:6px}
.shortcut-row{display:flex;justify-content:space-between;align-items:center;padding:4px 0;font-size:13px;border-bottom:1px solid var(--border)}
.shortcut-row kbd{background:var(--bg);border:1px solid var(--border);border-radius:3px;padding:1px 6px;font-size:11px;font-family:monospace;color:var(--accent)}
.shortcut-row span{color:var(--text-muted)}

/* ══════════════════════════════════════════════════════════════
   ENHANCED PRINT
   ══════════════════════════════════════════════════════════════ */
@media print{
  header,aside,#script-toolbar,#tools-bar,#tools-bar-extended,#tools-recommend,
  #tools-result,#save-status-bar,#orange-mascot,#toast-container,
  #stage-hero,#script-empty,.btn-primary,.btn-sm,.btn-xs,
  #char-focus-bar,#mobile-tab-bar,#global-search-overlay,#generation-stage,
  #chat-panel,.slide-drawer,#emotional-resonance,#identity-modal,
  #shortcuts-panel,.welcome-overlay{display:none!important}
  #script-content{display:block!important;max-width:100%;padding:0}
  #main-app{display:block;padding:0}
  #script-title{font-size:24pt;text-align:center;margin-bottom:1cm;border-bottom:2px solid #000;padding-bottom:12pt}
  .scene-card{page-break-before:always;border:none;box-shadow:none;margin-bottom:1cm}
  .scene-card::after{display:none}
  .scene-title{font-size:16pt;border-bottom:1px solid #999;color:#000!important}
  .dialogue-line{grid-template-columns:70pt 1fr;border-left:none;padding-left:0;margin-left:0;page-break-inside:avoid}
  .dialogue-speaker{font-weight:700;color:#000!important}
  .dialogue-text{font-size:11pt;line-height:1.6;color:#000!important}
  .dialogue-line.pivot-line{border-left:3px solid #000!important;background:none!important}
  .dialogue-line.pivot-line::before{display:none}
  @page{margin:2cm}
}

/* ══════════════════════════════════════════════════════════════
   SOUND TOGGLE (bottom-left corner)
   ══════════════════════════════════════════════════════════════ */
#btn-sound-toggle{position:fixed;bottom:24px;left:24px;z-index:499;width:36px;height:36px;border-radius:50%;border:1px solid var(--border);background:var(--panel-bg);color:var(--text-muted);cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;transition:all .2s;box-shadow:0 2px 8px rgba(0,0,0,.06)}
#btn-sound-toggle:hover{border-color:var(--accent2);color:var(--accent2)}
#btn-sound-toggle.muted{color:var(--text-muted);opacity:.5}
@media(max-width:767px){#btn-sound-toggle{bottom:80px;left:12px}}

/* Ask选择题 */
.ask-options{display:flex;flex-direction:column;gap:5px;margin-top:4px;}
.ask-opt-btn{background:var(--card-bg);border:1px solid var(--border);border-radius:6px;color:var(--text);cursor:pointer;font-size:12px;padding:7px 12px;text-align:left;transition:all .15s;font-family:var(--font-ui);}
.ask-opt-btn:hover{border-color:var(--accent2);background:rgba(15,171,181,.08);transform:translateX(3px);}
.ask-opt-btn:active{transform:scale(0.98);}

/* 登录弹窗 */
#login-modal{position:fixed;inset:0;z-index:2000;display:flex;align-items:center;justify-content:center;background:var(--color-bg-overlay,rgba(0,0,0,.5));backdrop-filter:blur(6px)}
#login-card{position:relative;background:var(--panel-bg);border-radius:var(--radius-lg);padding:32px 36px;max-width:380px;width:90%;text-align:center;border:1px solid var(--border);box-shadow:0 12px 48px rgba(0,0,0,.25);font-family:var(--font-ui)}
#login-card h2{font-family:var(--font-display);font-size:20px;margin-bottom:20px;color:var(--text)}
#login-card input{width:100%;padding:10px 14px;margin:8px 0;border:2px solid var(--border);border-radius:var(--radius-sm);background:var(--bg);color:var(--text);font-size:14px;transition:border-color .2s}
#login-card input:focus{border-color:var(--accent);outline:none}
#login-msg{font-size:12px;color:var(--accent);min-height:22px;margin:6px 0}
#btn-login-submit{width:100%;margin-top:12px;padding:12px;font-size:15px;font-weight:600}
#btn-register-submit{margin-top:8px;background:transparent;border:1px solid var(--border);color:var(--text-muted)}
#btn-register-submit:hover{color:var(--accent2);border-color:var(--accent2)}
#btn-login-close{position:absolute;top:10px;right:14px;background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer}
#btn-login-close:hover{color:var(--accent)}
