:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-2: #171b21;
  --panel-3: #1d2229;
  --line: #272d35;
  --line-soft: #20252c;
  --text: #eef2f5;
  --muted: #8e98a4;
  --muted-2: #636d78;
  --accent: #d3ff52;
  --accent-ink: #10130a;
  --blue: #76a9ff;
  --orange: #f3a85c;
  --success: #77d49b;
  --danger: #ff7b7b;
  --radius: 16px;
  --sidebar: 270px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template: 72px minmax(0, 1fr) / var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  background:
    radial-gradient(circle at 76% -10%, rgba(211, 255, 82, .055), transparent 29%),
    var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 16, .9);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 22px; }
.brand strong { display: block; font-size: 14px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark { position: relative; width: 30px; height: 30px; border: 1px solid #434b55; border-radius: 9px; transform: rotate(45deg); }
.brand-mark span { position: absolute; background: var(--accent); border-radius: 999px; }
.brand-mark span:first-child { width: 13px; height: 3px; left: 8px; top: 7px; }
.brand-mark span:last-child { width: 3px; height: 13px; left: 13px; top: 7px; }

.topbar-stats { display: flex; align-items: center; gap: 28px; padding-left: 28px; }
.top-stat { display: flex; align-items: baseline; gap: 7px; }
.top-stat strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.top-stat span { color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; padding-right: 22px; }
.system-status { color: var(--muted); font-size: 11px; }
.system-status i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(119,212,155,.09); }

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #0e1014;
}

