:root {
  --ink: #10201e;
  --ink-soft: #50605d;
  --night: #071916;
  --night-2: #0d2622;
  --paper: #f4f1e8;
  --paper-deep: #e9e4d8;
  --white: #fffef9;
  --line: #d8d3c7;
  --mint: #b9e5d1;
  --mint-strong: #59bb90;
  --gold: #f0c866;
  --coral: #e87f61;
  --danger: #c14f4f;
  --shadow: 0 16px 50px rgba(29, 45, 41, 0.09);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(240, 200, 102, 0.14), transparent 31rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--white);
}
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  width: 250px;
  flex-direction: column;
  padding: 28px 20px 22px;
  color: rgba(255, 255, 255, 0.76);
  background:
    radial-gradient(circle at 35% 4%, rgba(89, 187, 144, 0.16), transparent 25rem),
    var(--night);
}

.sidebar::after {
  position: absolute;
  right: 0;
  bottom: 8%;
  width: 1px;
  height: 42%;
  content: "";
  background: linear-gradient(transparent, rgba(240, 200, 102, 0.45), transparent);
}

.brand { display: flex; align-items: center; gap: 13px; color: #fff; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 16px; letter-spacing: -0.02em; }
.brand-copy small { margin-top: 5px; color: rgba(255,255,255,0.46); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.brand-mark { position: relative; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(240, 200, 102, 0.35); border-radius: 12px; background: rgba(255,255,255,0.04); }
.brand-mark i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 14px rgba(240,200,102,0.35); }
.brand-mark i:nth-child(1) { transform: translate(-8px, 5px); }
.brand-mark i:nth-child(2) { transform: translate(0, -6px); }
.brand-mark i:nth-child(3) { transform: translate(8px, 5px); }
.brand-mark::before, .brand-mark::after { position: absolute; top: 19px; width: 13px; height: 1px; content: ""; background: rgba(240, 200, 102, 0.65); }
.brand-mark::before { left: 7px; transform: rotate(-48deg); }
.brand-mark::after { right: 7px; transform: rotate(48deg); }

.side-nav { display: flex; flex: 1; flex-direction: column; gap: 7px; margin-top: 58px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 12px; font-size: 13px; transition: 180ms ease; }
.nav-item svg { width: 18px; height: 18px; color: rgba(255,255,255,0.48); }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.055); }
.nav-item.is-active { color: #fff; background: rgba(185,229,209,0.1); }
.nav-item.is-active::before { position: absolute; left: 0; width: 3px; height: 19px; content: ""; border-radius: 4px; background: var(--gold); }
.nav-item.is-active svg { color: var(--mint); }

.sidebar-foot { display: grid; gap: 18px; }
.mini-status { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid rgba(255,255,255,0.08); border-radius: 13px; background: rgba(255,255,255,0.035); }
.mini-status > span:last-child { display: flex; flex-direction: column; }
.mini-status strong { color: #fff; font-size: 11px; font-weight: 600; }
.mini-status small { margin-top: 2px; color: rgba(255,255,255,0.42); font-size: 10px; }
.status-orb { width: 9px; height: 9px; border: 2px solid rgba(255,255,255,0.25); border-radius: 50%; }
.status-orb.is-online { border: 0; background: var(--mint-strong); box-shadow: 0 0 0 4px rgba(89,187,144,0.12); }
.status-orb.is-offline { border: 0; background: var(--danger); box-shadow: 0 0 0 4px rgba(193,79,79,0.12); }
.github-link { display: flex; justify-content: space-between; padding: 0 4px; color: rgba(255,255,255,0.44); font-size: 11px; }
.github-link:hover { color: var(--gold); }

.main-content { margin-left: 250px; min-width: 0; }
.topbar { display: flex; height: 74px; align-items: center; justify-content: space-between; padding: 0 clamp(24px, 4vw, 64px); border-bottom: 1px solid rgba(16,32,30,0.1); }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 11px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint-strong); box-shadow: 0 0 0 4px rgba(89,187,144,0.13); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.model-pill { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,254,249,0.5); color: var(--ink); font-size: 11px; font-weight: 600; }
.model-pill span { margin-right: 5px; color: #87918f; font-weight: 450; }
.icon-button, .menu-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; }
.icon-button svg, .menu-button svg { width: 17px; height: 17px; }
.menu-button { display: none; }

