/* Theming layer — each theme defines the same token names, so the rest of this
   stylesheet (which reads the variables) re-themes automatically. Court is the default
   and identical to the original palette. Switch via the header control (theme.js). */

/* ---- COURT — default. The original black / dark-grey / mint look. ---------- */
:root,
:root[data-theme="court"] {
  --black:       #121212;   /* page background            */
  --dark-grey:   #1f1f1f;   /* panels / cards / header    */
  --grey:        #2c2c2c;   /* inputs / chips / hovers    */
  --border-2:    #3a3a3a;   /* panel / control borders    */
  --mint:        #3eb489;
  --mint-bright: #5fd6a8;
  --text:        #e8e8e8;
  --text-dim:    #9a9a9a;
  --on-accent:   #121212;   /* text/icon on a mint surface */
  --error:       #d9534f;   /* errors · court end marker   */
  --neutral:     #6c84a8;   /* in-play / neutral results   */
  --flag:        #ffd23a;   /* antenna · review flags      */
  --court-floor: #45433d;   /* free zone around the court  */
  --court-rect:  #16241f;   /* in-bounds court             */
  --court-line:  rgba(255, 255, 255, 0.55);
  color-scheme: dark;
}

/* ---- DAYLIGHT — friendly light / paper mode -------------------------------- */
:root[data-theme="daylight"] {
  --black:       #f4f4f1;
  --dark-grey:   #ffffff;
  --grey:        #ededea;
  --border-2:    #d2d1c8;
  --mint:        #1f9468;
  --mint-bright: #19805a;
  --text:        #1b1c1a;
  --text-dim:    #5f615d;
  --on-accent:   #ffffff;
  --error:       #c4443f;
  --neutral:     #4f6b95;
  --flag:        #c98a12;
  --court-floor: #d9d4c6;
  --court-rect:  #cfe3d8;
  --court-line:  rgba(40, 60, 50, 0.5);
  color-scheme: light;
}

/* ---- RALLY — energetic deep navy, broadcast feel --------------------------- */
:root[data-theme="rally"] {
  --black:       #0b1018;
  --dark-grey:   #131a26;
  --grey:        #1c2738;
  --border-2:    #38476b;
  --mint:        #2fd49b;
  --mint-bright: #4fe6b0;
  --text:        #eef2f9;
  --text-dim:    #97a4bd;
  --on-accent:   #04140e;
  --error:       #ff5d72;
  --neutral:     #6c8fd6;
  --flag:        #ffc14d;
  --court-floor: #1d2942;
  --court-rect:  #102a26;
  --court-line:  rgba(180, 200, 230, 0.5);
  color-scheme: dark;
}

/* ---- Header theme switcher (matches the .tag-level / .side-btn controls) ---- */
header .theme-switch {
  display: inline-flex;
  margin-left: auto;                 /* pushes switcher + account to the right */
  border: 1px solid var(--grey);
  border-radius: 6px;
  overflow: hidden;
}
header .theme-switch button {
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
header .theme-switch button + button { border-left: 1px solid var(--grey); }
header .theme-switch button:hover:not(.active) { background: var(--grey); color: var(--text); }
header .theme-switch button.active { background: var(--mint); color: var(--on-accent); }
header .account { margin-left: 1.25rem; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--black);
  color: var(--text);
}

/* --- Header (Videos / Stats / My Teams + account corner) --- */
header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--dark-grey);
  border-bottom: 2px solid var(--mint);
}
header .brand { font-weight: 700; color: var(--mint); font-size: 1.1rem; }
header nav { display: flex; gap: 1.25rem; }
header nav a { color: var(--text-dim); text-decoration: none; }
header nav a:hover { color: var(--mint-bright); }
header nav a.active { color: var(--mint); font-weight: 600; }
.badge {
  background: var(--mint);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Review page */
.resolve-panel { border-color: var(--mint); }
.review-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.review-info { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.review-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0; }
.review-actions button { padding: 0.35rem 0.6rem; }
header .account { color: var(--text-dim); }

/* The header needs ~880px for one row. Below that it used to overflow the page AND
   squeeze the theme switcher down to a couple of pixels, so it wraps instead: brand +
   switcher + account stay on top, the nav takes a full second row. Nothing is hidden,
   which is the point -- a nav link scrolled out of sight (Review and its count badge,
   say) is a link nobody clicks. */
@media (max-width: 880px) {
  header {
    flex-wrap: wrap;
    height: auto;                 /* the fixed 56px is what forced the squeeze */
    min-height: 56px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    row-gap: 0.5rem;
    column-gap: 1rem;
  }
  header nav {
    order: 3;                     /* after brand/switcher/account -> its own row */
    flex-basis: 100%;
    flex-wrap: wrap;              /* and wraps again on a really narrow phone */
    row-gap: 0.4rem;
  }
  header .theme-switch { flex-shrink: 0; }   /* never crushed again */
}

main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }
.backbar { margin-bottom: 0.75rem; }
.backbar #global-back { display: inline-block; }

h1, h2 { color: var(--text); font-weight: 600; }

video {
  width: 100%;
  max-height: 480px;
  background: #000;
  border-radius: 8px;
}

.panel {
  background: var(--dark-grey);
  border: 1px solid var(--grey);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.25rem; }

input, select {
  background: var(--grey);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 0.5rem;
  width: 100%;
}

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 120px; }

button {
  background: var(--mint);
  color: var(--on-accent);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--mint-bright); }
button.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--grey); }

/* Condensed-playback tools under the video */
.video-tools { display: flex; align-items: center; gap: 0.9rem; margin-top: 0.5rem; flex-wrap: wrap; }
/* Jump straight to the next rally -- ~70% of a game video is dead time. */
.rally-jump { display: inline-flex; gap: 0.3rem; margin-right: 0.6rem; }
.rally-jump button {
  background: var(--grey);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.rally-jump button:hover { background: var(--mint); color: var(--on-accent); border-color: var(--mint); }
.condensed-toggle { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text); cursor: pointer; white-space: nowrap; }
.condensed-toggle input { accent-color: var(--mint); cursor: pointer; }
.condensed-toggle:has(input:disabled) { color: var(--text-dim); cursor: default; }

