/* Palette: deep teal fields, warm cream paper, leaf and pale greens, a mint highlight.
   Signature shape: square corners with one rounded bottom-right corner. */
:root {
  color-scheme: light;
  --font-display: "Alegreya Sans", "Gill Sans", "Segoe UI", sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3eee5;
  --text: #22302f;
  --heading: #0a4150;
  --muted: #5c6b6b;
  --border: #e3dccf;
  --accent: #2f7d45;          /* leaf: links, focus, selection */
  --cta: #8fd48f;             /* pale green: primary buttons */
  --cta-hover: #7cc97e;
  --cta-text: #08343f;
  --band: #0a4150;            /* deep teal header + banner */
  --band-2: #11596b;
  --band-text: #faf6ef;
  --band-muted: #bfd6d6;
  --mint: #74dfc6;
  --warn-bg: #f7ead0;
  --warn-border: #d9a441;
  --warn-text: #3d3320;
  --bad: #b5412f;
  --ok: #2f7d45;
  --strategy: #f3d46b;
  --result: #a8cde0;
  --trr: #c9b8e3;
  --impact: #9ed39f;
  --node-text: #14282b;
  --node-border: rgba(10, 65, 80, 0.35);
  --canvas: #fdfbf7;
  --canvas-dot: #e6dfd2;
  --corner: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #062b35;
    --surface: #0b3a47;
    --surface-2: #0f4655;
    --text: #eef1ec;
    --heading: #f7f1e8;
    --muted: #a5bfc2;
    --border: #1c5868;
    --accent: #8fd48f;
    --cta: #8fd48f;
    --cta-hover: #a3dea3;
    --cta-text: #06303a;
    --band: #04212a;
    --band-2: #0f4655;
    --band-text: #f7f1e8;
    --band-muted: #a5bfc2;
    --mint: #74dfc6;
    --warn-bg: #3a3218;
    --warn-border: #c9973a;
    --warn-text: #f4e7c8;
    --bad: #ff8a73;
    --ok: #8fd48f;
    --canvas: #05313c;
    --canvas-dot: #0f4a59;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #062b35;
  --surface: #0b3a47;
  --surface-2: #0f4655;
  --text: #eef1ec;
  --heading: #f7f1e8;
  --muted: #a5bfc2;
  --border: #1c5868;
  --accent: #8fd48f;
  --cta: #8fd48f;
  --cta-hover: #a3dea3;
  --cta-text: #06303a;
  --band: #04212a;
  --band-2: #0f4655;
  --band-text: #f7f1e8;
  --band-muted: #a5bfc2;
  --mint: #74dfc6;
  --warn-bg: #3a3218;
  --warn-border: #c9973a;
  --warn-text: #f4e7c8;
  --bad: #ff8a73;
  --ok: #8fd48f;
  --canvas: #05313c;
  --canvas-dot: #0f4a59;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--font-display); color: var(--heading); letter-spacing: 0.005em; }
h2 { margin: 0; font-size: 1.7rem; font-weight: 400; line-height: 1.15; }
h3 { margin: 0 0 10px; font-size: 1.3rem; font-weight: 500; }

/* ---- Header band ---------------------------------------------------------- */
.site-header {
  background: var(--band);
  color: var(--band-text);
  border-bottom-right-radius: 64px;
  margin-bottom: 8px;
}
.site-header .inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}
.header-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
}
.site-header h1 {
  margin: 28px 0 10px;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 300;
  line-height: 1.05;
  color: var(--band-text);
}
.site-header .lede { margin: 0; max-width: 46rem; font-size: 1.05rem; font-weight: 300; color: var(--band-muted); }
.site-header .lede em { color: var(--band-text); font-style: normal; font-weight: 500; }

