:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #67717f;
  --line: #d8dde3;
  --soft-line: #e9edf1;
  --surface: #ffffff;
  --panel: #f5f7f9;
  --panel-strong: #eef2f5;
  --teal: #2f8f83;
  --teal-dark: #1f645e;
  --amber: #f6c343;
  --rose: #d85c72;
  --blue: #5477a5;
  --shadow: 0 16px 36px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--panel);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    "PingFang TC",
    system-ui,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1,
.band-title h2,
.sidebar h2,
.settings-block h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

.topbar-actions,
.sidebar-head,
.band-title,
.title-actions,
.player-tools,
.field-grid,
.swatches {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(47, 143, 131, 0.24);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(47, 143, 131, 0.08);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-head {
  justify-content: space-between;
  min-height: 64px;
  padding: 18px;
  border-bottom: 1px solid var(--soft-line);
}

.sidebar h2 {
  font-size: 16px;
}

.project-list,
.clip-list,
.export-list,
.subtitle-list {
  display: grid;
  gap: 10px;
}

.project-list {
  padding: 14px;
}

.project-card,
.clip-card,
.export-row {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--surface);
}

.project-card,
.clip-card {
  width: 100%;
  padding: 12px;
  text-align: left;
}

.project-card.active,
.clip-card.active {
  border-color: rgba(47, 143, 131, 0.62);
  box-shadow: 0 0 0 2px rgba(47, 143, 131, 0.14);
}

.project-card strong,
.clip-card strong {
  display: block;
  margin-bottom: 8px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta,
.clip-meta,
.export-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.export-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.main-stage {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 18px;
}

.upload-band,
.analysis-band,
.export-band {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-band,
.analysis-band {
  border-radius: 8px;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) minmax(130px, 0.7fr) minmax(150px, 0.8fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-drop label,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.file-drop label {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 11px 12px;
}

.file-drop strong,
.file-drop span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop strong {
  font-size: 15px;
}

.file-drop span,
.field span {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field input,
.field select,
.field textarea {
  min-height: 38px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 72px;
  resize: vertical;
}

.transcript-field {
  grid-column: 1 / -1;
}

.transcript-field textarea {
  min-height: 118px;
  line-height: 1.55;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.segment {
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--teal);
  color: #fff;
}

.primary-button,
.ghost-button,
.icon-button {
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--teal-dark);
  color: #fff;
  background: var(--teal);
}

.band-title .primary-button,
.band-title .ghost-button {
  min-width: 112px;
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 18px;
  line-height: 1;
}

.wide {
  width: 100%;
}

.band-title {
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--soft-line);
}

.band-title h2 {
  font-size: 19px;
}

.band-title.compact {
  min-height: 60px;
  padding: 13px 14px;
}

.band-title.compact h2 {
  font-size: 16px;
}

.progress-panel {
  padding: 16px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-copy strong {
  color: var(--ink);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-strong);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  transition: width 220ms ease;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(8, minmax(74px, 1fr));
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.stage-list li {
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
}

.stage-list li.done {
  border-color: rgba(47, 143, 131, 0.32);
  color: var(--teal-dark);
  background: rgba(47, 143, 131, 0.08);
}

.stage-list li.current {
  border-color: rgba(246, 195, 67, 0.7);
  color: #6c4c00;
  background: rgba(246, 195, 67, 0.16);
}

.insight-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.insight-item {
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid rgba(84, 119, 165, 0.22);
  border-radius: 6px;
  background: rgba(84, 119, 165, 0.08);
}

.insight-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.insight-item span {
  color: var(--muted);
  font-size: 12px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

#newProjectButton,
#clearExportsButton,
#autoRenderButton,
#analyzeButton,
#selectAllClipsButton,
#rerankButton,
#renderFinalButton,
#downloadSelectedButton,
#exportClipButton,
#exportAllButton,
#regenerateTitleButton,
#regenerateCopyButton,
.clip-card-head,
.player-tools,
.settings-column,
.segmented {
  display: none;
}

.clip-column,
.preview-column,
.settings-column,
.export-band {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.clip-list {
  max-height: 690px;
  overflow: auto;
  padding: 14px;
}

.clip-card {
  display: grid;
  gap: 9px;
  cursor: pointer;
}

.clip-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.clip-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clip-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.clip-select input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.clip-open,
.clip-card-main {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.clip-open {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.clip-card-main {
  display: grid;
  width: 100%;
  gap: 9px;
  padding: 0;
  text-align: left;
}

.compact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
}

.score-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-strong);
}

.score-bar span {
  display: block;
  height: 100%;
  background: var(--rose);
}

.reason {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.signal-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(246, 195, 67, 0.22);
  color: #5c4407;
  font-size: 12px;
  font-weight: 800;
}

.preview-column {
  display: grid;
  gap: 0;
}

.video-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 540px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(84, 119, 165, 0.22), transparent 45%),
    linear-gradient(315deg, rgba(63, 180, 137, 0.18), transparent 44%),
    #1f242a;
}

.video-frame video {
  position: relative;
  z-index: 2;
  width: min(100%, 330px);
  aspect-ratio: 9 / 16;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  object-fit: cover;
  background: #101317;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.34);
}

.video-frame.has-video .video-placeholder {
  display: none;
}

.video-placeholder {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  width: min(calc(100% - 36px), 330px);
  aspect-ratio: 9 / 16;
  margin: auto;
  border: 1px dashed rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.video-placeholder span {
  align-self: end;
  font-size: 13px;
}

.video-placeholder strong {
  align-self: start;
  font-size: 24px;
}

.subtitle-overlay {
  position: absolute;
  z-index: 3;
  bottom: 70px;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: max-content;
  max-width: min(340px, calc(100% - 48px));
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
}

.subtitle-chip-row {
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  transform: translateY(8px);
}

.subtitle-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-width: 150px;
  padding: 3px 10px 5px;
  border: 3px solid #fff;
  border-radius: 4px;
  color: #fff;
  background: #ff4378;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.68);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000;
  transform: rotate(-4deg);
}

.subtitle-chip:nth-child(2n) {
  background: #2bd2be;
  transform: rotate(4deg) translateY(3px);
}

.subtitle-chip:nth-child(3n) {
  background: #6090ff;
}

.subtitle-burst {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  max-width: 100%;
  padding: 12px 26px 14px;
  color: #1e1d22;
  background: #fff;
  clip-path: polygon(50% 0%, 58% 14%, 73% 6%, 75% 22%, 93% 22%, 84% 38%, 100% 50%, 84% 62%, 93% 78%, 75% 78%, 73% 94%, 58% 86%, 50% 100%, 42% 86%, 27% 94%, 25% 78%, 7% 78%, 16% 62%, 0% 50%, 16% 38%, 7% 22%, 25% 22%, 27% 6%, 42% 14%);
  filter: drop-shadow(7px 8px 0 rgba(0, 0, 0, 0.62));
}

.subtitle-burst::before {
  position: absolute;
  inset: 6px;
  z-index: -1;
  content: "";
  background: #ffda2a;
  clip-path: inherit;
}

.subtitle-primary {
  display: block;
  max-width: 270px;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: anywhere;
  text-shadow:
    2px 2px 0 #fff,
    -2px 2px 0 #fff,
    2px -2px 0 #fff,
    -2px -2px 0 #fff,
    4px 5px 0 rgba(0, 0, 0, 0.38);
}

.subtitle-overlay.mint .subtitle-burst::before {
  background: #2bd2be;
}

.subtitle-overlay.mint .subtitle-primary,
.subtitle-overlay.rose .subtitle-primary {
  color: #fff;
  text-shadow:
    2px 2px 0 #000,
    -2px 2px 0 #000,
    2px -2px 0 #000,
    -2px -2px 0 #000,
    4px 5px 0 rgba(0, 0, 0, 0.45);
}

.subtitle-overlay.rose .subtitle-burst::before {
  background: #ff4378;
}

.subtitle-overlay.rendered {
  display: none;
}

.player-tools {
  flex-wrap: wrap;
  padding: 12px;
  border-top: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
  background: #fff;
}

#markStartButton,
#markEndButton {
  display: none;
}

.timeline {
  position: relative;
  height: 72px;
  margin: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(103, 113, 127, 0.12) 38px 39px),
    linear-gradient(90deg, rgba(84, 119, 165, 0.16), rgba(47, 143, 131, 0.16));
}

