:root {
  --bg: #ecebe6;
  --paper: #fffefb;
  --ink: #1f1d1a;
  --ink-2: #57524a;
  --muted: #8f897e;
  --line: #e2ddd3;
  --line-strong: #cfc8bb;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --accent: #4f5fe0;
  --accent-soft: rgba(79, 95, 224, .12);
  --on-accent: #ffffff;
  --agent: #d97757;
  --on-agent: #ffffff;
  --evidence: #0f766e;
  --evidence-soft: rgba(15, 118, 110, .11);
  --proposed: #a16207;
  --proposed-soft: rgba(202, 138, 4, .13);
  --confirmed: #15803d;
  --danger: #b42318;
  --excerpt: #8b5cf6;
  --excerpt-soft: rgba(139, 92, 246, .14);
  --ins: #15803d;
  --del: #c2410c;
  --hl-yellow: #fde58a;
  --hl-green: #c3efc9;
  --hl-blue: #c9dcfd;
  --hl-pink: #fbd0e5;
  --hot: rgba(79, 95, 224, .18);
  --shadow-sm: 0 1px 2px rgba(30, 25, 15, .06);
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 6px 20px rgba(30, 25, 15, .08);
  --shadow-lg: 0 2px 6px rgba(30, 25, 15, .08), 0 18px 40px rgba(30, 25, 15, .14);
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --paper: #1c1b19;
    --ink: #ebe7df;
    --ink-2: #b7b0a4;
    --muted: #8a8478;
    --line: #2f2d29;
    --line-strong: #45423c;
    --surface: #24231f;
    --surface-2: #1f1e1b;
    --accent: #8b9bff;
    --accent-soft: rgba(139, 155, 255, .16);
    --on-accent: #12141f;
    --agent: #e0896b;
    --on-agent: #12141f; /* 6.9:1 on --agent; white would be 2.6:1 */
    --evidence: #4fd1bd;
    --evidence-soft: rgba(79, 209, 189, .14);
    --proposed: #f2b84b;
    --proposed-soft: rgba(242, 184, 75, .14);
    --confirmed: #6ee79a;
    --danger: #ff8f80;
    --excerpt: #b394ff;
    --excerpt-soft: rgba(179, 148, 255, .16);
    --ins: #6ee79a;
    --del: #ff9b6b;
    --hl-yellow: rgba(250, 204, 21, .32);
    --hl-green: rgba(74, 222, 128, .26);
    --hl-blue: rgba(96, 165, 250, .30);
    --hl-pink: rgba(244, 114, 182, .30);
    --hot: rgba(139, 155, 255, .22);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Nothing to see until the first submission is open */
body.booting #layout, body.booting #appbar { visibility: hidden; }
button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}
button:hover { background: var(--surface-2); }
button:disabled { cursor: default; opacity: .45; }
button:disabled:hover { background: transparent; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent); filter: brightness(1.08); }
code { font: .92em ui-monospace, "SF Mono", Menlo, monospace; padding: 0 .3em; border-radius: 4px; background: color-mix(in srgb, currentColor 12%, transparent); }
[hidden] { display: none !important; }

/* Layout */
#layout { display: flex; flex: 1 1 auto; min-height: 0; }
#doc-pane { flex: 0 0 58%; min-width: 0; overflow: auto; position: relative; scroll-behavior: smooth; }
#divider {
  flex: 0 0 9px;
  cursor: col-resize;
  position: relative;
  background: transparent;
}
#divider::after {
  content: "";
  position: absolute;
  inset: 0 4px;
  background: var(--line);
  transition: background .15s, inset .15s;
}
#divider:hover::after { background: var(--accent); inset: 0 3px; }
/* Right-hand column: the marking report above the workspace */
#side { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#side > .ws { min-height: 0; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 75; /* above the inbox drawer (70), so its Undo stays clickable; below the drop hint (80) */
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  max-width: min(560px, calc(100vw - 32px));
  width: max-content;
  text-align: center;
  animation: toast-in .18s ease-out;
}
.toast.error, .toast.warn { border-radius: 12px; padding: 10px 16px 10px 14px; text-align: left; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.toast.error::before, .toast.warn::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); transform: translateY(-1px); }
.toast.warn::before { background: var(--proposed); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* Read by screen readers, not shown */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* While the agent marks, the page is read-only: a pill at the top of the document says so. */
.lock-banner {
  position: sticky;
  top: 6px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  height: 30px;
  margin: 3px auto -33px;
  padding: 0 4px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12.5px;
  white-space: nowrap;
}
.lock-banner > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.lock-banner .avatar { flex: none; }
.lock-banner button { flex: none; padding: 4px 10px; border-radius: 999px; color: var(--danger); font-weight: 600; }
.lock-banner button::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 2px; background: currentColor; }

/* Connector between an excerpt card and its source */
.connector {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 40;
  opacity: 0;
  transition: opacity .15s;
}
.connector.on { opacity: 1; }
.connector path { fill: none; stroke: var(--excerpt); stroke-width: 1.75; stroke-dasharray: 5 4; }
.connector circle { fill: var(--excerpt); }

@media (max-width: 860px) {
  body { display: block; overflow: auto; }
  #layout { flex-direction: column; height: auto; }
  #doc-pane { flex: none; overflow: visible; }
  #divider { display: none; }
  #side { flex: none; border-top: 1px solid var(--line); }
  .ws { height: 80vh; flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
