/* ------------------------------------------------------------------
   design system façon shadcn/ui (zinc), en css pur
   ------------------------------------------------------------------ */
@font-face { font-family: "Geist"; font-weight: 100 900; font-display: swap; src: url("/fonts/geist-latin-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist"; font-weight: 100 900; font-display: swap; src: url("/fonts/geist-latin-ext-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Geist Mono"; font-weight: 100 900; font-display: swap; src: url("/fonts/geist-mono-latin-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist Mono"; font-weight: 100 900; font-display: swap; src: url("/fonts/geist-mono-latin-ext-wght-normal.woff2") format("woff2-variations"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #09090b;
  --fg: #fafafa;
  --card: #0c0c0f;
  --muted: #18181b;
  --muted-fg: #a1a1aa;
  --border: #27272a;
  --input: #3f3f46;
  --ring: #a1a1aa;
  --accent: #1f1f23;
  --primary: #fafafa;
  --primary-fg: #18181b;
  --destructive: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --switch-off: #3f3f46;
  --chart-1: #3b82f6;
  --chart-2: #f59e0b;
  --scroll: #3f3f46;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-fg: #71717a;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --ring: #71717a;
  --accent: #f4f4f5;
  --primary: #18181b;
  --primary-fg: #fafafa;
  --destructive: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --switch-off: #d4d4d8;
  --scroll: #d4d4d8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .25);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #ffffff; --fg: #09090b; --card: #ffffff; --muted: #f4f4f5; --muted-fg: #71717a; --border: #e4e4e7; --input: #d4d4d8;
    --ring: #71717a; --accent: #f4f4f5; --primary: #18181b; --primary-fg: #fafafa; --destructive: #dc2626; --ok: #16a34a; --warn: #d97706;
    --switch-off: #d4d4d8; --scroll: #d4d4d8; --shadow: 0 1px 2px rgba(0, 0, 0, .06); --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .25); color-scheme: light;
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
h1, h2, h3, h4, p { margin: 0; }
.muted { color: var(--muted-fg); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ic { flex: none; display: block; }
i[data-icon], i.i { display: inline-flex; font-style: normal; }
::selection { background: color-mix(in oklab, var(--fg) 22%, transparent); }

/* ---------- boutons ---------- */
button {
  font: 500 13px/1 var(--font);
  color: var(--fg);
  height: 36px;
  padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--input);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, transform .12s var(--ease), opacity .15s;
}
button:hover { background: var(--accent); }
button:active { transform: scale(.97); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .row:focus-visible, .vcard:focus-visible {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 35%, transparent);
}
button:disabled { opacity: .5; pointer-events: none; }
button.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); box-shadow: none; }
button.primary:hover { background: color-mix(in oklab, var(--primary) 88%, var(--bg)); }
button.ghost { border-color: transparent; background: transparent; box-shadow: none; }
button.ghost:hover { background: var(--accent); }
button.icon { width: 36px; padding: 0; }
button.danger { color: var(--destructive); }
button.danger:hover { background: color-mix(in oklab, var(--destructive) 12%, transparent); border-color: color-mix(in oklab, var(--destructive) 40%, var(--input)); }
button.destructive { background: var(--destructive); border-color: var(--destructive); color: #fff; box-shadow: none; }
button.destructive:hover { background: color-mix(in oklab, var(--destructive) 88%, #000); }
button.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-group { display: inline-flex; }
.btn-group button { border-radius: 0; margin-left: -1px; }
.btn-group button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group button:last-child { border-radius: 0 8px 8px 0; }
.btn-group button.primary { z-index: 1; }

/* infobulles */
@media (hover: hover) {
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translate(-50%, 2px);
    padding: 5px 9px; border-radius: 6px; background: var(--fg); color: var(--bg);
    font: 500 12px/1.2 var(--font); white-space: nowrap; pointer-events: none; z-index: 400;
    opacity: 0; transition: opacity .12s, transform .15s var(--ease);
  }
  [data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .4s; }
  #lastBar [data-tip]::after { top: auto; bottom: calc(100% + 8px); }
  #topbar > [data-tip]:last-child::after { left: auto; right: 0; transform: translate(0, 2px); }
  #topbar > [data-tip]:last-child:hover::after { transform: none; }
}

/* ---------- champs ---------- */
select, input:not([type=checkbox]):not([type=range]):not([type=color]), textarea {
  font: 400 13px/1.2 var(--font); color: var(--fg);
  height: 36px; padding: 0 12px;
  background-color: transparent; border: 1px solid var(--input); border-radius: 8px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; width: 100%; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-fg); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; max-width: 210px; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:hover { background-color: var(--accent); }
option, optgroup { background: var(--card); color: var(--fg); }
input[type=number] { width: 92px; }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--input); border-radius: 8px; background: transparent; cursor: pointer; }

/* switch (toutes les cases a cocher) */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 36px; height: 20px; margin: 0; padding: 0; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--switch-off); position: relative; transition: background-color .22s var(--ease);
}
input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .22s var(--ease), background-color .22s;
}
input[type=checkbox]:checked { background: var(--primary); }
input[type=checkbox]:checked::after { transform: translateX(16px); background: var(--primary-fg); }
input[type=checkbox]:active::after { width: 20px; }
input[type=checkbox]:checked:active::after { transform: translateX(12px); }

