/* ═════════ Polish layer (loaded last): rail, feedback, motion. Companion to js/polish.js.
   Rules: transform / opacity / colour only; every duration is a token from css/tokens.css (nothing routine is longer than --dur-slow);
   prefers-reduced-motion at the end of this file turns all of it into instant state changes. ═════════ */

/* ── motion defaults ── */
.app { transition: clip-path 1.1s var(--ease-io), grid-template-columns var(--dur-slow) var(--ease-std); }
.app.is-closing { transition-duration: .7s, var(--dur-slow); }
.dossier__card { transition: transform var(--dur-slow) var(--ease-std), opacity var(--dur-enter) var(--ease-std); }
.app.has-dossier .dossier__card { transition-delay: 0s; }
.toast { display: none; }                                    /* the old single-line toast: replaced by .toasts (js/polish.js) */

/* ═════ RAIL ═════ */
.rail { background: var(--bg); }
.rail__views { position: relative; padding: 10px 0; gap: 3px; overscroll-behavior: contain; }
/* the indicator: ONE element that glides to the active section (js/polish.js railInk); the item itself only changes its text colour */
.rail__ink { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 0; background: var(--hit); pointer-events: none; opacity: 0; will-change: transform;
  transition: transform var(--dur-slow) var(--ease-std), opacity var(--dur-fast); }
