/* ==========================================================================
   xTRACT Operator Console — design system
   Ink-on-paper monochrome taken from the mark: scan brackets, pixel squares,
   text lines. Colour is reserved for workflow state (review, valid, failed).
   ========================================================================== */

:root {
  color-scheme: light;
  --paper: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --surface-3: #e9e9e5;
  --line: #e4e4df;
  --line-strong: #cdcdc6;
  --ink: #111111;
  --ink-2: #2e2e2c;
  --muted: #676762;
  --faint: #9b9b94;
  --on-ink: #ffffff;
  --marker: #fff1a6;
  --marker-ink: #5a4700;

  --brand-accent: #111111;
  --brand-accent-ink: #ffffff;

  --success: #13773f;
  --success-soft: #e4f3ea;
  --warn: #a15c00;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --danger-soft: #fbe7e5;
  --info: #3b4bb8;
  --info-soft: #e9ebfa;
  --neutral-soft: #ededea;

  --shadow-sm: 0 1px 0 rgb(17 17 17 / 4%), 0 1px 2px rgb(17 17 17 / 6%);
  --shadow-md: 0 1px 2px rgb(17 17 17 / 6%), 0 8px 24px -8px rgb(17 17 17 / 16%);
  --shadow-lg: 0 24px 64px -16px rgb(17 17 17 / 28%), 0 2px 6px rgb(17 17 17 / 8%);
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-sans: "Inter", "InterVariable", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: "Inter Display", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  --nav-w: 68px;
  --topbar-h: 60px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0b0b0c;
    --surface: #141415;
    --surface-2: #1a1a1c;
    --surface-3: #232326;
    --line: #262629;
    --line-strong: #37373b;
    --ink: #f4f4f1;
    --ink-2: #d9d9d4;
    --muted: #9c9c96;
    --faint: #6b6b67;
    --on-ink: #0b0b0c;
    --marker: #4a3f0a;
    --marker-ink: #ffe98a;
    --brand-accent: #f4f4f1;
    --brand-accent-ink: #0b0b0c;
    --success: #5fd08d;
    --success-soft: #11291b;
    --warn: #f2b35b;
    --warn-soft: #2e2311;
    --danger: #ff8a80;
    --danger-soft: #331715;
    --info: #9aa6ff;
    --info-soft: #1a1d36;
    --neutral-soft: #202023;
    --shadow-sm: none;
    --shadow-md: 0 0 0 1px var(--line), 0 12px 32px -12px rgb(0 0 0 / 60%);
    --shadow-lg: 0 0 0 1px var(--line-strong), 0 32px 80px -16px rgb(0 0 0 / 70%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0b0c;
  --surface: #141415;
  --surface-2: #1a1a1c;
  --surface-3: #232326;
  --line: #262629;
  --line-strong: #37373b;
  --ink: #f4f4f1;
  --ink-2: #d9d9d4;
  --muted: #9c9c96;
  --faint: #6b6b67;
  --on-ink: #0b0b0c;
  --marker: #4a3f0a;
  --marker-ink: #ffe98a;
  --brand-accent: #f4f4f1;
  --brand-accent-ink: #0b0b0c;
  --success: #5fd08d;
  --success-soft: #11291b;
  --warn: #f2b35b;
  --warn-soft: #2e2311;
  --danger: #ff8a80;
  --danger-soft: #331715;
  --info: #9aa6ff;
  --info-soft: #1a1d36;
  --neutral-soft: #202023;
  --shadow-sm: none;
  --shadow-md: 0 0 0 1px var(--line), 0 12px 32px -12px rgb(0 0 0 / 60%);
  --shadow-lg: 0 0 0 1px var(--line-strong), 0 32px 80px -16px rgb(0 0 0 / 70%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

body.busy { cursor: progress; }

::selection { background: var(--ink); color: var(--on-ink); }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  line-height: 1.2;
}

p { margin: 0; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.xs { width: 14px; height: 14px; stroke-width: 2; }
.icon.sm { width: 16px; height: 16px; stroke-width: 1.9; }
.icon.xl { width: 32px; height: 32px; stroke-width: 1.4; }
.icon.faint { color: var(--faint); }

.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;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--on-ink);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: none; box-shadow: var(--focus); }

.mono { font-family: var(--font-mono); font-size: 0.86em; letter-spacing: -0.01em; }
.meta { color: var(--muted); font-size: 12.5px; }
.meta .icon { vertical-align: -2px; }
.note { color: var(--muted); font-size: 13px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
}

/* --- Scan brackets: the mark's four corners, reusable on any frame ------- */

.brackets {
  --bk: var(--ink);
  --bl: 16px;
  --bw: 2px;
  background-image:
    linear-gradient(var(--bk), var(--bk)), linear-gradient(var(--bk), var(--bk)),
    linear-gradient(var(--bk), var(--bk)), linear-gradient(var(--bk), var(--bk)),
    linear-gradient(var(--bk), var(--bk)), linear-gradient(var(--bk), var(--bk)),
    linear-gradient(var(--bk), var(--bk)), linear-gradient(var(--bk), var(--bk));
  background-repeat: no-repeat;
  background-size:
    var(--bl) var(--bw), var(--bw) var(--bl),
    var(--bl) var(--bw), var(--bw) var(--bl),
    var(--bl) var(--bw), var(--bw) var(--bl),
    var(--bl) var(--bw), var(--bw) var(--bl);
  background-position:
    left top, left top,
    right top, right top,
    left bottom, left bottom,
    right bottom, right bottom;
}

/* --- Buttons ------------------------------------------------------------- */

.btn,
button.small,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms, transform 80ms;
}
.btn:hover, .button:hover, button.small:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active, .button:active { transform: translateY(1px); }
.btn:disabled, button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--on-ink);
}
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.primary kbd { border-color: color-mix(in srgb, var(--on-ink) 30%, transparent); background: transparent; color: color-mix(in srgb, var(--on-ink) 70%, transparent); }

