:root {
  color-scheme: light;
  --paper: #fff;
  --canvas: #f7f8f6;
  --ink: #171a18;
  --muted: #555e59;
  --faint: #707872;
  --rule: #d7dcd8;
  --rule-strong: #aab2ac;
  --accent: #17634d;
  --accent-soft: #e7f1ec;
  --warn: #754c08;
  --warn-soft: #fff6df;
  --danger: #9b3029;
  --danger-soft: #fff0ee;
  --focus: #075fba;
  --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); font-size: 14px; line-height: 1.5; }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
::selection { color: var(--ink); background: #c8e5d6; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #aeb8b1; border: 3px solid var(--canvas); border-radius: 8px; }
::-webkit-scrollbar-track { background: var(--canvas); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.topbar {
  min-height: 60px; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand { color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: underline; text-decoration-color: var(--rule-strong); }
.brand-mark, .empty-mark {
  width: 28px; height: 28px; display: grid; place-items: center; background: var(--ink); color: white;
  border-radius: 2px; font: 700 14px/1 var(--serif);
}
.brand strong { display: block; font: 700 16px/1.1 var(--serif); letter-spacing: -.025em; }
.brand-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #727b75; }
.dot.ok { background: var(--accent); }
.dot.bad { background: var(--danger); }

.shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar {
  min-width: 0; padding: 22px 16px 30px; background: var(--paper); border-right: 1px solid var(--rule);
  overflow: auto;
}
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 18px; }
.side-head h1 { margin: 0; font: 600 19px/1.2 var(--serif); letter-spacing: -.02em; }
.field-label { display: block; margin: 18px 0 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.input, .textarea {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--rule-strong); border-radius: 2px;
  background: var(--paper); color: var(--ink); outline: none;
}
.input::placeholder, .textarea::placeholder { color: #626b65; opacity: 1; }
.input:focus, .textarea:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 1px; }
.token-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.global-nav, .project-list { display: grid; gap: 1px; margin: 10px 0 20px; }
.global-nav a, .global-nav button, .project-item, .view-button {
  min-width: 0; border: 0; border-radius: 0; padding: 8px 9px; background: transparent; color: var(--ink);
  text-align: left; text-decoration: none; cursor: pointer;
}
.global-nav a:hover, .global-nav button:hover, .project-item:hover, .view-button:hover { background: #f0f2ef; }
.global-nav .selected, .global-nav [aria-current="page"], .project-item.selected {
  background: var(--accent-soft); color: #124b3b; box-shadow: inset 2px 0 var(--accent); font-weight: 650;
}
.project-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; border-bottom: 1px solid #eceeec; }
.project-item strong { display: block; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.project-item span { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; }
.folder-icon { flex: 0 0 15px; width: 15px; height: 12px; margin-top: 4px; border: 1px solid #727b75; border-radius: 1px; }
.folder-icon::before { content: ""; display: block; width: 7px; height: 3px; margin: -4px 0 0 -1px; border: 1px solid #727b75; border-bottom: 0; }
.button {
  display: inline-flex; justify-content: center; align-items: center; min-height: 36px; padding: 8px 12px; border: 1px solid var(--ink);
  border-radius: 2px; background: var(--ink); color: white; font-weight: 650; cursor: pointer;
}
.button:hover { background: #303633; border-color: #303633; }
.button:disabled { cursor: wait; opacity: .55; }
.button-small { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.button-quiet { background: transparent; border-color: var(--rule-strong); color: var(--ink); }
.button-quiet:hover { background: #eef1ee; border-color: #737c76; }

.workspace { width: 100%; min-width: 0; max-width: 1440px; margin: 0 auto; padding: 26px clamp(20px, 4vw, 56px) 60px; }
.notice { min-height: 0; margin-bottom: 8px; color: var(--danger); }
.notice:empty { display: none; }
.empty { max-width: 520px; margin: 15vh auto 0; color: var(--muted); }
.empty-mark { margin-bottom: 16px; }
.empty h2 { margin: 0 0 8px; color: var(--ink); font: 500 34px/1.1 var(--serif); letter-spacing: -.035em; }
.empty p { max-width: 54ch; margin: 0 0 20px; }
.project-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; padding: 10px 0 19px; border-bottom: 1px solid var(--rule-strong); }
.project-kicker { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.project-head h2 { margin: 0; font: 500 clamp(27px, 3vw, 38px)/1.08 var(--serif); letter-spacing: -.035em; overflow-wrap: anywhere; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-navigation { display: flex; align-items: center; gap: 3px; overflow-x: auto; padding: 9px 0 8px; border-bottom: 1px solid var(--rule); scrollbar-width: thin; }
.view-button { flex: 0 0 auto; padding: 8px 10px; color: var(--muted); font-size: 12px; }
.view-button.selected, .view-button[aria-current="page"] { color: var(--ink); background: transparent; box-shadow: inset 0 -2px var(--accent); font-weight: 700; }
.project-content { max-width: 1080px; padding-top: 20px; }
.project-content > .button { margin-bottom: 14px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, .65fr); gap: 34px; padding-top: 20px; }
.section { margin: 0 0 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 7px; margin-bottom: 10px; border-bottom: 1px solid var(--rule); }
.section h3 { margin: 0; font: 650 13px/1.3 var(--sans); letter-spacing: .005em; }
.section-meta, .version { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.body-outline { display: flex; flex-wrap: wrap; gap: 5px 18px; padding: 0 0 14px; margin: 0 0 18px; border-bottom: 1px solid var(--rule); }
.body-outline a { font-size: 12px; }
.body-reader { padding: 2px 0; line-height: 1.72; }
.body-reader section { scroll-margin-top: 20px; }
.body-reader h3, .body-reader h4, .body-reader h5, .body-reader h6 { margin: 24px 0 7px; font: 500 21px/1.25 var(--serif); letter-spacing: -.015em; }
.body-reader section:first-child h3 { margin-top: 0; }
.body-reader .entry-body { margin: 0 0 16px; }
.body-editor { min-height: 52vh; resize: vertical; font: 13px/1.65 var(--mono); tab-size: 2; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.entry { padding: 13px 0; border-bottom: 1px solid var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.entry-body, .work-body { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.entry-body { white-space: pre-wrap; font: 12px/1.55 var(--mono); }
.append-form { display: flex; align-items: center; gap: 8px; margin: 12px 0 22px; }
.append-form .input { flex: 1; }
.work-list { display: grid; }
.work-row { padding: 12px 0; border-bottom: 1px solid var(--rule); background: transparent; }
.work-row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.work-row-top > strong { max-width: 72ch; font-weight: 600; overflow-wrap: anywhere; }
.status { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.status-open { color: #185f49; }.status-claimed { color: var(--warn); }.status-complete { color: var(--muted); }.status-blocked { color: var(--danger); }
.work-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.work-actions .button { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.work-result-form { max-width: 620px; padding: 12px 0 4px; }
.work-result-form textarea { min-height: 72px; }
.history { color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.conflict { padding: 12px 0; margin: 0 0 18px; border-top: 1px solid var(--warn); border-bottom: 1px solid var(--warn); background: var(--warn-soft); }
.conflict strong { display: block; color: #593900; }
.conflict pre { max-height: 180px; overflow: auto; margin: 7px 0; white-space: pre-wrap; font: 12px/1.5 var(--mono); }
.conflict-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.conflict-compare h4 { margin: 12px 0 5px; font-size: 12px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0 0 14px; font: 500 25px/1.2 var(--serif); }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
dialog { width: min(540px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgb(23 26 24 / 42%); }
dialog form > .button { margin: 8px 8px 0 0; }
details summary { width: fit-content; color: var(--accent); cursor: pointer; text-underline-offset: 3px; }

.context-inspector { min-width: 0; padding: 18px 0; border-top: 1px solid var(--rule); color: var(--muted); }
.context-inspector h2, .context-inspector h3 { margin: 0 0 10px; color: var(--ink); font: 600 14px/1.3 var(--sans); }
.context-inspector dl { display: grid; grid-template-columns: minmax(76px, .5fr) minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 12px; }
.context-inspector dt { color: var(--muted); }.context-inspector dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

.global-page { max-width: 940px; padding-top: 8px; }
.global-page > h2 { margin: 0 0 20px; font: 500 clamp(28px, 3vw, 38px)/1.12 var(--serif); letter-spacing: -.03em; }
.global-record, .workstream-row, .run-row { padding: 13px 0; border-bottom: 1px solid var(--rule); }
.record-title { padding: 0; border: 0; background: transparent; color: var(--ink); font: 600 15px/1.35 var(--sans); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.record-title:hover { color: var(--accent); text-decoration-color: currentColor; }
.legacy-work-label { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); font: 400 14px/1.55 var(--sans); text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.legacy-work-label:hover { color: var(--accent); }
.global-record > .entry-meta { margin-top: 3px; }
.pinned-context { padding: 12px 0; margin: 0 0 16px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.pinned-context h2 { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.pinned-item { display: block; width: 100%; padding: 4px 0; border: 0; background: transparent; color: var(--accent); text-align: left; cursor: pointer; }
.overview-summary { padding: 4px 0 18px; }
.overview-summary h3 { margin: 0 0 7px; font: 500 21px/1.25 var(--serif); }
.overview-summary > .entry-body { max-width: 76ch; color: var(--muted); }
.workstream-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.workstream-row > .entry-body { max-width: 76ch; }
.record-form { max-width: 760px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; padding: 18px 0; margin: 8px 0 24px; border-top: 1px solid var(--rule); }
.record-form > h3, .record-form > h4, .record-form > .form-actions { grid-column: 1 / -1; }
.record-form h3, .record-form h4 { margin: 0 0 4px; font: 600 15px/1.3 var(--sans); }
.form-field { min-width: 0; display: block; margin: 0 0 10px; }
.form-field .field-label { margin: 0 0 5px; }
.form-field input:not([type="checkbox"]), .form-field textarea { width: 100%; min-height: 36px; }
.form-field textarea { min-height: 74px; resize: vertical; font: 12px/1.5 var(--mono); }
.form-field input[type="checkbox"] { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.run-inspector { padding: 13px 0; border-top: 1px solid var(--rule); color: var(--ink); }
.run-inspector h4 { margin: 0 0 7px; font-size: 13px; }
.needs-you { color: var(--danger); font-weight: 650; }
.context-inspector .section { margin-top: 16px; }
.context-inspector .record-form { grid-template-columns: 1fr; }
.context-inspector .record-form > h4, .context-inspector .record-form > .form-actions { grid-column: 1; }
.context-link { padding: 0; border: 0; background: transparent; color: var(--accent); text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.context-link-unavailable { color: var(--muted); font-size: 12px; }
.pinned-context h2 span { color: var(--faint); font-weight: 500; letter-spacing: 0; text-transform: none; }
.workspace:has(.context-inspector) > #project-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 285px); column-gap: 30px; align-content: start; }
.workspace:has(.context-inspector) > #project-view > .back-projects,
.workspace:has(.context-inspector) > #project-view > .project-head,
.workspace:has(.context-inspector) > #project-view > .project-navigation { grid-column: 1 / -1; }
.workspace:has(.context-inspector) > #project-view > .project-content { grid-column: 1; max-width: none; }
.workspace:has(.context-inspector) > #project-view > .context-inspector { grid-column: 2; grid-row: 4; align-self: start; margin-top: 18px; }

@media (max-width: 780px) {
  .topbar { min-height: 56px; padding: 0 14px; }
  .shell { display: block; min-height: calc(100vh - 56px); }
  .sidebar { padding: 14px; border-right: 0; border-bottom: 1px solid var(--rule); overflow: visible; }
  .global-nav { display: flex; overflow-x: auto; margin: 8px -2px 12px; }
  .global-nav a, .global-nav button { flex: 0 0 auto; white-space: nowrap; }
  .project-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); max-height: 190px; overflow: auto; }
  .workspace { padding: 20px 16px 40px; }
  .project-head { display: block; }
  .head-actions { margin-top: 14px; }
  .project-navigation { margin-right: -16px; padding-right: 16px; }
  .editor-grid { display: block; }
  .body-outline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .body-reader { line-height: 1.65; }
  .record-form { grid-template-columns: 1fr; }
  .record-form > h3, .record-form > h4, .record-form > .form-actions { grid-column: 1; }
  .workspace:has(.context-inspector) > #project-view { display: block; }
}
@media (max-width: 480px) {
  .brand-sub { font-size: 11px; }
  .connection { gap: 5px; font-size: 11px; }
  .side-head { align-items: flex-start; }
  .project-head h2 { font-size: 29px; }
  .head-actions > * { flex: 1 1 auto; }
  .append-form { align-items: stretch; flex-direction: column; }
  .append-form .button { width: 100%; }
  .conflict-compare { grid-template-columns: 1fr; }
  .work-row-top { display: block; }
  .status { display: inline-block; margin-top: 5px; }
  .body-outline { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
