/* GOÄ Prüfassistent — single stylesheet.
   Surfaces/typography follow jakubkrehel/better-ui, motion follows
   emil-design-eng + the transitions.dev token scale. */

@font-face {
  font-family: "Inter";
  src: url("InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ── Neutral ramp (cool, hue 262) ── */
  --gray-0: oklch(1 0 0);
  --gray-25: oklch(0.988 0.002 262);
  --gray-50: oklch(0.976 0.003 262);
  --gray-100: oklch(0.957 0.004 262);
  --gray-150: oklch(0.935 0.005 262);
  --gray-200: oklch(0.905 0.006 262);
  --gray-300: oklch(0.84 0.008 262);
  --gray-400: oklch(0.71 0.011 262);
  --gray-500: oklch(0.53 0.013 262);
  --gray-600: oklch(0.47 0.014 262);
  --gray-700: oklch(0.37 0.014 262);
  --gray-800: oklch(0.27 0.012 262);
  --gray-900: oklch(0.2 0.01 262);

  /* ── Accent (indigo) + status ramps ── */
  --indigo-50: oklch(0.967 0.018 272);
  --indigo-100: oklch(0.93 0.04 272);
  --indigo-500: oklch(0.52 0.2 272);
  --indigo-600: oklch(0.46 0.2 272);
  --red-50: oklch(0.968 0.018 25);
  --red-100: oklch(0.93 0.045 25);
  --red-500: oklch(0.58 0.2 27);
  --red-700: oklch(0.47 0.17 27);
  --amber-50: oklch(0.978 0.03 85);
  --amber-100: oklch(0.945 0.07 85);
  --amber-500: oklch(0.76 0.15 75);
  --amber-700: oklch(0.5 0.11 65);
  --green-50: oklch(0.972 0.025 158);
  --green-100: oklch(0.935 0.055 158);
  --green-500: oklch(0.63 0.15 158);
  --green-700: oklch(0.47 0.11 158);

  /* ── Semantic tokens (components use only these) ── */
  --bg-page: var(--gray-50);
  --bg-surface: var(--gray-0);
  --bg-subtle: var(--gray-25);
  --bg-muted: var(--gray-100);
  --bg-hover: var(--gray-100);
  --bg-sidebar: var(--gray-25);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-500);
  --text-on-solid: var(--gray-0);
  --separator: var(--gray-150);
  --border-input: var(--gray-200);
  --border-strong: var(--gray-300);
  --accent-solid: var(--indigo-500);
  --accent-solid-hover: var(--indigo-600);
  --accent-text: var(--indigo-600);
  --accent-subtle: var(--indigo-50);
  --accent-ring: oklch(0.52 0.2 272 / 0.28);
  --danger-text: var(--red-700);
  --danger-subtle: var(--red-50);
  --danger-border: var(--red-100);
  --danger-solid: var(--red-500);
  --warning-text: var(--amber-700);
  --warning-subtle: var(--amber-50);
  --warning-border: var(--amber-100);
  --warning-solid: var(--amber-500);
  --success-text: var(--green-700);
  --success-subtle: var(--green-50);
  --success-border: var(--green-100);
  --success-solid: var(--green-500);

  /* ── Surfaces (better-ui: shadows for depth, borders for structure) ── */
  --shadow-border:
    0 0 0 1px oklch(0 0 0 / 0.06),
    0 1px 2px -1px oklch(0 0 0 / 0.06),
    0 2px 4px 0 oklch(0 0 0 / 0.04);
  --shadow-border-hover:
    0 0 0 1px oklch(0 0 0 / 0.08),
    0 1px 2px -1px oklch(0 0 0 / 0.08),
    0 2px 4px 0 oklch(0 0 0 / 0.06);
  --shadow-raised:
    0 0 0 1px oklch(0 0 0 / 0.06),
    0 4px 8px -2px oklch(0 0 0 / 0.08),
    0 12px 32px -4px oklch(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Type ── */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 30px;

  /* ── Motion tokens (transitions.dev scale) ── */
  --duration-stagger: 40ms;
  --duration-quick: 150ms;
  --duration-fast: 250ms;
  --duration-medium: 350ms;
  --duration-slow: 400ms;
  --duration-very-slow: 500ms;
  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-icon: cubic-bezier(0.2, 0, 0, 1);
  --distance-micro: 4px;
  --distance-base: 8px;
  --distance-medium: 12px;
  --blur-small: 2px;
  --blur-medium: 3px;

  /* transitions.dev snippet variables */
  --tabs-dur: 250ms;
  --tabs-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --think-hold: 2600ms;
  --think-swap: 150ms;
  --think-gap: 50ms;
  --think-distance: 8px;
  --think-blur: 2px;
  --think-shimmer: 2000ms;
  --think-ease: ease-in-out;
  --acc-expand: 250ms;
  --acc-collapse: 250ms;
  --acc-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --toast-open: 350ms;
  --toast-close: 250ms;
  --toast-distance: 16px;
  --toast-blur: 2px;
  --toast-scale: 0.97;
  --toast-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger-dur: 500ms;
  --stagger-distance: 12px;
  --stagger-stagger: 40ms;
  --stagger-blur: 3px;
  --stagger-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --check-box: 150ms;
  --check-draw: 350ms;
  --check-uncheck: 150ms;
  --check-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shake-ease: cubic-bezier(0.36, 0.07, 0.19, 0.97);
  --sc-dur: 500ms;
  --sc-path-delay: 80ms;
  --sc-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sc-ease-bob: cubic-bezier(0.34, 1.35, 0.64, 1);
  --reveal-dur: 400ms;
  --reveal-blur: 2px;

  --sidebar-w: 264px;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  font-feature-settings: "cv11" 1, "ss01" 1;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: inherit;
  line-height: inherit;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--indigo-100); }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-raised);
  font-weight: 500;
  translate: 0 -200%;
}
.skip-link:focus-visible { translate: 0 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px;
}

