/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1c1b38;
  --surface:   #242341;
  --surface2:  #2d2c52;
  --border:    #3e3b68;
  --accent:    #8170E7;
  --accent2:   #a99df0;
  --gold:      #F0CF6F;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warn:      #F0CF6F;
  --text:      #FAFAFA;
  --muted:     #9997b8;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Layout ───────────────────────────────────────────────────────── */
header {
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-logo {
  height: 32px;
  width: auto;
  display: block;
}
.header-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}
.header-product {
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}

main {
  width: 100%;
  max-width: 900px;
  padding: 32px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Step indicator ───────────────────────────────────────────────── */
.steps {
  display: flex;
  gap: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--muted);
  padding: 0 4px;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  width: 24px; height: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.steps li.active { color: var(--text); }
.steps li.active::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.done::before { background: var(--success); border-color: var(--success); color: #fff; content: "✓"; }
.steps li + li::after {
  /* connector shown via a pseudo on the li itself */
}

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Drop zone ────────────────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
#drop-zone:hover, #drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(108,99,255,.06);
}
#drop-zone p { color: var(--muted); font-size: .9rem; margin-top: 8px; }
#drop-zone .icon { font-size: 2.5rem; }
#file-input { display: none; }

/* ── Modality picker ──────────────────────────────────────────────── */
.modality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.mod-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
  color: var(--text);
  font-size: .82rem;
  line-height: 1.3;
}
.mod-btn .mod-icon { font-size: 1.4rem; display: block; margin-bottom: 6px; }
.mod-btn:hover { border-color: var(--accent2); }
.mod-btn.selected { border-color: var(--accent); background: rgba(108,99,255,.15); }

/* ── Frame picker ─────────────────────────────────────────────────── */
.frame-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.frame-picker-label {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 500;
}
.frame-picker-label span {
  color: var(--text);
  font-weight: 700;
}
.canvas-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  cursor: crosshair;
}
.canvas-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.canvas-hint {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 4px;
}
.frame-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Point legend ─────────────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 16px;
  font-size: .78rem;
  color: var(--muted);
  margin-top: 2px;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.pos { background: #22c55e; }
.dot.neg { background: #ef4444; }

/* ── Text categories input ────────────────────────────────────────── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 44px;
  align-items: center;
  cursor: text;
}
.tag {
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tag .remove {
  cursor: pointer;
  opacity: .7;
  font-size: .7rem;
  font-weight: 700;
}
.tag .remove:hover { opacity: 1; }
#tag-input-field {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .85rem;
  flex: 1;
  min-width: 120px;
}

/* ── Accepted frame display ───────────────────────────────────────── */
.accepted-frame {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--success);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
}
.accepted-frame .thumb {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.accepted-frame .info { flex: 1; }
.accepted-frame .info strong { display: block; color: var(--success); }
.accepted-frame .clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  padding: 4px 6px;
  border-radius: 4px;
}
.accepted-frame .clear-btn:hover { background: var(--surface); color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: .87; }
.btn:not(:disabled):active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }

/* ── Progress ─────────────────────────────────────────────────────── */
.progress-wrap { background: var(--surface2); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar  {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width .3s ease;
  width: 0%;
}
.progress-label { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* ── Result video ─────────────────────────────────────────────────── */
#result-video {
  width: 100%;
  border-radius: 8px;
  background: #000;
  display: block;
}
.result-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ── Error banner ─────────────────────────────────────────────────── */
.error-banner {
  background: rgba(239,68,68,.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .85rem;
  color: var(--danger);
  display: none;
}
.error-banner.visible { display: block; }

/* ── Divider ──────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* ── Utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent2);
  margin-bottom: 8px;
}
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* Box list (semantic exemplar) */
#box-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.box-tag {
  background: rgba(251,191,36,.15);
  border: 1px solid #fbbf24;
  color: var(--text);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .78rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.box-tag .remove { cursor: pointer; opacity: .7; font-size: .7rem; font-weight: 700; }
.box-tag .remove:hover { opacity: 1; color: var(--danger); }

/* Sample video grid */
#sample-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sample-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  min-width: 180px;
}
.sample-card:hover { border-color: var(--accent); background: rgba(108,99,255,.08); }
.sample-card.loading { opacity: .6; cursor: not-allowed; pointer-events: none; }
.sample-card .sample-icon { font-size: 1.3rem; flex-shrink: 0; }

/* spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading overlay */
#model-loading-banner {
  background: rgba(108,99,255,.12);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .82rem;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 10px;
}
