/* 视频放映室 — 放映室设计：深黑场 + 暖白字幕 + 场记板琥珀金 */

:root {
  --bg: #0f0f12;
  --panel: #161619;
  --panel-2: #1c1c21;
  --line: #2a2a31;
  --line-soft: #222228;
  --text: #ece7dd;
  --muted: #8b8778;
  --gold: #e0b45c;
  --gold-deep: #b8892f;
  --gold-ink: #241c0c;
  --ok: #8fae72;
  --err: #d47a63;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过任何 display 声明（.modal/.gate/.stage-error/.project-bar/.pip
   都设了 display:flex，会覆盖 UA 的 [hidden]{display:none}，导致弹框常显挡住页面） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 14px; flex: none; }

.brand-mark {
  width: 40px;
  height: 40px;
  color: var(--gold);
  flex: none;
}

.brand-text { flex: none; min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.tagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.provider-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.pip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
}

.pip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.pip.on { color: var(--text); border-color: var(--gold-deep); }
.pip.on i { background: var(--gold); box-shadow: 0 0 6px rgba(224, 180, 92, 0.55); }
.pip.off i { background: transparent; border: 1px solid var(--muted); }

.pip.user-chip { color: var(--gold); border-color: var(--gold-deep); cursor: default; }

/* ---------- 主布局 ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 22px;
  padding: 22px 28px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

/* ---------- 创作台（左） ---------- */

.console {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 20px;
}

.field { margin-bottom: 18px; }

.field label,
.model-field legend {
  display: block;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 130px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.7;
}

textarea:focus, input:focus, .cta:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

textarea::placeholder { color: #5d5a51; }

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.detected { color: var(--gold); text-align: right; }

.model-field {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
}

.model-field legend { padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 10px;
  cursor: pointer;
}

.chip[aria-checked="true"] {
  color: var(--gold-ink);
  background: var(--gold);
  border-color: var(--gold);
}

.chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: line-through;
}

.hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 1.2em;
}

/* 主按钮：场记板金 */

.cta {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold) 0%, #cfa04a 100%);
  border: 0;
  border-radius: 3px;
  padding: 13px 16px;
  cursor: pointer;
}

.cta:hover { filter: brightness(1.06); }
.cta:active { filter: brightness(0.94); }
.cta:disabled { opacity: 0.55; cursor: wait; }
.cta.small { width: auto; padding: 8px 22px; font-size: 13px; }

.ghost-btn {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 12px;
  cursor: pointer;
}

.ghost-btn:hover { color: var(--text); border-color: var(--muted); }
.ghost-btn.small { padding: 3px 10px; }

/* ---------- 放映厅（右） ---------- */

.screen { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* 取景框（空状态） */

.viewfinder {
  position: absolute;
  inset: 22px;
  border: 1px dashed #3a3a30;
}

.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 0 solid var(--gold-deep);
}

.corner.tl { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: -1px; right: -1px; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: -1px; left: -1px; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

.viewfinder-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.viewfinder-text p {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.viewfinder-text small { color: #6a675d; font-size: 12px; }

/* 生成中：胶片进度 + 状态行 */

.now-showing {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 18, 0.92);
  border-top: 1px solid var(--line-soft);
  padding: 14px 20px 12px;
}

.film-progress { display: flex; align-items: stretch; gap: 0; }

.sprockets {
  width: 14px;
  background: repeating-linear-gradient(
    180deg,
    transparent 0 5px,
    #34342f 5px 9px
  );
  opacity: 0.9;
}

.bar {
  flex: 1;
  height: 10px;
  background: #23231f;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  transition: width 0.6s ease;
  box-shadow: 0 0 12px rgba(224, 180, 92, 0.35);
}

.now-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.status-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.status-detail {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stage-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(15, 15, 18, 0.94);
  text-align: center;
  padding: 24px;
}

.stage-error p { margin: 0; color: var(--err); font-size: 14px; }

/* ---------- 放映记录（胶片格） ---------- */

.history {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 14px 18px 18px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.2em;
  font-weight: 600;
  color: var(--muted);
}

.filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filmstrip .empty {
  margin: 0;
  color: #6a675d;
  font-size: 12px;
  padding: 8px 0;
}

.frame {
  flex: none;
  width: 168px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
}

.frame::before {
  content: "";
  display: block;
  height: 7px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 8px,
    #34342f 8px 14px
  );
  border-bottom: 1px solid var(--line-soft);
}

.frame.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-deep); }

