/*
 * TAG Legal Desk v2.1: Autopilot (the Director's ruling of 7 Oct 2026; js/v21_autopilot.js). The item in your chip's
 * menu, the tracker (every email type, its status and run) and the confirm panel (the ten emails, why it is safe, the
 * risk, and Grant, Skip for now, Back to learning). The Director and the GM only.
 * Desk tokens only, so every theme holds. Each status takes one of the desk's own colours and always says its word,
 * so colour is never the only sign. 44 px targets, the desk's own focus ring, no sideways scroll at phone width. No
 * inline styles; the run bar's width is a class (v21ap-w0 to v21ap-w100).
 */

/* ---------- your chip's menu ---------- */
.v21ap-mi { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; color: var(--ink-3); }
.v21ap-mi .ico { display: block; }
.menu button:has(> .v21ap-mi) { position: relative; padding-right: 48px; }
.v21ap-mn { position: absolute; top: 50%; right: 12px; display: inline-grid; place-items: center; min-width: 24px; height: 22px; margin-top: -11px; padding: 0 7px; box-sizing: border-box; border-radius: 999px; background: var(--warn); color: var(--solid); font-size: .75rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- the sheet ---------- */
.sheet.v21ap-sheet { width: 100%; border-radius: 0; }
.v21ap-sheet .sheet-h { width: 100%; max-width: 1184px; margin: 0 auto; }
.v21ap-sheet .sheet-b { scrollbar-gutter: stable; }
.v21ap { display: grid; gap: 16px; width: 100%; max-width: 1080px; margin: 0 auto; min-width: 0; align-content: start; color: var(--ink); }
.v21ap-p { margin: 0; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.v21ap-wait { margin: 0; color: var(--ink-3); }
.v21ap-err { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--solid); border: 1px solid var(--glass-rim); box-shadow: inset 4px 0 0 var(--danger), var(--shadow-1); font-weight: 600; overflow-wrap: anywhere; }

/* the totals */
.v21ap-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.v21ap-tile { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); min-width: 0; }
.v21ap-tn { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.v21ap-tl { font-size: .8125rem; color: var(--ink-2); }

/* sections, lines, the rules note */
.v21ap-sec { display: grid; gap: 8px; min-width: 0; }
.v21ap-sech { margin: 0; font-size: .9375rem; font-weight: 800; color: var(--ink); }
.v21ap-lines { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.v21ap-rules { border-radius: 12px; padding: 4px 14px; background: var(--solid); border: 1px solid var(--glass-rim); }
.v21ap-rules > summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; color: var(--brand-text); }
.v21ap-rules > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.v21ap-rules .v21ap-lines { padding-bottom: 10px; }

/* the filters */
.v21ap-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.v21ap-filter { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--glass-rim); background: var(--solid); color: var(--ink-2); font-weight: 700; font-size: .875rem; cursor: pointer; }
.v21ap-filter[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.v21ap-filter:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* the tracker's table: a grid that stacks at phone width */
.v21ap-table { display: grid; gap: 6px; min-width: 0; }
.v21ap-tr { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(130px, 1fr) minmax(120px, 1fr) 80px minmax(180px, 2fr) 96px; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--solid); border: 1px solid var(--glass-rim); min-width: 0; }
.v21ap-th { background: transparent; border: 0; padding-top: 0; padding-bottom: 0; font-size: .75rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.v21ap-name { font-weight: 700; overflow-wrap: anywhere; }
.v21ap-num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.v21ap-last { font-size: .8125rem; color: var(--ink-2); overflow-wrap: anywhere; }
.v21ap-act { display: flex; justify-content: flex-end; }

/* the status chip: a colour and always its word */
.v21ap-chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; white-space: nowrap; box-shadow: inset 3px 0 0 var(--v21ap-c, var(--edge-strong)); background: color-mix(in srgb, var(--v21ap-c, var(--edge-strong)) var(--tint-alpha), var(--solid)); color: var(--ink); }
.v21ap-chip.is-ready { --v21ap-c: var(--warn); }
.v21ap-chip.is-auto { --v21ap-c: var(--ok); }
.v21ap-chip.is-back { --v21ap-c: var(--danger); }
.v21ap-chip.is-learn { --v21ap-c: var(--info); }
.v21ap-chip.is-person { --v21ap-c: var(--edge-strong); }

