:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --line: #d9dee5;
  --text: #15191f;
  --muted: #667085;
  --accent: #2364aa;
  --accent-strong: #184e86;
  --green: #1d7f4f;
  --red: #b42318;
  --amber: #a15c07;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px/1.5 Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

p {
  margin: 0;
}

.topbar p,
.project-head p {
  color: var(--muted);
}

.mode-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #f3f6f9;
}

.mode-tab {
  min-height: 36px;
  border-color: #c7ced8;
  background: #fff;
  color: #1f2937;
}

.mode-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100vh - 121px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2f6;
  padding: 16px;
  overflow: auto;
}

.workspace {
  padding: 18px;
  overflow: auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

form,
.settings-row {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c7ced8;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
}

.range-control {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px 58px;
  align-items: center;
  gap: 8px;
}

.range-step {
  min-height: 34px;
  width: 34px;
  padding: 0;
}

.range-control output {
  color: #1f2937;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

button,
.button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  font: 600 14px/1.2 Arial, Helvetica, sans-serif;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary {
  border-color: #c7ced8;
  background: #fff;
  color: #1f2937;
}

.secondary:hover {
  background: #f1f4f8;
}

.project-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.project-item {
  width: 100%;
  text-align: left;
  display: grid;
  align-items: flex-start;
  justify-content: stretch;
  gap: 3px;
  background: #fff;
  color: var(--text);
  border-color: #cfd6df;
}

.project-item strong,
.project-item span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.project-item:hover,
.project-item.active {
  background: #e8f1fb;
  border-color: var(--accent);
}

.project-item span {
  display: block;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}

.mini-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e4e9ef;
  overflow: hidden;
  margin-top: 10px;
}

.mini-progress span {
  height: 100%;
  background: var(--green);
  margin: 0;
}

.muted {
  color: var(--muted);
}

.empty-state {
  border: 1px dashed #b9c3d0;
  border-radius: 8px;
  background: #fff;
  padding: 34px;
  max-width: 720px;
}

.empty-state p {
  color: var(--muted);
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

.project-view {
  display: grid;
  gap: 16px;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.video-workflow-tabs {
  display: flex;
  gap: 8px;
}

.video-workflow-section {
  display: grid;
  gap: 14px;
}

.settings-row {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.video-output-settings {
  grid-template-columns: 1fr;
}

.design-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.preview-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-panel {
  padding: 12px;
}

.video-preview-shell {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #05070a;
  aspect-ratio: 16 / 9;
}

.video-preview-shell video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #05070a;
}

.subtitle-preview-overlay {
  position: absolute;
  display: flex;
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
}

.subtitle-preview-overlay span {
  display: block;
  white-space: pre-wrap;
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: break-word;
  word-break: normal;
}

.design-controls {
  display: grid;
  gap: 14px;
}

.control-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.control-panel h3 {
  margin: 0;
  font-size: 14px;
}

.color-grid,
.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.voice-preview-actions {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.voice-preview-audio {
  width: 100%;
  min-width: 0;
  height: 38px;
}

.checkbox-label {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  align-self: end;
  min-height: 38px;
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.progress-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e4e9ef;
  overflow: hidden;
}

#progressBar,
#videoProgressBar {
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease;
}

.error {
  color: var(--red);
  margin-top: 8px;
}

.chunks {
  display: grid;
  gap: 12px;
}

.transcript-list {
  display: grid;
  gap: 10px;
}

.transcript-segment {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment-time {
  color: var(--muted);
  font: 12px/1.4 Consolas, "Courier New", monospace;
}

.segment-text {
  white-space: pre-wrap;
}

.segment-lines {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.segment-edit-label {
  display: grid;
  gap: 5px;
  color: #344054;
  font-size: 12px;
}

.segment-edit {
  min-height: 58px;
  width: 100%;
  resize: vertical;
  border: 1px solid #c7ced8;
  border-radius: 6px;
  padding: 8px 10px;
  font: 14px/1.45 Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #fff;
}

.segment-translation-edit {
  color: #0f5132;
}

.segment-edit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segment-save-button {
  min-height: 32px;
  padding: 6px 10px;
}

.segment-save-status {
  font-size: 12px;
}

.chunk {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.chunk-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #f3f6f9;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.chunk-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.chunk-pane {
  padding: 12px;
  min-width: 0;
}

.chunk-pane + .chunk-pane {
  border-left: 1px solid var(--line);
}

.chunk-pane h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #344054;
}

.chunk-text {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  color: #1f2937;
}

.status-DONE {
  color: var(--green);
}

.status-FAILED {
  color: var(--red);
}

.status-TRANSLATING {
  color: var(--amber);
}

.status-PROCESSING {
  color: var(--amber);
}

.status-COMPLETED {
  color: var(--green);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

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

  .project-head,
  .chunk-body,
  .design-workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .actions {
    justify-content: flex-start;
  }

  .chunk-pane + .chunk-pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .workspace,
  .sidebar {
    padding: 12px;
  }

  .mode-tabs {
    padding: 10px 12px;
  }

  .transcript-segment {
    grid-template-columns: 1fr;
  }

  .color-grid,
  .two-column,
  .export-actions,
  .voice-preview-actions {
    grid-template-columns: 1fr;
  }
}
