/* ── Reset & design tokens ─────────────────────────────────────────────────────
   Copied verbatim from live-grid-stats/styles/app.css :root block.
   DPA-specific layout tokens added below.                                ──── */
:root {
  --bg:          #111827;
  --surface:     #1a2030;
  --surface-2:   #242d3d;
  --border:      #2d3a50;
  --border-mid:  #45556f;
  --text:        #f0f4f8;
  --subtext:     #c8d4e0;
  --dim:         #94a3b8;
  --accent:      #e8ff47;
  --ok:          #68d391;
  --warn:        #f6ad55;
  --red:         #fc8181;

  --home-bg:     #1a4d2a;
  --home-fg:     #7defa0;
  --home-border: #2a7a3e;
  --away-bg:     #4d1a1a;
  --away-fg:     #f08080;
  --away-border: #7a2a2a;

  /* Pitch surface — white field */
  --pitch-bg:    #e8ddd0;
  --pitch-line:  #c9b9a8;
  --pitch-text:  #5a3e28;

  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', monospace;

  /* ── DPA layout tokens ─────────────────────────────────────────────────── */
  --toolbar-h:  50px;
  --status-h:   28px;
  /* --controls-h and --history-h removed in DPA-API-2-0.
     Layout is now flex-proportional. No pixel arithmetic on band heights. */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  cursor: pointer;
}
input[type="text"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea {
  cursor: text;
}
button, input, select, textarea { font: inherit; border: none; }
button { background: none; color: inherit; cursor: pointer; }
input, select, textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */

#dpa-app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* ── Top toolbar ───────────────────────────────────────────────────────────── */

.dpa-toolbar {
  height: var(--toolbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.dpa-toolbar-brand {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.dpa-toolbar-divider {
  width: 1px; height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.dpa-toolbar-btn {
  background: transparent;
  color: var(--subtext);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.1s, color 0.1s;
}
.dpa-toolbar-btn:hover  { border-color: var(--accent); color: var(--accent); }
.dpa-toolbar-btn.active { border-color: var(--ok);     color: var(--ok);     }
.dpa-toolbar-btn.warn   { border-color: var(--warn);   color: var(--warn);   }

.dpa-session-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  flex-shrink: 1;
}

.dpa-toolbar-spacer { flex: 1; }

/* ── Three-band main layout ────────────────────────────────────────────────── */
/*
 * DPA-API-2-0 layout model (corrected allocation):
 * #dpa-main-bands fills all remaining height below the toolbar.
 * Three bands: 75% video | 15% capture | 10% status.
 * No pixel arithmetic. No calc() on band heights.
 * Toolbar sits outside the proportion calculation.
 * Previous 70 / 20 / 10 allocation withdrawn.
 */

#dpa-main-bands {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── 70% Video band ────────────────────────────────────────────────────────── */
/*
 * Contains two internal layers:
 *   A. #dpa-video-viewport — video image area (flex:1, takes remaining height)
 *   B. #dpa-transport      — transport row (flex-shrink:0, sized by content)
 * Both layers are inside the 70% band. Transport is subordinate to video image.
 * Zoom operates on #dpa-video only — bands below are not affected.
 */

#dpa-band-video {
  flex: 0 0 75%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #000;
}

/* Fixed-size viewport — zoom clips inside here */
#dpa-video-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 0;
}

/* Video element — transform:scale(N) applied by JS for zoom */
#dpa-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform-origin: center center;
}

/* Idle placeholder */
#dpa-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--dim);
  font-family: var(--mono);
  pointer-events: none;
}
#dpa-placeholder.hidden { display: none; }
#dpa-placeholder-icon { font-size: 3rem; opacity: 0.3; }

/* Transport row — fixed internal row at bottom of video band */
#dpa-transport {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 12px 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ── Transport controls (unchanged from 1.9) ───────────────────────────────── */

.dpa-progress-bar {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.dpa-progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
  width: 0%;
}
.dpa-progress-handle {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  left: 0%;
}

.dpa-transport-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dpa-transport-btn {
  background: transparent;
  color: var(--subtext);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.1s;
  white-space: nowrap;
}
.dpa-transport-btn:hover { border-color: var(--accent); color: var(--accent); }

.dpa-play-btn {
  width: 32px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dpa-play-btn:hover { border-color: var(--accent); color: var(--accent); }

.dpa-timecode {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--subtext);
  white-space: nowrap;
  min-width: 100px;
}