.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }

.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.btn.icon-only { width: 34px; padding: 0; }

button.small, .btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
button.link, .btn.link { border-color: transparent; background: transparent; color: var(--muted); padding: 0 6px; }
button.link:hover, .btn.link:hover { color: var(--ink); background: var(--surface-2); }

/* --- Pills ---------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
  background: currentColor;
}
.pill:has(.icon)::before { display: none; }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: var(--neutral-soft); color: var(--muted); }
.pill.live::before { animation: blink 1.2s steps(2, jump-none) infinite; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.tag.warn { border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }

/* --- App frame ------------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.nav-brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  transition: transform 160ms;
}
.nav-brand:hover { transform: rotate(-4deg) scale(1.04); }
.nav-brand img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 1px 1px rgb(0 0 0 / 12%)); }

.nav-group { display: flex; flex-direction: column; gap: 6px; }
.nav-bottom { margin-top: auto; }

.nav-item {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--ink); color: var(--on-ink); }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ink);
}

.nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  z-index: 40;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-4px, -50%);
  transition: opacity 120ms, transform 120ms;
}
.nav-item:hover::after, .nav-item:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

.nav-badge {
  position: absolute;
  top: 3px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
.nav-badge:empty { display: none; }
.nav-badge.muted { background: var(--surface-3); color: var(--ink-2); }
.nav-badge.danger { background: var(--danger); }

.nav-item.avatar {
  width: 36px;
  height: 36px;
  margin: 4px auto 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.main {
  display: grid;
  grid-template-rows: var(--topbar-h) auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  /* Keep the backdrop-filter stacking context above the pipeline and workspace. */
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
}
.wordmark {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.wordmark b { font-weight: 800; letter-spacing: 0.04em; }
#crumb-list { color: var(--muted); font-weight: 500; }

.search {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  height: 38px;
  margin: 0 auto;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.search:focus-within { border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}
.search input::placeholder { color: var(--faint); }
.search input:focus-visible { box-shadow: none; }
.search:focus-within .search-kbd { display: none; }

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border-left: 1px solid var(--line);
}
.select-wrap select {
  max-width: 150px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}

.toolbar { display: flex; align-items: center; gap: 8px; }

.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.engine-status .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--success); }
.engine-status.degraded .dot { background: var(--warn); }

.menu { position: relative; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: grid;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop 140ms ease-out;
}
.menu-label { padding: 6px 10px 4px; color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.menu-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
}
.menu-list a:hover, .menu-list a:focus-visible { background: var(--surface-2); }
.fmt {
  min-width: 46px;
  padding: 2px 0;
  border-radius: 4px;
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

/* --- Pipeline ------------------------------------------------------------ */

.pipeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  flex: 1 1 0;
  min-width: 140px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
}
.stage:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stage[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.stage .stage-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.stage[data-tone="warn"] .stage-icon { background: var(--warn-soft); color: var(--warn); }
.stage[data-tone="success"] .stage-icon { background: var(--success-soft); color: var(--success); }
.stage[data-tone="danger"] .stage-icon { background: var(--danger-soft); color: var(--danger); }
.stage strong { font-family: var(--font-mono); font-size: 20px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }
.stage span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stage .bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ink) var(--share, 0%), transparent 0);
  opacity: 0.8;
}
.stage[data-tone="warn"] .bar { background: linear-gradient(90deg, var(--warn) var(--share, 0%), transparent 0); }
.stage[data-tone="danger"] .bar { background: linear-gradient(90deg, var(--danger) var(--share, 0%), transparent 0); }
.stage[data-tone="success"] .bar { background: linear-gradient(90deg, var(--success) var(--share, 0%), transparent 0); }

