:root {
  color-scheme: dark;
  --bg: #171819;
  --rail: #1d1e20;
  --card: #222426;
  --field: #1b1c1e;
  --line: #393c3e;
  --text: #f0efec;
  --muted: #a5a7a6;
  --accent: #f38a68;
  --accent-bright: #ff9b7b;
  --danger: #f79890;
  --green: #95d1a4;
  --radius: 12px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; }
button { min-height: 40px; padding: .53rem .84rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; font-size: .875rem; font-weight: 650; }
button:hover { background: #2b2e30; }
button:disabled { cursor: default; opacity: .55; }
button.primary { color: #22140e; background: var(--accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-bright); }
button.quiet { background: transparent; }
button.quiet:hover { background: var(--card); }
button.danger-outline { color: var(--danger); }
button.primary span { margin-left: .25rem; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.48rem, 2.6vw, 1.95rem); font-weight: 710; letter-spacing: -.04em; }
h2 { font-size: 1rem; font-weight: 680; margin-bottom: 1rem; }
h3 { font-size: .95rem; font-weight: 680; }
label { display: block; font-size: .85rem; font-weight: 650; margin-bottom: .45rem; }
input, textarea, select { display: block; width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .68rem .75rem; font-size: 1rem; }
textarea { resize: vertical; min-height: 98px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); }

.brand { display: flex; align-items: center; gap: .7rem; width: max-content; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; aspect-ratio: 1; border-radius: 9px; background: var(--accent); color: #24160e; font-size: 1rem; font-weight: 760; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .65rem; padding: .7rem clamp(.8rem, 3vw, 2rem); min-height: 64px; border-bottom: 1px solid var(--line); background: var(--rail); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; }
.runtime-health { color: var(--muted); text-align: right; font-size: .77rem; }
.runtime-health[data-state="healthy"]::before { content: ""; display: inline-block; width: .43rem; aspect-ratio: 1; border-radius: 50%; background: var(--green); margin-right: .35rem; vertical-align: .07rem; }
.workspace { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.navigation { display: flex; align-items: stretch; flex-direction: column; gap: .2rem; padding: 1.1rem .8rem; border-right: 1px solid var(--line); background: var(--rail); }
.navigation button { justify-self: start; color: var(--muted); text-align: left; background: transparent; border-color: transparent; white-space: nowrap; }
.navigation button:hover { color: var(--text); background: var(--card); }
.navigation button[aria-current="page"] { color: var(--accent); background: #312723; }
.content { width: 100%; max-width: 1220px; padding: clamp(1rem, 3vw, 2.2rem); margin-inline: auto; }
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.card { min-width: 0; padding: clamp(.9rem, 2.4vw, 1.35rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.compose-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: .7rem; margin-top: .85rem; }
.context-field { width: min(310px, 68%); }
.context-field select { text-overflow: ellipsis; }
.compose-actions > button { flex-shrink: 0; }
.work-grid { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); gap: .75rem; align-items: start; margin-top: .8rem; }
.task-list, .worker-list { display: grid; gap: .68rem; }
.worker-list { margin-top: .75rem; }
.task-button { background: var(--field); text-align: left; display: grid; gap: .42rem; padding: .68rem .75rem; overflow-wrap: anywhere; }
.task-button[aria-pressed="true"] { border-color: var(--accent); }
.task-button .task-title { font-size: .89rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta, .row-header, .button-group, .detail-metadata { display: flex; flex-wrap: wrap; gap: .45rem .65rem; align-items: center; }
.row-header { justify-content: space-between; margin-bottom: .5rem; }
.badge { display: inline-block; width: max-content; border-radius: 999px; padding: .13rem .5rem; background: #303336; color: var(--muted); font-size: .75rem; font-weight: 650; line-height: 1.35; }
.badge[data-tone="good"] { background: #28392e; color: var(--green); }
.badge[data-tone="attention"] { background: #45302a; color: var(--accent-bright); }
.badge[data-tone="bad"] { background: #422b2c; color: var(--danger); }
.muted, time { color: var(--muted); font-size: .82rem; }
.error { color: var(--danger); border: 1px solid #6a3b3b; background: #322425; padding: .62rem .75rem; margin-top: .65rem; border-radius: 7px; font-size: .86rem; overflow-wrap: anywhere; }
#app-error { margin: 0 0 .75rem; }
.task-goal, .artifact-body, .detail-value { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.task-goal { margin: .45rem 0 .65rem; }
.detail-block { display: grid; gap: .5rem; margin-top: 1rem; }
.structured { margin: 0; border-radius: 8px; background: var(--field); padding: .75rem; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; font: .81rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.detail-block ol { margin: 0; padding-left: 1.25rem; }
.detail-block li + li { margin-top: .35rem; }
.report-data { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1rem; margin: 0; font-size: .86rem; }
.report-data dt { color: var(--muted); }
.report-data dd { margin: 0; overflow-wrap: anywhere; }
.source-ref { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.entry { display: grid; gap: .32rem; padding: .69rem 0; overflow-wrap: anywhere; }
.entry:first-child { padding-top: 0; }
.entry:last-child { padding-bottom: 0; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry .row-header { margin-bottom: 0; }
.worker-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: .65rem; align-items: end; }
.worker-card { display: grid; gap: .65rem; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.25rem; }
.login-card { width: min(100%, 410px); padding: clamp(1.2rem, 5vw, 2rem); border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.login-card h1 { margin-top: 1.55rem; }
.login-card form { margin-top: 1.15rem; }
.login-card button { width: 100%; margin-top: .9rem; }

@media (max-width: 820px) {
  .workspace { display: block; }
  .navigation { flex-direction: row; gap: .13rem; overflow: auto; padding: .35rem .55rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .navigation button { min-height: 42px; }
}

@media (max-width: 560px) {
  button { min-height: 44px; }
  .topbar { min-height: 60px; }
  .top-actions { gap: .35rem; }
  .brand { gap: .45rem; }
  .brand-mark { width: 30px; }
  .navigation button { padding-inline: .63rem; }
  .content { padding: .8rem; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .worker-form { grid-template-columns: minmax(0, 1fr); }
  .runtime-health { max-width: 105px; }
  .compose-actions { flex-wrap: wrap; }
  .context-field { width: 100%; }
  .compose-actions > button { margin-left: auto; }
}
