:root {
  --bg: #070b13;
  --surface: rgba(10,14,24,.97);
  --surface2: rgba(8,11,20,.98);
  --text: #e2e8f4;
  --muted: #7a8599;
  --stroke: rgba(255,255,255,.07);
  --accent: #5a8cff;
  --r: 14px;
  --r-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

/* ===== LAYOUT ===== */
.wrap {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
}

/* ===== HEADER ===== */
.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 8px 14px;
}
.topLeft { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.appName {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .6px;
  color: var(--accent);
  text-transform: uppercase;
}
.topCenter {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.titleInput {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  outline: none;
  padding: 4px 2px;
  min-width: 0;
  transition: border-color .15s;
}
.titleInput:focus { border-bottom-color: var(--accent); }
.titleInput::placeholder { color: var(--muted); font-weight: 400; font-size: 13px; }
.pill {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topActions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.08);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  cursor: pointer;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  color: var(--text);
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .1s;
}
.btn:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn.icon { padding: 6px 9px; }
.btn.small { padding: 5px 9px; font-size: 11px; }
.btn.primary {
  background: rgba(90,140,255,.16);
  border-color: rgba(90,140,255,.35);
  color: #a5c0ff;
}
.btn.primary:hover { background: rgba(90,140,255,.26); }
.btn.danger {
  background: rgba(248,113,113,.10);
  border-color: rgba(248,113,113,.25);
  color: rgba(255,160,160,.9);
}
.btn.danger:hover { background: rgba(248,113,113,.18); }
.btn[disabled] { opacity: .35; cursor: not-allowed; transform: none !important; }

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  overflow: hidden;
}

/* ===== GRID ===== */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 252px 1fr 270px;
  gap: 6px;
  min-height: 0;
}

/* ===== PANELS ===== */
.panel { display: flex; flex-direction: column; min-height: 0; }
.panelContent {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}
.panelContent::-webkit-scrollbar { width: 3px; }
.panelContent::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 99px; }
.panelFooter {
  flex: 0 0 auto;
  padding: 8px 10px;
  background: var(--surface2);
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex;
  gap: 6px;
}
.panelFooter .btn { flex: 1; justify-content: center; }

/* ===== SECTIONS ===== */
.sec { margin-bottom: 14px; }
.sec:last-child { margin-bottom: 2px; }
.secTitle {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.mt { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 6px; }

/* ===== DESCRIPTION ===== */
.descArea {
  width: 100%;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.07);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 11px;
  font-family: inherit;
  resize: vertical;
  min-height: 52px;
  max-height: 100px;
  outline: none;
  line-height: 1.5;
  transition: border-color .15s;
}
.descArea:focus { border-color: rgba(90,140,255,.35); }
.descArea::placeholder { color: var(--muted); }

/* ===== JOUEURS ===== */
.addPlayerRow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.addPlayerRow .text { min-width: 0; }

/* ===== TOOL GRID ===== */
.toolGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.toolGrid2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}
.tool {
  cursor: pointer;
  padding: 9px 4px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.07);
  color: var(--text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background .13s, border-color .13s, transform .1s;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .2px;
  line-height: 1;
}
.tool:hover {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.16);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  color: var(--text);
}
.tool:active { transform: translateY(0); }
.tool svg { flex-shrink: 0; }

/* ===== ANNOTATION OPTS ===== */
.annotOpts {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.05);
}

