:root {
  color-scheme: light;
  --ink: #172522;
  --muted: #65736e;
  --line: #dce4de;
  --canvas: #f2f4ef;
  --surface: #fff;
  --pine: #183b35;
  --pine-dark: #152a29;
  --lime: #d9f27a;
  --green: #276449;
  --red: #a13f37;
  --amber: #8e641c;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

button, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.shell { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }

.masthead { background: var(--pine-dark); color: #f7faf4; }
.masthead-inner { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: var(--lime); color: #20352e; font-size: 14px; font-weight: 800; letter-spacing: -.05em; }
.brand-copy .eyebrow { color: #acc2b7; margin-bottom: 1px; }
.brand-copy h1 { margin: 0; color: #fff; font-size: 19px; font-weight: 660; letter-spacing: -.025em; line-height: 1.25; }
.masthead-actions { display: flex; align-items: center; gap: 10px; }
.signout-button { min-height: 40px; padding: 0 12px; border: 1px solid #536c65; border-radius: 8px; background: transparent; color: #f7faf4; cursor: pointer; font-size: 12px; font-weight: 650; }
.signout-button:hover { background: #263e39; }

.eyebrow { margin: 0; color: #75827b; font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.connection { display: flex; align-items: center; gap: 9px; max-width: 48%; padding: 8px 12px; border: 1px solid #38514b; border-radius: 999px; color: #e0e9e2; font-size: 12px; line-height: 1.3; text-align: right; overflow-wrap: anywhere; }
.connection::before { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #e6bd66; content: ""; }
.connection.is-online::before { background: #a7df7b; }
.connection.is-error::before { background: #f08073; }

main { padding-bottom: 48px; }
.login-panel { width: min(100%, 480px); margin: 64px auto; padding: 26px; }
.login-panel h2 { margin: 7px 0 5px; font-size: 24px; font-weight: 670; letter-spacing: -.035em; }
.login-description { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-panel label { display: block; margin-bottom: 7px; color: #31433c; font-size: 13px; font-weight: 680; }
.login-panel input { width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid #c6d1c9; border-radius: 8px; background: #fbfcf9; color: var(--ink); font: inherit; }
.login-panel .primary-button { width: 100%; margin-top: 13px; justify-content: center; }
.login-panel .form-message { min-height: 20px; }
.intro { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(250px, .7fr); align-items: end; gap: 42px; margin: 38px 0 28px; }
.intro-kicker { color: #53645d; }
.intro h2 { margin: 9px 0 10px; font-size: clamp(30px, 4vw, 42px); font-weight: 650; letter-spacing: -.045em; line-height: 1.08; }
.intro > div:first-child > p:last-child { max-width: 620px; margin: 0; color: var(--muted); font-size: 15px; }
.guardrail { display: flex; align-items: flex-start; gap: 12px; padding: 3px 0 3px 16px; border-left: 2px solid #9bbd72; }
.guardrail-mark { width: 28px; height: 28px; display: grid; flex: 0 0 28px; place-items: center; border-radius: 50%; background: #e7f1d7; color: #365b37; font-weight: 800; }
.guardrail p { display: grid; gap: 2px; margin: 0; font-size: 13px; }
.guardrail p strong { color: #314b3b; font-size: 14px; }
.guardrail p span { color: var(--muted); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(275px, .65fr); grid-template-areas: "compose agents" "jobs agents"; align-items: start; gap: 18px; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 8px 24px rgb(22 43 33 / 4%); }
.compose-panel { grid-area: compose; }
.agents-panel { grid-area: agents; }
.jobs-panel { grid-area: jobs; }
.panel-heading { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 0; font-size: 17px; font-weight: 660; letter-spacing: -.02em; line-height: 1.25; }
.panel-aside { color: #87938d; font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }

.compose-form { padding: 20px; }
.field-group label, .provider-select label { display: block; margin: 0 0 7px; color: #31433c; font-size: 13px; font-weight: 680; }
textarea, select { width: 100%; border: 1px solid #c6d1c9; border-radius: 8px; background: #fbfcf9; color: var(--ink); }
textarea { min-height: 148px; padding: 12px 13px; resize: vertical; font-size: 16px; line-height: 1.55; }
textarea::placeholder { color: #89968f; opacity: 1; }
select { min-height: 48px; padding: 0 34px 0 12px; font-size: 14px; }
.field-hint { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.form-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; margin-top: 17px; }
.form-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.primary-button, .refresh-button, .job-action { min-height: 44px; border-radius: 8px; cursor: pointer; font-weight: 680; }
.primary-button { display: flex; min-width: 148px; align-items: center; justify-content: space-between; gap: 18px; padding: 0 15px; border: 1px solid var(--lime); background: var(--lime); color: #21362e; transition: background-color .15s ease, border-color .15s ease; }
.primary-button:hover { border-color: #c9e669; background: #c9e669; }
button:disabled { opacity: .62; cursor: wait; }
.form-message { min-height: 22px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.form-message.is-success { color: var(--green); }
.form-message.is-error { color: var(--red); }

.providers { padding: 3px 20px 0; }
.provider { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 12px; padding: 13px 0; border-bottom: 1px solid #e8ede9; }
.provider:last-child { border-bottom: 0; }
.provider-name { min-width: 0; font-size: 14px; font-weight: 670; }
.provider-quota { grid-column: 1 / -1; color: var(--muted); font-size: 11px; line-height: 1.45; }
.agent-state { display: inline-flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 7px; color: var(--muted); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.agent-state::before { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #94a19a; content: ""; }
.agent-state.is-ready { color: var(--green); }
.agent-state.is-ready::before { background: #4c9a6a; }
.agent-state.is-cooling { color: var(--amber); }
.agent-state.is-cooling::before { background: #d1a546; }
.agent-state.is-needed { color: var(--red); }
.agent-state.is-needed::before { background: #c55e51; }
.panel-footnote, .jobs-footnote { margin: 0; padding: 12px 20px 15px; color: var(--muted); font-size: 11px; }
.panel-footnote { border-top: 1px solid #edf0ed; }

.jobs-heading { align-items: center; }
.panel-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.refresh-button { min-width: 82px; padding: 0 12px; border: 1px solid #cbd5ce; background: #fff; color: #30443a; font-size: 12px; }
.refresh-button:hover, .job-action:hover { background: #f1f5f0; }
.jobs-list { padding: 0 20px; }
.jobs-footnote { border-top: 1px solid #edf0ed; }
.loading-state, .empty-state { margin: 0; padding: 22px 0; color: var(--muted); font-size: 13px; }
.empty-state { padding: 26px 0 28px; }
.empty-state strong { display: block; margin-bottom: 3px; color: #32463b; font-size: 14px; }
.empty-state.is-error { color: var(--red); }

.job { padding: 17px 0 18px; border-bottom: 1px solid #e7ece8; }
.job:last-child { border-bottom: 0; }
.job-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge { display: inline-flex; min-height: 25px; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: #edf0ec; color: #58645e; font-size: 11px; font-weight: 720; line-height: 1.2; text-transform: capitalize; white-space: nowrap; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge.running { background: #e5f2e9; color: #286749; }
.badge.completed { background: #e5f2e9; color: #286749; }
.badge.failed { background: #f9e9e6; color: #a13f37; }
.badge.waiting_quota, .badge.waiting_auth { background: #f7f0df; color: #805d1e; }
.badge.classifying, .badge.verifying { background: #e7edf8; color: #3d5c88; }
.badge.waiting_children { background: #e9eaf6; color: #535181; }
.job-meta { max-width: 100%; color: var(--muted); font-size: 11px; text-align: right; overflow-wrap: anywhere; }
.job-prompt-button { display: block; width: 100%; margin: 8px 0 0; padding: 0; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 560; line-height: 1.55; text-align: left; overflow-wrap: anywhere; }
.job-prompt-button:hover { color: #315f50; }
.job-prompt-button:focus-visible { outline-offset: 4px; }
.job-prompt-button::after { display: inline-block; margin-left: 7px; color: #73867a; content: "View result ↗"; font-size: 11px; font-weight: 600; white-space: nowrap; }
.job-prompt-button[aria-expanded="true"]::after { content: "Close result ↑"; }
.job-facts { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 8px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.job-facts span { max-width: 100%; overflow-wrap: anywhere; }
.classification-plan { display: grid; gap: 6px; margin-top: 10px; padding: 10px 12px; border: 1px solid #dce8dd; border-radius: 8px; background: #f5f8f4; color: #41584b; font-size: 12px; }
.classification-plan p { margin: 0; color: var(--muted); line-height: 1.5; }
.scope-chip { width: fit-content; max-width: 100%; padding: 4px 8px; border-radius: 999px; background: #e6eee4; overflow-wrap: anywhere; }
.job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.job-action { min-height: 40px; padding: 0 11px; border: 1px solid #cbd5ce; background: #fff; color: #34473e; font-size: 12px; }
.job-action.cancel { color: var(--red); }
.action-feedback { color: var(--red); font-size: 12px; }
.job-result { margin-top: 13px; padding: 14px; border: 1px solid #e0e8e1; border-radius: 9px; background: #f8faf7; }
.job-result[hidden] { display: none; }
.job-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.job-result h3 { margin: 0; color: #34493e; font-size: 13px; font-weight: 720; }
.job-result-tools { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 9px; }
.job-result-views { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid #dce4de; border-radius: 9px; background: #f5f7f3; }
.job-view-button { min-height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: #53645d; cursor: pointer; font-size: 11px; font-weight: 680; white-space: nowrap; }
.job-view-button.is-active { background: #fff; color: #203d32; box-shadow: 0 1px 3px rgb(22 43 33 / 12%); }
.job-view-button:disabled { opacity: .5; cursor: not-allowed; }
.job-copy-button { min-height: 38px; padding: 0 11px; border: 1px solid #cbd5ce; border-radius: 7px; background: #fff; color: #30443a; cursor: pointer; font-size: 12px; font-weight: 680; white-space: nowrap; }
.job-copy-button:hover:not(:disabled) { background: #f1f5f0; }
.copy-feedback { color: var(--green); font-size: 11px; }
.job-result-summary { margin: 0 0 12px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.job-result pre { max-height: min(65vh, 720px); margin: 0; padding: 14px; border-radius: 7px; background: #17231f; color: #e0e9e2; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; -webkit-overflow-scrolling: touch; }
.job-result pre:focus-visible { outline: 3px solid #84ab72; outline-offset: 2px; }

:focus-visible { outline: 3px solid #56816b; outline-offset: 2px; }

@media (max-width: 780px) {
  .shell { width: min(100% - 36px, 620px); }
  .masthead-inner { min-height: 72px; }
  .intro { grid-template-columns: 1fr; gap: 18px; margin: 30px 0 22px; }
  .intro h2 { font-size: clamp(30px, 7vw, 38px); }
  .guardrail { max-width: 520px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "compose" "agents" "jobs"; gap: 14px; }
}

@media (max-width: 480px) {
  .shell { width: calc(100% - 28px); }
  .masthead-inner { min-height: 68px; gap: 10px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 9px; font-size: 12px; }
  .brand-copy .eyebrow { font-size: 9px; }
  .brand-copy h1 { font-size: 17px; }
  .masthead-actions { gap: 6px; }
  .signout-button { min-height: 40px; padding: 0 8px; font-size: 11px; }
  .connection { max-width: 46%; gap: 6px; padding: 7px 9px; font-size: 10px; }
  .connection::before { width: 6px; height: 6px; flex-basis: 6px; }
  .intro { gap: 16px; margin: 25px 0 19px; }
  .login-panel { margin: 36px auto; padding: 20px 17px; }
  .intro h2 { margin-top: 7px; font-size: 31px; }
  .intro > div:first-child > p:last-child { font-size: 14px; }
  .panel { border-radius: 11px; }
  .panel-heading { min-height: 64px; padding: 13px 15px; }
  .panel-heading h2 { font-size: 16px; }
  .compose-form { padding: 16px 15px 14px; }
  textarea { min-height: 138px; }
  .form-footer { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 14px; }
  .form-options { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  select { font-size: 16px; }
  .primary-button { width: 100%; min-height: 48px; }
  .providers { padding-inline: 15px; }
  .provider { align-items: flex-start; flex-direction: column; gap: 5px; padding: 12px 0; }
  .agent-state { justify-content: flex-start; text-align: left; }
  .panel-footnote, .jobs-footnote { padding: 10px 15px 12px; }
  .panel-subtitle { max-width: 250px; line-height: 1.4; }
  .refresh-button { min-width: 76px; min-height: 44px; }
  .jobs-list { padding-inline: 15px; }
  .job { padding-block: 15px; }
  .job-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .job-meta { text-align: left; }
  .job-prompt-button { font-size: 14px; }
  .job-prompt-button::after { display: block; margin: 4px 0 0; }
  .job-result { padding: 11px; }
  .job-result-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .job-result-tools { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .job-view-button, .job-copy-button { min-height: 44px; }
  .job-result pre { max-height: min(62vh, 620px); font-size: 12px; line-height: 1.6; }
  .job-action { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
