:root {
  --teal: #007983;
  --teal-bg: #e6f2f3;
  --text: #373d43;
  --muted: #6c757d;
  --outline-dark: #aeb3b7;
  --outline-light: #dee0e2;
  --border: #eff0f1;
  --field-fill: #f7f7f8;
  --page-bg: #fbfbfb;
  --white: #ffffff;
  --danger: #cc4a4a;
  --danger-light: #ffefef;
  --video-bg: #0d1118;
  --icon: #7d858c;
  --radius: 5px;
  --padding: 10px;
  --control-height: 42px;
  --title-weight: 700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Open Sans", "Segoe UI", sans-serif;
  background: var(--page-bg);
}

button,
input,
select {
  font: inherit;
}

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

.panel {
  background: transparent;
  border-radius: var(--radius);
}

.icon {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.shell {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--padding);
  min-height: 100vh;
  height: 100dvh;
  padding: var(--padding);
  overflow: hidden;
}

.editor {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  min-height: 0;
}

.annotation-editor {
  min-height: 0;
  height: 100%;
}

.annotation-editor.is-buffering,
.annotation-editor.is-buffering * {
  cursor: progress;
}

.editor-form {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: var(--padding);
  min-height: 0;
  height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  align-self: start;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: var(--padding);
  height: 100%;
  overflow: hidden;
}

.sidebar-stack {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: var(--padding);
}

.ranges-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.range-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: var(--padding);
  overflow: auto;
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  width: 100%;
  padding: var(--padding);
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: var(--white);
  font: inherit;
  font-weight: var(--title-weight);
  cursor: pointer;
}

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

.control-row {
  position: relative;
  display: flex;
  align-items: stretch;
}

.video-picker__control {
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  background: var(--field-fill);
}

.picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.video-picker {
  min-height: 44px;
  padding: var(--padding);
  border-radius: inherit;
  font-weight: var(--title-weight);
}

.picker-trigger:hover,
.picker-option:hover,
.picker-option.is-selected,
.range-row__set:hover:not(:disabled),
.range-add:hover,
.frame-step__button:hover {
  background: var(--teal-bg);
}

.picker-control.is-open .picker-trigger,
.picker-trigger:focus-visible {
  outline: none;
}

.picker-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}

.video-picker__text,
.video-picker__option-text {
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.video-picker__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.picker-meta {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.video-picker__meta--selected,
.empty p {
  margin: 0;
}

.picker-icon {
  flex: none;
  color: var(--muted);
}

.picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  background: var(--white);
}

.video-picker__menu {
  left: -1px;
  width: calc(100% + 2px);
  max-height: calc(100dvh - 100% - 9px - 2 * var(--padding));
  overflow: auto;
}

.picker-menu[hidden] {
  display: none;
}

.picker-option {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.item-title {
  font-weight: var(--title-weight);
}

.video-picker__option--locked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--padding);
  cursor: not-allowed;
  opacity: 0.55;
}

.video-picker__option--locked:hover {
  background: var(--white);
}

.range-row {
  position: relative;
  z-index: 0;
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  background: var(--field-fill);
}

.range-row:has(.range-label-picker__control.is-open),
.range-row:focus-within {
  z-index: 3;
}

.range-row__main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  gap: var(--padding);
  padding: var(--padding) calc(var(--padding) * 3 + 28px) var(--padding) var(--padding);
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.range-row__main--picker {
  align-items: stretch;
  gap: 0;
  padding: 0 calc(var(--padding) * 2 + 28px) 0 0;
}

.range-row__main--picker .range-row__swatch {
  position: absolute;
  left: var(--padding);
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
}

.swatch {
  flex: none;
  border-radius: 999px;
}

.range-row__swatch {
  align-self: center;
  width: 14px;
  height: 14px;
}

.range-row__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  gap: 6px;
}

.range-label-picker__control {
  flex: 1 1 auto;
  min-width: 0;
}

.range-label-picker {
  min-height: 24px;
  gap: var(--padding);
  padding: 0 var(--padding) 0 calc(var(--padding) * 2 + 14px);
  border-radius: var(--radius) 0 0 var(--radius);
}

.range-label-picker__menu {
  left: 0;
  right: 0;
}

.range-label-picker__option {
  display: flex;
  align-items: center;
  gap: var(--padding);
}

.range-label-picker__option-swatch {
  width: 12px;
  height: 12px;
}

.range-row__remove {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--padding) * 2 + 28px);
  padding: 0;
  border: 0;
  border-radius: 0 var(--radius) 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.range-row__remove::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.range-row__remove:hover,
.range-row__remove:focus-visible {
  color: var(--danger);
  background: var(--danger-light);
}

.range-row__actions {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
}

.range-row__set {
  flex: 1 1 0;
  min-height: 36px;
  padding: 8px var(--padding);
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.range-row__set + .range-row__set,
.frame-step__button + .frame-step__button {
  border-left: 1px solid var(--border);
}

.range-row__set:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

.range-add {
  min-height: 34px;
  padding: 6px var(--padding);
  border: 1px dashed var(--outline-dark);
  border-radius: var(--radius);
  background: transparent;
  color: var(--teal);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.frame-step-group {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  background: var(--field-fill);
}

.frame-step__label {
  padding: 8px var(--padding);
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  user-select: none;
}

.frame-step {
  display: flex;
}

.frame-step > :first-child,
.frame-step > :first-child .picker-trigger {
  border-bottom-left-radius: calc(var(--radius) - 1px);
}

.frame-step > :last-child,
.frame-step > :last-child .picker-trigger {
  border-bottom-right-radius: calc(var(--radius) - 1px);
}

.frame-step__button {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.frame-step__button > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.speed-picker__control {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  border-left: 1px solid var(--border);
}

.speed-picker {
  gap: 4px;
  justify-content: center;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 0;
  color: var(--icon);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.speed-picker__text {
  flex: 0 1 auto;
  text-align: center;
}

.speed-picker__menu {
  right: -1px;
  bottom: calc(100% + 8px);
  top: auto;
  min-width: calc(100% + 2px);
}

.speed-picker__option {
  text-align: center;
  color: var(--icon);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.video-stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--video-bg);
}

.video-player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--video-bg);
}

.timeline {
  position: relative;
  flex: 0 0 var(--control-height);
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  max-height: var(--control-height);
  overflow: hidden;
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  background: repeating-linear-gradient(
    90deg,
    var(--outline-light) 0,
    var(--outline-light) 1px,
    transparent 1px,
    transparent 24px
  );
}

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

.timeline__range {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 1px;
  pointer-events: none;
}

.timeline__playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2px;
  background: var(--text);
  transform: translateX(-1px);
  pointer-events: none;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--padding);
  padding: var(--padding);
  border: 1px solid var(--outline-light);
  border-radius: var(--radius);
  background: var(--field-fill);
  text-align: center;
}

.empty--sidebar {
  min-height: 160px;
}

.empty--editor {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 320px;
}
