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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  padding: 14px;
  line-height: 1.6;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
}

h1 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

#upload-section {
  margin-top: 14px;
  padding: 24px 18px;
  background: #1a1a1a;
  border-radius: 10px;
  text-align: center;
}

.storage-warning {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(246, 173, 85, 0.4);
  background: rgba(246, 173, 85, 0.12);
  color: #f6ad55;
  font-size: 0.95rem;
}

input[type="file"] {
  margin: 14px 0 20px;
  color: #fff;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.session-caption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #9aa3af;
}

.session-caption.success {
  color: #4fc274;
}

.session-caption.warn {
  color: #f6ad55;
}

.uploading-status {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #9aa3af;
}


button {
  background: #fff;
  color: #000;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}

button:hover {
  background: #e0e0e0;
}

#status {
  padding: 20px;
  background: #1a1a1a;
  border-radius: 10px;
  margin-top: 20px;
}


.status-summary {
  margin-bottom: 10px;
}

.status-details {
  display: grid;
  gap: 8px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  background: #131313;
}

.status-item dt {
  font-size: 0.85rem;
  color: #9aa3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-item dd {
  font-weight: 600;
  color: #e6edf7;
}

#roi-section {
  margin-top: 18px;
  padding: 20px 16px;
  background: #141414;
  border-radius: 12px;
  border: 1px solid #222;
}


.roi-transition-copy {
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(79, 194, 116, 0.45);
  background: linear-gradient(180deg, rgba(79, 194, 116, 0.12), rgba(79, 194, 116, 0.06));
  color: #d7f6e1;
}

.roi-transition-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #8ee0a8;
}

.roi-transition-copy p {
  font-size: 0.92rem;
  color: #c8e7d2;
}

.roi-transition-copy ul {
  margin-top: 8px;
  margin-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
  color: #b9dfc5;
}

.roi-hint {
  margin-top: 6px;
  font-size: 0.95rem;
  color: #b9c2cc;
}

.roi-container {
  margin-top: 16px;
  position: relative;
  background: #0a0a0a;
  border: 1px solid #2b2b2b;
  border-radius: 12px;
  overflow: hidden;
}

#roi-frame {
  width: 100%;
  height: auto;
  display: block;
  background: #000;
}

#roi-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

#roi-rect {
  position: absolute;
  border: 2px solid #4fc274;
  background: rgba(79, 194, 116, 0.2);
  box-shadow: 0 0 0 1px rgba(10, 10, 10, 0.6);
}

.roi-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.roi-actions button {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 18px;
}

#clips-section .header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#clips-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.clip-card {
  background: #1a1a1a;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #333;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.clip-card:hover {
  border-color: #555;
}

.clip-card.is-kept {
  border-color: #4fc274;
  box-shadow: 0 0 0 1px rgba(79, 194, 116, 0.3);
}

.clip-card video {
  width: 100%;
  display: block;
  background: #000;
  aspect-ratio: 16 / 9;
}

.clip-info {
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #999;
}

.clip-info .clip-timestamp {
  font-size: 0.9em;
  color: #888;
}

.clip-controls {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid #2a2a2a;
}

.clip-row {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.keep-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
  font-weight: 500;
}

