/* Makor — "פנקס ראיות": a calm paper ledger where evidence reads like a court document.
   Quiet slate ink on warm paper; ONE gold thread reserved for acts of judgment (approval, the
   gate); red only for danger. Heebo (bundled, no CDN — works air-gapped). RTL-first, logical
   properties throughout. */

@font-face { font-family: "Heebo"; src: url("fonts/heebo-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Heebo"; src: url("fonts/heebo-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Heebo"; src: url("fonts/heebo-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* neutral ramp (slate, warmed) */
  --paper: #f4f5f7;
  --card: #ffffff;
  --line: #e4e7ec;
  --line-strong: #cfd4dd;
  --ink: #1c2534;
  --ink-2: #475062;
  --ink-3: #6c7689;
  /* the navy world (sidebar) */
  --navy: #131f38;
  --navy-2: #1c2b4d;
  --navy-ink: #c6d0e4;
  --navy-ink-dim: #8493b0;
  /* semantic */
  --accent: #a8862f;          /* gold: judgment/approval only */
  --accent-soft: #f6efdd;
  --ok: #1d7a4d;   --ok-soft: #e4f2ea;
  --warn: #a06b14; --warn-soft: #f7edda;
  --bad: #b23327;  --bad-soft: #f9e7e4;
  --info: #35538f; --info-soft: #e8edf8;
  --neutral-soft: #eef0f4;
  /* rhythm */
  --r-s: 7px; --r-m: 10px; --r-l: 14px;
  --shadow-1: 0 1px 2px rgba(28, 37, 52, .05);
  --shadow-2: 0 1px 3px rgba(28, 37, 52, .06), 0 6px 18px -8px rgba(28, 37, 52, .10);
  --focus: 0 0 0 3px rgba(53, 83, 143, .25);
  --t: .16s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  display: flex; background: var(--paper); color: var(--ink);
  font: 15px/1.65 "Heebo", "Segoe UI", "Noto Sans Hebrew", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[dir=ltr] { direction: ltr; unicode-bidi: isolate; }
.num, td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em; direction: ltr; unicode-bidi: isolate; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 216px; min-height: 100vh; flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, #0f1a30 100%);
  color: var(--navy-ink); display: flex; flex-direction: column;
}
.brand { padding: 26px 22px 20px; }
#brand-name { display: block; font-size: 21px; font-weight: 700; letter-spacing: .2px; color: #fff; line-height: 1.2; }
.brand-sub { display: block; font-size: 12px; color: var(--navy-ink-dim); margin-top: 3px; }
.brand::after { content: ""; display: block; width: 28px; height: 2px; background: var(--accent); margin-top: 14px; border-radius: 1px; }
#sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
#sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--navy-ink); text-decoration: none; font-size: 14px;
  padding: 9px 12px; border-radius: var(--r-s); transition: background var(--t), color var(--t);
}
#sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
#sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#sidebar nav a.active { background: var(--navy-2); color: #fff; font-weight: 500; }
#sidebar nav a.active svg { opacity: 1; color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 16px 22px 18px; font-size: 11.5px; color: var(--navy-ink-dim); line-height: 1.8; border-top: 1px solid rgba(255, 255, 255, .07); }
#who { color: var(--navy-ink); font-weight: 500; }

/* ---------- layout ---------- */
#main { flex: 1; min-width: 0; padding: 30px 40px 80px; max-width: 1180px; }
h1 { font-size: 23px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 15px; font-weight: 700; margin: 24px 0 10px; }
.card > h2:first-child, .card h2[style*="margin-top:0"] { margin-top: 0; }
.sub { color: var(--ink-3); font-size: 13px; margin-bottom: 20px; line-height: 1.6; }
.sub a { color: var(--info); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 20px 22px; margin-bottom: 14px; box-shadow: var(--shadow-1);
}

/* stat strip (overview) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px 12px; box-shadow: var(--shadow-1); }
.stat b { display: block; font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.stat.bad b { color: var(--bad); }
.stat.ok b { color: var(--ok); }

/* ---------- tables ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden; box-shadow: var(--shadow-1); font-size: 14px;
}
th {
  position: sticky; top: 0; z-index: 1;
  background: #f9fafb; color: var(--ink-3); font-size: 12px; font-weight: 500;
  text-align: start; padding: 9px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6f8fb; }
td .cell-sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  padding: 8px 16px; border-radius: var(--r-s); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
button:hover, .btn:hover { background: #f6f8fb; border-color: #b7bfcc; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover { background: var(--navy-2); }
button.primary:disabled { background: #a3abbb; border-color: #a3abbb; cursor: not-allowed; }
button.good { border-color: var(--ok); color: var(--ok); background: var(--card); }
button.good:hover { background: var(--ok-soft); }
button.danger { border-color: #d8a19a; color: var(--bad); background: var(--card); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
input, select, textarea {
  font: inherit; font-size: 14px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  background: #fff; color: var(--ink); transition: border-color var(--t);
}
input:hover, select:hover { border-color: #b7bfcc; }
textarea.json { width: 100%; min-height: 380px; direction: ltr; text-align: left; font: 13px/1.5 ui-monospace, Menlo, monospace; border-radius: var(--r-m); }
label.f { display: block; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label.f input, label.f select { display: block; width: 100%; max-width: 460px; margin-top: 5px; font-weight: 400; }
label.f .hint { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 4px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 14px 10px; color: var(--ink-3); text-decoration: none; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t);
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1.5px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.b-verified { background: var(--ok-soft); color: var(--ok); }
.b-supported { background: var(--info-soft); color: var(--info); }
.b-unverified, .b-inference { background: var(--warn-soft); color: var(--warn); }
.b-disputed, .b-contradicted, .b-danger { background: var(--bad-soft); color: var(--bad); }
.b-neutral { background: var(--neutral-soft); color: var(--ink-2); }
.b-neutral::before, .b-v-verbatim::before, .b-v-paraphrase_labeled::before, .b-v-failed::before, .b-v-pending::before { display: none; }
.b-v-verbatim { background: var(--ok-soft); color: var(--ok); }
.b-v-paraphrase_labeled { background: var(--warn-soft); color: var(--warn); }
.b-v-failed, .b-v-pending { background: var(--bad-soft); color: var(--bad); }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px;
  background: var(--neutral-soft); color: var(--ink-2);
}
.chip.mono { font-size: 11.5px; }

/* ---------- facts queue ---------- */
.fact { border-inline-start: 3px solid var(--line-strong); transition: box-shadow var(--t); }
.fact.danger { border-inline-start-color: var(--bad); }
.fact.focused { box-shadow: var(--focus), var(--shadow-2); }
.fact .statement { font-size: 15.5px; font-weight: 500; margin: 6px 0 8px; line-height: 1.55; }
blockquote {
  margin: 10px 0; padding: 10px 16px; background: #f8f9fb;
  border-inline-start: 3px solid var(--accent); border-radius: var(--r-s);
  font-size: 14px; line-height: 1.7;
}
.fact-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.kbd-hint { font-size: 12px; color: var(--ink-3); background: var(--neutral-soft); border-radius: var(--r-s); padding: 5px 12px; }
kbd { background: #fff; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: inherit; }

/* ---------- spend meter ---------- */
.meter { height: 8px; background: var(--neutral-soft); border-radius: 5px; overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.meter .green { background: var(--ok); } .meter .yellow { background: var(--warn); } .meter .red { background: var(--bad); }

/* ---------- contradictions ---------- */
.contra-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.side { background: #f8f9fb; border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; line-height: 1.7; }
.side .who { font-size: 12px; color: var(--ink-3); margin-bottom: 5px; font-weight: 500; }

/* ---------- audit journal ---------- */
.day-head { font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin: 20px 4px 8px; }
.events { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-1); }
.event { display: flex; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: baseline; }
.event:last-child { border-bottom: none; }
.event.denied { border-inline-start: 3px solid var(--bad); background: #fdf7f6; }
.event .t { flex: 0 0 44px; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
.event .what { flex: 1; min-width: 0; font-size: 14px; }
.event .what .chip { margin-inline-start: 6px; }
.event .who-cell { flex: 0 0 130px; font-size: 12.5px; color: var(--ink-2); }
.event .matter-cell { flex: 0 0 150px; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- source viewer ---------- */
.viewer-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .viewer-grid { grid-template-columns: 1fr; } }
.page-text { white-space: pre-wrap; font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
mark { background: #ffe9a8; border-radius: 3px; padding: 0 2px; box-shadow: 0 0 0 3px #ffe9a8; }
.cite-item { display: block; padding: 8px 10px; border-radius: var(--r-s); text-decoration: none;
  color: var(--ink); font-size: 13px; line-height: 1.5; transition: background var(--t); }
.cite-item:hover { background: #f2f5fa; }
.cite-item.current { background: var(--neutral-soft); pointer-events: none; }
.src-link { color: var(--info); text-decoration: none; font-size: 12.5px; white-space: nowrap; }
.src-link:hover { text-decoration: underline; }

/* ---------- evidence palette (⌘K) ---------- */
#palette { position: fixed; inset: 0; background: rgba(19, 31, 56, .45); z-index: 60;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette-box { width: min(640px, 92vw); background: var(--card); border-radius: var(--r-l);
  box-shadow: 0 18px 60px -12px rgba(19, 31, 56, .45); overflow: hidden; }
#palette-input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 15px 18px; font-size: 16px; }
#palette-input:focus-visible { box-shadow: none; }
#palette-results { max-height: 46vh; overflow-y: auto; }
.palette-head { padding: 8px 16px 3px; font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  background: #f9fafb; border-bottom: 1px solid var(--line); }
.palette-item { display: block; padding: 10px 16px; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--line); font-size: 14px; }
.palette-item:last-child { border-bottom: none; }
.palette-item:hover, .palette-item.sel { background: #f2f5fa; }
.palette-item .badge { margin-inline-end: 6px; }

/* ---------- states ---------- */
.empty {
  color: var(--ink-3); background: var(--card); border: 1px dashed var(--line-strong);
  border-radius: var(--r-l); padding: 34px 20px; text-align: center; font-size: 14px;
}
.err { color: var(--bad); }
.ok { color: var(--ok); }

/* ---------- auth screens ---------- */
.auth-wrap { max-width: 400px; margin: 9vh auto 0; }
.auth-wrap .card { padding: 30px 30px 26px; box-shadow: var(--shadow-2); }
.auth-brand { font-size: 24px; font-weight: 700; margin-bottom: 2px; }
.auth-brand::after { content: ""; display: block; width: 26px; height: 2px; background: var(--accent); margin: 12px 0 4px; border-radius: 1px; }

#toast {
  position: fixed; bottom: 24px; inset-inline-start: 240px; z-index: 50;
  background: var(--navy); color: #fff; padding: 11px 20px; border-radius: var(--r-m);
  box-shadow: var(--shadow-2); opacity: 0; transform: translateY(6px);
  transition: opacity .22s, transform .22s; pointer-events: none; font-size: 14px;
}
#toast.show { opacity: 1; transform: none; }

/* ---------- repeatable form rows (binding editor) ---------- */
.rep-row { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 8px; margin-bottom: 8px; max-width: 900px; }
.rep-row.theme-row { grid-template-columns: 1fr 3fr auto; }
.rep-row .rep-del { padding: 6px 10px; }
@media (max-width: 860px) { .rep-row, .rep-row.theme-row { grid-template-columns: 1fr; } }

/* ---------- copyable technical value (URLs/IDs never inline in prose) ---------- */
.copyable {
  display: flex; align-items: center; gap: 8px; max-width: 560px;
  background: #f8f9fb; border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 7px 12px; margin: 8px 0;
}
.copyable .cp-label { font-size: 12px; color: var(--ink-3); white-space: nowrap; font-weight: 500; }
.copyable .cp-value {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: isolate;
  color: var(--ink-2);
}
.copyable button { padding: 3px 10px; font-size: 12px; flex-shrink: 0; }

/* ---------- in-place guides (professional, hidden until asked) ---------- */
details.guide { margin: 10px 0 4px; border: 1px solid var(--line); border-radius: var(--r-m); background: #fbfcfd; }
details.guide summary {
  cursor: pointer; padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--info);
  list-style: none; display: flex; align-items: center; gap: 7px;
}
details.guide summary::before { content: "?"; display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%; background: var(--info-soft); color: var(--info);
  font-size: 12px; font-weight: 700; flex-shrink: 0; }
details.guide[open] summary { border-bottom: 1px solid var(--line); }
details.guide .guide-body { padding: 12px 16px 14px; font-size: 13.5px; color: var(--ink-2); line-height: 1.75; }
details.guide ol { margin: 6px 0; padding-inline-start: 20px; }
details.guide li { margin-bottom: 4px; }

/* ---------- tooltips ([data-tip] on any element) ---------- */
[data-tip] { position: relative; cursor: help; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); inset-inline-start: 50%;
  transform: translateX(50%); z-index: 40;
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.5;
  padding: 6px 11px; border-radius: var(--r-s); width: max-content; max-width: 260px; text-align: start;
  opacity: 0; pointer-events: none; transition: opacity var(--t); box-shadow: var(--shadow-2);
}
[dir=rtl] [data-tip]::after { transform: translateX(50%); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 860px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; min-height: 0; flex-direction: row; align-items: center; padding: 4px 8px; }
  .brand { padding: 10px 12px; } .brand::after, .brand-sub { display: none; }
  #brand-name { font-size: 17px; }
  #sidebar nav { flex-direction: row; padding: 0; }
  .sidebar-foot { display: none; }
  #main { padding: 18px 14px 60px; }
  .contra-sides { grid-template-columns: 1fr; }
  .event .matter-cell { display: none; }
  #toast { inset-inline-start: 14px; }
  table { display: block; overflow-x: auto; }
}

/* ---------- modals + selection gesture (intelligence push 2026-08) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(19, 31, 56, .45); z-index: 70;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 9vh; }
.modal-box { width: min(560px, 92vw); background: var(--card); border-radius: var(--r-l);
  padding: 18px 20px; max-height: 80vh; overflow-y: auto; box-shadow: 0 18px 60px rgba(0, 0, 0, .25); }
#sel-fab { position: absolute; z-index: 50; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.ask-answer { white-space: pre-wrap; }
.cite-chip { display: inline-block; margin: 3px 0 3px 6px; padding: 3px 9px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 12.5px; text-decoration: none; background: var(--card); }
.cite-chip:hover { background: #f2f5fa; }

/* version stamp in the sidebar foot: identity without noise */
.sidebar-foot .ver { opacity: .55; font-size: 11px; letter-spacing: .02em; }

/* entity page: the count strip */
.pstats { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 12px; }
.pstat { display: flex; flex-direction: column; }
.pstat b { font-size: 22px; line-height: 1.1; }
.pstat span { font-size: 12px; color: var(--ink-3); }
.badge a { color: inherit; opacity: .45; text-decoration: none; margin-inline-start: 4px; font-weight: 700; }
.badge a:hover { opacity: 1; color: var(--bad); }

/* An author `button { display: ... }` rule outranks the UA stylesheet's [hidden], so a
   hidden button kept showing. Make hidden mean hidden. */
[hidden] { display: none !important; }

/* settings: each field carries its own save, shown only once the field is dirty */
.f-row { display: flex; gap: 8px; align-items: center; max-width: 560px; margin-top: 5px; }
.f-row input, .f-row select { margin-top: 0; flex: 1 1 auto; }
.field-save { white-space: nowrap; padding: 6px 14px; font-size: 12px; }