input[type=range] { appearance: none; -webkit-appearance: none; width: 160px; height: 20px; background: transparent; padding: 0; border: 0; box-shadow: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--switch-off); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--switch-off); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--bg); border: 2px solid var(--primary); transition: transform .15s var(--ease); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--primary); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 11px; font-weight: 500; color: var(--muted-fg); }
.badge:empty { display: none; }
kbd { font: 500 11px/1 var(--mono); height: 20px; padding: 0 6px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--muted); color: var(--fg); }

/* ---------- barre du haut ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; margin-right: 4px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: var(--primary-fg); display: grid; place-items: center; }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.selects { display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.rec-toggle { gap: 8px; }
.rec-toggle .dot, #recBadge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-fg); transition: background-color .2s; }
.rec-toggle[aria-pressed="true"] { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 50%, var(--input)); background: color-mix(in oklab, var(--destructive) 10%, transparent); }
.rec-toggle[aria-pressed="true"] .dot { background: var(--destructive); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--destructive) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
.avatar { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--muted); border-color: var(--border); font-weight: 600; font-size: 13px; text-transform: uppercase; margin-left: 4px; box-shadow: none; }

/* ---------- mise en page ---------- */
#layout {
  flex: 1; min-height: 0; width: 100%; max-width: 1680px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr) minmax(270px, 340px);
  grid-template-areas: "left center right"; gap: 16px; padding: 16px;
}
#panelLeft { grid-area: left; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
#panelCenter { grid-area: center; display: flex; flex-direction: column; min-height: 0; min-width: 0; container-type: inline-size; }
#panelRight { grid-area: right; display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow: auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); animation: rise .45s var(--ease) both; }
#panelLeft .card:nth-child(2), #panelRight .card:nth-child(2) { animation-delay: .06s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }

/* ---------- scramble ---------- */
#scrambleBox { display: flex; gap: 8px; align-items: flex-start; justify-content: center; padding: 4px 0 0; }
#scrambleText {
  flex: 1; text-align: center; font: 500 clamp(15px, 1.6vw, 21px)/1.65 var(--mono);
  white-space: pre-line; word-spacing: .3em; max-height: 28vh; overflow: auto; padding: 0 4px;
  animation: swap .28s var(--ease);
}
@keyframes swap { from { opacity: 0; transform: translateY(4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
#scrambleText.long { font-size: clamp(12px, 1.15vw, 15px); }
#scrambleText.loading { color: var(--muted-fg); font-family: var(--font); font-weight: 400; animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.scr-nav { display: flex; flex-direction: column; gap: 2px; }

/* ---------- chrono ---------- */
#timerBox {
  flex: 1; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; user-select: none; -webkit-user-select: none; touch-action: manipulation; cursor: pointer; border-radius: 16px;
}
#timerDisplay {
  font: 500 calc(clamp(60px, 20cqw, 200px) * var(--tscale, 1))/1 var(--mono);
  font-variant-numeric: tabular-nums; letter-spacing: -.05em;
  transition: color .18s var(--ease), transform .25s var(--ease);
}
#timerBox[data-len="l"] #timerDisplay { font-size: calc(clamp(48px, 16cqw, 165px) * var(--tscale, 1)); }
#timerBox[data-len="xl"] #timerDisplay { font-size: calc(clamp(40px, 11.5cqw, 120px) * var(--tscale, 1)); }
#timerBox.state-holding #timerDisplay { color: var(--destructive); }
#timerBox.state-ready #timerDisplay { color: var(--ok); transform: scale(1.03); }
#timerBox.state-inspecting #timerDisplay { color: var(--warn); }
#timerBox.pop #timerDisplay { animation: pop .38s var(--ease); }
#timerBox.record #timerDisplay { animation: pop .38s var(--ease), flash 1.4s var(--ease); }
@keyframes pop { 0% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes flash { 0%, 40% { color: var(--ok); } 100% { color: var(--fg); } }
#timerSub { color: var(--muted-fg); min-height: 1.6em; margin-top: 14px; font-size: 14px; display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; }
#timerSub .chip-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 500; animation: rise .4s var(--ease); }
#typeInput { width: min(520px, 90%); height: 48px; font-size: 18px; text-align: center; margin-top: 14px; border-radius: 10px; }
#recBadge { position: absolute; top: 10px; right: 12px; display: flex; align-items: center; gap: 7px; color: var(--destructive); font: 600 12px/1 var(--font); animation: rise .3s var(--ease); }
#recBadge .dot { background: var(--destructive); animation: pulse 1.4s var(--ease) infinite; }
#smStatus { margin-top: 8px; padding: 0 12px; text-align: center; font-size: 13px; color: var(--muted-fg); display: flex; align-items: center; gap: 8px; }
#smStatus::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-fg); flex: none; }
#smStatus[data-ok="1"] { color: var(--ok); }
#smStatus[data-ok="1"]::before { background: var(--ok); }
#lastBar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 4px 0 12px; animation: rise .3s var(--ease); }
#uploadStatus { text-align: center; color: var(--muted-fg); font-size: 12px; padding-bottom: 8px; }
#panelLeft, #panelRight, #topbar, #scrambleBox, #lastBar { transition: opacity .3s var(--ease); }
body.solving #panelLeft, body.solving #panelRight, body.solving #topbar, body.solving #scrambleBox, body.solving #lastBar { opacity: .06; pointer-events: none; }

/* ---------- stats ---------- */
#statsBox table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#statsBox th { font-size: 12px; font-weight: 500; color: var(--muted-fg); text-align: right; padding: 0 0 8px; }
#statsBox th:first-child { text-align: left; }
#statsBox td { padding: 5px 0; text-align: right; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 13px; }
#statsBox td:first-child { text-align: left; color: var(--muted-fg); font-family: var(--font); }
#statsBox td.cell { cursor: pointer; transition: color .15s; }
#statsBox td.cell:hover { color: var(--chart-1); }
#statsBox td.best { font-weight: 600; }
.sum-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted-fg); font-size: 12px; }
.sum-line b { color: var(--fg); font-weight: 600; font-family: var(--mono); }
.goal-bar { height: 6px; border-radius: 99px; background: var(--muted); margin-top: 8px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .6s var(--ease); }

/* ---------- liste ---------- */
#timesBox { flex: 1; min-height: 180px; display: flex; flex-direction: column; }
#timesList { flex: 1; overflow: auto; font-variant-numeric: tabular-nums; margin: 0 -8px; padding: 0 8px; }
.row { display: grid; grid-template-columns: 36px 1fr 62px 62px 20px; gap: 4px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; align-items: center; transition: background-color .12s; }
.row:hover { background: var(--accent); }
.row.fresh { animation: row-in .45s var(--ease); }
@keyframes row-in { from { opacity: 0; transform: translateY(-8px); background: var(--accent); } to { opacity: 1; transform: none; } }
.row .n { color: var(--muted-fg); font-size: 12px; font-family: var(--mono); }
.row .t { font: 600 13px var(--mono); }
.row .a { color: var(--muted-fg); text-align: right; font: 400 12px var(--mono); }
.row .t.pb { color: var(--ok); }
.row .t.dnf { color: var(--destructive); }
.row .t.p2 { color: var(--warn); }
.row .t .ic { display: inline; vertical-align: -2px; margin-left: 4px; color: var(--muted-fg); }
.row .vid { color: var(--muted-fg); display: grid; place-items: center; transition: color .15s; }
.row:hover .vid { color: var(--fg); }
.row.head { position: sticky; top: 0; z-index: 1; background: var(--card); color: var(--muted-fg); font-size: 12px; font-weight: 500; cursor: default; }
.row.head:hover { background: var(--card); }
.row.head span { font: 500 12px var(--font); }

