/* Sifflet — thème sombre unique : lisible en salle comme dehors, et le flash ressort mieux. */
:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --accent: #334155;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; }

[hidden] { display: none !important; }

/* ---- en-tête ---- */
.top {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto; padding: 12px 16px;
}
.brand { font-weight: 800; letter-spacing: .02em; }
.badge { background: var(--warn); color: #111; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.conn { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
.conn.ok .dot { background: var(--ok); }

/* ---- affichage du timer ---- */
.display {
  text-align: center;
  border-radius: 20px;
  padding: 20px 16px 18px;
  background: color-mix(in srgb, var(--accent) 30%, var(--card));
  border: 2px solid var(--accent);
  transition: background .3s, border-color .3s;
}
.status { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.phase { font-size: clamp(26px, 8vw, 40px); font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; }
.clock {
  font-size: clamp(72px, 26vw, 150px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 8px 0;
}
.meta { font-size: 18px; }
.next { font-size: 15px; color: var(--muted); min-height: 1.4em; }
.progress { height: 8px; background: rgba(255, 255, 255, .12); border-radius: 99px; margin: 14px 0 8px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--text); }

body[data-state="paused"] .clock { opacity: .55; }
body[data-state="paused"] .status,
body[data-state="countdown"] .status { color: var(--warn); font-weight: 700; }
body[data-state="countdown"] .clock { color: var(--warn); }

/* ---- cartes ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 16px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h2 small, .small { font-size: 13px; font-weight: 400; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.between { justify-content: space-between; }
.pill { font-size: 13px; padding: 2px 8px; border-radius: 99px; background: #3f1d1d; color: #fca5a5; margin-left: 6px; }
.pill.ok { background: #143321; color: #86efac; }
.pill.warn { background: #3b2a0b; color: #fcd34d; }

/* ---- boutons ---- */
.btn {
  font: inherit; color: var(--text); background: #262b36; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn:hover:not(:disabled) { background: #303644; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: #2563eb; border-color: #2563eb; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #1d4ed8; }
.btn.big { font-size: 20px; padding: 14px 20px; min-height: 60px; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }

.transport { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin: 14px 0 6px; }

/* ---- éditeur de programme ---- */
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0 0; padding: 8px 12px 14px; min-width: 0; }
fieldset:disabled { opacity: .55; }
legend { font-weight: 700; padding: 0 6px; }
.timers { padding-left: 1.4em; margin: 8px 0; }
.timers li { margin: 8px 0; }
.timers li::marker { color: var(--muted); }
.timers li { display: list-item; }
.timers li > * { vertical-align: middle; }
.timers .label { width: 100%; max-width: 220px; margin-right: 6px; }
.dur { display: inline-flex; align-items: center; gap: 4px; margin: 4px 6px 4px 0; }
.dur span { color: var(--muted); font-size: 14px; }
input[type="text"], input[type="number"] {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; min-height: 40px;
}
input[type="number"] { width: 4.2em; text-align: right; }
.cycles input { width: 5em; }
details { margin: 4px 0 14px; }
summary { cursor: pointer; color: var(--muted); }
.instants { columns: 2; font-size: 14px; font-variant-numeric: tabular-nums; margin: 8px 0 0; padding-left: 1.6em; }

/* ---- réglages ---- */
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: #2563eb; }

/* ---- code PIN ---- */
.pin {
  font-size: 28px; letter-spacing: .3em; text-align: center; width: 7.5em;
  margin: 6px auto 0; display: block; font-variant-numeric: tabular-nums;
}
.pin.small { font-size: 20px; width: 6.5em; margin: 0; display: inline-block; }
.pin-msg { color: #fca5a5; min-height: 1.4em; }

/* ---- bloc « Application » du coach (repliable) ---- */
.app-box > summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  list-style: none; cursor: pointer; min-height: 44px; padding-right: 28px; position: relative;
}
.app-box > summary::-webkit-details-marker { display: none; }
.app-box > summary::after {
  content: ""; position: absolute; right: 6px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); transition: transform .2s;
}
.app-box[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
.app-title { font-weight: 700; }
.app-box .pill { margin-left: 0; }
@media (max-width: 420px) {           /* téléphone : la pastille « en marche » suffit, tout tient sur une ligne */
  .app-box.on .app-title { display: none; }
}
.pin-show { font-size: 15px; }
.pin-show strong { color: var(--warn); letter-spacing: .12em; font-size: 20px; font-variant-numeric: tabular-nums; }
.devices { font-size: 14px; }
.app-start { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.app-start label { font-weight: 700; }
.app-start .pin.small { width: 100%; min-width: 0; }
.app-start p { grid-column: 1 / -1; margin: 0; }
.app-running { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }

/* ---- surcouches ---- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 16px;
  background: rgba(15, 17, 21, .96);
}
.overlay-box { max-width: 420px; text-align: center; }
.overlay-box h1 { margin: 10px 0; }
.overlay-box p { color: var(--muted); }

#flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .08s; }
#flash.on { opacity: .9; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  background: #e2e8f0; color: #0f172a; padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

@media (prefers-reduced-motion: reduce) {
  .display, #flash { transition: none; }
}