.rail__ink.no-anim { transition: none; }
[data-theme='light'] .rail__ink { background: var(--hit); box-shadow: 0 0 0 1.5px var(--ink) inset; }
.rail__views.has-ink .mode.is-on, .rail__views.has-ink .mode.is-on:hover { background: transparent; }
.mode { z-index: 1; transition: color var(--dur-fast) var(--ease-std), background var(--dur-fast) var(--ease-std), transform var(--dur-instant) var(--ease-std); -webkit-tap-highlight-color: transparent; }
.mode:hover:not(.is-on) { background: color-mix(in srgb, var(--bg-3) 85%, transparent); }
.mode:active { transform: scale(.97); background: var(--bg-3); }
.mode.is-on:active { background: transparent; }
.mode__i { transition: transform var(--dur-page) var(--ease-std), color var(--dur-fast); }
.mode:hover:not(.is-on) .mode__i { transform: translateY(-1px) scale(1.06); } .mode:active .mode__i { transform: scale(.9); }
.mode.is-on .mode__i { transform: none; }
.mode::before { transition: transform var(--dur-slow) var(--ease-std) .04s; }
/* section badges: filled pills (a count is a thing to act on), critical ones in the alert colour */
.mode b:not(.dotwrap) { background: var(--ink); color: var(--bg); border: 0; min-width: 18px; padding: 2px 5px; line-height: 1.1; font: 700 10px var(--font-mono); letter-spacing: 0; font-variant-numeric: tabular-nums; animation: badge-pop var(--dur-enter) var(--ease-pop) both; }
.mode b:not(.dotwrap).is-crit { background: var(--alert); color: #fff; }
.mode.is-on b:not(.dotwrap) { background: var(--on-hit); color: var(--hit); } .mode.is-on b:not(.dotwrap).is-crit { background: var(--alert); color: #fff; }
@keyframes badge-pop { from { transform: scale(.5); opacity: 0; } }
@media (min-width: 1200px) { .app:not(.rail-min) .mode b:not(.dotwrap) { margin-left: auto; } }
/* the ⌘K row reads as a search field when there is room */
.rail__k { align-items: center; justify-content: center; gap: 8px; width: 100%; transition: color var(--dur-fast), background var(--dur-fast); }
@media (min-width: 761px) { .rail__k { display: flex; } }
.rail__k:active { background: var(--bg-3); }
@media (min-width: 1200px) { .app:not(.rail-min) .rail__k { justify-content: space-between; padding: 0 16px 0 18px; } .app:not(.rail-min) .rail__k::before { content: 'Jump to…'; font: 500 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; } }
.rail__fold, .rail__help, .rail__lock, .theme-switch button { transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-instant); }
.rail__fold:active, .rail__help:active, .theme-switch button:active { transform: scale(.94); }
.rail__fold:hover, .rail__help:hover { background: var(--bg-3); }
.rail__lock { min-height: 28px; }
/* collapse / expand: labels fade back in instead of snapping */
.rail-flip .mode span, .rail-flip .rail__sync-t, .rail-flip .rail__k::before { animation: fadein var(--dur-slow) var(--ease-std) both; }
/* sync footer: a calm line, no blinking */
.rail__sync { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 12px; margin: 0 0 2px; border: 1.5px solid var(--line); color: var(--ink-3); text-decoration: none; min-width: 0; transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast); }
.rail__sync:hover { color: var(--ink); border-color: var(--line-strong); background: var(--bg-3); } .rail__sync:active { transform: scale(.98); }
.rail__sync .sdot { flex: none; width: 8px; height: 8px; animation: none !important; transition: background var(--dur-slow); }
.rail__sync[data-state='syncing'] .sdot, .rail__sync[data-state='connecting'] .sdot { animation: rail-breathe 2.2s ease-in-out infinite !important; }
@keyframes rail-breathe { 50% { opacity: .35; } }
.rail__sync-t { font-size: 10px; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rail__sync[data-state='healthy'] .rail__sync-t { color: var(--ink-2); }
.rail__sync[data-state='expired'] .rail__sync-t, .rail__sync[data-state='warning'] .rail__sync-t { color: var(--ink); }
@media (min-width: 1200px) { .app:not(.rail-min) .rail__sync { flex: 1 0 100%; margin: 0 12px 4px; width: auto; } .app:not(.rail-min) .rail__foot { padding-inline: 0; } }
@media (max-width: 1199px) { .rail__sync { width: 34px; height: 30px; padding: 0; justify-content: center; } .rail__sync-t { display: none; } }
.app.rail-min .rail__sync { width: 34px; height: 30px; padding: 0; justify-content: center; margin: 0 0 2px; } .app.rail-min .rail__sync-t { display: none; }
/* tooltip (collapsed rail, [data-tip]) */
.tip { position: fixed; left: 0; top: 0; z-index: 90; display: flex; align-items: center; gap: 8px; padding: 6px 9px; background: var(--ink); color: var(--bg); font: 600 11px/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; pointer-events: none; opacity: 0; translate: -4px 0; transition: opacity var(--dur-fast), translate var(--dur-enter) var(--ease-std); }
.tip[data-side='top'] { translate: 0 4px; } .tip[data-side='bottom'] { translate: 0 -4px; }
.tip.is-on { opacity: 1; translate: 0 0; }
.tip kbd { padding: 1px 5px; border: 1px solid color-mix(in srgb, var(--bg) 50%, transparent); font-size: 10px; }

/* phone bottom bar: the indicator is a bar over the tab and the labels stay put */
@media (max-width: 760px) {
  .rail__views { padding: 0; gap: 0; }
  .rail__ink { background: transparent; box-shadow: none; }
  .rail__ink::before { content: ''; position: absolute; left: 18%; right: 18%; top: 0; height: 3px; background: var(--hit); }
  [data-theme='light'] .rail__ink::before { background: var(--blue); }
  .rail__views.has-ink .mode.is-on { color: var(--ink); } .rail__views.has-ink .mode.is-on em { color: var(--ink); }
  .rail__views.has-ink .mode::before, .rail__views.has-ink .mode.is-on::before { display: none; }
  .rail__views.has-ink .mode.is-on .mode__i { transform: translateY(-1px); color: var(--ink); }
  .mode b:not(.dotwrap) { top: 5px; }
  .mode.is-on b:not(.dotwrap) { background: var(--ink); color: var(--bg); } .mode.is-on b:not(.dotwrap).is-crit { background: var(--alert); color: #fff; }
  .mode:active { background: var(--bg-3); }
  .rail { box-shadow: 0 -8px 18px -14px rgba(0, 0, 0, .6); }
}

/* ═════ TOASTS ═════ */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; translate: -50% 0; display: flex; flex-direction: column; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
.tst { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; background: var(--bg-2); color: var(--ink); border: 1.5px solid var(--line-strong); border-left: 4px solid var(--blue-hot); box-shadow: 0 12px 30px rgba(0, 0, 0, .4); pointer-events: auto; font: 500 13.5px/1.35 var(--font-body);
  animation: tst-in var(--dur-enter) var(--ease-std) both; }
[data-theme='light'] .tst { box-shadow: 0 10px 24px rgba(5, 10, 28, .18); }
.tst--success { border-left-color: var(--ok); } .tst--error { border-left-color: var(--alert); } .tst--info { border-left-color: var(--blue-hot); }
[data-theme='light'] .tst--info { border-left-color: var(--blue); }
.tst__i { flex: none; width: 18px; height: 18px; } .tst--success .tst__i { color: var(--ok); } .tst--error .tst__i { color: var(--alert); } .tst--info .tst__i { color: var(--blue-hot); } [data-theme='light'] .tst--info .tst__i { color: var(--blue); }
.tst__t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tst__n { flex: none; color: var(--ink-3); font-size: 10px; letter-spacing: .04em; }
.tst__a { flex: none; padding: 6px 10px; border: 1.5px solid var(--line-strong); color: var(--ink); font-size: 10.5px; letter-spacing: .1em; transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-instant); }
.tst__a:hover { background: var(--hit); color: var(--on-hit); border-color: var(--hit); } .tst__a:active { transform: scale(.95); }
.tst__x { flex: none; width: 26px; height: 26px; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; transition: color var(--dur-fast), background var(--dur-fast); }
.tst__x:hover { color: var(--ink); background: var(--bg-3); }
.tst__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--blue-hot); opacity: .7; transform-origin: left; animation: tst-bar var(--tst-ms, 3600ms) linear forwards; }
[data-theme='light'] .tst--info .tst__bar { background: var(--blue); }
.tst--error .tst__bar { background: var(--alert); } .tst--success .tst__bar { background: var(--ok); }
.tst.is-paused .tst__bar { animation-play-state: paused; }
.tst.is-out { animation: tst-out var(--dur-exit) var(--ease-in) forwards; pointer-events: none; }
@keyframes tst-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes tst-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes tst-bar { to { transform: scaleX(0); } }
@media (max-width: 760px) { .toasts { bottom: calc(72px + env(safe-area-inset-bottom)); } }
@media print { .toasts, .tip, .modal-ghost { display: none !important; } }

