:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1b1d1f;
  --muted: #62676d;
  --line: #e3e1da;
  --soft: #efede6;
  --accent: #1f5f4a;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #a3261f;
  --bad-soft: #fbe5e3;
  --live: #d4541d;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131516; --panel: #1b1e20; --ink: #ecebe6; --muted: #9aa0a6; --line: #2c3033; --soft: #23272a;
    --accent: #5fbf9a; --accent-ink: #0d1a15; --accent-soft: #1d3029; --warn: #e0a447; --warn-soft: #33281a;
    --bad: #f0857c; --bad-soft: #3a2220; --live: #f08a52;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 600; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); flex: none;
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.top-nav { display: flex; align-items: center; gap: .75rem; }
.usage { color: var(--muted); font-size: .85rem; white-space: nowrap; }
@media (max-width: 560px) { .usage { display: none; } }

.view { max-width: 1240px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }

/* controls */
.btn, .ghost, .danger { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border-radius: 8px;
  padding: .55rem .95rem; border: 1px solid transparent; cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap; }
.btn { background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.06); }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: var(--soft); }
.danger { background: transparent; border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); }
.danger:hover { background: var(--bad-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-weight: 550; margin: 0 0 .3rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea { min-height: 7rem; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 12rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.stack > * + * { margin-top: 1rem; }

/* login */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .card { padding: 1.75rem; }
.auth h1 { margin-bottom: .5rem; }

/* team */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.emp { display: flex; flex-direction: column; gap: .5rem; color: inherit; text-decoration: none; transition: border-color .15s; }
.emp:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.emp-top { display: flex; align-items: center; gap: .75rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; flex: none;
  background: var(--accent-soft); color: var(--accent); }
.emp-name { font-weight: 650; }
.emp-role { color: var(--muted); font-size: .9rem; }
.emp-last { color: var(--muted); font-size: .88rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { text-align: center; padding: 3rem 1rem; }

.pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px;
  background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.running { background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--live); }
.pill.done { background: var(--accent-soft); color: var(--accent); }
.pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.queued, .pill.stopped { background: var(--warn-soft); color: var(--warn); }

/* workspace */
.ws { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .ws { grid-template-columns: 1fr; } .screen-col { order: -1; } }
.ws-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.ws-head .grow { flex: 1; min-width: 0; }
.ws-head h1 { margin: 0; }
.composer textarea { min-height: 5.5rem; }
.composer .row { justify-content: space-between; margin-top: .6rem; }
.examples { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: .25rem .7rem; font-size: .83rem; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--ink); border-color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; }
.timeline li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .5rem; padding: .35rem 0; font-size: .9rem; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; background: var(--line); }
.timeline li.act .dot { background: var(--accent); }
.timeline li.think { color: var(--muted); }
.timeline li.warn .dot { background: var(--warn); }
.timeline li.end .dot { background: var(--ink); }
.answer { white-space: pre-wrap; background: var(--soft); border-radius: 8px; padding: .75rem .9rem; font-size: .93rem; }

.pending { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 60%, var(--panel)); }
.pending h2 { color: var(--warn); }

.screen-col { position: sticky; top: 4.2rem; }
.screen { position: relative; aspect-ratio: 1280 / 800; background: #0e0f10; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.screen iframe, .screen img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #0e0f10; }
.screen .shield { position: absolute; inset: 0; cursor: not-allowed; }
.screen.working { box-shadow: 0 0 0 2px var(--live), 0 0 24px color-mix(in srgb, var(--live) 35%, transparent); }
.screen.human { box-shadow: 0 0 0 3px var(--warn); }
.screen .idle { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa0a6; text-align: center; padding: 1rem; }
.screen-bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .6rem; flex-wrap: wrap; }
.status-line { font-size: .9rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.runs { list-style: none; margin: 0; padding: 0; }
.runs li { border-top: 1px solid var(--line); padding: .7rem 0; }
.runs li:first-child { border-top: 0; }
.run-head { display: flex; gap: .6rem; align-items: baseline; justify-content: space-between; cursor: pointer; }
.run-goal { font-weight: 550; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.run-meta { font-size: .8rem; color: var(--muted); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; margin-top: .6rem; }
.shots img { width: 100%; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 2rem); z-index: 20; }
.devlink { word-break: break-all; font-family: var(--mono); font-size: .8rem; }
.sites { font-family: var(--mono); font-size: .9rem; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); max-width: min(92vw, 1100px); padding: .5rem; }
dialog img { max-width: 100%; display: block; }
dialog::backdrop { background: rgb(0 0 0 / .55); }
