:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #eef2f0;
  --border: #d7dedb;
  --border-strong: #aebcb7;
  --text: #17201e;
  --text-muted: #60706b;
  --teal: #087f75;
  --teal-dark: #06655e;
  --teal-soft: #d9f1ed;
  --amber: #d97706;
  --danger: #b42318;
  --shadow: 0 10px 24px rgba(34, 52, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 15px;
}

.app-header p,
.selection-title p,
.section-heading span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.server-badge {
  border: 1px solid #aad8d2;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf9f7;
  color: var(--teal-dark);
  font-size: 12px;
}

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

.app-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

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

.sidebar-heading,
.workspace-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-heading {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.file-list {
  min-height: 180px;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-item {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.file-item:hover {
  background: var(--surface-muted);
}

.file-item.active {
  border-color: #99d6cf;
  background: var(--teal-soft);
}

.file-name {
  display: block;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: flex;
  gap: 8px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.draft-dot {
  color: var(--teal-dark);
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 22px 30px;
}

.workspace-header {
  margin-bottom: 14px;
}

.selection-title {
  min-width: 0;
}

.selection-title h2,
.selection-title p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-actions,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-button,
.icon-button {
  border: 1px solid var(--teal);
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}

.text-button {
  min-height: 34px;
  padding: 6px 12px;
}

.text-button.compact {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.text-button.secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.text-button.accent {
  border-color: var(--amber);
  background: var(--amber);
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
}

.job-panel,
.result-panel {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
}

.job-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.job-copy strong {
  color: var(--text);
}

.progress-track {
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: #dfe7e4;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.media-stage {
  position: relative;
  display: grid;
  min-height: 280px;
  max-height: 56vh;
  overflow: hidden;
  place-items: center;
  border-radius: 6px;
  background: #111817;
  box-shadow: var(--shadow);
}

.media-stage video {
  display: block;
  width: 100%;
  max-height: 56vh;
}

.empty-player {
  position: absolute;
  color: #b5c4c0;
}

.timeline-section,
.segments-section,
.cut-options,
.settings-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.range-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.range-control input {
  width: 150px;
}

.timeline-group {
  margin-top: 11px;
}

.timeline-label {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.overview-wrap {
  height: 78px;
}

.detail-wrap {
  height: 132px;
  cursor: crosshair;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.segment-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.segment-block {
  position: absolute;
  top: 28px;
  bottom: 20px;
  min-width: 5px;
  border: 1px solid #087f75;
  background: rgba(8, 127, 117, 0.28);
  cursor: grab;
  pointer-events: auto;
}

.segment-block:active {
  cursor: grabbing;
}

.segment-block.active {
  border-color: var(--amber);
  background: rgba(217, 119, 6, 0.24);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.22);
}

.segment-block-label {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  overflow: hidden;
  color: #064e49;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  border: 0;
  background: var(--teal);
  cursor: ew-resize;
}

.segment-handle.left {
  left: -1px;
}

.segment-handle.right {
  right: -1px;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--amber);
  pointer-events: none;
}

.pan-range {
  width: 100%;
  margin: 5px 0 0;
}

.segment-table-header,
.segment-row {
  display: grid;
  grid-template-columns: 48px minmax(150px, 1.35fr) minmax(110px, 1fr) minmax(110px, 1fr) 88px 116px;
  align-items: center;
  gap: 8px;
}

.segment-table-header {
  margin-top: 10px;
  padding: 0 8px 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.segment-row {
  border-top: 1px solid var(--border);
  border-left: 3px solid transparent;
  padding: 8px;
}

.segment-row.active {
  border-left-color: var(--amber);
  background: #fff8eb;
}

.segment-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 7px;
  background: var(--surface);
}

.row-actions {
  display: flex;
  gap: 6px;
}

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

.mini-button {
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 5px 7px;
  background: var(--surface);
  color: var(--text);
}

.mini-button.delete {
  color: var(--danger);
}

.empty-list,
.empty-sidebar {
  padding: 16px 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.cut-options {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.cut-options label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.setting-field {
  display: grid;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.setting-field input {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px;
}

.settings-actions {
  margin-top: 12px;
}

.result-panel {
  margin-top: 16px;
  border-color: #aad8d2;
  background: #edf9f7;
  color: var(--teal-dark);
}

.result-panel.error {
  border-color: #efb5af;
  background: #fff1ef;
  color: var(--danger);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 6px;
}

.login-panel p {
  margin-bottom: 18px;
  color: var(--text-muted);
  line-height: 1.55;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.login-panel input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 9px;
}

.login-panel .text-button {
  width: 100%;
  margin-top: 14px;
}

.login-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: 230px;
    max-height: 230px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .file-list {
    min-height: 0;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px 12px 24px;
  }

  .media-stage {
    min-height: 180px;
  }

  .segment-table-header {
    display: none;
  }

  .segment-row {
    grid-template-columns: 36px 1fr 1fr;
  }

  .segment-row .segment-name {
    grid-column: 2 / 4;
  }

  .segment-row .duration {
    display: none;
  }

  .row-actions {
    grid-column: 2 / 4;
  }
}
