:root {
  --background: #efe6d6;
  --bright: #3b342e;
  --phosphor: #a8623f;
  --dim: #7a6e63;
  --faint: #a39789;
  --rule: rgba(59, 52, 46, 0.18);
  --rule-inner: rgba(59, 52, 46, 0.12);
  --tint: rgba(59, 52, 46, 0.06);
  --amber: #a65a3c;
  --shadow: 0 0 14px 3px rgba(59, 52, 46, 0.06);
  --sky-background: linear-gradient(
    180deg,
    #e3dfe4 0%,
    #ece5da 34%,
    #efe6d6 100%
  );
  --sun-background: radial-gradient(
    circle at var(--sun-x) 6%,
    rgba(255, 250, 232, 0.95) 0,
    rgba(255, 236, 170, 0.72) 6vmin,
    rgba(255, 226, 150, 0.32) 18vmin,
    rgba(255, 226, 150, 0) 38vmin
  );
  --selection: #d9c4a3;
  --focus: #526348;
  --header-rule: rgba(59, 52, 46, 0.1);
  --mark-shadow: rgba(255, 250, 240, 0.9);
  --daemon-running: #8a9a78;
  --control-surface: rgba(59, 52, 46, 0.05);
  --control-shadow: 0 0 12px 3px rgba(59, 52, 46, 0.05);
  --chip-shadow: 0 0 14px 3px rgba(59, 52, 46, 0.05);
  --control-hover-surface: rgba(251, 247, 239, 0.45);
  --control-current-surface: rgba(251, 247, 239, 0.9);
  --danger: #8c3f2b;
  --danger-hover: #6f2f21;
  --panel-surface: rgba(251, 247, 239, 0.85);
  --panel-strong-surface: rgba(251, 247, 239, 0.9);
  --error-surface: rgba(168, 98, 63, 0.12);
  --fact-rule: rgba(59, 52, 46, 0.14);
  --link: var(--phosphor);
  --link-hover: #8c4b2e;
  --status-on-color: #fbf7ef;
  --working-surface: rgba(126, 154, 108, 0.85);
  --working-shadow: 0 0 14px 3px rgba(126, 154, 108, 0.48);
  --action: #56704b;
  --action-hover: #3f5536;
  --action-surface: rgba(86, 112, 75, 0.1);
  --action-hover-surface: rgba(86, 112, 75, 0.18);
  --action-shadow: 0 0 14px 2px rgba(86, 112, 75, 0.1);
  --waiting: #5f7052;
  --waiting-surface: rgba(170, 190, 140, 0.45);
  --waiting-shadow: 0 0 14px 3px rgba(170, 190, 140, 0.28);
  --feedback-ink: var(--bright);
  --feedback-surface: rgba(201, 162, 74, 0.9);
  --feedback-shadow: 0 0 14px 3px rgba(201, 162, 74, 0.42);
  --fault-surface: rgba(166, 90, 60, 0.85);
  --fault-shadow: 0 0 14px 3px rgba(166, 90, 60, 0.38);
  --quiet-surface: rgba(150, 140, 110, 0.28);
  --quiet-shadow: 0 0 14px 3px rgba(150, 140, 110, 0.18);
  --latest-output-rule: rgba(59, 52, 46, 0.08);
  --open-control-shadow: 0 0 16px 3px rgba(86, 112, 75, 0.1);
  --control-hover-strong-surface: rgba(59, 52, 46, 0.12);
  --round-number-shadow: 0 0 12px 2px rgba(59, 52, 46, 0.05);
  --round-current-surface: rgba(59, 52, 46, 0.78);
  --round-current-shadow: 0 0 12px 2px rgba(59, 52, 46, 0.2);
  --interrupted: #9a7a2e;
  --code-surface: rgba(251, 247, 239, 0.45);
  --feed-boundary-surface: #f7f1e6;
  --font: "Alegreya Sans", Avenir, "Segoe UI", sans-serif;
  --font-size: 15px;
  --line-height: 1.5;
  --sun-opacity: 1;
  --sun-x: 50%;
}