.dpa-transport-spacer { flex: 1; }

.dpa-zoom-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dpa-zoom-level {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--dim);
  min-width: 36px;
  text-align: center;
}

/* ── 15% Capture strip ─────────────────────────────────────────────────────── */
/*
 * Persistent always-visible capture surface. Left-to-right: location → team → event.
 * Three internal zones: 28% grid | 10% toggle | 62% event buttons.
 * Previous 24 / 9 / 67 allocation withdrawn.
 * No overlay, no popup, no record-initiation mode.
 * Event list rendered from active template via getPopupButtonsForTeam().
 */

#dpa-band-capture {
  flex: 0 0 15%;
  display: flex;
  flex-direction: row;
  min-height: 0;
  background: var(--surface);
  border-top: 2px solid var(--border-mid);
}

/* LEFT: pitch grid zone (28%) */
#dpa-strip-grid {
  flex: 0 0 28%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: 100%;           /* explicit height — anchors the flex chain below */
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

/* CENTRE: team toggle zone (10%) */
#dpa-strip-toggle {
  flex: 0 0 10%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

/* RIGHT: event button zone (62%) — flex:1 1 absorbs sub-pixel rounding */
#dpa-strip-events {
  flex: 1 1 62%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 6px;
  min-width: 0;
}

/* ── Pitch surface — inside capture strip grid zone ─────────────────────────
 * Height chain: #dpa-strip-grid (height:100%) → .dpa-pitch-area (flex:1) →
 * .dpa-pitch-center (flex:1) → #dpa-pitch-grid (flex:1).
 * Each step has min-height:0 to allow shrinking without overflow.
 * DOM structure unchanged — yard markers and side labels remain in DOM,
 * suppressed by CSS only (yard markers: display:none; side labels: thin strips).
 */

.dpa-pitch-area {
  display: flex;
  align-items: stretch;
  flex: 1;
  height: 100%;
  min-height: 0;
  background: var(--bg);
}

/* Side labels — CSS-only: reduced to thin colour-coded edge strips.
 * font-size:0 hides text. width:8px provides a minimal visual edge.
 * Rotated text is not rendered at this scale — CSS suppresses without DOM change. */
.dpa-pitch-side-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--mono);
  color: transparent;        /* text hidden */
  font-size: 0;              /* text suppressed */
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 8px;                /* thin strip — minimal visual edge indicator */
  flex-shrink: 0;
  background: var(--home-bg);   /* home = green-tinted strip */
  border-right: 1px solid var(--border);
}
.dpa-pitch-side-label.left {
  transform: none;           /* rotation not needed — text is invisible */
  border-right: none;
  border-left: 1px solid var(--border);
  background: var(--home-bg);
}
/* Away label (right side) gets away colouring */
#pitch-label-away {
  background: var(--away-bg);
}

.dpa-pitch-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--pitch-bg);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* Pitch-band labels above the grid. These align with the seven grid columns
 * and update immediately when Flip Pitch changes visual orientation. */
.dpa-grid-band-labels {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  padding: 2px 2px 3px;
  flex: 0 0 auto;
  min-width: 0;
}

