/* ============================================================
   梵子编剧工作台 v2 — Editorial Studio Design System
   Warm Ivory Light Theme (default) + Warm Charcoal Dark Theme
   ============================================================ */

:root,
[data-theme="light"] {
  --bg: #f7f6f2;
  --bg-subtle: #f0eee8;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-hover: #f3f1eb;
  --border: rgba(24, 24, 27, 0.08);
  --border-strong: rgba(24, 24, 27, 0.14);
  --text: #18181b;
  --text-secondary: #52525b;
  --muted: #71717a;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-ring: rgba(79, 70, 229, 0.22);

  --warm: #d97706;
  --warm-soft: rgba(217, 119, 6, 0.11);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.11);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);

  --user-bubble: #eef2ff;
  --user-bubble-border: rgba(79, 70, 229, 0.18);
  --rail-bg: #141418;
  --rail-text: #a1a1aa;
  --rail-active-bg: rgba(255, 255, 255, 0.12);
  --rail-active-text: #ffffff;

  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 4px 16px rgba(24, 24, 27, 0.05), 0 1px 2px rgba(24, 24, 27, 0.03);
  --shadow-md: 0 12px 32px rgba(24, 24, 27, 0.08), 0 2px 6px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 24px 60px rgba(24, 24, 27, 0.14);
}

[data-theme="dark"] {
  --bg: #131316;
  --bg-subtle: #1a1a1f;
  --surface: #1d1d22;
  --surface-2: #24242b;
  --surface-hover: #292932;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f4f4f5;
  --text-secondary: #d4d4d8;
  --muted: #8e8e98;

  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --accent-ring: rgba(129, 140, 248, 0.28);

  --warm: #fbbf24;
  --warm-soft: rgba(251, 191, 36, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --user-bubble: #262947;
  --user-bubble-border: rgba(129, 140, 248, 0.28);
  --rail-bg: #0c0c0f;
  --rail-text: #8e8e98;
  --rail-active-bg: rgba(129, 140, 248, 0.2);
  --rail-active-text: #ffffff;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.full { width: 100%; }
.muted { color: var(--muted); }

/* ==================== Shared Controls ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 8px 15px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); transform: translateY(-0.5px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px var(--accent-ring);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 6px 18px var(--accent-ring); }
.btn.soft { background: var(--bg-subtle); border-color: transparent; color: var(--text); }
.btn.soft:hover { background: var(--surface-hover); border-color: var(--border); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger:hover { filter: brightness(0.95); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn.lg { padding: 11px 18px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.pill-btn, .pill-select {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-subtle); border: 1px solid transparent; color: var(--text-secondary);
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s ease; font-family: inherit;
}
.pill-btn:hover, .pill-select:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.pill-select { outline: none; max-width: 240px; }
.pill-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.search-pill {
  background: var(--bg-subtle); border: 1px solid transparent; color: var(--text);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; outline: none; width: 100%;
  transition: all 0.16s ease;
}
.search-pill.lg { max-width: 340px; background: var(--surface); border-color: var(--border); }
.search-pill:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.subtle-input, .text-input, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.subtle-input:focus, .text-input:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented {
  display: inline-flex; background: var(--bg-subtle); padding: 4px; border-radius: 12px; gap: 4px;
}
.segmented.sm { padding: 3px; border-radius: 10px; }
.seg-btn {
  border: none; background: transparent; color: var(--muted); padding: 7px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.segmented.sm .seg-btn { padding: 5px 12px; font-size: 12px; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); font-weight: 600; }

.micro-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-subtle); color: var(--muted); font-weight: 500;
}
.context-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-ring);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.context-pill:hover { filter: brightness(0.95); }
.toggle-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary);
  cursor: pointer; user-select: none;
}

.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6 55%, #ec4899);
  color: #fff; font-weight: 800; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35); flex-shrink: 0;
}
.brand-mark.lg { width: 46px; height: 46px; font-size: 20px; border-radius: 14px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 9px;
  border-radius: 999px; background: var(--bg-subtle); color: var(--text-secondary); font-weight: 500;
}
.tag.info { background: var(--accent-soft); color: var(--accent); }
.tag.gold { background: var(--warm-soft); color: var(--warm); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.err { background: var(--danger-soft); color: var(--danger); }
.tag.clickable { cursor: pointer; }
.tag.clickable:hover { filter: brightness(0.92); }

/* ==================== Auth Screen ==================== */
.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; overflow-y: auto;
}
.auth-ambient {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 18% 20%, rgba(79, 70, 229, 0.14), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(217, 119, 6, 0.11), transparent 44%);
}
.auth-shell {
  position: relative; z-index: 1; width: 100%; max-width: 980px;
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 40px; align-items: center;
}
.hero-pill {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px;
}
.auth-hero h1 { font-size: 36px; line-height: 1.22; letter-spacing: -0.025em; margin: 0 0 14px; }
.hero-desc { color: var(--text-secondary); font-size: 15px; margin: 0 0 28px; max-width: 460px; }
.hero-features { display: flex; flex-direction: column; gap: 14px; }
.hero-feat {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs);
}
.hero-feat span { font-size: 20px; line-height: 1; margin-top: 2px; }
.hero-feat b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.hero-feat small { color: var(--muted); font-size: 12px; }