html {
  color: var(--bright);
  background: var(--background);
  font-family: var(--font);
}

body {
  color: var(--bright);
  background: var(--sky-background);
  background-attachment: fixed;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: var(--sun-background);
  content: "";
  opacity: var(--sun-opacity);
}

body::after {
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .40 0 0 0 0 .34 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

::selection {
  color: var(--bright);
  background: var(--selection);
}

*:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.site-header {
  position: relative;
  z-index: 1;
  gap: 24px;
  padding: 18px 32px 14px;
  color: var(--dim);
  border-bottom-color: var(--header-rule);
}

.repository {
  gap: 16px;
  font-weight: 400;
}

.repository-link:hover,
.docs-link:hover {
  color: var(--bright);
  text-shadow: none;
}

.mark {
  width: 54px;
  opacity: 0.85;
  filter: drop-shadow(0 0 14px var(--mark-shadow));
}

.site-actions {
  gap: 18px;
}

.daemon-running,
.daemon-not-running {
  color: var(--dim);
}

.daemon::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: var(--daemon-running);
  border-radius: 50%;
  content: "";
}

.daemon-not-running::before {
  background: var(--amber);
}

.theme-switch {
  gap: 2px;
  padding: 2px;
  background: var(--control-surface);
  border: 0;
  border-radius: 9999px;
  box-shadow: var(--control-shadow);
}

.theme-choice {
  padding: 3px 12px;
  color: var(--dim);
  border-radius: 9999px;
  text-transform: none;
}

.theme-choice:hover {
  color: var(--bright);
  background: var(--control-hover-surface);
}

.theme-choice[aria-current="page"] {
  color: var(--bright);
  font-weight: 500;
  background: var(--control-current-surface);
}

.home-content,
.assignment-content,
.error-page {
  position: relative;
  z-index: 1;
  padding: 28px 32px 64px;
}

.instance {
  margin-bottom: 32px;
}

.refresh-error {
  position: relative;
  isolation: isolate;
  padding: 16px 22px;
  margin-bottom: 24px;
  color: var(--danger);
  background: transparent;
  border: 0;
  border-radius: 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 400;
}

.refresh-error::before,
.assignment-card::before,
.issue-row::before,
.failed-setup-row::before,
.assignment-feed::before {
  position: absolute;
  z-index: -1;
  inset: -6px;
  pointer-events: none;
  background: var(--panel-surface);
  border-radius: 40px;
  content: "";
  filter: blur(14px);
}

.refresh-error::before {
  background: var(--error-surface);
}

.facts,
.assignment-facts {
  row-gap: 6px;
  color: var(--dim);
}

.fact,
.assignment-facts > div {
  align-items: baseline;
  gap: 8px;
  padding-right: 16px;
  margin-right: 16px;
  border-right-color: var(--fact-rule);
  line-height: 1.2;
}