.dpa-grid-band-label {
  min-width: 0;
  padding: 3px 2px;
  border: 1px solid var(--pitch-line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: rgba(17, 24, 39, 0.82);
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(0.5rem, 0.58vw, 0.68rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.dpa-grid-band-label.midfield {
  color: var(--accent);
}

#dpa-pitch-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(3, 1fr);
  min-height: 0;
  min-width: 0;
}

.dpa-grid-cell {
  border: 1px solid var(--pitch-line);
  background: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;        /* increased from 0.75rem for legibility */
  font-weight: 700;
  color: #1e1208;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.dpa-grid-cell:hover  { background: rgba(232, 255, 71, 0.28); }
.dpa-grid-cell:active { background: rgba(232, 255, 71, 0.5);  }
.dpa-grid-cell.selected {
  background: rgba(232, 255, 71, 0.5) !important;
  outline: 2px solid var(--accent);
}

/* Yard markers — CSS-only suppression. Remain in DOM, not rendered. */
.dpa-yard-markers {
  display: none;
}

/* ── Strip team toggle buttons ─────────────────────────────────────────────── */

.dpa-strip-team-btn {
  flex: 1;
  padding: 0;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 2px solid var(--border-mid);
  color: var(--subtext);
  background: transparent;
  transition: all 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dpa-strip-team-btn[data-team="home"].active {
  background: var(--home-bg); color: var(--home-fg); border-color: var(--home-border);
}
.dpa-strip-team-btn[data-team="away"].active {
  background: var(--away-bg); color: var(--away-fg); border-color: var(--away-border);
}

/* ── Strip event buttons — four-row row-major layout ────────────────────────
 * DPA-API-2-3-2 §10.6–10.8: visible fill order must be row-major (left-to-right
 * across each row first, then next row). Column-major fill is explicitly rejected.
 * Fixed 4 columns × 4 rows = 16 slots, matching the standard hurling team set.
 * Template order (getPopupButtonsForTeam sort key) maps directly to reading order:
 *   row 1: items 1–4   row 2: items 5–8   row 3: items 9–12   row 4: items 13–16
 * grid-auto-flow: row ensures DOM insertion order = visible analyst reading order.
 * If a template exceeds 16 events, grid-auto-rows adds rows below the fixed four.
 */

#dpa-strip-event-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  grid-auto-flow: row;
  gap: 3px;
  height: 100%;
  min-height: 0;
}

.dpa-strip-event-btn {
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.dpa-strip-event-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 255, 71, 0.06);
}

.dpa-strip-empty {
  color: var(--dim);
  font-size: 0.8rem;
  font-style: italic;
  padding: 8px 4px;
  font-family: var(--mono);
  grid-column: 1 / -1;
}

/* ── 10% Status band ───────────────────────────────────────────────────────── */
/*
 * #dpa-status  — primary top row, single text line, always visible.
 * #dpa-history — compact clickable launcher strip.
 *                Single visible line. Click opens floating panel.
 *                Band does not grow. Does not scroll.
 */

#dpa-band-status {
  flex: 0 0 10%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

#dpa-status {
  height: var(--status-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--dim);
}
#dpa-status.status-ok   { color: var(--ok);   }
#dpa-status.status-warn { color: var(--warn); }
#dpa-status.status-err  { color: var(--red);  }

/* Launcher strip — shows most recent event, acts as a button to open panel */
#dpa-history {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  padding: 2px 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  transition: background 0.1s;
}
#dpa-history:hover { background: var(--surface-2); }

.dpa-history-empty {
  color: var(--dim);
  font-size: 0.8rem;
  font-style: italic;
  padding: 2px 0;
  font-family: var(--mono);
}

.dpa-history-row {
  display: flex;
  align-items: center;
  border-radius: 6px;
  margin-bottom: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* In the launcher strip, show only the first row compactly */
#dpa-history .dpa-history-row {
  margin-bottom: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  flex: 1;
  min-width: 0;
}
#dpa-history .dpa-history-row ~ .dpa-history-row { display: none; }
#dpa-history .dpa-history-delete { display: none; }

.dpa-history-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  cursor: pointer;
  min-width: 0;
  transition: background 0.1s;
}
.dpa-history-body:hover { background: var(--surface-2); }

.dpa-history-time  { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.dpa-history-team  { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; flex-shrink: 0; }

/* ── Period separator — shown in history panel, hidden in compact strip ── */
.dpa-history-period-sep {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(104, 211, 145, 0.08);
  border-top: 1px solid rgba(104, 211, 145, 0.25);
  border-bottom: 1px solid rgba(104, 211, 145, 0.1);
  padding: 4px 10px;
  margin: 4px 0 2px;
}
/* Hide separator in the compact bottom strip — only one event shown there */
#dpa-history .dpa-history-period-sep { display: none; }
.dpa-team-home     { background: var(--home-bg); color: var(--home-fg); }
.dpa-team-away     { background: var(--away-bg); color: var(--away-fg); }
.dpa-history-label { font-size: 0.8rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dpa-history-grid  { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); flex-shrink: 0; }

.dpa-history-delete {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--dim);
  border: none;
  border-left: 1px solid var(--border);
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: color 0.1s, background 0.1s;
}
.dpa-history-delete:hover { color: var(--red); background: rgba(252, 129, 129, 0.1); }

