/* Player Trace Lab cohesion pass: visual-only overrides. */
:root {
  --pt-bg: #070b13;
  --pt-bg-raised: #0b111b;
  --pt-surface: #101925;
  --pt-surface-2: #141f2c;
  --pt-surface-3: #192635;
  --pt-border: rgba(206, 225, 217, 0.14);
  --pt-border-strong: rgba(206, 225, 217, 0.23);
  --pt-text: #f4f8f6;
  --pt-muted: #9eafa9;
  --pt-faint: #74857f;
  --pt-green: #69e3ae;
  --pt-green-bright: #aaf2d0;
  --pt-green-soft: rgba(105, 227, 174, 0.12);
  --pt-danger: #ff9d99;
  --pt-radius-sm: 8px;
  --pt-radius: 12px;
  --pt-radius-lg: 16px;
  --pt-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

[hidden] {
  display: none !important;
}

body.has-session {
  color: var(--pt-text);
  background:
    radial-gradient(circle at 8% -20%, rgba(71, 175, 128, 0.16), transparent 34rem),
    linear-gradient(180deg, #090f18 0, var(--pt-bg) 34rem);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.has-session .app-shell {
  min-height: 100vh;
  background: transparent;
}

body.has-session .topbar {
  min-height: 68px;
  height: auto;
  padding: 10px clamp(16px, 2.5vw, 32px);
  gap: 18px;
  border-bottom: 1px solid var(--pt-border);
  background: rgba(7, 11, 19, 0.92);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(20px);
}

body.has-session .brand {
  min-width: max-content;
}

body.has-session .brand-mark {
  border-radius: 10px;
  background: linear-gradient(145deg, var(--pt-green), #c7ffe4);
  color: #072018;
  box-shadow: 0 10px 28px rgba(105, 227, 174, 0.16);
}

body.has-session .brand h1 {
  color: var(--pt-text);
  font-size: 15px;
  letter-spacing: -0.015em;
}

body.has-session .brand p {
  color: var(--pt-faint);
  font-size: 8px;
  letter-spacing: 0.12em;
}

body.has-session .tabs {
  width: min(100%, 520px);
  justify-self: center;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--pt-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

body.has-session .tab {
  min-height: 36px;
  height: auto;
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--pt-muted);
  font-size: 11px;
  line-height: 1.15;
}

body.has-session .tab:hover {
  color: var(--pt-text);
  background: rgba(255, 255, 255, 0.045);
}

body.has-session .tab.active {
  color: #082118;
  background: linear-gradient(135deg, var(--pt-green), var(--pt-green-bright));
  box-shadow: 0 8px 24px rgba(105, 227, 174, 0.14);
}

body.has-session .topbar-actions {
  justify-self: end;
  gap: 7px;
}

body.has-session .topbar-actions :is(.ghost-button, .product-switcher) {
  min-height: 38px;
}

body.has-session .topbar-actions .ghost-button {
  padding-inline: 13px;
  border-color: var(--pt-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--pt-muted);
}

body.has-session .topbar-actions .ghost-button:hover {
  border-color: var(--pt-border-strong);
  color: var(--pt-text);
  background: rgba(255, 255, 255, 0.065);
}

body.has-session .product-switcher {
  border-color: var(--pt-border);
  background: rgba(255, 255, 255, 0.035);
}

body.has-session .product-switcher :is(a, span) {
  min-height: 30px;
  color: var(--pt-muted);
}

body.has-session .product-switcher .active {
  color: var(--pt-text);
  background: var(--pt-surface-3);
  box-shadow: inset 0 0 0 1px rgba(105, 227, 174, 0.26);
}

body.has-session .project-savebar {
  border-color: var(--pt-border);
  background: #0c141e;
}

body[data-workspace] .workspace {
  max-width: 1500px;
  margin: 0 auto;
}

body[data-workspace] :is(#codeView, #libraryView, #annotateView).active {
  padding: clamp(16px, 2vw, 28px);
  gap: 18px;
}

body[data-workspace] :is(.code-workbar, .library-workbar, .annotate-workbar) {
  min-height: 64px;
  align-items: flex-end;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--pt-border);
}

.workspace-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--pt-green);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

body[data-workspace] :is(.code-match-heading strong, .library-workbar h2, .annotate-workbar h2) {
  display: block;
  margin: 0;
  color: var(--pt-text);
  font-size: clamp(21px, 2vw, 27px);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

body[data-workspace] :is(.code-match-heading span:last-child, .library-workbar p, .annotate-workbar p) {
  display: block;
  margin: 6px 0 0;
  color: var(--pt-muted);
  font-size: 12px;
  line-height: 1.4;
}

body[data-workspace] :is(.panel-button, .primary-button, .mini-button, .ghost-button, .skip-button, .icon-button) {
  border-radius: var(--pt-radius-sm);
  font-weight: 680;
  box-shadow: none;
}

body[data-workspace] :is(.panel-button, .mini-button, .skip-button) {
  border-color: var(--pt-border);
  background: rgba(255, 255, 255, 0.035);
  color: var(--pt-muted);
}

body[data-workspace] :is(.panel-button, .mini-button, .skip-button):hover:not(:disabled) {
  border-color: var(--pt-border-strong);
  background: rgba(255, 255, 255, 0.065);
  color: var(--pt-text);
}

body[data-workspace] .primary-button {
  border-color: transparent;
  background: linear-gradient(135deg, var(--pt-green), var(--pt-green-bright));
  color: #082118;
}

body[data-workspace] button:disabled {
  opacity: 0.38;
  filter: saturate(0.55);
}

body[data-workspace] :is(#codeView, #libraryView, #annotateView) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea) {
  min-height: 40px;
  border: 1px solid var(--pt-border-strong);
  border-radius: var(--pt-radius-sm);
  background: #0d1621;
  color: var(--pt-text);
}

body[data-workspace] :is(#codeView, #libraryView, #annotateView) :is(input, select, textarea):focus {
  border-color: rgba(105, 227, 174, 0.62);
  box-shadow: 0 0 0 3px rgba(105, 227, 174, 0.1);
  outline: none;
}

body[data-workspace] input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--pt-green);
}

