/* Perkara — prototype styles
   Visual direction: paper + ink, serif gravitas for headings,
   IBM Plex Sans for UI, Plex Mono for citations and IDs.
   Restraint is the brief — minimal color, maximal hierarchy. */

:root {
  /* Paper & ink */
  --paper: #f3ede1;
  --paper-deep: #ebe3d3;
  --surface: #fbf7ee;
  --surface-2: #f7f2e6;
  --ink: #1a1714;
  --ink-2: #3a3530;
  --ink-3: #6b6359;
  --ink-4: #9a9082;
  --rule: #d9d0bf;
  --rule-2: #e6dfcf;

  /* Restrained accents */
  --accent: #8b2e2e;       /* court red — findings, contradictions */
  --accent-deep: #6e2222;
  --amber: #a06820;        /* gaps, caution */
  --forest: #2d5a3d;       /* confirmed, supported */
  --ink-blue: #2a4565;     /* info, links */
  --warn-bg: #f3e3c4;
  --gap-bg: #f0e2c8;
  --found-bg: #f1d8d2;

  /* Type */
  --display: "Newsreader", "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  /* Shadow — none. Use borders and color shifts. */
  --shadow-1: 0 1px 0 rgba(26, 23, 20, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─────────── Top bar ─────────── */
.topbar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  flex: 0 0 auto;
}
.topbar-brand {
  padding: 12px 20px 12px 20px;
  border-right: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
}
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-name {
  font-family: var(--display);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-top: 1px;
}

.topbar-matter {
  flex: 1;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-right: 1px solid var(--rule);
  min-width: 0;
}
.matter-register {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: -0.01em;
}
.matter-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matter-stage {
  margin-left: auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  padding: 4px 8px;
  background: var(--surface-2);
  white-space: nowrap;
}

.topbar-user {
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─────────── Sub-nav (view switcher) ─────────── */
.subnav {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  flex: 0 0 auto;
  padding-left: 230px; /* aligns with content under spine */
}
.subnav-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--rule-2);
  padding: 10px 20px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.subnav-tab:hover { color: var(--ink); background: var(--surface-2); }
.subnav-tab[aria-current="true"] {
  color: var(--ink);
  background: var(--paper);
}
.subnav-tab[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--ink);
}
.subnav-tab .count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.subnav-tab[aria-current="true"] .count {
  color: var(--ink-2);
  border-color: var(--ink-4);
}
.subnav-tab.has-new::before {
  content: "";
  position: absolute;
  top: 8px; right: 12px;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.subnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.next-hearing {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}
.next-hearing strong {
  color: var(--accent);
  font-weight: 500;
}

/* ─────────── Main layout ─────────── */
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 230px 1fr 380px;
}

/* ─────────── Spine (left rail) ─────────── */
.spine {
  border-right: 1px solid var(--rule);
  background: var(--surface);
  overflow-y: auto;
  padding: 18px 0 80px 0;
}
.spine-section {
  padding: 0 18px;
  margin-bottom: 22px;
}
.spine-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-4);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.spine-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spine-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  margin: 0 -6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 2px;
}
.spine-item:hover { background: var(--surface-2); color: var(--ink); }
.spine-item.active { background: var(--paper-deep); color: var(--ink); }
.spine-item .swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.swatch.penggugat { background: var(--ink-blue); }
.swatch.tergugat { background: var(--accent); }
.swatch.turut { background: var(--amber); }
.swatch.witness { background: var(--ink-3); }
.swatch.expert { background: var(--forest); }