.flow-arrow { display: grid; place-items: center; width: 22px; flex: none; color: var(--faint); }
.flow-arrow .icon { width: 14px; height: 14px; }
.flow-sep { width: 1px; margin: 4px 14px; flex: none; background: var(--line); }
.stage.side { flex: 0.8 1 0; }

/* --- Three-pane shell ---------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr) minmax(300px, 360px);
  min-height: 0;
}

.list-pane, .inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
.list-pane { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }

.pane-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
}
.pane-head h2 { font-size: 18px; }
.count-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.count-chip:empty { display: none; }

.list-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 10px; }
.list-filters .btn { height: 26px; font-size: 12px; }

.item-list {
  display: grid;
  gap: 2px;
  align-content: start;
  margin: 0;
  padding: 0 10px 18px;
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.item-button {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.item-button:hover { background: var(--surface-2); }
.item-button.active {
  border-color: var(--line-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.item-button.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ink);
}
.item-body { display: grid; gap: 3px; min-width: 0; }
.item-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.item-title > span:first-child { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.item-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.item-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.file-glyph {
  position: relative;
  display: grid;
  place-items: end center;
  width: 32px;
  height: 40px;
  padding-bottom: 5px;
  border: 1.5px solid var(--ink);
  border-radius: 4px 10px 4px 4px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.file-glyph::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 9px;
  top: 8px;
  height: 9px;
  background: repeating-linear-gradient(var(--line-strong) 0 1.5px, transparent 1.5px 4px);
}
.file-glyph[data-kind="pdf"] { background: var(--ink); color: var(--on-ink); }
.file-glyph[data-kind="pdf"]::before { background: repeating-linear-gradient(color-mix(in srgb, var(--on-ink) 40%, transparent) 0 1.5px, transparent 1.5px 4px); }
.file-glyph[data-kind="img"] { border-style: dashed; }
.file-glyph.lg { width: 44px; height: 54px; padding-bottom: 7px; font-size: 10px; border-radius: 5px 14px 5px 5px; }
.file-glyph.lg::before { left: 8px; right: 12px; top: 11px; height: 13px; }

.empty {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.empty .icon { width: 28px; height: 28px; color: var(--faint); stroke-width: 1.4; }

.skeleton {
  height: 74px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* --- Workspace ----------------------------------------------------------- */

.workspace {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  outline: none;
}

