:root {
  color-scheme: dark;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --primary: #2b9ed0;
  --primary-dark: #1a7a9e;
  --bg: #191919;
  --panel: #2b2b2b;
  --panel-soft: #343434;
  --panel-deep: #101010;
  --line: #3b3b3b;
  --text: #ffffff;
  --muted: #aaaaaa;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #f0ad4e;
  --whatsapp: #25d366;
  --shadow: 0 4px 20px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

button:hover {
  background: var(--panel-soft);
  border-color: var(--primary);
  color: var(--text);
}

button:active {
  transform: translateY(1px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.workspace {
  width: min(1280px, calc(100vw - 30px));
  margin: 0 auto;
  padding: 15px 0 22px;
}

.header-panel,
.video-panel,
.timeline-panel,
.clips-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.header-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 18px;
  margin-bottom: 15px;
  min-height: 62px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-brand img {
  height: 34px;
  width: auto;
  flex: 0 0 auto;
}

.left-15 {
  margin-left: 15px;
}

.brandline {
  color: #d7dde4;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: 2px;
}

#eventTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .01em;
  color: #2a9ed0;
}

#eventMeta {
  color: #bcc3cb;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.event-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 29px;
  padding: 6px 13px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

.event-status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .06);
}

.event-status-running {
  color: #58d27b;
  border-color: rgba(88, 210, 123, .45);
  background: rgba(40, 167, 69, .12);
}

.event-status-stopped {
  color: #d5dae1;
  border-color: rgba(213, 218, 225, .25);
  background: rgba(255, 255, 255, .08);
}

.event-status-neutral {
  color: var(--warning);
  border-color: rgba(240, 173, 78, .45);
  background: rgba(240, 173, 78, .1);
}

.video-panel {
  display: grid;
  grid-template-columns: minmax(160px, 210px) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 15px;
}

.video-panel:has(.editing-badge.hidden) {
  grid-template-columns: minmax(0, 1fr);
}

.video-panel:has(.editing-badge.hidden) .video-column {
  grid-column: 1;
  width: 90%;
  justify-self: center;
}

.video-column {
  grid-column: 2;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.video-wrap {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.video-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.video-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  background: #050505;
  pointer-events: none;
}

.video-loading.hidden {
  display: none;
}

.video-loading strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
}

.video-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: video-loading-spin .8s linear infinite;
}

@keyframes video-loading-spin {
  to { transform: rotate(360deg); }
}

