/* RLStratBoard — dark theme default (UX-5), touch-first (UX-1/2), smartboard profile (UX-3) */
:root {
  --bg: #10141f;
  --panel: #1a2130;
  --panel-2: #232c40;
  --line: #313d58;
  --text: #e8ecf5;
  --text-dim: #93a0bb;
  --accent: #ffd54a;      /* Regina gold */
  --blue: #3d9dff;
  --orange: #ff8a2a;
  --danger: #ff4d5e;
  --tap: 46px;            /* min touch target */
  --radius: 10px;
}
/* Smartboard profile: large viewport → bigger chrome (UX-3) */
@media (min-width: 1900px) and (min-height: 950px), (pointer: coarse) and (min-width: 1500px) {
  :root { --tap: 60px; }
  body { font-size: 18px; }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none;
  overflow: hidden;
}

#app {
  display: grid; height: 100dvh;
  grid-template-areas: "top top" "pal board" "anim anim";
  grid-template-rows: auto 1fr auto;
  grid-template-columns: auto 1fr;
}

/* ---------- Top bar ---------- */
#topbar {
  grid-area: top; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
  z-index: 20;
}
#brand-logo { height: calc(var(--tap) - 6px); width: auto; border-radius: 8px; margin-left: -2px; }
#brand-bp { height: calc(var(--tap) - 6px); width: auto; border-radius: 8px; }

/* ---------- BoostPad.gg intro splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 300; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 10vh 10vw; box-sizing: border-box;
  transition: opacity .45s ease;
}
#splash img { width: 100%; height: 100%; object-fit: contain; animation: sp-in .7s ease-out both; }
#splash .sp-sub { color: #93a0bb; font: 600 14px/1 system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; animation: sp-in .7s .3s ease-out both; }
#splash.hide { opacity: 0; pointer-events: none; }
/* Invisible hotspots over Splash6.png's baked-in buttons — geometry set as
   inline left/top/width/height by js/main.js (positionSplashHotspots()),
   fixed (not absolute) so the numbers are plain viewport pixels straight
   from the image's own getBoundingClientRect(), no offsetParent/padding
   math to duplicate. */
.splash-hotspot { position: fixed; background: transparent; border: 0; padding: 0; cursor: pointer; z-index: 1; }
@keyframes sp-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #splash img, #splash .sp-sub { animation: none; } #splash { transition: none; } }

/* ---------- post-login transition (Regina crest + loading bar) ---------- */
#login-transition {
  position: fixed; inset: 0; z-index: 300; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
}
#login-transition.hidden { display: none; }
#login-transition img { width: min(30vw, 30vh); height: auto; }
#login-transition .lt-bar { width: min(40vw, 360px); height: 8px; border-radius: 4px; background: rgba(255,255,255,.14); overflow: hidden; }
#login-transition .lt-bar-fill { width: 0%; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #45bdf5, #ffd54a); transition: width 3s linear; }
#board-name {
  font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#board-name:hover, #board-name:focus { background: var(--panel-2); outline: none; }
#board-name.unsaved::after { content: " · unsaved"; color: var(--accent); font-weight: 500; font-size: 12px; }
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-spacer { flex: 1; }

.tb-btn {
  min-height: var(--tap); min-width: var(--tap); padding: 4px 14px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tb-btn:active { transform: scale(.96); }
.tb-btn.toggle.on { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.tb-btn.small { min-width: 40px; min-height: 40px; padding: 2px 8px; }
.tb-btn:disabled { opacity: .35; cursor: default; }

#btn-account.on { border-color: var(--accent); color: var(--accent); }
#btn-library.pending-sync::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent);
}
#btn-library { position: relative; }
#btn-save.unsaved { border-color: var(--accent); color: var(--accent); }

.tray-btn { position: relative; padding: 4px 10px; }
.car-chip, .ball-chip { display: inline-block; width: 26px; height: 18px; border-radius: 5px; }
.car-chip { background: center / contain no-repeat; }
.car-chip.blue { background-image: url('../assets/car-blue.png'); }
.car-chip.orange { background-image: url('../assets/car-orange.png'); }
.ball-chip { width: 20px; height: 20px; border-radius: 50%; background: #cfd6e4 url('../assets/ball.png') center / cover no-repeat; }
.tray-count {
  position: absolute; top: 2px; right: 4px; font-size: 11px; color: var(--text-dim); font-weight: 700;
}

/* ---------- Left palette ---------- */
#palette {
  grid-area: pal; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 20; scrollbar-width: none;
}
.pal-btn {
  width: var(--tap); height: var(--tap); border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.pal-btn svg { width: 55%; height: 55%; fill: currentColor; stroke: currentColor; }
.pal-btn img { width: 62%; height: 62%; object-fit: contain; }
.pal-btn.active img { filter: brightness(0.25); }
.pal-btn.active { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.pal-btn.danger { color: var(--danger); }
.pal-btn:active { transform: scale(.94); }
.pal-sep { width: 70%; height: 1px; background: var(--line); margin: 4px 0; }

#colors { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.color-btn {
  width: calc(var(--tap) / 2 + 6px); height: calc(var(--tap) / 2 + 6px);
  border-radius: 50%; border: 2px solid var(--line); background: var(--c); cursor: pointer;
}
.color-btn.active { border-color: var(--text); box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
#stroke-opts { display: flex; gap: 6px; }

/* player name label size slider */
#label-size { display: flex; flex-direction: column; align-items: center; gap: 1px; }
#label-size .ls-a { font-size: 11px; font-weight: 800; color: var(--text-dim); line-height: 1; }
#label-size input {
  width: calc(var(--tap) + 6px); margin: 0; accent-color: var(--accent); cursor: pointer;
}

/* ---------- Board ---------- */
#board-wrap { grid-area: board; position: relative; overflow: hidden; background: var(--bg); }
#bg-canvas, #main-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#main-canvas { touch-action: none; }

/* ---------- Context bar ---------- */
#ctxbar {
  position: absolute; display: flex; gap: 4px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 30;
}
#ctxbar button {
  min-width: var(--tap); min-height: var(--tap); border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: 19px; cursor: pointer;
}
#ctxbar button.danger { color: var(--danger); }
#ctxbar button:active { transform: scale(.94); }

/* ---------- Floating editor ---------- */
#float-edit {
  position: absolute; z-index: 40; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 6px;
}
#float-input {
  font: inherit; font-size: 17px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 190px;
  user-select: text; -webkit-user-select: text;
}
#role-chips { display: flex; gap: 6px; }
#role-chips button {
  flex: 1; min-height: 40px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font-weight: 700; cursor: pointer;
}
/* FR-406: play notes */
#btn-notes.has-notes { border-color: var(--accent); color: var(--accent); }
#notes-form { display: flex; flex-direction: column; gap: 4px; }
.notes-label { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-top: 6px; }
#notes-form textarea {
  font: inherit; font-size: 13px; width: 100%; resize: vertical; padding: 6px 10px;
  border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}

/* FR-407: side-elevation strip */
#side-strip {
  position: absolute; left: 10px; right: 10px; bottom: 10px; height: 148px;
  width: calc(100% - 20px); z-index: 6; touch-action: none;
}

/* FR-404: symbol drawer v2 */
#popover.drawer { width: 340px; max-width: 92vw; }
#popover.drawer #sym-q {
  font: inherit; width: 100%; min-height: 38px; padding: 4px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
#sym-list { overflow-y: auto; }
.sym-cat { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); padding: 8px 2px 4px; }
.sym-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#popover .sym {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 62px;
  padding: 6px 4px; font-size: 11px; text-align: center;
}
#popover .sym img, #popover .sym i { width: 30px; height: 30px; display: block; }
#popover .sym i canvas { display: block; }
#popover .sym span { line-height: 1.15; }

#ko-role-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 280px; }
#ko-role-chips button {
  min-height: 36px; padding: 3px 10px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: #ffd54a; font-weight: 600; font-size: 13px; cursor: pointer;
}
#roster-chips {
  display: flex; flex-wrap: wrap; gap: 6px; max-width: 280px;
  max-height: 132px; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 6px;
}
#roster-chips button {
  min-height: 40px; padding: 4px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--accent); font-weight: 600; cursor: pointer;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Film room ---------- */