.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 30px; box-shadow: var(--shadow-lg);
}
.auth-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.auth-card-head h2 { margin: 0; font-size: 20px; }
.auth-card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.auth-card .segmented { width: 100%; margin-bottom: 18px; }
.auth-card .seg-btn { flex: 1; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.field input {
  background: var(--bg-subtle); border: 1px solid transparent; border-radius: 11px;
  padding: 11px 13px; color: var(--text); font-size: 14px; outline: none; transition: all 0.15s;
}
.field input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; }

/* ==================== App Shell & Slim Nav Rail ==================== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.nav-rail {
  width: 68px; flex-shrink: 0; background: var(--rail-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 14px 8px; z-index: 20;
}
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 8px; }
.rail-btn {
  width: 100%; border: none; background: transparent; color: var(--rail-text);
  padding: 9px 4px; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; transition: all 0.16s ease;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.rail-btn.active { background: var(--rail-active-bg); color: var(--rail-active-text); }

.rail-mini-btn {
  width: 36px; height: 36px; border-radius: 10px; border: none; background: rgba(255, 255, 255, 0.06);
  color: #e4e4e7; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: background 0.15s;
}
.rail-mini-btn:hover { background: rgba(255, 255, 255, 0.14); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: #34d399; box-shadow: 0 0 10px #34d399; }
.status-dot.offline { background: #71717a; }

.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.view-pane { display: none; flex: 1; overflow: hidden; }
.view-pane.active { display: flex; flex-direction: column; }

/* ==================== View 1: Chat Studio ==================== */
.chat-shell { display: flex; flex: 1; overflow: hidden; }
.chat-drawer {
  width: 288px; flex-shrink: 0; background: var(--surface-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.drawer-head { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.drawer-brand { display: flex; align-items: center; justify-content: space-between; }
.drawer-brand h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.drawer-search-row { display: flex; gap: 6px; align-items: center; }

.session-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; display: flex; flex-direction: column; gap: 3px; }
.project-group-title {
  font-size: 11px; font-weight: 600; color: var(--muted); padding: 10px 8px 4px;
  display: flex; justify-content: space-between; align-items: center;
}
.project-group-ops button {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 2px 4px; border-radius: 5px;
}
.project-group-ops button:hover { background: var(--surface-hover); color: var(--text); }

.session-item {
  padding: 9px 11px; border-radius: 11px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  transition: background 0.14s ease;
}
.session-item:hover { background: var(--surface-hover); }
.session-item.active { background: var(--surface); box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.session-item-main { min-width: 0; flex: 1; }
.session-item-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.session-item-ops { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.session-item:hover .session-item-ops, .session-item.active .session-item-ops { opacity: 1; }
.session-item-ops button {
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 3px 5px; border-radius: 6px; font-size: 12px;
}
.session-item-ops button:hover { background: var(--bg-subtle); color: var(--text); }

.chat-canvas-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); position: relative; }
.canvas-header {
  height: 58px; flex-shrink: 0; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.canvas-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.canvas-title-group h1 {
  margin: 0; font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.canvas-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-pill { font-size: 12px; color: var(--text-secondary); padding: 4px 10px; border-radius: 999px; background: var(--bg-subtle); }

.mentor-banner {
  background: var(--warm-soft); border-bottom: 1px solid rgba(217, 119, 6, 0.2);
  padding: 10px 24px; font-size: 12.5px; color: var(--warm);
}

.chat-video-drawer {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 24px; max-height: 240px; overflow-y: auto; box-shadow: var(--shadow-xs);
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px 24px 16px;
  display: flex; flex-direction: column; gap: 22px;
}

/* Creative Welcome Hero inside empty chat */
.welcome-hero {
  margin: auto; width: 100%; max-width: 720px; text-align: center; padding: 24px 12px;
}
.welcome-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; margin-bottom: 14px;
}
.welcome-hero h2 { font-size: 28px; font-weight: 750; letter-spacing: -0.025em; margin: 0 0 8px; }
.welcome-hero p { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.starter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; text-align: left; }
.starter-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 15px 16px; cursor: pointer; transition: all 0.18s ease; box-shadow: var(--shadow-xs);
}
.starter-card:hover {
  border-color: var(--accent-ring); transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.starter-card-icon { font-size: 20px; margin-bottom: 6px; }
.starter-card b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.starter-card span { font-size: 12px; color: var(--muted); }

/* Editorial Message Stream */
.msg-row { width: 100%; max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; }
.msg-row.user { align-items: flex-end; }
.msg-row.assistant { align-items: flex-start; }
.msg-meta {
  font-size: 11.5px; color: var(--muted); margin-bottom: 5px; display: flex; align-items: center; gap: 8px;
}
.msg-row.user .msg-bubble {
  max-width: 82%; background: var(--user-bubble); border: 1px solid var(--user-bubble-border);
  padding: 11px 16px; border-radius: 18px 18px 4px 18px; color: var(--text);
  line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.msg-row.assistant .msg-bubble {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  padding: 18px 22px; border-radius: 18px; box-shadow: var(--shadow-xs);
  line-height: 1.75; word-break: break-word;
}
.msg-actions { margin-top: 8px; display: flex; gap: 6px; opacity: 0.75; transition: opacity 0.15s; }
.msg-row:hover .msg-actions { opacity: 1; }

/* Floating Composer Island */
.composer-dock { padding: 8px 24px 18px; max-width: 828px; width: 100%; margin: 0 auto; }
.composer-inner {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 12px 14px 10px; box-shadow: var(--shadow-md); transition: border-color 0.16s, box-shadow 0.16s;
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 12px 34px var(--accent-soft); }
.composer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.composer-chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500;
}
.chip button { border: none; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.composer-inner textarea {
  width: 100%; border: none; background: transparent; padding: 4px 2px 8px;
  font-size: 14px; resize: none; min-height: 46px; max-height: 190px; box-shadow: none !important;
}
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.composer-left-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), #6366f1); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 4px 12px var(--accent-ring); transition: transform 0.15s, filter 0.15s;
}
.send-btn svg { width: 16px; height: 16px; }
.send-btn:hover { transform: scale(1.05); filter: brightness(1.08); }
.send-btn:disabled { opacity: 0.45; transform: none; cursor: not-allowed; }

.quick-prompts {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px;
}
.q-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; cursor: pointer; transition: all 0.15s;
}
.q-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ==================== Editorial Pages (Videos / KB / Admin) ==================== */
.page-scroll {
  flex: 1; overflow-y: auto; padding: 24px 28px 32px;
  display: flex; flex-direction: column; gap: 18px; max-width: 1440px; width: 100%; margin: 0 auto;
}
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 4px; }
.page-header-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.page-header-bar h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.studio-hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 22px 24px; box-shadow: var(--shadow-sm);
}
.hero-top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.hero-top-row h1 { margin: 0 0 4px; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.subtitle { margin: 0; font-size: 13px; color: var(--muted); }
.platform-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.hero-input-bar {
  display: flex; gap: 8px; align-items: center; background: var(--bg-subtle);
  padding: 6px; border-radius: 14px; border: 1px solid var(--border);
}
.hero-url-input {
  flex: 1; min-width: 200px; border: none; background: transparent; padding: 8px 12px;
  font-size: 14px; color: var(--text); outline: none;
}
.hero-sub-bar { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.progress-toast {
  margin-top: 12px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500;
}

.filter-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.studio-split {
  display: grid; grid-template-columns: 340px 1fr; gap: 18px; min-height: 520px; align-items: start;
}
.studio-list-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 14px; box-shadow: var(--shadow-xs); max-height: calc(100vh - 220px); overflow-y: auto;
}
.studio-reader-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px 28px; box-shadow: var(--shadow-sm); min-height: 520px;
}
.col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.col-head h3 { margin: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }

.card-stack { display: flex; flex-direction: column; gap: 8px; }
.item-card {
  padding: 12px 14px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; transition: all 0.16s ease;
}
.item-card:hover { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.item-card.active {
  background: var(--surface); border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-soft);
}
.item-card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 5px; line-height: 1.35; }
.item-card-meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-card-preview { font-size: 12px; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.keyframes-strip { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 12px; }
.kf-thumb {
  flex-shrink: 0; width: 156px; cursor: zoom-in; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2); transition: transform 0.15s;
}
.kf-thumb:hover { transform: translateY(-2px); border-color: var(--accent); }
.kf-thumb img { width: 100%; height: 92px; object-fit: cover; display: block; }
.kf-thumb span { display: block; text-align: center; font-size: 11px; color: var(--muted); padding: 4px; }

/* ==================== Rich Markdown Rendering ==================== */
.md-body { font-size: 14px; line-height: 1.78; color: var(--text); }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 18px 0 8px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.35;
}
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child { margin-top: 0; }
.md-body h1 { font-size: 20px; }
.md-body h2 { font-size: 16.5px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 14.5px; color: var(--accent); }
.md-body p { margin: 0 0 10px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body ul, .md-body ol { margin: 6px 0 12px; padding-left: 22px; }
.md-body li { margin: 4px 0; }
.md-body blockquote {
  margin: 10px 0; padding: 10px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text-secondary);
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px;
  background: var(--bg-subtle); padding: 2px 6px; border-radius: 6px;
}
.md-body pre {
  position: relative; background: #161822; color: #e5e7eb; padding: 14px 16px;
  border-radius: 12px; overflow-x: auto; margin: 10px 0; font-size: 12.5px; line-height: 1.6;
}
.md-body pre code { background: transparent; padding: 0; color: inherit; }
.md-body table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.md-body th, .md-body td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.md-body th { background: var(--bg-subtle); font-weight: 600; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ==================== Admin Dashboard ==================== */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 15px 18px; box-shadow: var(--shadow-xs);
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 750; margin-top: 4px; letter-spacing: -0.02em; }
.admin-panel { display: flex; flex-direction: column; gap: 14px; }
.admin-two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
.surface-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px 20px; box-shadow: var(--shadow-xs);
}
.inline-row { display: flex; gap: 8px; align-items: center; }
.invite-banner {
  background: var(--ok-soft); border: 1px solid rgba(5, 150, 105, 0.3); color: var(--ok);
  padding: 10px 14px; border-radius: 11px; margin-bottom: 12px; font-family: monospace; font-weight: 600;
}

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.gallery-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow-xs); display: flex; flex-direction: column;
}
.gallery-cover { height: 148px; background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.gallery-cover img { width: 100%; height: 100%; object-fit: cover; }
.gallery-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.emp-avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ==================== Empty State, Modal, Lightbox, Toast ==================== */
.empty-hero {
  margin: auto; text-align: center; max-width: 420px; padding: 56px 20px; color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-hero h3 { color: var(--text); margin: 0 0 6px; font-size: 17px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 15, 20, 0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-box {
  width: 620px; max-width: 100%; max-height: 86vh; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.icon-close { border: none; background: var(--bg-subtle); color: var(--muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.icon-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.lightbox {
  position: fixed; inset: 0; background: rgba(10, 10, 14, 0.88); backdrop-filter: blur(6px);
  z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
}
.lightbox img { max-width: 90vw; max-height: 80vh; border-radius: 14px; box-shadow: var(--shadow-lg); }
.lightbox-caption { color: #e4e4e7; margin-top: 12px; font-size: 13px; }
.lightbox-close {
  position: fixed; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 18px; cursor: pointer;
}

.toast {
  position: fixed; bottom: 24px; right: 24px; background: #18181b; color: #fff;
  padding: 11px 18px; border-radius: 12px; z-index: 200; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
}

/* ==================== Script Studio (专业编剧剧本工坊) ==================== */
.script-studio { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.script-topbar {
  min-height: 56px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.script-bar-left, .script-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.episode-pills { display: flex; gap: 4px; flex-wrap: wrap; max-width: 420px; }
.ep-pill {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-subtle);
  color: var(--text-secondary); font-size: 12px; cursor: pointer; font-weight: 500; transition: all 0.14s;
}
.ep-pill:hover { background: var(--surface-hover); color: var(--text); }
.ep-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.metrics-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--bg-subtle); border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.script-workspace {
  flex: 1; display: grid; grid-template-columns: 1.38fr 1fr; overflow: hidden;
}
.script-editor-pane {
  display: flex; flex-direction: column; overflow: hidden; background: var(--surface);
  border-right: 1px solid var(--border);
}
.editor-format-bar {
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.format-inserts { display: flex; gap: 5px; flex-wrap: wrap; }
.fmt-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  padding: 4px 9px; border-radius: 7px; font-size: 11.5px; cursor: pointer; font-weight: 500;
}
.fmt-btn:hover { border-color: var(--accent); color: var(--accent); }
.fmt-btn.warm { color: var(--warm); border-color: rgba(217, 119, 6, 0.28); background: var(--warm-soft); }
.sm-inline { padding: 4px 9px; font-size: 12px; width: 140px; }

.script-textarea {
  flex: 1; width: 100%; border: none !important; border-radius: 0 !important; box-shadow: none !important;
  padding: 24px 32px; font-size: 15px; line-height: 1.9; resize: none; background: var(--surface);
  color: var(--text); font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
}
.script-preview {
  flex: 1; overflow-y: auto; padding: 24px 32px; line-height: 1.85; font-size: 14.5px; background: var(--surface);
}
.script-preview.compact { padding: 12px 14px; max-height: 280px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.sp-scene {
  background: var(--bg-subtle); padding: 7px 12px; border-radius: 9px; font-weight: 700;
  margin: 14px 0 8px; border-left: 3px solid var(--text); font-size: 14px;
}
.sp-scene:first-child { margin-top: 0; }
.sp-action { color: var(--text-secondary); font-style: italic; padding-left: 10px; margin: 5px 0; }
.sp-sfx { color: var(--warm); font-weight: 600; font-size: 13px; padding-left: 10px; margin: 4px 0; }
.sp-dialogue { margin: 7px 0; }
.sp-char { color: var(--accent); font-weight: 700; margin-right: 4px; }
.sp-hook-badge {
  display: inline-block; background: var(--warm-soft); color: var(--warm);
  border: 1px solid rgba(217, 119, 6, 0.3); font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; margin: 2px 4px 2px 0;
}

.script-copilot-pane {
  display: flex; flex-direction: column; overflow: hidden; background: var(--surface-2);
}
.copilot-tabs { padding: 12px 16px 8px; border-bottom: 1px solid var(--border); }
.copilot-tabs .seg-btn { flex: 1; }
.co-panel { flex: 1; overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.selection-banner {
  padding: 9px 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.selection-banner.active { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); font-weight: 600; }
.copilot-actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.co-action-btn {
  padding: 9px 10px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; text-align: left;
  transition: all 0.15s;
}
.co-action-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.co-action-btn.full-span { grid-column: span 2; text-align: center; }
.copilot-custom-box { display: flex; flex-direction: column; gap: 8px; }
.co-result-box {
  background: var(--surface); border: 1px solid var(--accent-ring); border-radius: 14px;
  padding: 12px; box-shadow: var(--shadow-sm);
}

.bible-form { display: flex; flex-direction: column; gap: 10px; }
.bible-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.bible-chars-list { display: flex; flex-direction: column; gap: 8px; }
.char-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.char-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.doctor-report-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}

/* Auto-save badge */
.autosave-badge {
  font-size: 11.5px; color: var(--ok); background: var(--ok-soft);
  padding: 3px 9px; border-radius: 999px; font-weight: 500;
}
.autosave-badge.saving { color: var(--warm); background: var(--warm-soft); }

/* Pacing Beat Timeline Bar */
.pacing-bar {
  padding: 8px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.pacing-header { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; gap: 8px; flex-wrap: wrap; }
.pacing-track {
  position: relative; height: 10px; border-radius: 999px; background: var(--bg-subtle);
  overflow: visible; border: 1px solid var(--border);
}
.pacing-golden-zone {
  position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(217, 119, 6, 0.35), rgba(217, 119, 6, 0.12));
  border-radius: 999px 0 0 999px;
}
.pacing-marker {
  position: absolute; top: -4px; width: 16px; height: 16px; border-radius: 50%;
  transform: translateX(-50%); background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22); cursor: default;
}
.pacing-marker.hook { background: #f59e0b; }
.pacing-marker.twist { background: #ec4899; }
.pacing-marker.cliff { background: #6366f1; }
.pacing-warnings { display: flex; gap: 6px; flex-wrap: wrap; }
.pacing-warn-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--warm-soft); color: var(--warm); font-weight: 500;
}
.pacing-ok-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); font-weight: 500;
}

/* Inline Red/Green Diff View */
.diff-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; padding: 2px 8px; border-radius: 4px; white-space: pre-wrap; margin: 1px 0; }
.diff-del { background: rgba(220, 38, 38, 0.13); color: var(--danger); text-decoration: line-through; }
.diff-add { background: rgba(5, 150, 105, 0.14); color: var(--ok); font-weight: 500; }
.diff-eq { color: var(--muted); }

/* Command Palette (Ctrl + K) */
.cmdk-box {
  width: 580px; max-width: 94vw; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; margin-top: -12vh;
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap span { font-size: 16px; color: var(--accent); font-weight: 700; }
.cmdk-input-wrap input {
  flex: 1; border: none; background: transparent; color: var(--text); font-size: 15px; outline: none;
}
.cmdk-results { max-height: 360px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px; }
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.cmdk-item:hover { background: var(--accent-soft); color: var(--accent); }
.cmdk-item-type { font-size: 11px; color: var(--muted); background: var(--bg-subtle); padding: 2px 7px; border-radius: 6px; }

/* Admin Analytics Row */
.admin-analytics-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }
.trend-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 110px; padding-top: 10px; }
.trend-col { display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.trend-bar-fill {
  width: 100%; max-width: 28px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--accent), #818cf8); min-height: 4px; transition: height 0.25s;
}
.trend-col small { font-size: 10.5px; color: var(--muted); }
.trend-col b { font-size: 11px; color: var(--text-secondary); }

.send-btn.stop-mode { background: var(--danger); box-shadow: 0 4px 12px var(--danger-soft); }

@media (max-width: 1080px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .studio-split { grid-template-columns: 1fr; }
  .admin-two-col, .admin-analytics-grid { grid-template-columns: 1fr; }
  .chat-drawer { width: 240px; }
  .script-workspace { grid-template-columns: 1fr; overflow-y: auto; }
}