body[data-workspace] :is(.panel-section, .library-inspector, .library-playlist, .annotation-sequence, .studio-timeline, .premium-tool-dock, .right-panel) {
  border-color: var(--pt-border) !important;
  border-radius: var(--pt-radius) !important;
  background: linear-gradient(180deg, rgba(17, 27, 40, 0.96), rgba(12, 19, 29, 0.96)) !important;
  box-shadow: none !important;
}

body[data-workspace] :is(.panel-section, .library-inspector, .library-playlist) h2,
body[data-workspace] :is(.panel-section, .library-inspector, .library-playlist) h3 {
  color: var(--pt-text);
  letter-spacing: -0.015em;
}

body[data-workspace] :is(.status, .empty-copy, .field-help, .privacy-note) {
  color: var(--pt-muted);
}

/* Code Match */
#codeView.active {
  grid-template-columns: minmax(0, 1fr) minmax(250px, 286px);
  gap: 18px;
}

#codeView .code-workbar-actions,
#annotateView .annotate-workbar-actions {
  justify-content: flex-end;
}

#codeView .video-shell,
#annotateView .video-shell,
#libraryView #libraryPreviewVideo {
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius) !important;
  background: #03060a;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
}

#codeView .empty-state,
#annotateView .annotate-empty {
  background:
    radial-gradient(circle at 50% 42%, rgba(105, 227, 174, 0.08), transparent 18rem),
    #070c13;
}

#codeView .empty-state strong,
#annotateView .annotate-empty strong {
  color: var(--pt-text);
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: -0.03em;
}

#codeView .empty-state span,
#annotateView .annotate-empty span {
  max-width: 440px;
  color: var(--pt-muted);
  line-height: 1.55;
}

#codeView .transport,
#annotateView .transport {
  padding: 9px 0;
  border-bottom: 1px solid var(--pt-border);
}

#codeView .code-clock-row,
#annotateView .precision-bar {
  color: var(--pt-muted);
}

#codeView #codeFeedback,
#annotateView .annotate-hint {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-left: 2px solid var(--pt-green);
  border-radius: 0 8px 8px 0;
  background: var(--pt-green-soft);
  color: #c9f5df;
  font-size: 12px;
}

