:root {
  --bg: #080a0e;
  --surface-0: #0c1016;
  --panel: #10151e;
  --panel-2: #161d29;
  --panel-hover: #1c2636;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #edf2f7;
  --muted: #7c8ea6;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.14);
  --accent-2: #f59e0b;
  --purple: #a78bfa;
  --danger: #f43f5e;
  --success: #34d399;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #2b384d transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b384d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #415575; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.ui-ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

/* Range inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(148, 163, 184, 0.24);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -3.5px;
  border-radius: 2px;
  background: var(--accent);
  border: 1px solid #041018;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.45);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(148, 163, 184, 0.24);
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent);
  border: 1px solid #041018;
}

/* Search input icon wrapper */
.input-ico-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-ico-wrap .input-ico {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}
.input-ico-wrap input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px 7px 31px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-ico-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.12);
}

.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  width: 276px;
  min-width: 250px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: margin-left 0.2s ease, transform 0.2s ease;
}
.sidebar.collapsed { margin-left: -276px; }
.app-shell.mode-library .sidebar,
.app-shell.mode-library .sidebar-backdrop,
.app-shell.mode-library #btn-sidebar,
.app-shell.mode-library #episode-breadcrumb,
.app-shell.mode-library .ep-nav-group,
.app-shell.mode-library #btn-prev,
.app-shell.mode-library #btn-next,
.app-shell.mode-library #btn-fav {
  display: none !important;
}
.app-shell.mode-library #topbar-library-brand {
  display: inline-flex !important;
}
.app-shell.mode-static .local-only,
.app-shell.mode-static .local-only-btn {
  display: none !important;
}
.static-disclaimer {
  display: none;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-0);
}
.app-shell.mode-static .static-disclaimer {
  display: block;
}
.topbar-library-brand {
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
  white-space: nowrap;
}
.brand-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.7);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.05) 0%, transparent 100%);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-copy { min-width: 0; }
.brand-tag {
  background: var(--accent);
  color: #041018;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  flex-shrink: 0;
}
.brand-title {
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-0);
}
.cat-tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 2px 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.sidebar-filter { padding: 8px 10px; border-bottom: 1px solid var(--border); }

.group-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.group-item { margin-bottom: 4px; border-radius: 4px; overflow: hidden; }
.group-header {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid transparent;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.group-header:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.group-header-right { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.group-chevron {
  width: 12px;
  height: 12px;
  color: var(--muted);
  transition: transform 0.18s ease;
}
.group-item.open .group-chevron { transform: rotate(90deg); color: var(--accent); }
.group-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.ep-list { padding: 4px 0 4px 8px; display: none; }
.group-item.open .ep-list { display: block; }
.ep-btn {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: none;
  border-left: 2px solid var(--border);
  padding: 5px 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  transition: color 0.12s ease, background 0.12s ease;
}
.ep-btn:hover { color: var(--text); background: rgba(34, 211, 238, 0.06); }
.ep-btn.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(34, 211, 238, 0.12);
  font-weight: 600;
}
.ep-read-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  opacity: 0.85;
}

/* Workspace & Single-Row Topbar */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 44px;
  min-height: 44px;
  background: rgba(16, 21, 30, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  flex-wrap: nowrap;
  z-index: 20;
}
.topbar-left { flex: 1 1 60px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.topbar-center { flex: 0 0 auto; min-width: 0; max-width: 100%; }
.topbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; min-width: 0; }
.ep-nav-group { display: inline-flex; align-items: center; gap: 4px; }

.breadcrumb {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.mode-switch::-webkit-scrollbar { display: none; height: 0; }
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 7px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.14s ease, background 0.14s ease;
}
.mode-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.mode-btn.active {
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.icon-btn, .nav-btn, .primary-btn, .hud-btn, .pack-btn, .chip-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.icon-btn { padding: 5px 7px; }
.icon-btn:hover, .nav-btn:hover, .hud-btn:hover, .pack-btn:hover, .chip-action:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
}
.nav-btn:disabled { opacity: 0.36; cursor: not-allowed; }
.icon-btn.is-fav {
  color: var(--accent-2);
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.12);
}