/* ---------- droite ---------- */
#scrImg { display: flex; justify-content: center; }
#scrImg svg { width: 100%; max-height: 220px; animation: swap .3s var(--ease); }
#scrImg .none { color: var(--muted-fg); padding: 24px 0; text-align: center; font-size: 13px; }
.tabs { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 3px; margin-bottom: 12px; background: var(--muted); border-radius: 9px; }
.tabs button { height: 28px; padding: 0 8px; border: 0; background: transparent; box-shadow: none; color: var(--muted-fg); font-size: 12.5px; position: relative; z-index: 1; border-radius: 6px; }
.tabs button:hover { background: transparent; color: var(--fg); }
.tabs button.on { color: var(--fg); }
.tab-ind { position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; background: var(--bg); border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 0 0 1px var(--border); transition: transform .3s var(--ease), width .3s var(--ease); }
#chart { width: 100%; height: 190px; display: block; }

/* ---------- dialogues ---------- */
dialog {
  background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 14px; padding: 0;
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px) scale(.97);
  transition: opacity .2s var(--ease), transform .25s var(--ease), overlay .25s allow-discrete, display .25s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(10px) scale(.97); } }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0); backdrop-filter: blur(0); transition: background-color .25s var(--ease), backdrop-filter .25s var(--ease), overlay .25s allow-discrete, display .25s allow-discrete; }
dialog[open]::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
@starting-style { dialog[open]::backdrop { background: rgba(0, 0, 0, 0); backdrop-filter: blur(0); } }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 0; position: sticky; top: 0; background: var(--card); z-index: 2; padding-bottom: 12px; }
.dlg-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.dlg-head p { color: var(--muted-fg); font-size: 13px; margin-top: 2px; }
.dlg-head button { margin: -4px -8px 0 0; }
.dlg-body { padding: 4px 24px 24px; overflow: auto; max-height: calc(100vh - 130px); }
.dlg-body h4 { margin: 24px 0 6px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; padding-top: 16px; border-top: 1px solid var(--border); }
.dlg-body h4:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.field label { flex: 1; font-weight: 500; font-size: 13px; }
.field small { display: block; color: var(--muted-fg); font-weight: 400; font-size: 12px; margin-top: 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.palette { display: flex; gap: 6px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .35); transition: transform .15s var(--ease), box-shadow .15s; }
.swatch:hover { transform: scale(1.12); background: inherit; }
.swatch.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--fg); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--muted-fg); }
.kv dd { margin: 0; word-break: break-word; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 99px; background: transparent; border: 1px solid var(--border); font-size: 12px; font-weight: 500; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.chip:hover { background: var(--accent); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.pen-btns { display: inline-flex; }
.pen-btns button { border-radius: 0; margin-left: -1px; }
.pen-btns button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.pen-btns button:last-child { border-radius: 0 8px 8px 0; }
.pen-btns button.on { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); z-index: 1; }
.scr-line { font: 400 12.5px/1.6 var(--mono); background: var(--muted); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.avg-list { list-style: none; padding: 0; margin: 12px 0; }
.avg-list li { display: flex; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; font-variant-numeric: tabular-nums; transition: background-color .12s; }
.avg-list li:hover { background: var(--accent); }
.avg-list li.dropped span.t { color: var(--muted-fg); text-decoration: line-through; }
.avg-list .sc { color: var(--muted-fg); font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sess-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; transition: border-color .2s; }
.sess-row.cur { border-color: var(--fg); }
.sess-row .nm { flex: 1; font-weight: 500; }
.bar { height: 8px; border-radius: 99px; background: var(--muted); overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; align-items: center; font-size: 13px; }
.help-grid > div:nth-child(odd) { display: flex; gap: 4px; flex-wrap: wrap; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users th { text-align: left; color: var(--muted-fg); font-weight: 500; font-size: 12px; padding: 4px 8px; }
table.users td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
table.users td.act { text-align: right; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 6px; background: var(--primary); color: var(--primary-fg); font-size: 11px; font-weight: 600; margin-left: 8px; }

/* ---------- video ---------- */
.player-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.player-wrap video { width: 100%; max-height: 60vh; display: block; background: #000; }
.player-wrap.mirror video { transform: scaleX(-1); }
.player-hud { position: absolute; left: 14px; top: 12px; font: 600 28px/1 var(--mono); color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, .8); pointer-events: none; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.player-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.timeline { position: relative; height: 8px; margin: 14px 0 4px; background: var(--muted); border-radius: 99px; cursor: pointer; }
.timeline::before { content: ""; position: absolute; inset: -8px 0; }
.timeline .range { position: absolute; top: 0; bottom: 0; background: color-mix(in oklab, var(--fg) 28%, transparent); border-radius: 99px; }
.timeline .head { position: absolute; top: -4px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--bg); border: 2px solid var(--primary); box-shadow: var(--shadow); }
.timeline .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--warn); border-radius: 2px; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.vcard { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; position: relative; transition: transform .25s var(--ease), border-color .2s, box-shadow .25s var(--ease); animation: rise .4s var(--ease) both; }
.vcard:hover { transform: translateY(-3px); border-color: var(--input); box-shadow: var(--shadow-lg); }
.vcard video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; pointer-events: none; }
.vcard .meta { padding: 8px 12px; display: flex; justify-content: space-between; align-items: baseline; }
.vcard .meta b { font: 600 16px var(--mono); font-variant-numeric: tabular-nums; }
.vcard .badge { position: absolute; top: 8px; left: 8px; background: var(--ok); color: #052e16; border: 0; font-weight: 600; }
.vcard .badge.dnf { background: var(--destructive); color: #fff; }

/* ---------- toasts ---------- */
#toaster { position: fixed; right: 16px; bottom: 16px; z-index: 500; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: min(360px, calc(100vw - 32px)); padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; animation: toast-in .35s var(--ease); }
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: var(--ok); }
.toast.error .ic { color: var(--destructive); }
.toast.info .ic { color: var(--muted-fg); }
.toast.out { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.96); } }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 450; overflow: hidden; }
#confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: .95; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

