:root {
  /* Architectural Blueprint & Craft Studio Light Palette */
  --bg: #f8fafc;
  --bg-dots: rgba(37, 99, 235, 0.08);
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --panel-hover: #e2e8f0;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --line-blueprint: rgba(37, 99, 235, 0.09);
  
  --text: #090d16;
  --text-muted: #334155;
  --text-dim: #64748b;

  /* Signature Deep Cobalt / Blueprint Blue */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-light: #3b82f6;
  --accent-subtle: #eff6ff;
  --accent-border: #bfdbfe;
  --accent-glow: rgba(29, 78, 216, 0.2);
  --accent-ink: #ffffff;
  
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-subtle: #fef2f2;
  
  /* Timeline Subtitle Blocks */
  --cap: #ffffff;
  --cap-border: #cbd5e1;
  --cap-text: #0f172a;
  --cap-sel: #eff6ff;
  --cap-sel-border: #1d4ed8;

  --radius-sm: 5px;
  --radius: 8px;
  --radius-md: 10px;
  
  --sidebar: 340px;
  --timeline: 245px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 20px 40px -15px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--bg);
  /* Faded architectural graph-paper grid pattern */
  background-image: 
    linear-gradient(var(--line-blueprint) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-blueprint) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  font: 14.5px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  letter-spacing: -0.015em;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: 50px 1fr var(--timeline);
  grid-template-areas: "top top" "side stage" "tl tl";
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15.5px; }
.brand-logo-img {
  width: 34px; height: 34px; object-fit: contain; display: block;
  filter: drop-shadow(0 2px 5px rgba(85, 85, 255, 0.28));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand:hover .brand-logo-img { transform: scale(1.08) rotate(-4deg); }
.brand-text { font-size: 15.5px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.badge-tag {
  font-size: 10px; font-weight: 700; padding: 2px 7px; margin-left: 2px;
  border-radius: var(--radius-sm); background: var(--accent-subtle);
  color: var(--accent); border: 1px solid var(--accent-border);
  letter-spacing: 0.05em; font-family: "JetBrains Mono", monospace;
}

.project-title {
  flex: 1; text-align: center; color: var(--text-dim);
  font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-title b { color: var(--text); font-weight: 600; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.export-status { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.export-status a { color: var(--accent); text-decoration: none; font-weight: 600; }
.export-status a:hover { text-decoration: underline; }

/* Buttons: Tactile, high-definition studio buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius); cursor: pointer; font-weight: 600;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1); outline: none; border: 1px solid transparent;
  white-space: nowrap;
}
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 3px rgba(29, 78, 216, 0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 3px 10px var(--accent-glow);
  transform: translateY(-0.5px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--panel-2); border-color: #94a3b8; color: #000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

.btn-group { display: flex; align-items: center; gap: 6px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

/* ---------- sidebar ---------- */
.sidebar {
  grid-area: side;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line-strong);
  background: var(--panel);
  min-height: 0;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.02);
}

.tabs {
  display: flex; border-bottom: 1px solid var(--line);
  background: #f8fafc;
  padding: 5px; gap: 5px;
}
.tab {
  flex: 1; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; background: transparent; border: 0; border-radius: var(--radius);
  cursor: pointer; color: var(--text-dim); font-size: 13px; font-weight: 600;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.8); }
.tab.active {
  color: var(--accent); background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.tab.active svg { color: var(--accent); }

.panel { display: none; flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.panel.active { display: block; }
.sidebar-heading {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); margin: 20px 0 10px;
}

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 26px 16px; border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md); background: #fafafa;
  color: var(--text-muted); cursor: pointer; text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.drop-icon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--accent);
  margin-bottom: 2px; transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.dropzone strong { color: var(--text); font-weight: 700; font-size: 14.5px; }
.dropzone span { font-size: 12.5px; color: var(--text-dim); }
.dropzone:hover, .dropzone.over, body.drag .dropzone {
  border-color: var(--accent); background: var(--accent-subtle);
}
.dropzone:hover .drop-icon, body.drag .dropzone .drop-icon {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.upload-progress { height: 4px; background: var(--panel-2); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.upload-progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.15s ease; }

.transcribe-controls {
  margin-top: 14px; padding: 14px; background: #f8fafc;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
}
.transcribe-controls .btn-primary { width: 100%; height: 36px; margin-top: 12px; font-size: 13.5px; font-weight: 700; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.file-item:hover { background: #fdfdfd; border-color: var(--line-strong); }
.file-item.active {
  background: var(--accent-subtle); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.file-thumb {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--text-muted); flex-shrink: 0;
}
.file-item.active .file-thumb { color: var(--accent); border-color: var(--accent-border); background: #ffffff; }
.file-meta { flex: 1; min-width: 0; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 600; color: var(--text); }
.file-sub { font-size: 12px; color: var(--text-dim); }
.file-sub.err { color: var(--danger); font-weight: 600; }
.file-del {
  opacity: 0; background: none; border: 0; color: var(--text-dim);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  transition: all 0.15s; display: grid; place-items: center;
}
.file-item:hover .file-del { opacity: 0.8; }
.file-del:hover { opacity: 1; background: var(--danger-subtle); color: var(--danger); }

/* Captions List (Sidebar) */
.empty {
  color: var(--text-dim); text-align: center; padding: 40px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty svg { color: var(--text-dim); opacity: 0.6; }
.empty p { color: var(--text); font-size: 14.5px; font-weight: 700; margin: 0; }
.empty span { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }

.caption-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cap-row {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  background: var(--panel); cursor: pointer; transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.cap-row:hover { border-color: var(--line-strong); background: #fdfdfd; }
.cap-row.active { border-color: var(--accent-light); }
.cap-row.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: var(--accent-subtle);
}
.cap-time {
  font-size: 12px; font-family: "JetBrains Mono", monospace;
  color: var(--text-muted); margin-bottom: 5px; letter-spacing: -0.02em; font-weight: 600;
}
.cap-row.selected .cap-time { color: var(--accent); }
.cap-row textarea {
  width: 100%; resize: none; border: 0; background: transparent; outline: none;
  padding: 0; line-height: 1.45; user-select: text; overflow: hidden;
  color: var(--text); font-size: 13.5px; font-weight: 500;
}

/* Fields & Form controls */
.field { margin-bottom: 16px; }
.field > label {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-muted); font-size: 12.5px; font-weight: 700; margin-bottom: 8px;
}
.field.row { display: flex; justify-content: space-between; align-items: center; }
.field.row > label { margin: 0; gap: 10px; justify-content: flex-start; color: var(--text); font-size: 13.5px; font-weight: 600; }
.field output { color: var(--accent); font-family: "JetBrains Mono", monospace; font-size: 12px; font-weight: 700; }

.select-wrap select, select {
  width: 100%; background: var(--panel); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius); padding: 8px 10px; color: var(--text);
  outline: none; font-size: 13.5px; font-weight: 500; transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
select:hover { border-color: #94a3b8; }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-border); }

input[type=range] {
  width: 100%; accent-color: var(--accent);
  height: 5px; background: var(--line-strong); border-radius: 3px; outline: none;
}
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
input[type=color] {
  width: 32px; height: 26px; border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--panel); padding: 1px; cursor: pointer;
}

/* ---------- stage (Halftone Canvas Blueprint) ---------- */
.stage {
  grid-area: stage; position: relative; min-width: 0; min-height: 0;
  display: grid; place-items: center; padding: 24px;
  background-color: #f1f5f9;
  /* Faded halftone radial dot pattern */
  background-image: radial-gradient(rgba(37, 99, 235, 0.14) 1px, transparent 1px);
  background-size: 16px 16px;
  border-left: 1px solid var(--line-strong);
}
.stage-empty {
  text-align: center; color: var(--text-muted); display: flex;
  flex-direction: column; align-items: center; gap: 8px;
}
.empty-icon {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--panel); border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; color: var(--accent); margin-bottom: 8px;
  box-shadow: var(--shadow-md);
}
.stage-empty h3 { color: var(--text); font-size: 16px; font-weight: 700; margin: 0; }
.stage-empty p { font-size: 13px; max-width: 320px; margin: 0; color: var(--text-dim); }

.player {
  position: relative; background: #000;
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-float);
}
.player video { display: block; width: 100%; height: 100%; }
.caption-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.caption {
  position: absolute; left: 6%; right: 6%;
  text-align: center; font-weight: 700;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.caption .w { paint-order: stroke fill; }
.caption.boxed .line {
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

.busy {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(5px);
}
.busy p { margin: 0; color: var(--text); font-size: 14px; font-weight: 700; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- timeline dock ---------- */
.timeline {
  grid-area: tl; display: flex; flex-direction: column;
  border-top: 1px solid var(--line-strong); background: var(--panel); min-height: 0;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}
.tl-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: #ffffff;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: all 0.15s; box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--panel-2); color: var(--accent); border-color: var(--accent); }

.timecode {
  font-family: "JetBrains Mono", monospace; font-size: 12.5px;
  color: var(--text-dim); margin: 0 4px; font-weight: 600;
}
.timecode span:first-child { color: var(--text); font-weight: 700; }
.tl-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 2px; }
.tl-spacer { flex: 1; }

.hint { color: var(--text-dim); font-size: 12px; margin-right: 10px; }
.zoom { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.zoom input { width: 95px; }

.tl-scroll {
  flex: 1; overflow-x: auto; overflow-y: hidden; position: relative;
  background-color: #fafafa;
  /* Blueprint subgrid in timeline */
  background-image: linear-gradient(rgba(37, 99, 235, 0.04) 1px, transparent 1px);
  background-size: 100% 20px;
}
.tl-content { position: relative; height: 100%; min-width: 100%; }

.ruler {
  height: 24px; position: relative; border-bottom: 1px solid var(--line);
  background: #f1f5f9; cursor: pointer;
}
.tick {
  position: absolute; top: 0; height: 100%; border-left: 1px solid #cbd5e1;
  font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--text-muted);
  padding-left: 4px; font-weight: 500;
}
.tick.minor { height: 6px; top: auto; bottom: 0; border-color: #cbd5e1; }

.track { position: absolute; left: 0; right: 0; }
.caption-track { top: 30px; height: 48px; }
.wave-track { top: 82px; height: 62px; display: block; cursor: pointer; }

/* Subtitle Block styling in Timeline (Crisp Architectural Paper Block) */
.cap-block {
  position: absolute; top: 0; height: 100%;
  background: var(--cap); border: 1.5px solid var(--cap-border); border-radius: var(--radius);
  padding: 5px 9px; overflow: hidden; cursor: grab;
  font-size: 12.5px; line-height: 1.35; color: var(--cap-text); font-weight: 600;
  white-space: nowrap; text-overflow: ellipsis;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.12s;
}
.cap-block:hover { border-color: #94a3b8; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1); }
.cap-block.selected {
  background: var(--cap-sel); border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent), 0 3px 10px var(--accent-glow);
  color: var(--accent); font-weight: 700;
  z-index: 2;
}
.cap-block.editing {
  white-space: normal; cursor: text; user-select: text;
  outline: 2px solid var(--accent); z-index: 3; overflow: auto;
  background: #ffffff;
}
.cap-block .handle { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.cap-block .handle.l { left: 0; }
.cap-block .handle.r { right: 0; }
.cap-block .handle:hover { background: rgba(29, 78, 216, 0.25); }
.cap-block .txt { pointer-events: none; display: block; overflow: hidden; text-overflow: ellipsis; }
.cap-block.editing .txt { pointer-events: auto; outline: none; }

.playhead {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 2px solid var(--accent); pointer-events: none; z-index: 5;
}
.playhead::before {
  content: ""; position: absolute; top: 0; left: -6px;
  border: 5px solid transparent; border-top: 7px solid var(--accent);
}