.primary-btn {
  background: var(--accent);
  color: #041018;
  border-color: var(--accent);
  font-weight: 700;
}
.primary-btn:hover { filter: brightness(1.08); background: var(--accent); }
.kbd-hint {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(4, 16, 24, 0.18);
  border: 1px solid rgba(4, 16, 24, 0.25);
  color: #041018;
}

.hud-btn.accent {
  background: var(--accent);
  color: #041018;
  border-color: var(--accent);
  font-weight: 700;
}
.hud-btn.active { border-color: var(--accent-2); color: var(--accent-2); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Tactical Dot-Grid Surface for Reading & Libraries */
.view-script, .view-gallery, .view-illusts, .view-voices {
  background-color: var(--bg);
  background-image: radial-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Theater Stage */
.view-theater { background: #04060a; }
.stage-outer {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}
.stage-frame {
  position: relative;
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  background: #06090e;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(34, 211, 238, 0.08);
}
.stage-frame::before,
.stage-frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 18;
}
.stage-frame::before {
  top: 6px;
  left: 6px;
  border-top: 2px solid rgba(34, 211, 238, 0.45);
  border-left: 2px solid rgba(34, 211, 238, 0.45);
}
.stage-frame::after {
  bottom: 6px;
  right: 6px;
  border-bottom: 2px solid rgba(34, 211, 238, 0.35);
  border-right: 2px solid rgba(34, 211, 238, 0.35);
}
.stage-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
}
.stage-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.stage-frame.shake { animation: stage-shake 0.35s ease; }
@keyframes stage-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 4px); }
  40% { transform: translate(7px, -4px); }
  60% { transform: translate(-5px, -3px); }
  80% { transform: translate(5px, 3px); }
}

.stage-camera {
  position: absolute; inset: 0;
  transition: filter 0.35s ease;
}
.stage-ambient {
  position: absolute; inset: -20px;
  background-size: cover; background-position: center;
  filter: blur(26px) brightness(0.45);
  opacity: 0.65;
}
.layer-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transition: opacity 0.25s ease;
}
.layer-largebg {
  position: absolute; top: 0; left: 0; height: 100%;
  display: flex; align-items: stretch;
  pointer-events: none; z-index: 2;
}
.layer-largebg img {
  height: 100%; width: auto; flex-shrink: 0; object-fit: cover;
}
.layer-fx {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 6;
}
.layer-cg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: rgba(0, 0, 0, 0.72); z-index: 7;
  transition: opacity 0.25s ease;
}
.layer-curtain {
  position: absolute; inset: 0; background: #000; pointer-events: none; z-index: 8;
  opacity: 0; transition: opacity 0.3s ease;
}
.layer-blocker {
  position: absolute; inset: 0; pointer-events: none; z-index: 8;
  transition: background-color 0.25s ease;
}

