/* agentbox gateway — organic "fir" theme. One file, no build step.
   Deep forest greens on warm off-white, one amber accent; soft shapes.
   Every text/background pair below is WCAG AA (>= 4.5:1) in both schemes;
   ui_test.go recomputes the ratios from these variables. */
:root {
  color-scheme: light dark;
  --bg: #f6f1e6; --surface: #fffcf5; --sunken: #ede6d6; --line: #e0d7c2;
  --fg: #1d2b21; --mute: #535e4f;
  --acc: #24603b; --onacc: #ffffff; --acc-soft: #e1ecdc;
  --amber: #8f4c05; --amber-soft: #f8e7cc;
  --ok: #24603b; --ok-soft: #e1ecdc;
  --warn: #975000; --warn-soft: #f8e7cc;
  --bad: #b42318; --bad-soft: #fbe5e0;
  --focus: #8f4c05;
  --blob1: #9cc79f; --blob2: #f2c27c; --blob3: #6f9f7d;
  --glow: 0 2px 6px rgb(40 60 30 / .06), 0 14px 40px -12px rgb(40 70 35 / .22);
  --s0: 4px; --s1: 8px; --s2: 16px; --s3: 24px; --s4: 40px; --s5: 64px;
  --r: 32px; --r-sm: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a13; --surface: #15251b; --sunken: #1d3125; --line: #2a4233;
    --fg: #ecf1e7; --mute: #a7b8a6;
    --acc: #93d3a2; --onacc: #0e1a13; --acc-soft: #1c3826;
    --amber: #f3b866; --amber-soft: #352816;
    --ok: #93d3a2; --ok-soft: #1c3826;
    --warn: #f3b866; --warn-soft: #352816;
    --bad: #ff9d90; --bad-soft: #3a201d;
    --focus: #f3b866;
    --blob1: #1f5a35; --blob2: #6b4512; --blob3: #17402a;
    --glow: 0 2px 6px rgb(0 0 0 / .3), 0 18px 48px -14px rgb(0 0 0 / .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg); font: 16.5px/1.6 var(--font); overflow-x: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--s2); }
.mute { color: var(--mute); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

a, a:visited { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 12px; }
.skip { position: absolute; left: -999px; top: var(--s1); z-index: 50; background: var(--surface); padding: var(--s1) var(--s2); border-radius: 999px; }
.skip:focus { left: var(--s1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

code { font: .875em var(--mono); background: var(--sunken); padding: 2px 8px; border-radius: 999px; overflow-wrap: anywhere; }
pre { background: var(--sunken); padding: var(--s2) var(--s3); border-radius: var(--r-sm); overflow: auto; margin: 0 0 var(--s2); font: .8125rem/1.55 var(--mono); }
pre code { background: none; padding: 0; border-radius: 0; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Living background: a few soft, blurred blobs ---- */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blobs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; animation: drift 28s ease-in-out infinite alternate; }
.blobs .b1 { width: 46vmax; height: 40vmax; left: -14vmax; top: -12vmax; background: var(--blob1); }
.blobs .b2 { width: 30vmax; height: 28vmax; right: -10vmax; top: 30vh; background: var(--blob2); opacity: .4; animation-duration: 34s; }
.blobs .b3 { width: 40vmax; height: 34vmax; left: 20vw; bottom: -22vmax; background: var(--blob3); opacity: .35; animation-duration: 40s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(3vmax, 2vmax) scale(1.08); } }

/* ---- Shell: brand + account float top; nav is a floating pill ---- */
.top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: var(--s2) var(--s3); }
.brand, .brand:visited { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 800; font-size: 1.125rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 36px; height: 36px; border-radius: 50% 50% 50% 18%; background: linear-gradient(140deg, var(--acc), var(--blob3)); color: var(--onacc);
  display: grid; place-items: center; box-shadow: var(--glow); }
.brand .logo .icon { width: 20px; height: 20px; stroke-width: 2.1; }

.account { position: relative; z-index: 30; }
.account > summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account > summary::-webkit-details-marker { display: none; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--amber-soft); color: var(--amber); display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; text-transform: uppercase; box-shadow: var(--glow); transition: transform .2s; }
.account > summary:hover .avatar { transform: scale(1.06); }
.menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 16rem; background: var(--surface); border-radius: 24px; box-shadow: var(--glow); padding: var(--s1); }
.menu p { padding: var(--s1) 12px; margin: 0 0 var(--s0); overflow-wrap: anywhere; }
.menu a, .menu a:visited { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border-radius: 999px; color: var(--fg); }
.menu a:hover { background: var(--sunken); text-decoration: none; }

