* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #101722;
  --panel-3: #0c1320;
  --line: #263142;
  --line-soft: #1e2938;
  --text: #edf2f7;
  --muted: #8d98aa;
  --muted-2: #687386;
  --blue: #3b82f6;
  --blue-soft: #12284a;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.09), transparent 260px),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 18px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.app-header h1 { font-size: 30px; line-height: 1.1; letter-spacing: 0; }
.app-header p { color: var(--muted); margin-top: 6px; font-size: 14px; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.version-pill {
  border: 1px solid var(--line);
  background: rgba(16, 23, 34, 0.85);
  color: #b9c4d6;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  white-space: nowrap;
}
.user-pill {
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(16, 23, 34, 0.85);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  color: #cbd5e1;
  font-size: 12px;
}
.user-pill button {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  background: #263142;
}
.user-pill button:hover { background: #334155; }
.user-pill .pill-action {
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.28);
}
.user-pill .pill-action strong { color: #ffffff; }
.auth-entry-btn {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  background: var(--blue);
  white-space: nowrap;
}
.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid #315985;
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.admin-link:hover { background: rgba(59, 130, 246, 0.22); }

.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.admin-workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px 32px;
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric {
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 14px;
}
.metric span {
  color: var(--muted);
  font-size: 12px;
}
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}
.admin-table th {
  color: #d8e2f0;
  background: var(--panel-2);
  white-space: nowrap;
}
.admin-table td { color: #cbd5e1; }
.admin-table tr:last-child td { border-bottom: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #263142;
  color: #d8e2f0;
  white-space: nowrap;
}
.status-done { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.status-failed { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.status-running, .status-queued { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.admin-error {
  max-width: 380px;
  color: #fca5a5;
  white-space: normal;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 190px;
}

.side-stack { display: grid; gap: 18px; }

.card {
  background: rgba(21, 27, 36, 0.96);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}
.create-card {
  --mode-accent: #f59e0b;
  --mode-accent-soft: rgba(245, 158, 11, 0.14);
  --mode-accent-line: rgba(245, 158, 11, 0.58);
}
.create-card[data-mode="narration"] {
  --mode-accent: #ec4899;
  --mode-accent-soft: rgba(236, 72, 153, 0.13);
  --mode-accent-line: rgba(236, 72, 153, 0.52);
}
.create-card[data-mode="beat"] {
  --mode-accent: #14b8a6;
  --mode-accent-soft: rgba(20, 184, 166, 0.13);
  --mode-accent-line: rgba(20, 184, 166, 0.52);
}
.create-card[data-mode="concat"] {
  --mode-accent: #ff6b5f;
  --mode-accent-soft: rgba(255, 107, 95, 0.14);
  --mode-accent-line: rgba(255, 107, 95, 0.58);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.section-title h2 { font-size: 18px; line-height: 1.25; }
.section-title p { color: var(--muted); font-size: 12px; margin-top: 4px; }

form { display: grid; gap: 14px; }
.form-section {
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.section-label {
  color: #d8e2f0;
  font-size: 13px;
  font-weight: 700;
}

label { display: grid; gap: 6px; font-size: 13px; color: #b7c1d1; min-width: 0; }
input, select {
  width: 100%;
  background: var(--panel-3);
  border: 1px solid #2b374b;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}
input[type="file"] { padding: 7px; color: #cbd5e1; }
input[type="range"] { padding: 0; accent-color: var(--blue); }
audio { width: 100%; min-height: 36px; }

.row, .file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.bgm-picker {
  border: 1px solid #2b374b;
  background: rgba(12, 19, 32, 0.78);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 12px;
}
.bgm-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  color: #b7c1d1;
  font-size: 13px;
}
.bgm-picker-head span {
  display: block;
  font-weight: 700;
  color: #d8e2f0;
}
.bgm-picker-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.bgm-source-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(360px, 100%);
  flex: 0 0 min(360px, 100%);
}
.bgm-source-tabs label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid #2b374b;
  border-radius: 8px;
  background: #0d1624;
  color: #d8e2f0;
  font-size: 12px;
}
.bgm-source-tabs input {
  width: auto;
  accent-color: var(--mode-accent);
}
.bgm-library-panel {
  display: grid;
  gap: 10px;
}
.audio-settings-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #2b3440;
  border-radius: 7px;
  background: #0e1319;
}
.audio-settings-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.audio-settings-head strong {
  color: #eef2f7;
  font-size: 13px;
}
.audio-settings-head span {
  color: #7f8b9c;
  font-size: 10px;
}
.audio-settings-panel.is-no-bgm [data-audio-control="bgm"] {
  display: none;
}
.audio-settings-panel.is-no-bgm .audio-level-row {
  grid-template-columns: minmax(0, 1fr);
  max-width: 50%;
}
.bgm-control-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.4fr);
  gap: 12px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.bgm-library-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 3px 12px;
  min-height: 58px;
  padding: 9px 12px;
  border: 1px solid #2b3440;
  border-radius: 7px;
  background: #0e1319;
}
.bgm-library-summary span { color: #aeb8c7; font-size: 11px; }
.bgm-library-summary strong { color: #eef2f7; font-size: 14px; }
.bgm-library-summary small { grid-column: 1 / -1; color: #778398; font-size: 10px; }
.bgm-track-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 196px;
  overflow: auto;
  padding-right: 3px;
}
.bgm-track-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid #303a48;
  border-radius: 7px;
  background: #111821;
  color: #dce5f1;
  text-align: left;
}
.bgm-track-card:hover { border-color: #536176; background: #151e29; }
.bgm-track-card.is-selected {
  border-color: var(--mode-accent);
  box-shadow: inset 3px 0 0 var(--mode-accent);
  background: color-mix(in srgb, var(--mode-accent) 8%, #111821);
}
.bgm-track-main, .bgm-track-meta { display: grid; gap: 3px; min-width: 0; }
.bgm-track-main strong { overflow: hidden; color: #f0f4f9; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.bgm-track-main small, .bgm-track-meta small { color: #8592a5; font-size: 10px; }
.bgm-track-meta { justify-items: end; flex: 0 0 auto; }
.bgm-track-meta em { color: #b9c7d8; font-size: 10px; font-style: normal; }
.bgm-empty { grid-column: 1 / -1; margin: 0; padding: 18px; color: #8490a2; text-align: center; }
#bgm-license-note { line-height: 1.55; }
#bgm-license-note a { color: #87aef7; }
#bgm-license-note span { color: #737f91; }
.bgm-preview-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.bgm-preview-row button { min-height: 38px; }
.subtitle-preview-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}
.subtitle-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.subtitle-preview-head strong {
  color: #d8e2f0;
  font-size: 13px;
}
.subtitle-preview-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.subtitle-preview-frame {
  position: relative;
  width: min(340px, 100%);
  aspect-ratio: 9 / 16;
  justify-self: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #2b374b;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.16), rgba(15, 23, 42, 0.72)),
    linear-gradient(135deg, #253246, #0b1018 62%, #182235);
}
.subtitle-preview-frame[data-orientation="landscape"] {
  width: min(360px, 100%);
  aspect-ratio: 16 / 9;
}
.subtitle-preview-text {
  position: absolute;
  left: 4%;
  right: 4%;
  color: #fff;
  font-weight: 800;
  line-height: 1.16;
  text-align: center;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 2px 5px rgba(0, 0, 0, 0.88);
}
.subtitle-preview-frame[data-size="small"] .subtitle-preview-text {
  font-size: 18px;
  max-width: 94%;
  margin: 0 auto;
}
.subtitle-preview-frame[data-size="medium"] .subtitle-preview-text {
  font-size: 21px;
  max-width: 94%;
  margin: 0 auto;
}
.subtitle-preview-frame[data-size="large"] .subtitle-preview-text {
  font-size: 24px;
  max-width: 94%;
  margin: 0 auto;
}
.subtitle-preview-frame[data-position="top"] .subtitle-preview-text {
  top: 20%;
  transform: translateY(-50%);
}
.subtitle-preview-frame[data-position="middle"] .subtitle-preview-text {
  top: 68%;
  transform: translateY(-50%);
}
.subtitle-preview-frame[data-position="bottom"] .subtitle-preview-text {
  bottom: 10%;
}
.video-order-panel {
  display: grid;
  gap: 10px;
  border: 1px solid #2b374b;
  background: #0d1624;
  border-radius: 8px;
  padding: 12px;
}
.order-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.order-head span {
  color: #d8e2f0;
  font-size: 13px;
  font-weight: 700;
}
.order-head small {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
#video-order-list {
  display: grid;
  gap: 8px;
  list-style: none;
}
#video-order-list li {
  display: grid;
  grid-template-columns: 24px 104px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line-soft);
  background: var(--panel-3);
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  transition: border-color .16s, background .16s, opacity .16s;
}
#video-order-list li.dragging { opacity: .48; }
#video-order-list li.drag-over {
  border-color: var(--mode-accent);
  background: var(--mode-accent-soft);
}
.drag-handle {
  color: #7b8592;
  font-size: 16px;
  letter-spacing: -5px;
  cursor: grab;
  user-select: none;
}
.video-thumb {
  width: 104px;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #343b45;
  border-radius: 6px;
  background-color: #0b0e12;
  background-position: center;
  background-size: cover;
}
.video-thumb i { font-size: 18px; font-style: normal; }
.video-file-info {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.video-file-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e8ebef;
  font-size: 13px;
}
.video-file-info small { color: var(--muted); font-size: 11px; }
.media-status {
  padding: 4px 7px;
  border-radius: 5px;
  background: #252b33;
  color: #b7bec8;
  font-size: 10px;
  white-space: nowrap;
}
.video-file-card.ready .media-status { background: rgba(22, 101, 52, .34); color: #86efac; }
.video-file-card.error { border-color: rgba(239, 68, 68, .5); }
.video-file-card.error .media-status { background: rgba(127, 29, 29, .45); color: #fca5a5; }
.order-actions { display: flex; gap: 5px; }
.order-btn {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 6px;
  background: #263142;
  color: #d8e2f0;
  font-size: 12px;
}
.order-btn:hover { background: #334155; }
.order-btn.remove:hover { background: rgba(127, 29, 29, .72); color: #fecaca; }
.order-btn:disabled {
  background: #17202d;
  color: #5f6b7d;
  cursor: default;
}
.compact-row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}
.check input { width: auto; }
.strong-check {
  padding: 10px 12px;
  border: 1px solid #2b374b;
  background: #0d1624;
  border-radius: 8px;
}

.safety-audit-card { display: grid; gap: 14px; }
.safety-audit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.safety-audit-card-head > div { display: grid; gap: 4px; }
.safety-audit-card h3 { margin: 0; color: #eef2f7; font-size: 16px; }
.safety-audit-card p { margin: 0; max-width: 720px; }
.section-kicker { color: #f59e0b; font-size: 10px; font-weight: 800; }
.switch-control { display: flex; align-items: center; gap: 9px; cursor: pointer; white-space: nowrap; }
.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.switch-track {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 12px;
  background: #3b4654;
  transition: background .18s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #f4f6f8;
  transition: transform .18s ease;
}
.switch-control input:checked + .switch-track { background: #d99100; }
.switch-control input:checked + .switch-track::after { transform: translateX(17px); }
.switch-control b { color: #e5e9ef; font-size: 12px; }
.safety-audit-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.safety-audit-tags span {
  padding: 5px 8px;
  border: 1px solid #303945;
  border-radius: 5px;
  color: #aeb8c6;
  background: #0e1319;
  font-size: 10px;
}
.safety-audit-card.is-disabled { opacity: .68; }

button {
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 700;
}
button:hover { background: #2563eb; }
button:disabled { background: #334155; cursor: wait; color: #94a3b8; }
.secondary-btn {
  background: #263142;
  color: #d8e2f0;
}
.secondary-btn:hover { background: #334155; }
.mini-btn {
  padding: 5px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.danger-btn {
  background: rgba(127, 29, 29, 0.88);
  color: #fecaca;
}
.danger-btn:hover { background: rgba(153, 27, 27, 0.95); }
.billing-preview {
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.billing-preview div {
  display: grid;
  gap: 3px;
}
.billing-preview span,
.billing-preview small {
  color: var(--muted);
  font-size: 12px;
}
.billing-preview strong {
  color: #dbeafe;
  font-size: 20px;
}
.billing-preview.insufficient {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(127, 29, 29, 0.2);
}
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  isolation: isolate;
}
.auth-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(6px);
}
.auth-card {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
}
.credit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.credit-summary div {
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 20px;
}
.credit-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.credit-summary strong {
  display: block;
  margin-bottom: 8px;
  font-size: 34px;
}
.credit-summary small { color: var(--muted); font-size: 11px; }
.credits-notice {
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 8px;
  background: rgba(120, 79, 12, .12);
  color: #d8c28c;
  font-size: 12px;
}
.plans-wrap {
  display: grid;
  gap: 16px;
}
.plans-wrap h3,
.ledger-section h3 {
  font-size: 14px;
  margin-bottom: 10px;
}
.credits-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.credits-section-head h3 { margin: 0; }
.credits-section-head span { color: var(--muted); font-size: 11px; }
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.plan-card {
  position: relative;
  display: grid;
  gap: 7px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 13px;
}
.plan-card.featured {
  border-color: rgba(245, 158, 11, 0.7);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), var(--panel-2));
}
.plan-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  font-size: 11px;
  font-weight: 700;
}
.plan-card strong { font-size: 15px; }
.plan-price {
  font-size: 24px;
  font-weight: 800;
}
.plan-card small,
.plan-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.plan-card button {
  margin-top: 4px;
  padding: 8px 10px;
  font-size: 12px;
}
.ledger-section {
  margin-top: 16px;
}
#credit-ledger {
  display: grid;
  gap: 8px;
  list-style: none;
}
#credit-ledger li {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  background: var(--panel-2);
}
#credit-ledger small,
#credit-ledger em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.credit-plus { color: #86efac !important; font-weight: 700; }
.credit-minus { color: #fca5a5 !important; font-weight: 700; }
.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: #263142;
  color: #d8e2f0;
  font-size: 20px;
  line-height: 1;
}
.auth-close:hover { background: #334155; }
.auth-tabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--panel-3);
}
.auth-tabs button {
  min-width: 88px;
  padding: 8px 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.auth-tabs button:hover {
  background: #1d2838;
  color: #d8e2f0;
}
.auth-tabs button.active {
  background: var(--blue);
  color: #fff;
}
.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.auth-actions button {
  min-width: 96px;
}

#mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mode-option input { display: none; }
.mode-option span {
  position: relative;
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 16px;
  border-radius: 9px;
  border: 1px solid #4a5870;
  background: linear-gradient(180deg, #243047, #192437);
  cursor: pointer;
  overflow: visible;
  transition: border-color .16s, background .16s, transform .16s, box-shadow .16s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.mode-option span:hover {
  border-color: #708299;
  background: linear-gradient(180deg, #2b3a54, #1d2a40);
  transform: translateY(-1px);
}
.mode-option strong { color: #f8fafc; font-size: 18px; line-height: 1.25; }
.mode-option small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.mode-option em {
  width: fit-content;
  margin-top: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: #d5deeb;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}
.mode-option input:checked + span {
  border-color: var(--mode-accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, var(--mode-accent-soft), #142033);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 14px 32px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}
.mode-option input:checked + span::after {
  display: none;
}
.mode-option.mode-plot input:checked + span {
  border-color: #f59e0b;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(245, 158, 11, 0.18), #142033);
}
.mode-option.mode-plot input:checked + span::after { background: rgba(245, 158, 11, 0.58); }
.mode-option.mode-narration input:checked + span {
  border-color: #ec4899;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(236, 72, 153, 0.17), #142033);
}
.mode-option.mode-narration input:checked + span::after { background: rgba(236, 72, 153, 0.52); }
.mode-option.mode-beat input:checked + span {
  border-color: #14b8a6;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(20, 184, 166, 0.17), #142033);
}
.mode-option.mode-beat input:checked + span::after { background: rgba(20, 184, 166, 0.52); }
.mode-option.mode-concat input:checked + span {
  border-color: #ff6b5f;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 107, 95, 0.2), #142033);
}
.mode-option input:checked + span em {
  background: var(--mode-accent-soft);
  color: #f8fafc;
}

.mode-select-section {
  position: relative;
  padding-bottom: 12px;
}
.mode-connector {
  display: grid;
  gap: 10px;
  border: 1px solid var(--mode-accent-line);
  background:
    linear-gradient(90deg, var(--mode-accent-soft), rgba(16, 23, 34, 0.9) 52%),
    var(--panel-2);
  border-radius: 10px 10px 6px 6px;
  padding: 13px 14px;
  position: relative;
}
.mode-connector::before,
.mode-connector::after { display: none; }
.connector-line {
  display: none;
}
.mode-summary {
  display: grid;
  gap: 4px;
}
.mode-summary span {
  color: var(--mode-accent);
  font-size: 12px;
  font-weight: 800;
}
.mode-summary strong {
  color: #f8fafc;
  font-size: 18px;
  line-height: 1.25;
}
.mode-summary small {
  color: #b9c4d6;
  font-size: 12px;
  line-height: 1.5;
}
.mode-summary-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mode-summary-tags span {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.44);
  color: #dbe4f0;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}
.mode-config-section {
  border-color: var(--mode-accent-line);
  border-top-width: 2px;
  background:
    linear-gradient(180deg, var(--mode-accent-soft), transparent 90px),
    var(--panel-2);
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.inline-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.dim { color: var(--muted-2); }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; color: var(--muted); }

.collapsible { padding: 0; overflow: hidden; }
.collapsible summary {
  list-style: none;
  cursor: pointer;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary span { font-size: 13px; font-weight: 700; color: #d8e2f0; }
.collapsible summary small { color: var(--muted); font-size: 12px; text-align: right; }
.advanced-body {
  border-top: 1px solid var(--line-soft);
  padding: 14px;
  display: grid;
  gap: 12px;
}
.option-line { display: flex; flex-wrap: wrap; gap: 14px; }

.dedupe-grid { display: grid; gap: 12px; }
.sub-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #253246;
  border-radius: 9px;
  padding: 13px;
  background: #0c1420;
}
.sub-panel h3 { font-size: 14px; color: #d8e2f0; }
.preview-panel { background: #0b1018; }
.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.preview-head > div:first-child {
  display: grid;
  gap: 5px;
}
.preview-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.preview-meta span {
  border: 1px solid rgba(34, 197, 94, 0.22);
  background: rgba(34, 197, 94, 0.09);
  color: #b7f7ce;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

#mask-params, #dedupe-params { display: grid; gap: 12px; }
#mask-stage, #dedupe-stage {
  position: relative;
  display: none;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  border: 1px solid #2b374b;
  background: #000;
  user-select: none;
}
#mask-stage {
  width: min(100%, 320px);
  margin-inline: auto;
}
#dedupe-stage {
  width: min(100%, 340px);
  aspect-ratio: 9 / 16;
  margin-inline: auto;
}
#dedupe-stage[data-orientation="landscape"] {
  width: min(100%, 680px);
  aspect-ratio: 16 / 9;
}
#mask-stage video { display: block; width: 100%; pointer-events: none; }
#dedupe-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
#mask-box {
  position: absolute;
  border: 2px solid var(--blue);
  background: rgba(59, 130, 246, .25);
  cursor: move;
}
#mask-handle, #dedupe-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: nwse-resize;
}
#mask-handle { background: var(--blue); }
#dedupe-overlay-box {
  position: absolute;
  border: 2px solid var(--green);
  background: rgba(34, 197, 94, .16);
  cursor: move;
}
#dedupe-overlay-preview, #dedupe-overlay-preview img, #dedupe-overlay-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
#dedupe-handle { background: var(--green); }
#dedupe-text-preview {
  position: absolute;
  left: 8%;
  right: 8%;
  display: none;
  color: #fff;
  font-weight: 700;
  text-align: left;
  line-height: 1.18;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
    1px 1px 0 #000, 0 2px 5px #000;
  cursor: move;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 86%;
  touch-action: none;
  user-select: none;
}

#stage-list, #job-list {
  list-style: none;
  display: grid;
  gap: 9px;
}
.job-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.job-summary div {
  border: 1px solid var(--line-soft);
  background: #0d1624;
  border-radius: 8px;
  padding: 10px;
}
.job-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.job-summary strong {
  color: #e8eef8;
  font-size: 13px;
}
#stage-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  background: #0d1624;
  border: 1px solid #1f2a3a;
  border-radius: 8px;
  padding: 10px;
}
.stage-item.stage-running {
  border-color: rgba(59, 130, 246, 0.5);
  background: #101d31;
}
.stage-item.stage-done { border-color: rgba(34, 197, 94, 0.22); }
.stage-item.stage-failed { border-color: rgba(239, 68, 68, 0.42); }
.stage-index {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #263142;
  color: #aab6c8;
  font-size: 12px;
  font-weight: 800;
}
.stage-running .stage-index { background: var(--blue); color: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
.stage-done .stage-index { background: rgba(34, 197, 94, 0.85); color: #052e16; }
.stage-failed .stage-index { background: var(--red); color: #fff; }
.stage-main { display: grid; gap: 2px; min-width: 0; }
.stage-main strong { font-size: 13px; }
.stage-main small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.stage-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #1f2a3a;
  margin-top: 5px;
}
.stage-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}
.stage-side {
  display: grid;
  justify-items: end;
  gap: 4px;
}
.stage-side small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.badge {
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.badge.pending, .badge.skipped, .badge.queued { background: #263142; color: #9aa6b8; }
.badge.running { background: #1d4ed8; color: #fff; }
.badge.done { background: rgba(22, 101, 52, .65); color: #86efac; }
.badge.failed { background: rgba(127, 29, 29, .72); color: #fecaca; }

#job-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: #0d1624;
  border: 1px solid #1f2a3a;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}
#job-list li:hover { border-color: #3b82f6; background: #101d31; }
#job-list li div { min-width: 0; }
#job-list small { color: var(--muted-2); font-size: 11px; }
.job-info {
  display: grid;
  gap: 5px;
}
.job-topline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.job-mode {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 800;
}
.job-info .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-info em {
  color: #fca5a5;
  font-size: 11px;
  font-style: normal;
  overflow-wrap: anywhere;
}

#result-area { margin-top: 12px; }
#result-area video { width: 100%; border-radius: 8px; margin-top: 8px; background: #000; }
.result-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#result-area a.dl {
  display: inline-flex;
  align-items: center;
  color: #bfdbfe;
  border: 1px solid #27466f;
  background: #0d1b2e;
  border-radius: 8px;
  padding: 7px 9px;
  text-decoration: none;
  font-size: 13px;
}
#result-area a.primary { background: var(--blue); color: white; border-color: var(--blue); }
.error-box {
  background: rgba(127, 29, 29, .32);
  border: 1px solid #b91c1c;
  color: #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 10px;
  white-space: pre-wrap;
}

.draft-retry-btn {
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.draft-retry-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.launch-draft-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #303741;
  color: var(--muted);
  font-size: 10px;
}
.launch-draft-note button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #46505d;
  border-radius: 6px;
  background: #242a31;
  color: #e5e7eb;
  font-size: 10px;
  white-space: nowrap;
}
.launch-draft-note button:hover { background: #303741; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-stack { grid-row: auto; }
}

@media (max-width: 720px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  #mode-switch { grid-template-columns: 1fr; }
  .bgm-picker-head { display: grid; }
  .bgm-source-tabs {
    width: 100%;
    flex-basis: auto;
  }
  .bgm-control-grid,
  .bgm-preview-row {
    grid-template-columns: 1fr;
  }
  .bgm-track-list { grid-template-columns: 1fr; max-height: 216px; }
  .mode-option span { min-height: auto; }
  .card { padding: 14px; }
  .form-section { padding: 12px; }
  .collapsible summary { align-items: flex-start; flex-direction: column; }
  .collapsible summary small { text-align: left; }
  .order-head { display: grid; }
  .order-head small { text-align: left; }
  #video-order-list li { grid-template-columns: 58px minmax(0, 1fr) 48px 48px; }
  .order-size { display: none; }
  #stage-list li { grid-template-columns: 28px 1fr; }
  #stage-list .stage-side { grid-column: 2; justify-items: start; }
  .job-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-head { display: grid; }
  .preview-meta { justify-content: flex-start; }
}

/* FunCut workspace refresh */
:root {
  --bg: #0b0d10;
  --panel: #15181d;
  --panel-2: #12151a;
  --panel-3: #0d1014;
  --line: #343a43;
  --line-soft: #262c34;
  --text: #f4f5f7;
  --muted: #9ba3ae;
  --muted-2: #6f7782;
  --blue: #407cff;
  --brand: #ff6b4a;
}

body {
  background: #0b0d10;
}

body::before {
  content: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: clamp(240px, 13.25vw, 252px) minmax(0, 1fr);
}

.primary-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  border-right: 1px solid #252a31;
  background: #111318;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 10px;
}

.sidebar-brand > div:last-child { display: grid; gap: 2px; }
.sidebar-brand strong { color: #f7f8fa; font-size: 20px; }
.sidebar-brand span { color: #7f8792; font-size: 11px; }
.sidebar-brand .brand-mark { width: 38px; height: 38px; font-size: 19px; }

.sidebar-nav {
  display: grid;
  gap: 5px;
  margin-top: 34px;
}

.sidebar-label {
  padding: 18px 13px 7px;
  color: #656d78;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-item,
.admin-link.sidebar-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #aab1bb;
  font-size: 15.5px;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}

.sidebar-item:has(.nav-count) {
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

.nav-count {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 106, 79, .16);
  color: #ff9a86;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.sidebar-item:hover,
.admin-link.sidebar-item:hover {
  background: #1c2026;
  color: #f3f4f6;
}

.sidebar-item.active {
  box-shadow: inset 3px 0 0 var(--brand);
  background: #292e36;
  color: #f4f5f7;
}

.nav-icon {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: inherit;
  font-size: 18px;
  font-weight: 500;
}

.sidebar-foot {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding: 13px 12px 4px;
  border-top: 1px solid #252a31;
}
.sidebar-foot span { color: #a8afb8; font-size: 12px; font-weight: 700; }
.sidebar-foot small { color: #626a75; font-size: 11px; }

.app-content { min-width: 0; }

#create-card,
#progress-card,
#history-card { scroll-margin-top: 98px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 15;
  max-width: none;
  margin: 0;
  min-height: 82px;
  padding: 18px 24px;
  align-items: center;
  border-bottom: 0;
  background: rgba(11, 13, 16, .94);
  backdrop-filter: blur(12px);
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff6b4a 0 34%, #f6b84a 34% 67%, #38bda8 67%);
}

.header-page-title { display: grid; gap: 3px; }
.header-page-title h1 { font-size: 18px; }
.header-page-title p { margin: 0; font-size: 11px; }
.mobile-brand { display: none; }

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f3f4f6;
  color: #111318;
  font-size: 21px;
}

.app-header h1 { font-size: 23px; }
.app-header p { margin-top: 3px; font-size: 12px; }

.app-nav {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 24px;
}

.app-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: #8f98a5;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.app-nav a:hover,
.app-nav a.active { color: #f4f5f7; }

.app-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -24px;
  height: 2px;
  background: var(--brand);
}

.workspace {
  width: 100%;
  max-width: 1520px;
  padding: 22px clamp(20px, 2vw, 32px) 40px;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 22vw, 350px);
  gap: clamp(18px, 1.4vw, 24px);
}

.records-workspace,
.credits-workspace {
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 22px clamp(20px, 2vw, 32px) 40px;
}

.credits-page {
  display: grid;
  gap: 20px;
}

.records-page {
  display: grid;
  gap: 18px;
}

.records-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #292e35;
}
.records-page-head > div { display: grid; gap: 5px; }
.records-eyebrow {
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
}
.records-page-head h2 { color: #f5f6f8; font-size: 24px; }
.records-page-head p { color: var(--muted); font-size: 12px; }
.records-refresh {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #3a414a;
  border-radius: 7px;
  background: #20252c;
  color: #d9dde3;
}
.records-refresh:hover { background: #2a3038; }

.records-tabs {
  width: fit-content;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid #30363f;
  border-radius: 8px;
  background: #14171c;
}
.records-tabs button {
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 6px;
  background: transparent;
  color: #8f98a5;
  font-size: 12px;
}
.records-tabs button.active {
  background: #2b3038;
  color: #f4f5f7;
}
.records-tabs span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 999px;
  background: #1a1e24;
  color: #b7bec8;
  font-size: 10px;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(150px, .7fr) minmax(150px, .7fr) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid #30363f;
  border-radius: 8px;
  background: #14171c;
}
.records-toolbar label { display: grid; gap: 7px; font-size: 11px; }
.records-toolbar input,
.records-toolbar select { min-height: 40px; }
.records-count {
  align-self: center;
  justify-self: end;
  padding: 6px 9px;
  border-radius: 6px;
  background: #242a31;
  color: #bbc2cb;
  font-size: 11px;
  white-space: nowrap;
}

.records-table-head,
.record-row {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(140px, 1fr) minmax(150px, 1.1fr) minmax(110px, .8fr) 86px 82px;
  align-items: center;
  gap: 14px;
}
.records-table-head {
  padding: 0 16px;
  color: #747d89;
  font-size: 10px;
  font-weight: 700;
}
.records-list { display: grid; gap: 8px; }
.record-row {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #2d343d;
  border-radius: 8px;
  background: #14171c;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .16s;
}
.record-row:hover,
.record-row:focus-visible {
  border-color: #4a535f;
  background: #191d23;
  transform: translateY(-1px);
  outline: none;
}
.record-task { min-width: 0; display: grid; gap: 4px; }
.record-task strong {
  overflow: hidden;
  color: #edf0f4;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-task small,
.record-row time,
.record-usage small { color: var(--muted); font-size: 10px; }
.record-row .job-mode { justify-self: start; }
.record-usage { display: grid; gap: 3px; color: #d9dde3; font-size: 11px; }
.record-row .badge { justify-self: start; }
.record-open {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 6px;
  background: #262c34;
  color: #d9dde3;
}
.record-open:hover { background: #343b45; }
.record-retry {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(245, 158, 11, .48);
  border-radius: 6px;
  background: rgba(245, 158, 11, .1);
  color: #fbbf24;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.record-retry:hover:not(:disabled) { background: rgba(245, 158, 11, .18); }
.records-empty {
  padding: 46px 20px;
  border: 1px dashed #303741;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.create-card {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.create-title {
  margin: 0 0 18px;
  padding: 0 2px;
}

.create-title h2 { font-size: 22px; }
.create-title p { font-size: 13px; }

#job-form { gap: 16px; }

.form-section {
  --section-accent: #7f9fff;
  border-color: #303741;
  border-radius: 8px;
  background: #15191f;
  padding: 20px;
  gap: 16px;
}

.form-section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.form-section-head > div { display: grid; gap: 4px; }
.form-section-head p { color: #aab4c3; font-size: 13px; line-height: 1.5; }

.step-number {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--section-accent, #ff6b5f) 56%, #3b424c);
  border-radius: 7px;
  color: color-mix(in srgb, var(--section-accent, #ff6b5f) 78%, white);
  background: color-mix(in srgb, var(--section-accent, #ff6b5f) 13%, #20252c);
  font: 700 11px/1 Consolas, monospace;
}

.section-label {
  color: #fbfcfe;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
}

.mode-select-section {
  padding: 20px;
  background: #15191f;
}

#mode-switch { gap: 12px; }

.mode-option span {
  min-height: 126px;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  column-gap: 12px;
  row-gap: 5px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid #3c444e;
  background: #292f37;
  box-shadow: none;
}

.mode-option span:hover {
  border-color: #606a76;
  background: #323943;
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.mode-icon {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #3a424c;
  font-size: 21px;
  font-style: normal;
}

.mode-option strong {
  align-self: end;
  color: #f2f4f7;
  font-size: 17px;
}

.mode-option em {
  align-self: start;
  padding: 0;
  background: transparent;
  color: #aeb6c0;
  font-size: 12px;
}

.mode-option input:checked + span,
.mode-option.mode-plot input:checked + span,
.mode-option.mode-narration input:checked + span,
.mode-option.mode-beat input:checked + span {
  border-color: var(--mode-accent);
  background:
    linear-gradient(90deg, var(--mode-accent-soft), transparent 72%),
    #303740;
  box-shadow: 0 0 0 2px var(--mode-accent-soft), 0 14px 32px rgba(0, 0, 0, 0.28);
  transform: translateY(-2px);
}

.mode-option input:checked + span .mode-icon { background: var(--mode-accent-soft); }
.mode-option input:checked + span em { color: #d2d7de; background: transparent; }

.mode-select-section > .hint {
  padding-left: 42px;
  color: #aeb5bf;
}

.mode-connector {
  grid-template-columns: minmax(190px, .7fr) minmax(0, 1.3fr);
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--mode-accent-line);
  border-left: 3px solid var(--mode-accent);
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--mode-accent-soft), transparent 58%),
    #171b20;
}

.mode-summary span { font-size: 11px; }
.mode-summary strong { font-size: 17px; }
.mode-summary small { color: #aeb5bf; }
.mode-summary-tags { justify-content: flex-end; }
.mode-summary-tags span {
  border-radius: 6px;
  border-color: #343b45;
  background: #20252c;
  padding: 6px 9px;
  color: #cfd4db;
  font-size: 11px;
}

.mode-config-section {
  border-color: var(--line-soft);
  border-top-width: 1px;
  background: #14171c;
}

#narration-options {
  border-color: var(--line-soft);
  background: #14171c;
}

label { color: #c2c8d0; }
input, select {
  min-height: 42px;
  border-color: #343b45;
  border-radius: 7px;
  background: #0e1115;
}
input:focus, select:focus {
  outline: 2px solid rgba(64, 124, 255, .28);
  border-color: #5d88e9;
}

input[type="file"] {
  min-height: 60px;
  padding: 15px 12px;
  border-style: dashed;
  background: #101318;
}

.bgm-picker {
  border-color: #343b45;
  border-radius: 8px;
  background: #101318;
  padding: 16px;
}

.bgm-source-tabs label {
  min-height: 38px;
  border-radius: 7px;
  border-color: #343b45;
  background: #181c22;
}

.collapsible {
  padding: 0;
  background: #14171c;
}

.collapsible summary { padding: 17px 20px; }
.collapsible summary span { color: #f4f5f7; font-size: 14px; }
.collapsible summary small { font-size: 11px; }
.summary-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  margin-right: 8px;
  border-radius: 6px;
  background: #262c34;
  color: #cbd1d9;
  font-size: 15px;
  font-weight: 400;
  transition: transform .18s;
}
.collapsible[open] .summary-icon { transform: rotate(45deg); }
.advanced-body { padding: 18px 20px 20px; }

.side-stack {
  position: relative;
  align-self: stretch;
  gap: 16px;
}
.side-stack .card { border-radius: 8px; box-shadow: none; }

.launch-card {
  position: sticky;
  top: 100px;
  align-self: start;
  z-index: 5;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 122px);
  overflow: auto;
  padding: 18px;
  border-color: #373e48;
  background: #171a1f;
}

.side-stack #progress-card {
  position: sticky;
  top: 100px;
  align-self: start;
}

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

.launch-head > div { display: grid; gap: 4px; }
.launch-head span { color: var(--muted); font-size: 11px; }
.launch-head strong { color: #f7f8fa; font-size: 17px; }
.launch-ready {
  padding: 5px 8px;
  border: 1px solid #3a414b;
  border-radius: 6px;
  background: #232830;
  color: #c9cfd7 !important;
  font-weight: 700;
}
.launch-ready.is-ready {
  border-color: rgba(34, 197, 94, .35);
  background: rgba(22, 101, 52, .3);
  color: #86efac !important;
}
.launch-ready.has-issues {
  border-color: rgba(245, 158, 11, .3);
  background: rgba(120, 53, 15, .25);
  color: #fcd34d !important;
}

.launch-preview {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px solid #2d343d;
  border-radius: 8px;
  background: #0d1014;
  text-align: center;
}
.preview-clap { font-size: 28px; filter: grayscale(.25); }
.launch-preview strong { font-size: 14px; }
.launch-preview span { color: var(--muted); font-size: 11px; }

.launch-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid #2d343d;
  border-radius: 8px;
  overflow: hidden;
}
.launch-summary div {
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid #2d343d;
  border-bottom: 1px solid #2d343d;
}
.launch-summary div:nth-child(2n) { border-right: 0; }
.launch-summary div:nth-last-child(-n+2) { border-bottom: 0; }
.launch-summary dt { color: var(--muted); font-size: 10px; }
.launch-summary dd {
  margin-top: 4px;
  overflow: hidden;
  color: #edf0f4;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launch-card .billing-preview {
  display: grid;
  padding: 13px;
  border-color: #3b424c;
  background: #20252c;
}
.launch-card .billing-preview strong { color: #ffffff; font-size: 22px; }
.launch-card .billing-preview small { line-height: 1.45; }

.launch-check {
  display: grid;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 7px;
  background: rgba(120, 53, 15, .12);
}
.launch-check > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.launch-check strong { color: #eceff3; font-size: 12px; }
.launch-check span { color: #fcd34d; font-size: 10px; }
.launch-check ul { display: grid; gap: 4px; padding-left: 16px; }
.launch-check li { color: #d5d9df; font-size: 11px; line-height: 1.45; }
.launch-check.is-ready {
  border-color: rgba(34, 197, 94, .28);
  background: rgba(22, 101, 52, .12);
}
.launch-check.is-ready span,
.launch-check.is-ready li { color: #86efac; }

.launch-actions {
  position: sticky;
  bottom: -18px;
  z-index: 3;
  display: grid;
  gap: 7px;
  margin: 0 -4px -18px;
  padding: 12px 4px 16px;
  background: linear-gradient(180deg, rgba(23, 26, 31, 0), #171a1f 20%);
}

#submit-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 7px;
  background: var(--brand);
  color: #17110f;
  font-size: 14px;
}
#submit-btn:hover { background: #ff8064; }
#submit-btn:disabled {
  background: #353b44;
  color: #858d98;
  cursor: not-allowed;
}
.launch-note { color: var(--muted-2); font-size: 10px; text-align: center; }

#progress-card,
.side-stack > .card:last-child { background: #14171c; }

#job-list { max-height: 520px; overflow: auto; padding-right: 2px; }
#job-list li { border-radius: 7px; background: #101318; }

@media (max-width: 1120px) {
  .app-nav { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .launch-card { position: static; max-height: none; overflow: visible; }
  .side-stack { position: static; grid-row: auto; }
  .launch-actions { position: static; margin-bottom: 0; padding-bottom: 0; }
}

@media (max-width: 1020px) {
  .records-table-head { display: none; }
  .record-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .record-row time,
  .record-usage { grid-row: 2; }
  .record-row time { grid-column: 1; }
  .record-usage { grid-column: 2; }
  .record-open,
  .record-retry { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .primary-sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 50;
    width: 100%;
    height: 68px;
    display: block;
    padding: 6px 8px;
    border-top: 1px solid #303640;
    border-right: 0;
    background: rgba(17, 19, 24, .97);
    backdrop-filter: blur(12px);
  }
  .sidebar-brand,
  .sidebar-label,
  .sidebar-foot { display: none; }
  .sidebar-nav {
    height: 100%;
    display: flex;
    align-items: stretch;
    gap: 4px;
    margin: 0;
  }
  .sidebar-item,
  .admin-link.sidebar-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 54px;
    grid-template-columns: 1fr;
    grid-template-rows: 25px 16px;
    place-items: center;
    gap: 1px;
    padding: 5px 4px;
    font-size: 10.5px;
    text-align: center;
  }
  .sidebar-item:has(.nav-count) {
    position: relative;
    grid-template-columns: 1fr;
  }
  .nav-icon { width: 25px; height: 25px; font-size: 17px; }
  .nav-count {
    position: absolute;
    top: 3px;
    left: calc(50% + 8px);
  }
  .sidebar-item.active { box-shadow: inset 0 2px 0 var(--brand); }
  .app-content { padding-bottom: 68px; }
  .mobile-brand {
    display: block;
    color: var(--brand);
    font-size: 10px;
    font-weight: 800;
  }
}

@media (max-width: 760px) {
  .app-header {
    padding: 14px 16px;
    align-items: center;
    flex-direction: row;
  }
  .brand-block { min-width: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-block p { display: none; }
  .header-actions { margin-left: auto; }
  .auth-entry-btn { padding: 8px 10px; }
  .version-pill { display: none; }
  .workspace { padding: 16px 14px 32px; }
  .records-workspace { padding: 16px 14px 32px; }
  .credits-workspace { padding: 16px 14px 32px; }
  .records-page-head { align-items: flex-start; }
  .records-toolbar { grid-template-columns: 1fr; }
  .records-count { justify-self: start; }
  .credit-summary { grid-template-columns: 1fr; }
  .record-row { grid-template-columns: minmax(0, 1fr) auto; }
  .record-row .job-mode { grid-column: 1; grid-row: 2; }
  .record-row time { grid-column: 1; grid-row: 3; }
  .record-usage { grid-column: 1; grid-row: 4; }
  .record-row .badge { grid-column: 2; grid-row: 1; }
  .record-open,
  .record-retry { grid-column: 2; grid-row: 2 / 5; align-self: end; }
  #mode-switch { grid-template-columns: 1fr; }
  .mode-option span { min-height: 88px; }
  .mode-connector { grid-template-columns: 1fr; }
  .mode-summary-tags { justify-content: flex-start; }
  .mode-select-section > .hint { padding-left: 0; }
  .form-section { padding: 16px; }
  .file-grid { grid-template-columns: 1fr; }
  #video-order-list li {
    grid-template-columns: 18px 76px minmax(0, 1fr);
    gap: 8px;
  }
  .video-thumb { width: 76px; }
  .media-status { grid-column: 2; justify-self: start; }
  .order-actions { grid-column: 3; grid-row: 2; justify-self: end; }
  .launch-summary { grid-template-columns: 1fr; }
  .launch-summary div,
  .launch-summary div:nth-child(2n),
  .launch-summary div:nth-last-child(-n+2) {
    border-right: 0;
    border-bottom: 1px solid #2d343d;
  }
  .launch-summary div:last-child { border-bottom: 0; }
}

@media (max-width: 560px) {
  .app-header { min-height: 72px; gap: 8px; }
  .header-page-title { gap: 1px; }
  .header-page-title h1 { font-size: 17px; }
  .header-page-title p { display: none; }
  .header-actions { gap: 5px; }
  #user-email { display: none; }
  .user-pill { padding: 4px; gap: 4px; }
  .user-pill button { padding: 6px 8px; }
  .auth-entry-btn { font-size: 11px; }
  .form-section { padding: 14px; }
}

/* Compact Vue-inspired layout for the original workbench basic settings. */
.mode-config-section {
  display: grid;
  gap: 14px;
}
.mode-config-section .form-section-head { margin-bottom: 0; }
.primary-media-upload {
  min-height: 118px;
  border: 1px dashed #485361;
  border-radius: 7px;
  background: #101419;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color .16s, background .16s;
}
.primary-media-upload:hover {
  border-color: #647184;
  background: #121820;
}
.primary-media-upload input,
.outro-upload input { display: none; }
.primary-media-upload-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #152644;
  color: #4b8cff;
  font-size: 25px;
  line-height: 1;
}
.primary-media-upload strong { color: #eef1f5; font-size: 14px; }
.primary-media-upload small { color: #8f9aaa; font-size: 11px; }
.output-spec-row,
.audio-level-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.audio-level-row label { align-content: start; }
.audio-level-row input[type="range"] {
  min-height: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  accent-color: #2584f5;
}
.audio-level-row output {
  color: #f4f6f8;
  font-size: 12px;
  font-weight: 700;
}
.outro-upload {
  min-height: 44px;
  border: 1px dashed #46515f;
  border-radius: 7px;
  background: #101419;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  color: #dce2ea;
}
.outro-upload:hover { border-color: #647184; background: #121820; }
.outro-upload span { color: #aeb8c5; }
.outro-upload strong { font-size: 12px; }

/* Keep the active job visible at the top of the right rail after submission. */
.side-stack #progress-card {
  order: 1;
  max-height: calc(100vh - 122px);
  overflow: auto;
  border-color: #3b4552;
}
.side-stack #launch-card { order: 2; }
#progress-card .section-title {
  position: sticky;
  top: -1px;
  z-index: 2;
  margin: -1px -1px 12px;
  padding: 1px 1px 11px;
  background: #14171c;
  border-bottom: 1px solid #2d343d;
}
@media (max-width: 760px) {
  .output-spec-row,
  .audio-level-row { grid-template-columns: 1fr; }
  .primary-media-upload { min-height: 106px; }
  .side-stack #progress-card { max-height: none; overflow: visible; }
}

/* Final workspace sizing rules: keep controls inside the viewport and modes 2 x 2. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.app-shell,
.app-content,
.workspace,
.create-card,
.side-stack {
  min-width: 0;
}

#mode-switch {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 760px) {
  #mode-switch { grid-template-columns: 1fr; }
}

/* Guided single-page creation flow. Keep capabilities visible, reveal detail on demand. */
.mode-connector {
  min-height: 0;
  padding: 13px 16px;
}
.mode-summary {
  gap: 2px;
}
.mode-summary small {
  line-height: 1.45;
}

.creation-tools-section {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-color: var(--line-soft);
  background: #15191f;
}

.narration-settings-block {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--mode-accent-line);
  border-radius: 8px;
  background: linear-gradient(100deg, var(--mode-accent-soft), transparent 45%), #101419;
}
.feature-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.feature-block-head > div {
  display: grid;
  gap: 3px;
}
.feature-block-head strong {
  color: #f2f4f7;
  font-size: 16px;
}
.feature-block-head small {
  color: #aab4c3;
  font-size: 12px;
}
.mode-required-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--mode-accent-line);
  border-radius: 6px;
  color: var(--mode-accent);
  background: var(--mode-accent-soft);
  font-size: 10px;
}
.narration-settings-block > .row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.narration-settings-block .subtitle-preview-panel {
  grid-column: 1 / -1;
}

.feature-toggle-list {
  overflow: hidden;
  border: 1px solid #303741;
  border-radius: 8px;
  background: #101419;
}
.feature-toggle-item + .feature-toggle-item,
.feature-toggle-list > .feature-toggle-row + .feature-toggle-row,
.feature-toggle-list > .feature-toggle-row + .feature-toggle-item {
  border-top: 1px solid #2b323b;
}
.feature-toggle-row {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 15px;
  cursor: pointer;
  background: #11161c;
  transition: background .16s, box-shadow .16s;
}
.feature-toggle-row:hover {
  background: #151b22;
}
.feature-toggle-row.is-enabled {
  background: linear-gradient(90deg, rgba(64, 124, 255, .10), transparent 56%), #131920;
  box-shadow: inset 3px 0 #407cff;
}
.feature-toggle-row > span {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.feature-toggle-row > select {
  flex: 0 0 auto;
  width: auto;
  max-width: 50%;
}
.feature-toggle-row strong {
  color: #eef1f5;
  font-size: 14px;
}
.feature-toggle-row small {
  color: #a3adbb;
  font-size: 11px;
  line-height: 1.45;
}
.feature-toggle-row > input[type="checkbox"] {
  appearance: none;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 2px;
  border: 1px solid #4a5461;
  border-radius: 12px;
  background: #242b34;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}
.feature-toggle-row > input[type="checkbox"]::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #a5afbc;
  transition: transform .16s, background .16s;
}
.feature-toggle-row > input[type="checkbox"]:checked {
  border-color: #407cff;
  background: #245fd4;
}
.feature-toggle-row > input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: #fff;
}
.feature-toggle-item > #mask-params,
.feature-toggle-item > #dedupe-params {
  margin: 0 15px 15px;
  padding-top: 15px;
  border-top: 1px solid #2f3741;
}
.dedupe-feature-item #dedupe-params {
  gap: 12px;
}

.safety-audit-card {
  padding: 14px 20px;
  gap: 10px;
}
.safety-audit-card-head {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.safety-audit-card-head h3 {
  margin: 1px 0 2px;
  font-size: 16px;
}
.safety-audit-card-head p {
  font-size: 12px;
}
.safety-audit-card > .safety-audit-tags,
.safety-audit-card > .hint {
  margin-left: 42px;
}

@media (max-width: 1100px) {
  .narration-settings-block > .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .creation-tools-section { padding: 14px; }
  .narration-settings-block > .row { grid-template-columns: 1fr; }
  .audio-settings-panel.is-no-bgm .audio-level-row { max-width: 100%; }
  .feature-block-head { align-items: flex-start; }
  .feature-toggle-row { min-height: 62px; padding: 11px 12px; }
  .feature-toggle-item > #mask-params,
  .feature-toggle-item > #dedupe-params { margin: 0 12px 12px; }
  .safety-audit-card-head {
    grid-template-columns: 30px minmax(0, 1fr);
  }
  .safety-audit-card-head .switch-control {
    grid-column: 2;
    justify-self: start;
  }
  .safety-audit-card > .safety-audit-tags,
  .safety-audit-card > .hint { margin-left: 42px; }
}

@media (max-width: 1120px) {
  .side-stack {
    align-self: auto;
  }
  .side-stack #launch-card,
  .side-stack #progress-card {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }
}
