* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
#top-bar {
  background: #16213e;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #0f3460;
}

#video-loader {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

#btn-pick-file {
  padding: 7px 14px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  background: #0f3460;
  color: #ccc;
}

#btn-pick-file:hover { background: #1a4a7a; }

#video-name {
  font-size: 12px;
  color: #28a745;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Orientation labeler: highlight videos this labeler has already touched.
   Chrome/Firefox honor color on <option>; Safari ignores it (the "· N
   labeled" suffix still reads). Native macOS select widgets ignore
   font-weight, but Chrome respects it. */
#video-select option.labeled {
  color: #28a745;
  font-weight: 600;
}


/* Main layout */
#main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left panel - punch types */
#punch-panel {
  width: 200px;
  min-width: 200px;
  background: #16213e;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid #0f3460;
  overflow-y: auto;
}

#punch-panel h3 {
  font-size: 14px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

#punch-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}


.punch-btn {
  padding: 10px 12px;
  border: 2px solid #0f3460;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.punch-btn:hover {
  border-color: #533483;
  background: #1e2a4a;
}

.punch-btn.selected {
  border-color: #e94560;
  background: #2a1a2e;
  color: #fff;
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.punch-group-header {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 0 2px;
  border-bottom: 1px solid #0f3460;
  margin-top: 4px;
}

.punch-group-header:first-child {
  margin-top: 0;
}

.punch-btn .shortcut {
  font-size: 11px;
  color: #666;
  background: #0d1117;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
}

.punch-btn.selected .shortcut {
  color: #e94560;
}

/* Center - video */
#video-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-width: 0;
}

#video-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  max-width: 100%;
  max-height: calc(100vh - 200px);
}

#video-player {
  display: block;
  width: 100%;
  max-height: calc(100vh - 200px);
  background: #000;
}

#video-controls {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Timeline minimap */
#timeline-minimap {
  position: relative;
  width: 100%;
  height: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 2px;
  margin-bottom: 3px;
  cursor: pointer;
}

#minimap-segments {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

#minimap-viewport {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(233, 69, 96, 0.2);
  border: 1px solid rgba(233, 69, 96, 0.5);
  border-radius: 2px;
  cursor: grab;
  z-index: 1;
}

#minimap-viewport:active { cursor: grabbing; }

#minimap-playhead {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: #e94560;
  z-index: 2;
  pointer-events: none;
}

/* Time ticks */
#timeline-ticks {
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  height: 16px;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.timeline-tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 5px;
  background: rgba(255,255,255,0.25);
}

.timeline-tick.major {
  height: 8px;
  background: rgba(255,255,255,0.4);
}

.timeline-tick-label {
  position: absolute;
  top: 0;
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  font-family: 'Courier New', monospace;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Zoom controls */
#zoom-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}

#zoom-controls button {
  padding: 3px 8px;
  font-size: 12px;
  min-width: 28px;
}

#zoom-level-display {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #e94560;
  min-width: 28px;
  text-align: center;
}

/* Seek bar full width on its own row */
#seek-bar-wrapper {
  position: relative;
  width: 100%;
  margin-top: 18px;
}

#seek-bar {
  width: 100%;
  accent-color: #e94560;
  height: 6px;
  cursor: pointer;
}

/* Seek bar overlay */
#seek-bar-overlay {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  border-radius: 3px;
}

#seek-bar {
  position: relative;
  z-index: 1;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

#seek-bar::-webkit-slider-runnable-track {
  background: rgba(255,255,255,0.1);
  height: 6px;
  border-radius: 3px;
}

#seek-bar::-moz-range-track {
  background: rgba(255,255,255,0.1);
  height: 6px;
  border-radius: 3px;
}

#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e94560;
  cursor: pointer;
  margin-top: -4px;
}

#seek-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e94560;
  cursor: pointer;
  border: none;
}

.seek-segment {
  position: absolute;
  top: 0;
  height: 100%;
  opacity: 0.6;
  border-radius: 2px;
  pointer-events: none;
}

.seek-segment.outside-round {
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
  border-radius: 0;
  /* Diagonal stripes to indicate "outside round" */
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.06) 3px,
    rgba(255, 255, 255, 0.06) 6px
  );
}

/* Video dim overlay (outside round) */
#video-dim-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity 0.3s;
  display: none;
}

#video-dim-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#video-dim-overlay .dim-label {
  font-size: 28px;
  font-weight: bold;
  color: rgba(233, 69, 96, 0.7);
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* Video overlay */
#video-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

#video-overlay:empty {
  display: none;
}

.video-overlay-tag {
  padding: 6px 16px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  border-left: 4px solid;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  transition: background 0.15s;
  pointer-events: auto;
  cursor: pointer;
}
.video-overlay-tag:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Overlay toggle button */
#btn-overlay,
#btn-defense-filter {
  font-size: 11px;
  padding: 3px 10px;
  min-width: auto;
}

#btn-overlay.overlay-off,
#btn-defense-filter.overlay-off {
  opacity: 0.5;
}