.pill { position: fixed; z-index: 20; top: var(--s2); left: 50%; transform: translateX(-50%); padding: 6px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 999px; box-shadow: var(--glow); }
.pill ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.pill a, .pill a:visited { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px 6px 6px; border-radius: 999px; color: var(--mute);
  font-weight: 600; font-size: .875rem; transition: background .2s, color .2s; }
.pill .ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; transition: background .2s; }
.pill a:hover { color: var(--fg); text-decoration: none; }
.pill a:hover .ico { background: var(--sunken); }
.pill a[aria-current="page"] { color: var(--acc); background: var(--acc-soft); }
.pill a[aria-current="page"] .ico { background: var(--acc); color: var(--onacc); }

.flow { max-width: 760px; margin: 0 auto; padding: 132px var(--s3) var(--s5); }
.pagehead { margin: 0 0 var(--s4); text-align: center; }
.pagehead p { margin: 12px auto 0; color: var(--mute); max-width: 36rem; }

@media (max-width: 1040px) {
  .pill .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pill a, .pill a:visited { padding: 6px; }
  .pill a[aria-current="page"] { padding-right: 14px; }
  .pill a[aria-current="page"] .lbl { position: static; width: auto; height: auto; clip-path: none; }
}
@media (max-width: 680px) {
  .top { padding: 12px var(--s2); }
  .pill { top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: 420px; }
  .pill ul { justify-content: space-between; }
  .pill a, .pill a:visited, .pill a[aria-current="page"] { padding: 4px; }
  .pill a[aria-current="page"] .lbl { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
  .pill .ico { width: 36px; height: 36px; }
  .flow { padding: 84px var(--s2) calc(110px + env(safe-area-inset-bottom)); }
  .pagehead { margin-bottom: var(--s3); }
}

/* ---- Home: the agent as a living centre ---- */
.garden { margin: calc(-1 * var(--s3)) auto var(--s3); text-align: center; }
.tree { width: 100%; max-width: 640px; height: auto; overflow: visible; display: block; margin: 0 auto; font-family: var(--font); }
.stem { fill: none; stroke: var(--acc); stroke-width: 2; stroke-linecap: round; opacity: .45; }
.stem.share { stroke: var(--amber); stroke-dasharray: 2 7; opacity: .7; }
.stem.seed { opacity: .28; }
.tree .s0 { stop-color: var(--blob1); stop-opacity: .9; }
.tree .s1 { stop-color: var(--blob1); stop-opacity: 0; }
.core .blob { fill: var(--acc); }
.core.warn .blob { fill: var(--amber); }
.core.bad .blob { fill: var(--bad); }
.core:not(.ok):not(.warn):not(.bad) .blob { fill: var(--mute); }
.core text { text-anchor: middle; fill: var(--onacc); }
.core:not(.ok) text { fill: var(--surface); }
.core-id { font-size: 22px; font-weight: 800; }
.core-state { font-size: 14px; font-weight: 600; opacity: .9; }
.core-count { font-size: 12px; }
.breath { transform-box: fill-box; transform-origin: center; }
.core.ok .breath { animation: breathe 5.5s ease-in-out infinite; }
.core.warn .breath { animation: breathe 2.4s ease-in-out infinite; }
.core.ok .halo, .core.warn .halo { transform-box: fill-box; transform-origin: center; animation: glow 5.5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.06) rotate(4deg); } }
@keyframes glow { 0%, 100% { opacity: .6; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }

.sprout circle { fill: var(--surface); stroke: var(--acc); stroke-width: 2.5; filter: drop-shadow(0 6px 10px rgb(30 60 30 / .18)); transition: transform .25s; transform-box: fill-box; transform-origin: center; }
.sprout.share circle { stroke: var(--amber); fill: var(--amber-soft); }
.sprout.seed circle { stroke: none; fill: var(--acc-soft); }
.sprout.more circle { stroke-dasharray: 4 5; }
.sprout text { text-anchor: middle; }
.sprout .glyph { fill: var(--acc); font-size: 18px; font-weight: 800; }
.sprout.share .glyph { fill: var(--amber); }
.sprout.seed .glyph { font-size: 14px; }
.sprout .name { fill: var(--fg); font-size: 15px; font-weight: 600; }
.sprout:hover circle, .sprout:focus-visible circle { transform: scale(1.12); }
.sprout:focus-visible { outline: none; }
.sprout:focus-visible circle { stroke: var(--focus); stroke-width: 4; }
.sprout { animation: sprout .8s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes sprout { from { opacity: 0; transform: translateY(8px); } }

.legend { list-style: none; padding: 0; margin: 0 0 var(--s3); display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s1) var(--s3); color: var(--mute); font-size: .875rem; }
.legend li { display: flex; align-items: center; gap: 8px; }

/* ---- Pods (forms, panels) and leaves (list items) ---- */
.pod { position: relative; background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); margin: var(--s4) 0; box-shadow: var(--glow); }
.pod > h2 { margin-bottom: var(--s2); }
.pod.reach { border-radius: 40px 32px 44px 36px; }