.dpa-history-edit {
  width: 28px; height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--dim);
  border: none;
  border-left: 1px solid var(--border);
  font-size: 0.85rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
}
.dpa-history-edit:hover { color: var(--accent); background: rgba(232, 255, 71, 0.08); }

/* Show edit button in the full panel */
#dpa-history-panel-list .dpa-history-edit { display: flex; }

/* ── Floating Event History panel ───────────────────────────────────────────── */

#dpa-history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 11%;   /* clear the capture + status bands */
}
#dpa-history-overlay.active { display: flex; }

#dpa-history-panel {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px 12px 0 0;
  width: min(720px, 92vw);
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.6);
}

#dpa-history-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dpa-history-panel-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  flex: 1;
}
.dpa-history-panel-count {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--dim);
}

/* Scrollable event list inside the panel */
#dpa-history-panel-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 10px;
}
#dpa-history-panel-list .dpa-history-empty {
  padding: 12px 6px;
}
/* In the panel every row is fully visible with delete button */
#dpa-history-panel-list .dpa-history-row {
  display: flex;
  margin-bottom: 4px;
  background: var(--surface-2);
  border-color: var(--border);
}
#dpa-history-panel-list .dpa-history-body { cursor: pointer; }
#dpa-history-panel-list .dpa-history-delete { display: flex; }

/* ── Resume prompt overlay ─────────────────────────────────────────────────── */

#dpa-resume-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}
#dpa-resume-overlay.active { display: flex; }

.dpa-resume-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.dpa-resume-title  { font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent); }
.dpa-resume-body   { font-size: 0.88rem; color: var(--subtext); line-height: 1.5; }
.dpa-resume-detail { font-family: var(--mono); font-size: 0.82rem; color: var(--text); background: var(--surface-2); border-radius: 6px; padding: 8px 12px; }
.dpa-resume-actions { display: flex; gap: 8px; }
.dpa-resume-btn {
  flex: 1; padding: 9px 0; border-radius: 8px;
  font-family: var(--mono); font-size: 0.85rem; font-weight: 700;
  border: 1px solid var(--border-mid);
  color: var(--subtext); background: var(--surface-2);
  transition: all 0.1s;
}
.dpa-resume-btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.dpa-resume-btn.primary:hover { opacity: 0.88; }
.dpa-resume-btn:not(.primary):hover { border-color: var(--text); color: var(--text); }

/* ── DPA Web 2.4.1 IndexedDB startup resume prompt overlay ─────────────────── */
.dpa-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
}
.dpa-overlay.hidden { display: none; }
.dpa-overlay.active { display: flex; }

.dpa-overlay-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.75);
}
.dpa-overlay-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dpa-overlay-title {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}
.dpa-overlay-detail {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0;
  line-height: 1.55;
}
.dpa-overlay-note {
  font-size: 0.83rem;
  color: var(--subtext);
  line-height: 1.5;
  margin: 0;
}
.dpa-overlay-actions {
  display: flex;
  gap: 8px;
}
.dpa-overlay-actions .dpa-toolbar-btn {
  flex: 1;
  padding: 9px 0;
  font-size: 0.86rem;
  font-weight: 700;
  justify-content: center;
}
.dpa-overlay-actions .dpa-toolbar-btn.primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}
.dpa-overlay-actions .dpa-toolbar-btn.primary:hover { opacity: 0.88; }

/* ── Manage Template overlay ───────────────────────────────────────────────── */
/* Overlay/modal architecture retained from existing DPA pattern.
 * Internal content expanded to full management surface.
 * No native <dialog> used — open/close via .active class as elsewhere in DPA.
 * Containment fix: outer overlay gets overflow-y:auto as fallback scroll path.
 * Panel gets explicit height + min-height:0 to bind it to viewport.
 * Body gets flex:1 1 auto + min-height:0 to become the real scroll node. */

#dpa-template-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  display: none;
  overflow-y: auto;
  padding: 24px 0;
}

#dpa-template-overlay.active {
  display: block;
}