.editing-badge {
  justify-self: start;
  width: min(100%, 210px);
  max-height: calc((min(1280px, calc(100vw - 30px)) - 222px) * 9 / 16 + 50px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.editing-badge.hidden {
  display: none;
}

.editing-badge > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  background: rgba(43, 158, 208, .2);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 9px;
}

.editing-badge strong,
.editing-badge small {
  display: block;
}

.editing-badge strong {
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editing-badge small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.editing-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  max-height: calc((min(1280px, calc(100vw - 30px)) - 222px) * 9 / 16 - 112px);
  overflow-y: auto;
  padding-right: 2px;
}

.editing-list:empty {
  display: none;
}

.editing-list-item {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 8px;
}

.editing-list-item.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.editing-list-item strong,
.editing-list-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editing-list-item strong {
  font-size: 12px;
}

.editing-list-item span {
  margin-top: 2px;
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.editing-download-menu {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  margin-top: 11px;
  position: relative;
}

.editing-download {
  width: 100%;
  border: none;
  border-radius: 0 8px 8px 0;
  color: #fff;
  background: var(--primary);
  font-weight: 400;
  font-size: 0.9em;
}

.editing-download:hover {
  background: var(--primary-dark);
}

.editing-download:disabled {
  cursor: default;
  color: #7f8791;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.editing-quality-select {
  min-width: 0;
  height: 39px;
  color: transparent;
  background: var(--primary-dark);
  border: none;
  border-right: 1px solid rgba(255, 255, 255, .2);
  border-radius: 8px 0 0 8px;
  padding: 0;
  font-size: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #fff 50%),
    linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position:
    calc(50% - 4px) 17px,
    calc(50% + 3px) 17px;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.editing-quality-select option {
  color: #fff;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.editing-quality-select:disabled {
  cursor: default;
  background: var(--panel-soft);
  background-image:
    linear-gradient(45deg, transparent 50%, #7f8791 50%),
    linear-gradient(135deg, #7f8791 50%, transparent 50%);
  background-position:
    calc(50% - 4px) 17px,
    calc(50% + 3px) 17px;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

.transport-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-height: 56px;
  padding: 9px 11px;
  overflow-x: auto;
  overflow-y: hidden;
}

.transport-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.transport-group.export-controls {
  margin-left: auto;
}


.playback-time {
  min-width: 116px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
  font-size: 16px;
}

.transport-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  color: var(--muted);
}

.transport-button.primary {
  min-width: 79px;
  min-height: 36px;
  color: #fff;
  border: none;
  background: var(--primary);
  font-weight: 800;
  border-radius: 8px;
  font-size: 16px;
}

.transport-button.primary:hover {
  background: var(--primary-dark);
}

.transport-button.icon {
  min-width: 34px;
  width: 34px;
  padding: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .14);
}

.transport-button.reset {
  min-width: 56px;
}

.transport-button.subtle {
  color: var(--muted);
  background: transparent;
}

.transport-button.audio {
  min-width: 36px;
  width: 36px;
  padding: 0;
  border-radius: 999px;
}

.transport-button.audio svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.transport-button.audio.muted {
  color: var(--danger);
  border-color: rgba(220, 53, 69, .65);
}

.transport-button.whatsapp {
  color: #dfffe9;
  border-color: rgba(37, 211, 102, .6);
  background: rgba(37, 211, 102, .12);
  font-weight: 800;
}

.transport-button.whatsapp:hover {
  color: #fff;
  background: rgba(37, 211, 102, .25);
}

.transport-button:disabled,
.transport-select:disabled {
  opacity: .55;
  cursor: default;
}

.export-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.transport-select {
  min-height: 34px;
  max-width: 98px;
  color: var(--text);
  background: var(--panel-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font-weight: 700;
}

.export-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.export-status.hidden {
  display: none;
}

.export-status.busy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--warning);
}

.export-status-spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: export-status-spin .75s linear infinite;
}

@keyframes export-status-spin {
  to { transform: rotate(360deg); }
}

.whatsapp-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.whatsapp-links a {
  color: #dfffe9;
  text-decoration: none;
  border: 1px solid rgba(37, 211, 102, .45);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(37, 211, 102, .12);
  font-size: 12px;
}

.volume-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.volume-control input[type="range"] {
  width: 86px;
  accent-color: var(--primary);
}

.transport-separator {
  width: 1px;
  height: 26px;
  background: var(--line);
}

.timeline-panel,
.clips-panel {
  padding: 16px;
  margin-bottom: 15px;
}

.timeline-panel {
  margin-top: 0;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 11px;
}

.timeline-toolbar strong {
  color: var(--text);
  font-size: 15px;
  margin-right: auto;
}

.timeline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
  padding: 7px 13px;
}

#selectionStatus {
  color: var(--muted);
  font-size: 13px;
}

#selectionStatus.active {
  color: var(--primary);
  background: rgba(43, 158, 208, .15);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
}

#zoomLabel {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.timeline-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.add-clip-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 120px 120px auto auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-deep);
  padding: 12px;
  margin: 0 0 12px;
}

.add-clip-panel.hidden {
  display: none;
}

.add-clip-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.add-clip-panel select,
.add-clip-panel input,
.clip-item input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-soft);
}

.add-clip-panel select:focus,
.add-clip-panel input:focus,
.clip-item input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

.timeline-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #121212;
}

.timeline {
  position: relative;
  min-width: 100%;
  padding: 0 10px 12px;
}

.playhead {
  display: none;
}

.timeline-ruler {
  height: 42px;
  position: relative;
  border-bottom: 1px solid var(--line);
  color: #d0d5db;
  font-size: 12px;
}

.tick {
  position: absolute;
  bottom: 8px;
  transform: translateX(-50%);
}

.tick.major::before,
.tick.mid::before,
.tick.minor::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 1px;
  transform: translateX(-50%);
}

.tick.major::before {
  height: 13px;
  background: #6e7b89;
}

.tick.minor,
.tick.mid {
  width: 1px;
  color: transparent;
}

.tick.mid::before {
  height: 10px;
  background: #505b66;
}

.tick.minor::before {
  height: 6px;
  background: #3e4852;
}

.segment-track {
  display: none;
}

