/* KARL Support design system (porte tel quel depuis KARLTimeLens, KARL_Support_UIX.md paragraphe 2). Logical properties only: the layout mirrors in RTL. */

:root {
  --font-sans: "Segoe UI", "Inter", system-ui, -apple-system, "Noto Sans", "Noto Sans Hebrew", "Arial Hebrew", sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "DejaVu Sans Mono", ui-monospace, monospace;

  --c-bg: #f5f6f8;
  --c-surface: #ffffff;
  --c-surface-2: #eef0f3;
  --c-border: #d9dde3;
  --c-border-strong: #b8bec8;
  --c-text: #1b1f24;
  --c-text-2: #4a525d;
  --c-text-3: #6b7380;
  --c-accent: #1f5f8b;
  --c-accent-strong: #174a6d;
  --c-accent-soft: #e3eef6;
  --c-focus: #0b63c4;
  --c-danger: #a3261d;
  --c-danger-soft: #fbeceb;
  --c-warning: #7a5200;
  --c-warning-soft: #fff4dc;
  --c-ok: #1d6b44;
  --c-ok-soft: #e4f3ea;

  --ev-observed: #1d6b44;
  --ev-observed-soft: #e4f3ea;
  --ev-measured: #2d5a8e;
  --ev-measured-soft: #e5edf7;
  --ev-corroborated: #5d3f8c;
  --ev-corroborated-soft: #eee8f6;
  --ev-hypothesis: #7a5200;
  --ev-hypothesis-soft: #fff4dc;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-pill: 999px;

  --e-1: 0 1px 2px rgba(20, 28, 38, 0.08);
  --e-2: 0 4px 14px rgba(20, 28, 38, 0.10);
  --e-3: 0 12px 36px rgba(20, 28, 38, 0.18);

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  --sidebar-w: 256px;
  --sidebar-w-compact: 68px;
  --topbar-h: 60px;
  --touch: 36px;
  --motion: 160ms;
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion: 0ms; }
  *, *::before, *::after { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: var(--r-1); }
.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; inset-inline-start: var(--sp-2); inset-block-start: -40px; z-index: 100; background: var(--c-surface); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-2); box-shadow: var(--e-2); }
.skip-link:focus { inset-block-start: var(--sp-2); }