#camPreview { position: fixed; right: 16px; bottom: 16px; width: 200px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 60; background: #000; animation: rise .4s var(--ease); }
#camPreview.mirror { transform: scaleX(-1); }

/* ---------- connexion ---------- */
#authView { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#authView::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 22px 22px; mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); opacity: .7; pointer-events: none; }
.auth-card { position: relative; width: min(390px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); animation: rise .5s var(--ease); }
.auth-card .logo { width: 36px; height: 36px; border-radius: 10px; margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
.auth-card p.sub { margin: 4px 0 20px; color: var(--muted-fg); font-size: 14px; }
.auth-card label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 500; }
.auth-card input { width: 100%; height: 40px; font-size: 14px; }
.auth-card .err { color: var(--destructive); min-height: 1.4em; margin-top: 12px; font-size: 13px; font-weight: 500; }
.auth-card button.primary { width: 100%; height: 40px; margin-top: 8px; }
.auth-card .switch { text-align: center; margin-top: 18px; color: var(--muted-fg); font-size: 13px; }
.auth-card .switch a { color: var(--fg); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }

/* mode concentration */
body.focus #topbar, body.focus #panelLeft, body.focus #panelRight { display: none; }
body.focus #layout { grid-template-columns: 1fr; grid-template-areas: "center"; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow: auto; }
  #layout { flex: none; grid-template-columns: 1fr; grid-template-areas: "center" "left" "right"; }
  #panelLeft, #panelRight { overflow: visible; }
  #timesList { max-height: 320px; }
  #timerBox { min-height: 42vh; }
  #camPreview { width: 120px; bottom: 12px; right: 12px; }
}
@media (max-width: 700px) {
  .hide-sm, .brand-name { display: none; }
  #topbar { flex-wrap: wrap; padding: 8px 10px; }
  .selects { order: 3; width: 100%; }
  .selects select { flex: 1; max-width: none; min-width: 0; }
  .row { grid-template-columns: 30px 1fr 54px 54px 18px; }
  .dlg-head { padding: 16px 16px 0; }
  .dlg-body { padding: 4px 16px 18px; }
  #lastBar button span { display: none; }
  #toaster { left: 12px; right: 12px; bottom: 12px; }
  .toast { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; } }