.empty-workspace {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  min-height: 100%;
  padding: 48px 32px;
  text-align: center;
}
.empty-workspace h2 { font-size: 26px; letter-spacing: -0.025em; }
.empty-workspace > p { max-width: 460px; color: var(--muted); }
.empty-art {
  --bl: 22px;
  --bw: 3px;
  position: relative;
  display: grid;
  place-items: center;
  width: 168px;
  height: 168px;
  margin-bottom: 10px;
  border-radius: 8px;
}
.empty-art img { filter: drop-shadow(0 12px 24px rgb(0 0 0 / 14%)); animation: float 5s ease-in-out infinite; }
.pixels { position: absolute; right: -26px; top: 50%; display: grid; grid-template-columns: repeat(3, 10px); gap: 6px; transform: translateY(-50%); }
.pixels i { width: 10px; height: 10px; border-radius: 2px; background: var(--ink); animation: pixel 2.4s ease-in-out infinite; }
.pixels i:nth-child(2) { animation-delay: 0.3s; }
.pixels i:nth-child(3) { animation-delay: 0.6s; opacity: 0.4; }
.pixels i:nth-child(4) { animation-delay: 0.9s; }
.pixels i:nth-child(5) { animation-delay: 1.2s; opacity: 0.6; }
.pixels i:nth-child(6) { animation-delay: 1.5s; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.how {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 620px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: how;
}
.how li {
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  counter-increment: how;
}
.how li::before { content: "0" counter(how); color: var(--faint); font-family: var(--font-mono); font-size: 11px; }
.how span { color: var(--muted); font-size: 12.5px; }

.document-view { display: grid; gap: 16px; padding: 20px 22px 28px; }

.workspace-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.doc-id h2 { font-size: 22px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.doc-id .eyebrow { text-transform: none; letter-spacing: 0; font-family: var(--font-sans); font-size: 12.5px; }
.doc-id #doc-type { color: var(--muted); font-weight: 500; }
.doc-id .meta { margin-top: 4px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; }

.lifecycle {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lifecycle li {
  position: relative;
  display: grid;
  gap: 6px;
  padding-top: 20px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}
.lifecycle li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 3px;
  background: var(--paper);
  z-index: 1;
}
.lifecycle li::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 2px;
  top: 10px;
  height: 2px;
  background: var(--line);
}
.lifecycle li:last-child::after { display: none; }
.lifecycle li.done { color: var(--ink-2); }
.lifecycle li.done::before { border-color: var(--ink); background: var(--ink); }
.lifecycle li.done::after { background: var(--ink); }
.lifecycle li.current { color: var(--ink); font-weight: 650; }
.lifecycle li.current::before { border-color: var(--ink); background: var(--paper); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 12%, transparent); }
.lifecycle li.current.warn { color: var(--warn); }
.lifecycle li.current.warn::before { border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.lifecycle li.current.danger { color: var(--danger); }
.lifecycle li.current.danger::before { border-color: var(--danger); background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.lifecycle li.current.success { color: var(--success); }
.lifecycle li.current.success::before { border-color: var(--success); background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.lifecycle li.current.active::before { animation: pulse 1.4s ease-in-out infinite; }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
}
.pixel-loader { display: grid; grid-template-columns: repeat(2, 6px); gap: 3px; }
.pixel-loader i { width: 6px; height: 6px; border-radius: 1.5px; background: var(--ink); animation: loader 1s steps(1) infinite; }
.pixel-loader i:nth-child(2) { animation-delay: 0.25s; }
.pixel-loader i:nth-child(4) { animation-delay: 0.5s; }
.pixel-loader i:nth-child(3) { animation-delay: 0.75s; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 { font-size: 14.5px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
}
.segmented button {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

.viewer { position: sticky; top: 0; }
.viewer-body {
  --bl: 14px;
  position: relative;
  margin: 12px;
  padding: 10px 6px;
  border-radius: 6px;
  background-color: var(--surface-2);
  overflow: hidden;
}
.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 0 18px 4px color-mix(in srgb, var(--ink) 35%, transparent);
  opacity: 0;
  pointer-events: none;
}
.document-view.processing .scanline { opacity: 0.7; animation: scan 2.2s ease-in-out infinite alternate; }

.ocr-lines {
  max-height: calc(100vh - 360px);
  min-height: 280px;
  margin: 0;
  padding: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  list-style: none;
  counter-reset: line;
}
.ocr-lines li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  padding-right: 12px;
  border-radius: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  counter-increment: line;
}
.ocr-lines li::before {
  content: counter(line);
  padding-right: 12px;
  color: var(--faint);
  font-size: 11px;
  text-align: right;
  user-select: none;
}
.ocr-lines li:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.ocr-lines li.highlight { background: var(--marker); color: var(--marker-ink); animation: mark 900ms ease-out; }
.ocr-lines li.highlight::before { color: var(--marker-ink); font-weight: 700; }
.ocr-lines li.empty { display: grid; grid-template-columns: 1fr; font-family: var(--font-sans); }
.ocr-lines li.empty::before { display: none; }

.original { display: grid; gap: 10px; justify-items: start; padding: 6px; }
.original img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.original iframe { width: 100%; height: calc(100vh - 380px); min-height: 360px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* --- Fields ------------------------------------------------------------- */

.ring {
  --p: 0;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: conic-gradient(var(--ink) calc(var(--p) * 1%), var(--surface-3) 0);
}
.ring span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.ring.complete { background: conic-gradient(var(--success) 100%, transparent 0); }

.field-list { display: grid; gap: 10px; padding: 12px; }

.field-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 120ms, box-shadow 120ms;
}
.field-card:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }
.field-card.attention { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: linear-gradient(var(--warn-soft), var(--warn-soft)) left / 3px 100% no-repeat, var(--surface); }
.field-card.verified { background: linear-gradient(var(--success), var(--success)) left / 3px 100% no-repeat, var(--surface); }
.field-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-card label { font-size: 12.5px; font-weight: 650; }
.field-card .code { color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; margin-left: 6px; }
.required { color: var(--danger); }

.field-card input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 13.5px;
  transition: border-color 120ms, background 120ms;
}
.field-card input:hover:not(:disabled) { border-color: var(--faint); }
.field-card input:focus { border-color: var(--ink); background: var(--surface); outline: 0; box-shadow: none; }
.field-card input:disabled { color: var(--ink-2); opacity: 1; cursor: default; }
.field-card input.dirty { border-style: dashed; border-color: var(--ink); background: var(--surface); }