.theme-switch { display: inline-flex; border: 1px solid #ffffff40; }
.theme-switch button {
  background: transparent;
  color: var(--band-muted);
  border: 0;
  border-radius: 0;
  padding: 5px 12px;
  font-size: 0.8rem;
}
.theme-switch button:hover { color: var(--band-text); }
.theme-switch button[aria-pressed="true"] { background: var(--band-text); color: var(--band); font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }

/* ---- Surfaces ------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--corner) 0;
  padding: 20px;
  margin: 20px 0;
}

/* ---- Controls ------------------------------------------------------------- */
button, select, textarea, input { font: inherit; color: var(--text); }
button, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 0;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--cta);
  color: var(--cta-text);
  border-color: var(--cta);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 0 0 14px 0;
}
button.primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
button.primary.arrow::after { content: "  →"; }
button[aria-pressed="true"] { background: var(--heading); color: var(--surface); border-color: var(--heading); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
textarea {
  width: 100%;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 0 0 10px 0;
  padding: 10px;
}

.tabs { display: flex; gap: 0; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--text); border-bottom-color: var(--border); }
.tab.active { color: var(--heading); border-bottom-color: var(--accent); font-weight: 700; }
.drop {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 0 0 var(--corner) 0;
  background: var(--canvas);
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input { display: none; }
.notice {
  margin-top: 16px;
  padding: 14px 18px 14px 52px;
  position: relative;
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  border-left-width: 6px;
  border-radius: 0 0 var(--corner) 0;
  font-size: 0.93rem;
}
.notice::before {
  content: "!";
  position: absolute;
  left: 16px;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--warn-border);
  color: #2b2210;
  font-weight: 700;
  text-align: center;
  line-height: 22px;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 8px; }
.notice strong { font-weight: 700; }
.access { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 16px; }
.access label { font-weight: 600; color: var(--heading); }
.access input {
  font: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  width: 13em;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.access input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.access .bad { color: var(--bad); }
.run-note { font-size: 0.82rem; opacity: 0.85; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }

/* ---- Document banner ------------------------------------------------------ */
.banner {
  background: var(--band-2);
  color: var(--band-text);
  border-radius: 0 0 48px 0;
  padding: 24px 28px;
  margin: 20px 0;
}
.banner h2 { color: var(--band-text); }
.banner .muted { color: var(--band-muted); }
.banner.caution { background: var(--warn-bg); color: var(--warn-text); box-shadow: inset 6px 0 0 var(--warn-border); }
.banner.caution h2 { color: var(--warn-text); }
.banner.caution .muted { color: var(--warn-text); opacity: 0.8; }
.banner-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner p { margin: 10px 0 0; max-width: 62rem; }
.pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--mint);
  color: #06303a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.caution .pill { background: var(--warn-border); color: #2b2210; }
.stats { display: flex; gap: 10px 22px; flex-wrap: wrap; margin-top: 16px; font-size: 0.88rem; }
.stat b { font-weight: 700; font-size: 1.05rem; color: var(--mint); margin-right: 2px; }
.caution .stat b { color: inherit; }

/* ---- Checks --------------------------------------------------------------- */
.warnings summary { cursor: pointer; font-weight: 600; font-family: var(--font-display); font-size: 1.15rem; color: var(--heading); }
.warnings ul { margin: 10px 0 0; padding-left: 20px; }
.count { color: var(--muted); font-weight: 400; }

/* ---- Workspace ------------------------------------------------------------ */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; }
.workspace > .card { margin: 0; }
@media (max-width: 900px) { .workspace { grid-template-columns: minmax(0, 1fr); } }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar label { font-size: 0.85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.toolbar .spacer { flex: 1; }
#cy {
  height: 62vh;
  min-height: 380px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--corner) 0;
  background-color: var(--canvas);
  background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 22px 22px;
}
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.sw { display: inline-block; width: 14px; height: 10px; margin-right: 5px; vertical-align: middle; border: 1px solid #0003; border-radius: 0 0 4px 0; }
.sw.strategy { background: var(--strategy); }
.sw.result { background: var(--result); }
.sw.trr { background: var(--trr); }
.sw.impact { background: var(--impact); }
.sw.dashed { border: 2px dashed var(--muted); background: transparent; }
.sw.bad { border: 2px solid var(--bad); background: transparent; }
.sw.ok { border: 3px double var(--ok); background: transparent; }

.panel { max-height: calc(62vh + 110px); overflow: auto; }
.panel label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-top: 12px; }
.panel select, .panel textarea { width: 100%; margin-top: 3px; font-weight: 400; }
.panel h3 { margin-bottom: 4px; }
.quote {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--mint);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
}
.qstatus { font-size: 0.85rem; margin-top: 4px; }
.qstatus.verified { color: var(--ok); }
.qstatus.not_found { color: var(--bad); }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin: 20px 0 0; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.list { margin: 0; padding-left: 18px; }
.list li { margin-bottom: 8px; }
.list li::marker { color: var(--accent); }
.list .muted { font-size: 0.85rem; }

/* ---- Ontology conformance ------------------------------------------------- */
#shacl h4 { margin: 16px 0 6px; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#shacl > p { margin: 10px 0 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.chip {
  padding: 1px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 0;
}
.chip.static { color: var(--muted); }

