/*
 * TAG Legal Desk v2.1: Rules to confirm (J193; js/v21_rules_confirm.js). The count on the item in your chip's menu, the
 * gentle line in the board head, and the wide panel (the desk's glass sheet, like Desk updates): one card per rule with
 * the rule in big plain words, where it came from, the three boxes, the choices and the note, {ai}'s robot while he
 * looks again, and the Done tab.
 * Desk tokens only, so Light, Dark, Eucalypt, Harbour, High contrast and the Canteen themes all hold. Each state takes
 * one of the desk's own colours through --v21rc-c, and words always say it too, so colour is never the only sign. Only
 * transform and opacity animate ({ai}'s robot and the live dot), and neither moves with reduced motion or Calm. 44 px
 * targets, the desk's own focus ring, no sideways scroll at phone width. No inline styles.
 */

/* ---------- your chip's menu: the mark and its count ---------- */
/* The count sits at the end of the row, clear of the words (the menu copies the mark, count and all). */
.v21rc-mi { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; color: var(--ink-3); }
.v21rc-mi .ico { display: block; }
.menu button:has(> .v21rc-mi) { position: relative; padding-right: 48px; }
.v21rc-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 gentle line in the board head ---------- */
.v21rc-notice { display: inline-flex; align-items: center; gap: 0; max-width: 100%; min-width: 0; padding: 0 2px 0 4px; border-radius: 999px; box-shadow: inset 3px 0 0 var(--ember), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.v21rc-nbtn { min-height: 44px; min-width: 0; padding: 0 8px 0 12px; border-radius: 999px; white-space: normal; text-align: left; font-weight: 700; font-size: .875rem; color: var(--ink); }
.v21rc-nbtn .ico { color: var(--ember); }
.v21rc-nx { width: 44px; min-height: 44px; border-radius: 999px; color: var(--ink-2); }

/* ---------- the panel: the desk's sheet, expanded wide ---------- */
.sheet.v21rc-sheet { width: 100%; border-radius: 0; }
.v21rc-sheet .sheet-h { width: 100%; max-width: 1184px; margin: 0 auto; }
.v21rc-sheet .sheet-b { scrollbar-gutter: stable; }
.v21rc { display: grid; gap: 16px; width: 100%; max-width: 1040px; margin: 0 auto; min-width: 0; align-content: start; }

/* the live line in the header */
.v21rc-live { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 30px; padding: 3px 12px 3px 11px; border-radius: 999px; font-size: .8125rem; font-weight: 600; color: var(--ink-2); background: color-mix(in srgb, var(--ok) var(--tint-alpha), transparent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.v21rc-live.is-off { background: var(--solid-2); }
.v21rc-pulse { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.v21rc-pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: v21rc-ping 2.6s var(--ease-out) infinite; }
.v21rc-live.is-off .v21rc-pulse { background: var(--edge-strong); }
.v21rc-live.is-off .v21rc-pulse::after { display: none; }
@keyframes v21rc-ping { 0% { transform: scale(.4); opacity: .7; } 70%, 100% { transform: scale(1.5); opacity: 0; } }

/* the tabs: the same segmented control as Desk updates */
.v21rc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-width: 0; }
.v21rc-head[hidden] { display: none; }
.v21rc-tabs { display: inline-flex; gap: 2px; max-width: 100%; padding: 3px; border-radius: 14px; background: var(--brand-soft); }
.v21rc-tab { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 11px; background: transparent; color: var(--ink-2); font-size: .875rem; font-weight: 700; line-height: 1.15; transition: background-color var(--t-small) var(--ease-out), color var(--t-small) var(--ease-out); }
.v21rc-tab:hover { color: var(--ink); background: var(--glass-hover); }
.v21rc-tab[aria-selected="true"] { background: var(--solid); color: var(--ink); box-shadow: var(--shadow-1); }
.v21rc-tab:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.v21rc-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--solid); color: var(--ink-2); font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.v21rc-tab[aria-selected="true"] .v21rc-n { background: var(--brand-soft); color: var(--brand-text); }
.v21rc-n.is-new, .v21rc-tab[aria-selected="true"] .v21rc-n.is-new { background: var(--warn); color: var(--solid); }
.v21rc-intro { margin: 0; flex: 1 1 320px; min-width: 0; font-size: .875rem; line-height: 1.35rem; }

/* one plain line when the rules could not load */
.v21rc-err { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0; padding: 10px 12px 10px 16px; border-radius: 14px; background: var(--solid); border: 1px solid var(--glass-rim); box-shadow: inset 4px 0 0 var(--warn), var(--shadow-1); color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.v21rc-err > span { flex: 1 1 200px; min-width: 0; }
.v21rc-err .ico { flex: none; color: var(--warn); }
.v21rc-err[hidden] { display: none; }

.v21rc-panel { display: grid; gap: 18px; min-width: 0; border-radius: 12px; }
.v21rc-panel[hidden] { display: none; }
.v21rc-loading { margin: 0; }
.v21rc-empty { margin: 0; padding: 18px 20px; border-radius: var(--r-card); color: var(--ink-2); font-weight: 600; }

/* ---------- one card per rule ---------- */
.v21rc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; min-width: 0; }
.v21rc-list > li { display: grid; min-width: 0; }
.v21rc-card { --v21rc-c: var(--brand-text); display: grid; gap: 16px; min-width: 0; padding: 20px 22px 20px 24px; border-radius: var(--r-card); }
.v21rc-card.g1 { box-shadow: inset 5px 0 0 var(--v21rc-c), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.v21rc-card.is-mine { --v21rc-c: var(--info); }
.v21rc-card.is-reanalysing { --v21rc-c: var(--ember); }
.v21rc-card.is-confirmed { --v21rc-c: var(--ok); }
.v21rc-card.is-declined { --v21rc-c: var(--ink-3); }
/* Stage 29e (J296): a rule Fred applied himself */
.v21rc-card.is-applied { --v21rc-c: var(--ok); }
.v21rc-state.is-applied { --v21rc-s: var(--ok); }
.v21rc-was { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 14px 16px 16px; border-radius: 16px; background: var(--solid); border: 1px solid var(--glass-rim); box-shadow: inset 0 3px 0 var(--ink-3); }
.v21rc-appl { padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--ok) var(--tint-alpha), transparent); font-weight: 700; }
.v21rc-undone { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 10px 14px; border-radius: 14px; font-size: .9375rem; line-height: 1.4rem; font-weight: 700; color: var(--ink); background: color-mix(in srgb, var(--info) var(--tint-alpha), transparent); overflow-wrap: anywhere; }
.v21rc-undone .ico { flex: none; margin-top: 1px; color: var(--info); }
.btn.v21rc-undo { font-weight: 700; }