.dpa-template-panel {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  width: min(1180px, 96vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  height: auto;
  max-height: none;
  min-height: 0;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

.dpa-template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.dpa-template-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}

.dpa-template-body {
  padding: 14px 16px 16px;
}

.dpa-tmpl-layout {
  display: grid;
  grid-template-columns: 1.45fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.dpa-tmpl-col-heading,
.dpa-tmpl-section-title {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dpa-tmpl-left-col,
.dpa-tmpl-right-col {
  min-width: 0;
}

.dpa-tmpl-right-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dpa-tmpl-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.dpa-tmpl-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#dpa-tmpl-saved-list,
#dpa-tmpl-groups,
#dpa-tmpl-restore-list {
  padding: 8px 10px;
}

.dpa-tmpl-template-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
}

.dpa-tmpl-template-row.is-active {
  border-color: var(--accent);
  background: rgba(232,255,71,0.06);
}

.dpa-tmpl-tname {
  font-size: 0.86rem;
  color: var(--text);
  word-break: break-word;
}

.dpa-tmpl-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}

.dpa-tmpl-row-btns,
.dpa-tmpl-event-btns,
.dpa-tmpl-group-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.dpa-tmpl-btn {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--subtext);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}

.dpa-tmpl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dpa-tmpl-btn.primary {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232,255,71,0.08);
}

.dpa-tmpl-btn.danger {
  border-color: rgba(252,129,129,0.4);
  color: var(--red);
}

.dpa-tmpl-btn.danger:hover {
  border-color: var(--red);
  background: rgba(252,129,129,0.08);
}

.dpa-tmpl-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg);
}

.dpa-tmpl-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.dpa-tmpl-group-name {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dpa-tmpl-event-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.dpa-tmpl-event-row:last-child {
  border-bottom: none;
}

.dpa-tmpl-event-main {
  min-width: 0;
}

.dpa-tmpl-event-label {
  display: block;
  font-size: 0.84rem;
  color: var(--text);
  word-break: break-word;
  margin-bottom: 3px;
}

.dpa-tmpl-event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.dpa-tmpl-team-badge,
.dpa-tmpl-visible-badge,
.dpa-tmpl-short-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.dpa-tmpl-team-badge.home { background: var(--home-bg); color: var(--home-fg); }
.dpa-tmpl-team-badge.away { background: var(--away-bg); color: var(--away-fg); }
.dpa-tmpl-visible-badge { border: 1px solid var(--border-mid); color: var(--dim); }
.dpa-tmpl-visible-badge.visible { border-color: rgba(104,211,145,0.5); color: var(--ok); background: rgba(104,211,145,0.08); }
.dpa-tmpl-short-badge { border: 1px solid var(--border-mid); color: var(--subtext); }

.dpa-tmpl-field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--subtext);
}

.dpa-tmpl-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  transition: border-color 0.1s;
}

.dpa-tmpl-input:focus {
  outline: none;
  border-color: var(--accent);
}

.dpa-tmpl-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dpa-tmpl-check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--subtext);
}

.dpa-tmpl-check-line {
  margin-top: 2px;
}

.dpa-tmpl-id-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--dim);
}

#dpa-tmpl-score-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.dpa-tmpl-form-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.dpa-tmpl-submit-btn {
  background: #48bb78;
  border: none;
  color: #0a1f0a;
  font-weight: 700;
}

.dpa-tmpl-submit-btn:hover {
  opacity: 0.9;
  color: #0a1f0a;
}

.dpa-tmpl-reset-wrap {
  padding: 10px 12px;
}

.dpa-tmpl-reset-btn {
  width: 100%;
  border-color: rgba(252,129,129,0.4);
  color: var(--red);
}

.dpa-tmpl-reset-btn:hover {
  border-color: var(--red);
  background: rgba(252,129,129,0.08);
}

.dpa-tmpl-restore-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.dpa-tmpl-restore-name {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text);
}

.dpa-tmpl-restore-sub {
  font-size: 0.76rem;
  color: var(--dim);
}

