/* ==========================================================================
   Components: buttons, chips, pills and badges, alerts, forms, tables, the
   case list, empty states, toasts, dialogs and the secondary pages.
   Tokens live in tokens.css; the frame in shell.css; the review workspace in
   workspace.css; charts and signal tiles in dataviz.css.
   ========================================================================== */

/* ---------------------------------------------------------------- buttons */

.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: var(--r-md);
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
  font: 500 var(--fs-md)/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .06s;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-3); color: var(--btn-fg); }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { --btn-bg: var(--primary-bg); --btn-fg: var(--primary-fg); --btn-border: var(--primary-bg); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-fg); }
.btn-primary:disabled:hover { background: var(--primary-bg); }
.btn-secondary { --btn-bg: var(--surface-3); --btn-fg: var(--text); --btn-border: transparent; }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger-text); --btn-border: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger); }
.btn-quiet, .btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-2); box-shadow: none; }
.btn-quiet:hover, .btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { min-height: 42px; padding: 9px 18px; font-size: var(--fs-md); }
.btn-count { color: var(--text-3); font-weight: 500; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 28px; height: 28px; padding: 0 6px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-3); cursor: pointer;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.link-button { border: 0; background: none; padding: 0; color: var(--text); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-button:hover { color: var(--accent-text); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- chips, pills, badges */

.status-chip {
  --chip-bg: var(--low-bg); --chip-fg: var(--low-text); --chip-dot: var(--low-solid); --chip-border: var(--low-border);
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--chip-fg); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; line-height: 1.5; flex: none;
}
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--chip-dot); }
/* the dot carries the state; the words stay in the text roles */
.chip-new, .chip-refused, .chip-entity-other, .chip-task-unavailable, .chip-list-optional { --chip-fg: var(--text-2); --chip-dot: var(--low-solid); }
.chip-awaiting_entity_pick, .chip-in_review, .chip-task-open, .chip-list-stale, .status-chip.is-stalled { --chip-fg: var(--text); --chip-dot: var(--accent); }
.chip-running { --chip-fg: var(--text); --chip-dot: var(--accent); }
.chip-running::before { animation: pulse 1.6s ease-in-out infinite; }
.status-chip.is-stalled::before { animation: none; }
.chip-signed_off, .chip-entity-live, .chip-task-done, .chip-list-current { --chip-fg: var(--text); --chip-dot: var(--high-solid); }
.chip-failed, .chip-list-missing { --chip-fg: var(--danger-text); --chip-dot: var(--danger); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; cursor: help;
}
.pill::before { content: ""; width: 14px; height: 4px; border-radius: 2px; flex: none;
  background: linear-gradient(90deg, currentColor 0 var(--fill), color-mix(in srgb, currentColor 22%, transparent) var(--fill)); }
.pill-high { color: var(--high-text); --fill: 100%; }
.pill-medium { color: var(--text-2); --fill: 66%; }
.pill-low { color: var(--text-3); --fill: 33%; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); white-space: nowrap; }
.badge .icon { width: 14px; height: 14px; }
.badge-verified { color: var(--ok-text); }
.badge-failed { color: var(--danger-text); }
.badge-pending { color: var(--text-3); }

.tag {
  display: inline-block; padding: 0 7px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-2);
  font: 500 var(--fs-xs)/1.6 var(--font); vertical-align: 1px;
}
.tag.reliability-official { background: var(--high-bg); color: var(--high-text); }
.tag.reliability-reputable { background: var(--info-bg); color: var(--info-text); }
.tag.reliability-unofficial { background: var(--low-bg); color: var(--low-text); }

.redflag-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: var(--r-sm); background: var(--danger); color: var(--on-danger); font: 600 var(--fs-xs)/1 var(--font);
}
.redflag-dot { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--redflag); vertical-align: 2px; }
.pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }

/* ---------------------------------------------------------------- alerts and callouts */