.speakerTracks {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.speaker-row {
  display: grid;
  grid-template-columns: 1fr;
  border-radius: 10px;
}

.speaker-row.focused {
  background: rgba(43, 158, 208, .08);
  border: 1px solid rgba(43, 158, 208, .45);
  padding: 10px;
  margin: 8px 0 14px;
}

.speaker-label {
  display: none;
}

.speaker-rail {
  position: relative;
  min-height: 44px;
  background: linear-gradient(90deg, rgba(43, 158, 208, .16), rgba(43, 158, 208, .05));
  border: 1px solid rgba(80, 99, 114, .7);
  border-radius: 8px;
}

.speaker-row.focused .speaker-rail {
  min-height: 58px;
  background: #1e2931;
  border-color: var(--primary);
}

.event-row .speaker-rail {
  min-height: 44px;
  background:
    linear-gradient(90deg, rgba(43,158,208,.12), rgba(43,158,208,.03)),
    repeating-linear-gradient(90deg, transparent 0, transparent 39px, rgba(255,255,255,.07) 40px);
  cursor: pointer;
}

.event-rail-label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.clip-block {
  position: absolute;
  top: 7px;
  height: 36px;
  min-width: 8px;
  border-radius: 8px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.24);
  padding: 5px 8px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.speaker-row.focused .clip-block {
  top: 8px;
  height: 40px;
}

.clip-block.selected,
.clip-block.active {
  outline: 3px solid rgba(43, 158, 208, .45);
  outline-offset: 2px;
}

.clip-block.editing {
  outline: 4px solid rgba(255,255,255,.9);
}

.clip-block strong,
.clip-block small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clip-block small {
  opacity: .9;
  font-size: 11px;
}

.handle {
  position: absolute;
  top: 0;
  width: 18px;
  height: 100%;
  cursor: ew-resize;
  background: linear-gradient(90deg, rgba(255,255,255,.34), rgba(255,255,255,0));
}

.handle.left {
  left: 0;
  border-radius: 8px 0 0 8px;
}

.handle.right {
  right: 0;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(270deg, rgba(255,255,255,.34), rgba(255,255,255,0));
}

.rail-playhead {
  display: none;
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(220, 53, 69, .25);
  z-index: 30;
  pointer-events: none;
}

.rail-playhead::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--danger);
}

.playhead-grip {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 22px;
  height: 18px;
  transform: translateX(-50%);
  cursor: ew-resize;
  pointer-events: auto;
  background: var(--danger);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 2px 7px rgba(0,0,0,.35);
}

.playhead-grip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-left: 2px solid #fff;
  border-right: 2px solid #fff;
  transform: translate(-50%, -50%);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.section-action-btn:hover {
  color: var(--text);
}

.section-title span,
.speaker-chip span,
.clip-item label {
  color: var(--muted);
  font-size: 12px;
}

.clips-list {
  display: grid;
  gap: 8px;
}

.clip-item {
  display: grid;
  grid-template-columns: 24px minmax(230px, .85fr) minmax(280px, 1.35fr) 104px 104px auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: var(--panel-deep);
}

.clip-item.selected {
  background: rgba(43, 158, 208, .1);
  border-color: var(--primary);
}

.clip-item.active {
  box-shadow: 0 0 0 3px rgba(43, 158, 208, .18);
}

.speaker-chip {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.speaker-chip img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-soft);
}

.speaker-chip strong,
.speaker-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clip-topic {
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  padding-left: 4px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clip-play,
.clip-download {
  color: var(--primary);
}

.empty-timeline {
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 1100px) {
  .workspace {
    width: calc(100vw - 18px);
  }

  .video-panel {
    grid-template-columns: 1fr;
  }

  .video-panel::after {
    display: none;
  }

  .editing-badge,
  .video-column {
    grid-column: 1;
    justify-self: stretch;
    width: 100%;
    max-height: none;
  }

  .video-panel:has(.editing-badge.hidden) .video-column {
    width: 100%;
  }

  .editing-list {
    max-height: 180px;
  }

  .add-clip-panel {
    grid-template-columns: 1fr 1fr;
  }

  .add-clip-panel label:first-child {
    grid-column: 1 / -1;
  }

  .transport-bar {
    justify-content: center;
  }

  .clip-item {
    grid-template-columns: 24px 1fr 1fr 1fr;
  }

  .clip-play,
  .clip-download {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .header-panel {
    align-items: flex-start;
  }

  .header-brand {
    align-items: flex-start;
  }

  .timeline-toolbar {
    flex-wrap: wrap;
  }

  #selectionStatus {
    margin-left: 0;
    order: 4;
    width: 100%;
  }

  .add-clip-panel {
    grid-template-columns: 1fr;
  }

  .volume-control input[type="range"] {
    width: 82px;
  }
}