.keep-toggle {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.label-select {
  flex: 1;
  max-width: 170px;
  background: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.label-select:focus {
  outline: none;
  border-color: #666;
}

.clip-actions {
  width: 100%;
  display: flex;
  gap: 8px;
}

.clip-actions button {
  flex: 1;
}

.primary-action {
  background: #4fc274;
  color: #06110a;
}

.primary-action:hover {
  background: #66cf87;
}

.secondary-action {
  background: #d8dee3;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.75);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #111317;
  border-radius: 14px;
  border: 1px solid #2c2f36;
  padding: 18px 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-body {
  display: grid;
  gap: 16px;
}


.chart-meta {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.chart-help {
  color: #c7d1e5;
  font-size: 0.82rem;
  margin: 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: #d6e0f4;
  font-size: 0.8rem;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-swatch {
  width: 18px;
  height: 0;
  border-top: 3px solid transparent;
}

.chart-legend-swatch.band-run {
  height: 9px;
  border-top: none;
  background: rgba(79, 194, 116, 0.32);
  border: 1px solid rgba(79, 194, 116, 0.7);
  border-radius: 2px;
}

.chart-legend-swatch.band-gap {
  height: 9px;
  border-top: none;
  background: rgba(248, 113, 113, 0.24);
  border: 1px solid rgba(248, 113, 113, 0.66);
  border-radius: 2px;
}

.chart-legend-swatch.threshold {
  border-top-color: #fbd38d;
  border-top-style: dashed;
}

.chart-legend-swatch.cursor,
.chart-legend-swatch.sample-range {
  border-top-color: #c5d3ea;
  border-top-style: dashed;
}
.chart-card {
  position: relative;
  background: #0d0f14;
  border: 1px solid #20242d;
  border-radius: 12px;
  padding: 12px;
}

.chart-hover {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: 280px;
  background: rgba(9, 12, 18, 0.92);
  border: 1px solid #324055;
  color: #d8e4f8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: none;
}

#motion-chart {
  width: 100%;
  height: auto;
  display: block;
}

.diagnostics {
  display: grid;
  gap: 10px;
  background: #151922;
  border: 1px solid #262c39;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
}

.diagnostics dl {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 2fr;
  gap: 6px 12px;
}

.diagnostics dt {
  color: #9fb0c9;
  font-weight: 600;
}

.diagnostics dd {
  color: #e4ebf4;
}

.trim-editor {
  width: 100%;
  background: #121212;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: 8px 10px 10px;
}

.trim-editor summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.trim-editor summary::-webkit-details-marker {
  display: none;
}

.trim-fields {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trim-row-label {
  font-size: 0.95rem;
  color: #c9c9c9;
  font-weight: 500;
}

.trim-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
}

.trim-track {
  position: relative;
  width: 100%;
  height: 26px;
  border-radius: 999px;
  background: #3a3a3a;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  touch-action: none;
}

.trim-track.is-disabled {
  opacity: 0.6;
}

.trim-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f8d66f, #f4c643);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.45);
}

.trim-center-tick {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.trim-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 34px;
  border-radius: 6px;
  border: 2px solid #fef3c7;
  background: #f9d976;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45);
  cursor: grab;
  padding: 0;
}

.trim-handle::before {
  content: "";
  position: absolute;
  inset: 6px 6px;
  border-left: 2px solid rgba(135, 90, 17, 0.5);
  border-right: 2px solid rgba(135, 90, 17, 0.5);
}

.trim-handle:active {
  cursor: grabbing;
}

.trim-handle:focus-visible {
  outline: 2px solid #fbd38d;
  outline-offset: 2px;
}

.trim-fine-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #181818;
  border: 1px solid #2b2b2b;
  border-radius: 10px;
  padding: 10px 12px;
}

.trim-buttons {
  display: flex;
  gap: 8px;
}

.trim-center-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.trim-center-input {
  background: #0f0f0f;
  border: 1px solid #3b3b3b;
  color: #f4f4f4;
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 40px;
  width: 130px;
}

.trim-center-input::placeholder {
  color: #9aa3af;
}

.trim-step {
  background: #2a2a2a;
  color: #f4f4f4;
  border: 1px solid #3b3b3b;
  padding: 8px 14px;
  min-height: 40px;
  min-width: 64px;
}

.trim-step-fine {
  min-width: 72px;
}

.trim-step:hover {
  background: #383838;
}

.trim-effective {
  font-size: 0.9rem;
  color: #9ec2ff;
  background: #111928;
  border-radius: 8px;
  padding: 8px 10px;
}

.trim-status {
  font-size: 0.85rem;
  min-height: 18px;
  color: #9aa3af;
}

.trim-status.is-saving {
  color: #fbd38d;
}

.trim-status.is-saved {
  color: #86efac;
}

.trim-status.is-error {
  color: #fca5a5;
}

.feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.feedback.info {
  background: #17202b;
  color: #cbe3ff;
}

.feedback.success {
  background: #163220;
  color: #b9f8cc;
}

.feedback.warn {
  background: #332915;
  color: #fce2b1;
}

@media (min-width: 860px) {
  body {
    padding: 20px;
  }

  #clips-section .header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  #clips-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 18px;
  }

  .roi-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .roi-actions button {
    width: auto;
    min-width: 160px;
  }
}