@media (max-width: 980px) {
  .dpa-tmpl-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
/*
 * Anchored above the capture strip.
 * bottom: calc(15% + 24px) floats clear of the 15% capture band.
 */

#dpa-toast {
  position: fixed;
  bottom: calc(15% + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--ok);
  color: var(--ok);
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 6px 16px;
  border-radius: 20px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#dpa-toast.show { opacity: 1; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* ── Edit event overlay ──────────────────────────────────────────────────────*/
#dpa-edit-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
#dpa-edit-overlay.active { display: flex; }

.dpa-edit-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 280px;
  max-width: 340px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.dpa-edit-title {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border-mid);
  padding-bottom: 10px;
}
.dpa-edit-field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--subtext);
  font-family: var(--mono);
}
.dpa-edit-input {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 7px 10px;
  font-family: var(--mono);
  width: 100%;
}
.dpa-edit-input:focus { outline: none; border-color: var(--accent); }
.dpa-edit-team-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.dpa-edit-team-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--subtext);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
}
.dpa-edit-team-btn.active[data-team="home"],
#dpa-edit-team-home.active { background: var(--home-bg); color: var(--home-fg); border-color: var(--home-border); }
#dpa-edit-team-away.active { background: var(--away-bg); color: var(--away-fg); border-color: var(--away-border); }
.dpa-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}
.dpa-edit-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.1s;
}
.dpa-edit-btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.dpa-edit-btn.primary:hover { opacity: 0.88; }
.dpa-edit-btn:not(.primary):hover { border-color: var(--text); color: var(--text); }

/* ── Subtype picker overlay ──────────────────────────────────────────────────*/
#dpa-subtype-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
#dpa-subtype-overlay.active { display: flex; }

.dpa-subtype-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 280px;
  max-width: 360px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dpa-subtype-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border-mid);
  padding-bottom: 10px;
}