/* ═════ BUTTONS: busy -> saved ═════ */
.btn, .qa, .lnk { transition: transform var(--dur-instant) var(--ease-std), color var(--dur-fast), background var(--dur-fast), opacity var(--dur-fast); }
.btn:hover { transform: translate(-2px, -2px); } .btn:active { transform: translate(0, 0) scale(.97); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .45; cursor: not-allowed; transform: none; }
.btn > span { transition: opacity var(--dur-fast); }
.btn.is-busy, .qa.is-busy { cursor: progress; }
.btn.is-busy > span, .btn.is-saved > span { opacity: 0; }
.btn.is-busy::after, .btn.is-saved::after { content: ''; position: absolute; z-index: 3; left: 50%; top: 50%; }
.btn.is-busy::after { width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spn .7s linear infinite; }
.btn.is-saved::after { width: 6px; height: 11px; margin: -8px 0 0 -3px; border: solid currentColor; border-width: 0 2.5px 2.5px 0; rotate: 45deg; animation: check-in var(--dur-enter) var(--ease-pop) both; }
.btn.is-failed { animation: btn-shake 300ms var(--ease-std); }
@keyframes check-in { from { opacity: 0; scale: .4; } }
@keyframes btn-shake { 20% { transform: translateX(-4px); } 45% { transform: translateX(3px); } 70% { transform: translateX(-2px); } }
button.is-busy:not(.btn) { opacity: .6; cursor: progress; }
button.is-saved:not(.btn) { color: var(--ok); }

/* ═════ FORMS ═════ */
.fld-err { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0 0; color: var(--alert); font: 600 12.5px/1.35 var(--font-body); letter-spacing: 0; text-transform: none; animation: fld-in var(--dur-enter) var(--ease-std) both; }
.fld-err::before { content: '!'; flex: none; width: 15px; height: 15px; display: grid; place-items: center; margin-top: 1px; background: var(--alert); color: #fff; font: 800 10px/1 var(--font-mono); }
@keyframes fld-in { from { opacity: 0; transform: translateY(-3px); } }
[aria-invalid='true'], input:user-invalid, textarea:user-invalid, select:user-invalid { border-color: var(--alert) !important; box-shadow: 0 0 0 1px var(--alert); }
input, textarea, select { transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast); }

