:root {
  --bg: #0a0e1a;
  --bg-elev: #121829;
  --bg-elev-2: #1a2138;
  --border: #26304d;
  --text: #e6ebf5;
  --text-dim: #9aa6c2;
  --accent: #6ea8fe;
  --accent-2: #ffd479;
  --danger: #ff6b6b;
  --ok: #4dd08a;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 80% -10%, #16213f 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.moon-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background:
    radial-gradient(circle at 65% 35%, #f4f1e6 0%, #cfc9b4 45%, #8f8a76 100%);
  box-shadow: inset -8px -6px 12px rgba(0,0,0,0.45), 0 0 22px rgba(255, 236, 179, 0.25);
}

.app-header h1 { font-size: 18px; margin: 0; letter-spacing: 0.3px; }
.subtitle { margin: 2px 0 0; color: var(--text-dim); font-size: 12px; }
.ref-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.ref-link:hover { text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-elev);
}
.drop-zone.dragover { border-color: var(--accent); background: var(--bg-elev-2); }
.drop-inner { text-align: center; padding: 24px; }
.upload-glyph { font-size: 46px; color: var(--accent); }
.drop-title { font-size: 16px; margin: 12px 0 6px; }
.drop-hint { color: var(--text-dim); max-width: 420px; margin: 0 auto; }

/* Stage / video */
.stage { display: flex; flex-direction: column; gap: 14px; }
.video-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  line-height: 0;
}
#video { width: 100%; display: block; max-height: 62vh; object-fit: contain; background: #000; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.transport {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
}
.seek { flex: 1; accent-color: var(--accent); }
.time-label { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }

.analysis-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.progress-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 240px; }
.progress-track { flex: 1; height: 8px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.15s; }
.progress-text { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 40px; }

/* Buttons */
.btn {
  background: var(--bg-elev-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; font-size: 14px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #232c47; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #4f8dfd, #3f79e6); border-color: #3f79e6; font-weight: 600; }
.btn-primary:hover { background: linear-gradient(180deg, #5f99ff, #4a83ef); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Cards */
.side-panel { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card h2 { font-size: 14px; margin: 0 0 12px; letter-spacing: 0.3px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.field-value { color: var(--accent); font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field-help { color: var(--text-dim); font-size: 11px; }
.checkbox-field { flex-direction: row; align-items: center; gap: 10px; }
.checkbox-field input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Results */
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.results-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.pill { background: var(--accent); color: #06122c; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.empty-state { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
.results-scroll { max-height: 320px; overflow: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.results-table th, .results-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.results-table th { color: var(--text-dim); font-weight: 600; position: sticky; top: 0; background: var(--bg-elev); }
.results-table tbody tr { cursor: pointer; }
.results-table tbody tr:hover { background: var(--bg-elev-2); }
.results-table tbody tr.active { background: #2a3a5f; }
.tag-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); margin-right: 6px; }

.note-card p { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin: 0 0 8px; }
.disclaimer { color: #c7a24a; }

.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); z-index: 50; font-size: 13px;
}

.credit {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 0 2px;
  letter-spacing: 0.3px;
}

/* Collapsible section */
.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 12px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.collapse-header h2 { margin: 0; }
.collapse-header .chevron {
  color: var(--text-dim);
  font-size: 12px;
  transition: transform 0.2s ease;
}
.collapse-header[aria-expanded="false"] { margin-bottom: 0; }
.collapse-header[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
.collapse-header:hover .chevron { color: var(--accent); }

.collapse-body {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}
.collapse-body.collapsed {
  max-height: 0 !important;
  opacity: 0;
}

/* Per-row clip export button */
.clip-btn { white-space: nowrap; padding: 4px 10px; }
.clip-btn:disabled { opacity: 0.6; }