/* Hidden overlays */
.overlays-hidden #seek-bar-overlay,
.overlays-hidden #video-overlay,
.overlays-hidden #video-dim-overlay {
  display: none !important;
}

/* Thumbnail preview */
#seek-thumbnail {
  display: none;
  position: absolute;
  bottom: 24px;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

#thumb-canvas {
  border: 2px solid #e94560;
  border-radius: 4px;
  background: #000;
}

#thumb-time {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #e94560;
  background: rgba(0,0,0,0.8);
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 2px;
}

/* Controls row below seek bar */
#controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#video-controls button {
  padding: 6px 12px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #533483;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  min-width: 36px;
}

#video-controls button:hover { background: #1a4a7a; }

#time-display {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: #e94560;
  min-width: 180px;
}

#speed-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

#speed-controls button {
  padding: 3px 8px;
  font-size: 11px;
  min-width: auto;
}

#speed-controls .speed-active {
  background: #e94560;
  border-color: #e94560;
}

/* Right panel - labeling */
#label-panel {
  width: 280px;
  min-width: 280px;
  background: #16213e;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid #0f3460;
  overflow-y: auto;
}

#label-panel h3 {
  font-size: 14px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#selected-punch {
  font-size: 14px;
  color: #888;
  padding: 8px;
  background: #1a1a2e;
  border-radius: 4px;
  text-align: center;
}

#btn-timestamp {
  padding: 14px;
  font-size: 15px;
  font-weight: bold;
  border: 2px solid #0f3460;
  border-radius: 6px;
  background: #1a1a2e;
  color: #666;
  cursor: not-allowed;
  transition: all 0.15s;
}

#btn-timestamp.ready {
  border-color: #28a745;
  background: #1a2e1a;
  color: #28a745;
  cursor: pointer;
}

#btn-timestamp.ready:hover {
  background: #1e3a1e;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

#btn-timestamp.end-mode {
  border-color: #e94560;
  background: #2e1a1a;
  color: #e94560;
  cursor: pointer;
}

#btn-timestamp.end-mode:hover {
  background: #3a1e1e;
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

#pending-label {
  font-size: 12px;
  color: #888;
  padding: 4px 8px;
  min-height: 20px;
}

#label-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-entry {
  font-size: 12px;
  padding: 6px 8px;
  background: #1a1a2e;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 3px solid #533483;
}

.label-entry .label-text {
  flex: 1;
}

.label-entry .label-delete {
  background: none;
  border: none;
  color: #e94560;
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  opacity: 0.5;
}

.label-entry .label-delete:hover { opacity: 1; }
.edit-form > .label-delete {
  position: absolute;
  top: 0;
  right: 0;
}

/* Round indicator in label panel */
#round-indicator {
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 11px;
  text-align: center;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

#round-indicator.round-idle {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #666;
}

#round-indicator.round-idle:hover {
  border-color: #533483;
  color: #aaa;
}

#round-indicator.round-active {
  background: #2e1a1a;
  border: 1px solid #e94560;
  color: #e94560;
  animation: pulse 1.5s infinite;
}

/* Round marker entries - less prominent */
.label-entry.round-marker {
  border-left-color: #444;
  opacity: 0.65;
  padding: 4px 8px;
  font-size: 11px;
}

/* Edit form inside label entry */
.label-entry.editing {
  border-left-color: #e94560;
  padding: 8px;
}

.edit-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}

.edit-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.edit-row label {
  font-size: 11px;
  color: #888;
  min-width: 30px;
}

.edit-form select, .edit-form input {
  background: #0d1117;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 3px;
  padding: 3px 5px;
  font-size: 11px;
}

.edit-form select { flex: 1; min-width: 0; max-width: 90px; }
.edit-form input[type="text"] { width: 70px; }