.frame-body { padding: 8px 10px 10px; }

.frame-title {
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.frame .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  background: var(--muted);
}

.frame.succeeded .dot { background: var(--ok); }
.frame.failed .dot { background: var(--err); }
.frame.active.succeeded .dot { background: var(--ok); }

/* ---------- 令牌门 ---------- */

.gate {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 18, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.gate-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px 30px;
  width: min(360px, calc(100vw - 48px));
  text-align: center;
}

.gate-title {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.15em;
}

.gate-desc { margin: 0 0 18px; color: var(--muted); font-size: 12px; }

.gate-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.gate-error { color: var(--err); font-size: 12px; margin: 12px 0 0; }

/* ---------- 页脚 ---------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 28px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.footer-mid { color: #5d5a51; }

/* ---------- Studio：模板 / 分镜 / 接入矩阵 ---------- */

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

.tabs { display: flex; gap: 2px; }

.tab {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 6px 14px;
  cursor: pointer;
}

.tab.active {
  color: var(--gold);
  border-color: var(--gold-deep);
  background: var(--bg);
}

.templates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tpl {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 11px;
  cursor: pointer;
}

.tpl:hover, .tpl.picked { color: var(--gold-ink); background: var(--gold); border-color: var(--gold); }

.field-row { display: flex; gap: 10px; }
.field-row .grow { flex: 1; }

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  padding: 9px 12px;
}

/* 分镜脚本面板 */

.script-panel { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 16px; }

.script-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.script-title { margin: 0; font-family: var(--serif); font-size: 18px; letter-spacing: 0.06em; }

.script-logline { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

.shots { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }

.shot {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px 12px;
}

.shot.succeeded { border-color: var(--ok); }
.shot.failed { border-color: var(--err); }
.shot.processing, .shot.submitted, .shot.queued { border-color: var(--gold-deep); }

.shot-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}

.shot-n {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 12px;
}

.shot-scene { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.shot-dur { color: var(--muted); font-variant-numeric: tabular-nums; }

.shot-status {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.shot-status.st-succeeded { color: var(--ok); border-color: var(--ok); }
.shot-status.st-failed { color: var(--err); border-color: var(--err); }
.shot-status.st-processing, .shot-status.st-submitted, .shot-status.st-queued { color: var(--gold); border-color: var(--gold-deep); }

.shot-prompt {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 10px;
  resize: vertical;
}

.shot-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  min-height: 22px;
}

.shot-link { font-size: 12px; color: var(--gold); }

.shot-err { flex: 1; font-size: 11px; color: var(--err); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.script-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.script-sum { font-size: 12px; color: var(--muted); }

/* Studio 放映厅 */

.project-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 12px 16px;
}

.project-bar .hint { flex: 1; min-height: 0; }

/* 引擎接入矩阵（模态） */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 26px 28px;
  width: min(520px, calc(100vw - 40px));
  max-height: 80vh;
  overflow-y: auto;
}

.modal-close {
  float: right;
}

.modal-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.12em;
}

.modal-desc { margin: 6px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }

.keys-list { display: flex; flex-direction: column; gap: 10px; }

.key-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 10px 12px;
  background: var(--bg);
}

.key-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--line);
}

.key-dot.on { background: var(--gold); box-shadow: 0 0 6px rgba(224, 180, 92, 0.55); }

.key-main { flex: 1; min-width: 0; }

.key-name { font-size: 13px; color: var(--text); text-decoration: none; }
a.key-name:hover { color: var(--gold); }

.key-needs { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.6; word-break: break-all; }

.key-state {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 16 / 10; }
  .brand-text h1 { font-size: 22px; }
  .provider-status .pip { font-size: 10px; }
  .topbar { flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: space-between; }
}

/* ---------- 动效（克制：一次载入 + 操作反馈） ---------- */

@media (prefers-reduced-motion: no-preference) {
  .topbar { animation: rise 0.5s ease both; }
  .layout { animation: rise 0.5s 0.08s ease both; }
  .footer { animation: rise 0.5s 0.14s ease both; }
  .fill { animation: sheen 1.6s linear infinite; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheen {
  from { background-position: -200px 0; }
  to { background-position: 200px 0; }
}

.fill { background-size: 200px 100%; }