/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --red:    #E30613;
  --red-dk: #a5040e;
  --bg:     #111111;
  --bg2:    #1c1c1c;
  --bg3:    #262626;
  --border: #333333;
  --text:   #e8e8e8;
  --muted:  #777777;
  --sel:    rgba(227, 6, 19, 0.28);
  --play:   rgba(255, 220, 0, 0.35);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-logo {
  height: 34px;
  width: auto;
  display: block;
}

.header-title {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--red-dk); }
.btn-primary:disabled { background: #444; cursor: not-allowed; }

.btn-export {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-export:hover:not(:disabled) { background: var(--red-dk); }
.btn-export:disabled { background: #333; color: var(--muted); cursor: not-allowed; }

/* ─── Upload page ────────────────────────────────────────────────────────────── */
.upload-page main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 20px;
  gap: 24px;
}

.upload-card {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s;
}
.upload-card.drag-over { border-color: var(--red); background: rgba(227,6,19,0.05); }

.upload-icon { font-size: 40px; color: var(--muted); }
.upload-label { font-size: 17px; font-weight: 600; }
.upload-hint { font-size: 13px; color: var(--muted); }

.file-list {
  max-width: 480px;
  width: 100%;
  background: var(--bg2);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.file-list-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); flex-shrink: 0; }
.file-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 18px; line-height: 1;
  padding: 0 4px;
}
.file-remove:hover { color: var(--red); }
.btn-upload { margin-top: 8px; align-self: flex-end; }

.status-bar {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.progress-track {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ─── Editor layout ──────────────────────────────────────────────────────────── */
.editor-page { overflow: hidden; }

.editor-layout {
  display: grid;
  grid-template-columns: 42% 1fr;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ─── Transcript panel ───────────────────────────────────────────────────────── */
.panel-transcript {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.panel-header {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transcript-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

.rush-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 20px 0 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.rush-header:first-child { padding-top: 0; }

.words-block {
  line-height: 1.9;
  user-select: text;
  cursor: text;
  margin-bottom: 24px;
}

.word {
  display: inline;
  border-radius: 3px;
  cursor: pointer;
  padding: 1px 0;
  transition: background 0.08s;
}
.word:hover { background: var(--bg3); }
.word.playing { background: var(--play); }
.word.selected { background: var(--sel); }

.hint {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}
.hint.error { color: #e06c6c; }

/* ─── Right panel ────────────────────────────────────────────────────────────── */
.panel-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-wrap {
  flex-shrink: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

#video-player {
  width: 100%;
  max-height: 40vh;
  display: block;
  object-fit: contain;
  background: #000;
}

.rush-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.rush-tab {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
}
.rush-tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ─── Segments panel ─────────────────────────────────────────────────────────── */
.segments-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.segments-hint { font-weight: 400; color: var(--muted); }

.segments-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segment-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: default;
  transition: border-color 0.1s, opacity 0.1s;
}
.segment-row.dragging { opacity: 0.4; }
.segment-row.drag-over { border-color: var(--red); }

.seg-handle {
  color: var(--muted);
  cursor: grab;
  font-size: 18px;
  line-height: 1.2;
  flex-shrink: 0;
  user-select: none;
}

.seg-body { flex: 1; min-width: 0; }

.seg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.seg-file {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.seg-time { font-size: 11px; color: var(--muted); }

.seg-text {
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.seg-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.seg-remove:hover { color: var(--red); }

.total-duration {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.export-opts {
  padding: 8px 16px 12px;
  flex-shrink: 0;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.opt-row input[type="checkbox"] {
  accent-color: var(--red);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.opt-row:hover { color: var(--text); }

.opt-sub {
  margin-top: 6px;
  padding-left: 22px;
}
.opt-sub select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  width: 100%;
}

/* ─── Export overlay ─────────────────────────────────────────────────────────── */
.export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.export-overlay.hidden { display: none; }

.export-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 48px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
}

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