.v21rc-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.v21rc-state, .v21rc-round { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px; font-size: .75rem; line-height: 1.2rem; font-weight: 700; }
.v21rc-state { --v21rc-s: var(--brand-text); color: color-mix(in srgb, var(--v21rc-s) 78%, var(--ink)); background: color-mix(in srgb, var(--v21rc-s) var(--tint-alpha), transparent); }
.v21rc-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--v21rc-s); }
.v21rc-state.is-wait { --v21rc-s: var(--info); }
.v21rc-state.is-again { --v21rc-s: var(--ember); }
.v21rc-state.is-ok { --v21rc-s: var(--ok); }
.v21rc-state.is-no { --v21rc-s: var(--ink-3); }
.v21rc-round { color: var(--ink-2); background: var(--solid-2); border: 1px solid var(--glass-rim); }

.v21rc-r2 { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 14px; border-radius: 14px; font-weight: 700; font-size: .9375rem; line-height: 1.35rem; color: var(--ink); background: color-mix(in srgb, var(--ember) var(--tint-alpha), transparent); box-shadow: inset 3px 0 0 var(--ember); overflow-wrap: anywhere; }
.v21rc-r2 > span:last-child { min-width: 0; }

.v21rc-rule { margin: 0; font-size: 1.375rem; line-height: 1.9rem; font-weight: 700; letter-spacing: -.005em; color: var(--ink); overflow-wrap: anywhere; }
.v21rc-rule:focus { outline: none; }
.v21rc-rule:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.v21rc-rule.is-done { font-size: 1.125rem; line-height: 1.6rem; }
.v21rc-rule.is-none { font-style: italic; color: var(--ink-2); }
.v21rc-cut { margin: 0; font-size: .8125rem; line-height: 1.2rem; color: var(--ink-2); font-style: italic; }
/* a rule that cannot go live as written (it names a client, or came with no words): only Decline, and this line says why */
.v21rc-block { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 10px 14px; border-radius: 14px; font-size: .9375rem; line-height: 1.4rem; font-weight: 600; color: var(--ink); background: color-mix(in srgb, var(--warn) var(--tint-alpha), transparent); box-shadow: inset 3px 0 0 var(--warn); overflow-wrap: anywhere; }
.v21rc-block .ico { flex: none; margin-top: 1px; color: var(--warn); }
.v21rc-block > span { min-width: 0; }
/* Done: the one of {ai}'s options you both chose */
.v21rc-won { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: .875rem; line-height: 1.35rem; font-weight: 600; color: var(--ink-2); overflow-wrap: anywhere; }
.v21rc-won .ico { flex: none; margin-top: 2px; color: var(--ember); }
.v21rc-won > span { min-width: 0; }