/* Technical data keeps its logical direction (hash, ids, coordinates). */
.tech { font-family: var(--font-mono); font-size: var(--fs-xs); unicode-bidi: isolate; direction: ltr; word-break: break-all; color: var(--c-text-2); }
bdi.tech { display: inline; }
.muted { color: var(--c-text-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.stack-4 > * + * { margin-block-start: var(--sp-4); }
.stack-3 > * + * { margin-block-start: var(--sp-3); }
.stack-2 > * + * { margin-block-start: var(--sp-2); }
.divider { border: 0; border-block-start: 1px solid var(--c-border); margin: var(--sp-3) 0; }

/* Directional icons flip in RTL. */
[dir="rtl"] .icon.dir { transform: scaleX(-1); }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon.sm { width: 14px; height: 14px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--topbar-h) minmax(0, 1fr); height: 100vh; }
.shell.compact { grid-template-columns: var(--sidebar-w-compact) minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sp-3); padding-inline: var(--sp-4); background: var(--c-surface); border-block-end: 1px solid var(--c-border); z-index: 20; }
.brand { display: flex; align-items: center; gap: var(--sp-2); min-width: calc(var(--sidebar-w) - var(--sp-5)); }
.shell.compact .brand { min-width: auto; }
.brand-mark { width: 30px; height: 30px; border-radius: var(--r-2); background: var(--c-accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: 0.5px; }
.brand-name { font-weight: 650; font-size: var(--fs-lg); white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--c-text-3); white-space: nowrap; }
.topbar-search { flex: 1 1 220px; min-width: 160px; max-width: 560px; }
.topbar-search input { width: 100%; height: 36px; border: 1px solid var(--c-border); border-radius: var(--r-pill); padding-inline: var(--sp-4); background: var(--c-surface-2); }
.topbar-tools { display: flex; align-items: center; gap: var(--sp-2); margin-inline-start: auto; min-width: 0; }
.topbar { overflow: hidden; }
@media (max-width: 1360px) { .health { display: none; } .brand-sub { display: none; } }
@media (max-width: 1100px) { .brand-text { display: none; } .brand { min-width: auto; } }
.health { display: flex; gap: var(--sp-1); align-items: center; }
.health-dot { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-pill); background: var(--c-surface-2); color: var(--c-text-2); }
.health-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); }
.health-dot.degraded::before { background: #c28a00; border-radius: 1px; }
.health-dot.down::before { background: var(--c-danger); border-radius: 0; transform: rotate(45deg); }

.sidebar { background: var(--c-surface); border-inline-end: 1px solid var(--c-border); display: flex; flex-direction: column; overflow-y: auto; padding: var(--sp-3) var(--sp-2); gap: 2px; }
.nav-link { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--touch); padding-inline: var(--sp-3); border-radius: var(--r-2); color: var(--c-text-2); font-weight: 500; }
.nav-link:hover { background: var(--c-surface-2); text-decoration: none; color: var(--c-text); }
.nav-link[aria-current="page"] { background: var(--c-accent-soft); color: var(--c-accent-strong); }
.nav-sep { border-block-start: 1px solid var(--c-border); margin: var(--sp-3) var(--sp-2); }
.nav-badge { margin-inline-start: auto; font-size: 11px; background: var(--c-surface-2); border-radius: var(--r-pill); padding: 0 6px; }
.shell.compact .nav-label, .shell.compact .nav-badge, .shell.compact .brand-text { display: none; }
.shell.compact .nav-link { justify-content: center; padding-inline: 0; }
.main { overflow: auto; min-width: 0; position: relative; }
.page { padding: var(--sp-5) var(--sp-6); max-width: 1680px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-block-end: var(--sp-5); flex-wrap: wrap; }
.page-head p { color: var(--c-text-2); margin-block-start: var(--sp-1); }
.breadcrumbs { display: flex; gap: var(--sp-1); align-items: center; font-size: var(--fs-sm); color: var(--c-text-3); margin-block-end: var(--sp-2); }