#codeView .code-tray {
  padding-top: 16px;
  border-color: var(--pt-border);
}

#codeView .code-tray .code-grid {
  gap: 9px;
}

#codeView .code-tray .code-card {
  overflow: hidden;
  border-color: var(--pt-border);
  border-radius: 10px;
  background: var(--pt-surface);
}

#codeView .code-tray .code-button {
  min-height: 82px;
  border-radius: 0;
  background: var(--pt-surface-2) !important;
}

#codeView > .right-panel {
  padding: 16px !important;
}

#codeView .event-list.empty,
#libraryView :is(.clip-list.empty, .playlist-list.empty),
#annotateView :is(.pause-list.empty, .annotation-list.empty, .tracked-ring-list.empty, .timeline-stage.empty) {
  min-height: 96px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--pt-border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--pt-muted);
  text-align: center;
  line-height: 1.5;
}

/* Keep the first task obvious before footage is loaded. */
#codeView .stage-column:has(#emptyState:not([hidden])) :is(.transport, .code-clock-row) {
  display: none;
}

#codeView .stage-column:has(#emptyState:not([hidden])) #codeFeedback {
  margin-top: 4px;
}

/* Clip Library */
#libraryView.active {
  grid-template-columns: minmax(270px, 0.78fr) minmax(0, 1.35fr);
  gap: 18px;
}

#libraryView .library-filterbar {
  padding: 0 0 16px;
  border-color: var(--pt-border);
}

#libraryView .library-filterbar .toggle-row {
  width: auto !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 0;
  color: var(--pt-muted);
}

#libraryView .library-filterbar .toggle-row input[type="checkbox"] {
  appearance: auto !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#libraryView .library-collection,
#libraryView .library-inspector,
#libraryView .library-playlist {
  align-self: start;
}

#libraryView .library-inspector,
#libraryView .library-playlist {
  padding: 17px;
}

#libraryView .library-row {
  padding: 10px;
  border-radius: 8px;
  background: var(--pt-surface);
}

#libraryView .library-row.active {
  border-color: rgba(105, 227, 174, 0.42);
  background: #172b25;
}

#libraryView .library-selected-head {
  margin-bottom: 12px;
}

#libraryView .library-primary-actions {
  padding: 12px 0;
  border-block: 1px solid var(--pt-border);
}

#libraryView .library-editor {
  gap: 13px;
}

/* An empty library is a decision screen, not a disabled editor. */
#libraryView:not(:has(.library-row)) .library-inspector {
  min-height: 220px;
  display: grid;
  place-content: center;
  text-align: center;
}

#libraryView:not(:has(.library-row)) .library-inspector::after {
  content: "Code a moment during the match and it will appear here, ready to trim, organise and annotate.";
  max-width: 430px;
  color: var(--pt-muted);
  font-size: 13px;
  line-height: 1.6;
}

#libraryView:not(:has(.library-row)) .library-selected-head h3 {
  margin: 0 0 8px;
  font-size: 0;
}

#libraryView:not(:has(.library-row)) .library-selected-head h3::after {
  content: "Select your first moment";
  font-size: 22px;
}

#libraryView:not(:has(.library-row)) .library-inspector > :not(.library-selected-head) {
  display: none !important;
}

/* Annotate + Export */
#annotateView.active {
  gap: 18px !important;
}

#annotateView .annotation-sequence {
  padding: 13px 15px;
}

#annotateView .premium-tool-dock {
  padding: 10px !important;
}

#annotateView.active .premium-tool-dock .tool-button {
  border-color: var(--pt-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

#annotateView.active .premium-tool-dock .tool-button:hover:not(:disabled) {
  border-color: var(--pt-border-strong);
  background: rgba(255, 255, 255, 0.055);
}

#annotateView.active .premium-tool-dock .tool-button.active {
  border-color: rgba(105, 227, 174, 0.5);
  background: var(--pt-green-soft);
  color: var(--pt-green);
}

#annotateView #annotateInspectorPanel {
  padding: 14px !important;
}

#annotateView .inspector-tabs {
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid var(--pt-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

#annotateView .annotate-details {
  border-color: var(--pt-border);
}