/* where it came from */
.v21rc-src { display: grid; gap: 6px; min-width: 0; }
.v21rc-srch, .v21rc-vh { margin: 0; font-size: .75rem; line-height: 1rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.v21rc-srcl { margin: 0; font-size: .9375rem; line-height: 1.4rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.v21rc-job { white-space: nowrap; overflow-wrap: normal; }
.v21rc-words { margin: 2px 0 0; padding: 8px 14px; border-left: 3px solid var(--edge-strong); border-radius: 0 10px 10px 0; background: var(--solid-2); min-width: 0; }
.v21rc-words p { margin: 0; font-size: .9375rem; line-height: 1.45rem; color: var(--ink-2); overflow-wrap: anywhere; }

/* the three boxes */
.v21rc-boxes { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; min-width: 0; }
.v21rc-box { --v21rc-b: var(--info); display: grid; align-content: start; gap: 8px; min-width: 0; padding: 14px 16px 16px; border-radius: 16px; background: var(--solid); border: 1px solid var(--glass-rim); box-shadow: inset 0 3px 0 var(--v21rc-b); }
.v21rc-box.is-op { --v21rc-b: var(--info); }
.v21rc-box.is-risk { --v21rc-b: var(--warn); }
.v21rc-box.is-gain { --v21rc-b: var(--ok); }
.v21rc-bh { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .9375rem; line-height: 1.3rem; font-weight: 700; color: var(--ink); }
.v21rc-bi { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; color: var(--v21rc-b, var(--ember)); background: color-mix(in srgb, var(--v21rc-b, var(--ember)) var(--tint-alpha), transparent); }
.v21rc-bt { margin: 0; font-size: .9375rem; line-height: 1.45rem; color: var(--ink-2); overflow-wrap: anywhere; }
.v21rc-bt.is-none { font-style: italic; }

/* the choice */
.v21rc-vote { display: grid; gap: 12px; min-width: 0; padding-top: 16px; border-top: 1px solid var(--glass-rim); }
.v21rc-other, .v21rc-mine, .v21rc-both { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: .9375rem; line-height: 1.4rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.v21rc-other .ico, .v21rc-mine .ico, .v21rc-both .ico { flex: none; margin-top: 1px; }
.v21rc-other .ico { color: var(--info); }
.v21rc-mine { padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--info) var(--tint-alpha), transparent); font-weight: 700; }
.v21rc-mine .ico { color: var(--info); }
.v21rc-both .ico { color: var(--ok); }
.v21rc-mynote { margin: 0; font-size: .875rem; line-height: 1.35rem; color: var(--ink-2); overflow-wrap: anywhere; }
.v21rc-change { justify-self: start; }
.v21rc-notef { display: grid; gap: 6px; max-width: 640px; min-width: 0; }
.v21rc-notef label { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.v21rc-notein { width: 100%; min-height: 44px; box-sizing: border-box; padding: 0 12px; border-radius: 12px; border: 1px solid var(--edge-strong); background: var(--solid); color: var(--ink); font: inherit; font-size: .9375rem; }
.v21rc-notein::placeholder { color: var(--ink-3); opacity: 1; }
.v21rc-notein:focus-visible { outline-offset: 0; border-color: var(--focus); }
.v21rc-notein[aria-invalid="true"] { border-color: var(--danger); }
.v21rc-noteerr { margin: 0; font-size: .8125rem; font-weight: 700; color: var(--danger); overflow-wrap: anywhere; }
.v21rc-noteerr:empty { display: none; }
.v21rc-btns { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; }
.v21rc-btns .btn { white-space: normal; text-align: left; line-height: 1.2; padding-top: 8px; padding-bottom: 8px; }
.v21rc-btns .btn[aria-disabled="true"] { opacity: .5; cursor: progress; }
.v21rc-btns .btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--brand-text); }
.v21rc-accept { min-width: 132px; }
.v21rc-decline .ico { color: var(--danger); }
.v21rc-opt .ico { color: var(--ember); }
.v21rc-optnote { margin: -2px 0 0; }
.v21rc-cerr { margin: 0; font-size: .875rem; font-weight: 700; color: var(--danger); overflow-wrap: anywhere; }
.v21rc-cerr:empty { display: none; }