.fact dt,
.assignment-facts dt {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fact dd,
.assignment-facts dd {
  color: var(--bright);
  font-weight: 500;
}

.fact.warning dd {
  color: var(--danger);
}

.dashboard {
  gap: 32px;
}

.panel {
  padding: 0;
  border: 0;
}

.panel > h1 {
  position: static;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 0 10px;
  margin: 0 0 12px;
  color: var(--bright);
  background: transparent;
  border-bottom: 1px solid var(--rule-inner);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  text-shadow: none;
  text-transform: capitalize;
}

.panel-body {
  gap: 14px;
}

.assignment-group-label {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.14em;
}

.assignment-card,
.issue-row,
.failed-setup-row {
  position: relative;
  isolation: isolate;
  padding: 22px 26px;
  background: transparent;
  border: 0;
  border-radius: 28px;
}

.assignment-card.needs-feedback {
  background: transparent;
  border: 0;
}

.card-heading {
  gap: 14px;
}

.card-heading > :first-child {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.3;
}

.issue-number {
  color: var(--link);
  font-weight: 400;
  text-decoration: none;
}

.issue-number:hover,
.assignment-navigation:hover,
.assignment-issue:hover {
  color: var(--link-hover);
  text-shadow: none;
}

.title {
  color: var(--bright);
  font-weight: 400;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 12px;
  color: var(--dim);
  background: var(--control-surface);
  border-radius: 9999px;
  box-shadow: var(--chip-shadow);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.chip::before,
.latest-output > span::before,
.round-outcome::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: currentcolor;
  border-radius: 50%;
  content: "";
}

.chip::after,
.latest-output > span::after,
.feed-label::before,
.feed-label::after,
.round-outcome::after {
  content: none;
}

.status-working,
.issue-available {
  color: var(--status-on-color);
  background: var(--working-surface);
  box-shadow: var(--working-shadow);
  text-shadow: none;
}

.status-waiting {
  color: var(--waiting);
  background: var(--waiting-surface);
  box-shadow: var(--waiting-shadow);
}

.status-needs-user-feedback,
.status-routing-conflict,
.issue-routing-conflict {
  color: var(--feedback-ink);
  background: var(--feedback-surface);
  box-shadow: var(--feedback-shadow);
}

.status-fault {
  color: var(--status-on-color);
  background: var(--fault-surface);
  box-shadow: var(--fault-shadow);
}

.status-complete,
.status-cancelled,
.status-idle,
.status-unknown,
.issue-blocked {
  color: var(--dim);
  background: var(--quiet-surface);
  box-shadow: var(--quiet-shadow);
}

.assignment-detail,
.assignment-meta,
.labels,
.evidence {
  color: var(--dim);
}

.latest-output {
  padding-top: 8px;
  color: var(--bright);
  border-top: 1px solid var(--latest-output-rule);
  font-size: 14px;
}

.latest-output > span {
  display: inline;
  color: var(--waiting);
  font-weight: 500;
  text-transform: lowercase;
}

.latest-output > span::before {
  margin-right: 7px;
}

.card-heading-actions,
.assignment-heading-actions {
  align-items: center;
  gap: 10px;
}

.retry-control {
  padding: 6px 14px;
  border-radius: 9999px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: capitalize;
  color: var(--action);
  background: var(--action-surface);
  box-shadow: var(--action-shadow);
}

.retry-control:hover,
.retry-control:focus-visible {
  color: var(--action-hover);
  background: var(--action-hover-surface);
}

.pr-chip,
.assignment-open {
  color: var(--action);
  background: var(--action-surface);
  border: 0;
  box-shadow: var(--open-control-shadow);
}

.pr-chip {
  padding: 6px 16px;
  border-radius: 9999px;
  font-weight: 500;
}

.assignment-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--bright);
  background: var(--control-surface);
  border-radius: 50%;
  box-shadow: var(--control-shadow);
}

.pr-chip:hover,
.assignment-open:hover {
  color: var(--bright);
  background: var(--control-hover-strong-surface);
}

.ended-assignments summary,
.empty,
.assignment-navigation {
  color: var(--dim);
}

.failed-setup-row {
  color: var(--danger);
}

.assignment-content {
  gap: 24px;
}

.assignment-overview {
  gap: 14px;
}

.assignment-heading h1 {
  color: var(--bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.2;
}

.assignment-issue,
.assignment-issue span {
  color: inherit;
  font-weight: inherit;
}

.assignment-issue {
  color: var(--link);
}

.assignment-workspace {
  gap: 28px;
}

.assignment-sidebar {
  gap: 16px;
}

.assignment-rounds > h1,
.assignment-feed > h1 {
  font-size: 22px;
}

.round-link {
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 20px;
}

.round-link:hover,
.round-link[aria-current="true"] {
  background: var(--tint);
  border: 0;
}

.round-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--dim);
  background: var(--control-surface);
  border-radius: 50%;
  box-shadow: var(--round-number-shadow);
  font-size: 14px;
  font-weight: 500;
}