/* ═════ SURFACES: hover, press, enter ═════ */
.big { transition: background var(--dur-fast) var(--ease-std), border-color var(--dur-fast); }
.big:hover { background: color-mix(in srgb, var(--bg-3) 55%, transparent); border-color: var(--ink-3); z-index: 1; }
.big__n b { font-variant-numeric: tabular-nums; }
.tr, .tbl tbody tr { transition: background var(--dur-fast) var(--ease-std), box-shadow var(--dur-fast) var(--ease-std); }
.tr:hover, .tbl tbody tr:hover { box-shadow: inset 2px 0 0 var(--hit); } [data-theme='light'] .tr:hover, [data-theme='light'] .tbl tbody tr:hover { box-shadow: inset 2px 0 0 var(--blue); }
.tr:active, .tbl tbody tr:active { background: var(--bg-3); }
.panel { transition: border-color var(--dur-fast); } .panel:hover { border-color: var(--ink-3); }
a.drill, .fchip, .seg2__a, .ltab, .pill, .bell, .chip2 { transition: transform var(--dur-instant) var(--ease-std), color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast); }
a.drill:active, .fchip:active, .seg2__a:active, .ltab:active, .pill:active, .bell:active { transform: scale(.96); }
.seg2 button, .seg2 a { transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-instant); } .seg2 button:active { transform: scale(.97); }
/* rows and tiles enter with a short stagger (first 8 only, only when the PAGE changes — never on a live refresh) */
.page.rise .trs > .tr:nth-child(-n+8), .page.rise .tbl tbody tr:nth-child(-n+8), .page.rise .bigs > .big:nth-child(-n+8) { animation: row-in var(--dur-enter) var(--ease-std) both; animation-delay: calc(var(--i, 0) * var(--stagger)); }
.page.rise :nth-child(1) { --i: 0; } .page.rise :nth-child(2) { --i: 1; } .page.rise :nth-child(3) { --i: 2; } .page.rise :nth-child(4) { --i: 3; } .page.rise :nth-child(5) { --i: 4; } .page.rise :nth-child(6) { --i: 5; } .page.rise :nth-child(7) { --i: 6; } .page.rise :nth-child(8) { --i: 7; }
@keyframes row-in { from { opacity: .001; transform: translateY(4px); } }
/* an updated row / tile flashes once so a live change is noticed without a toast */
.flash { animation: row-flash 1.2s var(--ease-std) both; }
@keyframes row-flash { 0% { background-color: color-mix(in srgb, var(--hit) 34%, transparent); } 100% { background-color: transparent; } }

/* ═════ EMPTY / ERROR / LOADING ═════ */
.empty { position: relative; padding-top: 68px; }
.empty::before { content: ''; position: absolute; left: 24px; top: 22px; width: 30px; height: 30px; border: 1.5px dashed var(--ink-3); background: linear-gradient(var(--ink-3), var(--ink-3)) center / 10px 1.5px no-repeat; opacity: .8; }
.errbox { background: color-mix(in srgb, var(--alert) 7%, transparent); border-left-width: 4px; animation: fadein var(--dur-enter) var(--ease-std) both; }
.skel { position: relative; }
button .spin, .btn .spin { vertical-align: -2px; }

/* ═════ OVERLAYS ═════ */
.modal { animation-duration: var(--dur-enter); }
.modal__box { animation: modal-in var(--dur-enter) var(--ease-std) both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-ghost { position: fixed; inset: 0; pointer-events: none; animation: fadeout var(--dur-exit) var(--ease-in) forwards; }
.modal-ghost > * { animation: modal-out var(--dur-exit) var(--ease-in) forwards !important; }
@keyframes fadeout { to { opacity: 0; } } @keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
.palette { animation-duration: var(--dur-enter); } .palette__box { animation: modal-in var(--dur-enter) var(--ease-std) both; }
.why-pop:not([hidden]) { animation: modal-in var(--dur-enter) var(--ease-std) both; }
#palette-list li { transition: background var(--dur-instant), color var(--dur-instant); }

/* ═════ PAGE CHROME ═════ */
.subnav { transition: box-shadow var(--dur-page) var(--ease-std); }
.subnav.is-scrolled { box-shadow: 0 8px 16px -12px rgba(0, 0, 0, .65); } [data-theme='light'] .subnav.is-scrolled { box-shadow: 0 8px 16px -12px rgba(5, 10, 28, .35); }
.subnav__t:active { background: var(--bg-3); }

/* ═════ DRAG AND DROP (Planning reorder) ═════ */
.pln__row { transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-enter) var(--ease-std), opacity var(--dur-fast); }
.pln__row.is-drag { scale: 1.012; background: var(--bg-2); box-shadow: 0 14px 34px rgba(0, 0, 0, .42); opacity: .97; user-select: none; -webkit-user-select: none; transition: box-shadow var(--dur-enter), scale var(--dur-enter) var(--ease-std); }
.pln__row.is-drop-before::before, .pln__row.is-drop-after::after { box-shadow: 0 0 10px var(--hit); transform-origin: left; animation: drop-in var(--dur-fast) var(--ease-std) both; }
@keyframes drop-in { from { transform: scaleX(.2); opacity: 0; } }
.pln__grip:hover { color: var(--ink); } .pln__grip:active { cursor: grabbing; }