.dpa-subtype-radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dpa-subtype-radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.dpa-subtype-radio-row input[type="radio"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.dpa-subtype-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.dpa-subtype-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.dpa-subtype-btn.primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.dpa-subtype-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dpa-subtype-btn:not(.primary):hover { background: var(--surface-3, var(--surface-2)); }

.dpa-subtype-option-btn {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.dpa-subtype-option-btn:hover  { background: var(--surface-3, #2e3a50); border-color: var(--text); }
.dpa-subtype-option-btn.selected { background: rgba(232,255,71,0.12); color: var(--accent); border-color: var(--accent); }


/* ── 5.7.1.2 mobile subtype picker fixes ────────────────────────────────── */
.dpa-subtype-card {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  min-height: 0 !important;
  max-height: min(74dvh, 420px) !important;
  overflow: hidden !important;
  gap: 10px !important;
  padding: 14px 16px !important;
}
.dpa-subtype-radio-group {
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  gap: 7px !important;
  padding-right: 4px !important;
}
.dpa-subtype-option-btn {
  min-height: 42px !important;
  padding: 7px 12px !important;
  font-size: 0.88rem !important;
  line-height: 1.12 !important;
}
.dpa-subtype-option-btn.selected {
  background: rgba(232,255,71,0.12) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  box-shadow: inset 0 0 0 1px rgba(232,255,71,0.20) !important;
}
.dpa-subtype-actions {
  flex-shrink: 0 !important;
  padding-top: 4px !important;
}
@media screen and (max-width: 960px) and (orientation: landscape) {
  #dpa-subtype-overlay {
    align-items: flex-start !important;
    padding-top: max(8px, env(safe-area-inset-top)) !important;
  }
  .dpa-subtype-card {
    width: min(520px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    padding: 10px !important;
    gap: 7px !important;
    border-radius: 12px !important;
  }
  .dpa-subtype-title { display: none !important; }
  .dpa-subtype-radio-group { gap: 6px !important; }
  .dpa-subtype-option-btn {
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: clamp(0.78rem, 2.3vw, 0.9rem) !important;
  }
  .dpa-subtype-btn {
    min-height: 34px !important;
    padding: 6px 14px !important;
    font-size: 0.82rem !important;
  }
}

/* ── DPA Web 2.4 period / YouTube / save-folder additions ─────────────── */
.hidden { display: none !important; }
/* External embedded video is CLOCK_BASED: hide DPA-owned source transport/timeline.
   The only visible video controls in this mode should be the external provider's
   own player controls inside the iframe plus DPA's period clock/buttons below. */
body.dpa-source-embedded #dpa-transport,
html.dpa-source-embedded #dpa-transport,
.dpa-source-embedded #dpa-transport {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.dpa-source-embedded .dpa-progress-bar,
html.dpa-source-embedded .dpa-progress-bar,
.dpa-source-embedded .dpa-progress-bar {
  display: none !important;
}

.is-hidden { display: none !important; }

#dpa-youtube-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  transform-origin: center center;
}

#dpa-youtube-iframe-host {
  width: 100%;
  height: 100%;
}

#dpa-youtube-player iframe {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Embedded External Video — spec §14D, integrated per CR-DPA-5-8-0-
   INTEGRATION-R3 as a third source mode INSIDE the normal 3-band shell
   (video band / period band / capture band), not a separate page. The old
   dormant "External Video Manual Sync panel" rules (dead HTML, unreachable
   since CR-DPA-EXTERNAL-VIDEO-021-R1-REVIEW) have been replaced here. ──── */

#dpa-live-period-controls {
  display: inline-flex;
  gap: 4px;
  margin-left: 10px;
}
.dpa-live-period-locked {
  color: var(--dim, #9aa4b2);
  border-color: var(--border, #2d3648) !important;
  opacity: 0.6;
}
.dpa-live-period-running {
  color: var(--accent, #e8ff47);
  border-color: var(--accent, #e8ff47) !important;
  box-shadow: 0 0 0 2px rgba(232, 255, 71, 0.16);
}

#dpa-embedded-external-video-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden; /* crop viewport for the zoom/pan transform below */
}
#dpa-embedded-frame-pan { width: 100%; height: 100%; }
#dpa-embedded-frame-pan iframe {
  width: 100%; height: 100%; border: 0; display: block;
  transform-origin: center center; /* fixed — no crop-position controls, per prior probe-kit finding */
}
#dpa-embedded-frame-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim, #9aa4b2); font-size: 0.9rem; text-align: center; padding: 0 24px;
  background: rgba(0,0,0,0.4);
}

#dpa-embedded-compact-status {
  font-family: var(--mono, monospace);
  font-size: 0.78rem;
  color: var(--dim, #9aa4b2);
  margin-right: 10px;
  white-space: nowrap;
}

/* ── Video Tools floating dropdown — spec §14D.6. position:fixed, never
   affects the video/strip layout beneath it; visible only while embedded
   mode is active (toolbar toggle button hidden otherwise). ───────────────── */
#dpa-video-tools-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  width: 320px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  display: none;
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--border-mid, #3a4356);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 520;
}
#dpa-video-tools-panel.active { display: block; }

.dpa-video-tools-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border, #2d3648);
  font-size: 0.85rem; font-weight: 600;
}
.dpa-video-tools-body { padding: 10px; font-size: 0.8rem; }
.dpa-video-tools-label { display: block; color: var(--dim, #9aa4b2); font-size: 0.72rem; margin: 8px 0 4px; }
.dpa-video-tools-label:first-child { margin-top: 0; }
.dpa-video-tools-group { display: flex; flex-wrap: wrap; gap: 4px; }
.dpa-video-tools-row { display: flex; align-items: center; gap: 8px; }
.dpa-video-tools-row input[type="range"] { flex: 1 1 auto; accent-color: var(--accent, #e8ff47); }
.dpa-video-tools-value { font-family: var(--mono, monospace); font-size: 0.76rem; min-width: 3em; text-align: right; }
.dpa-video-tools-note { font-style: italic; color: var(--dim, #9aa4b2); font-size: 0.7rem; margin: 2px 0 8px; }
.dpa-video-tools-fs-note { font-style: normal; border-top: 1px solid var(--border, #2d3648); padding-top: 8px; margin-top: 10px; }
.dpa-video-tools-measurements {
  font-family: var(--mono, monospace); font-size: 0.66rem; color: var(--dim, #9aa4b2);
  border-top: 1px solid var(--border, #2d3648); margin-top: 10px; padding-top: 8px; word-break: break-word;
}
.dpa-video-tools-reset-btn { width: 100%; margin-top: 10px; }

.dpa-video-tools-layout-btn.active,
.dpa-video-tools-pan-btn.active,
.dpa-video-tools-perm-btn.active,
.dpa-video-tools-preset-btn.active { border-color: var(--accent, #e8ff47); color: var(--accent, #e8ff47); }
#dpa-video-tools-panel .dpa-video-tools-pan-btn[data-embedded-pan-mode="manual"].active,
#dpa-video-tools-panel .dpa-video-tools-perm-btn[data-embedded-perm="disabled"].active {
  border-color: var(--warn, #f6ad55); color: var(--warn, #f6ad55);
}

/* ── Manual alignment gate — modal, spec §14D.11/§14 ─────────────────────── */
#dpa-embedded-align-overlay {
  position: fixed; inset: 0; z-index: 600; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,0.72);
}
#dpa-embedded-align-overlay.active { display: flex; }
.dpa-align-card { width: min(480px, 92vw); background: var(--surface, #1a1a1a); border: 1px solid var(--border-mid, #3a4356); border-radius: 10px; }
.dpa-align-message { font-size: 0.95rem; margin: 0 0 10px; }
.dpa-align-confirm-btn {
  width: 100%; margin-top: 10px; background: var(--accent, #e8ff47); color: #1a1f14;
  border: 1px solid var(--accent, #e8ff47); border-radius: 5px; padding: 10px; font-size: 0.88rem; font-weight: 700;
}

#dpa-period-band {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.55rem;
  border-top: 1px solid var(--border);
  background: rgba(17,24,39,0.92);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
}

.dpa-period-select-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--subtext);
}

.dpa-period-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  font-family: var(--sans);
}

.dpa-period-time {
  color: var(--subtext);
  overflow: hidden;
  text-overflow: ellipsis;
}

.dpa-period-warning {
  min-height: 24px;
  padding: 0.2rem 0.6rem;
  background: rgba(246,173,85,0.18);
  border-top: 1px solid rgba(246,173,85,0.35);
  color: var(--warn);
  font-size: 0.82rem;
  font-weight: 600;
}

#dpa-period-overlay,
#dpa-settings-overlay,
#dpa-export-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.62);
  padding: 2vh 2vw;
}

#dpa-period-overlay.active,
#dpa-settings-overlay.active,
#dpa-export-menu-overlay.active { display: flex; }

#dpa-export-menu-overlay .dpa-settings-card { width: min(420px, 92vw); }

.dpa-export-menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.dpa-export-menu-btn { text-align: left; padding: 10px 14px; font-size: 0.9rem; }

.dpa-period-card,
.dpa-settings-card {
  width: min(980px, 96vw);
  max-height: 92vh;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-mid);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.dpa-period-card-header,
.dpa-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.dpa-period-card-title,
.dpa-settings-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.dpa-period-help,
.dpa-settings-body {
  padding: 0.85rem 1rem;
  color: var(--subtext);
}

.dpa-period-rows {
  overflow-y: auto;
  min-height: 0;
  padding: 0 1rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.dpa-period-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(190px, 1fr) minmax(190px, 1fr) auto auto auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.dpa-period-row:first-child { border-top: 0; }

.dpa-period-row label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.dpa-period-marker {
  color: var(--subtext);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.dpa-settings-value {
  margin: 0.5rem 0 0.8rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  word-break: break-word;
}

.dpa-settings-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dpa-settings-note {
  margin-top: 0.8rem;
  color: var(--dim);
}

@media (max-width: 900px) {
  #dpa-period-band { flex-wrap: wrap; white-space: normal; }
  .dpa-period-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── R4 UX/layout audit fixes ─────────────────────────────────────────────── */
.is-hidden { display: none !important; }
.dpa-note-strong { font-weight: 600; color: var(--text); }

:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.dpa-toolbar-btn:focus-visible,
.dpa-tmpl-btn:focus-visible,
.dpa-strip-team-btn:focus-visible,
.dpa-event-btn:focus-visible,
.dpa-grid-cell:focus-visible,
.dpa-transport-btn:focus-visible,
.dpa-play-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 255, 71, 0.28);
}

.dpa-field-error {
  color: var(--red) !important;
  font-size: 0.72rem;
  line-height: 1.25;
}
.dpa-rule-preview {
  border: 1px solid rgba(232, 255, 71, 0.35);
  background: rgba(232, 255, 71, 0.07);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 2px;
}
.dpa-tmpl-list-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, max-content));
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  margin: 8px 0 10px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.dpa-tmpl-empty {
  padding: 12px 10px;
  color: var(--dim);
  font-size: 0.84rem;
  border: 1px dashed var(--border-mid);
  border-radius: 8px;
  background: var(--surface-2);
}
.dpa-video-tools-preset-btn.active {
  border-color: var(--accent, #e8ff47);
  color: var(--accent, #e8ff47);
  background: rgba(232, 255, 71, 0.08);
}
@media (max-width: 900px) {
  .dpa-tmpl-list-toolbar { grid-template-columns: 1fr 1fr; }
  #dpa-tmpl-search { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .dpa-tmpl-event-row { grid-template-columns: 1fr; }
  .dpa-tmpl-event-btns { justify-content: start; }
}