.alert, .callout {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--info-border); background: var(--info-bg); color: var(--info-text); margin-bottom: var(--sp-4);
}
.alert .icon, .callout > .icon { margin-top: 2px; }
.alert p, .callout p { color: inherit; }
.alert-error { background: var(--danger-bg); border-color: transparent; color: var(--danger-text); }
.alert-success { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.alert-title { font-weight: 600; }
.callout { background: var(--surface); color: var(--text); border-color: var(--border); align-items: center; }
.callout > .icon { color: var(--text-3); }
.callout > div, .callout > span { flex: 1; }
.callout p:not(.alert-title) { color: var(--text-2); }
.callout-warn { background: var(--warn-bg); border-color: transparent; color: var(--text); }
.callout-warn > .icon, .callout-warn .alert-title { color: var(--warn-text); }
.callout-action { flex: none; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-weight: 500; font-size: var(--fs-sm); color: var(--text); margin-bottom: 6px; }
input[type=text], input[type=search], input:not([type]), textarea, select {
  width: 100%; padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--input-border);
  background: var(--surface); color: var(--text); font: var(--fs-md)/1.4 var(--font);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input.mono { font-family: var(--mono); }
textarea { resize: vertical; min-height: 40px; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[aria-invalid="true"] { border-color: var(--danger); }
input[readonly] { background: var(--surface-3); color: var(--text-2); }
input[type=file] { font: var(--fs-sm)/1.4 var(--font); color: var(--text-2); max-width: 100%; }
.field { margin-bottom: var(--sp-5); }
.hint { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.field-error { margin-top: 6px; font-size: var(--fs-sm); color: var(--danger-text); font-weight: 600; }
.optional, .required { font-size: var(--fs-xs); font-weight: 400; color: var(--text-3); margin-left: 6px; }
.required { color: var(--danger-text); }
.locked-field { position: relative; }
.locked-field .icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.form-card { padding: var(--sp-8); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); }
.inline-form { padding: var(--sp-4); margin-top: var(--sp-4); }
.inline-row { display: flex; gap: var(--sp-2); }
.inline-row input { max-width: 280px; }

.steps-hint { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-top: var(--sp-6); counter-reset: step; }
.steps-hint li {
  display: flex; gap: var(--sp-3); align-items: flex-start; color: var(--text-2); font-size: var(--fs-sm);
  padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface-2);
}
.steps-hint .icon { color: var(--text-3); margin-top: 2px; width: 18px; height: 18px; }
.steps-hint strong { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- tables */

.table-card { overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px var(--sp-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table thead th { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); padding-top: 12px; padding-bottom: 8px; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr { transition: background-color .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.col-num { text-align: right !important; width: 1%; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- the case list */

.page-header-hero { align-items: flex-end; padding-bottom: var(--sp-2); }
.filter-bar { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-field { position: relative; flex: 0 1 340px; margin: 0; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-field input { padding-left: 36px; padding-right: 36px; background: var(--surface-2); }
.search-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.status-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: var(--fs-sm); border: 1px solid transparent;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.filter-pill:hover { background: var(--surface-3); color: var(--text); }
.filter-pill.is-active { background: var(--surface-3); color: var(--text); }
.filter-count { color: var(--text-3); }
.cell-partner { min-width: 260px; }
.row-link { display: block; color: var(--text); font-weight: 500; text-decoration: none; }
.row-link:hover { color: var(--text); text-decoration: underline; }
.uen { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.col-progress { width: 300px; }
.col-signals { width: 1%; white-space: nowrap; }
.review-progress { display: flex; align-items: center; gap: var(--sp-3); }
.bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--text-2); }
.bar-fill.is-complete { background: var(--high-solid); }
.bar-label { font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.updated { color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.case-row td { padding-top: 14px; padding-bottom: 14px; }
.case-row:hover .row-link { text-decoration: underline; }
.signals { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.signal { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-2); }
.signal-count { font-weight: 600; color: var(--text); }
.empty-inline { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-8); color: var(--text-2); justify-content: center; }

.empty-state { text-align: center; padding: var(--sp-12) var(--sp-8); display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.empty-state p { color: var(--text-2); max-width: 56ch; }
.empty-state .icon-xl { color: var(--text-3); }
.empty-state .btn { margin-top: var(--sp-2); }
.empty-art { width: 150px; height: 120px; margin-bottom: var(--sp-2); }
.art-paper { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; }
.art-line { fill: var(--border-strong); }
.art-lens { fill: var(--surface-3); stroke: var(--text-2); stroke-width: 3; }
.art-handle { stroke: var(--text-2); stroke-width: 5; stroke-linecap: round; }
.art-check { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.panel-empty { padding: var(--sp-10) var(--sp-6); }
.empty { color: var(--text-3); padding: var(--sp-4) 0; }

/* ---------------------------------------------------------------- entity pick */

.pick-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-6); align-items: start; }
.candidate-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
.candidate-card { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); transition: border-color .15s, box-shadow .15s; }
.candidate-card:hover { border-color: var(--border-strong); }
.candidate-card:first-child { border-color: var(--accent); }
.candidate-head { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: flex-start; }
.candidate-name { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.candidate-facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin: 0; }
.candidate-facts .wide { grid-column: 1 / -1; }
.candidate-facts dt, .evidence-meta dt { font-size: var(--fs-xs); color: var(--text-3); }
.candidate-facts dd, .evidence-meta dd { margin: 2px 0 0; color: var(--text); }
.score { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; }
.score-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.score-bar { height: 8px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.score-fill { display: block; height: 100%; border-radius: inherit; background: var(--low-solid); }
.score-fill.is-fair { background: var(--med-solid); }
.score-fill.is-strong { background: var(--high-solid); }
.score-value { font-weight: 600; color: var(--text); }
.reasons { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chip { padding: 1px 9px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; }
.pick-form { margin-top: auto; }
.pick-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.pick-confirm { padding: var(--sp-3); border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); margin-bottom: var(--sp-3); font-size: var(--fs-sm); border: 1px solid var(--accent-soft-2); }
.pause-note {
  padding: var(--sp-5); position: sticky; top: calc(var(--topbar-h) + var(--dossier-h) + var(--sp-4));
  display: flex; flex-direction: column; gap: var(--sp-3); background: var(--surface-2); border-color: transparent;
}
.pause-note > .icon { color: var(--accent); width: 20px; height: 20px; }
.pause-note p { color: var(--text-2); font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- the evidence page */

.evidence-page { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-5); align-items: start; }
.evidence-page > .card { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.evidence-details { grid-template-columns: 1fr; }
.url { display: block; font-size: var(--fs-xs); color: var(--text-3); overflow-wrap: anywhere; }
.hash { font-size: var(--fs-xs); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- report preview */

.report-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.report-toc { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); max-height: calc(100vh - var(--topbar-h) - var(--sp-8)); overflow: auto; }
.report-toc ol { list-style: none; display: flex; flex-direction: column; gap: 1px; counter-reset: toc; }
.report-toc a { display: block; padding: 6px var(--sp-3); border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-size: var(--fs-sm); line-height: 1.35; }
.report-toc a:hover { background: var(--surface-3); color: var(--text); }
.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-10) var(--sp-12); }
.report-section { margin-top: var(--sp-8); scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); }
.report-section h2 { font: 400 24px/1.2 var(--display); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--text); margin-bottom: var(--sp-3); }
.report-section h3 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); color: var(--text-2); }
.report-section p { margin: var(--sp-2) 0; color: var(--text); overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin: var(--sp-2) 0; }
.report-table td, .report-table th { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.report-table td:first-child { background: var(--surface-2); font-weight: 600; width: 26%; }
.report-header th { width: 220px; background: var(--surface-2); }
.gap-marker { display: inline; padding: 0 4px; border-radius: 3px; background: var(--surface-3); color: var(--text-2); }
.yn { font-weight: 600; }
.yn-yes { color: var(--danger-text); }
.yn-no { color: var(--ok-text); }
.yn-not-checked { color: var(--warn-text); }

/* ---------------------------------------------------------------- lists, TSFA, error */

.list-name { display: block; font-weight: 600; }
.refresh-how { font-size: var(--fs-sm); color: var(--text-2); }
.list-fetched { display: table-cell; }
.list-fetched .list-age { margin-top: 6px; }
.stepper { list-style: none; display: flex; gap: var(--sp-6); margin-top: var(--sp-4); }
.stepper li { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-3); font-weight: 500; font-size: var(--fs-sm); }
.stepper .step-num { background: var(--surface-3); color: var(--text-3); }
.stepper .is-current { color: var(--text); }
.stepper .is-current .step-num, .stepper .is-done .step-num { background: var(--accent); color: var(--on-accent); }
#tsfa-preview { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.tsfa-entries { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-10); }
.tsfa-entry { padding: 4px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.tsfa-entry:last-child { border-bottom: 0; }
.form-card > p { color: var(--text-2); margin-bottom: var(--sp-4); }
.error-card { margin-top: var(--sp-10); padding: var(--sp-10); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.error-card .icon-xl { color: var(--text-3); width: 40px; height: 40px; }
.error-card .error { color: var(--text-2); max-width: 52ch; }
.error-actions { margin-top: var(--sp-2); }

/* ---------------------------------------------------------------- popovers built on <details> (work without JS) */

.popover-details { position: relative; }
.popover-details > summary { list-style: none; }
.popover-details > summary::-webkit-details-marker { display: none; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(340px, 80vw);
  padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); cursor: default; animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.popover-title { font-weight: 600; margin-bottom: 6px; }
.popover-text { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--sp-3); }
.popover-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-3); }
.popover-edit label { font-size: var(--fs-xs); }

/* ---------------------------------------------------------------- toasts and dialogs */

.toasts { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 60; display: flex; flex-direction: column-reverse; gap: var(--sp-2); width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; position: relative; display: flex; align-items: center; gap: var(--sp-3); padding: 12px 12px 12px var(--sp-4);
  border-radius: var(--r-lg); background: #232120; color: #efebe5; overflow: hidden; border: 1px solid #34302c;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.2);
  animation: toast-in .24s var(--ease);
}
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: rgba(255, 255, 255, .3); transform-origin: left; animation: toast-timer var(--toast-ms, 5000ms) linear forwards; }
.toast:hover::after, .toast:focus-within::after { animation-play-state: paused; }
.toast > .icon { color: #86cfa3; }
.toast-error > .icon { color: #ff9592; }
.toast-info > .icon { color: #f4a174; }
.toast-msg { flex: 1; font-size: var(--fs-sm); font-weight: 500; }
.toast-action { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font: 600 var(--fs-sm)/1 var(--font); padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; }
.toast-action:hover { background: rgba(255, 255, 255, .24); }
.toast-action:focus-visible, .toast-close:focus-visible { outline-color: #f4a174; }
.toast-close { border: 0; background: none; color: rgba(255, 255, 255, .72); cursor: pointer; padding: 4px; border-radius: var(--r-sm); display: inline-flex; }
.toast-close:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.toast.is-leaving { animation: toast-out .18s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.dialog { width: min(520px, calc(100vw - 32px)); padding: var(--sp-6); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: var(--overlay); }
.dialog[open] { animation: pop .16s var(--ease); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-4); }
.shortcuts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.shortcuts > div { display: grid; grid-template-columns: 120px 1fr; gap: var(--sp-3); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.shortcuts > div:last-child { border-bottom: 0; }
.shortcuts dt { display: flex; gap: 4px; }
.shortcuts dd { margin: 0; color: var(--text-2); }
.dialog .hint { margin-top: var(--sp-4); }

/* ---------------------------------------------------------------- responsive (pages) */

@media (max-width: 1100px) {
  .pick-layout { grid-template-columns: 1fr; }
  .pause-note { position: static; order: -1; }
  .evidence-page, .report-layout { grid-template-columns: 1fr; }
  .report-toc { position: static; max-height: none; }
  .report-doc { padding: var(--sp-6); }
}
@media (max-width: 1023px) {
  .page, .page-wide { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .brand-tag { display: none; }
  .col-progress { width: auto; }
  .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; }
  .steps-hint { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ---------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .toast::after { display: none; }
}
