/* Workbench chrome stays quiet so the card is the loudest thing on screen.
   Colors come from the printed card itself: its ink and muted grey, plus a placeholder accent until the HuddlePal brand look is agreed. */
:root {
  --bg: #e9ecef;
  --panel: #ffffff;
  --panel-2: #f5f7f8;
  --ink: #18212b;
  --muted: #66727e;
  --line: #d6dce1;
  --accent: #7ff21a;        /* HuddlePal green (the logo): fills, highlights */
  --on-accent: #0b1220;     /* text on green fills: white on bright green is unreadable */
  --accent-text: #2f7d0b;   /* green for links and text on white (5:1 contrast) */
  --accent-soft: #eefbe3;
  --focus: #1677c8;
  --danger: #c92a2a;
  --ui: "Barlow", "Segoe UI", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
  --nav-h: 60px;
  --dlg-h: calc(100vh - var(--nav-h) - 24px);
}
@supports (height: 100dvh) { :root { --dlg-h: calc(100dvh - var(--nav-h) - 24px); } }
@media (max-width: 760px) { :root { --nav-h: 56px; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 var(--ui); display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar: brand and navigation only ---------- */
/* HuddlePal's own colours (fixed, not the team colour): the dark bar and the amber of the mark. */
.topbar { --brand: #7ff21a; position: relative; z-index: 15; display: flex; align-items: center; gap: 18px; height: var(--nav-h); padding: 0 20px; background: var(--ink); color: #fff; flex-wrap: nowrap; box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 4px 14px rgba(24,33,43,.18); }
.topbar > * { flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; margin-right: 8px; }
.logo-mark { height: 38px; width: auto; display: block; }
.wordmark { font: 700 26px/1 var(--display); letter-spacing: .02em; }
.wordmark b { color: var(--brand); font-weight: 700; }

.nav-links { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-link { position: relative; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #d5dce3; font: 600 15px/1 var(--ui); text-decoration: none; white-space: nowrap; }
.nav-link svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
.nav-link:hover { background: #243040; color: #fff; }
.nav-link.ai-btn svg { fill: var(--brand); }
.nav-link .short { display: none; }
.print-btn b { background: rgba(255,255,255,.14); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.print-btn:not(.empty) b { background: var(--brand); color: var(--ink); }
.print-btn.empty { color: #7d8a97; pointer-events: none; }

/* Team menu on the right: the team badge now, the account menu once sign-in exists. */
.team-menu { position: relative; margin-left: auto; }
.team-btn { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 10px 0 6px; border: 1px solid #3b4a5c; border-radius: 999px; background: #202c3a; color: #fff; }
.team-btn:hover, .team-btn[aria-expanded="true"] { border-color: #5b6f87; background: #2a3747; }
.team-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.brand-mark { font: 700 17px/1 var(--display); letter-spacing: .06em; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-btn .caret { width: 16px; height: 16px; fill: #aab4bd; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 270px; padding: 6px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px rgba(24,33,43,.25); display: grid; gap: 2px; z-index: 40; }
.menu[hidden] { display: none; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; text-align: left; font: 600 14px/1.2 var(--ui); color: var(--ink); white-space: nowrap; }
.menu button svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--panel-2); }
.menu button:disabled { color: var(--muted); cursor: default; }
.menu small { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- tool dock under the card ---------- */
/* Tools read as real buttons: light pills on the dark dock, the active one in the accent colour. */
.dock { display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 6px; background: var(--ink); border-radius: 14px; box-shadow: 0 10px 24px rgba(24,33,43,.22); }
.tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tool { display: flex; align-items: center; gap: 7px; border: 1px solid transparent; background: #3a4b61; color: #fff; padding: 7px 13px; border-radius: 9px; font-weight: 700; font-size: 15px; }
.tool svg { width: 19px; height: 19px; fill: currentColor; stroke: currentColor; }
.tool kbd { font: 600 10px/1 var(--ui); color: #c9d1d9; border: 1px solid #5b6f87; border-radius: 4px; padding: 2px 4px; }
.tool { flex-shrink: 0; }
/* The dock fits the middle column, not the window: wide side panels on a big screen squeeze it
   too. Compact (icon over a short label) when the column is narrow, then wrap as a last resort. */
.stage-wrap { container: stage / inline-size; }
@container stage (max-width: 720px) {
  .tool kbd, .style-pick > span { display: none; }
  .tool { flex-direction: column; gap: 2px; padding: 4px 7px; font-size: 11px; line-height: 1; }
  .tool svg { width: 18px; height: 18px; }
  .dock { padding: 4px; gap: 6px; }
  .save-state:not(.error) { display: none; }
}
@container stage (max-width: 600px) {
  .dock { flex-wrap: wrap; justify-content: center; }
  .tools { flex-wrap: wrap; justify-content: center; }
  .tool { padding: 4px 5px; font-size: 10.5px; }
}
.tool:hover { background: #4a5e78; border-color: #6d84a0; }
.tool.on { background: var(--accent); border-color: rgba(255, 255, 255, .45); color: var(--on-accent); box-shadow: 0 0 0 2px rgba(255, 255, 255, .18), 0 2px 8px rgba(0, 0, 0, .35); }
.tool.on kbd { color: #fff; border-color: rgba(255, 255, 255, .5); }
.style-pick { display: flex; align-items: center; gap: 6px; margin-left: 6px; padding-left: 10px; border-left: 1px solid #3b4a5c; color: #aab4bd; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.style-pick select { background: #fff; color: var(--ink); border: 0; border-radius: 6px; padding: 5px 6px; text-transform: none; letter-spacing: 0; font-size: 14px; }
.style-pick[hidden] { display: none; }

.history { display: flex; gap: 2px; padding-left: 8px; border-left: 1px solid #3b4a5c; }
.icon-btn { width: 36px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: #c9d1d9; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.icon-btn:hover:not(:disabled) { background: #2f3d50; color: #fff; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.save-state { font-size: 12px; color: #aab4bd; min-width: 0; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state:empty { display: none; }
@media (max-width: 1640px) { .tool kbd { display: none; } }
.save-state.error { color: #ffa8a8; font-weight: 600; }

/* ---------- layout ---------- */
.layout { --lib-w: 300px; --insp-w: 290px; position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: var(--lib-w) minmax(0, 1fr) var(--insp-w); }
/* Folding panels away is a wide-screen thing; small screens already use a drawer and stacking. */
@media (min-width: 1101px) {
  body.lib-shut .layout { --lib-w: 0px; }
  body.insp-shut .layout { --insp-w: 0px; }
  body.lib-shut .library, body.insp-shut .inspector { visibility: hidden; overflow: hidden; padding: 0; border: 0; }
}

/* Panel edges: drag to resize, tab to fold a panel away and bring it back. */
.edge { position: absolute; top: 0; bottom: 0; width: 10px; z-index: 5; cursor: col-resize; touch-action: none; }
.edge::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent; transition: background .15s; }
.edge:hover::after, .edge.dragging::after { background: var(--accent); }
.edge-lib { left: calc(var(--lib-w) - 5px); }
.edge-insp { right: calc(var(--insp-w) - 5px); }
body.lib-shut .edge-lib, body.insp-shut .edge-insp { cursor: default; }
.fold { position: absolute; top: 14px; z-index: 6; display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: 700 12px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; padding: 7px 8px; box-shadow: 0 2px 8px rgba(24,33,43,.12); }
.fold:hover { color: var(--ink); border-color: var(--accent); }
.fold-lib { left: var(--lib-w); border-radius: 0 9px 9px 0; border-left: 0; }
.fold-insp { right: var(--insp-w); border-radius: 9px 0 0 9px; border-right: 0; }
.fold span { display: none; }
body.lib-shut .fold-lib span, body.insp-shut .fold-insp span { display: inline; }
.fold b { font: 700 20px/.7 var(--ui); padding-bottom: 2px; }
body.lib-shut .fold, body.insp-shut .fold { padding: 9px 10px; }
.library, .inspector { background: var(--panel); min-height: 0; overflow: auto; }
.library { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.inspector { border-left: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- library ---------- */
.lib-head { position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 14px 14px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.lib-head input[type=search] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--panel-2); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips .fdot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.print-tools { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.print-tools span { margin-right: auto; }
.link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; font-size: 12px; }
.link:hover { text-decoration: underline; }

.play-list { padding: 6px 10px 20px; }
.group-title { font: 700 13px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; margin: 14px 4px 6px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.group-title i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.play-item { display: grid; grid-template-columns: 112px 1fr auto; gap: 10px; align-items: center; padding: 6px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.play-item:hover { background: var(--panel-2); }
.play-item.current { background: var(--accent-soft); border-color: #c6eba6; }
.play-item .thumb svg { display: block; width: 112px; height: auto; }
.play-item .meta { min-width: 0; }
.play-item .name { font-weight: 700; line-height: 1.2; }
.play-item .tag { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.play-item .pick { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; }
.play-item .pick input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
/* A narrow play list: the card picture goes on top, full width, with the name and print box below. */
.library { container: lib / inline-size; }
@container lib (max-width: 270px) {
  .play-item { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  .play-item .thumb { grid-column: 1 / -1; }
  .play-item .thumb svg { width: 100%; }
  .play-item .name { overflow-wrap: anywhere; }
  .print-tools { flex-wrap: wrap; gap: 4px 10px; }
  .print-tools span { flex-basis: 100%; }
}
.empty-note { color: var(--muted); padding: 20px 8px; }

/* ---------- stage ---------- */
.stage-wrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 12px; }
.stage-frame { width: 100%; max-width: min(1100px, calc((100vh - 270px) * 572 / 371)); }
#stage { display: block; width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(24, 33, 43, .18)); touch-action: none; user-select: none; }
#stage.tool-move [data-kind] { cursor: grab; }
#stage.tool-move.dragging, #stage.tool-move.dragging [data-kind] { cursor: grabbing; }
#stage.tool-route, #stage.tool-zone, #stage.tool-label, #stage.tool-ball, #stage.tool-motion { cursor: crosshair; }
#stage [data-handle] { cursor: move; }
/* Motion looks strip under the card */
.looks { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; max-width: 100%; }
.looks[hidden] { display: none; }
.looks-label { font: 700 12px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.look { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 600; color: var(--ink); min-height: 34px; }
.look i { width: 10px; height: 10px; border-radius: 50%; }
.look.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.look.add { border-style: dashed; color: var(--accent-text); }
.look.add.on { background: var(--accent); border-color: var(--accent); border-style: solid; color: var(--on-accent); }
.look-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.look-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px; align-items: center; padding: 4px; border-radius: 9px; }
.look-list li.on { background: var(--panel-2); }
.look-dot { width: 30px; height: 30px; border-radius: 50%; border: 0; font-weight: 700; font-size: 12px; }
.look-list input[data-look-name] { min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 14px; color: var(--ink); background: var(--panel); }
.look-print { display: flex; gap: 4px; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.look-print input { accent-color: var(--accent); width: 16px; height: 16px; }
.look-del { border: 0; background: none; color: var(--danger); font-size: 20px; line-height: 1; width: 30px; height: 30px; border-radius: 7px; }
.look-del:hover { background: var(--panel-2); }
.look-why { grid-column: 2 / -1; margin: 0; font-size: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; min-height: 1.4em; }
.hint kbd { font: 600 11px/1 var(--ui); border: 1px solid var(--line); background: var(--panel); border-radius: 4px; padding: 2px 5px; }

/* ---------- inspector ---------- */
.section { display: grid; gap: 10px; }
.section h3 { margin: 0; font: 700 13px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font-size: 14px; font-weight: 500; color: var(--ink); background: var(--panel); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 6px 12px; font-weight: 600; }
.btn:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.primary { border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; border-radius: 8px; padding: 8px 14px; }
.primary:hover { filter: brightness(1.08); }
.ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.roster { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-select { flex: 1; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 14px; background: var(--panel); }
.dot-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); font: 700 11px/1 Helvetica, Arial, sans-serif; color: #fff; }
.dot-btn.sel { box-shadow: 0 0 0 2px var(--accent); }
.dot-btn.add { background: var(--panel-2) !important; color: var(--muted); border: 1px dashed #aab4bd; box-shadow: none; }
.warn { font-size: 12px; color: #9c4400; background: var(--accent-soft); border-radius: 7px; padding: 6px 9px; }
.confirm { display: grid; gap: 8px; padding: 10px; border-radius: 8px; background: #fff5f5; border: 1px solid #ffc9c9; font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 60px rgba(0,0,0,.3);
  margin: calc(var(--nav-h) + 12px) auto auto; max-height: var(--dlg-h); overflow: auto; }
/* Owner: dialogs open just under the top bar so the branding stays in view. */
dialog::backdrop { background: rgba(24, 33, 43, .45); top: 60px; }
@media (max-width: 760px) { dialog::backdrop { top: 56px; } }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font: 700 24px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
dialog label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
dialog input:not([type=radio]), dialog select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 15px; color: var(--ink); }
.seg { border: 0; padding: 0; margin: 0; display: flex; gap: 6px; }
.seg legend { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; padding: 0; }
.seg label { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; border: 1px solid var(--line); border-radius: 8px; padding: 7px; color: var(--ink); font-size: 14px; }
.seg label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.note { margin: 0; font-size: 12px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- formations ---------- */
.swatches { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.swatches[hidden] { display: none; }
.swatches legend { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; padding: 0; }
.swatches label { position: relative; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatches input { position: absolute; opacity: 0; }
.swatches label:has(input:checked) { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.swatches label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.form-box { display: grid; gap: 10px; padding: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }

/* ---------- coach notes ---------- */
.notes p { margin: 0; font-size: 13px; }
.notes ul { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.notes li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; font-size: 13px; }
.notes .who { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 700 10px/1 Helvetica, Arial, sans-serif; color: #fff; }
.tag-ai { display: inline-block; font: 700 10px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); background: var(--accent-soft); border-radius: 4px; padding: 3px 5px; margin-left: 6px; vertical-align: middle; }
.notes-head { display: flex; justify-content: space-between; align-items: center; }
.notes-head .link { font: 600 12px/1 var(--ui); letter-spacing: 0; text-transform: none; padding: 6px 2px; }
.notes-links { display: flex; gap: 12px; }
.route-tree { margin: 4px 0 10px; }
.route-tree h4 { margin: 0 0 6px; font: 700 11px/1 var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.route-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.inspector { container: insp / inline-size; }
@container insp (max-width: 340px) {
  .route-grid { gap: 4px; }
  .route-pick { padding: 5px 0 4px; border-radius: 8px; }
  .route-pick svg { width: 26px; height: 26px; }
  .route-pick span { font-size: 9.5px; letter-spacing: -.01em; }
  .route-depth span { flex-basis: 100%; }
}
.route-pick { display: grid; justify-items: center; gap: 2px; padding: 6px 2px 5px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--ink); cursor: pointer; }
.route-pick svg { width: 34px; height: 34px; }
.route-pick span { font: 700 11px/1 var(--ui); }
.route-pick:hover { border-color: var(--ink); }
.route-pick.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.route-pick:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.route-depth { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font: 600 12px/1 var(--ui); color: var(--muted); }
.route-depth span { margin-right: auto; }
.route-depth.off { opacity: .45; }
.route-depth button { min-width: 34px; }
.notes-form textarea { width: 100%; resize: vertical; font: 14px/1.4 var(--ui); }
.notes-form .job-row { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; margin-top: 6px; }
.notes-form .job-row input { min-width: 0; font-size: 13px; }

/* ---------- AI suggestions ---------- */
dialog.ai-dialog { width: min(1240px, calc(100vw - 32px)); max-height: var(--dlg-h); overflow: hidden; }
.ai-runs { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.ai-runs.out { color: var(--danger); }
.ai-wrap { display: flex; flex-direction: column; max-height: var(--dlg-h); }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.ai-head h2 { margin: 0; font: 700 24px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
/* Close is a real button: easy to see and at least 44px tall to tap. */
.icon-close { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel-2); color: var(--ink); font: 600 14px/1 var(--ui); cursor: pointer; flex: none; }
.icon-close span { font-size: 22px; line-height: 1; }
.icon-close:hover { background: var(--line); }
.icon-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ai-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; overflow: hidden; }
.ai-form { padding: 18px 22px; display: grid; gap: 14px; align-content: start; border-right: 1px solid var(--line); overflow: auto; }
.ai-form label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ai-form textarea, .ai-form select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 500 14px/1.4 var(--ui); color: var(--ink); resize: vertical; }
.ai-form details { font-size: 13px; }
.ai-form summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.ai-form details textarea { width: 100%; }
.ai-results { padding: 18px 22px; overflow: auto; display: grid; gap: 18px; align-content: start; background: var(--bg); }
.ai-empty { color: var(--muted); max-width: 52ch; margin: 40px auto; text-align: center; }
.ai-empty h3 { font: 700 18px/1.2 var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--ink); margin: 0 0 8px; }
.suggestion { background: var(--panel); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.suggestion .preview svg { display: block; width: 100%; height: auto; }
.suggestion .info { display: grid; gap: 10px; align-content: start; min-width: 0; }
.suggestion h3 { margin: 0; font: 700 20px/1.1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
.suggestion .when { font-size: 12px; color: var(--muted); }
.suggestion .actions { display: flex; gap: 8px; align-items: center; }
.working { display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); margin: 60px 0; }
.working i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: #fff5f5; border: 1px solid #ffc9c9; color: #a61e1e; border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.cost { font-size: 12px; color: var(--muted); text-align: right; }
/* Stacked panel (foldables, tablets in portrait): one scroll, compact two-column form. */
@media (max-width: 900px) {
  .ai-body { display: block; overflow: auto; }
  .ai-form { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .ai-form label:has(#aiBase), .ai-form label:has(#aiAsk), .ai-form details, .ai-form #aiStatus { grid-column: 1 / -1; }
  .ai-form #aiGo { align-self: end; }
  .ai-form textarea#aiAsk { min-height: 0; }
  .ai-results { overflow: visible; }
  .suggestion { grid-template-columns: 1fr; }
}

/* ---------- filters ---------- */
.lib-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.filters { display: grid; gap: 8px; }
.fgroup { display: grid; gap: 4px; }
.flabel { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
/* Picked choices use the accent colour with a tick, so several picks in a group read at a glance. */
.fgroup .chips button:not([data-v=""]).on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fgroup .chips button:not([data-v=""]).on::before { content: "✓ "; }
.fgroup .chips button:not([data-v=""]).on .fdot { outline: 1.5px solid #fff; }
.fclear { justify-self: start; }

/* ---------- browse ---------- */
dialog.browse { width: calc(100vw - 24px); max-width: 1500px; height: var(--dlg-h); max-height: none; overflow: hidden; }
.browse-wrap { display: flex; flex-direction: column; height: 100%; }
.browse-head { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.browse-head h2 { margin: 0; font: 700 24px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; align-self: center; }
.browse-head input[type=search] { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); min-width: 180px; }
.browse-head .filters { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.browse-head .filters { align-items: start; }
.browse-head .fclear { align-self: center; }
/* Title, search and Close share the top row at every width, so Close never wraps down under the filters. */
.browse-title { display: flex; align-items: center; gap: 10px 18px; flex: 1 1 100%; min-width: 0; }
.browse-title input[type=search] { flex: 0 1 260px; min-width: 0; }
.browse-head .icon-close { margin-left: auto; }
.browse-grid { flex: 1; overflow: auto; padding: 16px 18px 90px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; align-content: start; background: var(--bg); }
.bcard { background: var(--panel); border-radius: 12px; padding: 8px; display: grid; gap: 6px; cursor: pointer; border: 2px solid transparent; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.bcard:hover { border-color: var(--line); }
.bcard.sel { border-color: var(--accent); background: var(--accent-soft); }
.bthumb svg { display: block; width: 100%; height: auto; }
.bmeta { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.bpick { display: grid; place-items: center; width: 40px; height: 40px; }
.bpick input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.btext { display: grid; min-width: 0; }
.btext b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btext span { font-size: 12px; color: var(--muted); }
.btags { display: flex; gap: 4px; }
.tag { font: 700 10px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase; border-radius: 4px; padding: 4px 6px; }
.tag.mo { background: #e7f0fb; color: #1864ab; }
.tag.pr { background: var(--accent-soft); color: var(--accent-text); }
.tag.plain, .btags .tag:not(.mo):not(.pr) { background: var(--panel-2); color: var(--muted); }
.bcard.look-card .btext b { color: #1864ab; }
.browse-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 18px; background: var(--ink); color: #fff; }
.browse-bar[hidden] { display: none; }
.browse-bar .link { color: var(--accent); }
.browse-bar .btn { background: transparent; color: #fff; border-color: #3b4a5c; }
/* The page behind an open panel stays put (iPhone otherwise scrolls it when a swipe lands on
   something inside the panel that can't scroll). */
html:has(dialog[open]) { overflow: hidden; }
.browse-grid, .browse-wrap { overscroll-behavior: contain; }
/* Phones: the filters alone are taller than the screen, so the whole panel scrolls as one, with
   title, search and Close pinned on top and each filter group on one sideways-swiping line. */
@media (max-width: 640px) {
  .browse-wrap { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .browse-head { display: contents; }  /* so the title bar can stay pinned to the panel, not to the header */
  .browse-title { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .browse-head h2 { font-size: 20px; }
  .browse-head .filters { display: grid; gap: 8px; padding: 10px 0 0; }
  .browse-head .fgroup { padding-left: 14px; }
  .browse-head .fgroup .chips { flex-wrap: nowrap; overflow-x: auto; padding-right: 14px; scrollbar-width: none; overscroll-behavior-x: contain; }
  .browse-head .fgroup .chips::-webkit-scrollbar { display: none; }
  .browse-head .fgroup .chips button { flex: none; }
  .browse-head #bCount, .browse-head .fclear { margin: 8px 14px 10px; display: inline-block; }
  .browse-grid { overflow: visible; padding: 12px 12px 90px; border-top: 1px solid var(--line); }
}
.sp { flex: 1; }

/* ---------- add motion ---------- */
.motion-body { flex: 1; overflow: auto; padding: 16px 20px; background: var(--bg); }
.motion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.mcard { background: var(--panel); border-radius: 12px; padding: 10px; display: grid; gap: 8px; align-content: start; border: 2px solid var(--accent); }
.mcard.off { border-color: transparent; opacity: .55; }
.mcard.skipped { border-color: transparent; }
.mwhy { margin: 0; font-size: 13px; }
.motion-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- drawing controls (all sizes) ---------- */
.draft-bar { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: 0 6px 18px rgba(24,33,43,.12); font-size: 14px; }
.draft-bar[hidden] { display: none; }
.draft-bar .primary, .draft-bar .ghost { border-radius: 999px; padding: 8px 16px; }

.lib-toggle { display: none; align-items: center; gap: 6px; height: 40px; border: 1px solid #3b4a5c; background: transparent; color: #fff; font-weight: 700; padding: 0 12px; border-radius: 9px; }
.lib-toggle svg { width: 18px; height: 18px; stroke: currentColor; }
.scrim { position: fixed; inset: 0; background: rgba(24, 33, 43, .4); z-index: 20; }
.scrim[hidden] { display: none; }

/* ---------- tablets and foldables ---------- */
@media (max-width: 1100px) {
  .lib-toggle { display: flex; }
  /* Autosave is quiet here; the status only takes space when something needs attention. */
  .save-state:not(.error) { display: none; }
  .tool kbd { display: none; }
  /* Small screens keep a short label under each tool icon so the tools are easy to spot. */
  .style-pick > span { display: none; }
  .tool { flex-direction: column; gap: 2px; padding: 4px 7px; font-size: 11px; line-height: 1; }
  .tool svg { width: 18px; height: 18px; }
  .dock { padding: 4px; gap: 6px; }
  .style-pick select { max-width: 118px; }
  .edge, .fold { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }

  /* Library slides in over the card instead of taking a column. */
  .library { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(380px, 88vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 40px rgba(24,33,43,.25); }
  body.lib-open .library { transform: none; }

  .layout { grid-template-columns: minmax(0, 1fr) 290px; }
  /* Card sits right under the top bar (no empty band above it), dock and motion follow. */
  .stage-wrap { padding: 14px; justify-content: flex-start; }
  /* Short nav labels while they fit (an unfolded Fold is about 860px wide). */
  .nav-link { padding: 0 11px; gap: 7px; }
  .nav-link .long { display: none; }
  .nav-link .short { display: inline; }
}
/* Too narrow for words: nav goes to icons (names stay in the tooltip and for screen readers). */
@media (max-width: 819px) {
  .nav-link > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-link svg { width: 20px; height: 20px; }
}

/* Portrait or near-square (a foldable opened up): card on top, controls underneath. */
@media (max-width: 1100px) and (orientation: portrait) {
  .layout { display: flex; flex-direction: column; }
  .stage-wrap { flex: 0 0 auto; padding: 10px 10px 6px; gap: 8px; }
  .stage-frame { max-width: 100%; }
  .hint { display: none; }
  .inspector { flex: 1 1 auto; min-height: 0; border-left: 0; border-top: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 16px 22px; padding: 14px; }
  .inspector .section { flex: 1 1 250px; min-width: 0; }
}

@media (max-width: 760px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .lib-toggle { padding: 0 10px; }
  .logo { margin-right: 0; }
  .logo-mark { height: 32px; width: auto; }
  .wordmark, .team-btn .brand-mark, .team-btn .caret { display: none; }
  .team-btn { padding: 0 5px; }
  .nav-links { gap: 0; }
  .nav-link { padding: 0 9px; }
  .print-btn b { padding: 1px 6px; }
  .tool { padding: 5px 6px; min-width: 44px; font-size: 10.5px; }
  .tools { gap: 2px; }
  .history { padding-left: 4px; }
  .style-pick { margin-left: 2px; padding-left: 6px; }
  .style-pick select { max-width: 104px; }
}

/* Touch-first devices: finger-sized controls. */
@media (pointer: coarse) {
  .tool, .icon-btn { min-height: 42px; min-width: 42px; }
  .chips button { padding: 7px 13px; font-size: 14px; }
  .look { min-height: 42px; padding: 8px 15px; }
  .look-dot, .look-del { width: 40px; height: 40px; }
  .look-print input { width: 20px; height: 20px; }
  .btn { padding: 10px 14px; }
  .field input, .field select, .inline-select { padding: 10px; font-size: 16px; }
  .play-item { padding: 8px 6px; }
  .play-item .pick { width: 44px; height: 44px; }
  .play-item .pick input { width: 24px; height: 24px; }
  .dot-btn { width: 38px; height: 38px; font-size: 12px; }
  .style-pick select { padding: 9px 8px; font-size: 16px; }
  #stage { -webkit-touch-callout: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Settings ---------- */
dialog.settings-dialog { width: min(520px, calc(100vw - 32px)); max-height: var(--dlg-h); overflow: hidden; }
.settings-wrap { display: flex; flex-direction: column; max-height: var(--dlg-h); }
.settings-body { overflow: auto; padding-bottom: 18px; }
.settings-body > .muted { margin: 14px 22px 4px; font-size: 13px; }
.settings-body h3 { margin: 18px 22px 6px; font: 700 13px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--accent-text); }
.settings-body .hint { margin: 0 22px 6px; color: var(--muted); font-size: 12px; }
.settings-wrap .setting { display: flex; gap: 12px; align-items: flex-start; padding: 12px 22px; border-top: 1px solid var(--line); cursor: pointer; color: var(--ink); font-size: 15px; }
.settings-wrap .setting > span { display: grid; gap: 4px; flex: 1; }
.settings-wrap .setting small { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.35; }
.settings-wrap .setting input[type=checkbox] { accent-color: var(--accent); width: 22px; height: 22px; margin: 1px 0 0; padding: 0; border: 0; flex: none; }
.settings-wrap .setting select { flex: none; min-width: 112px; font-size: 15px; }
.settings-wrap .setting.sub { padding-left: 56px; border-top: 0; padding-top: 0; align-items: center; }
.settings-wrap .setting.row2 { display: grid; grid-template-columns: 1fr 112px; cursor: default; }
.settings-wrap .setting.row2 input[type=color] { width: 100%; height: 38px; padding: 2px 4px; cursor: pointer; }

/* Simple mode hides the extras. */
body.simple #aiOpen, body.simple #aiMotion, body.simple #bMotion,
body.simple .tool[data-tool=zone], body.simple .tool[data-tool=label] { display: none; }

/* ------------------------------------------------------------ sign-in screen
   A night-game field: dark turf, chalk yard lines, a faint play diagrammed on it. */
body.gated { overflow: hidden; }
body.gated > .shell { visibility: hidden; }
.gate { --brand: #4fa80f; position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background: radial-gradient(120% 80% at 50% 0%, #24313d 0%, #18212b 55%, #10171e 100%); color: var(--ink); }
.gate[hidden] { display: none; }
.gate-field { position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background:
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(255,255,255,.07) 79px 81px),
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(255,255,255,.035) 15px 16px);
  -webkit-mask-image: radial-gradient(90% 70% at 50% 45%, #000 35%, transparent 100%);
          mask-image: radial-gradient(90% 70% at 50% 45%, #000 35%, transparent 100%); }
.gate-field::before, .gate-field::after { content: ""; position: absolute; border: 3px solid rgba(255,178,122,.28); }
.gate-field::before { width: 34px; height: 34px; border-radius: 50%; left: 14%; top: 22%; }
.gate-field::after { width: 120px; height: 90px; right: 12%; bottom: 18%; border-width: 0 3px 3px 0; border-radius: 0 0 60px 0; border-color: rgba(255,255,255,.14); }
.gate-card { position: relative; width: min(420px, 100%); padding: 30px 30px 26px; background: var(--panel); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04); animation: gate-in .35s ease-out; }
@keyframes gate-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.gate-brand .logo-mark { height: 48px; width: auto; }
.gate-brand .wordmark { font-size: 30px; color: var(--ink); }
.gate-brand .wordmark b { color: #4fa80f; }
.gate-legal { margin: 18px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }
.gate-legal a { color: var(--muted); font-weight: 600; }
.menu-legal { margin: 4px 0 0; padding: 8px 12px 4px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.menu-legal a { color: var(--muted); text-decoration: none; font-weight: 600; }
.menu-legal a:hover { color: var(--ink); text-decoration: underline; }
.gate-step { display: grid; gap: 8px; }
.gate-step[hidden], .gate-msg[hidden] { display: none; }
.gate-step h1 { margin: 0; font: 700 30px/1.05 var(--display); letter-spacing: .01em; }
.gate-lede { margin: 2px 0 12px; color: var(--muted); font: 500 15px/1.45 var(--ui); }
.gate-lede b { color: var(--ink); word-break: break-all; }
.gate-step > label, .gate-sizes legend { font: 700 12px/1 var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.gate-step input[type=email], .gate-step input[type=text] { width: 100%; box-sizing: border-box; padding: 14px 14px; font: 600 17px/1.2 var(--ui); color: var(--ink);
  background: var(--panel-2); border: 2px solid var(--line); border-radius: 12px; outline: none; transition: border-color .15s, background .15s; }
.gate-step input:focus { border-color: var(--focus); background: #fff; }
.gate-step input.gate-code { font: 700 32px/1 var(--display); letter-spacing: .45em; text-align: center; padding: 14px 0 14px .45em; }
.gate-go { margin-top: 10px; padding: 15px 18px; border: 0; border-radius: 12px; background: var(--ink); color: #fff;
  font: 700 17px/1 var(--ui); letter-spacing: .01em; cursor: pointer; transition: transform .1s, background .15s; }
.gate-go:hover { background: #24313d; }
.gate-go:active { transform: translateY(1px); }
.gate-go:disabled { opacity: .6; cursor: progress; }
.gate-step.busy .gate-go::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: gate-spin .7s linear infinite; }
@keyframes gate-spin { to { transform: rotate(360deg); } }
.gate-links { margin: 8px 0 0; text-align: center; font: 600 14px/1.4 var(--ui); color: var(--muted); }
.gate-links a { color: var(--focus); text-decoration: none; }
.gate-links a:hover { text-decoration: underline; }
.gate-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 0; padding: 0; border: 0; }
.gate-sizes legend { margin-bottom: 8px; padding: 0; }
.gate-sizes label { position: relative; }
.gate-sizes input { position: absolute; opacity: 0; inset: 0; }
.gate-sizes span { display: block; padding: 14px 0; text-align: center; font: 700 22px/1 var(--display); border: 2px solid var(--line); border-radius: 12px;
  background: var(--panel-2); cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.gate-sizes input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.gate-sizes input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
#gateGoogleWrap[hidden] { display: none; }
.gate-google { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 18px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); font: 700 17px/1 var(--ui); text-decoration: none; transition: border-color .15s, background .15s; }
.gate-google:hover { border-color: #b9c2ca; background: var(--panel-2); }
.gate-google:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.gate-google svg { width: 20px; height: 20px; flex: none; }
.gate-or { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; color: var(--muted); font: 600 13px/1 var(--ui); }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gate-msg { margin: 14px 0 0; padding: 11px 13px; border-radius: 10px; background: var(--accent-soft); color: var(--danger); font: 600 14px/1.35 var(--ui); }
.gate-msg.ok { background: #e7f4ea; color: #1f7a3a; }
@media (max-width: 420px) { .gate-card { padding: 24px 20px 20px; border-radius: 16px; } .gate-step h1 { font-size: 27px; } }
@media (prefers-reduced-motion: reduce) { .gate-card { animation: none; } }

.menu-who { margin: 0; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font: 600 13px/1.3 var(--ui); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who:empty { display: none; }
.menu-plan { margin: -6px 0 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); font: 700 12px/1.3 var(--ui); color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.menu-plan:empty { display: none; }
.menu-who:has(+ .menu-plan:not(:empty)) { border-bottom: 0; margin-bottom: 0; }
/* Free teams: AI features are marked as paid (the server refuses them; this explains why). */
body.plan-free #coachesOpen::after { content: "Paid"; margin-left: auto; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--on-accent);
  font: 800 10px/1.2 var(--ui); text-transform: uppercase; letter-spacing: .06em; }
.notice { position: fixed; z-index: 60; top: 72px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: min(620px, calc(100vw - 24px)); padding: 12px 14px 12px 18px; border-radius: 12px; background: #e7f6ec; color: #145c2e; border: 1px solid #b9e2c6; box-shadow: 0 10px 28px rgba(24,33,43,.18); font: 600 14px/1.4 var(--ui); }
.notice.error { background: #fdecea; color: #8a1c13; border-color: #f3c2bc; }
.notice[hidden] { display: none; }
.notice .link { font-size: 20px; line-height: 1; color: inherit; padding: 2px 6px; }
#billingOpen small { margin-left: auto; }
.menu button[hidden] { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.coach-seat { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 2px 0 4px; padding: 0; border: 0; }
.coach-seat label { position: relative; }
.coach-seat input { position: absolute; opacity: 0; inset: 0; }
.coach-seat span { display: grid; gap: 3px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.coach-seat b { font: 700 15px/1.2 var(--ui); }
.coach-seat small { font: 600 12px/1.3 var(--ui); color: var(--muted); }
.coach-seat input:checked + span { border-color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--ink); }
.coach-seat input:disabled + span { opacity: .5; cursor: not-allowed; }
.coach-seat input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.coach-role.viewer { background: #e6f0fa; color: #1a5a96; }
/* View-only coaches: plays are shown, every way to change or print them is hidden.
   The server refuses changes anyway; this keeps the screen honest. */
.viewer-note { display: none; }
body.viewer .viewer-note { display: block; margin: 10px auto 0; max-width: 640px; padding: 10px 14px; border-radius: 10px; background: #e6f0fa; color: #1a5a96; font: 500 14px/1.4 var(--ui); text-align: center; }
body.viewer .dock, body.viewer .lib-actions, body.viewer #aiOpen, body.viewer #printLink,
body.viewer #settingsOpen, body.viewer .play-item input[type=checkbox], body.viewer .print-tools,
body.viewer #hint, body.viewer #lookAdd, body.viewer #lookAdd2, body.viewer .inspector .row:has(#addWho) { display: none !important; }
body.viewer #stage { pointer-events: none; }
.viewer-name { margin: 2px 0 12px; font: 700 22px/1.15 var(--display); color: var(--ink); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { display: grid; gap: 3px; padding: 9px 11px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.fact span { font: 700 11px/1 var(--ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.fact b { font: 700 15px/1.2 var(--ui); color: var(--ink); }
.coach-list { list-style: none; margin: 14px 22px 18px; padding: 0; display: grid; gap: 8px; }
.coach-list li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.coach-list li.pending { border-style: dashed; background: #fff; }
.coach-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 15px/1.3 var(--ui); }
.coach-email em { font-style: normal; color: var(--muted); font-weight: 500; }
.coach-role { flex: none; padding: 4px 9px; border-radius: 999px; font: 700 11px/1 var(--ui); text-transform: uppercase; letter-spacing: .06em; background: #e3e8ec; color: var(--ink); }
.coach-role.owner { background: var(--ink); color: #fff; }
.coach-role.pending { background: #fff3e6; color: #9a4a12; }
.coach-remove { flex: none; border: 0; background: none; color: var(--danger); font: 700 13px/1 var(--ui); padding: 6px 4px; cursor: pointer; }
.coach-remove:hover { text-decoration: underline; }
.coach-add { display: grid; gap: 8px; }
.coach-add[hidden] { display: none; }
.coach-add > label { font: 700 12px/1 var(--ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.coach-add-row { display: flex; gap: 8px; }
.coach-add-row input { flex: 1; min-width: 0; padding: 12px 13px; font: 600 15px/1.2 var(--ui); border: 2px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--ink); }
.coach-add-row input:focus { outline: none; border-color: var(--focus); background: #fff; }
.coach-go { flex: none; padding: 0 18px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font: 700 15px/1 var(--ui); cursor: pointer; }
.coach-go:disabled, .coach-add-row input:disabled { opacity: .5; cursor: not-allowed; }
.coach-how { margin: 0; font-size: 13px; }
.coach-msg { margin: 14px 22px 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--danger); font: 600 14px/1.35 var(--ui); }
.coach-msg[hidden] { display: none; }
.coach-msg.ok { background: #e7f4ea; color: #1f7a3a; }
@media (max-width: 480px) { .coach-add-row { flex-direction: column; } .coach-go { padding: 13px; } }
/* ---------- Coach's Coordinator: practice plans and roster ---------- */
dialog.coord { width: calc(100vw - 24px); max-width: 1320px; height: var(--dlg-h); max-height: none; overflow: hidden; padding: 0; }
.coord-wrap { display: flex; flex-direction: column; height: 100%; }
.coord-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.coord-title { display: flex; align-items: center; gap: 10px 22px; min-width: 0; }
.coord-title h2 { margin: 0; font: 700 24px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.coord-title .icon-close { margin-left: auto; }
.coord-tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.coord-tabs[hidden] { display: none; }
.coord-tabs button { border: 0; background: none; border-radius: 999px; padding: 8px 16px; font: 700 14px/1 var(--ui); color: var(--muted); white-space: nowrap; }
.coord-tabs button[aria-selected=true] { background: var(--ink); color: #fff; }
.coord-tabs span { font-weight: 600; opacity: .75; }
.coord h3 { margin: 0; font: 700 15px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.coord-paywall { max-width: 560px; margin: 60px auto; padding: 0 20px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.coord-paywall[hidden] { display: none; }
.coord-paywall h3 { font-size: 22px; color: var(--ink); letter-spacing: .03em; }
.coord-paywall p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }

.coord-plans { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); overflow: hidden; }
.coord-plans[hidden], .coord-edit[hidden], .coord-roster[hidden] { display: none; }
.coord-draft { padding: 20px 22px 28px; display: grid; gap: 16px; align-content: start; border-right: 1px solid var(--line); overflow: auto; overscroll-behavior: contain; }
.coord-draft[hidden] { display: none; }
.coord-draft label, .coord-label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.coord-label small { font-weight: 600; color: var(--accent-text); margin-left: 6px; }
.coord-draft input, .coord-draft textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 500 14px/1.4 var(--ui); color: var(--ink); background: var(--panel); }
.coord-draft textarea { resize: vertical; }
.coord-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.coord-draft .seg { flex-wrap: wrap; }
.coord-draft .seg label { flex: 1 0 auto; font-weight: 600; font-size: 13px; padding: 8px 6px; color: var(--ink); position: relative; }
.coord-pick .coord-label { display: block; }
.coord-long[hidden] { display: none; }
.coord-long input { max-width: 140px; }
.coord-pick { display: grid; gap: 6px; }
.coord-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 190px; overflow: auto; padding: 2px; }
.coord-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px 6px 9px; font: 600 13px/1.1 var(--ui); color: var(--ink); }
.coord-chip small { color: var(--muted); font-weight: 600; font-size: 11px; }
.coord-chip i { width: 9px; height: 9px; border-radius: 50%; background: #9aa5b1; }
.coord-chip i.k-run { background: #2474b5; }
.coord-chip i.k-pass { background: #31834b; }
.coord-chip i.k-defense { background: #343a40; }
.coord-chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.coord-chip.on small { color: #c9d1d9; }
#pGo { padding: 13px; font-size: 15px; }
#pGo:disabled { opacity: .55; cursor: default; filter: none; }
.coord-or { margin: -6px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.coord-or .link { font-size: 13px; }
.coord-saved { padding: 20px 22px; overflow: auto; overscroll-behavior: contain; background: var(--bg); display: grid; gap: 12px; align-content: start; }
.coord-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.coord-item { display: grid; gap: 6px; text-align: left; padding: 16px 18px 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  box-shadow: 0 1px 2px rgba(0,0,0,.05); position: relative; overflow: hidden; }
.coord-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent); }
.coord-item:hover { border-color: #b8c2cc; box-shadow: 0 6px 18px rgba(24,33,43,.1); }
.coord-item b { font: 700 18px/1.1 var(--display); text-transform: uppercase; letter-spacing: .02em; color: var(--ink); }
.coord-item span { font-size: 13px; color: var(--muted); }
.coord-item { min-width: 0; } .coord-item b, .coord-item span { min-width: 0; overflow-wrap: anywhere; }

.coord-edit { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--bg); }
.coord-editbar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.coord-editbar .sp { flex: 1; }
.coord-editbar .link { font-size: 14px; }
.coord-date { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.coord-date input { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font: 500 14px var(--ui); color: var(--ink); }
.danger-text { color: var(--danger); }
.coord-sheet { max-width: 980px; margin: 22px auto 60px; box-shadow: 0 10px 30px rgba(24,33,43,.14); border-radius: 6px; overflow: hidden; }

.coord-roster { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 22px; display: grid; gap: 14px; align-content: start; max-width: 1080px; width: 100%; margin: 0 auto; }
.roster-intro { display: grid; gap: 6px; }
.roster-intro .note { margin: 0; }
.roster-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) 64px minmax(90px, 1fr) minmax(90px, 1fr) minmax(140px, 2fr) 40px; gap: 8px; align-items: center; }
.roster-row input { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: 500 14px var(--ui); color: var(--ink); background: var(--panel); }
.roster-row input[data-k=name] { font-weight: 700; }
.roster-headrow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 2px; }
.roster-del { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 18px; }
.roster-del:hover { color: var(--danger); border-color: var(--danger); }
.roster-list { display: grid; gap: 8px; }
.roster-actions { display: flex; align-items: center; gap: 14px; }

@media (max-width: 860px) {
  .coord-plans { grid-template-columns: 1fr; overflow: auto; overscroll-behavior: contain; }
  .coord-draft { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .coord-saved { overflow: visible; }
}
@media (max-width: 640px) {
  dialog.coord { width: 100vw; max-width: 100vw; height: 100dvh; border-radius: 0; margin: 0; }
  .coord-head { padding: 10px 12px; }
  .coord-title { flex-wrap: wrap; gap: 10px; }
  .coord-title h2 { font-size: 20px; }
  .coord-tabs { order: 3; flex: 1 1 100%; }
  .coord-tabs button { flex: 1; }
  .coord-draft, .coord-saved, .coord-roster { padding: 16px 14px; }
  .coord-editbar { padding: 8px 12px; }
  .coord-sheet { margin: 0 0 40px; border-radius: 0; box-shadow: none; }
  .roster-headrow { display: none; }
  .roster-row { grid-template-columns: 1fr 64px 40px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
  .roster-row input[data-k=offense], .roster-row input[data-k=defense] { grid-column: span 1; }
  .roster-row input[data-k=note] { grid-column: 1 / -1; }
  .roster-row .roster-del { grid-column: 3; grid-row: 1; }
  .roster-row input[data-k=offense] { grid-column: 1; }
  .roster-row input[data-k=defense] { grid-column: 2 / 4; }
}
body.plan-free #coordOpen::after,
body.plan-free #aiOpen::after, body.plan-free #aiMotion::after, body.plan-free #bMotion::after {
  content: "Paid"; margin-left: 6px; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--on-accent);
  font: 800 10px/1.2 var(--ui); text-transform: uppercase; letter-spacing: .06em; }