/* Complexity toggle (Core / Trajectory / Tactical) — segmented control */
.tag-level { display: inline-flex; margin-bottom: 0.45rem; border: 1px solid var(--grey); border-radius: 6px; overflow: hidden; }
.level-btn { background: transparent; color: var(--text-dim); border: none; border-radius: 0; padding: 0.3rem 0.7rem; font-size: 0.78rem; font-weight: 600; }
.level-btn + .level-btn { border-left: 1px solid var(--grey); }
.level-btn:hover:not(.active) { background: var(--grey); color: var(--text); }
.level-btn.active { background: var(--mint); color: var(--on-accent); }

/* Our team / Opponent toggle — segmented control at the top of the tagger */
.tag-side { display: inline-flex; margin-bottom: 0.7rem; border: 1px solid var(--grey); border-radius: 6px; overflow: hidden; }
.side-btn { background: transparent; color: var(--text-dim); border: none; border-radius: 0; padding: 0.35rem 0.9rem; font-size: 0.85rem; font-weight: 600; }
.side-btn + .side-btn { border-left: 1px solid var(--grey); }
.side-btn:hover:not(.active) { background: var(--grey); color: var(--text); }
.side-btn.active { background: var(--mint); color: var(--on-accent); }

/* Rotation control — "Rotation [1-6] [Serve|Receive]" segmented controls */
.tag-rotation { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.rot-label { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; }
.rot-nums, .rot-phase { display: inline-flex; border: 1px solid var(--grey); border-radius: 6px; overflow: hidden; }
.rot-btn, .rot-pbtn {
  background: transparent; color: var(--text-dim); border: none; border-radius: 0;
  padding: 0.25rem 0.55rem; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.rot-btn { min-width: 1.7rem; }
.rot-btn + .rot-btn, .rot-pbtn + .rot-pbtn { border-left: 1px solid var(--grey); }
.rot-btn:hover:not(.active), .rot-pbtn:hover:not(.active) { background: var(--grey); color: var(--text); }
.rot-btn.active, .rot-pbtn.active { background: var(--mint); color: var(--on-accent); }
.rot-now { font-size: 0.85rem; color: var(--mint-bright); font-weight: 700; white-space: nowrap; }

/* Tagger header (title · current rotation · settings gear) + the settings popover */
.tag-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.tag-head h2 { margin: 0; }
.tag-head .rot-now { margin-left: auto; }   /* push the rotation readout + gear to the right */
.tag-gear {
  background: transparent; border: 1px solid var(--grey); color: var(--text-dim);
  border-radius: 6px; width: 2rem; height: 2rem; padding: 0; font-size: 1rem; cursor: pointer;
  flex: 0 0 auto;
}
.tag-gear:hover, .tag-gear.open { background: var(--grey); color: var(--text); }
.tag-settings {
  background: var(--grey); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 0.7rem; margin-bottom: 0.7rem; display: flex; flex-direction: column; gap: 0.7rem;
}
.tag-settings[hidden] { display: none; }
.settings-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.settings-label { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; min-width: 5.5rem; }
.rot-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.rot-fix { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.85rem; }
.rot-fix select { width: auto; padding: 0.25rem 0.4rem; }
.rot-fix-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.3rem 0.8rem; flex-wrap: wrap; }
.rot-fix-list li { color: var(--text-dim); }
.rot-fix-list .ghost { padding: 0 0.35rem; }

/* Live scoreboard on the game view */
.scoreboard {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  margin: 0 0 1rem;
}
.score-meta { display: flex; align-items: center; gap: 1rem; font-size: 0.82rem; color: var(--text-dim); }
.score-setlabel { font-weight: 700; color: var(--text); }
/* Some of this set's points are guesses (serves weren't tagged): main._rallies. */
.score-est { font-style: italic; color: var(--text-dim); cursor: help; border-bottom: 1px dotted var(--grey); }
.score-newset { padding: 0.2rem 0.6rem; font-size: 0.75rem; }
.score-main { display: flex; align-items: center; justify-content: center; gap: 1.75rem; }
.score-side { text-align: center; }
.score-name {
  color: var(--text-dim); font-size: 0.85rem; margin-bottom: 0.25rem;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-row { display: flex; align-items: center; gap: 0.6rem; }
.score-val { font-size: 2.1rem; font-weight: 800; color: var(--mint-bright); min-width: 2.2rem; }
.score-val.opp { color: var(--text); }
.score-dash { font-size: 1.6rem; color: var(--text-dim); padding-top: 1.2rem; }
.scoreboard-ro .score-dash { padding-top: 0; }   /* no +/- rows, so center on the values */
.score-btn {
  background: transparent; border: 1px solid var(--grey); color: var(--text);
  border-radius: 6px; width: 2rem; height: 2rem; padding: 0; font-size: 1.15rem; line-height: 1;
}
.score-btn:hover { background: var(--grey); }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
/* In-table links (player names, game names, roster numbers) read like the clickable
   stats — white text, mint on hover — not default blue/purple. */
table a { color: var(--text); text-decoration: none; }
table a:hover { color: var(--mint-bright); }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--grey); font-size: 0.9rem; }
th { color: var(--text-dim); font-weight: 500; }
.timestamp { color: var(--mint-bright); cursor: pointer; text-decoration: underline; }

.hint { color: var(--text-dim); font-size: 0.85rem; }

/* Collapsible upload panel */
details.panel summary { cursor: pointer; color: var(--mint-bright); font-weight: 600; }

/* Warning / call-to-action panel */
.panel.warn { border-color: var(--mint); }
.panel.warn a { color: var(--mint-bright); }