#modal.film { width: min(1100px, 96vw); }
.film-count { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-left: 8px; }
.film-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.film-tools input[type="search"] {
  flex: 1 1 200px; min-width: 150px; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
}
.film-tools select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; cursor: pointer;
}
#film-cal-btn {
  font: inherit; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px; cursor: pointer;
}
#film-cal-btn.on { background: var(--accent); border-color: var(--accent); }
#film-cal {
  margin-top: 10px; padding: 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px; max-width: 340px;
}
.fcal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fcal-head button {
  font: inherit; font-weight: 700; color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; cursor: pointer;
}
.fcal-title { font-weight: 800; flex: 1; text-align: center; }
#fcal-clear { color: var(--accent); border-color: var(--accent); font-size: 12px; }
.fcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.fcal-dow { font-size: 11px; color: var(--text-dim); text-align: center; padding: 2px 0; }
.fcal-day {
  position: relative; text-align: center; padding: 7px 0; border-radius: 8px;
  font: inherit; font-size: 13px; color: var(--text-dim); border: 1px solid transparent;
}
.fcal-day.has {
  color: var(--text); font-weight: 700; cursor: pointer;
  background: rgba(255, 213, 74, 0.14); border-color: rgba(255, 213, 74, 0.45);
}
.fcal-day.has:hover { border-color: var(--accent); }
.fcal-day.sel { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.fcal-day.has i {
  position: absolute; top: 1px; right: 3px; font-style: normal;
  font-size: 9px; font-weight: 800; opacity: 0.85;
}

#film-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px; margin-top: 12px;
}
.film-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; cursor: pointer;
}
.film-card:hover { border-color: var(--accent); }
.fc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fc-map { font-weight: 700; }
.fc-badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.fc-badge.win { background: rgba(64, 200, 110, .18); color: #4ade80; }
.fc-badge.loss { background: rgba(255, 77, 94, .18); color: #ff8a94; }
.fc-score { font-size: 20px; margin: 6px 0 2px; }
.fc-score .blue, .film-player-head .blue, .film-table caption.blue { color: #3d9dff; }
.fc-score .orange, .film-player-head .orange, .film-table caption.orange { color: #ff8a2a; }
.fc-ff { font-size: 11px; color: var(--text-dim); margin-left: 6px; }
.fc-teams { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-teams em { color: var(--text); font-style: normal; font-weight: 700; }
.fc-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.film-empty { color: var(--text-dim); padding: 24px 4px; }
.film-player-head { align-items: center; gap: 10px; }
.film-player-head h2 { margin: 0; }
#film-back {
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; cursor: pointer;
}
#film-stage { position: relative; margin-top: 10px; overflow: hidden; border-radius: 12px; touch-action: none; }
#film-video { display: block; width: 100%; max-height: 62dvh; border-radius: 12px; background: #000; }
#film-draw {
  position: absolute; left: 0; top: 0; cursor: crosshair; touch-action: none;
  border-radius: 12px 12px 0 0;
}
#film-draw-tools {
  position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; align-items: center;
  background: rgba(16, 20, 31, 0.82); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 7px; backdrop-filter: blur(6px);
}
#film-draw-tools button {
  font: inherit; min-width: 34px; min-height: 34px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
#film-draw-tools button.active { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.fd-colors { display: flex; gap: 5px; padding: 0 3px; }
.fd-color {
  min-width: 22px !important; min-height: 22px !important; width: 22px; height: 22px;
  border-radius: 50% !important; background: var(--c) !important; border: 2px solid var(--line) !important;
}
.fd-color.active { border-color: #fff !important; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
#film-zoom-tools {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; align-items: center;
  background: rgba(16, 20, 31, 0.82); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 7px; backdrop-filter: blur(6px);
}
#film-zoom-tools button {
  font: inherit; min-width: 34px; min-height: 34px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
#fz-level { font-size: 12px; color: var(--text-dim); min-width: 30px; text-align: center; }
#film-zoom-ctrl {
  position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 10px;
  align-items: center; background: rgba(16, 20, 31, 0.82); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 10px; backdrop-filter: blur(6px);
}
#film-zoom-ctrl button {
  font: inherit; min-width: 40px; min-height: 36px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
#fzc-scrub { flex: 1; min-width: 0; touch-action: none; accent-color: var(--accent); }
#fzc-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
#film-events { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
#film-timeline {
  position: relative; height: 22px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
}
#ftl-played {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: rgba(255, 255, 255, .09); border-radius: 11px 0 0 11px; pointer-events: none;
}
.ftl-mark {
  position: absolute; top: 3px; bottom: 3px; width: 8px; margin-left: -4px;
  border-radius: 3px; background: var(--text-dim); cursor: pointer;
}
.ftl-mark.blue { background: #3d9dff; }
.ftl-mark.orange { background: #ff8a2a; }
.ftl-mark:hover { filter: brightness(1.3); }
#film-ev-types { display: flex; flex-wrap: wrap; gap: 6px; }
.fev-type {
  font: inherit; font-size: 12px; min-height: 30px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--line);
  cursor: pointer; opacity: .55;
}
.fev-type.on { color: var(--text); opacity: 1; border-color: var(--accent); }
#film-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip img { width: 14px; height: 14px; }
.fev-type img { width: 16px; height: 16px; vertical-align: -4px; }
.fchip i { display: inline-flex; align-items: center; }
.fchip {
  font: inherit; font-size: 11px; display: inline-flex; align-items: center; gap: 4px;
  min-height: 28px; padding: 2px 8px 2px 6px; border-radius: 7px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-left-width: 3px; cursor: pointer;
}
.fchip.blue { border-left-color: #3d9dff; }
.fchip.orange { border-left-color: #ff8a2a; }
.fchip:hover { background: var(--panel); }
.fchip.cur { outline: 2px solid var(--accent); outline-offset: -1px; }
.film-info { color: var(--text-dim); font-size: 13px; margin: 8px 2px; }
.fc-unread { font-size: 11.5px; font-weight: 700; color: var(--accent); background: rgba(255,213,74,.16); border-radius: 999px; padding: 2px 8px; }
#film-comments { margin: 4px 2px 14px; }
#film-comments #fc-add { min-height: var(--tap); padding: 4px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }
#fc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fc-thread { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; }
.fc-post { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fc-post .fc-body { flex-basis: 100%; margin-top: 2px; white-space: pre-wrap; }
.fc-reply { margin: 6px 0 0 22px; padding-top: 6px; border-top: 1px solid var(--line); }
.fc-time { font: 700 12px/1 system-ui, sans-serif; color: var(--accent); background: rgba(255,213,74,.12); border-radius: 6px; padding: 4px 8px; min-height: 30px; }
.fc-time:hover { background: rgba(255,213,74,.22); }
.fc-hide { margin-left: auto; color: var(--text-dim); min-height: 30px; padding: 2px 8px; }
.fc-hide:hover { color: var(--danger); }
.fc-replybtn { margin-top: 6px; color: var(--blue); font-size: 12.5px; min-height: 30px; padding: 2px 4px; }
#fc-composer {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 2px; padding: 10px; border: 1px solid var(--accent);
  border-radius: 10px; background: var(--panel-2);
}
#fc-composer span { flex-basis: 100%; font-size: 12.5px; color: var(--text-dim); }
#fc-composer textarea { flex: 1; min-width: 200px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; }
.film-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.film-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.film-table caption { text-align: left; font-weight: 800; padding-bottom: 4px; }
.film-table th, .film-table td { text-align: left; padding: 4px 8px; border-top: 1px solid var(--line); }
.film-table th { color: var(--text-dim); font-weight: 600; border-top: none; }

/* ---------- Popover / modal / toast ---------- */
#popover {
  position: absolute; z-index: 50; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.55);
  display: flex; flex-direction: column; gap: 6px; min-width: 220px;
  max-height: 76dvh; overflow-y: auto;
}
#popover button {
  min-height: var(--tap); border-radius: 9px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; padding: 6px 14px; text-align: left;
}
#popover button.danger { color: var(--danger); }
#popover .po-title { font-size: 13px; color: var(--text-dim); padding: 2px 4px; }

/* icon-picker grid mode */
#popover.grid { display: grid; grid-template-columns: repeat(4, 1fr); min-width: 300px; }
#popover.grid .po-title { grid-column: 1 / -1; }
#popover.grid button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 600;
}
#popover.grid button img { width: 34px; height: 30px; object-fit: contain; }
#popover.grid button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

#modal-scrim {
  position: fixed; inset: 0; background: rgba(5,8,15,.6); z-index: 60;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
/* #modal-frame is a bare positioning anchor sized to #modal's own box (its
   only in-flow child) so #modal-x can sit pinned at its corner regardless
   of #modal's dynamic width/height/scroll position — see modal.js's
   comment on #modal-x for why it lives outside #modal itself. */