/* ───────────────────────── Buttons ───────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding-inline: 14px;
  border: 0;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition-property: scale, background-color, box-shadow, color, opacity;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.btn:active:not(:disabled) { scale: 0.96; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn[aria-busy="true"] { opacity: 1; cursor: progress; }
.btn .icon:first-child { margin-inline-start: -2px; }
.btn .icon:last-child:not(:first-child) { margin-inline-end: -2px; }
.btn--block { width: 100%; }
.btn--sm { height: 30px; padding-inline: 10px; font-size: var(--text-sm); gap: 6px; border-radius: 7px; }
.btn--lg { height: 42px; padding-inline: 18px; font-size: var(--text-md); border-radius: 10px; }

.btn--primary {
  background: var(--accent-solid);
  color: var(--text-on-solid);
  box-shadow: 0 1px 2px oklch(0.3 0.15 272 / 0.25), inset 0 1px 0 oklch(1 0 0 / 0.14);
}
.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-border);
}
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--danger-ghost { background: transparent; color: var(--danger-text); }

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover:not(:disabled) { background: var(--accent-solid-hover); }
  .btn--secondary:hover:not(:disabled) { box-shadow: var(--shadow-border-hover); background: var(--bg-subtle); }
  .btn--ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
  .btn--danger-ghost:hover:not(:disabled) { background: var(--danger-subtle); }
}

.icon-btn {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition-property: scale, background-color, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.icon-btn--sm { width: 26px; height: 26px; border-radius: var(--radius-sm); }
/* keep a 32px hit area on the small variant */
.icon-btn--sm::after { content: ""; position: absolute; inset: -3px; }
.icon-btn:active { scale: 0.96; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
}

/* Spinner (inside buttons while a request is in flight) */
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────── Inputs ───────────────────────── */

.field { display: grid; gap: 6px; }
.field-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.field-error { min-height: 18px; font-size: var(--text-sm); color: var(--danger-text); }
.input-wrap { position: relative; display: block; }
.input-icon {
  position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%;
  width: 16px; height: 16px; fill: none; stroke: var(--text-tertiary);
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}
.input {
  width: 100%;
  height: 40px;
  padding-inline: 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 16px; /* 16px keeps iOS from zooming */
  transition-property: border-color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
@media (min-width: 640px) { .input { font-size: var(--text-base); } }
.input--icon { padding-inline-start: 36px; }
.input::placeholder { color: var(--text-tertiary); }
.input:focus { outline: none; border-color: var(--accent-solid); box-shadow: 0 0 0 3px var(--accent-ring); }
.is-error .input { border-color: var(--danger-solid); box-shadow: 0 0 0 3px oklch(0.58 0.2 27 / 0.18); }

.textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: vertical;
}
.textarea:focus { outline: none; border-color: var(--accent-solid); box-shadow: 0 0 0 3px var(--accent-ring); }

/* transitions.dev #12 — error state shake */
.t-shake-target.is-shaking { animation: t-shake 400ms var(--shake-ease); }
@keyframes t-shake {
  0%, 100% { translate: 0 0; }
  20% { translate: -8px 0; }
  40% { translate: 6px 0; }
  60% { translate: -4px 0; }
  80% { translate: 2px 0; }
}

/* ───────────────────────── Login ───────────────────────── */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(60rem 30rem at 50% -10%, oklch(0.93 0.04 272 / 0.7), transparent 70%) no-repeat,
    var(--bg-page);
}
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 16px;
  padding: 32px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  box-shadow: var(--shadow-raised);
}
.login-title { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; }
.login-sub { color: var(--text-secondary); margin-top: -8px; text-wrap: pretty; }
.login-foot { font-size: var(--text-xs); color: var(--text-tertiary); text-align: center; }