/* Teams page: team title row with a delete button */
.team-head { display: flex; align-items: center; justify-content: space-between; }
.team-head h2 { margin: 0.25rem 0; }
/* Collapsible team sections */
.team-details summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.team-details summary .team-name { font-size: 1.05rem; color: var(--text); font-weight: 700; }
.team-details > summary { cursor: pointer; flex-wrap: wrap; -webkit-tap-highlight-color: transparent; }  /* the whole row opens the team */
.team-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0 0.4rem; }
.team-details[open] summary { margin-bottom: 0.25rem; }
/* Columns size to their content: fixed 20% columns clipped "View stats" on a phone. */
.roster-view { width: 100%; }
.roster-view td:last-child .btn-link { white-space: nowrap; }
/* Push the Stats column (header + "View stats" button) flush to the far right. */
.roster-view th:last-child, .roster-view td:last-child { text-align: right; }

/* Former players (left the team): listed after the current ones, dimmed. */
.roster-view td.roster-subhead { padding-top: 0.9rem; font-style: italic; text-align: left; }
tr.former td { color: var(--text-dim); }
/* "rename" on My Teams and the roster page: a ghost button that opens an inline form. */
.rename-dd { margin-right: auto; margin-left: 0.6rem; }
.rename-dd > summary { list-style: none; display: inline-block; }
.rename-dd > summary.ghost-btn { color: var(--text-dim); font-size: 0.85rem; }
.rename-dd > summary::-webkit-details-marker { display: none; }
.ghost-btn {
  cursor: pointer; color: var(--text-dim); border: 1px solid var(--grey);
  border-radius: 6px; padding: 0.45rem 0.9rem; font-weight: 600;
}
.rename-dd[open] > summary { display: none; }
.rename-form { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.rename-form input { min-width: 16rem; }
.roster-title { display: flex; align-items: center; gap: 0.4rem; }
.roster-title .rename-dd { margin-right: 0; }
.roster-msg { margin: -0.4rem 0 0.8rem; }
.paste-roster { margin-top: 0.6rem; }
.paste-roster > summary { cursor: pointer; }
.paste-roster textarea { width: 100%; box-sizing: border-box; font: inherit; resize: vertical; }
.new-season > summary { cursor: pointer; }
.season-picks { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin-top: 0.6rem; }
.season-picks label { display: flex; align-items: center; gap: 0.35rem; color: var(--text);
  white-space: nowrap; margin: 0; font-size: 0.95rem; }
.season-picks input[type="checkbox"] { width: auto; margin: 0; }

/* Button-styled link (e.g. "Edit roster") */
.btn-link {
  background: var(--mint);
  color: var(--on-accent);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}
.btn-link:hover { background: var(--mint-bright); }

/* Stats: game-selection checkboxes */
.game-checks { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.game-check { display: inline-flex; align-items: center; color: var(--text); font-size: 0.9rem; cursor: pointer; }
.game-check input { width: auto; margin-right: 0.35rem; }

/* Keyboard shortcut legend on the tagging form */
.legend {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--grey);
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.9;
}
.legend .keys {
  display: inline-block;
  background: var(--grey);
  color: var(--mint-bright);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  margin: 0 0.15rem 0 0.6rem;
  font-family: monospace;
}

/* --- Video library --- */
.lib-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.lib-actions { display: flex; align-items: center; gap: 0.6rem; }
.upload-dd { position: relative; }
.upload-dd > summary { list-style: none; cursor: pointer; }
.upload-dd > summary::-webkit-details-marker { display: none; }
.upload-pop {
  position: absolute;
  right: 0;
  top: 120%;
  width: 320px;
  z-index: 10;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.video-card {
  display: block;
  background: var(--dark-grey);
  border: 1px solid var(--grey);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
}
.video-card:hover { border-color: var(--mint); }
/* Thumbnails are painted by thumbs.js into an <img> (see that file for why we
   no longer hang a <video preload="metadata"> on every card). Until one arrives
   the box shows a play glyph, so the grid never jumps as frames fill in. */
.video-thumb {
  background: var(--court-rect);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-thumb img.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb:empty::after { content: "\25B6"; color: var(--text-dim); font-size: 1.5rem; }
.video-meta { padding: 0.6rem 0.7rem; display: flex; align-items: center; gap: 0.5rem; }
.meta-text { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
/* Watch / Tag actions on each library card */
.card-actions { display: flex; gap: 0.5rem; padding: 0 0.7rem 0.7rem; }
.card-actions .btn-link { flex: 1; text-align: center; }
.card-actions .secondary { background: transparent; color: var(--text-dim); border: 1px solid var(--grey); }
.card-actions .secondary:hover { background: var(--grey); color: var(--text); }
.video-title { font-weight: 600; }
.video-team { margin-top: 0.15rem; }

/* Selectable cards on the Stats picker */
.video-card.selectable { position: relative; cursor: pointer; }
.video-card.selectable .card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  z-index: 2;
  cursor: pointer;
}
.video-card.selected { border-color: var(--mint); box-shadow: 0 0 0 2px var(--mint) inset; }

/* "See stats" action bar (appears once videos are selected) */
.stats-actionbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--dark-grey);
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

/* Card link + 3-dot menu (menu lives in the meta row, beside the name/team) */
.video-card { position: relative; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-menu { position: relative; flex: 0 0 auto; }
.card-menu-btn {
  background: none;
  color: var(--text-dim);
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.card-menu-btn:hover { background: var(--grey); color: var(--mint-bright); }
.card-menu-pop {
  display: none;
  position: absolute;
  right: 0;
  bottom: 32px;            /* open upward, above the button */
  background: var(--grey);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  min-width: 110px;
  overflow: hidden;
  z-index: 4;
}
.card-menu-pop.open { display: block; }
.card-menu-pop button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 0.45rem 0.7rem;
  font: inherit;
  border-radius: 0;
  cursor: pointer;
}
.card-menu-pop button:hover { background: var(--dark-grey); color: var(--mint-bright); }
.card-menu-pop form { margin: 0; }

/* Edit dialog */
.edit-dialog {
  background: var(--dark-grey);
  color: var(--text);
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 1.2rem;
  min-width: 320px;
}
.edit-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

/* Upload progress rows */
.upload-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0; }
.upload-name { flex: 0 0 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row progress { flex: 1; }
.yt-import { border-top: 1px solid var(--border-2); padding-top: 0.7rem; }
.yt-import textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.upload-row .upload-cancel, .upload-row .upload-retry { padding: 0.1rem 0.5rem; }

/* Game tagging view top bar */
.game-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.game-bar-title { flex: 1; }

/* Profile header: name left, position/games same style on the right, team underneath */
.profile-head { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.profile-head h1 { margin: 0; font-size: 1.8rem; }
/* Prev/next player arrows (squared off to match the rest of the UI) */
.player-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 6px;
  background: var(--grey);
  border: 1px solid var(--border-2);
  color: var(--text);
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1;
  padding-bottom: 4px;            /* the ← / → glyph sits low; nudge it to optical center */
  flex: 0 0 auto;
}
.player-arrow:hover { background: var(--mint); border-color: var(--mint); color: var(--on-accent); }
.profile-meta {
  margin-left: auto;                 /* right-justify */
  color: var(--text);
  font-size: 1.8rem;                 /* match the name */
  font-weight: 600;
}
.profile-team { margin-top: 0.2rem; }

/* Profile tabs */
.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--grey); margin-bottom: 1rem; }
.tabs .tab {
  background: none;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 600;
}
.tabs .tab:hover { color: var(--mint-bright); }
.tabs .tab.active { color: var(--mint); border-bottom-color: var(--mint); }

/* Visual tab layout */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  align-items: start;
}
/* Heat maps (attack/serve landing locations) — two wide court cards below the grid */
.heat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}
.heat-court {
  width: 100%;
  height: auto;
  display: block;
  background: var(--black);
  border-radius: 6px;
  margin-top: 0.5rem;
}
/* Translucent blobs stack additively so dense landing zones read as brighter "heat". */
.heat-blobs { mix-blend-mode: screen; }
/* Blob colors live here (not in profile.js) so the courts re-theme with the switcher. */
.hg-good stop { stop-color: var(--mint); }
.hg-bad stop { stop-color: var(--error); }
.hg-neutral stop { stop-color: var(--text-dim); }