.banner { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); border-block-end: 1px solid var(--c-border); }
.banner.warn { background: var(--c-warning-soft); color: var(--c-warning); }
.banner.error { background: var(--c-danger-soft); color: var(--c-danger); }
.banner.info { background: var(--c-accent-soft); color: var(--c-accent-strong); }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--touch); padding: 0 var(--sp-4); border-radius: var(--r-2); border: 1px solid var(--c-border-strong); background: var(--c-surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background var(--motion); }
.btn:hover { background: var(--c-surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn.primary:hover { background: var(--c-accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--c-surface-2); }
.btn.sm { min-height: 28px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn.icon-only { padding: 0; width: var(--touch); }
.btn.sm.icon-only { width: 28px; }
.btn[aria-pressed="true"] { background: var(--c-accent-soft); border-color: var(--c-accent); color: var(--c-accent-strong); }
.btn.danger { color: var(--c-danger); }
/* Decision buttons share one neutral style: no bias towards "confirm". */
.btn.decision { min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: var(--r-2); overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; border-inline-end: 1px solid var(--c-border); }
.seg .btn:last-child { border-inline-end: 0; }

.input, .select, .textarea { min-height: var(--touch); border: 1px solid var(--c-border-strong); border-radius: var(--r-2); padding: 0 var(--sp-3); background: var(--c-surface); }
.textarea { padding: var(--sp-2) var(--sp-3); resize: vertical; }
.input.sm, .select.sm { min-height: 28px; font-size: var(--fs-sm); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--c-text-2); }
.field > span { font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; min-height: 28px; }
.check input { width: 16px; height: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding-inline: var(--sp-3) var(--sp-1); border-radius: var(--r-pill); background: var(--c-accent-soft); color: var(--c-accent-strong); font-size: var(--fs-sm); border: 1px solid transparent; }
.chip button { border: 0; background: transparent; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.chip button:hover { background: rgba(0, 0, 0, 0.08); }
.chip.plain { background: var(--c-surface-2); color: var(--c-text-2); padding-inline: var(--sp-3); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); padding: 1px 8px; border-radius: var(--r-pill); background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); white-space: nowrap; }
.tag.warn { background: var(--c-warning-soft); color: var(--c-warning); border-color: #eed9a8; }
.tag.error { background: var(--c-danger-soft); color: var(--c-danger); border-color: #efc4c0; }
.tag.ok { background: var(--c-ok-soft); color: var(--c-ok); border-color: #bfe0cc; }

/* Evidence badges: icon + label + tooltip, never color alone. */
.evidence { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px 2px 6px; border-radius: var(--r-1); border: 1px solid; position: relative; white-space: nowrap; }
.evidence.observed { color: var(--ev-observed); background: var(--ev-observed-soft); border-color: currentColor; }
.evidence.measured { color: var(--ev-measured); background: var(--ev-measured-soft); border-color: currentColor; border-style: dashed; }
.evidence.corroborated { color: var(--ev-corroborated); background: var(--ev-corroborated-soft); border-color: currentColor; border-style: double; border-width: 3px; padding-block: 0; }
.evidence.hypothesis { color: var(--ev-hypothesis); background: var(--ev-hypothesis-soft); border-color: currentColor; border-style: dotted; }
.evidence-filter { border: 1px solid transparent; background: transparent; padding: 0; cursor: pointer; border-radius: var(--r-1); }
.evidence-filter.active { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.validation { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--c-text-2); }
.validation.confirmed { color: var(--c-ok); font-weight: 600; }
.validation.rejected { color: var(--c-danger); text-decoration: line-through; }

.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip { position: absolute; inset-block-end: calc(100% + 6px); inset-inline-start: 0; z-index: 50; background: #1b1f24; color: #fff; font-size: var(--fs-xs); font-weight: 400; padding: 6px 10px; border-radius: var(--r-1); width: max-content; max-width: 280px; white-space: normal; opacity: 0; pointer-events: none; transition: opacity var(--motion); }
.tooltip-wrap:hover .tooltip, .tooltip-wrap:focus-within .tooltip { opacity: 1; }

.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-3); box-shadow: var(--e-1); }
.card.pad { padding: var(--sp-4); }
a.card { display: block; color: inherit; }
a.card:hover { border-color: var(--c-accent); text-decoration: none; }
.card-title { font-weight: 600; margin-block-end: var(--sp-2); display: flex; align-items: center; gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .page { padding: var(--sp-4); } }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px var(--sp-4); font-size: var(--fs-sm); }
.kv dt { color: var(--c-text-3); }
.kv dd { margin: 0; min-width: 0; }
.json-nested { border-inline-start: 2px solid var(--c-border); padding-inline-start: var(--sp-3); margin-block-start: 2px; }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: start; font-weight: 600; color: var(--c-text-2); padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--c-border); background: var(--c-surface-2); position: sticky; inset-block-start: 0; }
.table td { padding: var(--sp-2) var(--sp-3); border-block-end: 1px solid var(--c-border); vertical-align: middle; }
.table tr:hover td { background: #fafbfc; }
.table-wrap { overflow: auto; border: 1px solid var(--c-border); border-radius: var(--r-2); background: var(--c-surface); }

.tabs { display: flex; gap: 2px; border-block-end: 1px solid var(--c-border); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: var(--sp-2) var(--sp-3); min-height: var(--touch); cursor: pointer; color: var(--c-text-2); border-block-end: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab[aria-selected="true"] { color: var(--c-accent-strong); border-block-end-color: var(--c-accent); }
.tab-panel { padding-block: var(--sp-4); }

.progress { height: 6px; background: var(--c-surface-2); border-radius: var(--r-pill); overflow: hidden; }
.progress > div { height: 100%; background: var(--c-accent); }
.meter { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); }
.meter .progress { flex: 1; min-width: 60px; }

.skeleton { background: linear-gradient(90deg, var(--c-surface-2), #f7f8fa, var(--c-surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--r-2); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-4); color: var(--c-text-2); }
.state .icon { width: 36px; height: 36px; color: var(--c-text-3); }
.state.error .icon { color: var(--c-danger); }
.state h3 { color: var(--c-text); }

/* ---------- Overlays ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(15, 20, 28, 0.42); z-index: 60; display: grid; place-items: center; }
.modal { background: var(--c-surface); border-radius: var(--r-3); box-shadow: var(--e-3); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto; padding: var(--sp-5); }
.modal.wide { width: min(1080px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-block-end: var(--sp-4); gap: var(--sp-3); }
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(480px, 100vw); background: var(--c-surface); box-shadow: var(--e-3); z-index: 70; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-block-end: 1px solid var(--c-border); gap: var(--sp-3); }
.drawer-body { padding: var(--sp-4) var(--sp-5); overflow: auto; flex: 1; }
.toasts { position: fixed; inset-block-end: var(--sp-4); inset-inline-end: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); z-index: 80; }
.toast { background: #1b1f24; color: #fff; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-2); box-shadow: var(--e-2); font-size: var(--fs-sm); max-width: 420px; display: flex; gap: var(--sp-3); align-items: center; }

/* ---------- Photos ---------- */
.thumb { position: relative; background: var(--c-surface-2); border-radius: var(--r-2); overflow: hidden; aspect-ratio: 4 / 3; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .placeholder-flag { position: absolute; inset-block-start: 6px; inset-inline-start: 6px; }
.crop { background-repeat: no-repeat; border-radius: var(--r-2); background-color: var(--c-surface-2); border: 1px solid var(--c-border); flex: none; }
.crop.face { border-radius: 50%; }
.box { position: absolute; border: 2px solid; border-radius: 2px; pointer-events: none; }
.box.face { border-color: #ffffff; box-shadow: 0 0 0 1px rgba(0,0,0,0.55); border-radius: 40%; }
.box.person { border-color: rgba(255,255,255,0.8); border-style: dashed; }
.box.building, .box.monument { border-color: #f3c34a; box-shadow: 0 0 0 1px rgba(0,0,0,0.5); }
.box.inscription { border-color: #7fd1ff; box-shadow: 0 0 0 1px rgba(0,0,0,0.5); }
.box.custom { border-color: #ff8ad1; }
.box.match { border-color: #ffffff; border-width: 3px; box-shadow: 0 0 0 2px var(--c-accent), 0 0 18px rgba(31, 95, 139, 0.6); }
.box.selected { border-color: #ffffff; background: rgba(31, 95, 139, 0.18); box-shadow: 0 0 0 2px var(--c-accent); }
.box-label { position: absolute; inset-block-start: -20px; inset-inline-start: -2px; font-size: 11px; background: rgba(15,20,28,0.8); color: #fff; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.match-point { position: absolute; width: 7px; height: 7px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; border: 2px solid var(--c-accent); pointer-events: none; }

/* ---------- Search ---------- */
.search-hero { max-width: 920px; margin: var(--sp-6) auto var(--sp-5); text-align: center; }
.search-hero h1 { font-size: 32px; margin-block-end: var(--sp-4); letter-spacing: -0.2px; }
.search-box { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-3); box-shadow: var(--e-2); padding: var(--sp-3); text-align: start; }
.search-box:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft), var(--e-2); }
.search-box textarea { width: 100%; border: 0; resize: none; min-height: 64px; font-size: 18px; padding: var(--sp-2); background: transparent; outline: none; }
.search-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; border-block-start: 1px solid var(--c-border); padding-block-start: var(--sp-3); margin-block-start: var(--sp-2); }
.examples { display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; margin-block-start: var(--sp-3); }
.example { border: 1px solid var(--c-border); background: transparent; border-radius: var(--r-pill); padding: 4px 12px; font-size: var(--fs-sm); color: var(--c-text-2); cursor: pointer; }
.example:hover { background: var(--c-surface); color: var(--c-text); }
.ref-strip { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2); border-radius: var(--r-2); background: var(--c-surface-2); margin-block-end: var(--sp-2); }
.ref-strip .thumb { width: 96px; flex: none; }
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; margin-block: var(--sp-3); }
.filters .field { min-width: 150px; }
.adv-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); padding: var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-2); margin-block-end: var(--sp-3); }
@media (max-width: 1100px) { .adv-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.interpretation { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); background: var(--c-accent-soft); border-radius: var(--r-2); margin-block-end: var(--sp-3); }
.interpretation .segments { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.phases { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-block-end: var(--sp-3); font-size: var(--fs-sm); }
.phase { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--c-surface-2); color: var(--c-text-3); }
.phase.active { background: var(--c-accent); color: #fff; }
.phase.done { background: var(--c-ok-soft); color: var(--c-ok); }
.toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding-block: var(--sp-2); border-block-end: 1px solid var(--c-border); margin-block-end: var(--sp-3); position: sticky; inset-block-start: 0; background: var(--c-bg); z-index: 5; }
.results-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--sp-4); }
@media (max-width: 1100px) { .results-layout { grid-template-columns: minmax(0, 1fr); } .facets { display: none; } }
.facets { font-size: var(--fs-sm); }
.facet { margin-block-end: var(--sp-4); }
.facet h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.6px; color: var(--c-text-3); margin-block-end: var(--sp-2); }
.facet-row { display: flex; justify-content: space-between; gap: var(--sp-2); padding: 3px 0; }