/* ───────────────────────── Shell ───────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 12px 12px;
  background: var(--bg-sidebar);
  border-inline-end: 1px solid var(--separator);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(180deg in oklab, oklch(0.58 0.2 272), oklch(0.48 0.2 272));
  color: var(--text-on-solid);
  box-shadow: 0 1px 2px oklch(0.3 0.15 272 / 0.3), inset 0 1px 0 oklch(1 0 0 / 0.18);
  flex: none;
}
.brand-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark--lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-mark--lg svg { width: 24px; height: 24px; }
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-weight: 600; font-size: var(--text-base); letter-spacing: -0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--text-tertiary); }

.sidebar-new { justify-content: flex-start; }
.sidebar-section { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 4px; }
.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
}
.history { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; margin-inline: -4px; padding: 4px 4px 8px; }
.history-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  transition-property: background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.history-item[aria-current="page"] { background: var(--bg-surface); box-shadow: var(--shadow-border); }
@media (hover: hover) and (pointer: fine) {
  .history-item:not([aria-current="page"]):hover { background: var(--bg-hover); }
}
.history-title { font-size: var(--text-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { grid-column: 2; font-size: var(--text-xs); color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-empty { padding: 8px; font-size: var(--text-sm); color: var(--text-tertiary); }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 0 8px;
  border-top: 1px solid var(--separator);
}
.conn[data-state="ok"] .dot { background: var(--success-solid); }
.conn[data-state="down"] .dot { background: var(--danger-solid); }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--text-secondary); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); flex: none; }
.dot--ready { background: var(--success-solid); }
.dot--failed { background: var(--danger-solid); }
.dot--queued, .dot--processing { background: var(--accent-solid); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.main { min-width: 0; }
.view { max-width: 1040px; margin-inline: auto; padding: 32px 40px 120px; overflow-wrap: anywhere; }
.view .num, .view .r, .view .nowrap, .view .pill, .view .t-tab { overflow-wrap: normal; }

/* ───────────────────────── Page chrome ───────────────────────── */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-kicker { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-tertiary); margin-bottom: 6px; }
.page-kicker a { position: relative; display: inline-flex; align-items: center; gap: 4px; transition: color 150ms ease-out; }
.page-kicker a::after { content: ""; position: absolute; inset: -6px -4px; }
.chip--link { color: var(--accent-text); background: var(--accent-subtle); transition: background-color 150ms ease-out; }
@media (hover: hover) and (pointer: fine) { .chip--link:hover { background: var(--indigo-100); } }
@media (hover: hover) and (pointer: fine) { .page-kicker a:hover { color: var(--text-primary); } }
.page-title { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
.page-sub { margin-top: 6px; color: var(--text-secondary); max-width: 62ch; text-wrap: pretty; }
.page-actions { display: flex; gap: 8px; flex: none; }
.page-head > div:first-child, .card-head > *, .card-head .row > div { min-width: 0; }

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-border);
}
.card:has(> .table-wrap), .card:has(> .changes-wrap) { overflow: hidden; }
.card-pad { padding: 20px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--separator);
}
.card-title { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: var(--text-sm); color: var(--text-secondary); }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.stack-lg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.label { font-size: var(--text-xs); font-weight: 500; color: var(--text-tertiary); }

/* ───────────────────────── Pills / badges ───────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding-inline: 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.pill .icon { width: 12px; height: 12px; stroke-width: 2; }
.pill--danger { background: var(--danger-subtle); color: var(--danger-text); box-shadow: inset 0 0 0 1px var(--danger-border); }
.pill--warning { background: var(--warning-subtle); color: var(--warning-text); box-shadow: inset 0 0 0 1px var(--warning-border); }
.pill--success { background: var(--success-subtle); color: var(--success-text); box-shadow: inset 0 0 0 1px var(--success-border); }
.pill--accent { background: var(--accent-subtle); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--indigo-100); }
.pill--outline { background: var(--bg-surface); box-shadow: inset 0 0 0 1px var(--border-input); }

.chip {
  display: inline-block;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  line-height: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 5px;
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--bg-muted);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ───────────────────────── New analysis ───────────────────────── */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 40px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  text-align: center;
  cursor: pointer;
  transition-property: border-color, background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.dropzone.is-over { border-color: var(--accent-solid); background: var(--accent-subtle); }
@media (hover: hover) and (pointer: fine) {
  .dropzone:hover { border-color: var(--gray-400); }
}
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-border);
  color: var(--text-secondary);
}
.dropzone-title { font-weight: 500; }
.dropzone-sub { font-size: var(--text-sm); color: var(--text-tertiary); }

.examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.example {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  box-shadow: var(--shadow-border);
  transition-property: scale, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.example:has(.example-main:active) { scale: 0.96; }
@media (hover: hover) and (pointer: fine) {
  .example:hover { box-shadow: var(--shadow-border-hover); }
}
.example-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: start; }
/* stretch the main button over the whole card; the PDF link sits above it */
.example-main::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.example-main:focus-visible { outline: none; }
.example:has(.example-main:focus-visible) { outline: 2px solid var(--accent-solid); outline-offset: 2px; }
.example-pdf {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding-inline: 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  flex: none;
  transition-property: background-color, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.example-pdf .icon { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) {
  .example-pdf:hover { background: var(--bg-hover); color: var(--text-primary); }
}
.example-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent-text);
  flex: none;
}
.example-title { font-weight: 500; font-size: var(--text-base); }
.example-sub { font-size: var(--text-xs); color: var(--text-tertiary); }

.or-divider { display: flex; align-items: center; gap: 12px; font-size: var(--text-xs); color: var(--text-tertiary); }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--separator); }

.invoice-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--separator);
  border-bottom: 1px solid var(--separator);
}
.invoice-meta > div { background: var(--bg-surface); padding: 12px 20px; display: grid; gap: 2px; }
.invoice-meta dt { font-size: var(--text-xs); color: var(--text-tertiary); }
.invoice-meta dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.options-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 24px; align-items: start; }
.mode-desc { margin-top: 10px; font-size: var(--text-sm); color: var(--text-secondary); min-height: 40px; max-width: 58ch; text-wrap: pretty; }

.start-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* ───────────────────────── Tables ───────────────────────── */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  padding: 10px 12px;
  text-align: start;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--separator);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--separator); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-inline-start: 20px; }
.table th:last-child, .table td:last-child { padding-inline-end: 20px; }
.table .r { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .txt { color: var(--text-secondary); min-width: 220px; }
.table tfoot td { font-weight: 600; background: var(--bg-subtle); border-top: 1px solid var(--separator); border-bottom: 0; }
.table tr.is-flagged td { background: oklch(0.985 0.012 25); }
.table tr.is-flagged td:first-child { box-shadow: inset 2px 0 0 var(--danger-solid); }
.table tr.is-added td { background: var(--success-subtle); }
.table tr.is-added td:first-child { box-shadow: inset 2px 0 0 var(--success-solid); }
.table tr.is-removed td { background: var(--danger-subtle); color: var(--text-tertiary); }
.table tr.is-removed td:not(:first-child) { text-decoration: line-through; text-decoration-color: oklch(0.58 0.2 27 / 0.5); }
.table tr.is-removed td:first-child { box-shadow: inset 2px 0 0 var(--danger-solid); }
.table tr.is-changed td:first-child { box-shadow: inset 2px 0 0 var(--warning-solid); }
.was { color: var(--text-tertiary); text-decoration: line-through; margin-inline-end: 6px; font-weight: 400; }
.now { font-weight: 600; color: var(--text-primary); }

/* ───────────────────────── Tabs (transitions.dev #16) ───────────────────────── */

.t-tabs {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-muted);
}
.t-tab {
  position: relative;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  height: 30px;
  padding: 4px 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 7px;
  z-index: 1;
  white-space: nowrap;
  transition: color var(--tabs-dur) var(--tabs-ease);
}
.t-tab[aria-selected="true"], .t-tab[aria-checked="true"] { color: var(--text-primary); }
@media (hover: hover) and (pointer: fine) { .t-tab:hover { color: var(--text-primary); } }
.t-tab:focus-visible { outline-offset: -2px; }
.t-tab .count {
  min-width: 18px;
  height: 18px;
  padding-inline: 5px;
  border-radius: 999px;
  font-size: var(--text-xs);
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: oklch(0 0 0 / 0.06);
  color: var(--text-secondary);
}
.t-tab .count--danger { background: var(--danger-subtle); color: var(--danger-text); }
.t-tabs-pill {
  position: absolute;
  top: 3px;
  left: 0;
  height: 30px;
  width: 0;
  background: var(--bg-surface);
  border-radius: 7px;
  box-shadow: 0 0 0 1px oklch(0 0 0 / 0.04), 0 1px 2px oklch(0 0 0 / 0.08);
  transform: translateX(0);
  transition:
    transform var(--tabs-dur) var(--tabs-ease),
    width var(--tabs-dur) var(--tabs-ease);
  will-change: transform;
  z-index: 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .t-tabs-pill, .t-tab { transition: none !important; }
}

.tab-panels { margin-top: 16px; }
.tab-panel[hidden] { display: none; }

/* Text swap for the mode description (transitions.dev #04) */
.t-swap { transition: opacity var(--duration-quick) ease-in-out, filter var(--duration-quick) ease-in-out, translate var(--duration-quick) ease-in-out; }
.t-swap.is-out { opacity: 0; filter: blur(var(--blur-small)); translate: 0 calc(var(--distance-micro) * -1); }
.t-swap.is-in-start { transition: none; opacity: 0; filter: blur(var(--blur-small)); translate: 0 var(--distance-micro); }
@media (prefers-reduced-motion: reduce) { .t-swap { transition: opacity var(--duration-quick) ease-in-out; filter: none !important; translate: none !important; } }