.edit-row button {
  padding: 3px 8px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.edit-save { background: #28a745; color: white; }
.edit-cancel { background: #555; color: white; }
.edit-seek { background: #0f3460; color: #ccc; }

/* Shortcuts bar */
#shortcuts-bar {
  background: #0d1117;
  padding: 8px 16px;
  font-size: 12px;
  color: #666;
  border-top: 1px solid #0f3460;
}

/* Status toast */
.toast {
  position: fixed;
  bottom: 50px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 1000;
  animation: fadeIn 0.2s, fadeOut 0.3s 2.7s;
  opacity: 0;
  animation-fill-mode: forwards;
}

.toast.success { background: #28a745; color: white; }
.toast.error { background: #e94560; color: white; }
.toast.info { background: #0f3460; color: white; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ============================================================
   Rules labeler (rules.html) — punch list + checklist panels.
   Shares #top-bar, #drive-link-bar, #video-container, #shortcuts-bar
   with index.html; only the left and right panels differ.
   ============================================================ */

#punch-list-panel {
  width: 220px;
  min-width: 220px;
  background: #16213e;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid #0f3460;
  overflow: hidden;
}

#punch-list-panel h3 {
  font-size: 13px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

#punch-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#punch-filter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 4px;
}

#punch-filter .filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

#punch-filter label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 30px;
}

#punch-filter select {
  flex: 1;
  background: #0d1117;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 3px;
  padding: 3px 5px;
  font-size: 11px;
  min-width: 0;
}

#punch-filter .filter-answer-row {
  gap: 3px;
}

.filter-ans {
  flex: 1;
  padding: 4px 0;
  background: #0d1117;
  color: #888;
  border: 1px solid #0f3460;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.1s;
  text-align: center;
  min-width: 0;
}

.filter-ans:hover { background: #1a2a4a; color: #e0e0e0; }

.filter-ans.active                   { background: #1a2e3a; border-color: #5ab; color: #cde; }
.filter-ans.ans-pass.active          { background: #1a3a1e; border-color: #28a745; color: #28a745; }
.filter-ans.ans-fail.active          { background: #3a1a1e; border-color: #e94560; color: #e94560; }
.filter-ans.ans-unclear.active       { background: #2a2a2a; border-color: #888;    color: #ccc;    }
.filter-ans.ans-unanswered.active    { background: #2a2a3a; border-color: #aab;    color: #cce;    }

#punch-list-empty {
  padding: 12px 8px;
  text-align: center;
  color: #666;
  font-size: 12px;
  font-style: italic;
}

.punch-list-entry {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: #1a1a2e;
  border-radius: 4px;
  border-left: 3px solid #555;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s, border-color 0.1s;
}

.punch-list-entry:hover { background: #1e2a4a; }
.punch-list-entry.current { background: #2a1a2e; border-left-color: #e94560; }
.punch-list-entry.status-partial  { border-left-color: #ffaa33; }
.punch-list-entry.status-complete { border-left-color: #28a745; }

.punch-list-entry .pl-idx {
  color: #555;
  font-family: 'Courier New', monospace;
  text-align: right;
}
.punch-list-entry .pl-type {
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.punch-list-entry .pl-time {
  color: #888;
  font-family: 'Courier New', monospace;
  font-size: 11px;
}
.punch-list-entry .pl-progress {
  color: #666;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  min-width: 26px;
  text-align: right;
}
.punch-list-entry.status-complete .pl-progress { color: #28a745; }
.punch-list-entry.status-partial  .pl-progress { color: #ffaa33; }

/* Right panel — current-punch card + rule checklist */
#rules-panel {
  width: 320px;
  min-width: 320px;
  background: #16213e;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1px solid #0f3460;
  overflow-y: auto;
}

#current-punch-card {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#current-punch-empty {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 12px 0;
}

#rule-next-btn {
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  border: 2px solid #28a745;
  background: #1a2e1a;
  color: #5aff7a;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}
#rule-next-btn:hover:not(:disabled) {
  background: #1e3a1e;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.35);
}
#rule-next-btn:disabled {
  border-color: #2a3550;
  background: #16213e;
  color: #555;
  cursor: not-allowed;
}

#rule-complete-badge {
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  border: 2px solid #28a745;
  background: #28a745;
  color: #0a1a0a;
  text-align: center;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(40, 167, 69, 0.4);
}

#current-punch-card .cp-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
#current-punch-card .cp-label { color: #888; text-transform: uppercase; letter-spacing: 0.5px; font-size: 10px; padding-top: 2px; }
#current-punch-card .cp-value { color: #e0e0e0; font-family: 'Courier New', monospace; text-align: right; }

#rule-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-row {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-left-width: 3px;
  border-radius: 5px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.rule-row:hover { background: #1e2a4a; }
.rule-row.active {
  border-color: #e94560;
  border-left-color: #e94560;
  box-shadow: 0 0 6px rgba(233, 69, 96, 0.25);
}
.rule-row.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rule-row .rule-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.rule-row .rule-num {
  background: #0d1117;
  color: #666;
  font-family: monospace;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}
.rule-row.active .rule-num { color: #e94560; }
.rule-row .rule-title { font-size: 13px; font-weight: 600; color: #e0e0e0; }
.rule-row .rule-na {
  margin-left: auto;
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rule-row .rule-cue { color: #888; font-size: 11px; margin-bottom: 6px; }

.rule-row .rule-answers {
  display: flex;
  gap: 4px;
}

.ans-btn {
  flex: 1;
  padding: 5px 8px;
  background: #0d1117;
  color: #888;
  border: 1px solid #0f3460;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.1s;
  text-transform: capitalize;
}
.ans-btn:hover { background: #1a2a4a; color: #e0e0e0; }
.rule-row.disabled .ans-btn { pointer-events: none; }

.ans-btn.ans-pass.active    { background: #1a3a1e; border-color: #28a745; color: #28a745; }
.ans-btn.ans-fail.active    { background: #3a1a1e; border-color: #e94560; color: #e94560; }
.ans-btn.ans-unclear.active { background: #2a2a2a; border-color: #888;   color: #ccc;     }