/* ═════ REDUCED MOTION: everything above becomes an instant state change ═════ */
@media (prefers-reduced-motion: reduce) {
  .app, .rail__ink, .mode, .mode__i, .mode::before, .tst, .tst__bar, .tst__a, .tip, .btn, .btn > span, .fld-err, .big, .tr, .tbl tbody tr, .modal, .modal__box, .palette, .palette__box, .why-pop,
  .subnav, .dossier__card, .pln__row, .rail__sync, .rail-flip .mode span { transition: none !important; animation: none !important; }
  .tst__bar { display: none; }
  .flash { animation: none !important; background-color: color-mix(in srgb, var(--hit) 18%, transparent); }
  .btn.is-busy::after { animation: none; border-right-color: currentColor; }
  .page.rise .trs > .tr, .page.rise .tbl tbody tr, .page.rise .bigs > .big, .badge-pop, .mode b { animation: none !important; }
  .rail__sync .sdot { animation: none !important; }
}

/* Light theme: --hit is a bright sun-yellow (#ffd60a) that is 1.3:1 on the page, so every place that uses it as TEXT colour (axe found the Milestone map's active tab) reads as nearly blank. A dark gold (#7a5c00: 5.3-6.3:1 on --bg, --bg-2 and --bg-3) takes over for text only; borders, fills and the dark theme are unchanged. Generated from the rules that set `color: var(--hit)`; the ones that put it on a dark --on-hit surface on purpose are left out. */
[data-theme='light'] { --hit-text: #7a5c00; }
[data-theme='light'] .am-attn h2 b,
[data-theme='light'] .am-ctl button:hover,
[data-theme='light'] .atl-btn b,
[data-theme='light'] .atl-btn.is-on,
[data-theme='light'] .atl-clear,
[data-theme='light'] .atl-hud__v a.is-on,
[data-theme='light'] .atl-lnk:hover,
[data-theme='light'] .atl-tab.is-on,
[data-theme='light'] .big.is-hit .big__n,
[data-theme='light'] .chat__spark,
[data-theme='light'] .flt-more > summary:hover,
[data-theme='light'] .hf-arrow,
[data-theme='light'] .hf-end.is-warn,
[data-theme='light'] .hf-k.is-warn b,
[data-theme='light'] .hf-k.is-warn b a,
[data-theme='light'] .hf-mx td.is-warn a,
[data-theme='light'] .hf-st.is-warn,
[data-theme='light'] .ledger__i.is-warn .ledger__g,
[data-theme='light'] .mi-s h3 b,
[data-theme='light'] .mi-t__a a,
[data-theme='light'] .mi-tab.is-on,
[data-theme='light'] .mk-b[aria-pressed='true'],
[data-theme='light'] .mode--ai .mode__i,
[data-theme='light'] .nm__star,
[data-theme='light'] .nm__tab.is-on .nm__star,
[data-theme='light'] .note p::after,
[data-theme='light'] .palette__in .mono,
[data-theme='light'] .pb__sev--med,
[data-theme='light'] .pf-g__h h2 a:hover,
[data-theme='light'] .pf-today em,
[data-theme='light'] .pln__fedit:hover,
[data-theme='light'] .rp-sort i,
[data-theme='light'] .src-cnt.is-warn b,
[data-theme='light'] .src-conf.is-provisional b,
[data-theme='light'] .sys__a.is-warn .sys__ah em,
[data-theme='light'] .sys__c.is-warn .sys__g,
[data-theme='light'] .sys__i.is-warning .sys__sev,
[data-theme='light'] .tlink:hover,
[data-theme='light'] .tt .tt__sort i,
[data-theme='light'] .vp.is-warn i,
[data-theme='light'] .vt tr.is-warn td:last-child { color: var(--hit-text); }