/* ───────────────────────── Toggle ───────────────────────── */

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-sm); font-weight: 500; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--gray-300);
  transition: background-color var(--duration-quick) ease-out;
  flex: none;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-0);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.2);
  transition: translate var(--duration-fast) var(--ease-smooth-out);
}
.toggle input:checked + .toggle-track { background: var(--accent-solid); }
.toggle input:checked + .toggle-track::after { translate: 14px 0; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent-solid); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .toggle-track, .toggle-track::after { transition: none; } }

/* ───────────────────────── Running state ───────────────────────── */

.running {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 44px 24px 36px;
  text-align: center;
}
.orbit {
  position: relative;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent-text);
}
.orbit::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--indigo-100);
  border-top-color: var(--accent-solid);
  animation: spin 900ms linear infinite;
}
@media (prefers-reduced-motion: reduce) { .orbit::before { animation-duration: 2400ms; } }
.orbit .icon { width: 24px; height: 24px; }
.running-foot { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); color: var(--text-tertiary); }
.running-note { font-size: var(--text-sm); color: var(--text-tertiary); max-width: 44ch; text-wrap: pretty; }

/* transitions.dev #28 — thinking states */
.t-think { position: relative; display: inline-block; text-align: center; font-size: var(--text-md); font-weight: 500; }
.t-think-sizer { display: block; visibility: hidden; white-space: nowrap; }
.t-think-text {
  --think-base: var(--text-tertiary);
  --think-highlight: var(--text-primary);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: block;
  color: var(--think-base);
  white-space: nowrap;
  transform: translateY(0);
  filter: blur(0);
  opacity: 1;
  transition:
    transform var(--think-swap) var(--think-ease),
    filter var(--think-swap) var(--think-ease),
    opacity var(--think-swap) var(--think-ease);
  will-change: transform, filter, opacity;
}
.t-think-text::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(90deg,
    transparent 0%, transparent 40%,
    var(--think-highlight) 50%,
    transparent 60%, transparent 100%);
  background-size: 400% 100%;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: t-think-shimmer var(--think-shimmer) linear infinite;
}
@keyframes t-think-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0% 0; }
}
.t-think-text.is-exit {
  transform: translateY(calc(var(--think-distance) * -1));
  filter: blur(var(--think-blur));
  opacity: 0;
}
.t-think-text.is-enter-start {
  transition: none;
  transform: translateY(var(--think-distance));
  filter: blur(var(--think-blur));
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .t-think-text { transition: none !important; transform: none !important; filter: none !important; }
  .t-think-text::before { display: none !important; }
}

/* Skeleton (transitions.dev #14 pulse) */
.skel-block { border-radius: var(--radius-lg); background: var(--bg-surface); box-shadow: var(--shadow-border); padding: 20px; display: grid; gap: 10px; }
.skel-line { height: 10px; border-radius: 5px; background: var(--gray-150); animation: t-skel-pulse 1400ms ease-in-out infinite; }
.skel-line:nth-child(2) { width: 80%; animation-delay: 80ms; }
.skel-line:nth-child(3) { width: 55%; animation-delay: 160ms; }
@keyframes t-skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .skel-line { animation: none; } }

/* ───────────────────────── Result ───────────────────────── */

.verdict {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px;
}
.verdict-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.verdict-icon .icon { width: 22px; height: 22px; }
.verdict--ok .verdict-icon { background: var(--success-subtle); color: var(--success-text); }
.verdict--warn .verdict-icon { background: var(--warning-subtle); color: var(--warning-text); }
.verdict--bad .verdict-icon { background: var(--danger-subtle); color: var(--danger-text); }
.verdict-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; text-wrap: balance; }
.verdict-sub { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }

.meter { display: grid; gap: 6px; justify-items: end; }
.meter-bars { display: flex; gap: 3px; }
.meter-bars span { width: 22px; height: 6px; border-radius: 3px; background: var(--gray-200); }
.meter[data-level="niedrig"] .meter-bars span:nth-child(-n + 1) { background: var(--danger-solid); }
.meter[data-level="mittel"] .meter-bars span:nth-child(-n + 2) { background: var(--warning-solid); }
.meter[data-level="hoch"] .meter-bars span:nth-child(-n + 3) { background: var(--success-solid); }
.meter-label { font-size: var(--text-xs); color: var(--text-tertiary); }
.meter-label strong { color: var(--text-primary); font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--separator);
}
.stat { padding: 14px 20px; display: grid; gap: 2px; }
.stat + .stat { border-inline-start: 1px solid var(--separator); }
.stat-label { font-size: var(--text-xs); color: var(--text-tertiary); }
.stat-value { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-value small { display: inline-block; white-space: nowrap; font-size: var(--text-sm); font-weight: 500; color: var(--text-tertiary); letter-spacing: 0; margin-inline-start: 4px; }
.stat-value--pos { color: var(--success-text); }

.verdict-summary {
  padding: 14px 20px;
  border-top: 1px solid var(--separator);
  color: var(--text-secondary);
  line-height: 1.6;
}
.verdict-summary span { display: block; max-width: 90ch; text-wrap: pretty; }
.notes { display: grid; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--separator); background: var(--bg-subtle); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.note { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; font-size: var(--text-sm); color: var(--text-secondary); text-wrap: pretty; }
.note .icon { margin-top: 2px; color: var(--text-tertiary); }

.tabs-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Finding cards */
.finding { overflow: hidden; }
.finding-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 20px 0;
}
.finding-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.finding-title { font-size: var(--text-md); font-weight: 500; line-height: 1.4; letter-spacing: -0.01em; text-wrap: pretty; }
.finding-body { padding: 8px 20px 16px; display: grid; gap: 12px; }
.finding-text { color: var(--text-secondary); font-size: var(--text-base); line-height: 1.55; max-width: 72ch; text-wrap: pretty; }
.finding-text strong { color: var(--text-primary); font-weight: 500; }
.finding-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 20px;
  border-top: 1px solid var(--separator);
  background: var(--bg-subtle);
}
.finding.is-flash { animation: flash 1200ms var(--ease-smooth-out); }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-border); } 100% { box-shadow: var(--shadow-border); } }

.quote {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  box-shadow: inset 2px 0 0 var(--border-strong);
  font-size: var(--text-sm);
}
.quote-text { color: var(--text-primary); font-style: italic; text-wrap: pretty; }
.quote-src { display: flex; align-items: center; gap: 6px; color: var(--text-tertiary); font-size: var(--text-xs); }

.section-label { font-size: var(--text-xs); font-weight: 500; color: var(--text-tertiary); margin-bottom: -4px; }

/* Repair options (radio cards) */
.options { display: grid; gap: 8px; }
.option {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-border);
  text-align: start;
  cursor: pointer;
  transition-property: box-shadow, background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .option:hover { box-shadow: var(--shadow-border-hover); }
}
.option:focus-visible { outline-offset: 2px; }
.option[aria-checked="true"] {
  background: oklch(0.985 0.008 272);
  box-shadow: 0 0 0 1.5px var(--accent-solid), 0 1px 2px oklch(0.3 0.15 272 / 0.12);
}
.radio {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  display: grid;
  place-items: center;
  transition: box-shadow var(--check-box) var(--check-ease);
}
.radio::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-on-solid);
  scale: 0.25;
  opacity: 0;
  transition-property: scale, opacity;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-icon);
}
.option[aria-checked="true"] .radio { box-shadow: inset 0 0 0 9px var(--accent-solid); }
.option[aria-checked="true"] .radio::after { scale: 1; opacity: 1; }
.option-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.option-name { font-weight: 600; font-size: var(--text-base); }
.option-comment { margin-top: 4px; font-size: var(--text-sm); color: var(--text-secondary); text-wrap: pretty; }
.actions-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.actions-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: var(--text-sm); }
.act { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-tertiary); min-width: 64px; }
.act--entfernen { color: var(--danger-text); }
.act--ergaenzen { color: var(--success-text); }
.act--ersetzen, .act--anpassen { color: var(--warning-text); }

/* Checkbox (transitions.dev #25) */
.t-check {
  position: relative;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--bg-surface);
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  color: var(--text-on-solid);
  flex: none;
  transition:
    background var(--check-box) var(--check-ease),
    box-shadow var(--check-box) var(--check-ease);
}
/* 18px box, 30px hit area */
.t-check::after { content: ""; position: absolute; inset: -6px; }
.t-check svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.t-check svg path {
  stroke-dasharray: var(--check-len, 22);
  stroke-dashoffset: var(--check-len, 22);
  transition: stroke-dashoffset var(--check-uncheck) var(--check-ease);
}
.t-check[aria-checked="true"] { background: var(--accent-solid); box-shadow: inset 0 0 0 1.5px var(--accent-solid); }
.t-check[aria-checked="true"] svg path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--check-draw) var(--check-ease);
}
@media (prefers-reduced-motion: reduce) {
  .t-check, .t-check svg path, .radio, .radio::after { transition: none !important; }
}