.leaves { list-style: none; padding: 0; margin: 0 0 var(--s4); display: flex; flex-direction: column; gap: 14px; }
.leaf { background: var(--surface); border-radius: 30px 36px 32px 40px; box-shadow: var(--glow); transition: transform .25s, box-shadow .25s; }
.leaf:nth-child(3n+2) { margin-inline: 22px -6px; border-radius: 38px 28px 40px 30px; }
.leaf:nth-child(3n) { margin-inline: -8px 14px; border-radius: 34px 40px 28px 36px; }
.leaf:hover { transform: translateY(-2px); }
.leaf > details > summary, .leaf > .row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 16px 22px; min-height: 64px; }
.leaf > details > summary { list-style: none; cursor: pointer; border-radius: inherit; }
.leaf > details > summary::-webkit-details-marker { display: none; }
.leaf > details > summary::after { content: ""; margin-left: auto; width: 10px; height: 10px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute);
  transform: rotate(45deg); transition: transform .25s; order: 99; }
.leaf > details[open] > summary::after { transform: rotate(-135deg); }
.leaf > .row form { margin-left: auto; }
.leaf > details > :not(summary) { margin-left: 22px; margin-right: 22px; }
.leaf > details > :last-child { margin-bottom: 20px; }
.leaf .name { font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; }
.leaf .btn.ghost { border-color: transparent; background: var(--acc-soft); color: var(--acc); }
.more { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s3); margin: 0 0 var(--s2); padding: 14px 20px; background: var(--sunken); border-radius: 22px; }
.more dt { color: var(--mute); font-size: .875rem; }
.more dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.err-text { color: var(--bad); }
.end { display: flex; justify-content: flex-end; }
.leaf-actions { display: flex; flex-wrap: wrap; gap: var(--s1); justify-content: space-between; align-items: center; }
@media (max-width: 680px) {
  .leaf:nth-child(3n+2) { margin-inline: 10px 0; }
  .leaf:nth-child(3n) { margin-inline: 0 10px; }
  .pod { padding: var(--s3); }
  .more { grid-template-columns: 1fr; gap: 0; }
  .more dd { margin-bottom: 8px; }
}

.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--mute); box-shadow: 0 0 0 5px var(--sunken); }
.dot.ok, .dot.app { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 5px var(--bad-soft); }
.dot.share { background: var(--amber); box-shadow: 0 0 0 5px var(--amber-soft); }
.dot.seed { background: var(--acc-soft); box-shadow: 0 0 0 5px var(--sunken); border: 2px solid var(--acc); }

.trail { list-style: none; padding: 0; margin: 0 0 var(--s2); display: flex; flex-direction: column; gap: 8px; }
.trail li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 16px; background: var(--sunken); border-radius: 999px; }
.trail li:nth-child(even) { margin-left: 18px; }
.trail .who { font-weight: 600; }
.trail time { margin-left: auto; }
@media (max-width: 680px) { .trail li { border-radius: 22px; } .trail li:nth-child(even) { margin-left: 8px; } }
.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: var(--s2); }

/* ---- Buttons, fields, chips ---- */
.btn, .btn:visited, button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); min-height: 44px; padding: 10px 20px;
  font: 600 .9375rem/1.2 var(--font); border-radius: 999px; border: 0; background: var(--sunken); color: var(--fg);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .15s, filter .15s, background .15s; }