/* ---------- Result cards ---------- */
.vgrid { position: relative; overflow-y: auto; height: calc(100vh - 330px); min-height: 360px; }
.vgrid-inner { position: relative; }
.vgrid-row { position: absolute; inset-inline: 0; display: grid; gap: var(--sp-4); }
.result-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-3); overflow: hidden; position: relative; display: flex; flex-direction: column; transition: box-shadow var(--motion); }
.result-card:hover, .result-card:focus-within { box-shadow: var(--e-2); }
.result-card .thumb { border-radius: 0; }
.result-card .body { padding: var(--sp-3); display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.result-card .title { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-card .reasons { font-size: var(--fs-xs); color: var(--c-text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-card .hover-actions { position: absolute; inset-block-start: var(--sp-2); inset-inline-end: var(--sp-2); display: flex; gap: 4px; opacity: 0; transition: opacity var(--motion); }
.result-card:hover .hover-actions, .result-card:focus-within .hover-actions { opacity: 1; }
.result-card .hover-actions .btn { background: rgba(255,255,255,0.95); }
.result-card .crop-inset { position: absolute; inset-block-end: var(--sp-2); inset-inline-end: var(--sp-2); box-shadow: 0 0 0 2px #fff, var(--e-2); }
.result-card.selected { outline: 3px solid var(--c-accent); outline-offset: -3px; }
.result-card.compact .body { padding: var(--sp-2); }
.result-card.compact .reasons { display: none; }
.pending-rank { font-size: 11px; color: var(--c-text-3); font-style: italic; }
.list-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: var(--sp-4); align-items: center; padding: var(--sp-2); border-block-end: 1px solid var(--c-border); background: var(--c-surface); }
.list-row .thumb { width: 120px; }
.group-head { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-4) 0 var(--sp-2); font-weight: 600; }
.plain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-4); }
.plain-grid.dense { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--sp-2); }