#modal-frame { position: relative; max-width: 96vw; max-height: 84dvh; }
#modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; width: min(560px, 92vw); max-height: 84dvh; overflow-y: auto;
  box-shadow: 0 12px 50px rgba(0,0,0,.6);
}
#modal h2, #analytics h2 { font-size: 19px; margin-bottom: 12px; }
#modal h2 { padding-right: 34px; }
#modal-x {
  position: absolute; top: -12px; right: -12px;
  width: 32px; height: 32px; min-height: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim); font-size: 15px; line-height: 1; cursor: pointer; z-index: 1;
}
#modal-x:hover { color: var(--text); border-color: var(--accent); }
#modal .row, #analytics .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
#modal button, #modal .file-label, #analytics button, #analytics .file-label {
  min-height: var(--tap); border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; padding: 8px 16px; display: inline-flex; align-items: center; gap: 8px;
}
#modal button.primary, #analytics button.primary { background: var(--accent); color: #1c1500; border-color: var(--accent); }
#modal button.danger, #analytics button.danger { color: var(--danger); }
#modal input[type=text], #modal input[type=password], #modal input[type=email],
#analytics input[type=text], #analytics input[type=password], #analytics input[type=email] {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; flex: 1; user-select: text; -webkit-user-select: text;
}
.copy-code { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.copy-code:hover { filter: brightness(1.2); }
.acct-name { cursor: pointer; }
.acct-name:hover { text-decoration: underline dotted; text-underline-offset: 3px; color: var(--accent); }
.acct-ava, .acct-ava-big {
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  vertical-align: middle; background: var(--panel-2); border: 1px solid var(--line);
}
.acct-ava { width: 26px; height: 26px; border-radius: 50%; margin-right: 6px; }
.acct-ava-big { width: 64px; height: 64px; border-radius: 14px; font-size: 26px; flex: 0 0 auto; }
.acct-ava img, .acct-ava-big img { width: 100%; height: 100%; object-fit: cover; }
#modal label.check, #analytics label.check { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
#modal input[type=checkbox], #analytics input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

.board-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.board-item {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
}
.board-item:hover { border-color: var(--accent); }
.board-item img { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; background: #0b0e16; }
.board-item .bi-meta { flex: 1; min-width: 0; }
.board-item .bi-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-item .bi-date { font-size: 12px; color: var(--text-dim); }
.board-item .bi-actions { display: flex; gap: 6px; }
.board-item .bi-actions button { min-height: 40px; min-width: 40px; padding: 4px 10px; }

/* ---------- animation bar (FR-301..304) ---------- */
#animbar {
  grid-area: anim; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line);
  z-index: 20; overflow-x: auto; scrollbar-width: thin;
}
.an-btn {
  min-width: var(--tap); min-height: var(--tap); border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.an-btn.toggle.on, .an-btn.on { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.an-btn:active { transform: scale(.95); }
#an-scrub { flex: 0 1 220px; min-width: 90px; accent-color: var(--accent); }
#an-time { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
#frames-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
#an-dur-wrap { display: flex; align-items: center; gap: 4px; color: var(--text-dim); font-size: 13px; white-space: nowrap; }
#an-dur { width: 90px; min-width: 70px; accent-color: var(--accent); }
#an-dur-val { min-width: 34px; }
.frame-chip {
  min-width: 52px; min-height: calc(var(--tap) - 4px); border-radius: 10px;
  background: var(--panel-2); border: 2px solid var(--line); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 2px 6px;
}
.frame-chip.sel { border-color: var(--accent); background: #33291a; }
.fc-n { font-weight: 800; font-size: 16px; }
.fc-d { font-size: 11px; color: var(--text-dim); }

/* playback caption (FR-308) */
#anim-caption {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  max-width: 80%; background: rgba(10, 14, 22, .82); color: var(--text);
  padding: 12px 26px; border-radius: 14px; font-size: 20px; font-weight: 600;
  text-align: center; pointer-events: none; z-index: 25;
}
body.present #anim-caption { font-size: 30px; bottom: 120px; }

/* presentation mode (FR-305): chrome hidden, giant controls */
body.present #topbar, body.present #palette, body.present #animbar,
body.present #ctxbar, body.present #float-edit { display: none !important; }
body.present #app { grid-template-areas: "board board"; grid-template-rows: 1fr; }
#present-controls {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center; z-index: 30;
  background: rgba(16, 20, 31, .85); padding: 12px 20px; border-radius: 20px;
  border: 1px solid var(--line); backdrop-filter: blur(6px);
}
body:not(.present) #present-controls { display: none; }
#present-controls button {
  min-width: 76px; min-height: 76px; font-size: 30px; border-radius: 16px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
#present-controls #pr-exit { min-width: 56px; min-height: 56px; font-size: 20px; }
#present-controls input { width: min(420px, 40vw); accent-color: var(--accent); }

/* team management pills & membership toggles */
.team-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; font-weight: 600;
}
.team-pill button {
  min-width: 36px; min-height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer;
}
.team-pill button.danger { color: var(--danger); }
.team-toggle {
  min-height: 40px; padding: 6px 16px; border-radius: 999px; font: inherit; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim); cursor: pointer;
}
.team-toggle.on { background: var(--accent); border-color: var(--accent); color: #1c1500; }
.roster-group { width: 100%; font-size: 12px; color: var(--text-dim); margin-top: 2px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  padding: 12px 22px; border-radius: 12px; z-index: 100; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); pointer-events: none;
  transition: opacity .25s;
}

.hidden { display: none !important; }

/* Narrow / portrait: palette docks to bottom */
@media (max-width: 740px), (orientation: portrait) and (max-width: 1100px) {
  /* minmax(0,1fr): content min-size must never push the column past the viewport */
  #app { grid-template-areas: "top" "board" "pal"; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); }
  #palette {
    flex-direction: row; border-right: none; border-top: 1px solid var(--line);
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));   /* clear the iOS home indicator */
    overflow-x: auto; overflow-y: hidden;
  }
  #palette > * { flex: 0 0 auto; }   /* tools must never crush — the bar scrolls instead */
  .pal-sep { width: 1px; height: 70%; margin: 0 4px; }
  #colors { grid-template-columns: repeat(5, 1fr); }
  #topbar { flex-wrap: wrap; }
  #board-name { max-width: 40vw; }
}

/* ---------- Phase 6: 3D arena view (view3d.js) ---------- */
#view3d-bar {
  position: absolute; top: 10px; right: 10px; z-index: 30;
  display: none; gap: 6px; align-items: center;
  background: rgba(16, 20, 31, 0.72); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; backdrop-filter: blur(6px);
}
#view3d-bar button {
  min-height: var(--tap); padding: 6px 12px; border-radius: 9px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  font: 600 13px/1 system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
#view3d-bar button:active { background: var(--accent); color: #1c1500; }
#view3d-bar button.on { background: var(--accent); color: #1c1500; }
/* 3D edit mode: the content canvas becomes a transparent interaction overlay
   stacked above the GL canvas (chrome stays higher at z-index 20+) */
#main-canvas.edit3d { z-index: 5; }
#view3d-bar button.danger { color: #ff8a94; }
body.present #view3d-bar { display: none !important; }

/* ---------- Film ⧉ Board split view (U4 bridge) ---------- */
body.film-split #app { margin-left: min(44vw, 780px); }
body.film-split #modal-scrim {
  pointer-events: none; background: transparent; backdrop-filter: none;
  justify-content: flex-start; align-items: stretch;
}
body.film-split #modal, body.film-split #modal.film {
  pointer-events: auto; width: min(44vw, 780px); max-height: 100dvh;
  border-radius: 0; border-top: 0; border-bottom: 0; border-left: 0;
  box-shadow: 4px 0 24px rgba(0,0,0,.5);
}
#film-split-btn.on { border-color: var(--accent); color: var(--accent); }
/* split view needs room for both halves — phones keep the full-screen film room */
@media (max-width: 900px) { #film-split-btn, #film-trace-btn { display: none; } }

/* ---------- play assignments + read receipts ---------- */
#btn-library.has-assign::after {
  content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
#btn-library { position: relative; }
.asn-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0;
  background: var(--panel-2);
}
.asn-item.clickable { cursor: pointer; }
.asn-item.clickable:hover { border-color: var(--accent); }
.asn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.asn-head b { font-size: 14px; }
.asn-head button[data-close] { min-height: 30px; padding: 2px 10px; font-size: 12px; margin-left: auto; }
.asn-team { color: var(--text-dim); font-size: 12px; }
.asn-note { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.asn-viewers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.asn-v {
  font-size: 12px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--text-dim);
}
.asn-v.ok { color: #7ce38b; border-color: rgba(124,227,139,.4); }
.asn-new {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  background: var(--accent); color: #1c1500;
}
#modal select, #analytics select { min-height: var(--tap); border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font: inherit; padding: 6px 10px; }

/* ---------- kickoff picker quick row (U1 speed pass) ---------- */
#popover.ko { width: 290px; }
.ko-quick {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.ko-quick button {
  flex: 0 1 auto; width: auto; min-height: 38px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--panel-2);
  font-size: 13px; font-weight: 600;
}
.ko-quick button.active { border-color: var(--accent); color: var(--accent); }
.ko-row { display: flex; align-items: center; }
.ko-row button:first-child { flex: 1; }
.ko-row .ko-pin { width: 40px; flex: none; color: var(--text-dim); font-size: 15px; }
.ko-row .ko-pin.on { color: var(--accent); }

/* ---------- Phase 5: live sessions ---------- */
#btn-live.on { border-color: #ff4d5e; color: #ff4d5e; }
.live-code { font-family: ui-monospace, monospace; color: var(--accent); letter-spacing: 2px; font-size: 16px; margin-left: 8px; }
.live-dim { color: var(--text-dim); font-size: 13px; }
.live-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.live-row i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.live-row b { font-size: 14px; }
.live-marker { color: var(--accent); font-size: 12px; font-weight: 700; }
.live-btn { margin-left: auto; min-height: 32px !important; padding: 2px 10px !important; font-size: 12px !important; }
.live-ptr {
  position: absolute; z-index: 15; pointer-events: none;
  transform: translate(-50%, -50%); transition: opacity .4s, left .09s linear, top .09s linear;
  display: flex; align-items: center; gap: 5px;
}
.live-ptr i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.6); }
.live-ptr span {
  font-size: 11px; font-weight: 700; color: #fff; background: rgba(10,14,22,.75);
  padding: 1px 7px; border-radius: 10px; white-space: nowrap;
}