.elements-list {
  margin: 0; padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.element {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.35;
}
.element-dot {
  flex: 0 0 auto;
  margin-top: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
}
.element-dot.supported { background: var(--forest); }
.element-dot.partial { background: var(--amber); }
.element-dot.gap { background: var(--accent); border: 1px solid var(--accent); background: transparent; }

.claim-card {
  border: 1px solid var(--rule);
  background: var(--surface-2);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.claim-title {
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin-bottom: 2px;
  line-height: 1.25;
}
.claim-basis {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.spine-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  color: var(--ink-2);
}
.spine-stat .num {
  font-family: var(--mono);
  font-size: 12.5px;
}

/* ─────────── Center pane ─────────── */
.center {
  overflow-y: auto;
  background: var(--paper);
  position: relative;
}

.view-padded { padding: 26px 32px 120px 32px; }

/* ─────────── Timeline view ─────────── */
.timeline-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.view-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1;
}
.view-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 6px;
}
.timeline-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--ink-3);
  align-items: center;
}
.legend-item { display: flex; gap: 5px; align-items: center; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.ok { background: var(--ink-2); }
.legend-dot.warn { background: var(--amber); }
.legend-dot.bad { background: var(--accent); }

.timeline {
  position: relative;
  padding-left: 140px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 124px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--rule);
}
.t-row {
  position: relative;
  padding: 14px 0 14px 28px;
  border-bottom: 1px dashed var(--rule-2);
  cursor: pointer;
}
.t-row:hover { background: var(--surface-2); margin: 0 -16px; padding-left: 44px; padding-right: 16px; }
.t-row:last-child { border-bottom: none; }
.t-date {
  position: absolute;
  left: -140px;
  width: 110px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  padding-top: 2px;
}
.t-dot {
  position: absolute;
  left: -8px; top: 18px;
  width: 11px; height: 11px;
  background: var(--paper);
  border: 1.5px solid var(--ink-2);
  border-radius: 50%;
  z-index: 1;
}
.t-row:hover .t-dot { left: 8px; }
.t-dot.warn { border-color: var(--amber); background: var(--warn-bg); }
.t-dot.bad { border-color: var(--accent); background: var(--found-bg); }
.t-dot.filing { background: var(--ink); border-color: var(--ink); }

.t-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin-bottom: 4px;
}
.t-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-3);
  flex-wrap: wrap;
}
.t-actor { color: var(--ink-2); }
.t-sources {
  font-family: var(--mono);
  font-size: 10.5px;
}
.t-source-chip {
  padding: 1px 5px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  margin-right: 4px;
  color: var(--ink-2);
}
.t-flag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border: 1px solid;
}
.t-flag.warn { color: var(--amber); border-color: var(--amber); background: var(--gap-bg); }
.t-flag.bad { color: var(--accent); border-color: var(--accent); background: var(--found-bg); }
.t-conf {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
}

/* ─────────── Graph view ─────────── */
.graph-wrap {
  border: 1px solid var(--rule);
  background: var(--surface);
  position: relative;
  height: 540px;
  overflow: hidden;
}
.graph-zoom-ctrl {
  position: absolute;
  top: 16px; right: 16px;
  display: flex; gap: 4px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 4px;
  z-index: 2;
}
.graph-zoom-ctrl button {
  width: 26px; height: 26px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.graph-zoom-ctrl button:hover { background: var(--ink); color: var(--paper); }
.graph-svg { width: 100%; height: 100%; display: block; }
.graph-legend {
  position: absolute;
  bottom: 16px; left: 16px;
  background: rgba(251, 247, 238, 0.94);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ─────────── Findings rail (right) ─────────── */
.findings {
  border-left: 1px solid var(--rule);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.findings-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.findings-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.findings-head h2 .num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
}
.findings-restraint {
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 4px;
  font-style: italic;
  line-height: 1.4;
}

.finding-filter {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  font-size: 11px;
}
.finding-filter button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  padding: 3px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
}
.finding-filter button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.finding {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule-2);
  cursor: pointer;
  position: relative;
}
.finding:hover { background: var(--surface-2); }
.finding.selected {
  background: var(--paper);
  border-left: 3px solid var(--ink);
  padding-left: 15px;
}
.finding.dismissed { opacity: 0.55; }