.round-link[aria-current="true"] .round-number {
  color: var(--status-on-color);
  background: var(--round-current-surface);
  box-shadow: var(--round-current-shadow);
}

.round-purpose,
.round-outcome {
  color: var(--bright);
  font-weight: 500;
}

.round-timing {
  color: var(--dim);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.round-outcome {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-size: 14px;
  text-transform: capitalize;
}

.outcome-running {
  color: var(--waiting);
}

.outcome-errored {
  color: var(--amber);
}

.outcome-interrupted {
  color: var(--interrupted);
}

.outcome-stopped {
  color: var(--danger);
}

.agent-work-foot {
  color: var(--dim);
  border-top-color: var(--rule);
}

.stop-control,
.cancel-control,
.manual-recovery summary {
  color: var(--danger);
}

.stop-control:hover,
.stop-control:focus-visible,
.cancel-control:hover,
.cancel-control:focus-visible,
.manual-recovery summary:hover,
.manual-recovery summary:focus-visible {
  color: var(--danger-hover);
}

.manual-recovery pre {
  color: var(--bright);
  background: var(--code-surface);
  border: 0;
  border-radius: 20px;
}

.assignment-feed {
  position: relative;
  isolation: isolate;
}

.assignment-feed::before {
  inset: 42px -6px -6px;
  background: var(--panel-strong-surface);
}

.feed-records {
  height: 52vh;
  min-height: 320px;
  padding: 6px 24px 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.feed-tail {
  top: 2px;
  color: var(--waiting);
  background: transparent;
  text-shadow: none;
}

.feed-line {
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 14px;
}

.feed-line time,
.feed-timestamp-missing {
  color: var(--faint);
}

.feed-label {
  color: var(--waiting);
  font-weight: 600;
  text-transform: lowercase;
}

.feed-detail {
  color: var(--bright);
}

.round-boundary {
  top: -6px;
  padding: 10px 0 8px;
  color: var(--dim);
  background: var(--feed-boundary-surface);
  border-bottom-color: var(--rule);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
}

@media (max-width: 700px) {
  .site-header,
  .home-content,
  .assignment-content,
  .error-page {
    padding-right: 20px;
    padding-left: 20px;
  }

  .site-actions {
    align-items: flex-start;
  }
}

@media (prefers-color-scheme: dark) {
  html[data-web-theme="nature"] {
    color-scheme: dark;
    --background: #1a1830;
    --bright: #ece6dc;
    --phosphor: #e9b183;
    --dim: rgba(236, 230, 220, 0.64);
    --faint: rgba(236, 230, 220, 0.56);
    --rule: rgba(236, 230, 220, 0.16);
    --rule-inner: rgba(236, 230, 220, 0.1);
    --tint: rgba(236, 230, 220, 0.05);
    --amber: #e9bf76;
    --shadow: 0 0 0 1px rgba(236, 230, 220, 0.06);
    --sky-background: radial-gradient(
        ellipse 120% 40% at 60% 112%,
        rgba(236, 140, 98, 0.2),
        transparent 70%
      ),
      radial-gradient(
        ellipse 85% 20% at var(--moon-x) 24%,
        rgba(236, 178, 160, 0.06),
        transparent 72%
      ),
      linear-gradient(
        180deg,
        #0f1128 0%,
        #1d1a36 42%,
        #33233d 78%,
        #4a2a3c 100%
      );
    --moon-background: radial-gradient(
      circle at var(--moon-x) 6%,
      rgba(250, 236, 214, 0.72) 0,
      rgba(250, 236, 214, 0.52) 1.2vmin,
      rgba(240, 204, 184, 0.2) 3vmin,
      rgba(230, 184, 172, 0.07) 12vmin,
      rgba(230, 184, 172, 0) 40vmin
    );
    --selection: #e9b183;
    --focus: #f3c9a3;
    --header-rule: rgba(236, 230, 220, 0.07);
    --mark-shadow: rgba(250, 236, 214, 0.3);
    --daemon-running: #a9c7a3;
    --control-surface: rgba(236, 230, 220, 0.06);
    --control-shadow: 0 0 12px 3px rgba(0, 0, 0, 0.16);
    --chip-shadow: 0 0 0 1px rgba(236, 230, 220, 0.06);
    --control-hover-surface: rgba(236, 230, 220, 0.1);
    --control-current-surface: rgba(236, 230, 220, 0.14);
    --danger: #e7977f;
    --danger-hover: #f5b8a8;
    --panel-surface: rgba(20, 18, 43, 0.62);
    --panel-strong-surface: rgba(20, 18, 43, 0.72);
    --error-surface: rgba(231, 151, 127, 0.12);
    --fact-rule: rgba(236, 230, 220, 0.12);
    --link-hover: #f3c9a3;
    --status-on-color: #16152a;
    --working-surface: rgba(169, 199, 163, 0.9);
    --working-shadow: 0 0 14px 3px rgba(169, 199, 163, 0.22);
    --action: #b3cba6;
    --action-hover: #d0e0c7;
    --action-surface: rgba(179, 203, 166, 0.1);
    --action-hover-surface: rgba(179, 203, 166, 0.18);
    --action-shadow: 0 0 14px 2px rgba(179, 203, 166, 0.08);
    --waiting: #b3cba6;
    --waiting-surface: rgba(179, 203, 166, 0.14);
    --waiting-shadow: 0 0 14px 3px rgba(179, 203, 166, 0.1);
    --feedback-ink: var(--status-on-color);
    --feedback-surface: rgba(233, 192, 110, 0.92);
    --feedback-shadow: 0 0 14px 3px rgba(233, 192, 110, 0.2);
    --fault-surface: rgba(231, 151, 127, 0.9);
    --fault-shadow: 0 0 14px 3px rgba(231, 151, 127, 0.18);
    --quiet-surface: rgba(236, 230, 220, 0.08);
    --quiet-shadow: 0 0 0 1px rgba(236, 230, 220, 0.04);
    --latest-output-rule: rgba(236, 230, 220, 0.07);
    --open-control-shadow: 0 0 0 1px rgba(179, 203, 166, 0.12);
    --control-hover-strong-surface: rgba(236, 230, 220, 0.12);
    --round-number-shadow: 0 0 0 1px rgba(236, 230, 220, 0.06);
    --round-current-surface: rgba(233, 177, 131, 0.9);
    --round-current-shadow: 0 0 14px 2px rgba(233, 177, 131, 0.18);
    --interrupted: #e9cb93;
    --code-surface: rgba(236, 230, 220, 0.055);
    --feed-boundary-surface: #1e1b34;
    --moon-opacity: 0;
    --moon-x: 50%;
  }

  html[data-web-theme="nature"] body::before {
    background: var(--moon-background);
    opacity: var(--moon-opacity);
  }

  html[data-web-theme="nature"] body::after {
    opacity: 0.22;
    mix-blend-mode: screen;
  }

  html[data-web-theme="nature"] ::selection {
    color: var(--background);
  }

  html[data-web-theme="nature"] .mark {
    filter: invert(0.92) sepia(0.2)
      drop-shadow(0 0 12px var(--mark-shadow));
  }

  html[data-web-theme="nature"] .refresh-error::before,
  html[data-web-theme="nature"] .assignment-card::before,
  html[data-web-theme="nature"] .issue-row::before,
  html[data-web-theme="nature"] .failed-setup-row::before,
  html[data-web-theme="nature"] .assignment-feed::before {
    backdrop-filter: blur(14px) saturate(1.2);
  }
}