/* ---- Example link --------------------------------------------------------- */
.example-cta { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.9rem; }
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
button.link:hover { text-decoration-thickness: 2px; }
.stat a { color: inherit; text-underline-offset: 3px; }
.sev {
  display: inline-block;
  margin-right: 8px;
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 1px;
  border-radius: 0 0 5px 0;
}
.sev.must { background: var(--bad); color: var(--surface); }
.sev.should { border: 1px solid var(--warn-border); color: var(--text); }

/* ---- Contexts and Wikidata ------------------------------------------------ */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
#link-status:empty { display: none; }
#link-status { margin: 6px 0 0; font-size: 0.85rem; }
#contexts { margin-top: 12px; }
#contexts > li { margin-bottom: 14px; }
.wd { margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border-radius: 0 0 10px 0; font-size: 0.9rem; }
.wd-head { display: flex; gap: 10px; align-items: flex-start; }
.wd .why { margin-top: 4px; font-size: 0.82rem; }
.wd .ids { font-size: 0.82rem; margin-top: 2px; }
.wd a { color: var(--accent); text-underline-offset: 3px; }
.wd-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.wd-actions button { padding: 4px 12px; font-size: 0.82rem; }
.tag {
  display: inline-block;
  flex: none;
  padding: 1px 7px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 0 0 5px 0;
  margin-top: 2px;
}
.tag.suggested { border: 1px solid var(--warn-border); color: var(--text); }
.tag.confirmed { background: var(--ok); color: var(--surface); }
.tag.none { border: 1px solid var(--border); color: var(--muted); }
.picker-list { display: grid; gap: 4px; }
.pick { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; padding: 3px 0; }
.pick input { margin-top: 4px; }
.picker-search { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.picker-search input {
  flex: 1;
  min-width: 140px;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 0;
}

/* ---- Impact targets ------------------------------------------------------- */
.targets { margin-top: 14px; }
.targets .hint { font-size: 0.8rem; margin-bottom: 4px; }
.targets .wd { margin-top: 8px; }
.target-name { margin-bottom: 4px; }
.wd .detail { font-size: 0.8rem; }
.picker-search select { padding: 5px 8px; }
/* The side panel styles labels as field headings; picker options are not headings. */
.panel label.pick { display: flex; margin-top: 0; font-size: 0.88rem; font-weight: 400; color: var(--text); }
.panel .picker-search select { width: auto; margin-top: 0; }

/* ---- Extraction progress -------------------------------------------------- */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.progress-head h3 { margin: 0; }
#progress-facts { margin: 6px 0 12px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 0 0 6px 0; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.8s ease; }
.progress.slow #progress-bar { animation: pulse 1.6s ease-in-out infinite; }
.steps { list-style: none; padding: 0; margin: 14px 0 6px; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 0.92rem; }
.steps li { color: var(--muted); padding-left: 22px; position: relative; }
.steps li::before { content: ""; position: absolute; left: 2px; top: 0.45em; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓"; border: 0; width: auto; height: auto; top: 0; left: 0; color: var(--accent); font-weight: 700; }
.steps li.failed::before { content: "!"; border: 0; width: auto; height: auto; top: 0; left: 4px; color: var(--bad); font-weight: 700; }
.thinking { margin-top: 12px; min-height: 1.5em; }
.thinking p { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--accent); max-width: 62rem; transition: opacity 0.4s; }
.thinking p.old { opacity: 0.55; border-left-color: var(--border); font-size: 0.92rem; }
.thinking-all { margin-top: 10px; }
.thinking-all summary { cursor: pointer; color: var(--muted); }
.thinking-all ol { margin: 8px 0 0; padding-left: 22px; max-width: 62rem; }
.thinking-all li { margin: 6px 0; }
.progress .error { color: var(--bad); font-weight: 600; }
/* While the chain is being written: show the banner and diagram only, and don't allow edits yet. */
#result-section.building #warnings-box,
#result-section.building #shacl-box,
#result-section.building .grid-2,
#result-section.building > section.card,
#result-section.building .toolbar,
#result-section.building #stats,
#result-section.building #panel { display: none; }
#result-section.building #cy { pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .steps li.active::before, .progress.slow #progress-bar { animation: none; }
  #progress-bar { transition: none; }
}
#result-section.building .workspace { grid-template-columns: minmax(0, 1fr); }