.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: end; padding: 66px clamp(24px, 4vw, 64px) 42px; }
.section-kicker { margin: 0 0 14px; color: #7b8583; font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.intro h1 { max-width: 760px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 4.4vw, 66px); font-weight: 400; letter-spacing: -0.045em; line-height: 0.98; }
.intro h1 em { color: #477a68; font-weight: 400; }
.intro-copy { max-width: 690px; margin: 24px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.75; }
.health-card { display: flex; min-width: 250px; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,254,249,0.55); box-shadow: 0 8px 24px rgba(29,45,41,0.05); }
.health-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: #dfede4; }
.health-icon span { position: relative; width: 18px; height: 9px; border-bottom: 2px solid #3e906d; transform: skew(-25deg); }
.health-card > div:nth-child(2) { display: flex; flex: 1; flex-direction: column; }
.health-card span { color: #798482; font-size: 10px; }
.health-card strong { margin-top: 2px; font-size: 12px; }
.health-code { padding: 4px 7px; border-radius: 6px; background: var(--paper-deep); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.workspace-grid { display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(400px, 0.9fr); gap: 20px; padding: 0 clamp(24px, 4vw, 64px); }
.panel { min-width: 0; overflow: hidden; border: 1px solid rgba(16,32,30,0.12); border-radius: var(--radius); background: rgba(255,254,249,0.77); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 24px 26px; border-bottom: 1px solid rgba(16,32,30,0.09); }
.panel-heading > div, .result-toolbar > div { display: flex; align-items: center; gap: 12px; }
.panel-heading h2, .result-toolbar h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.panel-number { color: #8a938f; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.quiet-label { color: #929a98; font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; }

#task-form { padding: 20px 24px 24px; }
#task-input { width: 100%; min-height: 170px; resize: vertical; padding: 18px; border: 1px solid #d4d0c5; outline: none; border-radius: 16px; color: var(--ink); background: rgba(244,241,232,0.72); line-height: 1.7; transition: 160ms ease; }
#task-input::placeholder { color: #9aa19f; }
#task-input:focus { border-color: #76aa95; background: var(--white); box-shadow: 0 0 0 4px rgba(89,187,144,0.1); }
.composer-meta { display: flex; justify-content: space-between; margin: 9px 3px 18px; color: #959c9a; font-size: 9px; }
kbd { padding: 1px 4px; border: 1px solid #cec9be; border-bottom-width: 2px; border-radius: 4px; background: var(--white); font: inherit; color: #687370; }
.presets { display: flex; flex-wrap: wrap; gap: 7px; }
.presets button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: #596562; font-size: 10px; cursor: pointer; transition: 150ms ease; }
.presets button:hover { border-color: #91b9a8; color: #28674f; background: #edf7f1; }
.run-controls { display: flex; align-items: end; justify-content: space-between; margin-top: 24px; padding-top: 19px; border-top: 1px solid rgba(16,32,30,0.08); }
.repair-control { display: grid; gap: 6px; }
.repair-control label { color: #7c8683; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
.repair-control select { padding: 8px 30px 8px 10px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: var(--white); color: var(--ink); font-size: 11px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; cursor: pointer; transition: 170ms ease; }
.primary-button { min-width: 178px; padding: 12px 17px; border-radius: 12px; color: #fff; background: var(--night-2); box-shadow: 0 10px 24px rgba(7,25,22,0.16); font-size: 12px; font-weight: 650; }
.primary-button svg { width: 15px; height: 15px; fill: var(--gold); stroke: var(--gold); }
.primary-button:hover { transform: translateY(-1px); background: #12372f; }
.primary-button:disabled { cursor: wait; opacity: 0.65; transform: none; }

.topology-pill { padding: 5px 8px; border-radius: 999px; color: #2f7458; background: #e3f2e9; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; text-transform: uppercase; }
.graph-stage { position: relative; min-height: 326px; margin: 18px 20px 0; overflow: hidden; border: 1px solid #d8d7ce; border-radius: 17px; background: #eff0e8; }
.graph-grid { position: absolute; inset: 0; opacity: 0.36; background-image: linear-gradient(#ccd3ca 1px, transparent 1px), linear-gradient(90deg, #ccd3ca 1px, transparent 1px); background-size: 24px 24px; mask-image: linear-gradient(to bottom, black, transparent); }
.graph-route { position: absolute; z-index: 1; height: 1px; background: repeating-linear-gradient(90deg, #8ca69d 0 5px, transparent 5px 10px); transform-origin: left center; }
.route-one { top: 105px; left: 48%; width: 120px; transform: rotate(-31deg); }
.route-two { top: 105px; left: 48%; width: 120px; transform: rotate(31deg); }
.agent-node { position: absolute; z-index: 2; display: flex; width: 146px; align-items: center; gap: 9px; padding: 11px; border: 1px solid #cfd4cd; border-radius: 13px; background: rgba(255,254,249,0.93); box-shadow: 0 8px 20px rgba(37,56,50,0.08); transition: 220ms ease; }
.agent-node > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.agent-node small { color: #909995; font-size: 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.agent-node strong { margin-top: 2px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.agent-node > i { width: 6px; height: 6px; border-radius: 50%; background: #b7bfbb; }
.agent-node.is-ready > i { background: var(--mint-strong); }
.agent-node.is-active { border-color: #69ae90; transform: translateY(-3px); box-shadow: 0 10px 24px rgba(51,131,96,0.2), 0 0 0 3px rgba(89,187,144,0.11); }
.agent-node.is-active > i { background: var(--gold); box-shadow: 0 0 0 4px rgba(240,200,102,0.18); animation: pulse 1.2s infinite; }
.agent-node.is-complete > i { background: var(--mint-strong); }
.agent-icon { display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; border-radius: 9px; color: #477362; background: #e6efe9; }
.agent-icon svg { width: 16px; height: 16px; }
.node-meta { top: 42px; left: 50%; transform: translateX(-50%); }
.node-meta.is-active { transform: translate(-50%, -3px); }
.node-research { bottom: 51px; left: 28px; }
.node-builder { right: 28px; bottom: 51px; }
.node-critic { bottom: 51px; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; }
.node-critic.is-active, .node-critic.is-complete { transform: translate(-50%, -3px); opacity: 1; }
.phase-strip { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 21px 16px 22px; color: #8c9592; font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.phase-strip span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.phase-strip b { display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid #cbd0ca; border-radius: 50%; font-size: 8px; }
.phase-strip i { width: 16px; height: 1px; background: #d4d6d1; }
.phase-strip span.is-active { color: #2b6c52; font-weight: 700; }
.phase-strip span.is-active b { border-color: #6db090; background: #dff1e7; }

.result-section { padding: 42px clamp(24px, 4vw, 64px) 22px; }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.secondary-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,254,249,0.56); color: #5e6966; font-size: 10px; }
.secondary-button:hover { border-color: #a7b7b0; background: var(--white); }
.secondary-button svg { width: 14px; height: 14px; }
.result-grid { display: grid; grid-template-columns: minmax(270px, 0.72fr) minmax(420px, 1.28fr); min-height: 360px; overflow: hidden; border: 1px solid rgba(16,32,30,0.12); border-radius: var(--radius); background: rgba(255,254,249,0.72); box-shadow: var(--shadow); }
.runs-card { min-width: 0; border-right: 1px solid rgba(16,32,30,0.1); }
.runs-head { display: flex; align-items: center; justify-content: space-between; padding: 19px 20px; border-bottom: 1px solid rgba(16,32,30,0.09); color: #747f7c; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.runs-head span:last-child { color: #9ba29f; font-weight: 500; }
.runs-list { max-height: 360px; overflow-y: auto; }
.empty-runs, .output-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-runs { min-height: 265px; padding: 30px; }
.empty-icon { display: grid; width: 42px; height: 42px; margin-bottom: 13px; place-items: center; border-radius: 50%; color: #8c9894; background: var(--paper-deep); }
.empty-icon svg { width: 17px; height: 17px; }
.empty-runs strong { font-size: 12px; }
.empty-runs p { margin: 4px 0 0; color: #8f9795; font-size: 10px; }
.run-item { display: block; width: 100%; padding: 15px 18px; border: 0; border-bottom: 1px solid rgba(16,32,30,0.07); text-align: left; background: transparent; cursor: pointer; }
.run-item:hover, .run-item.is-selected { background: rgba(223,239,228,0.6); }
.run-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.run-item-title { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.run-item-id { color: #99a19e; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; }
.status-chip, .run-state { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; color: #73570e; background: #f5e8bd; font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.status-chip.completed, .run-state.completed { color: #236449; background: #dff1e7; }
.status-chip.failed, .run-state.failed { color: #8e3535; background: #f7dfda; }
.output-card { min-width: 0; background: rgba(255,254,249,0.35); }
.output-empty { min-height: 360px; max-width: 510px; margin: auto; padding: 46px; }
.output-emblem { position: relative; display: block; width: 76px; height: 60px; margin-bottom: 20px; }
.output-emblem i { position: absolute; top: 19px; width: 20px; height: 20px; border: 1px solid #8eb4a4; border-radius: 50%; background: #eef5f0; }
.output-emblem i:nth-child(1) { left: 4px; }
.output-emblem i:nth-child(2) { left: 28px; top: 3px; border-color: #caa744; background: #fbf1d3; }
.output-emblem i:nth-child(3) { right: 4px; }
.output-emblem::before, .output-emblem::after { position: absolute; top: 26px; z-index: -1; width: 27px; height: 1px; content: ""; background: #b7c4bd; }
.output-emblem::before { left: 18px; transform: rotate(-34deg); }
.output-emblem::after { right: 18px; transform: rotate(34deg); }
.output-empty h3 { max-width: 430px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 23px; font-weight: 400; line-height: 1.25; }
.output-empty > p:last-child { max-width: 440px; margin: 13px 0 0; color: #78827f; font-size: 11px; line-height: 1.7; }
.output-content { padding: 25px 27px 30px; }
.output-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.output-head h3 { margin: 10px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; }
.task-id { color: #8d9793; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.metrics-row { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: rgba(244,241,232,0.5); }
.metrics-row > div { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; }
.metrics-row > div + div { border-left: 1px solid var(--line); }
.metrics-row span { color: #8a9390; font-size: 8px; text-transform: uppercase; letter-spacing: 0.1em; }
.metrics-row strong { font-size: 13px; }
.result-copy { max-height: 310px; overflow: auto; padding-right: 8px; color: #35433f; font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.result-copy.is-placeholder { color: #7d8885; }
.result-copy h4 { margin: 18px 0 6px; color: var(--ink); font-size: 13px; }

.site-footer { display: flex; justify-content: space-between; padding: 29px clamp(24px, 4vw, 64px) 35px; color: #89928f; font-size: 9px; letter-spacing: 0.05em; }
.site-footer b { padding: 2px 5px; border-radius: 4px; color: #477362; background: #dfede4; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 15px; transform: translateY(30px); border: 1px solid rgba(255,255,255,0.1); border-radius: 11px; color: #fff; background: var(--night-2); box-shadow: 0 14px 40px rgba(7,25,22,0.22); font-size: 11px; opacity: 0; pointer-events: none; transition: 220ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { background: #712f2f; }

@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(240,200,102,0); } }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .graph-stage { min-height: 310px; }
  .intro { align-items: start; }
  .health-card { margin-top: 6px; }
}

@media (max-width: 840px) {
  .sidebar { transform: translateX(-100%); transition: 220ms ease; }
  .sidebar.is-open { transform: translateX(0); box-shadow: 18px 0 50px rgba(7,25,22,0.23); }
  .main-content { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { gap: 14px; }
  .eyebrow { flex: 1; }
  .intro { grid-template-columns: 1fr; padding-top: 44px; }
  .health-card { max-width: 300px; }
  .result-grid { grid-template-columns: 1fr; }
  .runs-card { border-right: 0; border-bottom: 1px solid rgba(16,32,30,0.1); }
  .runs-list { max-height: 230px; }
  .empty-runs { min-height: 180px; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding-inline: 17px; }
  .model-pill { display: none; }
  .intro { gap: 24px; padding: 35px 17px 30px; }
  .intro h1 { font-size: 39px; }
  .workspace-grid, .result-section { padding-inline: 12px; }
  .panel-heading { padding: 19px; }
  .quiet-label { display: none; }
  #task-form { padding: 15px; }
  .run-controls { align-items: stretch; flex-direction: column; gap: 14px; }
  .repair-control select, .primary-button { width: 100%; }
  .graph-stage { min-height: 350px; margin-inline: 12px; }
  .node-research { bottom: 48px; left: 12px; }
  .node-builder { right: 12px; bottom: 48px; }
  .agent-node { width: 132px; }
  .phase-strip { gap: 4px; }
  .phase-strip span { font-size: 0; }
  .phase-strip b { font-size: 8px; }
  .phase-strip i { width: 22px; }
  .result-section { padding-top: 32px; }
  .result-toolbar { padding-inline: 7px; }
  .output-content { padding: 20px 17px; }
  .output-head { flex-direction: column; gap: 8px; }
  .output-empty { padding: 36px 22px; }
  .metrics-row > div { padding: 10px; }
  .site-footer { align-items: center; flex-direction: column; gap: 8px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