.project-block { padding: 23px 22px 18px; }
.project-block h1 { margin: 7px 0 0; font-size: 21px; letter-spacing: -.03em; }
.project-block p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.eyebrow { color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.search-box { display: flex; align-items: center; gap: 8px; margin: 0 15px 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #13161b; }
.search-box:focus-within { border-color: #4a535e; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #5d6670; }

.scene-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 20px; }
.episode-label { display: flex; justify-content: space-between; align-items: center; padding: 10px 13px 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.scene-link { width: 100%; display: grid; grid-template-columns: 31px 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid transparent; border-radius: 11px; color: #aeb6bf; background: transparent; text-align: left; }
.scene-link:hover { background: #15191e; color: var(--text); }
.scene-link.active { border-color: #333a43; color: var(--text); background: linear-gradient(120deg, #1d2228, #171b20); box-shadow: inset 3px 0 0 var(--accent); }
.scene-number { color: #68727d; font-size: 10px; font-variant-numeric: tabular-nums; }
.scene-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.scene-copy small { display: block; margin-top: 4px; color: #68727c; font-size: 10px; }
.scene-dot { width: 7px; height: 7px; border-radius: 50%; background: #4b535c; }
.scene-dot.completed { background: var(--success); }
.scene-dot.planning { background: var(--orange); }
.sidebar-note { margin: 10px 15px 16px; padding: 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: #12151a; }
.sidebar-note p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }

.workspace { min-width: 0; min-height: 0; overflow: auto; padding: 28px 32px 80px; }
.scene-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; max-width: 1500px; margin: 0 auto 22px; }
.breadcrumb { color: var(--muted); font-size: 11px; }
.scene-header h2 { margin: 8px 0 6px; font-size: 30px; letter-spacing: -.04em; }
.scene-summary { color: var(--muted); font-size: 12px; }
.scene-actions { display: flex; gap: 9px; }

.button { min-height: 36px; padding: 0 14px; border: 1px solid #343b44; border-radius: 9px; color: #d9dee3; background: #181c21; font-size: 11px; font-weight: 600; }
.button:hover { border-color: #505a65; background: #20252b; }
.button-primary { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.button-primary:hover { border-color: #e0ff7a; background: #e0ff7a; }
.button-small { min-height: 31px; padding: 0 11px; font-size: 10px; }
.button-ghost { border-color: transparent; color: var(--muted); background: transparent; }
.button:disabled { cursor: not-allowed; opacity: .45; }

.pipeline { max-width: 1500px; margin: 0 auto 24px; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.pipeline-step { position: relative; min-height: 84px; padding: 15px 17px; border-right: 1px solid var(--line); }
.pipeline-step:last-child { border-right: 0; }
.pipeline-step span { display: block; color: var(--muted); font-size: 10px; }
.pipeline-step strong { display: block; margin-top: 8px; font-size: 21px; font-variant-numeric: tabular-nums; }
.pipeline-step small { position: absolute; right: 14px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(119,212,155,.08); }

.scene-layout { max-width: 1500px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 2px 0 12px; }
.section-head h3 { margin: 5px 0 0; font-size: 17px; }
.section-head p { margin: 0; color: var(--muted); font-size: 10px; }

.shot-list { display: grid; gap: 14px; }
.shot-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.shot-card.changed { border-color: rgba(211,255,82,.45); }
.shot-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.shot-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.shot-index { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px; color: var(--accent); background: rgba(211,255,82,.08); font-size: 10px; font-weight: 700; }
.shot-title input { width: min(420px, 45vw); border: 0; outline: 0; color: var(--text); background: transparent; font-size: 13px; font-weight: 650; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.draft, .status-pill.planning { color: var(--orange); }

.shot-body { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(340px, 1.1fr); }
.frame-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; min-height: 214px; background: var(--line); }
.frame { position: relative; min-width: 0; overflow: hidden; background: #0c0f13; }
.frame img { width: 100%; height: 100%; min-height: 214px; object-fit: cover; display: block; }
.frame-label { position: absolute; left: 10px; top: 10px; padding: 5px 7px; border-radius: 6px; color: #ecf1f4; background: rgba(9,11,14,.75); backdrop-filter: blur(8px); font-size: 9px; }
.frame-action { position: absolute; right: 9px; bottom: 9px; padding: 6px 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 7px; color: white; background: rgba(8,10,12,.7); font-size: 9px; opacity: 0; transition: opacity .15s ease; }
.frame-download { position: absolute; left: 9px; bottom: 9px; padding: 6px 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 7px; color: white; background: rgba(8,10,12,.7); font-size: 9px; text-decoration: none; opacity: 0; transition: opacity .15s ease; }
.frame:hover .frame-action, .frame:hover .frame-download { opacity: 1; }
.frame-placeholder { height: 100%; min-height: 214px; display: grid; place-items: center; color: #59636d; background: linear-gradient(135deg, #12171d, #0d1014); font-size: 10px; }

.prompt-editor { padding: 15px; border-left: 1px solid var(--line-soft); }
.prompt-editor > label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.prompt-editor textarea { width: 100%; min-height: 134px; resize: vertical; border: 1px solid var(--line); border-radius: 9px; outline: none; padding: 11px 12px; color: #cdd3da; background: #0e1115; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 10px; line-height: 1.55; }
.prompt-editor textarea:focus { border-color: #46515d; }
.shot-controls { display: grid; grid-template-columns: 1fr 90px 100px; gap: 8px; margin-top: 9px; }
.field { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.field input, .field select { width: 100%; height: 33px; border: 1px solid var(--line); border-radius: 8px; outline: 0; padding: 0 9px; color: #dce2e7; background: #12161b; font-size: 10px; }
.shot-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.clip-link { display: inline-flex; align-items: center; gap: 7px; color: var(--blue); text-decoration: none; font-size: 10px; }
.clip-link::before { content: "▶"; font-size: 8px; }

.asset-column { position: sticky; top: 0; display: grid; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--line-soft); }
.panel-head strong { font-size: 12px; }
.panel-head span { color: var(--muted); font-size: 9px; }
.video-preview { background: #07090b; }
.video-preview video { display: block; width: 100%; aspect-ratio: 16/9; background: black; }
.video-load-state { aspect-ratio: 16/9; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 18px; text-align: center; background: radial-gradient(circle at 50% 35%, #19212a, #090c0f 68%); }
.video-load-state strong { color: #dfe6eb; font-size: 11px; }
.video-load-state small { color: var(--muted-2); font-size: 9px; }
.video-load-state .button { margin-top: 5px; }
.video-load-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #3b4651; border-radius: 50%; color: var(--blue); background: rgba(7,9,11,.72); font-size: 11px; }
.video-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.video-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.video-meta small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.asset-list { max-height: 340px; overflow: auto; padding: 7px; }
.asset-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: center; padding: 9px; border-radius: 9px; }
.asset-row:hover { background: var(--panel-2); }
.asset-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); background: #0f1216; font-size: 11px; }
.asset-copy { min-width: 0; }
.asset-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 550; }
.asset-copy small { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.asset-row a { color: var(--muted); text-decoration: none; font-size: 12px; }

.empty-state { min-height: 70vh; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-state h2 { margin: 20px 0 5px; font-size: 18px; }
.empty-state p { color: var(--muted); font-size: 11px; }
.empty-orbit { width: 54px; height: 54px; border: 1px solid #353c45; border-radius: 50%; box-shadow: inset 0 0 0 10px #11151a; animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { border-color: var(--accent); box-shadow: inset 0 0 0 17px #11151a; } }

.dialog { width: min(560px, calc(100vw - 30px)); border: 1px solid #353c44; border-radius: 16px; padding: 20px; color: var(--text); background: #15191e; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog h2 { margin: 5px 0 0; font-size: 20px; }
.dialog label { display: grid; gap: 7px; margin-bottom: 13px; color: var(--muted); font-size: 10px; }
.dialog input, .dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: 0; padding: 10px; color: var(--text); background: #0f1216; font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.icon-button { width: 30px; height: 30px; border: 0; border-radius: 8px; color: var(--muted); background: #20252b; font-size: 18px; }
.payload-dialog { width: min(800px, calc(100vw - 30px)); }
.payload-dialog pre { max-height: 58vh; overflow: auto; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 10px; color: #cfe3b2; background: #0b0e11; font-size: 10px; line-height: 1.6; white-space: pre-wrap; }
.dialog-hint { color: var(--muted); font-size: 10px; line-height: 1.6; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 11px 14px; border: 1px solid #3b454f; border-radius: 10px; color: var(--text); background: #1a1f25; box-shadow: 0 16px 50px rgba(0,0,0,.45); font-size: 11px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,123,123,.55); color: #ffc2c2; }

@media (max-width: 1080px) {
  :root { --sidebar: 235px; }
  .topbar-stats { display: none; }
  .topbar { grid-template-columns: var(--sidebar) 1fr auto; }
  .scene-layout { grid-template-columns: 1fr; }
  .asset-column { position: static; grid-template-columns: 1fr 1fr; }
  .shot-body { grid-template-columns: 1fr; }
  .prompt-editor { border-left: 0; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { display: block; height: auto; }
  .topbar { position: sticky; top: 0; display: flex; justify-content: space-between; height: 64px; }
  .topbar-actions .system-status, .topbar-actions .button { display: none; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .project-block, .sidebar-note { display: none; }
  .search-box { margin-top: 12px; }
  .scene-nav { display: flex; overflow-x: auto; padding: 0 10px 12px; }
  .episode-label { display: none; }
  .scene-link { min-width: 200px; }
  .workspace { padding: 22px 14px 60px; }
  .scene-header { display: block; }
  .scene-actions { margin-top: 14px; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .pipeline-step { border-bottom: 1px solid var(--line); }
  .asset-column { grid-template-columns: 1fr; }
  .frame-pair { grid-template-columns: 1fr; }
  .shot-controls { grid-template-columns: 1fr 1fr; }
}