/* Optimization card */
.opt {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  transition: box-shadow 150ms ease-out;
}
@media (hover: hover) and (pointer: fine) { .opt:not(.is-selected):hover { box-shadow: var(--shadow-border-hover); } }
.opt.is-selected { box-shadow: 0 0 0 1.5px var(--accent-solid), 0 1px 2px oklch(0.3 0.15 272 / 0.12); }
.opt .t-check { margin-top: 2px; }
.opt-value { text-align: end; display: grid; gap: 6px; justify-items: end; align-content: start; }
.opt-euro { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; color: var(--success-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.opt-euro--none { color: var(--text-tertiary); font-size: var(--text-sm); font-weight: 500; }
.opt-euro--neg { color: var(--text-secondary); }
.conf { display: grid; gap: 4px; justify-items: end; }
.conf-bar { width: 64px; height: 4px; border-radius: 2px; background: var(--gray-150); overflow: hidden; }
.conf-bar span { display: block; height: 100%; border-radius: 2px; background: var(--accent-solid); }
.conf-label { font-size: var(--text-xs); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.ask {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--accent-subtle);
  color: var(--accent-text);
  font-size: var(--text-sm);
  text-wrap: pretty;
}
.ask .icon { margin-top: 2px; }

/* Feedback buttons */
.fb { display: inline-flex; align-items: center; gap: 2px; }
.fb-label { font-size: var(--text-xs); color: var(--text-tertiary); margin-inline-end: 6px; }
.fb .icon-btn[aria-pressed="true"][data-action="accepted"] { color: var(--success-text); background: var(--success-subtle); }
.fb .icon-btn[aria-pressed="true"][data-action="rejected"] { color: var(--danger-text); background: var(--danger-subtle); }

/* Follow-up list */
.followups { display: grid; }
.followup { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 16px 20px; }
.followup + .followup { border-top: 1px solid var(--separator); }
.followup-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--warning-subtle); color: var(--warning-text); }
.followup-title { font-weight: 600; }
.followup-text { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; text-wrap: pretty; }
.followup-how { font-size: var(--text-sm); margin-top: 6px; text-wrap: pretty; }

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
}
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--success-subtle); color: var(--success-text); }
.empty-icon--neutral { background: var(--bg-muted); color: var(--text-tertiary); }
.empty-title { font-weight: 600; }
.empty-sub { font-size: var(--text-sm); color: var(--text-secondary); max-width: 46ch; text-wrap: pretty; }

/* Error card */
.error-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; padding: 20px; }
.error-card .verdict-icon { background: var(--danger-subtle); color: var(--danger-text); }
.error-detail { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-subtle); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); overflow-wrap: anywhere; }

/* ───────────────────────── Sticky action bar ───────────────────────── */

body:has(.actionbar.is-open) .toaster { bottom: 92px; }
.actionbar {
  position: fixed;
  left: calc(var(--sidebar-w) + (100% - var(--sidebar-w)) / 2);
  bottom: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - var(--sidebar-w) - 32px);
  padding: 8px 8px 8px 18px;
  border-radius: 16px;
  background: var(--gray-900);
  color: var(--gray-0);
  box-shadow: 0 12px 32px -8px oklch(0 0 0 / 0.35), 0 0 0 1px oklch(0 0 0 / 0.1);
  translate: -50% 12px;
  opacity: 0;
  visibility: hidden;
  filter: blur(var(--toast-blur));
  pointer-events: none;
  transition:
    translate var(--toast-close) var(--toast-ease),
    opacity var(--toast-close) var(--toast-ease),
    filter var(--toast-close) var(--toast-ease),
    visibility 0s linear var(--toast-close);
}
.actionbar.is-open {
  translate: -50% 0;
  opacity: 1;
  visibility: visible;
  filter: blur(0);
  pointer-events: auto;
  transition:
    translate var(--toast-open) var(--toast-ease),
    opacity var(--toast-open) var(--toast-ease),
    filter var(--toast-open) var(--toast-ease),
    visibility 0s;
}
.actionbar-text { font-size: var(--text-sm); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* H6: the apply status line lives on a dark surface */
.actionbar .t-think { font-size: var(--text-sm); text-align: start; }
.actionbar .t-think-text { --think-base: var(--gray-400); --think-highlight: var(--gray-0); text-align: start; }
.actionbar .btn { flex: none; }
.actionbar .short { display: none; }
.actionbar-text strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.actionbar .btn--ghost { color: var(--gray-300); }
@media (hover: hover) and (pointer: fine) {
  .actionbar .btn--ghost:hover { background: oklch(1 0 0 / 0.08); color: var(--gray-0); }
}
.actionbar .btn--primary { box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.16); }
@media (prefers-reduced-motion: reduce) {
  .actionbar { transition: opacity var(--duration-quick) ease !important; filter: none !important; }
}

/* ───────────────────────── Apply result ───────────────────────── */