/* Attack trajectories: a line from contact to landing, colored by outcome, ending in a
   shape that says how the ball was hit (X = spike, circle = tip/jam, triangle = other).
   Each element carries an outcome class that sets --traj-c for both stroke and fill. */
.traj-good { --traj-c: var(--mint); }
.traj-bad { --traj-c: var(--error); }
.traj-neutral { --traj-c: var(--text); }
.traj-key { --traj-c: var(--text-dim); }
.traj-line {
  stroke: var(--traj-c);
  stroke-width: 1.1;
  stroke-opacity: 0.5;
  stroke-linecap: round;
}
.traj-mark {
  stroke: var(--traj-c);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.traj-mark.filled { fill: var(--traj-c); fill-opacity: 0.85; }
.shape-chip { width: 12px; height: 12px; display: inline-block; vertical-align: -2px; }
/* Trajectories / Heat switch on the attack card */
.viz-toggle { display: inline-flex; border: 1px solid var(--grey); border-radius: 6px; overflow: hidden; }
.viz-btn { background: transparent; color: var(--text-dim); border: none; border-radius: 0; padding: 0.25rem 0.65rem; font-size: 0.75rem; font-weight: 600; }
.viz-btn + .viz-btn { border-left: 1px solid var(--grey); }
.viz-btn:hover:not(.active) { background: var(--grey); color: var(--text); }
.viz-btn.active { background: var(--mint); color: var(--on-accent); }
.heat-legend { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.5rem; }
.heat-legend .leg { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-dim); }
.heat-legend .leg .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.heat-legend .leg .dot.sw-good { background: var(--mint); }
.heat-legend .leg .dot.sw-bad { background: var(--error); }
.heat-legend .leg .dot.sw-neutral { background: var(--text-dim); }
/* In the trajectory view an in-play attack is a white line, so its swatch matches. */
.heat-legend.lines .leg .dot.sw-neutral { background: var(--text); }
.heat-legend.shapes { margin-top: 0.35rem; }
.heat-legend .leg b { color: var(--text); font-weight: 700; }
.heat-legend .leg.clickable { cursor: pointer; }
.heat-legend .leg.clickable:hover { color: var(--text); }
.heat-legend .leg.empty { opacity: 0.5; }
.heat-note { text-align: center; margin-top: 0.4rem; }

/* ---- Trends: small multiples, one stat per chart -------------------------------
   Each chart carries ONE series, so the title names it and no legend is needed.
   Colors are tokens, so the charts follow the theme switcher. */
.trend-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.trend-scope { display: flex; flex-direction: column; gap: 0.2rem; }
.trend-scope label { margin: 0; }
.trend-scope select { min-width: 200px; max-width: 100%; }
.trend-crumb { margin-top: 0; }
.trend-table-head { margin-top: 1.6rem; }