.timeline-window {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 16%;
  width: 26%;
  border: 2px solid var(--rose);
  border-radius: 6px;
  background: rgba(216, 92, 114, 0.16);
}

.settings-column {
  display: grid;
}

.settings-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--soft-line);
}

.settings-block:last-child {
  border-bottom: 0;
}

.settings-block h3 {
  font-size: 15px;
}

.field-grid {
  align-items: start;
}

.field-grid .field {
  min-width: 0;
  flex: 1;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--swatch);
}

.swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px #fff inset;
}

.subtitle-list {
  max-height: 260px;
  overflow: auto;
}

.subtitle-row {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--panel);
}

.subtitle-row label {
  color: var(--muted);
  font-size: 12px;
}

.subtitle-row textarea {
  width: 100%;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
}

.render-status {
  min-height: 38px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.render-status.ready {
  border-color: rgba(47, 143, 131, 0.28);
  color: var(--teal-dark);
  background: rgba(47, 143, 131, 0.08);
}

.render-status.error {
  border-color: rgba(216, 92, 114, 0.34);
  color: #8a2d3e;
  background: rgba(216, 92, 114, 0.08);
}

.export-band {
  overflow: hidden;
}

.export-list {
  padding: 14px;
}

.export-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.export-row strong {
  display: block;
  margin-bottom: 5px;
}

.empty-state {
  min-height: 82px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 1180px) {
  .upload-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  }

  .settings-column {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-block {
    border-bottom: 0;
    border-right: 1px solid var(--soft-line);
  }

  .settings-block:last-child {
    border-right: 0;
  }
}

@media (max-width: 820px) {
  .topbar {
    padding: 12px 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .project-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 1fr);
    overflow-x: auto;
  }

  .main-stage {
    padding: 12px;
  }

  .upload-form,
  .editor-layout,
  .settings-column {
    grid-template-columns: 1fr;
  }

  .stage-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-panel {
    grid-template-columns: 1fr;
  }

  .video-frame {
    min-height: 480px;
  }

  .settings-block {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .export-row {
    grid-template-columns: 1fr;
  }
}

#newProjectButton,
#clearExportsButton,
#autoRenderButton,
#analyzeButton,
#selectAllClipsButton,
#rerankButton,
#renderFinalButton,
#downloadSelectedButton,
#exportClipButton,
#exportAllButton,
#regenerateTitleButton,
#regenerateCopyButton,
.clip-card-head,
.player-tools,
.settings-column,
.segmented {
  display: none !important;
}