.applied-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 20px; }
.delta { display: grid; justify-items: end; gap: 2px; }
.delta-value { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.delta-value.is-up { color: var(--success-text); }
.change-list { display: grid; }
.change { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 12px 20px; align-items: baseline; }
.change + .change { border-top: 1px solid var(--separator); }
.change-text { font-size: var(--text-sm); color: var(--text-secondary); text-wrap: pretty; }
.change-text strong { color: var(--text-primary); font-weight: 500; }

/* transitions.dev #10 — success check */
.t-success-check {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--success-subtle);
  color: var(--success-text);
  transform-origin: center;
  opacity: 0;
  will-change: transform, opacity, filter;
}
.t-success-check svg { width: 22px; height: 22px; display: block; overflow: visible; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-success-check svg path { stroke-dasharray: 22; stroke-dashoffset: 22; }
.t-success-check[data-state="in"] {
  animation:
    t-check-fade var(--sc-dur) var(--sc-ease) forwards,
    t-check-rotate var(--sc-dur) var(--sc-ease) forwards,
    t-check-blur var(--sc-dur) var(--sc-ease) forwards,
    t-check-bob var(--sc-dur) var(--sc-ease-bob) forwards;
}
.t-success-check[data-state="in"] svg path { animation: t-check-draw var(--sc-dur) var(--sc-ease) var(--sc-path-delay) forwards; }
@keyframes t-check-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes t-check-rotate { from { transform: rotate(40deg); } to { transform: rotate(0deg); } }
@keyframes t-check-blur { from { filter: blur(8px); } to { filter: blur(0); } }
@keyframes t-check-bob { from { translate: 0 16px; } to { translate: 0 0; } }
@keyframes t-check-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .t-success-check { animation: none !important; opacity: 1; }
  .t-success-check svg path { animation: none !important; stroke-dashoffset: 0 !important; }
}

/* ───────────────────────── Enter animation (transitions.dev #18) ───────────────────────── */

.t-stagger-line {
  opacity: 0;
  transform: translateY(var(--stagger-distance));
  filter: blur(var(--stagger-blur));
  transition:
    opacity var(--stagger-dur) var(--stagger-ease),
    transform var(--stagger-dur) var(--stagger-ease),
    filter var(--stagger-dur) var(--stagger-ease);
  transition-delay: calc(var(--i, 0) * 100ms);
}
.t-stagger.is-shown .t-stagger-line { opacity: 1; transform: none; filter: none; }
@media (prefers-reduced-motion: reduce) {
  .t-stagger-line { transition: opacity 200ms ease !important; transform: none !important; filter: none !important; transition-delay: 0ms !important; }
}

/* ───────────────────────── Toasts (transitions.dev #22) ───────────────────────── */

.toaster {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transition: bottom var(--duration-fast) var(--ease-smooth-out);
  z-index: 50;
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: none;
}
.t-toast {
  overflow-wrap: anywhere;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-raised);
  font-size: var(--text-sm);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(var(--toast-distance)) scale(var(--toast-scale));
  filter: blur(var(--toast-blur));
  will-change: transform, opacity, filter;
  transition:
    opacity var(--toast-close) var(--toast-ease),
    transform var(--toast-close) var(--toast-ease),
    filter var(--toast-close) var(--toast-ease);
}
.t-toast.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  transition:
    opacity var(--toast-open) var(--toast-ease),
    transform var(--toast-open) var(--toast-ease),
    filter var(--toast-open) var(--toast-ease);
}
.t-toast .icon { margin-top: 2px; }
.t-toast--success .icon { color: var(--success-text); }
.t-toast--error .icon { color: var(--danger-text); }
.toast-title { font-weight: 500; }
.toast-text { color: var(--text-secondary); margin-top: 1px; overflow-wrap: anywhere; }
.toast-close { margin: -4px -6px -4px 0; }
@media (prefers-reduced-motion: reduce) {
  .t-toast { transition: none !important; }
}

/* ───────────────────────── Responsive ───────────────────────── */

@media (max-width: 960px) {
  .examples { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-inline-start: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--separator); }
  .invoice-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .options-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .actionbar .js-clear, .actionbar .long { display: none; }
  .actionbar .short { display: inline; }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-inline-end: 0; border-bottom: 1px solid var(--separator); }
  .sidebar-section { max-height: 200px; }
  .view { padding: 24px 16px 120px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .verdict { grid-template-columns: auto minmax(0, 1fr); }
  .verdict .meter { grid-column: 1 / -1; justify-items: start; }
  .opt { grid-template-columns: 18px minmax(0, 1fr); }
  .opt-value { grid-column: 2; justify-items: start; text-align: start; }
  .actionbar { left: 50%; width: calc(100% - 32px); gap: 8px; }
  .actionbar-text { flex: 1; }
}

/* ───────────────────────── Motion & contrast preferences ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled), .icon-btn:active, .example:has(.example-main:active) { scale: 1; }
  .t-shake-target.is-shaking { animation: none; }
  .dot--queued, .dot--processing { animation: none; }
  .orbit::before { animation: none; border-color: var(--accent-solid); opacity: 0.4; }
  .spinner { animation-duration: 1600ms; }
  .toaster { transition: none; }
}

@media (forced-colors: active) {
  .radio, .t-check { border: 1px solid CanvasText; }
  .option[aria-checked="true"], .opt.is-selected { outline: 2px solid Highlight; }
  .option[aria-checked="true"] .radio, .t-check[aria-checked="true"] { background: Highlight; }
  .card, .option, .example, .btn--secondary { border: 1px solid CanvasText; }
}