/* ---------- film clip bar ---------- */
#film-clip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 2px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2);
}
#film-clip #fcl-range { font-family: ui-monospace, monospace; font-size: 13px; color: var(--accent); }
#film-clip input { flex: 1; min-width: 120px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* ---------- Team Hub (TH1) ---------- */
.hub-head { align-items: center; gap: 12px; }
.hub-head h2 { margin: 0; }
.hub-season { color: var(--text-dim); font-size: 13px; font-weight: 500; margin-left: 6px; }
.hub-tabs { display: flex; gap: 4px; }
.hub-tabs button { min-height: 36px !important; padding: 4px 14px !important; }
.hub-tabs button.active { border-color: var(--accent); color: var(--accent); }
.hub-next {
  border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; margin: 8px 0;
  background: rgba(255,213,74,.06); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.hub-nav { align-items: center; }
.hub-nav .hub-range { font-size: 14px; }
.hub-day { border-top: 1px solid var(--line); padding: 4px 0; }
.hub-day.today .hub-day-h { color: var(--accent); }
.hub-day-h { font-size: 12px; font-weight: 700; color: var(--text-dim); padding: 4px 2px; text-transform: uppercase; letter-spacing: .4px; }
.hub-empty { color: var(--text-dim); padding: 2px 8px; font-size: 12px; }
.hub-ev {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin: 4px 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.hub-ev.match, .hub-ev.tournament { border-color: rgba(255,213,74,.5); }
.hub-ev-time { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-dim); min-width: 110px; }
.hub-ev-main { flex: 1; min-width: 140px; }
.hub-ev-title { font-size: 14px; font-weight: 600; }
.hub-ev-sub { font-size: 12px; color: var(--text-dim); }
.hub-official { color: var(--accent); font-size: 11px; font-weight: 700; }
.hub-rsvp { display: flex; gap: 4px; }
.hub-rsvp button { min-height: 40px; min-width: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 15px; }
.hub-rsvp button.on { border-color: var(--accent); background: rgba(255,213,74,.14); }
.hub-tally { font-size: 12px; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.hub-ev-ops { display: flex; gap: 4px; }
.hub-ev-ops button { min-height: 40px; min-width: 40px; }
.hub-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 8px; }
.hub-cell { min-height: 62px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 5px; font-size: 11px; }
.hub-cell.hd { min-height: auto; border: 0; color: var(--text-dim); font-weight: 700; text-align: center; }
.hub-cell.out { opacity: .35; }
.hub-cell.today { border-color: var(--accent); }
.hub-cell i { font-style: normal; color: var(--text-dim); }
.hub-cell b { font-size: 14px; margin-left: 2px; }
.hub-foot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
#hub-push.on { border-color: var(--accent); color: var(--accent); }
.hub-report { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.hub-rep-row {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 8px; align-items: center;
  padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px;
}
.hub-rep-row:first-child { border-top: 0; }
.hub-rep-head { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; background: var(--panel-2); }
.hub-report.cols-5 .hub-rep-row { grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; }
.hub-report.cols-6 .hub-rep-row { grid-template-columns: 1fr 1.2fr 0.8fr 1.2fr 1fr 1.2fr; }
.hub-report.cols-7 .hub-rep-row { grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr 1fr 1.1fr 1fr; }
.hub-nav input[type=date] { min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: inherit; padding: 2px 6px; }
.hub-nav select { min-height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: inherit; padding: 2px 6px; }
.hub-chip { border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 150px; }
.hub-chip b { display: block; font-size: 22px; line-height: 1.3; }
.hub-chip span { color: var(--text-dim); font-size: 12px; }
.chart-box { position: relative; height: 280px; margin: 10px 0 18px; overflow: hidden; }
.chart-box.tall { height: 420px; }
.chart-box canvas { max-width: 100%; }
.hub-roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 8px; }
.hub-player { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); }
.hub-p-head { display: flex; align-items: center; gap: 8px; }
.hub-p-head b { font-size: 15px; }
.hub-p-head button { margin-left: auto; min-height: 40px; min-width: 40px; }
.hub-num { color: var(--accent); font-weight: 700; }
.hub-result-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 800;
  margin-right: 6px; color: #fff;
}
.hub-result-badge.win { background: #2ea043; }
.hub-result-badge.loss { background: var(--danger); }
.hub-result-badge.tie { background: var(--text-dim); }
.att-mark {
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 8px;
  color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--line);
}
.att-mark.on { color: #2ea043; border-color: #2ea043; background: rgba(46,160,67,.12); }
.hub-dim { color: var(--text-dim); font-size: 12px; }
.hub-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.hub-tag { font-size: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 1px 9px; }
.hub-link { font-size: 12px; color: var(--accent); }
.hub-notes { font-size: 12px; color: var(--text-dim); border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }

/* ---------- Team Hub TH2: announcements, threads, assign bar ---------- */
#btn-hub { position: relative; }
#btn-hub.has-unread::after {
  content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
#hub-ann-dot { color: var(--accent); font-weight: 700; }
.hub-compose textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  resize: vertical;
}
.hub-anns { margin-top: 10px; }
.hub-ann {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0;
  background: var(--panel-2);
}
.hub-ann.fam { border-color: rgba(124,227,139,.45); }
.hub-ann-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hub-ann-head button { margin-left: auto; min-height: 38px !important; padding: 2px 12px !important; font-size: 12px !important; }
.hub-fam-chip { font-size: 11px; font-weight: 700; color: #7ce38b; }
.hub-ann-body { margin-top: 6px; font-size: 14px; white-space: pre-wrap; }
.hub-th { min-height: 38px; min-width: 42px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.hub-thread { max-height: 44dvh; overflow-y: auto; margin: 8px 0; }
.hub-cmt { border-top: 1px solid var(--line); padding: 8px 2px; font-size: 14px; }
.hub-cmt.hidden-cmt { opacity: .45; }
.hub-cmt button { float: right; min-height: 36px !important; padding: 1px 10px !important; font-size: 11px !important; }
#film-assign {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 2px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2);
}
#film-assign input[type=text] { flex: 1; min-width: 140px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.asn-due { font-size: 12px; color: var(--accent); }
.asn-due.late { color: var(--danger); }
#modal input[type=date], #modal input[type=datetime-local], #modal input[type=number],
#analytics input[type=date], #analytics input[type=datetime-local], #analytics input[type=number] {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}

/* ---------- Home / landing dashboard (js/home.js) ---------- */
#home {
  position: fixed; inset: 0; z-index: 45; background: var(--bg);
  display: none; overflow-y: auto; overflow-x: hidden;
  touch-action: pan-y; -webkit-overflow-scrolling: touch;
  background-image: radial-gradient(1100px 500px at 75% -80px, rgba(61,157,255,.10), transparent 65%),
                    radial-gradient(700px 400px at 15% 110%, rgba(255,213,74,.05), transparent 60%);
}
body.home-open #home { display: block; }