.trend-grid {
  display: grid;
  /* min() so a card can never be wider than the screen it's on -- a bare 300px
     minimum pushes the page sideways below ~350px. */
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.trend-card { padding: 0.8rem 0.9rem 0.6rem; }
.trend-title {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
/* Group kicker: "Errors" alone is ambiguous across Attack/Serve/Dig/Block. */
.trend-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.trend-empty { margin: 0.6rem 0 0.2rem; }
.trend-svg { width: 100%; height: auto; display: block; }
.trend-svg.drillable .tr-hit { cursor: pointer; }

/* Recessive scaffolding, prominent data. */
.tr-grid { stroke: var(--border-2); stroke-width: 0.6; opacity: 0.5; }
.tr-zero { stroke: var(--text-dim); stroke-width: 0.9; stroke-dasharray: 3 2; opacity: 0.8; }
.tr-cross { stroke: var(--text-dim); stroke-width: 0.8; opacity: 0.7; pointer-events: none; }
.tr-line { fill: none; stroke: var(--mint); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* A 2px surface ring keeps overlapping points readable where a line doubles back. */
.tr-dot { fill: var(--mint); stroke: var(--dark-grey); stroke-width: 1.4; }
.tr-tick, .tr-xlab { fill: var(--text-dim); font-size: 8px; }
/* Values wear text ink, never the series color. */
.tr-last { fill: var(--text); font-size: 9.5px; font-weight: 700; }
.tr-hit { fill: transparent; }

.tr-rowsub { font-size: 0.75rem; }

/* Shared hover tooltip for every small multiple. */
.trend-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--dark-grey);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  max-width: 260px;
}
.trend-tip .tt-head { font-weight: 700; margin-bottom: 0.2rem; }
.trend-tip .tt-sub { color: var(--text-dim); font-weight: 400; }
.trend-tip .tt-row { display: flex; gap: 0.8rem; justify-content: space-between; }
.trend-tip .tt-row span { color: var(--text-dim); }
.trend-tip .tt-hint { color: var(--text-dim); font-size: 0.72rem; margin-top: 0.25rem; }

/* Serve stat strip (Serve % / Efficiency / Avg pass) */
.stat-strip { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.stat-mini {
  flex: 1;
  text-align: center;
  background: var(--grey);
  border-radius: 6px;
  padding: 0.5rem 0.3rem;
}
.sm-val { font-size: 1.15rem; font-weight: 700; color: var(--mint-bright); }
.sm-lbl { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.15rem; }
.stat-box.clickable { cursor: pointer; }
.stat-box.clickable:hover { background: rgba(62, 180, 137, 0.18); }

/* Blocking "Total blocks" headline (where a doughnut center would sit) */
.block-headline .stat-mini {
  background: var(--grey);
  border-radius: 6px;
  padding: 0.6rem;
  text-align: center;
}
.big-stat .sm-val { font-size: 1.8rem; }

/* Hitting-% doughnut */
.viz-card h2 { margin-top: 0; }
.donut-wrap { width: 240px; max-width: 100%; margin: 0.5rem auto 0; }
.donut { width: 100%; height: auto; display: block; }
.donut-seg { cursor: pointer; transition: stroke-width 0.12s ease; }
.donut-seg:hover { stroke-width: 24; }
.donut-num { fill: var(--on-accent); font-size: 8px; font-weight: 700; pointer-events: none; }
.donut-center { fill: var(--text); font-size: 17px; font-weight: 700; }
#donut-caption { text-align: center; font-size: 0.95rem; }

/* --- Video + tagger side-by-side layout --- */
.tag-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;            /* stacks on narrow screens */
}
.tag-video { flex: 1 1 520px; min-width: 320px; }
.tag-video video { max-height: 70vh; }
.undo-btn { padding: 0.2rem 0.55rem; font-size: 0.8rem; }
.table-scroll { overflow-x: auto; }          /* a wide row scrolls the table, not the page */
/* Not enough room for the video and the tagger side by side (a phone, a tablet held
   upright): the video stays pinned at the top while the buttons scroll under it, so a
   play is watched and tagged without scrolling up and down for each one; the tagger
   takes the full width. */
@media (max-width: 900px) {
  .tag-layout { display: block; }
  .tag-layout > .tag-video {
    position: sticky; top: 0; z-index: 20; min-width: 0;
    background: var(--black); padding-bottom: 0.35rem;
  }
  .tag-layout > .tag-video video { max-height: 30vh; width: 100%; }
  .tag-layout > .tag-panel {
    position: static; max-height: none; overflow: visible; margin-top: 0.6rem;
  }
}
@media (max-width: 520px) {               /* the saved tags fit a phone without scrolling */
  #tags-table th, #tags-table td { padding: 0.35rem 0.3rem; font-size: 0.85rem; }
  #tags-table .delete-btn, #tags-table .confirm-btn { padding: 0.2rem 0.4rem; }
}
/* No keyboard on a touch screen: the key list is just noise there. */
@media (hover: none) and (pointer: coarse) { .keys-legend { display: none; } }

/* Action timeline beneath the video (multitrack-style lanes) */
.timeline { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.tl-labels { flex: 0 0 64px; display: flex; flex-direction: column; }
.tl-label {
  height: 26px;
  line-height: 26px;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-tracks {
  position: relative;
  flex: 1;
  background-color: var(--dark-grey);
  /* faint horizontal line between channels (every 24px) */
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 23px, var(--grey) 23px, var(--grey) 24px);
  border: 1px solid var(--grey);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
}
/* an action "clip" spanning ~1s, with its action name on the bar */
.tl-clip {
  position: absolute;
  height: 18px;        /* top is set per lane in JS */
  min-width: 4px;
  border-radius: 3px;
  opacity: 0.9;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 5px;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-clip:hover { opacity: 1; outline: 1px solid var(--mint-bright); }
.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;                /* window is centered on the playhead */
  width: 2px;
  margin-left: -1px;
  background: var(--mint-bright);
  pointer-events: none;
  z-index: 2;
}
.tag-panel {
  flex: 0 0 300px;
  margin-top: 0;
  max-height: 78vh;
  overflow-y: auto;          /* scrolls if the buttons overflow */
  position: sticky;
  top: 1rem;
}
.tag-panel h2 { margin-top: 0; }

/* Breadcrumb of the in-progress tag (click a chip to step back) */
.tag-breadcrumb { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.tag-breadcrumb .chip {
  background: var(--grey);
  border: 1px solid var(--mint);
  color: var(--mint-bright);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.step-label { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 0.5rem; letter-spacing: 0.03em; }

/* Button grid used for player / action / result choices */
.btn-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tagbtn {
  flex: 1 1 calc(33% - 0.5rem);
  min-width: 70px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--grey);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.1;
}
/* The background MUST be restated here. The generic `button:hover` rule sets
   background to --mint-bright, and this rule sets the text to --mint-bright --
   so without it a hovered tag button is mint text on mint, i.e. blank. That hit
   every button in the tagger, not just the clips editor. */
.tagbtn:hover {
  background: var(--grey);
  border-color: var(--mint);
  color: var(--mint-bright);
}
.tagbtn.muted { color: var(--text-dim); font-weight: 500; }
/* The tagger is a wizard, so it never needs to show a current value. Correcting
   a tag does: you must be able to see what it is now before changing it. */
.tagbtn.active {
  border-color: var(--mint);
  color: var(--mint-bright);
  box-shadow: inset 0 0 0 1px var(--mint);
}
.tagbtn .bnum { font-size: 1.25rem; }
.tagbtn .bname { font-size: 0.7rem; color: var(--text-dim); font-weight: 400; }

.tag-extra { margin-top: 0.75rem; }
.tag-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }

/* Court trajectory step (attacks & serves) */
.court { width: 100%; height: auto; background: var(--black); border-radius: 6px; cursor: crosshair; touch-action: none; }
/* The playable free zone around the court — a lighter "floor" tone, clearly distinct from
   the panel background, so out-of-bounds plays are easy to see. */
.court-oob { fill: var(--court-floor); }
/* The in-bounds court: darker, mint-tinted, with a bright sideline so it reads as the court. */
.court-rect { fill: var(--court-rect); stroke: var(--court-line); stroke-width: 1; }
.court-net { stroke: var(--mint); stroke-width: 1.4; }
.court-attackline { stroke: var(--text-dim); stroke-width: 0.6; stroke-dasharray: 3 2; }
.court-start { fill: var(--mint); }
.court-end { fill: var(--error); }
.court-traj { stroke: var(--mint-bright); stroke-width: 1.4; }
.court-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
/* Set back view: draggable arc apex + the net-height reference label */
.court.backview { cursor: pointer; }
.court-apex { fill: var(--mint-bright); stroke: var(--black); stroke-width: 0.8; cursor: grab; }
.bv-netlabel { fill: var(--text-dim); font-size: 6px; }
.bv-antenna { stroke: var(--flag); stroke-width: 3.2; stroke-linecap: round; }
.bv-antenna-tip { fill: var(--flag); }
.bv-net { fill: rgba(230, 230, 230, 0.07); stroke: var(--text-dim); stroke-width: 0.4; }

/* ---- Court Vision: the calibrated court overlay drawn ON the video ---- */
.cv-host { position: relative; }            /* .tag-video, so the overlay can position over it */
.cv-overlay {
  position: absolute;
  pointer-events: none;                     /* clicks pass through unless we're calibrating/tagging */
  z-index: 3;
}
.cv-overlay.interactive { pointer-events: auto; cursor: crosshair; }
.cv-strip { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.35rem; }
.cv-strip button { padding: 0.25rem 0.6rem; }
.cv-strip .hint { font-size: 0.75rem; }
/* Lines map straight->straight; off-frame corners get clipped at the picture edge (correct). */
.cv-line { stroke: var(--mint-bright); stroke-width: 2; fill: none; opacity: 0.9; }
.cv-net { stroke: var(--mint); stroke-width: 2.5; }
.cv-attackline { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 6 4; opacity: 0.7; }
.cv-netband { fill: rgba(62, 180, 137, 0.18); stroke: none; }
.cv-marker { fill: var(--mint); stroke: var(--black); stroke-width: 1.5; }
.cv-marker.pending { fill: var(--flag); }
.cv-marker.net { fill: var(--mint-bright); }

/* The Court Vision control panel (below the video) */
.cv-toggle-btn { margin-left: auto; }
.cv-panel {
  margin-top: 0.6rem;
  padding: 0.7rem 0.8rem;
  background: var(--dark-grey);
  border: 1px solid var(--border-2);
  border-radius: 8px;
}
.cv-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.cv-frames, .cv-pts { list-style: none; padding: 0; margin: 0.3rem 0; font-size: 0.85rem; }
.cv-frames li, .cv-pts li { padding: 0.15rem 0; }
.cv-frames em { color: var(--mint); font-style: normal; }
.cv-calib { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: flex-start; }
.cv-side { flex: 1 1 200px; min-width: 180px; }
.cv-mini { width: 240px; max-width: 100%; height: auto; background: var(--black); border-radius: 6px; cursor: default; }
.cv-mini-rect { fill: var(--court-rect); stroke: var(--court-line); stroke-width: 1; }
.cv-mini-net { stroke: var(--mint); stroke-width: 1.2; }
.cv-mini-atk { stroke: var(--text-dim); stroke-width: 0.6; stroke-dasharray: 3 2; }
.cv-dot { fill: var(--text-dim); cursor: pointer; }
.cv-dot.used { fill: var(--mint); }
.cv-dot.arm { fill: var(--flag); cursor: pointer; }
.cv-dot.arm:hover { fill: var(--mint-bright); }
.cv-panel .link {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 0.78rem; padding: 0 0.2rem; text-decoration: underline;
}
.cv-panel .link:hover { color: var(--error); }
.cv-panel .hint.error { color: var(--error); }

/* Clip list items in the scrollable Clips column */
.clip-item {
  border: 1px solid var(--grey);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.clip-item:hover { border-color: var(--mint); }
.clip-item.active { border-color: var(--mint); background: rgba(62, 180, 137, 0.12); }
.clip-row1 { display: flex; align-items: center; gap: 0.5rem; }
.clip-idx {
  flex: 0 0 auto;
  background: var(--grey);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
}
.clip-row1 .timestamp { text-decoration: none; }
.clip-meta { color: var(--text); font-size: 0.85rem; font-weight: 600; }
.clip-row2 { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.2rem; }

/* --- Stats box score --- */
.table-scroll { overflow-x: auto; }            /* let the wide box score scroll sideways */
.boxscore { text-align: center; border-collapse: collapse; }
.boxscore th, .boxscore td {
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
  border-right: 1px solid var(--grey);        /* thin vertical line between every column */
}
.boxscore thead th { color: var(--text-dim); font-weight: 600; }
.boxscore .grp-head { color: var(--mint); border-bottom: 2px solid var(--mint); }
.boxscore td.lbl, .boxscore th.lbl {
  text-align: left;
  border-right: 3px solid var(--mint);        /* separate player names from the numbers */
}
/* Alternating row shading for readability */
.boxscore tbody tr:nth-child(odd) { background: var(--dark-grey); }
.boxscore tbody tr:nth-child(even) { background: var(--grey); }
/* thick divider between skill sections (set on the last column of each group by JS) */
.boxscore .grp-end { border-right: 3px solid var(--mint); }
.boxscore tbody tr:hover { background: rgba(62, 180, 137, 0.18); }
.boxscore tfoot .totals td { border-top: 2px solid var(--mint); font-weight: 700; color: var(--mint-bright); }
/* Opponent total: muted, set apart from our team's mint total below it. */
.boxscore tfoot .opp-total td { border-top: 1px solid var(--grey); font-weight: 600; color: var(--text-dim); }

/* clickable stat cells -> open the matching clips */
.boxscore td.clickable { cursor: pointer; }
.boxscore td.clickable:hover { color: var(--mint-bright); background: rgba(62, 180, 137, 0.16); }

.hidden-col { display: none; }                 /* columns turned off in the picker */

/* Columns toolbar + modal */
.table-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.6rem; }
.columns-dialog {
  background: var(--dark-grey);
  color: var(--text);
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 1.2rem;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.columns-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; }

/* Column picker */
.picker-groups { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.75rem; }
.picker-group { min-width: 150px; }
.picker-head { color: var(--mint); font-weight: 600; font-size: 0.8rem; margin-bottom: 0.3rem; }
.picker-item { display: block; color: var(--text); font-size: 0.85rem; margin-bottom: 0.2rem; cursor: pointer; }
.picker-item input { width: auto; margin-right: 0.4rem; }

/* --- clip retagging ------------------------------------------------------ */
/* An AI tag is visibly marked because its numbers already count in the box
   score; the badge is how you tell a checked figure from an unchecked one. */
.clip-ai {
  margin-left: auto;
  white-space: nowrap;   /* "AI 38%" must not wrap inside its pill */
  flex: 0 0 auto;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  color: var(--flag);
  border: 1px solid var(--flag);
}
.clip-row2 { display: flex; align-items: center; gap: 0.4rem; }
.clip-edit {
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  margin-left: 0.4rem;
}
/* Always visible, deliberately. A hover-only control does not exist at all on
   a touch screen, and the film gets watched on a tablet. It is also the only
   hint that a tag can be corrected here, so hiding it hides the feature. */
.clip-item .clip-edit { opacity: 0.8; }
.clip-item:hover .clip-edit,
.clip-item .clip-edit:focus-visible { opacity: 1; }
.clip-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-2);
}
.clip-editor { display: block; }          /* sections stack; grids wrap inside */
.clip-edit-section + .clip-edit-section { margin-top: 0.5rem; }
.clip-editor .step-label { font-size: 0.72rem; }
.clip-editor .tagbtn { min-height: 40px; min-width: 54px; padding: 0.3rem; }
.clip-editor .tagbtn .bnum { font-size: 1rem; }
.clip-editor .e-msg { margin-left: 0.25rem; }