.field-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field-signal { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 12px; }
.field-signal .item-meta { font-size: 12px; }
.field-actions { display: flex; flex-wrap: wrap; gap: 4px; }

.meter { display: inline-grid; grid-template-columns: repeat(10, 5px); gap: 2px; flex: none; }
.meter i { width: 5px; height: 10px; border-radius: 1px; background: var(--surface-3); }
.meter i.on { background: var(--ink); }
.meter.low i.on { background: var(--warn); }
.meter.none i { background: var(--surface-3); }
.meter-value { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }

.history summary { color: var(--muted); font-size: 12px; cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.history summary::-webkit-details-marker { display: none; }
.history summary .icon { transition: transform 120ms; }
.history[open] summary .icon { transform: rotate(90deg); }
.history ol { display: grid; gap: 6px; margin: 8px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); list-style: none; }
.history li { display: grid; font-size: 12px; }
.history li strong { font-family: var(--font-mono); font-weight: 600; }

/* --- Inspector ---------------------------------------------------------- */

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.inspector-tabs button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 2px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
}
.inspector-tabs button:hover { background: var(--surface-2); color: var(--ink); }
.inspector-tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.inspector-tabs em {
  position: absolute;
  top: 3px;
  right: calc(50% - 20px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
}
.inspector-tabs em:empty { display: none; }

.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
}
.inspector-panel[hidden] { display: none; }
.panel-intro { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-intro h2 { font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.chip:hover:not(:disabled) { border-color: var(--ink); background: var(--surface-2); }

.composer {
  position: sticky;
  bottom: -16px;
  display: flex;
  gap: 6px;
  margin: auto -16px -16px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}
.composer input:focus { border-color: var(--ink); background: var(--surface); outline: 0; box-shadow: none; }
.composer .btn { height: 38px; width: 38px; border-radius: 10px; }

.answer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  animation: rise 200ms ease-out;
}
.answer header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.answer h3 { font-size: 14px; }
.answer > p { font-size: 13.5px; }
.answer .label { color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.citations { display: grid; gap: 8px; margin: 6px 0 0; padding: 0; list-style: none; counter-reset: cite; }
.citations li { position: relative; padding-left: 26px; font-size: 12.5px; counter-increment: cite; }
.citations li::before {
  content: counter(cite);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
blockquote {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-left: 2px solid var(--ink);
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.boundary {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stack { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card > strong { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; text-transform: capitalize; }
.card > p { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: linear-gradient(var(--danger), var(--danger)) left / 3px 100% no-repeat, var(--surface); }
.card.success { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); }
.card .button, .card button { justify-self: start; margin-top: 6px; }
.card .ref {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
}
.error-text { color: var(--danger); font-family: var(--font-mono); font-size: 12px; }

.timeline { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline li {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 0 0 16px 24px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--ink);
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: 2px;
  width: 1px;
  background: var(--line-strong);
}
.timeline li:last-child::after { display: none; }
.timeline li strong { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.timeline li p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.timeline li p:hover { -webkit-line-clamp: unset; }
.timeline li.failure::before { background: var(--danger); }
.timeline li.failure strong { color: var(--danger); }
.timeline li.human::before { background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }

/* --- Toasts ------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: rise 180ms ease-out;
}
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: var(--success); }
.toast.danger { background: var(--danger); color: #fff; }
.toast.danger .icon { color: #fff; }
:root[data-theme="dark"] .toast.success .icon { color: #13773f; }

/* --- Dialogs ------------------------------------------------------------ */

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop 180ms ease-out; }
dialog::backdrop { background: rgb(10 10 10 / 42%); backdrop-filter: blur(3px); }
#upload-dialog { width: min(640px, calc(100vw - 32px)); }

.dialog-form { display: grid; gap: 10px; padding: 20px 22px 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.dialog-head h2 { font-size: 19px; }
.dialog-form label { font-size: 12.5px; font-weight: 600; }
.dialog-form input[type="text"],
.dialog-form input[type="password"],
.dialog-form select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
}
.dialog-form input:focus, .dialog-form select:focus { border-color: var(--ink); background: var(--surface); outline: 0; box-shadow: none; }
.dialog-form .row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dialog-form .row > div { display: grid; gap: 6px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.dialog-actions > .meta { margin-right: auto; }

.dropzone {
  --bl: 20px;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 30px 20px;
  border-radius: 10px;
  background-color: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms;
}
.dropzone:hover, .dropzone.over { background-color: var(--surface-3); }
.dropzone strong { font-size: 14px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { box-shadow: var(--focus); }

.file-rows { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.file-rows:empty { display: none; }
.file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.file-row .file-glyph { width: 24px; height: 30px; font-size: 7px; padding-bottom: 3px; }
.file-row .file-glyph::before { left: 4px; right: 6px; top: 6px; height: 6px; }
.file-row .name { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.file-row.success { border-color: color-mix(in srgb, var(--success) 40%, var(--line)); }
.file-row.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.choice-group { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 8px; font-size: 12.5px; font-weight: 600; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input { margin-top: 3px; accent-color: var(--ink); }
.choice span { display: grid; }
.choice small { color: var(--muted); font-size: 12px; font-weight: 400; }

.institution-meta-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.institution-meta-card .institution-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}
.institution-meta-card .institution-tagline {
  font-size: 11.5px;
  color: var(--muted);
}
.institution-meta-card .institution-pack-badge,
.institution-meta-card .institution-user-badge {
  margin-top: 6px;
}

.engine-list { display: grid; gap: 6px; margin-top: 6px; }
.engine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.engine .reason { color: var(--faint); font-family: var(--font-sans); font-size: 11.5px; }

.shortcuts { display: grid; gap: 0; margin: 0; }
.shortcuts div { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.shortcuts div:last-child { border-bottom: 0; }
.shortcuts dt { display: flex; gap: 4px; }
.shortcuts dd { margin: 0; color: var(--ink-2); font-size: 13px; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(6px);
}
.drop-overlay[hidden] { display: none; }
.drop-target {
  --bl: 36px;
  --bw: 3px;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(560px, 100%);
  padding: 64px 24px;
  text-align: center;
  animation: pop 160ms ease-out;
}
.drop-target strong { font-family: var(--font-display); font-size: 22px; }
.drop-target span { color: var(--muted); }

/* --- Motion --------------------------------------------------------------- */

@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes pixel { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.55); opacity: 0.35; } }
@keyframes loader { 0% { opacity: 1; } 50% { opacity: 0.15; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes scan { from { top: 0; } to { top: calc(100% - 2px); } }
@keyframes mark { from { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1360px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .viewer { position: static; }
  .ocr-lines { max-height: 420px; }
}

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .shell { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .inspector-panel { max-height: none; }
  .list-pane { max-height: calc(100vh - 170px); position: sticky; top: 0; }
  .engine-status { display: none; }
}

@media (max-width: 760px) {
  :root { --nav-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    flex-direction: row;
    justify-content: space-around;
    height: 60px;
    padding: 8px 12px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .nav-brand, .nav-item[data-tip]::after { display: none; }
  .nav-group { flex-direction: row; }
  .nav-bottom { margin-top: 0; }
  .nav-item[aria-current="page"]::before { display: none; }
  .main { padding-bottom: 64px; grid-template-rows: auto auto minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .crumbs { flex: 1; }
  .crumbs > :not(.wordmark) { display: none; }
  .search { order: 3; flex-basis: 100%; }
  .search-kbd, .btn kbd, .select-wrap .icon { display: none; }
  .pipeline { padding: 12px 16px; }
  .shell { grid-template-columns: 1fr; }
  .list-pane { position: static; max-height: 360px; border-right: 0; border-bottom: 1px solid var(--line); }
  .document-view { padding: 16px; }
  .how { grid-template-columns: 1fr; }
  .viewer .panel-head { flex-wrap: wrap; }
  .dialog-form .row { grid-template-columns: 1fr; }
  .lifecycle li { font-size: 0; }
  .lifecycle li.current { font-size: 11px; }
}

body { display: flex; flex-direction: column; }
.app { flex: 1; min-height: 0; height: auto; }
.demo-notice { flex-shrink: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 8px 16px; background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.demo-notice span { flex: 1; font-size: 12px; }
.workspace { container-type: inline-size; }
@container (max-width: 750px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .viewer { position: static; }
  .ocr-lines { max-height: 420px; }
}
