:root { --bg: #0b0d10; --fg: #e6e9ee; --mut: #9aa4b2; --gold: #ffd54f; --line: #222831; color-scheme: dark }
* { box-sizing: border-box }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 Inter, system-ui, -apple-system, sans-serif; overscroll-behavior: none }
body { display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line) }
.brand { color: var(--gold); font-weight: 700; letter-spacing: .04em }
.sym { color: var(--mut) } .px { font-variant-numeric: tabular-nums; font-weight: 600 }
nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto }
nav button { background: none; border: 1px solid transparent; color: var(--mut); padding: 6px 9px; border-radius: 6px; font: inherit; cursor: pointer }
nav button.on { color: var(--fg); border-color: var(--line); background: #151920 }
#legend { padding: 4px 12px; color: var(--mut); font-size: 12px; font-variant-numeric: tabular-nums; min-height: 22px }
#legend b { color: var(--fg); font-weight: 500 }
main { flex: 1; min-height: 0 }
footer { padding: 2px 12px 4px; font-size: 10px; color: #5c6570 } footer a { color: inherit }
.login { align-items: center; justify-content: center }
.login form { display: flex; flex-direction: column; gap: 12px; width: min(320px, 90vw); text-align: center; align-items: center }
.login h1 { margin: 0; color: var(--gold); letter-spacing: .06em }
.login input, .login button { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: #151920; color: var(--fg); font: inherit }
.login button { background: var(--gold); color: #111; border: 0; font-weight: 600 }
#err { color: #ff8a80; margin: 0 }

.indbtn { background: #151920; border: 1px solid var(--line); color: var(--gold); padding: 6px 10px; border-radius: 6px; font: italic 600 14px/1 Georgia, serif; cursor: pointer }
#indPanel { position: fixed; z-index: 20; top: calc(env(safe-area-inset-top, 0px) + 52px); right: max(8px, env(safe-area-inset-right, 0px)); width: min(380px, calc(100vw - 16px));
  max-height: calc(100dvh - 80px - env(safe-area-inset-top, 0px)); overflow: auto; background: #11151b; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; box-shadow: 0 8px 30px #0008 }
#indPanel .ph { display: flex; justify-content: space-between; align-items: center; padding: 4px 0 8px }
#indPanel .x { background: none; border: 0; color: var(--mut); font-size: 16px; cursor: pointer; padding: 4px 8px }
.ind { border-top: 1px solid var(--line); padding: 8px 0 }
.ind summary { cursor: pointer; list-style: none } .ind summary::-webkit-details-marker { display: none }
.ind summary span { color: var(--gold); font-weight: 600 } .ind summary small { color: var(--mut) }
.ind h4 { margin: 12px 0 4px; font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .06em }
.fld { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px }
.fld small { color: #5c6570 }
.fld input[type=number], .fld select { width: 84px; background: #151920; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: inherit; font-size: 16px }
.fld input[type=checkbox] { order: 2; width: 20px; height: 20px; accent-color: var(--gold) }
.reset { margin-top: 10px; background: none; border: 1px solid var(--line); color: var(--mut); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer }
.err { color: #ff8a80; font-size: 12px; white-space: pre-wrap }
.ind summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap } .ind summary input { width: 20px; height: 20px; accent-color: var(--gold) }
.gear { margin-left: auto; font-style: normal; font-size: 12px; color: var(--mut) }
#legend .atr { margin-left: 10px; color: var(--gold) } #legend .atr b { color: var(--gold) }
main { position: relative }
#tip { position: fixed; z-index: 30; pointer-events: none; background: #151920f2; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  font-size: 12px; line-height: 1.45; color: var(--fg); max-width: 260px; box-shadow: 0 4px 16px #0008; font-variant-numeric: tabular-nums }
#tip div { padding-left: 10px } #tip div + div { margin-top: 6px }
#tip .mut { color: #8892a0 } #tip .score { font-size: 12px; line-height: 1.5 }

/* téléphone (27/11) : retour au direct, UT au balayage, cibles au doigt */
#liveBtn { position: absolute; z-index: 5; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #151920e6; color: var(--gold);
  font: 600 18px/1 Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 0 2px 10px #0008 }
#toast { position: fixed; z-index: 40; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.9); padding: 10px 18px; border-radius: 10px; background: #151920ee;
  border: 1px solid var(--line); color: var(--gold); font-weight: 700; font-size: 20px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s }
#toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1) }
header, #legend { touch-action: pan-y; user-select: none; -webkit-user-select: none }
main { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none }
@media (pointer: coarse) {
  nav { flex-wrap: wrap; overflow: visible }
  nav button { padding: 8px 9px; min-height: 36px; min-width: 36px }
  .indbtn { min-height: 36px; padding: 8px 12px }
  #liveBtn { width: 44px; height: 44px; font-size: 22px }
}

/* fenêtre flottante du score P(TP) (27/11) : posée sur le graphique, déplaçable par sa barre, fermable */
#scoreBox { position: absolute; z-index: 6; left: 12px; top: 12px; width: min(380px, calc(100% - 90px)); height: 180px; display: flex; flex-direction: column;
  background: #0f1318f2; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px #000a; overflow: hidden }
#scoreBox[hidden] { display: none }
#scoreBox .sh { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 3px 10px; font-size: 11px; color: var(--mut); cursor: move;
  touch-action: none; user-select: none; -webkit-user-select: none; border-bottom: 1px solid var(--line) }
#scoreBox .x { background: none; border: 0; color: var(--mut); font-size: 13px; cursor: pointer; padding: 2px 8px }
#scoreBox .sb { flex: 1; min-height: 0 }
@media (pointer: coarse) { #scoreBox { height: 150px } #scoreBox .sh { padding: 6px 4px 6px 10px } #scoreBox .x { padding: 6px 10px } }

/* mode Entraînement (02/12) : bouton de l'en-tête et fenêtre flottante (question, réponse, révélation, score) */
.trainbtn { background: #151920; border: 1px solid var(--line); color: var(--mut); padding: 6px 10px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer }
.trainbtn.on { color: var(--gold); border-color: #ffd54f66 }
#trainBox { position: absolute; z-index: 7; left: 12px; top: 12px; width: min(330px, calc(100% - 24px)); background: #0f1318f2; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 24px #000a; font-size: 13px; font-variant-numeric: tabular-nums; max-height: calc(100% - 24px); overflow: auto }
#trainBox[hidden], #trainBox [hidden] { display: none !important }
#trainBox .sh { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 3px 10px; font-size: 11px; color: var(--gold); cursor: move;
  touch-action: none; user-select: none; -webkit-user-select: none; border-bottom: 1px solid var(--line) }
#trainBox .x { background: none; border: 0; color: var(--mut); font-size: 13px; cursor: pointer; padding: 2px 8px }
#trainBox .tb { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px }
#trainBox .mut { color: #8892a0 }
#trainBox .tcut { color: var(--mut); font-size: 12px } #trainBox .tcut b { color: var(--fg); font-weight: 600 }
#trainBox .trow { display: flex; gap: 6px; align-items: center }
#trainBox .trow span { color: var(--mut); font-size: 12px; margin-right: 2px }
#trainBox .trow button { flex: 1; background: #151920; border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 7px 6px; font: inherit; cursor: pointer }
#trainBox .trow button:hover:not(:disabled) { border-color: #3a4250 }
#trainBox .trow button:disabled { opacity: .45; cursor: default }
#trainBox .tdir button[data-a="1"].on { border-color: #26a69a; color: #26a69a } #trainBox .tdir button[data-a="-1"].on { border-color: #e040fb; color: #e040fb }
#trainBox .tconf button { flex: 0 0 40px }
#trainBox .tnext button { color: var(--gold) }
#trainBox .tres { border-left: 3px solid #8892a0; padding: 2px 0 2px 8px; line-height: 1.5 }
#trainBox .tres.ok { border-color: #26a69a } #trainBox .tres.ok > b { color: #26a69a }
#trainBox .tres.ko { border-color: #ff5252 } #trainBox .tres.ko > b { color: #ff8a80 }
#trainBox .tkeys { font-size: 11px; color: #5c6570 }
#trainBox .tset { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--mut); border-top: 1px solid var(--line); padding-top: 8px }
#trainBox .tset label { display: flex; align-items: center; gap: 6px }
#trainBox .tset input[type=number] { width: 52px; background: #151920; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; font: inherit }
#trainBox .tset input[type=checkbox] { accent-color: var(--gold) }
#trainBox .tscore { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px }
#trainBox .tsh { font-size: 11px; color: var(--mut) }
#trainBox .tl { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center }
#trainBox .tg b { font-weight: 600 }
#trainBox .dots { display: flex; gap: 3px } #trainBox .dots i { width: 8px; height: 8px; border-radius: 50%; background: #3a4250 }
#trainBox .dots i.ok { background: #26a69a } #trainBox .dots i.ko { background: #ff5252 }
@media (pointer: coarse) { .trainbtn { min-height: 36px } #trainBox .trow button { padding: 10px 6px } }

/* vue multi-graphiques (02/12) : 1, 2 côte à côte ou 4 (2 × 2) ; UT de chaque panneau en haut à gauche */
#panes { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); gap: 1px; background: var(--line); position: relative }
#panes.l2 { grid-template: minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr) }
#panes.l4 { grid-template: minmax(0, 1fr) minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr) }
#panes > main, #panes > .pane { min-width: 0; min-height: 0; position: relative; background: var(--bg) }
#panes > .pane { touch-action: none; user-select: none; -webkit-user-select: none }
@media (max-width: 760px) { #panes.l2 { grid-template: minmax(0, 1fr) minmax(0, 1fr) / minmax(0, 1fr) } }
.ptf { position: absolute; z-index: 5; left: 6px; top: 6px; background: #151920e6; color: var(--fg); border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 12px; padding: 2px 4px; cursor: pointer }
.ptf[hidden] { display: none }
#panes:not(.l1) > #trainBox { top: 40px }
#lay { margin-left: 0; gap: 2px }
#lay button { line-height: 0; padding: 5px 6px } #lay svg { display: block }
/* mesure à deux doigts (03/12) */
#mesure { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: visible }
#mesureLab { position: absolute; z-index: 6; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: #151920ee; border: 1px solid #2a313b;
  color: #d6dde6; font: 13px/1.45 Inter, system-ui, sans-serif; white-space: nowrap; font-variant-numeric: tabular-nums }
/* tableaux des indicateurs (03/12) : angle inférieur droit, comme les tables Pine en bottom_right */
.indTables { position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; gap: 6px; align-items: flex-end }
.indTables table { border-collapse: collapse; background: #12161ce6; border: 1px solid #2a313b; border-radius: 6px; font: 11px/1.3 Inter, system-ui, sans-serif;
  color: #c9d1db; font-variant-numeric: tabular-nums; overflow: hidden }
.indTables caption { caption-side: top; text-align: right; color: #7d8794; font-size: 10px; padding: 0 2px 2px }
.indTables th, .indTables td { padding: 3px 8px; text-align: left; white-space: nowrap }
.indTables th { color: #8b95a3; font-weight: 500; border-bottom: 1px solid #2a313b }
.indTables tr + tr td { border-top: 1px solid #1c2129 }
