:root {
  --ink: #17201c;
  --muted: #65716a;
  --paper: #f6f4ee;
  --card: #fffefa;
  --line: #deddd5;
  --green: #1f684d;
  --green-soft: #dcece3;
  --amber: #b66b1b;
  --amber-soft: #fff0dc;
  --shadow: 0 16px 46px rgba(31, 46, 38, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(216, 233, 223, 0.72), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding: 3rem clamp(1.25rem, 5vw, 5rem) 2.25rem;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-family: Georgia, serif; font-size: clamp(2.3rem, 5vw, 4.4rem); font-weight: 500; letter-spacing: -.04em; }
h2 { margin-bottom: .65rem; font-size: 1.05rem; }
.eyebrow, .label { color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.subtitle { max-width: 42rem; margin-bottom: 0; color: var(--muted); }
.status-pill, .review-status { display: inline-flex; align-items: center; gap: .55rem; border: 1px solid #b8d2c2; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: .6rem .9rem; font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.status-pill span { width: .5rem; height: .5rem; border-radius: 50%; background: #2d9168; box-shadow: 0 0 0 .25rem rgba(45, 145, 104, .13); }

.layout { display: grid; grid-template-columns: minmax(17rem, 24rem) minmax(0, 1fr); gap: 1.4rem; padding: 1.4rem clamp(1.25rem, 5vw, 5rem) 4rem; }
.sidebar, .workspace { display: flex; min-width: 0; flex-direction: column; gap: 1.4rem; }
.panel, .run-card, .result-header, .empty-state, .raw-result { border: 1px solid var(--line); border-radius: 1.1rem; background: rgba(255, 254, 250, .94); box-shadow: var(--shadow); }
.panel { padding: 1.25rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.count { border-radius: 999px; background: #eeeee8; color: var(--muted); padding: .25rem .55rem; font-size: .72rem; font-weight: 700; }
.task-copy { max-height: 21rem; margin: .5rem 0 0; overflow: auto; color: #35413b; font: .78rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.source-list, .evidence-list { margin: .4rem 0 0; padding: 0; list-style: none; }
.source-list li { border-top: 1px solid #ebeae4; }
.source-button { display: flex; width: 100%; min-width: 0; align-items: center; gap: .65rem; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: #4e5953; padding: .52rem 0; font-size: .82rem; font-weight: 500; text-align: left; }
.source-button:hover { background: #f0f4ef; color: var(--green); }
.source-button[aria-pressed="true"] { background: var(--green-soft); color: var(--green); font-weight: 700; }
.source-button:focus-visible { outline: 3px solid rgba(31, 104, 77, .25); outline-offset: 2px; }
.source-button span:last-child { overflow-wrap: anywhere; }
.file-mark { width: .55rem; height: .7rem; border: 1px solid #779283; border-radius: .1rem; background: #eef5f0; }

.run-card { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 1.6rem 1.8rem; background: linear-gradient(135deg, #fffefa, #eef6f1); }
.run-card p:last-child { max-width: 41rem; margin-bottom: 0; color: var(--muted); }
.run-card form { min-width: min(100%, 23rem); }
.case-select-label { display: block; margin-bottom: .45rem; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.run-controls { display: flex; flex-direction: column; gap: .65rem; }
select { width: 100%; border: 1px solid #bfcac3; border-radius: .75rem; background: white; color: var(--ink); padding: .8rem .9rem; font: inherit; font-weight: 700; }
select:focus { outline: 3px solid rgba(31, 104, 77, .16); border-color: var(--green); }
button { min-width: 14rem; border: 0; border-radius: .75rem; background: var(--green); color: white; padding: .9rem 1.1rem; cursor: pointer; font: inherit; font-weight: 800; box-shadow: 0 8px 20px rgba(31, 104, 77, .2); }
button:hover { background: #164f3a; }
button:disabled { cursor: wait; opacity: .72; }
button span { margin-left: .5rem; }

.loading-panel { display: grid; grid-template-columns: 1fr 16rem; align-items: center; gap: 2rem; overflow: hidden; border: 1px solid #b8d2c2; border-radius: 1.1rem; background: linear-gradient(135deg, #f9fcfa, #e4f1e9); padding: 1.5rem 1.7rem; box-shadow: var(--shadow); }
.loading-panel[hidden] { display: none; }
.loading-copy p:last-child { max-width: 42rem; margin-bottom: 0; color: var(--muted); }
.scroll-window { position: relative; height: 8.5rem; overflow: hidden; border: 1px solid #c2d6ca; border-radius: .8rem; background: rgba(255, 255, 255, .65); }
.scroll-window::before, .scroll-window::after { position: absolute; z-index: 2; right: 0; left: 0; height: 2.2rem; content: ""; pointer-events: none; }
.scroll-window::before { top: 0; background: linear-gradient(#edf6f0, transparent); }
.scroll-window::after { bottom: 0; background: linear-gradient(transparent, #edf6f0); }
.scrolling-evidence { display: flex; flex-direction: column; gap: .55rem; padding: .65rem; animation: evidence-scroll 4.8s linear infinite; }
.scroll-item { display: grid; grid-template-columns: 3.2rem 1fr; gap: .55rem; min-height: 2.5rem; align-items: center; border: 1px solid #d8e3dc; border-radius: .55rem; background: white; padding: .45rem .55rem; box-shadow: 0 5px 12px rgba(31, 104, 77, .06); }
.scroll-item span { grid-row: 1 / 3; color: var(--green); font: 800 .64rem ui-monospace, monospace; }
.scroll-item i { display: block; height: .34rem; border-radius: 999px; background: #d9e3dd; }
.scroll-item i:last-child { width: 68%; }
body.is-loading .run-card { opacity: .72; }

@keyframes evidence-scroll {
  from { transform: translateY(0); }
  to { transform: translateY(-12.2rem); }
}

.alert { border: 1px solid #e9b97d; border-radius: .9rem; background: var(--amber-soft); color: #75440f; padding: 1rem 1.2rem; }
.alert p { margin: .35rem 0 0; }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.5rem 1.7rem; }
.result-header h2 { max-width: 52rem; margin: 0; font-family: Georgia, serif; font-size: clamp(1.35rem, 2.2vw, 2rem); font-weight: 500; line-height: 1.3; }
.result-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 1.4rem; }
.highlight-card { border-left: .32rem solid var(--green); }
.action-card { border-left: .32rem solid var(--amber); }
.draft { font-family: Georgia, serif; font-size: 1.25rem; line-height: 1.55; }
.fine-print { margin-bottom: 0; color: var(--muted); font-size: .75rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.chips span { border-radius: 999px; background: var(--amber-soft); color: #8b5010; padding: .3rem .6rem; font: 700 .73rem ui-monospace, monospace; }
.chips.compact { margin-top: 0; }
.chips.compact span { background: var(--green-soft); color: var(--green); }
.full-width { width: 100%; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .72rem .5rem; border-top: 1px solid #ebeae4; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
code { color: var(--green); font-size: .76rem; }
.evidence-list li { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: .85rem 0; border-top: 1px solid #ebeae4; }
.evidence-list p { margin: 0; }
.conflict-card { border-color: #e3a45b; background: var(--amber-soft); }
.raw-result { overflow: hidden; }
.raw-result summary { cursor: pointer; padding: 1rem 1.2rem; font-weight: 800; }
.raw-result pre { margin: 0; overflow: auto; border-top: 1px solid var(--line); background: #1f2924; color: #d9e5de; padding: 1.2rem; font-size: .78rem; line-height: 1.55; }
.empty-state { padding: 4.5rem 2rem; text-align: center; }
.empty-state p { margin-bottom: 0; color: var(--muted); }
.empty-icon { display: grid; width: 3rem; height: 3rem; margin: 0 auto 1rem; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 900; }

@media (max-width: 900px) {
  .site-header, .run-card, .result-header { align-items: flex-start; flex-direction: column; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  button { width: 100%; }
  .loading-panel { grid-template-columns: 1fr; }
  .scroll-window { width: 100%; }
}

@media (max-width: 600px) {
  .site-header { padding-top: 2rem; }
  .sidebar { display: flex; }
  .evidence-list li { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scrolling-evidence { animation: none; }
}