/* the run bar */
.v21ap-run { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.v21ap-track { position: relative; display: block; width: 72px; height: 8px; border-radius: 999px; background: var(--solid-2); overflow: hidden; flex: none; }
.v21ap-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--brand); }
.v21ap-w0 { width: 0; } .v21ap-w10 { width: 10%; } .v21ap-w20 { width: 20%; } .v21ap-w30 { width: 30%; }
.v21ap-w40 { width: 40%; } .v21ap-w50 { width: 50%; } .v21ap-w60 { width: 60%; } .v21ap-w70 { width: 70%; }
.v21ap-w80 { width: 80%; } .v21ap-w90 { width: 90%; } .v21ap-w100 { width: 100%; background: var(--ok); }
.v21ap-runn { font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- the confirm panel ---------- */
.v21ap-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 12px 10px 16px; border-radius: 14px; box-shadow: inset 4px 0 0 var(--danger), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); font-weight: 600; }
.v21ap-notice > span { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.v21ap-notice .ico { flex: none; color: var(--danger); }
.v21ap-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-2); font-weight: 600; }
.v21ap-kicker { margin: 0; font-size: .8125rem; font-weight: 700; color: var(--brand-text); text-transform: uppercase; letter-spacing: .05em; }
.v21ap-type { margin: 0; font-size: 1.625rem; line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; }
.v21ap-type:focus { outline: none; }

.v21ap-ten { display: grid; gap: 4px; min-width: 0; }
.v21ap-tenr { display: grid; grid-template-columns: 32px minmax(110px, 1fr) minmax(80px, .8fr) minmax(220px, 4fr) 56px; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 10px; background: var(--solid); border: 1px solid var(--glass-rim); }
.v21ap-tenr.v21ap-th { background: transparent; border: 0; padding-top: 0; padding-bottom: 0; }
.v21ap-mail { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.v21ap-mail > span { font-size: .8125rem; color: var(--ink-2); line-height: 1.4; }

.v21ap-choose { display: grid; gap: 14px; padding: 16px; border-radius: 16px; box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.v21ap-grant { display: grid; gap: 8px; }
.v21ap-lab { font-weight: 700; color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
.v21ap-phrase { font-weight: 800; color: var(--brand-text); }
.v21ap-in, .v21ap-ta { width: 100%; box-sizing: border-box; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--edge-strong); background: var(--solid); color: var(--ink); font: inherit; }
.v21ap-ta { resize: vertical; }
.v21ap-in:focus-visible, .v21ap-ta:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.v21ap-grant .btn, .v21ap-back .btn { justify-self: start; min-height: 44px; }
.v21ap-grant .btn[disabled], .v21ap-back .btn[disabled] { opacity: .5; cursor: not-allowed; }
.v21ap-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.v21ap-row .btn { min-height: 44px; }
.v21ap-hint { margin: 0; font-size: .8125rem; color: var(--ink-3); }
.v21ap-back { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--glass-rim); }

/* ---------- phone width: rows stack, nothing scrolls sideways ---------- */
@media (max-width: 760px) {
  .v21ap-tr { grid-template-columns: 1fr auto; }
  .v21ap-tr > :nth-child(1) { grid-column: 1 / -1; }
  .v21ap-tr > :nth-child(5), .v21ap-tr > :nth-child(6) { grid-column: 1 / -1; }
  .v21ap-tr > :nth-child(6) { justify-content: flex-start; }
  .v21ap-th { display: none; }
  .v21ap-tenr { grid-template-columns: 28px 1fr 56px; }
  .v21ap-tenr > :nth-child(4) { grid-column: 1 / -1; }
  .v21ap-type { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { .v21ap-filter, .v21ap-chip { transition: none; } }