.hm-top {
  display: flex; align-items: center; gap: 20px; padding: 12px 26px;
  border-bottom: 1px solid var(--line); background: rgba(16,20,31,.85);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px);
}
.hm-brand { display: flex; align-items: center; gap: 12px; }
.hm-brand img { height: 58px; border-radius: 12px; }
.hm-brand img.bp { margin-right: -4px; }
.hm-word { font-size: 26px; font-weight: 800; letter-spacing: .2px; line-height: 1.1; }
.hm-word span { color: var(--accent); }
.hm-sub { font-size: 13px; color: var(--text-dim); }
.ic {
  width: 1.15em; height: 1.15em; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto;
}
/* min-width:0 overrides flexbox's default min-width:auto, which otherwise
   refuses to shrink a flex item below its content's own width — without it,
   overflow-x:auto below never actually engages (the nav just grows past its
   allotted space instead of scrolling within it), clipping the right-most
   buttons off-screen entirely on any viewport too narrow for all nine. */
.hm-nav { display: flex; gap: 2px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.hm-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font: 600 14px/1 system-ui, sans-serif; padding: 10px 14px; border-radius: 10px;
  border-bottom: 3px solid transparent; white-space: nowrap; gap: 6px;
}
.hm-nav .ic { width: 26px; height: 26px; }
.hm-nav button:hover { color: var(--text); background: var(--panel-2); }
.hm-nav button.on { color: var(--accent); border-bottom-color: var(--accent); }
.hm-user {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); padding: 10px 18px; cursor: pointer; font: inherit; min-height: 52px;
}
.hm-user.has-ava { padding-left: 8px; }
.hm-user:hover { border-color: var(--accent); }
.hm-user-txt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.hm-user b { font-size: 15px; }
.hm-user .hm-role { font-size: 12px; color: var(--text-dim); text-transform: capitalize; }
.hm-ava {
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--panel); display: flex;
}
.hm-ava img { width: 100%; height: 100%; object-fit: cover; }

.hm-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; padding: 26px 26px 8px;
}
.hm-hero h1 { font-size: 30px; letter-spacing: .2px; }
.hm-hero p { color: var(--text-dim); margin-top: 6px; max-width: 520px; }
.hm-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.hm-chip {
  display: flex; align-items: center; gap: 10px; font: inherit; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); padding: 10px 14px; cursor: pointer;
}
.hm-chip:hover { border-color: var(--accent); }
.hm-chip.alert { border-color: var(--accent); }
.hm-chip b { display: block; font-size: 13px; }
.hm-chip span { font-size: 12px; color: var(--text-dim); }
.hm-chip > .ic { width: 20px; height: 20px; color: var(--accent); }

.hm-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 14px; padding: 18px 26px;
}
.hm-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
/* equal head height keeps the artwork on one line across cards; the CTA is
   pinned to the bottom so buttons align even when a title wraps */
.hm-card-head { display: flex; gap: 10px; align-items: flex-start; min-height: 92px; }
.hm-card-head h2 { font-size: 17px; }
.hm-card-head p { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.hm-ico {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
}
.hm-ico .ic { width: 20px; height: 20px; }
.tint-blue .hm-ico { color: var(--blue); border-color: rgba(61,157,255,.4); background: rgba(61,157,255,.12); }
.tint-green .hm-ico { color: #5ac878; border-color: rgba(90,200,120,.4); background: rgba(90,200,120,.12); }
.tint-teal .hm-ico { color: #3cc8be; border-color: rgba(60,200,190,.4); background: rgba(60,200,190,.12); }
.tint-purple .hm-ico { color: #9678ff; border-color: rgba(150,120,255,.4); background: rgba(150,120,255,.12); }
.tint-gold .hm-ico { color: var(--accent); border-color: rgba(255,213,74,.45); background: rgba(255,213,74,.12); }
.tint-gold { border-color: rgba(255,213,74,.45); }
/* per-card CTA tints, mirroring the mock's teal / purple / gold buttons */
.tint-teal .hm-cta { background: rgba(60,200,190,.16); border-color: rgba(60,200,190,.55); }
.tint-teal .hm-cta:hover { background: rgba(60,200,190,.28); }
.tint-purple .hm-cta { background: rgba(150,120,255,.16); border-color: rgba(150,120,255,.55); }
.tint-purple .hm-cta:hover { background: rgba(150,120,255,.28); }
.tint-green .hm-cta { background: rgba(90,200,120,.14); border-color: rgba(90,200,120,.5); }
.tint-green .hm-cta:hover { background: rgba(90,200,120,.26); }
.hm-visual {
  position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  /* 16:9 is the floor; artwork absorbs card slack but is capped so the
     landscape screenshots never crop down to a narrow strip */
  aspect-ratio: 16 / 9; flex: 1 1 auto; max-height: 200px; background: var(--panel-2);
}
.hm-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hm-timeline {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 14px;
  align-items: center; padding: 7px 12px; background: rgba(10,14,22,.82);
  font-size: 10px; color: var(--text-dim);
}
.hm-timeline span { flex: 1; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 45%, var(--line) 45%); }
.hm-cta {
  font: 600 14px/1 system-ui, sans-serif; color: var(--text);
  background: rgba(61,157,255,.14); border: 1px solid rgba(61,157,255,.5);
  border-radius: 10px; padding: 12px; cursor: pointer; margin-top: auto;
}
.hm-cta:hover { background: rgba(61,157,255,.25); }
.hm-cta.gold { background: rgba(255,213,74,.14); border-color: rgba(255,213,74,.55); }
.hm-cta.gold:hover { background: rgba(255,213,74,.25); }
.hm-hublist { display: flex; flex-direction: column; gap: 6px; }
.hm-hubrow {
  display: flex; gap: 10px; align-items: center; padding: 7px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
}
.hm-hubrow b { display: block; font-size: 13px; }
.hm-hubrow span { font-size: 12px; color: var(--text-dim); }
.hm-hubrow > .ic { width: 18px; height: 18px; color: var(--text-dim); }

.hm-quick {
  display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; padding: 4px 26px 14px;
}
.hm-quick-label {
  display: flex; align-items: center; font-weight: 700; gap: 6px; padding: 0 10px;
  color: var(--accent);
}
.hm-quick button {
  display: flex; align-items: center; gap: 10px; font: inherit; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); padding: 10px 16px; cursor: pointer; font-size: 17px;
}
.hm-quick button:hover { border-color: var(--blue); }
.hm-q-ic {
  flex: 0 0 auto; width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--blue);
}
.hm-q-ic .ic { width: 17px; height: 17px; }
.hm-quick button b { display: block; font-size: 13px; }
.hm-quick button span { font-size: 11.5px; color: var(--text-dim); }

.hm-panels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px; padding: 4px 26px 20px;
}
.hm-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.hm-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hm-panel-head b { font-size: 14.5px; }
.hm-panel-head button {
  background: none; border: none; color: var(--blue); cursor: pointer; font: 600 12px/1 system-ui, sans-serif;
}
.hm-dim { font-size: 11.5px; color: var(--text-dim); }
.hm-row {
  display: flex; gap: 10px; align-items: center; font: inherit; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 8px 10px; cursor: pointer;
}
.hm-row:hover { border-color: var(--blue); }
.hm-row.static { cursor: default; }
.hm-row.static:hover { border-color: var(--line); }
.hm-row img { width: 56px; height: 34px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.hm-row b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.hm-row span { font-size: 11.5px; color: var(--text-dim); }
.hm-evico { flex: 0 0 auto; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: rgba(61,157,255,.1); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  color: var(--blue); }
.hm-evico img { width: 100%; height: 100%; object-fit: cover; }
.hm-evico .ic { width: 16px; height: 16px; }
.hm-num { color: var(--accent); font-variant-numeric: tabular-nums; }
.hm-empty { color: var(--text-dim); font-size: 13px; padding: 8px 4px; }
.hm-signin { align-items: flex-start; gap: 10px; max-width: 460px; }
.hm-signin p { color: var(--text-dim); font-size: 13.5px; }

.hm-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding: 16px 26px calc(16px + env(safe-area-inset-bottom, 0px));
  color: var(--text-dim); font-size: 12.5px;
}
.hm-foot-brand b { color: var(--accent); }