.btn:hover, button:hover { filter: brightness(.97); text-decoration: none; transform: translateY(-1px); }
.btn.primary, .btn.primary:visited, button.primary { background: linear-gradient(135deg, var(--acc), color-mix(in srgb, var(--acc) 78%, var(--fg))); color: var(--onacc);
  box-shadow: 0 8px 20px -10px var(--acc); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.danger, button.danger { color: var(--bad); background: var(--bad-soft); }
.btn.sm, button.sm { min-height: 36px; padding: 6px 14px; font-size: .875rem; }
.btn.block, button.block { width: 100%; min-height: 52px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.reach .actions { margin-top: var(--s2); }

.field { display: flex; align-items: center; gap: var(--s1); background: var(--sunken); border-radius: 999px; padding: 4px 4px 4px 20px; }
.field.gap { margin-bottom: var(--s2); }
.field code { flex: 1; min-width: 0; background: none; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field button { background: var(--surface); }

form { margin: 0; }
.form { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.form .wide, .form .submit { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: .875rem; color: var(--mute); font-weight: 600; padding-left: 6px; }
input { font: inherit; font-weight: 400; color: var(--fg); background: var(--sunken); border: 2px solid transparent; border-radius: 999px; padding: 10px 18px;
  min-height: 46px; width: 100%; transition: border-color .2s, background .2s; }
input:focus { border-color: var(--acc); background: var(--surface); outline: none; }
input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--acc); flex: none; }
input[type=checkbox] { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0; flex: none;
  border: 2px solid var(--mute); border-radius: 6px; background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; transition: none; }
input[type=checkbox]::before { content: ""; width: 10px; height: 10px; background: var(--onacc); transform: scale(0);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type=checkbox]:checked { background: var(--acc); border-color: var(--acc); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
input::placeholder { color: var(--mute); opacity: .8; }
.inline { display: flex; gap: var(--s1); align-items: center; flex: 1; min-width: 12rem; }
.inline input { min-width: 0; min-height: 40px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-size: .8125rem; font-weight: 700;
  background: var(--sunken); color: var(--mute); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.empty { text-align: center; padding: var(--s4) var(--s2); color: var(--mute); background: var(--surface); border-radius: 48% 52% 46% 54% / 40% 44% 56% 60%; box-shadow: var(--glow); margin-bottom: var(--s4); }
.empty .icon { width: 48px; height: 48px; stroke-width: 1.4; margin-bottom: var(--s1); color: var(--acc); }
.empty h3 { color: var(--fg); margin-bottom: var(--s0); }
.empty p { margin: 0 auto; max-width: 26rem; }

.toasts { position: fixed; z-index: 40; right: var(--s3); bottom: var(--s3); display: grid; gap: var(--s1); max-width: min(26rem, calc(100vw - 2 * var(--s2))); }
.toast { display: flex; align-items: center; gap: var(--s1); padding: 12px 12px 12px 20px; border-radius: 999px; background: var(--surface);
  box-shadow: var(--glow), inset 4px 0 0 var(--ok); transition: opacity .3s, transform .3s; }
.toast.err { box-shadow: var(--glow), inset 4px 0 0 var(--bad); border-radius: 24px; }
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast button { min-height: 32px; min-width: 32px; padding: 0 6px; background: none; color: var(--mute); }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 680px) { .toasts { left: var(--s2); right: var(--s2); bottom: calc(96px + env(safe-area-inset-bottom)); max-width: none; } }

/* ---- Login: one soft card floating over the blobs ---- */
.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s2); }
.login { width: 100%; max-width: 420px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 44px 40px 48px 36px; padding: var(--s4) 36px; box-shadow: var(--glow); text-align: center; animation: float 9s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.login .brand { justify-content: center; margin-bottom: var(--s3); font-size: 1.25rem; }
.login .brand .logo { width: 56px; height: 56px; }
.login .brand .logo .icon { width: 30px; height: 30px; }
.login .brand { flex-direction: column; }
.login h1 { font-size: 1.75rem; margin-bottom: var(--s1); }
.login .stack { display: grid; gap: 12px; margin: var(--s3) 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--mute); font-size: .8125rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.login .toasts { position: static; max-width: none; margin-bottom: var(--s2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Connections */
.field code.usercode { font-size: 1.5rem; font-weight: 700; letter-spacing: .15em; }
.leaf code.provider-id { font-size: .75rem; color: var(--mute); }
.leaf-note { margin: -6px 22px 16px; font-size: .875rem; }
.check { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--mute); }
.menu button.link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; min-height: 44px; border: 0; border-radius: 999px; background: none; color: var(--fg); font: inherit; cursor: pointer; box-shadow: none; }
.menu button.link:hover { background: var(--sunken); }