/* ---------- Inspector ---------- */
.inspector { display: grid; grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: minmax(0, 1fr) auto; height: calc(100vh - var(--topbar-h) - 38px); }
@media (max-width: 1200px) { .inspector { grid-template-columns: minmax(0, 1fr); height: auto; } }
.viewer { position: relative; background: #20252c; overflow: hidden; min-height: 420px; user-select: none; touch-action: none; flex: 1 1 auto; width: 100%; }
.viewer:fullscreen { background: #000; }
.viewer-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer-layer { position: relative; transform-origin: 0 0; }
.viewer-layer img { display: block; max-width: none; }
.viewer-tools { position: absolute; inset-block-start: var(--sp-3); inset-inline-start: var(--sp-3); display: flex; gap: 4px; z-index: 5; flex-wrap: wrap; }
.viewer-tools .btn { background: rgba(255,255,255,0.95); }
.viewer-overlays { position: absolute; inset-block-end: var(--sp-3); inset-inline-start: var(--sp-3); display: flex; gap: 4px; flex-wrap: wrap; z-index: 5; max-width: calc(100% - 24px); }
.viewer-overlays .btn { background: rgba(255,255,255,0.92); }
.viewer-zoom { position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3); color: #fff; background: rgba(0,0,0,0.5); padding: 2px 8px; border-radius: var(--r-1); font-size: var(--fs-xs); z-index: 5; }
.select-layer { position: absolute; inset: 0; cursor: crosshair; }
.clickable-box { position: absolute; border: 2px solid rgba(255,255,255,0.85); border-radius: 3px; cursor: pointer; background: transparent; padding: 0; pointer-events: auto; }
.clickable-box:hover, .clickable-box:focus-visible { background: rgba(31,95,139,0.25); }
.panel { background: var(--c-surface); border-inline-start: 1px solid var(--c-border); overflow: auto; display: flex; flex-direction: column; }
.panel .tabs { position: sticky; inset-block-start: 0; background: var(--c-surface); z-index: 2; padding-inline: var(--sp-3); flex-wrap: wrap; overflow: visible; }
.panel-body { padding: var(--sp-4); }
.related { grid-column: 1 / -1; background: var(--c-surface); border-block-start: 1px solid var(--c-border); padding: var(--sp-3) var(--sp-4); overflow-x: auto; }
.related-strip { display: flex; gap: var(--sp-3); }
.related-strip a { width: 140px; flex: none; }
.assertion { border: 1px solid var(--c-border); border-radius: var(--r-2); padding: var(--sp-3); display: flex; flex-direction: column; gap: 6px; background: var(--c-surface); }
.assertion.machine { border-inline-start: 3px solid var(--c-border-strong); }
.assertion .row.between { align-items: flex-start; }
.reason-list { margin: 0; padding-inline-start: var(--sp-4); font-size: var(--fs-sm); }
.reason-list.contra li { color: var(--c-danger); }
.note { border-radius: var(--r-2); padding: var(--sp-3); background: #fffbe8; border: 1px solid #efe2a8; border-inline-start: 4px solid #c9a227; font-size: var(--fs-sm); }

/* ---------- Region selector ---------- */
.selector-wrap { position: relative; display: inline-block; max-width: 100%; }
.selector-wrap img { display: block; max-width: 100%; max-height: 60vh; }
.drag-rect { position: absolute; border: 2px dashed #fff; background: rgba(31,95,139,0.2); box-shadow: 0 0 0 1px rgba(0,0,0,0.6); pointer-events: none; }

/* ---------- Map ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-4); }
@media (max-width: 1100px) { .map-layout { grid-template-columns: minmax(0, 1fr); } }
.map-frame { position: relative; background: #e9eef2; border: 1px solid var(--c-border); border-radius: var(--r-3); overflow: hidden; }
.map-frame svg { display: block; width: 100%; height: auto; max-height: 72vh; }
.map-land { fill: #fbfbf9; stroke: #9aa5b1; stroke-width: 1.4; }
.marker-confirmed { fill: var(--ev-observed); stroke: #fff; stroke-width: 2; }
.marker-corroborated { fill: var(--ev-corroborated); stroke: #fff; stroke-width: 2; }
.marker-candidate { fill: #fff; stroke: var(--ev-hypothesis); stroke-width: 3; stroke-dasharray: 4 3; }
.zone { fill: rgba(122, 82, 0, 0.12); stroke: var(--ev-hypothesis); stroke-dasharray: 6 4; stroke-width: 1.5; }
.marker-label { font-size: 13px; fill: var(--c-text); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.marker-count { font-size: 11px; fill: #fff; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.marker-count.dark { fill: var(--c-text); }
.route { fill: none; stroke: var(--c-accent); stroke-width: 3; }
.route.hypothetical { stroke-dasharray: 8 6; stroke: var(--ev-hypothesis); }
.map-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--c-text-2); padding: var(--sp-2) var(--sp-3); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.map-controls { position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3); display: flex; flex-direction: column; gap: 4px; }
.map-controls .btn { background: #fff; }
.range-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); }
.range-row input[type="range"] { flex: 1; }

/* ---------- Timeline ---------- */
.timeline { position: relative; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-3); overflow: hidden; }
.timeline-axis { position: relative; height: 34px; border-block-end: 1px solid var(--c-border); background: var(--c-surface-2); }
.tick { position: absolute; inset-block: 0; border-inline-start: 1px solid var(--c-border); font-size: 11px; color: var(--c-text-3); padding-inline-start: 4px; padding-block-start: 8px; white-space: nowrap; }
.tick.major { border-inline-start-color: var(--c-border-strong); color: var(--c-text-2); font-weight: 600; }
.timeline-lanes { position: relative; }
.tl-bar { position: absolute; height: 22px; border-radius: 4px; border: 1px solid; font-size: 11px; padding-inline: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; text-align: start; line-height: 20px; }
.tl-bar.observed { background: var(--ev-observed-soft); color: var(--ev-observed); }
.tl-bar.measured { background: var(--ev-measured-soft); color: var(--ev-measured); border-style: dashed; }
.tl-bar.corroborated { background: var(--ev-corroborated-soft); color: var(--ev-corroborated); border-width: 2px; }
.tl-bar.hypothesis { background: repeating-linear-gradient(45deg, var(--ev-hypothesis-soft), var(--ev-hypothesis-soft) 6px, #fff 6px, #fff 10px); color: var(--ev-hypothesis); border-style: dotted; }
.tl-bar.event { font-weight: 600; }
.tl-bar.selected { box-shadow: 0 0 0 2px var(--c-accent); }
.tl-point { position: absolute; width: 14px; height: 14px; margin-inline-start: -7px; margin-block-start: 4px; border-radius: 50%; border: 2px solid var(--ev-observed); background: #fff; cursor: pointer; padding: 0; }
.tl-point.selected { background: var(--c-accent); border-color: var(--c-accent); }
.timeline-grid-lines { position: absolute; inset: 0; pointer-events: none; }

/* ---------- Graph ---------- */
.graph-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; gap: var(--sp-4); }
@media (max-width: 1280px) { .graph-layout { grid-template-columns: minmax(0, 1fr); } }
.graph-frame { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-3); overflow: hidden; }
.graph-frame svg { display: block; width: 100%; height: auto; }
.g-edge { stroke: #8f99a5; stroke-width: 1.4; }
.g-edge.corroborated { stroke-width: 2.4; stroke: var(--ev-corroborated); }
.g-edge.observed { stroke: var(--ev-observed); stroke-width: 2; }
.g-edge.measured { stroke-dasharray: 5 3; }
.g-edge.hypothesis { stroke-dasharray: 2 4; stroke: var(--ev-hypothesis); }
.g-node { cursor: pointer; }
.g-node:focus-visible { outline: none; }
.g-node:focus-visible .g-shape, .g-node.selected .g-shape { stroke: var(--c-focus); stroke-width: 4; }
.g-shape { stroke: #fff; stroke-width: 2; }
.g-person .g-shape { fill: #2d5a8e; }
.g-photo .g-shape { fill: #6b7380; }
.g-place .g-shape { fill: #1d6b44; }
.g-event .g-shape { fill: #7a5200; }
.g-collection .g-shape { fill: #5d3f8c; }
.g-cluster .g-shape { fill: #fff; stroke: #6b7380; stroke-dasharray: 3 2; }
.g-label { font-size: 12px; fill: var(--c-text); paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
.g-glyph { font-size: 11px; fill: #fff; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.g-cluster .g-glyph { fill: var(--c-text); }

/* ---------- Compare ---------- */
.compare-grid { display: grid; gap: var(--sp-4); }
.compare-grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compare-grid.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compare-grid.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compare-pane .viewer { min-height: 320px; height: 360px; border-radius: var(--r-2); }
.decisions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Person / Place ---------- */
.person-card { display: flex; gap: var(--sp-3); align-items: center; }
.silhouette { width: 64px; height: 64px; border-radius: 50%; background: var(--c-surface-2); border: 1px dashed var(--c-border-strong); display: grid; place-items: center; color: var(--c-text-3); flex: none; }
.silhouette .icon { width: 30px; height: 30px; }
.entity-head { display: flex; gap: var(--sp-4); align-items: center; }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--sp-5); }
@media (max-width: 900px) { .admin-layout { grid-template-columns: minmax(0, 1fr); } }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.device-card { border: 1px solid var(--c-border); border-radius: var(--r-2); padding: var(--sp-3); background: var(--c-surface); display: flex; flex-direction: column; gap: var(--sp-2); }
.device-card.unavailable { background: #f8f8f8; border-style: dashed; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--c-border-strong); border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start var(--motion); }
.switch[aria-checked="true"] { background: var(--c-accent); }
.switch[aria-checked="true"]::after { inset-inline-start: 19px; }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: var(--fs-xl); font-weight: 600; }
.stat .label { font-size: var(--fs-xs); color: var(--c-text-3); }