/* --- AI attribution card + Saved-tags column (game.html) ------------------------- */
.ai-stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.25rem 0 1rem; }
.ai-stat {
  flex: 1 1 9rem; background: var(--dark-grey); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 0.6rem 0.8rem; display: flex; flex-direction: column;
}
.ai-stat b { font-size: 1.6rem; color: var(--mint-bright); line-height: 1.1; }
.ai-stat b small { font-size: 0.95rem; color: var(--text-dim); font-weight: 500; }
.ai-stat span { color: var(--text-dim); font-size: 0.82rem; }
.ai-stat.bad b { color: var(--error); }
.ai-stat.dim b { color: var(--text); }
.ai-actions { width: 100%; max-width: 34rem; border-collapse: collapse; margin-bottom: 0.5rem; }
.ai-actions th, .ai-actions td { text-align: left; padding: 0.2rem 0.6rem 0.2rem 0; font-size: 0.9rem; }
.ai-actions th { color: var(--text-dim); font-weight: 500; }
.ai-bar-cell { width: 40%; }
.ai-bar { display: block; height: 0.5rem; background: var(--grey); border-radius: 999px; overflow: hidden; }
.ai-bar > span { display: block; height: 100%; background: var(--mint); }
.ai-col { text-align: center; }
.ai { display: inline-block; min-width: 1.6rem; padding: 0 0.35rem; border-radius: 999px;
      font-size: 0.8rem; font-weight: 600; line-height: 1.4; cursor: default; }