/* ===== INPUTS ===== */
.text {
  flex: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, background .12s;
}
.text:focus { border-color: rgba(90,140,255,.45); background: rgba(90,140,255,.05); }
.text.small { width: 64px; flex: none; }
select.text option { background: #0b0f1c; color: var(--text); }

.colorPick {
  width: 30px;
  height: 26px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: #07090f;
  flex-shrink: 0;
}
.colorPickLg {
  width: 36px;
  height: 30px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: #07090f;
  flex-shrink: 0;
}

/* ===== BOXES ===== */
.box {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  font-size: 11px;
  min-height: 36px;
  line-height: 1.5;
}
.box b { color: var(--text); }

/* ===== SELECTION PROPS ===== */
.propGroup {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.propRow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.propLabel {
  font-size: 10px;
  color: var(--muted);
  min-width: 52px;
  flex-shrink: 0;
}

/* ===== HELP ===== */
.help {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.05);
}
.helpRow { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
kbd {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  color: var(--text);
  min-width: 56px;
  text-align: center;
  flex-shrink: 0;
}

/* ===== MISC ===== */
.mini { font-size: 11px; color: var(--muted); }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.hidden { display: none !important; }

/* ===== PITCH ===== */
.pitchCard { padding: 0; min-height: 0; }
.pitchWrap { width: 100%; height: 100%; background: #0a1c10; overflow: hidden; }
#pitchSvg { width: 100%; height: 100%; display: block; }
#pitchSvg.drawMode { cursor: crosshair !important; }

/* ===== PLAYBACK ===== */
.playRow { display: flex; align-items: center; gap: 5px; }
.playBtn {
  padding: 8px 14px;
  background: rgba(90,140,255,.16);
  border-color: rgba(90,140,255,.35);
  color: #a5c0ff;
  font-size: 14px;
}
.playBtn:hover { background: rgba(90,140,255,.26); }

/* ===== TIMELINE ===== */
#timeSlider {
  width: 100%;
  accent-color: var(--accent);
  margin: 6px 0 4px;
}
.timeInfo { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.timeLabel {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.durRow { display: flex; align-items: center; gap: 4px; }

/* ===== VISUAL TIMELINE ===== */
.vizTimeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 130px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}
.vizTimeline:empty::after {
  content: "Aucune trajectoire";
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
  display: block;
}
.vtRow {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.02);
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.vtRow:hover { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.10); }
.vtRow.vtSel { background: rgba(90,140,255,.10); border-color: rgba(90,140,255,.25); }
.vtDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.2);
}
.vtName { font-size: 11px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtPts { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.vtBar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.vtBarFill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  opacity: .5;
  position: absolute;
  left: 0;
  top: 0;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(10,14,24,.97);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  max-width: 380px;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(52,211,153,.35); color: #6ee7b7; }
.toast.error { border-color: rgba(248,113,113,.35); color: #fca5a5; }

/* ===== DYNAMIC STATES ===== */
.toolActive {
  background: rgba(90,140,255,.18) !important;
  border-color: rgba(90,140,255,.50) !important;
  color: #a5c0ff !important;
}
.dragging { opacity: .45; }
.trackPoint { cursor: grab; }
.trackPoint:active { cursor: grabbing; }
.mgHandle { cursor: nwse-resize; }
.mgHandle.ne { cursor: nesw-resize; }
.mgHandle.nw { cursor: nwse-resize; }
.mgHandle.se { cursor: nwse-resize; }
.mgHandle.sw { cursor: nesw-resize; }
.mgRotate { cursor: grab; }
.mgRotate:active { cursor: grabbing; }
.zoneHandle { cursor: nwse-resize; }
.zoneHandle[data-handle="n"] { cursor: ns-resize; }
.zoneHandle[data-handle="s"] { cursor: ns-resize; }
.zoneHandle[data-handle="e"] { cursor: ew-resize; }
.zoneHandle[data-handle="w"] { cursor: ew-resize; }
.zoneHandle[data-handle="nw"] { cursor: nwse-resize; }
.zoneHandle[data-handle="ne"] { cursor: nesw-resize; }
.zoneHandle[data-handle="se"] { cursor: nwse-resize; }
.zoneHandle[data-handle="sw"] { cursor: nesw-resize; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
  .top { flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .topCenter { order: 3; width: 100%; }
  .titleInput { font-size: 13px; }
}
@media (max-width: 640px) {
  html, body { overflow: auto; }
  .wrap { height: auto; min-height: 100vh; }
  .topActions { gap: 3px; }
  .grid { gap: 4px; }
}

/* ===== RECORD MODE ===== */
.recActive {
  background: rgba(239,68,68,.18) !important;
  border-color: rgba(239,68,68,.45) !important;
  color: #fca5a5 !important;
  animation: recPulse 1.1s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%       { box-shadow: 0 0 0 5px rgba(239,68,68,.0); }
}
#animPanel.recMode {
  box-shadow: 0 0 0 1.5px rgba(239,68,68,.40);
}

/* ===== KEYFRAME BUTTON ===== */
.btnKF {
  width: 100%;
  justify-content: center;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(52,211,153,.10);
  border-color: rgba(52,211,153,.28);
  color: #6ee7b7;
  letter-spacing: .2px;
}
.btnKF:hover {
  background: rgba(52,211,153,.18) !important;
  border-color: rgba(52,211,153,.50) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(52,211,153,.15);
}
.btnKF:active { transform: translateY(0); }

/* ===== SECTION COLLAPSIBLE ===== */
.secToggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.secToggle:hover { color: var(--text); }
.secToggle .toggleArrow { font-size: 9px; transition: transform .2s; }
.secToggle.open .toggleArrow { transform: rotate(90deg); }
