/* KeyRead AI — тренерская тактическая доска.
   Тёмная тема — грифельная доска, светлая — маркерная. Оранжевый только у мяча, кольца, главной кнопки и указателя времени. */
:root {
  --bg: #101513; --panel: #181f1c; --panel2: #202925; --line: #2e3a35; --line2: #3c4a44;
  --text: #eceeea; --muted: #94a19b;
  --ball: #ff8b3d; --on-ball: #1a1206;
  --a: #f2efe4; --a-ink: #14181b; --b: #6ca6ff; --b-ink: #0b1220;
  --ideal: #4ade8c; --ideal-b: #a9cbff;
  --good: #4ade8c; --warn: #f0be48; --bad: #ff6b75; --on-score: #10160f;
  --board: #151c19; --court: #1c2622; --court-line: rgba(236, 238, 234, .7); --paint: rgba(255, 139, 61, .09);
  --edit: #f0be48; --edit-bg: #2a2412; --edit-line: #5e4c17;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --num: "DIN Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --ui: "PT Sans", "Helvetica Neue", system-ui, sans-serif;
  --r: 10px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #e8ebe9; --panel: #ffffff; --panel2: #f2f4f3; --line: #d2d8d5; --line2: #b9c2be;
  --text: #14181b; --muted: #5d696f;
  --ball: #f0641e; --on-ball: #14181b;
  --a: #14181b; --a-ink: #ffffff; --b: #2b62d9; --b-ink: #ffffff;
  --ideal: #0a8f5b; --ideal-b: #5b8cf0;
  --good: #0a8f5b; --warn: #b87400; --bad: #cf2a40; --on-score: #ffffff;
  --board: #eef1ef; --court: #ffffff; --court-line: rgba(20, 24, 27, .78); --paint: rgba(240, 100, 30, .09);
  --edit: #b87400; --edit-bg: #fff6df; --edit-line: #e7c873;
  --shadow: 0 10px 30px rgba(20, 30, 25, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--ui); }