.finding-type {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.finding-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 6px;
  border: 1px solid;
}
.finding-tag.contradiction { color: var(--accent); border-color: var(--accent); background: var(--found-bg); }
.finding-tag.gap { color: var(--amber); border-color: var(--amber); background: var(--gap-bg); }
.finding-tag.chronology { color: var(--ink-blue); border-color: var(--ink-blue); background: #e1e7ef; }
.finding-tag.exposure { color: var(--forest); border-color: var(--forest); background: #d8e4dc; }
.finding-when {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  margin-left: auto;
}
.finding-title {
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin-bottom: 4px;
}
.finding-summary {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}
.finding-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.finding-conf {
  display: flex;
  align-items: center;
  gap: 4px;
}
.conf-bar {
  width: 38px; height: 4px;
  background: var(--rule);
  position: relative;
}
.conf-bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink-2);
}
.finding-action {
  margin-left: auto;
  color: var(--ink-2);
  font-family: var(--sans);
  font-style: italic;
  text-align: right;
}

/* ─────────── Detail overlay ─────────── */
.detail-mask {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.32);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}
.detail {
  width: 720px;
  max-width: 92vw;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail-head {
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--rule);
}
.detail-close {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--ink-3);
}
.detail-body { padding: 22px 28px 60px; }
.detail-section { margin-bottom: 28px; }
.detail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.detail h1 {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 6px 0 10px;
}

.anchor {
  border-left: 2px solid var(--ink-2);
  padding: 6px 0 6px 16px;
  margin-bottom: 16px;
}
.anchor-source {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.anchor-quote {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.anchor.b { border-color: var(--accent); }
.anchor.b .anchor-source { color: var(--accent); }

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  border-top: 1px solid var(--rule-2);
  border-bottom: 1px solid var(--rule-2);
  padding: 16px 0;
  margin-bottom: 24px;
}
.meta-row { display: flex; flex-direction: column; gap: 4px; }
.meta-row .v {
  font-size: 13px;
  color: var(--ink);
}
.meta-row .v.mono { font-family: var(--mono); font-size: 12px; }

.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 12.5px;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--ink-2); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-3);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { border-color: var(--accent); background: var(--accent); }
.btn.danger:hover { background: var(--accent-deep); }
.btn.link {
  background: transparent;
  border: none;
  color: var(--ink-blue);
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.permission-rung {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 3px 8px;
  margin-left: auto;
}
.permission-rung b { color: var(--ink); font-weight: 500; }

/* ─────────── Capture bar ─────────── */
.capture {
  position: fixed;
  left: 230px;
  right: 380px;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 0;
  z-index: 5;
  transition: transform 0.25s ease;
}
.capture.collapsed { transform: translateY(calc(100% - 38px)); }
.capture-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 24px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-2);
}
.capture-tab:hover { background: var(--surface-2); }
.capture-tab .pulse {
  width: 8px; height: 8px;
  background: var(--forest);
  border-radius: 50%;
  position: relative;
}
.capture-tab .pulse::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid var(--forest);
  border-radius: 50%;
  opacity: 0.6;
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  from { transform: scale(1); opacity: 0.6; }
  to { transform: scale(2.2); opacity: 0; }
}
.capture-tab .meta {
  margin-left: auto;
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
.capture-body {
  padding: 18px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.dropzone {
  border: 1.5px dashed var(--ink-4);
  padding: 22px;
  text-align: center;
  background: var(--surface-2);
  color: var(--ink-3);
}
.dropzone.over { border-color: var(--ink); background: var(--paper); color: var(--ink); }
.dropzone-title {
  font-family: var(--display);
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 4px;
}
.captured-list {
  list-style: none;
  margin: 0; padding: 0;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
}
.captured-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule-2);
}
.captured-item:last-child { border-bottom: none; }
.captured-name { font-family: var(--mono); font-size: 11px; color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.captured-time { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.captured-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1px 6px;
  border: 1px solid;
}
.captured-status.processed { color: var(--forest); border-color: var(--forest); }
.captured-status.processing { color: var(--amber); border-color: var(--amber); }
.captured-status.queued { color: var(--ink-4); border-color: var(--ink-4); }
.captured-findings {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
}

/* ─────────── Misc ─────────── */
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  color: var(--ink-3);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 0; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
