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

:root {
  --green:   #22c55e;
  --red:     #ef4444;
  --orange:  #f97316;
  --yellow:  #eab308;
  --blue:    #3b82f6;
  --bg:      #0f172a;
  --surface: #1e293b;
  --surface2:#263348;
  --border:  #334155;
  --text:    #f1f5f9;
  --muted:   #64748b;
  --radius:  12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow-x: hidden;
}

/* ── Views ─────────────────────────────────────────────── */
.view { display: none; flex-direction: column; min-height: 100dvh; }
.view.active { display: flex; }

/* ═══════════════════════════════════════════════════════
   VIEW 1 — Selection
═══════════════════════════════════════════════════════ */
.app-header {
  padding: 28px 20px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

#movement-grid {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.mv-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  width: 100%;
}
.mv-card:active { transform: scale(0.98); }
.mv-card:hover  { background: var(--surface2); border-color: var(--blue); }

.mv-icon { font-size: 1.8rem; flex-shrink: 0; width: 36px; text-align: center; }

.mv-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mv-info strong { font-size: 0.95rem; color: var(--text); }
.mv-info span   { font-size: 0.75rem; color: var(--muted); line-height: 1.3; }

.mv-arrow { color: var(--muted); font-size: 1.4rem; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════
   VIEW 2 — Analyser
═══════════════════════════════════════════════════════ */

/* Header */
.analyse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#back-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
#back-btn:hover { background: var(--surface2); }

#mv-title-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.95rem;
}
#mv-icon-header { font-size: 1.1rem; }

/* Camera */
#video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
  max-height: 44vh;
}
#video  { position: absolute; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#canvas { position: absolute; width: 100%; height: 100%; transform: scaleX(-1); }

#feedback-badge {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s;
  white-space: nowrap;
  z-index: 10;
}
#feedback-badge.show-good { opacity: 1; background: rgba(34,197,94,.9);  color:#fff; }
#feedback-badge.show-bad  { opacity: 1; background: rgba(239,68,68,.9);  color:#fff; }
#feedback-badge.show-info { opacity: 1; background: rgba(59,130,246,.9); color:#fff; }

#pose-hint {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}

/* Stats bar */
#stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--border);
  gap: 1px;
  flex-shrink: 0;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: var(--surface);
}
.sv { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.sl { font-size: 0.62rem; color: var(--muted); margin-top: 2px; text-align: center; }

/* Score bar */
#score-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#score-label { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
#score-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
#score-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.4s, background 0.4s;
}
#score-value { font-size: 0.8rem; font-weight: 700; width: 30px; text-align: right; }

/* Corrections */
#corrections-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
.panel-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
#corrections-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#corrections-list li {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
li.c-muted  { color: var(--muted); }
li.c-ok     { background: rgba(34,197,94,.1);  border-left: 3px solid var(--green);  color: #86efac; }
li.c-warn   { background: rgba(234,179,8,.1);  border-left: 3px solid var(--yellow); color: #fde047; }
li.c-error  { background: rgba(239,68,68,.1);  border-left: 3px solid var(--red);    color: #fca5a5; }
li.c-info   { background: rgba(59,130,246,.1); border-left: 3px solid var(--blue);   color: #93c5fd; }

/* Controls */
#controls {
  display: flex;
  gap: 10px;
  padding: 10px 14px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#controls button {
  flex: 1;
  padding: 11px;
  border-radius: 10px;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
#controls button:disabled { opacity: .35; cursor: not-allowed; }
#start-btn          { background: var(--blue); color: #fff; }
#start-btn.is-stop  { background: var(--red); }
#reset-btn          { background: var(--border); color: var(--text); }