body { min-height: 100dvh; }
.hidden { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, select, input, textarea, .btn { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ball); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.note { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
b { font-weight: 700; }

/* роли: элементы только для админа / только для менеджера */
body:not(.is-admin) .adminOnly { display: none !important; }
body.is-admin .managerOnly { display: none !important; }

/* ------------------------------------------------------------ кнопки и поля */
.btn, select, .icon {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.2;
}
.btn:hover, .icon:hover, select:hover { border-color: var(--line2); }
.btn.primary { background: var(--ball); border-color: var(--ball); color: var(--on-ball); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { padding: 12px 20px; font-size: 15px; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.on { background: var(--edit-bg); border-color: var(--edit); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon { padding: 6px; width: 34px; height: 34px; justify-content: center; }
.icon svg { width: 18px; height: 18px; fill: currentColor; }
select { padding-right: 8px; max-width: 220px; text-overflow: ellipsis; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; color: var(--text);
  font-size: 14px; width: 100%; max-width: none;
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--line2); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ball) 30%, transparent); }
.formErr { color: var(--bad); font-size: 13px; min-height: 0; }
.formErr:empty { display: none; }
.row2 { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------ шапка */
.top {
  height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 700 25px/1 var(--num); padding-top: 4px; letter-spacing: .3px; }
.brand span, .gateBrand span { color: var(--ball); }
.ballIcon { width: 22px; height: 22px; margin-top: -4px; fill: var(--ball); stroke: var(--on-ball); stroke-width: 1.1; }
.ballIcon path { fill: none; }
.episode { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; }
.badge { font-size: 12px; color: var(--muted); white-space: nowrap; }
.userMenu { position: relative; }
.userBtn { display: inline-flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; border-radius: 20px; padding: 3px 10px 3px 3px; cursor: pointer; }
.userBtn:hover { border-color: var(--line); }
.userBtn i { width: 28px; height: 28px; border-radius: 50%; background: var(--a); color: var(--a-ink); display: grid; place-items: center; font: 700 15px/1 var(--num); font-style: normal; padding-top: 3px; }
.userBtn span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: grid; }
.pop button { text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.pop button:hover { background: var(--panel2); }
.popHead { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.popHead small { color: var(--muted); }

.progress { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 30; width: min(520px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 8px; }
.progress span { font-size: 13px; color: var(--muted); }
.progress .bar { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ball); transition: width .25s; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13.5px; }

/* ------------------------------------------------------------ вход и смена пароля */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gateCard { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.gateCard h1 { font: 700 40px/1 var(--num); padding-top: 6px; }
.gateCard .note { margin: -6px 0 4px; }
.gateCard .btn.primary { justify-content: center; margin-top: 4px; }
.gateBrand { display: flex; align-items: center; gap: 8px; font: 700 22px/1 var(--num); padding-top: 3px; color: var(--muted); }
.gateBrand .ballIcon { width: 20px; height: 20px; }

/* ------------------------------------------------------------ рабочий экран разбора */
main {
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(300px, .8fr) minmax(380px, 1fr) 388px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "left center right" "tape tape right";
  height: calc(100dvh - 56px);
}
.left { grid-area: left; display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.center { grid-area: center; display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.tape { grid-area: tape; min-width: 0; }
.right { grid-area: right; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.videoWrap { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 16/9; flex-shrink: 0; }
video { width: 100%; height: 100%; display: block; object-fit: contain; }
.novideo { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: #aab4af;
  background: repeating-linear-gradient(45deg, #121816, #121816 10px, #161d1a 10px, #161d1a 20px); }

.eventNow { flex: 1; min-height: 0; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.eventNow h3 { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }

.courtHead { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.possName { font: 700 26px/1 var(--num); padding-top: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.possName small { display: block; font: 400 12.5px/1.4 var(--ui); color: var(--muted); margin-bottom: 2px; }
#court { width: 100%; flex: 1; min-height: 0; border-radius: 12px; display: block; cursor: pointer; background: var(--board); }
.editing #court { cursor: grab; }

.layers { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.layer { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--muted); user-select: none; }
.layer input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.layer:has(input:checked) { color: var(--text); border-color: var(--line2); background: var(--panel2); }
.layer:has(input:focus-visible) { outline: 2px solid var(--ball); outline-offset: 2px; }
.sw { width: 18px; height: 0; border-top: 2.5px solid var(--muted); display: inline-block; }
.layer:has(input:checked) .sw.trail { border-color: var(--text); }
.layer:has(input:checked) .sw.ideal { border-top-style: dashed; border-color: var(--ideal); }
.layer:has(input:checked) .sw.idealb { border-top-style: dashed; border-color: var(--ideal-b); }
.layer:has(input:checked) .sw.opts { border-color: var(--bad); }
.sw.ideal, .sw.idealb { border-top-style: dashed; }
.keys { display: inline-flex; gap: 12px; margin-left: auto; color: var(--muted); flex-wrap: wrap; }
.keys span { display: inline-flex; align-items: center; gap: 5px; }
.k { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.k.a { background: var(--a); box-shadow: 0 0 0 1px var(--line2); } .k.b { background: var(--b); }
.k.ball { background: var(--ball); } .k.ghost { border: 1.5px dashed var(--muted); }

#warn { background: var(--edit-bg); border: 1px solid var(--edit-line); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; display: grid; gap: 4px; }
#warn .btn { margin-left: 6px; }

.editbar { background: var(--edit-bg); border: 1px solid var(--edit-line); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; font-size: 12.5px; }
.editbar .edrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.editbar button { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; cursor: pointer; font-size: 12.5px; }
.editbar button:hover { border-color: var(--edit); }
.editbar button.primary { background: var(--ball); color: var(--on-ball); border-color: var(--ball); font-weight: 700; margin-left: auto; }
.editbar input { width: 58px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; color: var(--text); }

/* лента времени: транспорт + плёнка кадров с решениями */
.tape { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: stretch; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.transport { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.keysRow { display: flex; gap: 6px; align-items: center; }
.playBtn { width: 44px; height: 38px; background: var(--text); color: var(--bg); border-color: var(--text); }
.playBtn:hover { border-color: var(--text); filter: brightness(1.1); }
.playBtn .iPause, .playBtn.playing .iPlay { display: none; }
.playBtn.playing .iPause { display: block; }
#speed { padding: 6px 8px; }
.clock { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clock b { font: 700 22px/1 var(--num); color: var(--text); padding-top: 3px; display: inline-block; }
.clock span { display: block; }

.timeline { --lab: 20px; --strip: 52px; --lane: 18px; position: relative; height: calc(var(--lab) + var(--strip) + var(--lane)); cursor: pointer; touch-action: none; user-select: none; min-width: 0; }
.timeline.nothumbs { --strip: 0px; }
.timeline .poss { position: absolute; left: 0; right: 0; top: 0; height: var(--lab); display: flex; }
.timeline .poss div { border-left: 2px solid var(--line2); padding: 0 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: var(--lab); }
.timeline .strip { position: absolute; left: 0; right: 0; top: var(--lab); height: var(--strip); display: flex; border-radius: 6px; overflow: hidden; background: #000; pointer-events: none; }
.timeline .strip img { flex: 1; min-width: 0; height: 100%; object-fit: cover; opacity: .82; }
.timeline .marks { position: absolute; left: 0; right: 0; bottom: 0; height: var(--lane); pointer-events: none; }
.timeline .marks i { position: absolute; bottom: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; border: 2px solid var(--panel); }
.timeline .marks i::before { content: ""; position: absolute; left: 3px; bottom: 8px; width: 1.5px; height: calc(var(--strip) * .5); background: currentColor; opacity: .55; }
.timeline .marks i.good { background: var(--good); color: var(--good); }
.timeline .marks i.warn { background: var(--warn); color: var(--warn); }
.timeline .marks i.bad { background: var(--bad); color: var(--bad); }
.timeline .marks i.to { background: var(--muted); color: var(--muted); border-radius: 2px; }
.timeline .head { position: absolute; top: calc(var(--lab) - 4px); bottom: 0; width: 2px; margin-left: -1px; background: var(--ball); pointer-events: none; }
.timeline .head::before { content: ""; position: absolute; top: -5px; left: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--ball); }

/* правая панель */
.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tabs button { flex: 1; background: none; border: 0; padding: 12px 4px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); font-weight: 700; }
.tab { overflow: auto; padding: 12px; flex: 1; }
.tab h3, .group { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 2px 8px; }
.tab > .group:first-child, .tab > h3:first-child { margin-top: 2px; }

.pcard { border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.pcard:hover { border-color: var(--line2); }
.pcard.sel { border-color: var(--text); background: var(--panel); cursor: default; }
.row1 { display: flex; align-items: center; gap: 10px; }
.chip { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 700 18px/1 var(--num); padding-top: 3px; flex-shrink: 0; }
.chip.A { background: var(--a); color: var(--a-ink); } .chip.B { background: var(--b); color: var(--b-ink); }
.pname { flex: 1; min-width: 0; }
.pname small { display: block; color: var(--muted); font-size: 12px; }
.score { font: 700 30px/1 var(--num); padding-top: 4px; font-variant-numeric: tabular-nums; }
.score.good { color: var(--good); } .score.warn { color: var(--warn); } .score.bad { color: var(--bad); }
.score.none { font: 400 11.5px/1.2 var(--ui); color: var(--muted); text-align: right; padding: 0; }
.meter { height: 3px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; }
.meter i.good { background: var(--good); } .meter i.warn { background: var(--warn); } .meter i.bad { background: var(--bad); }
.detail { display: none; margin-top: 10px; }
.pcard.sel .detail { display: block; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.metrics div { display: flex; justify-content: space-between; gap: 6px; }
.metrics b { color: var(--text); font-variant-numeric: tabular-nums; }
.cm { border-left: 3px solid var(--line2); padding: 6px 10px; margin: 8px 0; font-size: 13px; background: var(--panel2); border-radius: 0 8px 8px 0; }
.cm.good { border-color: var(--good); } .cm.warn { border-color: var(--warn); } .cm.bad { border-color: var(--bad); }
.cm p { margin: 4px 0 0; }
.cm .t { color: var(--muted); font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: underline dotted; font-size: 12px; }
.llm { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; white-space: pre-wrap; }
.llm b { display: block; margin-bottom: 4px; }

.ev { border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font-size: 13px; }
.ev:hover { border-color: var(--line2); }
.h { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.sc { min-width: 32px; text-align: center; padding: 3px 6px 0; border-radius: 6px; font: 700 17px/1.2 var(--num); color: var(--on-score); }
.sc.good { background: var(--good); } .sc.warn { background: var(--warn); } .sc.bad { background: var(--bad); }
.h .tt { color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; }
.opts { margin-top: 8px; display: grid; gap: 4px; }
.opt { display: grid; grid-template-columns: 88px 1fr 34px 62px; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.opt .track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.opt .track i { display: block; height: 100%; background: var(--muted); }
.opt.best .track i { background: var(--ideal); }
.opt.chosen { color: var(--text); }
.opt.chosen.bad .track i { background: var(--bad); } .opt.chosen.warn .track i { background: var(--warn); } .opt.chosen.good .track i { background: var(--good); }
.opt .val { font-variant-numeric: tabular-nums; text-align: right; }
.opt .tag { font-size: 11.5px; }

.pat { border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); padding: 12px; margin-bottom: 10px; cursor: pointer; }
.pat .h b { flex: 1; }
.comp { display: grid; grid-template-columns: 120px 1fr 34px; gap: 8px; align-items: center; font-size: 12.5px; margin: 5px 0; color: var(--muted); }
.comp .meter { margin: 0; height: 5px; }
.comp span:last-child { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; margin-bottom: 6px; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.duo div { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.duo small { color: var(--muted); display: block; }
.duo .score { font-size: 36px; }

/* ------------------------------------------------------------ калибровка */
.calib { display: grid; grid-template-columns: 1fr 340px; gap: 12px; padding: 12px; height: calc(100dvh - 56px); }
.calibMain { background: #000; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 0; }
#calibCanvas { max-width: 100%; max-height: 100%; cursor: crosshair; }
.calibSide { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.calibSide h2 { font: 700 28px/1 var(--num); padding-top: 4px; }
#calibMini { width: 100%; aspect-ratio: 15/14; background: var(--board); border-radius: 8px; flex-shrink: 0; }
.kpList { display: grid; gap: 4px; }
.kp { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); cursor: pointer; font-size: 12.5px; }
.kp:hover { border-color: var(--line2); }
.kp.on { border-color: var(--ball); background: color-mix(in srgb, var(--ball) 10%, transparent); }
.kp .st { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line2); flex-shrink: 0; display: grid; place-items: center; font: 700 12px/1 var(--num); padding-top: 2px; color: var(--muted); }
.kp.set .st { background: var(--ideal); border-color: var(--ideal); color: var(--on-score); }
.kp .x { margin-left: auto; color: var(--muted); padding: 0 4px; }
.calibSide .row2 .btn { flex: 1; justify-content: center; }

/* ------------------------------------------------------------ стартовый экран */
.empty { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center; max-width: 1180px; margin: 0 auto; padding: 56px 24px; min-height: calc(100dvh - 56px); }
.pitch h1 { font: 700 clamp(44px, 5.6vw, 76px)/.95 var(--num); letter-spacing: -.5px; padding-top: 8px; max-width: 12ch; }
.lead { font-size: 17px; color: var(--muted); max-width: 52ch; margin: 18px 0 0; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 26px 0 0; }
.hint { color: var(--muted); font-size: 13.5px; margin: 14px 0 0; }
.hint a { color: var(--text); }
.steps { list-style: none; padding: 0; margin: 34px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: s; border-top: 1px solid var(--line); padding-top: 18px; }
.steps li { counter-increment: s; font-size: 13px; color: var(--muted); }
.steps li::before { content: counter(s); display: block; font: 700 30px/1 var(--num); color: var(--text); padding-top: 3px; margin-bottom: 6px; }
.steps b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
figure.play { margin: 0; width: 100%; }
figure.play svg { width: 100%; height: auto; display: block; }
figure.play figcaption { color: var(--muted); font-size: 13px; margin-top: 10px; max-width: 46ch; }
.floor { fill: var(--court); }
.pt { fill: var(--paint); }
.ln { fill: none; stroke: var(--court-line); stroke-width: 1.4; }
.ln .bb { stroke-width: 3; }
.rim { fill: none; stroke: var(--ball); stroke-width: 2; }
.tr { fill: none; stroke-width: 1.8; stroke-linecap: round; opacity: .55; }
.tr.a { stroke: var(--a); } .tr.b { stroke: var(--b); }
.arr { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.arr.best { stroke: var(--ideal); stroke-dasharray: 8 5; }
.arr.bad { stroke: var(--bad); }
.bestTip { fill: var(--ideal); } .badTip { fill: var(--bad); }
.lbl { font: 600 11px var(--ui); fill: var(--ideal); }
.badge { fill: var(--bad); }
.badgeT { font: 700 15px var(--num); fill: var(--on-score); text-anchor: middle; dominant-baseline: middle; }
.ca circle, .cb circle { stroke: var(--court); stroke-width: 1.2; }
.ca circle { fill: var(--a); } .cb circle { fill: var(--b); }
.ca text, .cb text { font: 700 12.5px var(--num); text-anchor: middle; dominant-baseline: middle; }
.ca text { fill: var(--a-ink); } .cb text { fill: var(--b-ink); }
.ca .hold { fill: none; stroke: var(--ball); stroke-width: 2.2; }
.ballDot { fill: var(--ball); stroke: var(--on-ball); stroke-width: 1; }
.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s ease-out .2s forwards; }
.draw.d2 { animation-delay: 1.3s; animation-duration: .7s; }
.fade { opacity: 0; animation: fade .4s ease-out forwards; }
.fade.f1 { animation-delay: 1.9s; } .fade.f2 { animation-delay: 2.4s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
.tr.draw { opacity: .55; }
.arr.bad.draw { stroke-dasharray: 1; }

/* ------------------------------------------------------------ админ-панель и мои замечания */
.admin { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.adminHead { display: flex; align-items: flex-end; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.adminHead h1 { font: 700 36px/1 var(--num); padding: 6px 0 12px; }
.adminTabs { border: 0; flex: 1; }
.adminTabs button { flex: none; padding: 12px 14px; }
.adminHead > .btn { margin-bottom: 10px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 2px 6px 0; border-radius: 10px; background: var(--ball); color: var(--on-ball); font: 700 13px/1 var(--num); margin-left: 4px; }

.newUser { display: grid; grid-template-columns: 1.2fr 1fr .8fr auto; gap: 10px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.newUser h2 { grid-column: 1 / -1; font-size: 15px; }
.newUser .formErr { grid-column: 1 / -1; }
.secret { background: var(--edit-bg); border: 1px solid var(--edit-line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.secret code { font: 700 22px/1 var(--num); letter-spacing: 1.5px; padding: 6px 10px 3px; background: var(--panel); border-radius: 6px; border: 1px solid var(--line); user-select: all; }
.secret p { margin: 0; flex: 1 1 260px; font-size: 13px; }
.tableWrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-weight: 700; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.act { text-align: right; white-space: nowrap; }
.grid td.act .btn + .btn { margin-left: 6px; }
.grid select { padding: 4px 8px; }
.grid .muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.off { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.new { color: var(--ball); border-color: color-mix(in srgb, var(--ball) 45%, transparent); }
.pill.progress { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.done { color: var(--muted); }

.fbLayout { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
.fbList { display: grid; gap: 6px; max-height: calc(100dvh - 190px); overflow: auto; }
.fbItem { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; }
.fbItem:hover { border-color: var(--line2); }
.fbItem.on { border-color: var(--text); }
.fbItem .top1 { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.fbItem .top1 .when { margin-left: auto; }
.fbItem p { margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13.5px; }
.fbDetail { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-height: 240px; }
.fbDetail .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.fbDetail .meta select { margin-left: auto; }
.fbDetail .body { white-space: pre-wrap; font-size: 14.5px; margin: 0 0 12px; }
.ctx { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--panel2); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }
.ctx .btn { margin-left: auto; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 14px; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--board); text-decoration: none; }
.gallery img { width: 100%; height: 120px; object-fit: contain; display: block; background: #000; }
.gallery span { display: block; font-size: 12px; color: var(--muted); padding: 4px 8px; }
.thread { display: grid; gap: 8px; margin-bottom: 12px; }
.reply { border-left: 3px solid var(--line2); padding: 4px 10px; font-size: 13.5px; }
.reply.admin { border-color: var(--ball); }
.reply small { color: var(--muted); display: block; }
.reply p { margin: 2px 0 0; white-space: pre-wrap; }
.replyForm { display: grid; gap: 8px; }
.replyForm textarea { min-height: 70px; }
.replyForm .btn { justify-self: end; }

.serverGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card h3 { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.card .big { font: 700 34px/1 var(--num); padding-top: 4px; }
.card .big small { font: 400 13px var(--ui); color: var(--muted); margin-left: 4px; }
.card .meter { height: 6px; margin: 10px 0 6px; }
.card .meter i { background: var(--text); }
.card p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.state { font-weight: 700; } .state.ok { color: var(--good); } .state.off { color: var(--bad); }

/* ------------------------------------------------------------ окно замечания */
.fbDialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(620px, calc(100% - 24px)); box-shadow: var(--shadow); }
.fbDialog::backdrop { background: rgba(0, 0, 0, .45); }
.fbDialog form { padding: 18px 20px; display: grid; gap: 12px; }
.dlgHead { display: flex; align-items: center; justify-content: space-between; }
.dlgHead h2 { font: 700 26px/1 var(--num); padding-top: 4px; }
.dlgHead .icon { font-size: 15px; }
#fbContext { margin: -4px 0 0; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.shot { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; }
.shot img { width: 100%; height: 86px; object-fit: contain; display: block; }
.shot span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11.5px; padding: 3px 6px; }
.shot button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.shotActions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.shotActions .note { margin: 0; }
.fbDialog.drag { outline: 2px dashed var(--ball); outline-offset: -8px; }

/* ------------------------------------------------------------ адаптивность */
@media (max-width: 1320px) { .badge { display: none; } }
@media (max-width: 1180px) {
  main { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; grid-template-areas: "left center" "tape tape" "right right"; height: auto; }
  .right { max-height: 80vh; }
  #court { flex: none; aspect-ratio: 15 / 14; }
  .episode { display: none; }
  .fbLayout { grid-template-columns: 1fr; }
  .fbList { max-height: 320px; }
}
@media (max-width: 900px) {
  .calib { grid-template-columns: 1fr; height: auto; }
  .calibMain { min-height: 50vh; }
  .empty { grid-template-columns: 1fr; gap: 32px; padding-top: 32px; }
  .newUser { grid-template-columns: 1fr 1fr; }
  .top { gap: 10px; }
  #history, #fbBtn { display: none; }
  .userBtn span { display: none; }
}
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; grid-template-areas: "left" "center" "tape" "right"; padding: 8px; }
  .tape { grid-template-columns: 1fr; }
  .transport { flex-direction: row; justify-content: space-between; align-items: center; }
  .steps { grid-template-columns: 1fr; }
  .top .btn.primary { padding: 7px 10px; font-size: 13px; }
  .brand { font-size: 21px; }
  .newUser { grid-template-columns: 1fr; }
  .opt { grid-template-columns: 76px 1fr 32px 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .draw, .fade { animation: none; stroke-dashoffset: 0; opacity: 1; }
  .progress i { transition: none; }
}
