/* Doc Ops — UI styles. Light, compact, works on desktop and tablet. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --border: #e2e4e9;
  --text: #1d2129;
  --muted: #6b7280;
  --primary: #2563eb;
  /* Background of filled buttons with --primary-ink text. */
  --primary-fill: var(--primary);
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  /* A card paged away from its first page (app.js). */
  --flipped-bg: #fde047;
  --flipped-ink: #422006;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1f232b;
    --surface-2: #262b34;
    --border: #333944;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    /* Text/icons on dark surfaces: 4.3:1. Filled buttons get a darker
       blue, so their white text reaches 5.2:1 (P3-9). */
    --primary: #3b82f6;
    --primary-fill: #2563eb;
    --warn: #f59e0b;
    --flipped-bg: #facc15;
    --flipped-ink: #1c1405;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must win over component display rules (.field is flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.muted { color: var(--muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary-fill); color: var(--primary-ink); border-color: var(--primary-fill); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.tiny { padding: 2px 10px; font-size: 16px; line-height: 1; font-weight: 600; }
.btn:disabled,
.btn[disabled] {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Clear-cache button: orange warning when documents are cached. */
.cache-btn.cache-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 55%, var(--border));
  background: transparent;
}
.cache-btn.cache-warn:hover {
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
}

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h2 { margin: 8px 0 4px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}
.brand { font-weight: 700; font-size: 20px; margin: 0; letter-spacing: -0.01em; }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.tagline { font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

/* Grid controls that live in the sticky nav. */
.nav-ctrl { display: flex; align-items: center; gap: 8px; }
.nav-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.nav-ctrl input[type="range"] { width: 180px; margin: 0; }
.nav-toggle { font-size: 12px; font-weight: 500; }
.topbar .fa-solid { font-size: 13px; }
.nav-label .fa-solid, .nav-toggle .fa-solid, .user-badge .fa-solid { color: var(--muted); }

.lang-switch { display: inline-flex; gap: 6px; font-size: 13px; }
.lang-switch a { color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.lang-switch a.active { color: var(--primary); font-weight: 600; background: var(--surface-2); }

/* ---- Layout ---- */
.layout { max-width: 1200px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.section-title { margin: 0 0 12px; font-size: 15px; }

/* ---- Config head (scrolls away with the page) ---- */
.config-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}
/* Top-aligned variant so a field's helper text can't push its control out of
   line with its neighbours (used by the sort / regex form). */
.config-grid-top { align-items: start; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; }
/* Label with its (i) button; the explanation opens in #info-dialog. */
.field-head { display: flex; align-items: center; gap: 4px; }
.info-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  line-height: 1;
  border-radius: 6px;
}
.info-btn:hover, .info-btn:focus-visible { color: var(--primary); }
.info-dialog {
  max-width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 18px 20px 14px;
}
.info-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.info-title { margin: 0 0 8px; font-size: 15px; }
.info-body { margin: 0 0 14px; white-space: pre-line; }
.info-actions { display: flex; justify-content: flex-end; margin: 0; }
.field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.field small { font-size: 11px; }
.field-actions { flex-direction: row; gap: 8px; align-items: center; }

.stepper { display: flex; align-items: stretch; }
.stepper input { border-radius: 0; text-align: center; }
.stepper .step {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  width: 34px;
  font-size: 11px;
}
.stepper .step:first-child { border-radius: 8px 0 0 8px; border-right: 0; }
.stepper .step:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.stepper input { border-radius: 0; }

/* ---- Range slider ---- */
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 6px 0;
}

/* ---- Toggle switch ---- */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Drop zone ---- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.drop-inner { padding: 34px 20px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.drop-icon { font-size: 28px; color: var(--primary); }
.drop-title { font-weight: 600; font-size: 16px; }

/* htmx's own indicator styles are disabled (CSP); these replace them. */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }

/* Drop zone modes: "new" PDF vs. appending the next part. */
.dropzone[data-mode="new"] .when-append,
.dropzone[data-mode="append"] .when-new { display: none; }
.dropzone[data-mode="append"] { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
/* Receiving an upload: the field is visibly blocked until it is done. */
.dropzone .when-busy { display: none; }
.dropzone.busy .when-busy { display: revert; }
.dropzone.busy .when-idle,
.dropzone.busy .when-new,
.dropzone.busy .when-append { display: none !important; }
.dropzone.busy {
  cursor: progress;
  border-style: solid;
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  animation: dropzone-pulse 1.6s ease-in-out infinite;
}
.dropzone.busy.reject { border-color: var(--warn); cursor: not-allowed; }
@keyframes dropzone-pulse {
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .dropzone.busy { animation: none; }
}
/* A file is being dragged somewhere over the page: show where to drop it. */
.dropzone.drag-active:not(.busy) { border-color: var(--primary); }
.dropzone:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.upload-status { width: min(460px, 100%); display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.upload-label { color: var(--primary); font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.upload-bar { width: 100%; height: 8px; accent-color: var(--primary); }

/* ---- Grid ---- */
.grid-wrap { min-height: 40px; }
.empty-hint { text-align: center; padding: 30px; }
.grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.grid-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-stats { display: flex; gap: 16px; }
.stat { font-size: 13px; color: var(--muted); }
.stat strong { color: var(--text); font-size: 15px; }

.blocks {
  display: grid;
  grid-template-columns: repeat(var(--doc-cols, 4), minmax(0, 1fr));
  gap: 16px;
}
.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Hundreds of documents: let the browser skip layout/paint of blocks and
   assignment rows outside the viewport. Skipped ones take the height of a
   shown one, measured by app.js (--block-h / --row-h): after a swap all of
   them are new, and a guessed height moved the page by hundreds of pixels
   whenever the real one differed (e.g. with 6 columns). */
.blocks > .block { content-visibility: auto; contain-intrinsic-size: auto var(--block-h, 430px); }
.map-row { content-visibility: auto; contain-intrinsic-size: auto var(--row-h, 190px); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.block-title { font-weight: 700; font-size: 13px; }
.block-file { flex: 1; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reorder controls: hidden until the "Reihenfolge anpassen" toggle is on.
   In reorder mode the per-page +/- controls are hidden so only the
   left/right document-move arrows remain. */
.block-reorder { display: none; gap: 4px; flex: none; }
.reorder-on .block-reorder { display: inline-flex; }
.reorder-on .adjust { display: none; }
/* Page arrows on the cards only with "Page through" on; the full-screen
   view always flips. */
html:not(.flip-on) .pg-prev,
html:not(.flip-on) .pg-next { visibility: hidden; }
.user-badge { font-size: 12px; font-weight: 600; }

.page-view {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.page-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pg-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 26px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.pg-btn:hover { background: var(--surface-2); }
.pg-label { font-size: 11px; text-align: center; flex: 1; }
.pg-label.flipped {
  flex: 0 1 auto;
  margin: 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--flipped-bg);
  color: var(--flipped-ink);
  font-weight: 600;
  cursor: pointer;
}
.pg-label.flipped .muted { color: inherit; }

.block-foot { display: flex; align-items: center; justify-content: space-between; }
.page-count { font-size: 12px; color: var(--muted); }
.adjust { display: flex; gap: 6px; }

/* ---- Alerts ---- */
.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.alert.warn {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}
.alert.info {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}

/* Flash messages (errors from uploads / HTMX requests), bottom right. */
.flash {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  max-width: min(520px, calc(100vw - 40px));
}
.flash-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  font-size: 14px;
}
.flash-msg span { flex: 1; overflow-wrap: anywhere; }
.flash-close {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}

.inline-form { display: inline-flex; margin: 0; }

/* Step 3: the final ZIP after the list, at the end of the page. */
.footbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Delete all attachments: at the very end of the list, away from "assign". */
.extra-clear {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.btn.small { padding: 4px 10px; font-size: 12px; }

/* Total number of documents at the end of the grid */
.split-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  margin: 24px 0 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 15px;
}
.split-total-line { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.split-total-count { font-size: 28px; line-height: 1; color: var(--primary); }
.split-total small { max-width: 640px; }

/* Last document: + / − change the number of documents, so mark them. */
.adjust-last .btn:not(:disabled) { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }

/* Uploaded parts of the source PDF */
.parts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
  font-size: 12px;
}
.parts-title { font-weight: 600; color: var(--muted); }
.parts-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.part-chip {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  max-width: 420px;
}
.part-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.parts .expiry { margin-left: auto; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px 16px 60px;
}
.lightbox[hidden] { display: none; }
/* ‹ page › in one row, centred: the arrows and ✕ sit right at the page's
   edges. The page box has the page's aspect ratio (--lb-ratio, set by app.js
   from the image) and the largest size that fits, so the thumbnail shown
   first and the full-size image replacing it take exactly the same place. */
.lightbox-stage { display: flex; align-items: center; gap: 12px; }
.lightbox-page { position: relative; }
.lightbox img {
  display: block;
  aspect-ratio: var(--lb-ratio, 0.7071);
  height: min(calc(100vh - 90px), calc((100vw - 150px) / var(--lb-ratio, 0.7071)));
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}
.lightbox-nav {
  flex: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.lightbox-nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.3); }
.lightbox-nav:disabled { opacity: 0.25; cursor: default; }
.lightbox-label {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 2px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
}
.lightbox-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lightbox-name:empty { display: none; }
.lightbox-pos { flex: none; }
/* Top right, just outside the page (above the › arrow). */
.lightbox-close {
  position: absolute;
  top: 0;
  left: calc(100% + 15px);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

/* ---- Form selects ---- */
.field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  cursor: pointer;
}

/* ---- Additional-documents: sorted list ---- */
.extra-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.assign-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.assign-actions form { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-valid { color: #157347; background: color-mix(in srgb, #16a34a 16%, transparent); }
.badge-invalid { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.badge-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }

.extra-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.extra-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.extra-icon { color: var(--danger); }
.extra-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.extra-meta { font-size: 12px; margin-left: auto; }
.key-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}
.key-chip.key-none { background: transparent; color: var(--muted); font-weight: 400; border: 1px dashed var(--border); }

/* ---- Assignment: originals | group carriers | parking column ---- */
.layout-wide { max-width: 1480px; }
.map-legend,
.map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}
/* All cards of a row are equally high: the cells stretch, the cards fill them. */
.map-row { align-items: stretch; }
.map-legend { margin-bottom: 8px; }
.map-col-title { font-weight: 700; font-size: 14px; }
.map-col-hint { display: block; font-weight: 400; font-size: 11px; margin-top: 2px; }
.map-rows { display: flex; flex-direction: column; gap: 14px; }
.map-cell { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

/* One card = one row: thumbnail left, controls beside it (mapping.html).
   Every thumbnail has the same height, so the cards do too. */
.map-card { flex: 1 0 auto; flex-direction: row; align-items: stretch; gap: 12px; }
.map-thumb { flex: none; align-self: center; height: clamp(120px, 11.5vw, 168px); }
/* Beside a thumbnail, hidden page arrows (Page through off) take no room. */
html:not(.flip-on) .card-side .pg-prev,
html:not(.flip-on) .card-side .pg-next { display: none; }
.card-side .pager { justify-content: flex-start; }
.card-side .pg-label { flex: 0 1 auto; }
.card-side .pg-label.flipped { margin: 0; }
.card-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; justify-content: center; }
.card-side .block-title,
.card-side .pg-label,
.card-side .doc-switch-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The file name: tiny on the card, in full in the full-screen view. */
.file-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  line-height: 1.2;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager.mini { font-size: 11px; }
.pager.mini .pg-btn { width: 24px; height: 22px; font-size: 12px; }

/* Group carrier */
.group-card { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.group-card.is-empty { border-style: dashed; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.group-title { font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.group-title i { color: var(--primary); }
.group-ctrls { display: flex; gap: 6px; flex-wrap: wrap; }
.group-ctrls .btn.tiny { font-size: 12px; padding: 4px 8px; }

.group-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
}

/* Level 2: document switcher */
.doc-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 4px;
}
.doc-switch-label { font-size: 12px; font-weight: 600; }
/* Number of documents in the group; the hue comes from the count (app.js). */
.count-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: hsl(var(--count-hue, 220) 85% 90%);
  color: hsl(var(--count-hue, 220) 75% 26%);
}
.count-badge .fa-solid { color: inherit; }
@media (prefers-color-scheme: dark) {
  .count-badge {
    background: hsl(var(--count-hue, 220) 45% 26%);
    color: hsl(var(--count-hue, 220) 90% 86%);
  }
}

.doc-switch .pg-btn:disabled { opacity: 0.3; cursor: default; }
.page-nav { align-self: flex-start; }

/* Level 3: move the focused document into a neighbouring group */
.doc-move-ctrls { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-move { color: var(--primary); }
.doc-move .fa-angles-up, .doc-move .fa-angles-down { margin-right: 2px; }

/* Free slot: a row without a carrier, or an empty one waiting for a parked group. */
.free-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  flex: 1 0 auto;
}
.free-slot.is-target,
.group-card.is-target {
  border: 2px dashed var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  color: var(--primary);
}
.group-card.is-target .group-empty { color: var(--primary); }
.park-btn { color: var(--primary); }

/* Parking column: a group on its way to another row */
.parked-card { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.parked-card .group-title i { color: var(--warn); }
.parked-row { font-size: 12px; white-space: nowrap; }
.parked-ctrls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.parked-ctrls .btn.tiny { font-size: 12px; padding: 4px 8px; }
.unpark-btn:not(:disabled) {
  color: var(--primary-ink);
  background: var(--primary-fill);
  border-color: var(--primary-fill);
}
.park-steps { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-left: auto; }
.park-steps input[type="range"] { width: 70px; margin: 0; }
.park-steps-value { min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.parked-taken { font-size: 11px; }

/* ---- Header on narrower screens ----
   First the tagline goes, then the header shows only the icons: the labels
   stay for screen readers, the tooltips (title) name every control. */
@media (max-width: 1600px) {
  .tagline { display: none; }
}
@media (max-width: 1280px) {
  .topbar .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  /* Each icon close to its own switch, clearly apart from the next one. */
  .topbar .nav-toggle { gap: 4px; }
  .topbar .btn { padding: 8px 10px; }
  .nav-ctrl input[type="range"] { width: 120px; }
}

/* ---- Phones (P3-17) ----
   The header wraps below the brand and scrolls away; step 3 stacks the three
   columns of a row (original, its group, a parked group) instead of
   squeezing them side by side. */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; position: static; }
  .topbar-right { justify-content: flex-start; gap: 8px; }
  .layout { padding: 16px; }
  .map-legend { display: none; }
  .map-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .map-row + .map-row { border-top: 1px solid var(--border); padding-top: 14px; }
  .map-cell:not(:has(> *)) { display: none; }
  .brand { white-space: nowrap; }
  /* The column slider is for wide screens: two documents per row here. */
  .blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