.ai-agree { color: var(--mint-bright); }
.ai-disagree { background: var(--error); color: var(--on-accent); }
.ai-suggest { border: 1px dashed var(--mint); color: var(--mint-bright); }
.ai-held { color: var(--text-dim); }

/* --- AI draft tags (tools/actions/draft.py): unchecked until confirmed or retagged --- */
.draft-badge { display: inline-block; padding: 0 0.35rem; border: 1px dashed var(--flag);
               border-radius: 4px; color: var(--flag); font-size: 0.72rem; font-weight: 700;
               line-height: 1.35; }
tr.ai-draft td { color: var(--text-dim); }
/* a save in flight: no second tap (app.js oneAtATime) */
body.tag-saving #step-buttons button, body.tag-saving .draft-card button { pointer-events: none; opacity: 0.6; }
.tag-problem { margin: 0.5rem 0 0; padding: 0.5rem 0.65rem; border-radius: 6px; border: 1px solid var(--error);
               color: var(--text); background: var(--grey); font-size: 0.85rem; }
.set-step { padding: 0 0.35rem; min-width: 0; font-size: 1rem; line-height: 1; }
.match-window { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.85rem; }
.clips-ai-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
                flex-wrap: wrap; border: 1px dashed var(--flag); border-radius: 8px;
                padding: 0.45rem 0.6rem; margin-bottom: 0.6rem; font-size: 0.85rem; }