/* ---------- Sign-in gate + About preview (signed-out #home content) ---------- */
.hm-gate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; flex: 1; min-height: calc(100vh - 200px); padding: 40px 20px; gap: 30px;
}
.hm-gate-hero h1 { font-size: 28px; letter-spacing: .2px; }
.hm-gate-hero p { color: var(--text-dim); margin-top: 8px; max-width: 480px; font-size: 15px; }
.hm-gate-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; }
.hm-gate-btn {
  display: flex; align-items: center; gap: 14px; text-align: left; font: inherit;
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); min-height: 60px; cursor: pointer;
}
.hm-gate-btn:hover { border-color: var(--accent); }
.hm-gate-btn.primary { background: var(--accent); color: #1c1500; border-color: var(--accent); }
.hm-gate-btn.primary:hover { filter: brightness(1.06); }
.hm-gate-btn .hm-ico { background: var(--panel); }
.hm-gate-btn b { display: block; font-size: 15px; }
.hm-gate-btn > div > span { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.hm-gate-btn.primary > div > span { color: rgba(28,21,0,.65); }
.hm-about-badge {
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--accent);
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 20px; white-space: nowrap;
}
.hm-cta:disabled { opacity: .5; cursor: default; }
.hm-cta:disabled:hover { background: rgba(61,157,255,.14); }

/* header sizes step down so all nine nav items always fit: large (smartboard/desktop),
   medium (laptops), icons-only with tooltips (small laptops/tablets) */
@media (max-width: 1500px) {
  .hm-nav button { font-size: 12.5px; padding: 9px 10px; }
  .hm-nav .ic { width: 22px; height: 22px; }
  .hm-brand img { height: 50px; }
  .hm-word { font-size: 23px; }
}
@media (max-width: 1300px) {
  .hm-nav span { display: none; }
  .hm-nav button { padding: 10px 12px; }
  .hm-nav .ic { width: 25px; height: 25px; }
  .hm-brand img { height: 46px; }
}
@media (max-width: 900px) {
  .hm-nav span { display: none; }
  .hm-nav button { font-size: 15px; padding: 8px 9px; }
  .hm-hero h1 { font-size: 23px; }
  .hm-hero, .hm-cards, .hm-quick, .hm-panels, .hm-foot { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 600px) {
  .hm-top { padding: 8px 12px; gap: 8px; }
  .hm-sub, .hm-user .hm-role { display: none; }
  .hm-user.has-ava .hm-user-txt { display: none; }   /* avatar alone on phones */
  .hm-user.has-ava { padding: 5px; }
  .hm-cards, .hm-panels { grid-template-columns: 1fr; }
  .hm-card-head { min-height: 0; }   /* full-width cards need no head padding */
  .hm-quick button { flex: 1 1 40%; }
  .hm-quick-label { width: 100%; padding: 0; }
  /* panel-head "Open"/"View all"/etc links: text-only at 12px/1 line-height
     is a ~12px touch target — pad the hit area without shifting the visible
     layout (negative margin cancels the padding's footprint). */
  .hm-panel-head button { padding: 11px 6px; margin: -11px -6px; }
  /* Audit log table: its wrapper (#au-table) already has overflow-x:auto,
     but the <table> itself is inline-styled width:100% — clamped to the
     phone-width wrapper instead of overflowing it, so columns just squeeze
     and clip text instead of the wrapper actually needing to scroll.
     !important is required to beat the inline style's specificity. */
  #au-table table { width: auto !important; min-width: 540px; }
}

/* ---------- Team Playbook (js/playbook.js) — full-screen layer like Home ---------- */
/* Home's own top menu (.hm-top: brand, main nav, account button) stays
   visible and usable above this — same treatment as #analytics below —
   so #playbook sits below that strip rather than covering it. --hm-top-h
   is measured live in home.js (syncHmTopHeight) since its height varies
   by breakpoint/theme; the var()'s fallback covers the instant before
   that first measurement runs. */
#playbook {
  position: fixed; top: var(--hm-top-h, 84px); left: 0; right: 0; bottom: 0;
  z-index: 46; background: var(--bg); display: none;
  flex-direction: column; overflow: hidden; touch-action: pan-y;
  --pb-green: #5ac878; --pb-gold-dim: rgba(255,213,74,.12);
}
body.playbook-open #playbook { display: flex; }
body.playbook-open #home > *:not(.hm-top) { display: none; }
#playbook button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Analytics — its own full page (like Playbook), not a modal: results/
   reports/games are page-shaped content, not a form or a small dialog. */
#analytics {
  position: fixed; top: var(--hm-top-h, 84px); left: 0; right: 0; bottom: 0;
  z-index: 46; background: var(--bg); display: none;
  flex-direction: column; overflow: hidden; touch-action: pan-y;
}
body.analytics-open #analytics { display: flex; }
body.analytics-open #home > *:not(.hm-top) { display: none; }
#analytics button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
#analytics .an-body { flex: 1; overflow-y: auto; padding: 20px 28px 40px; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
#playbook button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pb-top {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex-wrap: wrap;
  background: rgba(16,20,31,.92); border-bottom: 1px solid var(--line); z-index: 3;
}
.pb-tabs { display: flex; gap: 6px; }
.pb-tabs button { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--text-dim); min-height: 34px; }
.pb-tabs button.on { background: var(--accent); color: #1c1500; border-color: var(--accent); font-weight: 700; }
.pb-search { flex: 1 1 200px; max-width: 320px; }
.pb-search input {
  width: 100%; min-height: 36px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; color: var(--text); font: inherit; font-size: 13px;
}
.pb-spacer { flex: 1; }
.pb-btn {
  min-height: 36px; padding: 5px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line) !important;
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pb-btn:hover { border-color: var(--accent) !important; }
.pb-btn.on, .pb-btn.primary { background: var(--accent); color: #1c1500; border-color: var(--accent) !important; }
.pb-btn.pub { background: rgba(90,200,120,.18); border-color: rgba(90,200,120,.6) !important; color: #8fe3a6; }
.pb-btn.warn { background: var(--pb-gold-dim); border-color: rgba(255,213,74,.5) !important; color: var(--accent); cursor: default; }
.pb-btn small { font-weight: 500; opacity: .8; }
.pb-icon { min-width: 36px; min-height: 36px; border-radius: 9px; font-size: 18px; border: 1px solid var(--line); background: var(--panel-2); }
#pb-rail-btn { display: none; }
.pb-user { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 4px; font-size: 13px; min-height: 34px; }
.pb-user img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.pb-user:empty { display: none; }

.pb-cols { flex: 1; display: grid; grid-template-columns: 250px minmax(0,1fr) 230px; min-height: 0; position: relative; }
.pb-rail { border-right: 1px solid var(--line); padding: 12px 10px; font-size: 13.5px; overflow-y: auto; touch-action: pan-y; }
.pb-g { font: 600 10.5px/1 system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); margin: 14px 8px 5px; }
.pb-g:first-child { margin-top: 0; }
.pb-rail button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 8px; border-radius: 8px; color: var(--text-dim); text-align: left; min-height: 38px; }
.pb-rail button:hover { background: var(--panel-2); color: var(--text); }
.pb-rail button.on { background: var(--panel-2); color: var(--text); }
.pb-rail button .n { font-weight: 800; color: var(--accent); width: 22px; flex: none; font-size: 12.5px; }
.pb-rail button .q { width: 22px; text-align: center; flex: none; }
.pb-rail button .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-rail button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
.pb-rail button .dr { font: 700 10.5px/1 system-ui, sans-serif; background: var(--pb-gold-dim); color: var(--accent); border-radius: 999px; padding: 3px 7px; flex: none; }
.pb-rail button .dr.prop { background: rgba(255,138,42,.2); color: var(--orange); }
.pb-rail-plays { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.pb-offline { margin: 10px 8px; font-size: 11.5px; color: var(--orange); }
.pb-scrim { display: none; }

.pb-content { padding: 20px 28px 40px; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.pb-sh { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.pb-sh h2 { font-size: 30px; line-height: 1.1; display: flex; gap: 10px; align-items: baseline; margin: 2px 0 0; }
.pb-sh h2 i { font-style: normal; color: var(--accent); font-size: 20px; font-weight: 800; }
.pb-layer { font-size: 11.5px; color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; }
.pb-filt { margin-left: auto; display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.pb-filt button { padding: 5px 10px; border-radius: 999px; font-size: 12px; color: var(--text-dim); min-height: 30px; }
.pb-filt button.on { background: var(--panel-2); color: var(--text); }
.pb-intro { color: #c9d1e3; font-size: 14.5px; max-width: 68ch; margin-bottom: 14px; position: relative; }
.pb-intro p { margin: 0 0 6px; }
.pb-dim { color: var(--text-dim); font-size: 13px; }
.pb-empty { color: var(--text-dim); padding: 16px 4px; }
.pb-gate { padding: 40px 28px; max-width: 520px; display: flex; flex-direction: column; gap: 10px; }
.pb-gate b { font-size: 20px; }
.pb-gate p { color: var(--text-dim); }

/* blocks */
.pb-blk { position: relative; margin: 0 0 12px; max-width: 900px; }
.pb-blk .md-tw, .pb-tw { overflow-x: auto; border-radius: 10px; }
.pb-rule { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 10px; position: relative; scroll-margin-top: 20px; }
.pb-rule.experimental { border-style: dashed; border-color: rgba(255,213,74,.55); }
.pb-rule.situational { border-color: rgba(61,157,255,.55); }
.pb-rule.retired { opacity: .6; }
.pb-rule.retired h4 { text-decoration: line-through; }
.pb-rule.draft { border-color: var(--accent); }
.pb-rule.flash { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .3s; }
.pb-rule .rh { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pb-rule .code, .pb-ctx .code, .pb-hit .code { font-weight: 800; color: var(--accent); letter-spacing: .04em; background: var(--pb-gold-dim); border-radius: 6px; padding: 1px 7px; font-size: 13.5px; }
.pb-rule h4 { font-size: 18.5px; line-height: 1.2; flex: 1; min-width: 200px; margin: 0; }
.pb-badge { font: 700 10.5px/1 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: 3px 8px; border: 1px solid; white-space: nowrap; }
.pb-badge.default { color: var(--accent); border-color: rgba(255,213,74,.5); }
.pb-badge.experimental { color: var(--accent); border-color: rgba(255,213,74,.5); border-style: dashed; }
.pb-badge.situational { color: var(--blue); border-color: rgba(61,157,255,.55); }
.pb-badge.retired, .pb-badge.def { color: var(--text-dim); border-color: var(--line); }
.pb-badge.dr { color: #1c1500; background: var(--accent); border-color: var(--accent); }
.pb-badge.prop { color: #1c1500; background: var(--orange); border-color: var(--orange); }
.pb-rule .rb { font-size: 14.5px; color: #c9d1e3; margin: 8px 0 6px; max-width: 68ch; }
.pb-rule .rb p, .pb-prose p, .pb-callout p, .hbody p { margin: 0 0 8px; }
.pb-rule .rb em, .pb-prose em { color: var(--text); }
.pb-rule .rb ul, .pb-prose ul, .pb-prose ol { padding-left: 20px; margin: 4px 0 8px; }
.pb-rule .exc { font-size: 13px; color: var(--text-dim); margin: 4px 0 6px; }
.pb-rule .exc summary { cursor: pointer; font-weight: 600; color: var(--text); }
.pb-published { font-size: 13px; color: var(--text-dim); border-top: 1px dashed var(--line); padding-top: 6px; margin: 6px 0; }
.pb-published summary { cursor: pointer; }
.pb-rule .rf { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--text-dim); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; flex-wrap: wrap; }
.pb-conf { letter-spacing: 2px; color: var(--accent); font-size: 11px; }
.pb-conf .o { color: var(--line); }
.rf .sp { flex: 1; }
.pb-stale { color: var(--orange); font-size: 11.5px; border: 1px solid rgba(255,138,42,.5); border-radius: 999px; padding: 1px 7px; }
.pb-mini { color: var(--text-dim); font-size: 12.5px; padding: 5px 9px; border-radius: 7px; border: 1px solid transparent; min-height: 38px; }
.pb-mini:hover { border-color: var(--line); color: var(--text); }
.pb-mini.ok { color: #8fe3a6; border-color: rgba(90,200,120,.5); }
.pb-mini.danger { color: var(--danger); }
.pb-prose { font-size: 14.5px; color: #c9d1e3; max-width: 68ch; position: relative; padding: 2px 0; }
.pb-prose h3, .pb-tablewrap h3, .pb-traffic h3, .pb-mediablock h3 { font-size: 18px; color: var(--text); margin: 8px 0 6px; }
.pb-callout { border-left: 3px solid var(--accent); background: rgba(255,213,74,.07); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 14px; max-width: 68ch; position: relative; }
.pb-callout.later { border-color: #9678ff; background: rgba(150,120,255,.09); }
.pb-callout.warning { border-color: var(--danger); background: rgba(255,77,94,.08); }
.pb-callout .k { font: 700 11px/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); margin-right: 8px; }
.pb-callout p { display: inline; }
.pb-traffic { display: grid; gap: 6px; max-width: 68ch; position: relative; }
.pb-traffic > div { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 14px; }
.pb-traffic .l { width: 13px; height: 13px; border-radius: 50%; flex: none; margin-top: 4px; }
.pb-traffic.big > div { font-size: 22px; padding: 14px 16px; }
.pb-traffic.big .l { width: 20px; height: 20px; margin-top: 6px; }
.pb-tablewrap { position: relative; }
.pb-table, .md-table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pb-table th, .pb-table td, .md-table th, .md-table td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.pb-table th, .md-table th { border-top: 0; background: var(--panel-2); color: var(--text-dim); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }
.pb-table td:first-child { font-weight: 700; white-space: nowrap; }
.pb-table .alt { color: var(--text-dim); font-size: 12.5px; }
.pb-table.vocab td:first-child { white-space: normal; min-width: 150px; }   /* long multi-alias terms wrap on phones */
.pb-rulelink { color: var(--accent); font-weight: 700; text-decoration: underline dotted; padding: 0 2px; }
.pb-from { margin-top: 6px; }
.pb-from button { color: var(--blue); font-size: 12.5px; }
.pb-mediablock { position: relative; }

/* attachments */
.pb-atts { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; align-items: flex-start; }
.pb-att { margin: 0; position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-width: 100%; min-width: 0; }
.pb-atts { max-width: 100%; }
.pb-att.img img { display: block; max-height: 220px; max-width: min(100%, 360px); object-fit: cover; cursor: zoom-in; }
.pb-atts.standalone .pb-att.img img { max-height: 480px; max-width: 100%; }
.pb-att.vid video, .pb-att.yt iframe { display: block; width: 100%; max-width: 420px; aspect-ratio: 16 / 9; background: #000; border: 0; }
.pb-atts.standalone .pb-att.vid video, .pb-atts.standalone .pb-att.yt iframe { width: min(100%, 760px); }
.pb-att figcaption { font-size: 12px; color: var(--text-dim); padding: 5px 8px; }
.pb-boardbtn { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; text-align: left; }
.pb-boardbtn img { width: 96px; height: 60px; object-fit: cover; border-radius: 6px; background: #0b0e16; }
.pb-boardbtn span { font-weight: 600; font-size: 13.5px; }
.pb-boardbtn small { display: block; color: var(--blue); font-weight: 500; font-size: 12px; }
.pb-ytbtn { width: 100%; max-width: 420px; aspect-ratio: 16 / 9; background: #000 center / cover no-repeat; display: flex; align-items: flex-end; padding: 8px; }
.pb-ytbtn span { background: rgba(16,20,31,.85); border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px; }
.pb-att.link a { display: block; padding: 10px 12px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 13.5px; }
.pb-att.link small { display: block; color: var(--text-dim); font-weight: 500; }
.pb-atttools { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; background: rgba(16,20,31,.85); border-radius: 7px; padding: 2px; }
.pb-atttools button { width: 28px; height: 26px; border-radius: 5px; font-size: 13px; }
.pb-atttools button.d { color: var(--danger); }
.pb-addatt { font-size: 12.5px; color: var(--text-dim); border: 1px dashed var(--line) !important; border-radius: 999px; padding: 6px 12px; min-height: 34px; }
.pb-addatt:hover { color: var(--accent); border-color: var(--accent) !important; }
.pb-light img { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; border-radius: 8px; }
.pb-progress { position: fixed; left: 0; top: 0; height: 4px; width: 0; background: var(--accent); z-index: 200; transition: width .2s; }

/* ack bar / pager */
.pb-ack { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13.5px; color: var(--text-dim); max-width: 900px; flex-wrap: wrap; }
.pb-ack .pb-btn { margin-left: auto; }
.pb-bottom { display: none; }

/* context panel */
.pb-ctx { border-left: 1px solid var(--line); padding: 16px 14px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 16px; overflow-y: auto; touch-action: pan-y; }
.pb-ctx > div > b { display: block; color: var(--text); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.pb-ctx a { display: block; color: var(--text-dim); text-decoration: none; padding: 4px 0; }
.pb-ctx a:hover { color: var(--text); }
.pb-ctx .code { font-size: 11.5px; }
.pb-rel { display: flex; gap: 8px; align-items: center; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; margin: 4px 0; color: var(--text); text-align: left; }
.pb-rel img { width: 48px; height: 30px; object-fit: cover; border-radius: 5px; flex: none; }
.pb-rel span { font-size: 12.5px; font-weight: 600; }
.pb-rel small { display: block; color: var(--text-dim); font-weight: 500; }

/* search / revision log */
.pb-hit { display: block; width: 100%; max-width: 900px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.pb-hit:hover { border-color: var(--accent); }
.pb-hit .where { font-size: 11.5px; color: var(--text-dim); letter-spacing: .06em; text-transform: uppercase; display: block; }
.pb-hit b { display: block; font-size: 15px; margin: 2px 0; }
.pb-hit .snip { font-size: 13px; color: var(--text-dim); }
.pb-revlog { max-width: 900px; }
.pb-rev { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.pb-rev:first-child { border-top: 0; }
.pb-rev .d, .pb-rev .who { color: var(--text-dim); font-size: 12.5px; }

/* edit mode */
.pb-tools { position: absolute; top: -12px; right: 10px; display: none; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: 0 6px 18px rgba(0,0,0,.4); z-index: 2; }
.pb-tools button, .pb-tool { min-width: 38px; height: 38px; border-radius: 6px; font-size: 14px; }
.pb-tools button:hover { background: var(--panel); }
.pb-tools button.d { color: var(--danger); }
.pb-tool.solo { position: absolute; top: -8px; right: 0; background: var(--panel-2); border: 1px solid var(--line); }
#playbook.editing .pb-tools { display: flex; }
#playbook.editing .pb-blk { outline: 1px dashed transparent; outline-offset: 6px; border-radius: 12px; }
#playbook.editing .pb-blk:hover { outline-color: var(--line); }
.pb-ins { display: none; text-align: center; margin: -4px 0 8px; max-width: 900px; }
#playbook.editing .pb-ins { display: block; }
.pb-ins button { font-size: 11.5px; color: var(--text-dim); padding: 3px 12px; border: 1px dashed var(--line) !important; border-radius: 999px; min-height: 26px; }
.pb-ins button:hover { color: var(--accent); border-color: var(--accent) !important; }
.pb-ed { background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; display: grid; gap: 12px; }
.pb-ed.drop { box-shadow: 0 0 0 3px rgba(255,213,74,.4); }
.pb-ed-head { display: flex; gap: 10px; align-items: center; }
.pb-ed-head b { font-size: 16px; }
.pb-ed .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.pb-ed label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); display: block; margin-bottom: 4px; }
.pb-ed input, .pb-ed textarea, .pb-ed select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
.pb-ed input.code { width: 90px; font-weight: 800; color: var(--accent); text-transform: uppercase; }
.pb-ed .tt { flex: 1; min-width: 200px; }
.pb-ed .grow { flex: 1; min-width: 200px; }
.pb-mdtb { display: flex; gap: 3px; margin-bottom: 4px; }
.pb-mdtb button { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: var(--panel-2); font-weight: 700; }
.pb-ed .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pb-ed textarea { resize: vertical; font-size: 14px; line-height: 1.45; }
.pb-ed .prev { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; color: #c9d1e3; overflow: auto; max-height: 320px; }
.pb-ed .prev p { margin: 0 0 6px; }
.pb-ed .meta { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.pb-ed .meta > div { min-width: 130px; }
.pb-confpick button { font-size: 18px; color: var(--line); padding: 2px; }
.pb-confpick button.on { color: var(--accent); }
.pb-ed .act { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.pb-ed .act small { margin-right: auto; color: var(--text-dim); font-size: 12.5px; }
.pb-grid { display: grid; gap: 4px; }
.pb-gr { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr) ; gap: 4px; align-items: center; }
.pb-gr > span { display: flex; gap: 2px; width: 96px; }
.pb-gr > span button { width: 30px; height: 30px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }
.pb-gr > span button.d { color: var(--danger); }
.pb-gr.head input { font-weight: 700; }
.pb-lights { display: grid; gap: 6px; }
.pb-lightrow { display: grid; grid-template-columns: 64px 140px 1fr 34px; gap: 6px; align-items: center; }
.pb-lightrow button.d { color: var(--danger); }
.pb-publist { padding-left: 18px; font-size: 13.5px; margin: 4px 0 8px; max-height: 40vh; overflow: auto; }
.pb-publist li { margin: 3px 0; }
.pb-ver { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.pb-verbody { color: var(--text-dim); font-size: 13px; }
.pb-chlist { display: grid; gap: 4px; }
.pb-chrow { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13.5px; }
.pb-chrow .n { font-weight: 800; color: var(--accent); }
.pb-chrow > span:last-child { display: flex; gap: 4px; }
.pb-chrow button { min-width: 32px; min-height: 32px; padding: 2px 8px; }

/* flags */
.pb-threads { display: grid; gap: 10px; max-height: 55vh; overflow: auto; }
.pb-thread { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.pb-thread.resolved { opacity: .7; }
.pb-post div:last-child { margin-top: 3px; white-space: pre-wrap; }
.pb-post.reply { margin: 8px 0 0 18px; border-left: 2px solid var(--line); padding-left: 10px; }
.pb-post.hidden-post { opacity: .45; }
.pb-replyrow { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.pb-replyrow input { flex: 1; min-height: 34px !important; }
.pb-replyrow button { min-height: 34px !important; padding: 4px 10px !important; }

/* huddle */
.pb-hudlayer { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; padding: 28px 48px; z-index: 5; }
.pb-hudlayer.hidden { display: none; }
.pb-hudlayer .hb { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }
.pb-hudlayer .hb .sp { flex: 1; }
.pb-hudlayer .hc { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 1100px; overflow: auto; }
.pb-hudlayer .hcode { font-weight: 800; font-size: 26px; color: var(--accent); }
.pb-hudlayer h3 { font-size: clamp(34px, 5vw, 60px); line-height: 1.05; margin: 0; text-wrap: balance; }
.pb-hudlayer .hbody { font-size: clamp(18px, 2.2vw, 26px); color: #c9d1e3; max-width: 40ch; }
.pb-hudlayer .pb-table { font-size: clamp(15px, 1.8vw, 22px); }
.pb-hudlayer .pb-atts .pb-att.img img { max-height: 320px; }
.pb-hudlayer .hn { display: flex; gap: 10px; align-items: center; justify-content: flex-end; font-size: 14px; color: var(--text-dim); }
.pb-hudlayer .hn button { min-width: 64px; min-height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: 24px; }

/* responsive */
@media (max-width: 1100px) { .pb-cols { grid-template-columns: 220px minmax(0,1fr); } .pb-ctx { display: none; } }
@media (max-width: 760px) {
  .pb-cols { grid-template-columns: minmax(0,1fr); }
  #pb-rail-btn { display: inline-flex; align-items: center; justify-content: center; }
  .pb-rail { position: absolute; top: 0; bottom: 0; left: 0; width: min(82vw, 300px); background: var(--panel); z-index: 4; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 24px rgba(0,0,0,.5); }
  #playbook.rail-open .pb-rail { transform: none; }
  #playbook.rail-open .pb-scrim { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 3; }
  .pb-top { gap: 6px; padding: 6px 8px; }
  .pb-tabs button { padding: 6px 10px; }
  .pb-search { flex: 1 1 120px; }
  .pb-user span { display: none; }
  .pb-user { padding: 3px; }
  .pb-user:not(:has(img)) span { display: inline; }
  .pb-content { padding: 14px 12px 90px; }
  .pb-sh h2 { font-size: 24px; }
  .pb-filt { margin-left: 0; }
  .pb-bottom { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: rgba(16,20,31,.95); border-top: 1px solid var(--line); font-size: 13px; }
  .pb-bottom button { color: var(--blue); padding: 6px 0; min-height: 40px; max-width: 48%; text-align: left; }
  .pb-bottom button:last-child { text-align: right; }
  .pb-bottom b { font-weight: 600; }
  .pb-ed .two { grid-template-columns: 1fr; }
  .pb-hudlayer { padding: 16px 18px; }
  .pb-lightrow { grid-template-columns: 56px 1fr 34px; }
  .pb-lightrow [data-t] { grid-column: 1 / -1; }
  #playbook.editing .pb-tools { position: static; justify-content: flex-end; margin-bottom: 6px; box-shadow: none; }
}
@media print {
  body.playbook-open > #app, body.playbook-open #home, .pb-top, .pb-rail, .pb-ctx, .pb-bottom, .pb-ack, .pb-ins, .pb-tools, .rf .pb-mini, .pb-filt, #modal-scrim, #toast { display: none !important; }
  #playbook { position: static; display: block; background: #fff; color: #000; }
  .pb-content { overflow: visible; padding: 0; color: #000; }
  .pb-rule, .pb-table, .pb-traffic > div, .pb-callout { background: #fff; color: #000; border-color: #999; break-inside: avoid; }
  .pb-rule .rb, .pb-prose, .pb-intro, .pb-callout, .pb-table th { color: #222; }
  .pb-rule .code, .pb-sh h2 i { color: #000; background: none; }
  .pb-table th { background: #eee; }
}