.char-stage {
  position: absolute; inset: 0; z-index: 4;
  pointer-events: none;
}
.char-slot {
  position: absolute;
  bottom: 0;
  width: auto;
  height: 94%;
  max-width: 68%;
  object-fit: contain;
  object-position: bottom center;
  transition: filter 0.22s ease, opacity 0.22s ease, transform 0.28s ease;
}
.layer-cutin {
  position: absolute; top: 10%; bottom: 26%; left: 50%;
  width: 24%; max-width: 280px;
  transform: translateX(-50%);
  overflow: hidden;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgba(5, 10, 18, 0.85);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  z-index: 5; pointer-events: none;
}
.layer-cutin img {
  width: 100%; height: 145%; object-fit: cover; object-position: top center;
}
.layer-stickers {
  position: absolute; inset: 0; z-index: 9; pointer-events: none;
}
.sticker-item {
  position: absolute;
  color: #f8fafc;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
  font-size: 17px; line-height: 1.65;
}
.avg-native-hud {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 16;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.native-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(8, 12, 19, 0.82);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 3px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}
.native-pill:hover { border-color: var(--accent); color: var(--accent); }
.native-pill.active {
  background: rgba(34, 211, 238, 0.22);
  border-color: var(--accent);
  color: #fff;
}
.native-pill.accent {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.65);
  color: #fde68a;
}
.native-pill.accent:hover { background: rgba(245, 158, 11, 0.32); color: #fff; }

.char-l { left: 22%; transform: translateX(-50%); }
.char-m { left: 50%; transform: translateX(-50%); }
.char-r { left: 78%; transform: translateX(-50%); }
.char-slot.is-active { filter: brightness(1.03) drop-shadow(0 6px 24px rgba(0, 0, 0, 0.75)); z-index: 5; }
.char-slot.is-dimmed { filter: brightness(0.48) saturate(0.85); z-index: 4; }

.layer-item {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.layer-item img {
  max-width: 34%; max-height: 46%;
  background: rgba(12, 16, 23, 0.88);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
}

.layer-center-text {
  position: absolute; left: 10%; right: 10%; top: 36%; z-index: 9;
  text-align: center;
  font-size: 20px; line-height: 1.7; font-weight: 500;
  color: #f8fafc;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95);
  background: rgba(6, 10, 16, 0.68);
  padding: 14px 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  pointer-events: none;
}

.layer-choices {
  position: absolute; inset: 0; z-index: 12;
  background: rgba(6, 10, 16, 0.58);
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 20px;
}
.choice-btn {
  min-width: min(460px, 88%);
  background: rgba(16, 21, 30, 0.94);
  color: var(--text);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 11px 18px;
  font-size: 14.5px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
.choice-btn:hover { background: var(--accent); color: #041018; font-weight: 700; transform: translateY(-1px); }

/* Dialogue HUD */
.hud-dialogue {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: linear-gradient(to top, rgba(6, 8, 13, 0.96) 54%, rgba(6, 8, 13, 0.8) 84%, transparent);
  padding: 20px 24px 10px;
  display: flex; flex-direction: column; gap: 7px;
}
.hud-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-speaker {
  background: rgba(34, 211, 238, 0.14);
  border-left: 3px solid var(--accent);
  color: #f0fdff;
  padding: 3px 12px;
  font-weight: 700;
  font-size: 14.5px;
  border-radius: 0 3px 3px 0;
}
.hud-branch {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 3px;
}
.hud-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.hud-text {
  font-size: 15.5px;
  line-height: 1.65;
  min-height: 48px;
  max-height: 116px;
  overflow-y: auto;
  color: #f1f5f9;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.92);
  white-space: pre-wrap;
}
.hud-scrubber { display: flex; align-items: center; gap: 10px; }
.beat-counter {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
}
.hud-scrubber input[type="range"] { flex: 1; }

.restore-hud {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(12, 16, 23, 0.88);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.restore-hud:hover { border-color: var(--accent); color: var(--accent); }

/* Collapsible Active Asset Bar */
.active-assets-bar {
  flex-shrink: 0;
  min-height: 40px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.assets-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.assets-toggle-btn:hover { color: var(--text); background: var(--panel-2); }
.assets-toggle-btn svg { transition: transform 0.16s ease; }
.active-assets-bar.is-collapsed .assets-toggle-btn svg { transform: rotate(-90deg); }
.active-assets-bar.is-collapsed { min-height: 32px; padding: 3px 12px; justify-content: space-between; }
.active-assets-bar.is-collapsed .assets-chips { display: none; }
.assets-bar-label { font-size: 12px; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.assets-chips {
  flex: 1;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  align-items: center;
  min-width: 0;
  flex-wrap: nowrap;
}
.pack-btn { flex-shrink: 0; white-space: nowrap; }
.asset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11.5px;
  white-space: nowrap;
}
.asset-chip img { width: 20px; height: 20px; object-fit: cover; border-radius: 2px; background: #000; }
.chip-action { padding: 2px 6px; font-size: 11px; }

/* Script Storyboard & Galleries */
.view-script, .view-gallery, .view-illusts { overflow-y: auto; padding: 16px 20px; }
.script-container, .gallery-container { max-width: 1120px; margin: 0 auto; width: 100%; }

/* Illusts Toolbar */
.illust-toolbar {
  position: sticky;
  top: -16px;
  z-index: 10;
  max-width: 1120px;
  margin: 0 auto 16px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: rgba(16, 21, 30, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
}
.toolbar-search-wrap { flex: 1 1 240px; min-width: 0; }
.illust-filters { display: flex; gap: 5px; flex-wrap: wrap; }
.illust-filter-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}
.illust-filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.illust-filter-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}
.illust-stats { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-left: auto; }
.illust-op-section { margin-bottom: 22px; }
.illust-op-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  padding: 0 2px 7px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.illust-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
}
.illust-thumb-wrap {
  position: relative;
  cursor: zoom-in;
  overflow: hidden;
  background: repeating-conic-gradient(#10151f 0% 25%, #161d2b 0% 50%) 50% / 16px 16px;
}
.illust-card .illust-thumb-wrap img {
  width: 100%;
  height: 215px;
  object-fit: contain;
  display: block;
  transition: transform 0.22s ease;
}
.illust-card:hover .illust-thumb-wrap img { transform: scale(1.035); }
.illust-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.badge-e2 { background: rgba(245, 158, 11, 0.92); color: #05111a; }
.badge-skin { background: rgba(167, 139, 250, 0.92); color: #0e0720; }
.badge-base { background: rgba(34, 211, 238, 0.88); color: #041018; }
.illust-more-wrap { display: flex; justify-content: center; padding: 14px 0 24px; }

/* Upgraded Lightbox */
.modal-lightbox-card { width: min(1020px, 96vw); max-height: 92vh; }
.lightbox-head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lb-bg-group {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}
.lb-bg-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.lb-bg-btn.active { background: var(--panel-2); color: var(--accent); font-weight: 600; }
.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 14px;
}
.lightbox-stage.bg-checker { background: repeating-conic-gradient(#10151f 0% 25%, #161d2b 0% 50%) 50% / 20px 20px; }
.lightbox-stage.bg-dark { background: #05070a; }
.lightbox-stage.bg-light { background: #cbd5e1; }
.lightbox-stage img { max-width: 100%; max-height: 70vh; object-fit: contain; transition: transform 0.15s ease; }
.lightbox-stage.is-actual { align-items: flex-start; justify-content: flex-start; }
.lightbox-stage.is-actual img { max-width: none; max-height: none; cursor: zoom-out; }
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 52px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: rgba(12, 16, 23, 0.78);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}
.lightbox-nav:hover { border-color: var(--accent); color: var(--accent); background: rgba(16, 21, 30, 0.94); }
.lightbox-nav.prev { left: max(16px, calc(50vw - 490px)); }
.lightbox-nav.next { right: max(16px, calc(50vw - 490px)); }
.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
}
.lightbox-path { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.lightbox-actions { display: flex; gap: 7px; }

.synopsis-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.synopsis-card h2 { margin: 0 0 8px; font-size: 17px; }
.synopsis-card p { margin: 0; color: var(--muted); line-height: 1.65; }

.script-scene-banner {
  margin: 16px 0 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.script-scene-banner img {
  width: 100%; max-height: 360px; object-fit: contain; display: block; background: #05070b;
}
.script-scene-caption {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 12px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border);
}

.script-line {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.script-line:hover { background: var(--panel); border-color: var(--border); }
.script-line.is-current { background: rgba(34, 211, 238, 0.1); border-color: var(--accent); }
.script-avatar {
  width: 46px; height: 46px; border-radius: 5px;
  object-fit: cover; object-position: top center;
  background: #090d13; border: 1px solid var(--border); flex-shrink: 0;
}
.script-avatar.placeholder { visibility: hidden; }
.script-body { flex: 1; min-width: 0; }
.script-speaker { font-weight: 700; color: var(--accent); font-size: 13px; margin-bottom: 3px; }
.script-speaker.narrator { color: var(--accent-2); }
.script-text { line-height: 1.65; white-space: pre-wrap; color: var(--text); }
.script-tag {
  display: inline-block; font-size: 11px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; margin-right: 6px; color: #fde68a;
}

/* Gallery */
.gallery-section { margin-bottom: 22px; }
.gallery-section h3 { margin: 0 0 10px; font-size: 14.5px; color: var(--accent); letter-spacing: 0.02em; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px;
}
.gallery-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.gallery-card:hover {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
}
.gallery-card img {
  width: 100%; height: 150px; object-fit: contain;
  background: repeating-conic-gradient(#10151f 0% 25%, #161d2b 0% 50%) 50% / 16px 16px;
}
.gallery-meta { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.gallery-name { word-break: break-all; color: var(--text); font-weight: 600; }
.gallery-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* Modals & Toast */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 6, 11, 0.8);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  width: min(680px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72);
  animation: modal-in 0.15s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-card.modal-wide { width: min(860px, 100%); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 15px; border-bottom: 1px solid var(--border);
}

/* Auto-Sync Header Button & Modal */
.sync-btn { position: relative; gap: 4px; }
.sync-label { font-size: 11.5px; }
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.85);
}
.sync-btn.has-update {
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
}
.sync-btn.is-running {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.sync-btn.is-running .sync-ico {
  animation: sync-spin 1.1s linear infinite;
}
.sync-btn.is-running .sync-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.9);
}
@keyframes sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sync-modal-body { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }
.sync-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 8px;
}
.sync-stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
}
.sync-stat-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.sync-stat-val {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.sync-stat-val.is-ok { color: var(--success); }
.sync-stat-val.is-update { color: var(--accent-2); }
.sync-stat-val.is-running { color: var(--accent); }
.sync-stat-val.is-err { color: var(--danger); }

.sync-delta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.sync-delta-card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sync-delta-card.has-delta {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.08);
}
.sync-delta-name { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.sync-delta-num { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--text); }
.sync-delta-card.has-delta .sync-delta-num { color: var(--accent-2); }
.sync-delta-sub { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.sync-samples {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  max-height: 74px;
  overflow-y: auto;
}
.sync-config-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sync-config-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-config-label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sync-config-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
.sync-config-row input[type="text"]:focus { border-color: var(--accent); }
.sync-checks-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.sync-progress-wrap {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sync-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.sync-progress-pct { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.sync-progress-track {
  width: 100%;
  height: 7px;
  background: rgba(148, 163, 184, 0.16);
  border-radius: 3px;
  overflow: hidden;
}
.sync-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, var(--accent));
  transition: width 0.25s ease;
}
.sync-log-box {
  margin: 0;
  padding: 8px 10px;
  background: #05070b;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: #cbd5e1;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.sync-modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.modal-header h3 { margin: 0; font-size: 14px; font-family: var(--mono); letter-spacing: 0.03em; }
.search-bar-wrap { padding: 12px 16px 6px; }
.search-status { padding: 0 16px 10px; font-size: 12px; color: var(--muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.search-item, .backlog-item {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 5px;
  margin-bottom: 8px; background: var(--panel-2);
}
.search-item { cursor: pointer; transition: border-color 0.12s ease; }
.search-item:hover { border-color: var(--accent); background: var(--panel-hover); }
.search-item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--accent); margin-bottom: 4px; font-weight: 600; }
.search-snippet { font-size: 13px; color: var(--text); line-height: 1.5; }
mark { background: rgba(245, 158, 11, 0.32); color: #fef08a; padding: 0 2px; border-radius: 2px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(12, 18, 28, 0.96);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 16px;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.mobile-only { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 25; }

/* Dynamic Spine Viewer */
.view-dynchars { flex: 1; min-height: 0; padding: 0; background: var(--bg); }
.dyn-layout { display: flex; height: 100%; min-height: 0; }
.dyn-sidebar {
  width: 268px; flex-shrink: 0;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.dyn-search-box { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.dyn-filter-row { display: flex; gap: 4px; }
.dyn-filter-btn {
  flex: 1; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font-size: 12px; cursor: pointer;
}
.dyn-filter-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); font-weight: 600; }
.dyn-stats { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.dyn-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.dyn-item-btn {
  width: 100%; text-align: left; background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: 4px; padding: 7px 9px; cursor: pointer; margin-bottom: 3px;
}
.dyn-item-btn:hover { background: var(--panel-2); border-color: var(--border); }
.dyn-item-btn.active { background: var(--accent-dim); border-color: var(--accent); }
.dyn-item-title { font-size: 12.5px; font-weight: 600; }
.dyn-item-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }

.dyn-stage-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.dyn-canvas-box { position: relative; flex: 1; min-height: 260px; overflow: hidden; }
.dyn-canvas-box.bg-checker { background: repeating-conic-gradient(#10151f 0% 25%, #161d2b 0% 50%) 50% / 20px 20px; }
.dyn-canvas-box.bg-dark { background: radial-gradient(circle at center, #182131 0%, #070a10 100%); }
.dyn-canvas-box.bg-green { background: #00b140; }
.dyn-canvas-box.bg-black { background: #000; }
#spine-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#spine-canvas:active { cursor: grabbing; }
.dyn-stage-info {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 6;
  pointer-events: none;
  background: rgba(8, 12, 19, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
}
.dyn-overlay-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px; text-align: center; color: #e2e8f0; background: rgba(6, 10, 16, 0.58); pointer-events: none;
}
.dyn-rec-badge {
  position: absolute; top: 10px; right: 12px;
  background: rgba(244, 63, 94, 0.92); color: #fff; font-weight: 700; font-size: 11.5px;
  font-family: var(--mono);
  padding: 4px 10px; border-radius: 4px;
}
.dyn-controls {
  background: var(--panel); border-top: 1px solid var(--border);
  padding: 8px 12px; display: flex; flex-direction: column; gap: 7px;
}
.dyn-ctrl-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.dyn-ctrl-label { font-size: 11.5px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.dyn-ctrl-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }
.dyn-pill-group { display: flex; gap: 5px; flex-wrap: wrap; }
.dyn-pill {
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 9px; font-size: 11.5px; cursor: pointer;
}
.dyn-pill:hover { color: var(--text); border-color: var(--border-strong); }
.dyn-pill.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); font-weight: 600; }

.dyn-bg-swatches { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.dyn-bg-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}
.dyn-bg-btn.swatch-checker { background: repeating-conic-gradient(#1c2536 0% 25%, #2a3750 0% 50%) 50% / 8px 8px; }
.dyn-bg-btn.swatch-dark { background: radial-gradient(circle, #223049, #080b12); }
.dyn-bg-btn.swatch-green { background: #00b140; }
.dyn-bg-btn.swatch-black { background: #000; }
.dyn-bg-btn.active { border: 2px solid var(--accent); box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.25); }

.dyn-zoom-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.dyn-zoom-label input { width: 100px; }
.dyn-zoom-val { font-family: var(--mono); font-size: 11px; color: var(--accent); min-width: 38px; }
.dyn-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 7px; font-family: var(--mono); font-size: 11.5px;
}
.dyn-btn-cluster { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }

/* Operator Voice Library */
.view-voices {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.voice-toolbar {
  flex-shrink: 0;
  padding: 10px 18px;
  background: rgba(16, 21, 30, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.voice-pill-group {
  display: inline-flex;
  gap: 3px;
  background: var(--bg);
  padding: 2px;
  border-radius: 5px;
  border: 1px solid var(--border);
}
.voice-cat-btn, .voice-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.voice-cat-btn:hover, .voice-lang-btn:hover { color: var(--text); }
.voice-cat-btn.active, .voice-lang-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.42);
  font-weight: 600;
}
.voice-check-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.voice-scroll-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px 28px;
}
.voice-grid-root {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.voice-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.voice-op-card {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.16s ease;
}
.voice-op-card:hover { border-color: var(--border-strong); }
.voice-op-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.voice-op-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.voice-op-name { font-weight: 700; font-size: 14.5px; color: var(--text); }
.voice-op-code { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.voice-meta-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}
.voice-meta-pill.accent { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.voice-lines-list { display: flex; flex-direction: column; }
.voice-line-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  transition: background 0.14s ease;
}
.voice-line-row:last-child { border-bottom: none; }
.voice-line-row.is-playing {
  background: rgba(34, 211, 238, 0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.voice-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.1s ease;
}
.voice-play-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: scale(1.04);
}
.voice-play-btn.playing {
  background: var(--accent);
  color: #041018;
  border-color: var(--accent);
}
.voice-play-btn:disabled { opacity: 0.34; cursor: not-allowed; }
.voice-line-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.voice-line-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.voice-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
}
.voice-badge.badge-bday { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.voice-badge.badge-holiday { background: rgba(244, 63, 94, 0.16); color: #fda4af; }
.voice-badge.badge-extra { background: rgba(167, 139, 250, 0.18); color: #c4b5fd; }
.voice-id-code { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.voice-offline-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
}
.voice-line-text {
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--text);
  white-space: pre-wrap;
}
.voice-line-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.voice-lang-group, .voice-action-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.voice-lang-pill {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 9px;
  font-size: 11.5px;
  cursor: pointer;
}
.voice-lang-pill.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.voice-lang-pill.missing { opacity: 0.28; cursor: not-allowed; }
.voice-dl-link { text-decoration: none; display: inline-flex; align-items: center; }

/* Animated 3-bar Equalizer */
.eq-bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.voice-line-row.is-playing .eq-bars,
.eq-bars.eq-live {
  display: inline-flex;
}
.eq-bars i {
  display: block;
  width: 2.5px;
  height: 4px;
  background: var(--accent);
  border-radius: 1px;
  animation: eq-bounce 0.8s ease-in-out infinite alternate;
}
.eq-bars i:nth-child(2) { animation-delay: 0.2s; height: 10px; }
.eq-bars i:nth-child(3) { animation-delay: 0.4s; height: 6px; }
@keyframes eq-bounce {
  0% { transform: scaleY(0.35); }
  100% { transform: scaleY(1); }
}

.voice-player-bar {
  flex-shrink: 0;
  background: rgba(16, 21, 30, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--accent);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.voice-now-meta { flex: 1; min-width: 200px; overflow: hidden; }
.voice-now-head { display: flex; align-items: center; gap: 8px; }
.voice-now-title { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.voice-now-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.voice-now-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#voice-now-seek { width: 150px; }

/* Compact right-side labels when workspace width is < 1360px so all 6 mode tabs fit unclipped */
@media (max-width: 1360px) {
  .kbd-hint { display: none; }
  .ep-nav-group .nav-label { display: none; }
  .ep-nav-group .nav-btn { padding: 4px 6px; }
  .sync-label { display: none; }
}

@media (max-width: 700px) {
  .topbar { height: auto; min-height: 40px; flex-wrap: wrap; row-gap: 5px; padding: 5px 10px; }
  .topbar-left { flex: 1 1 110px; }
  .topbar-right { flex: 0 0 auto; }
  .topbar-center { order: 3; width: 100%; display: flex; justify-content: center; }
}

@media (max-width: 820px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; }
  .sidebar.collapsed { margin-left: 0; transform: translateX(-100%); }
  .mobile-only { display: inline-flex; }
  .breadcrumb { max-width: 48vw; }
}

@media (max-height: 620px) {
  .topbar { height: 38px; min-height: 38px; padding: 0 10px; gap: 6px; }
  .mode-btn { padding: 3px 7px; font-size: 11.5px; gap: 4px; }
  .mode-btn .ui-ico { width: 12px; height: 12px; }
  .icon-btn, .nav-btn, .primary-btn { padding: 3px 7px; font-size: 11.5px; }

  .view-theater { overflow-y: auto; display: block; }
  .stage-outer {
    container-type: normal;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: visible;
    padding: 4px 8px;
    height: auto;
    flex: none;
  }

  .view-voices { overflow-y: auto; display: block; }
  .voice-toolbar { padding: 7px 12px; gap: 6px; }
  .voice-scroll-wrap { overflow: visible; height: auto; padding: 10px 12px 20px; }
  .voice-player-bar { position: sticky; bottom: 0; z-index: 15; padding: 6px 12px; }
}

@media (max-height: 620px) and (min-width: 641px) {
  .stage-frame {
    width: min(100%, calc((100vh - 82px) * 16 / 9));
    height: auto;
    aspect-ratio: 16 / 9;
    min-height: 260px;
    max-width: 100%;
    max-height: none;
    margin: 0 auto;
  }
  .stage-canvas { position: absolute; inset: 0; }
  .hud-dialogue { padding: 10px 14px 6px; gap: 4px; }
  .hud-btn { padding: 2px 7px; font-size: 11px; }
  .hud-speaker { padding: 2px 8px; font-size: 12.5px; }
  .hud-text { font-size: 13px; line-height: 1.45; min-height: 32px; max-height: 76px; }
  .avg-native-hud { top: 6px; right: 8px; gap: 4px; }
  .native-pill { padding: 2px 6px; font-size: 10.5px; }
  .active-assets-bar { padding: 3px 10px; min-height: 32px; flex-wrap: nowrap; }

  .dyn-layout { flex-direction: row; height: 100%; }
  .dyn-sidebar { width: 216px; max-height: none; border-right: 1px solid var(--border); border-bottom: none; }
  .dyn-canvas-box { min-height: 180px; }
  .dyn-controls { padding: 5px 10px; gap: 4px; }
}

@media (max-width: 640px) {
  .view-theater { overflow-y: auto; display: block; }
  .stage-outer { container-type: normal; display: block; overflow: visible; padding: 6px; height: auto; flex: none; }
  .stage-frame {
    width: 100%;
    aspect-ratio: auto;
    min-height: 0;
    max-height: none;
    max-width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .stage-canvas {
    position: relative;
    inset: auto;
    width: 100%;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
  }
  .hud-dialogue {
    position: static;
    background: var(--panel);
    padding: 10px;
    border-top: 1px solid var(--border);
  }
  .hud-text { font-size: 14px; max-height: 200px; }
  .avg-native-hud { top: 6px; right: 6px; gap: 4px; }
  .native-pill { padding: 3px 6px; font-size: 10.5px; }
  .active-assets-bar { padding: 6px 10px; flex-wrap: wrap; gap: 6px; }
  .assets-chips { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .pack-btn { width: 100%; text-align: center; }

  .view-dynchars { overflow-y: auto; }
  .dyn-layout { flex-direction: column; height: auto; min-height: 100%; }
  .dyn-sidebar { width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .dyn-stage-wrap { flex: 0 0 auto; min-height: auto; }
  .dyn-canvas-box { flex: 0 0 auto; height: 46vh; min-height: 260px; }
  .dyn-controls { flex-shrink: 0; padding-bottom: 18px; }
  .dyn-btn-cluster { margin-left: 0; }
  .voice-toolbar { padding: 10px 12px; }
  .voice-scroll-wrap { padding: 12px 12px 24px; }
}

@media (max-width: 520px) {
  .topbar-right { width: 100%; justify-content: space-between; }
  .breadcrumb { max-width: 100%; }
  .sync-delta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