tr.ai-draft td:first-child { box-shadow: inset 3px 0 0 var(--flag); }
.confirm-btn { color: var(--mint-bright); margin-right: 0.3rem; }
.tl-clip.ai { opacity: 0.55; outline: 1px dashed var(--flag); outline-offset: -1px; }
.draft-card { border: 1px dashed var(--flag); border-radius: 8px; padding: 0.6rem 0.75rem;
              margin-bottom: 0.75rem; background: var(--grey); }
.draft-card .draft-what { font-weight: 600; }
.draft-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 0.25rem; }
.draft-results { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.draft-choice { flex: 1 1 4.5rem; }
.draft-choice.draft-player { display: flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 0.35rem 0.3rem; }
.draft-choice.draft-player small { font-size: 0.68rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* while the AI card is up it is the whole tagger */
#tagger.card-open #tag-side, #tagger.card-open #tag-breadcrumb, #tagger.card-open #step-label,
#tagger.card-open #step-buttons, #tagger.card-open #tag-extra, #tagger.card-open #tag-reset { display: none !important; }
.draft-result { flex: 1 1 auto; }
.draft-card kbd { font-size: 0.72rem; opacity: 0.75; margin-left: 0.25rem; }
.draft-card .hint { margin: 0; font-size: 0.8rem; }

/* --- Rotational stats (stats.html) ------------------------------------------------ */
.rot-filter { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.rot-filter select { margin-left: 0.4rem; }
.rot-table tr.rot-on td { background: var(--grey); }
.warn-text { color: var(--flag); }

/* --- Accounts: landing, log in, set up, account menu ---------------------------------- */
header .brand { text-decoration: none; }
header details.account { position: relative; margin-left: 1.25rem; }
header details.account summary { cursor: pointer; list-style: none; color: var(--text-dim); }
header details.account summary::-webkit-details-marker { display: none; }
header details.account[open] summary { color: var(--mint-bright); }
.account-menu {
  position: absolute; right: 0; top: 2rem; z-index: 20; min-width: 12rem;
  display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem 0.9rem;
  background: var(--dark-grey); border: 1px solid var(--border-2); border-radius: 8px;
}
.account-menu a { color: var(--text); text-decoration: none; }
.account-menu a:hover { color: var(--mint-bright); }
.account-menu form .btn-link { width: 100%; }
a.account { color: var(--mint); text-decoration: none; font-weight: 600; }
.auth-card { max-width: 26rem; margin: 2rem auto; display: flex; flex-direction: column; gap: 0.5rem; }
.auth-card input { width: 100%; }
.auth-card button { margin-top: 0.5rem; }
.auth-error { color: var(--error); margin: 0; }
/* Account: a club's members and invitation links (owners only) */
.account-msg { margin: 0 0 0.8rem; }
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }
.inline-form select { width: auto; padding: 0.25rem 0.4rem; }
.members-table { width: 100%; }
.members-table .member-actions { text-align: right; white-space: nowrap; }
.members h3 { margin: 1.2rem 0 0.5rem; }
.invite-list { list-style: none; padding: 0; margin: 0.6rem 0 0; color: var(--text-dim); font-size: 0.9rem; }
.invite-list li { margin: 0.3rem 0; }
.pager { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0; }
.auth-ok { color: var(--mint-bright); margin: 0; }
pre.token { background: var(--black); border: 1px solid var(--border-2); border-radius: 6px;
            padding: 0.6rem; white-space: pre-wrap; word-break: break-all; color: var(--text); }
.hero { max-width: 46rem; margin: 3rem auto 2rem; text-align: center; }
.hero h1 { font-size: 2.2rem; line-height: 1.2; margin-bottom: 0.75rem; }
.hero-sub { color: var(--text-dim); font-size: 1.1rem; line-height: 1.5; }
.hero-cta { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; align-items: center; }
.hero-cta .btn-link { padding: 0.6rem 1.4rem; font-size: 1rem; }
.cta-secondary { color: var(--mint-bright); text-decoration: none; font-weight: 600; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
            gap: 1rem; max-width: 64rem; margin: 0 auto 3rem; }
.feature { background: var(--dark-grey); border: 1px solid var(--grey); border-radius: 8px; padding: 1rem 1.2rem; }
.feature h3 { margin: 0 0 0.4rem; color: var(--mint); }
.feature p { margin: 0; color: var(--text-dim); line-height: 1.5; }
@media (max-width: 640px) { .hero h1 { font-size: 1.6rem; } }

/* --- Home (signed-in dashboard) -------------------------------------------------------- */
.home-head h1 { margin-bottom: 0.2rem; }
.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.home-stat { background: var(--dark-grey); border: 1px solid var(--grey); border-radius: 8px;
             padding: 0.7rem 0.9rem; display: flex; flex-direction: column; text-decoration: none; }
a.home-stat:hover { border-color: var(--mint); }
.home-stat b { font-size: 1.6rem; color: var(--mint-bright); line-height: 1.15; }
.home-stat span { color: var(--text-dim); font-size: 0.85rem; }
.home-section-head { display: flex; align-items: baseline; justify-content: space-between; }
.home-section-head a { text-decoration: none; }
.home-result { margin-top: 0.2rem; font-weight: 600; }
.result-w { color: var(--mint-bright); margin-right: 0.3rem; }
.result-l { color: var(--error); margin-right: 0.3rem; }
.home-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; margin-bottom: 2rem; }
.home-link { background: var(--dark-grey); border: 1px solid var(--grey); border-radius: 8px;
             padding: 0.8rem 1rem; text-decoration: none; display: flex; flex-direction: column; gap: 0.2rem; }
.home-link:hover { border-color: var(--mint); }
.home-link b { color: var(--mint); }
.home-link span { color: var(--text-dim); font-size: 0.88rem; }
.card-actions .btn-link { white-space: nowrap; }
.auth-links { display: flex; gap: 0.9rem; align-items: center; }
.auth-links .account { margin-left: 0; }
a.account-signup { background: var(--mint); color: var(--on-accent); padding: 0.25rem 0.75rem; border-radius: 6px; }