/* both choices, shown once both have chosen */
.v21rc-votes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.v21rc-v { padding: 8px 12px; border-radius: 12px; background: var(--solid-2); font-size: .9375rem; line-height: 1.4rem; color: var(--ink); overflow-wrap: anywhere; }
.v21rc-vw { color: var(--ink-2); }
.v21rc-vn { color: var(--ink-2); }

/* {ai} looks again */
.v21rc-again { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 16px; background: color-mix(in srgb, var(--ember) var(--tint-alpha), transparent); box-shadow: inset 3px 0 0 var(--ember); min-width: 0; }
.v21rc-againt { display: grid; gap: 4px; min-width: 0; }
.v21rc-againh { margin: 0; font-size: 1.0625rem; line-height: 1.5rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.v21rc-againt .meta { margin: 0; }

/* ---------- {ai}'s robot ---------- */
.v21rc-bot { display: block; flex: none; overflow: visible; }
.v21rc-bot .rb-head { fill: var(--solid); stroke: var(--brand-text); stroke-width: 2.4; }
.v21rc-bot .rb-ear { fill: var(--brand-text); }
.v21rc-bot .rb-line, .v21rc-bot .rb-mouth { fill: none; stroke: var(--brand-text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.v21rc-bot .rb-tip { fill: var(--ember); }
.v21rc-bot .rb-eye { fill: var(--info); }
.v21rc-bi .v21rc-bot .rb-head, .v21rc-bi .v21rc-bot .rb-line, .v21rc-bi .v21rc-bot .rb-mouth { stroke-width: 3.2; }
.v21rc-bot.is-thinking .rb-eyes { animation: v21rc-scan 2.4s ease-in-out infinite; }
.v21rc-bot.is-thinking .rb-tip { animation: v21rc-blink 1.2s ease-in-out infinite; }
@keyframes v21rc-scan { 0%, 100% { transform: translateX(-2.5px); } 50% { transform: translateX(2.5px); } }
@keyframes v21rc-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- narrower screens ---------- */
@media (max-width: 899px) {
  .v21rc-boxes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 599px) {
  .v21rc-sheet .sheet-h { flex-wrap: wrap; row-gap: 6px; }
  .v21rc-sheet .sheet-h h2 { flex: 1 1 60%; min-width: 0; }
  .v21rc-sheet .v21rc-live { order: 3; }
  .v21rc-sheet .sheet-b { padding-left: 16px; padding-right: 16px; }
  .v21rc-tabs { display: flex; width: 100%; }
  .v21rc-tab { flex: 1 1 0; min-width: 0; padding: 0 8px; }
  .v21rc-card { padding: 16px 16px 16px 18px; gap: 14px; }
  .v21rc-rule { font-size: 1.1875rem; line-height: 1.65rem; }
  .v21rc-btns .btn { flex: 1 1 100%; justify-content: flex-start; }
  .v21rc-again { flex-direction: column; align-items: flex-start; }
  .v21rc-notice { border-radius: 16px; }
}

/* ---------- High contrast and forced colours ---------- */
:root[data-theme="high_contrast"] .v21rc-card, :root[data-theme="high_contrast"] .v21rc-empty, :root[data-theme="high_contrast"] .v21rc-err, :root[data-theme="high_contrast"] .v21rc-box, :root[data-theme="high_contrast"] .v21rc-block, :root[data-theme="high_contrast"] .v21rc-was { border: 2px solid var(--ink); }
:root[data-theme="high_contrast"] .v21rc-state, :root[data-theme="high_contrast"] .v21rc-round, :root[data-theme="high_contrast"] .v21rc-n, :root[data-theme="high_contrast"] .v21rc-live, :root[data-theme="high_contrast"] .v21rc-mn { border: 1.5px solid currentColor; }
:root[data-theme="high_contrast"] .v21rc-tab[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
:root[data-theme="high_contrast"] .v21rc-notein { border: 2px solid var(--ink); }
:root[data-theme="high_contrast"] .v21rc-mn { box-shadow: 0 0 0 2px var(--ink); }
@media (forced-colors: active) {
  .v21rc-card, .v21rc-empty, .v21rc-err, .v21rc-box, .v21rc-notice, .v21rc-block, .v21rc-was { border: 1px solid CanvasText; }
  .v21rc-state, .v21rc-round, .v21rc-n, .v21rc-live, .v21rc-mn { border: 1px solid CanvasText; }
  .v21rc-tab[aria-selected="true"] { border: 2px solid Highlight; }
  .v21rc-btns .btn[aria-pressed="true"] { outline: 2px solid Highlight; }
  .v21rc-pulse, .v21rc-state::before { forced-color-adjust: none; background: CanvasText; }
  .v21rc-bot .rb-head, .v21rc-bot .rb-line, .v21rc-bot .rb-mouth { stroke: CanvasText; }
  .v21rc-bot .rb-ear, .v21rc-bot .rb-tip, .v21rc-bot .rb-eye { fill: CanvasText; }
}

/* ---------- reduced motion and Calm: nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .v21rc-pulse::after, :root:not([data-motion="full"]) .v21rc-bot .rb-eyes, :root:not([data-motion="full"]) .v21rc-bot .rb-tip { animation: none; }
  :root:not([data-motion="full"]) .v21rc-pulse::after { display: none; }
  :root:not([data-motion="full"]) .v21rc-tab { transition: none; }
}
:root[data-motion="reduced"] .v21rc-pulse::after, :root[data-calm="on"] .v21rc-pulse::after { animation: none; display: none; }
:root[data-motion="reduced"] .v21rc-bot .rb-eyes, :root[data-motion="reduced"] .v21rc-bot .rb-tip,
:root[data-calm="on"] .v21rc-bot .rb-eyes, :root[data-calm="on"] .v21rc-bot .rb-tip { animation: none; }
:root[data-motion="reduced"] .v21rc-tab, :root[data-calm="on"] .v21rc-tab { transition: none; }

/* ---------- print: the rules, never the controls ---------- */
@media print {
  .v21rc-notice, .v21rc-btns, .v21rc-notef, .v21rc-change, .v21rc-live { display: none !important; }
}