/* Before a clip is chosen, focus on the one next step. */
#annotateView:has(#annotateEmptyState:not([hidden])) :is(
  .annotation-sequence,
  .premium-tool-dock,
  .transport,
  .precision-bar,
  .freeze-quick-edit,
  .studio-timeline,
  .annotate-freezes,
  #annotateInspectorPanel
) {
  display: none !important;
}

#annotateView:has(#annotateEmptyState:not([hidden])).active {
  grid-template-columns: minmax(0, 1fr) !important;
}

#annotateView:has(#annotateEmptyState:not([hidden])) .stage-column {
  grid-column: 1 / -1;
}

#annotateView:has(#annotateEmptyState:not([hidden])) .annotate-hint {
  display: none;
}

/* Projects, account and setup dialogs */
body.has-session dialog,
body.has-session .modal-card {
  border: 1px solid var(--pt-border-strong);
  border-radius: var(--pt-radius-lg);
  background: #0b121c;
  color: var(--pt-text);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.5);
}

body.has-session dialog::backdrop,
body.has-session .modal-backdrop {
  background: rgba(1, 4, 8, 0.76);
  backdrop-filter: blur(8px);
}

body.has-session :is(#projectsDialog, #codeSetup, #annotateExportDialog) > header,
body.has-session .modal-head {
  border-color: var(--pt-border);
  background: rgba(255, 255, 255, 0.018);
}

body.has-session :is(#projectsDialog, .account-modal) :is(input, select, textarea) {
  border-color: var(--pt-border-strong);
  background: #0e1722;
  color: var(--pt-text);
}

/* Responsive hierarchy */
@media (max-width: 1100px) {
  body.has-session .topbar {
    display: grid !important;
    grid-template-columns: minmax(170px, auto) minmax(0, 1fr);
  }

  body.has-session .tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  body.has-session .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  #codeView.active,
  #libraryView.active,
  #annotateView.active {
    gap: 14px !important;
  }
}

@media (max-width: 760px) {
  body.has-session .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid !important;
    grid-template-columns: 1fr !important;
    padding: 12px;
    gap: 10px;
  }

  body.has-session .brand {
    justify-self: center;
  }

  body.has-session .brand p {
    display: none;
  }

  body.has-session .topbar-actions {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(76px, 0.65fr) minmax(0, 1fr);
    gap: 6px;
  }

  body.has-session .topbar-actions :is(.product-switcher, .ghost-button) {
    width: 100%;
    min-width: 0;
  }

  body.has-session .topbar-actions .account-pill {
    max-width: none;
    padding-inline: 8px;
  }

  body.has-session .tabs {
    grid-column: 1;
    grid-row: 3;
    gap: 3px;
  }

  body.has-session .tab {
    padding-inline: 5px;
    font-size: 10px;
  }

  body[data-workspace] :is(#codeView, #libraryView, #annotateView).active {
    padding: 16px 12px 30px;
  }

  body[data-workspace] :is(.code-workbar, .library-workbar, .annotate-workbar) {
    align-items: flex-start;
  }

  body[data-workspace] :is(.code-workbar-actions, .annotate-workbar-actions) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  body[data-workspace] :is(.code-workbar-actions, .annotate-workbar-actions) button {
    width: 100%;
  }

  #codeView.active,
  #libraryView.active,
  #annotateView.active {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #codeView > .right-panel,
  #libraryView :is(.library-collection, .library-inspector, .library-playlist),
  #annotateView :is(.stage-column, #annotateInspectorPanel) {
    grid-column: 1 !important;
  }

  #libraryView .library-filterbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  #libraryView .library-filterbar :is(input, select) {
    width: 100% !important;
  }

  #libraryView .library-filterbar .toggle-row input[type="checkbox"] {
    width: 16px !important;
  }

  #libraryView .library-editor {
    grid-template-columns: minmax(0, 1fr);
  }

  #annotateView:has(#annotateEmptyState:not([hidden])) .video-shell {
    margin-top: 0 !important;
  }
}

@media (max-width: 440px) {
  body.has-session .topbar-actions {
    grid-template-columns: 1fr 1fr;
  }

  body.has-session .topbar-actions .product-switcher {
    grid-column: 1 / -1;
  }

}
