:root {
  --bg: #f7f7fb;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --border: #e3e5ef;
  --text: #141625;
  --text-2: #4a4f68;
  --muted: #62677f;
  --brand: #5b4cf0;
  --brand-2: #8b5cf6;
  --brand-soft: #ece9ff;
  --ok: #0e7a50;
  --ok-soft: #dff5ea;
  --warn: #9a5c00;
  --warn-soft: #fff1d9;
  --bad: #c62f3b;
  --bad-soft: #fde4e6;
  --info: #1a64c4;
  --info-soft: #e2eeff;
  --shadow: 0 1px 2px rgba(20, 22, 37, .06), 0 8px 24px rgba(20, 22, 37, .06);
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e17; --bg-2: #12131f; --surface: #161828; --surface-2: #1d2034; --border: #2a2d45;
    --text: #eef0ff; --text-2: #b8bcd8; --muted: #8a8fb0; --brand: #8b7bff; --brand-2: #b18cff;
    --brand-soft: #241f4a; --ok: #3ccf8e; --ok-soft: #143326; --warn: #f0b04a; --warn-soft: #3a2b10;
    --bad: #ff6b76; --bad-soft: #3d171c; --info: #64a8ff; --info-soft: #132a47;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e17; --bg-2: #12131f; --surface: #161828; --surface-2: #1d2034; --border: #2a2d45;
  --text: #eef0ff; --text-2: #b8bcd8; --muted: #8a8fb0; --brand: #8b7bff; --brand-2: #b18cff;
  --brand-soft: #241f4a; --ok: #3ccf8e; --ok-soft: #143326; --warn: #f0b04a; --warn-soft: #3a2b10;
  --bad: #ff6b76; --bad-soft: #3d171c; --info: #64a8ff; --info-soft: #132a47;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

/* --- nav --- */
.nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 8%, transparent 9%), radial-gradient(circle at 65% 30%, #fff 0 8%, transparent 9%), linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 0 0 3px var(--brand-soft); }
.nav-links { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav-links a { color: var(--text-2); font-weight: 500; }
@media (max-width: 720px) { .nav-links .hide-sm { display: none; } }

/* --- buttons & inputs --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .05s, background .15s, border-color .15s; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, textarea, select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: 15px var(--font); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
.check input { width: auto; }
.advanced { border-top: 1px solid var(--border); margin: 4px 0 16px; padding-top: 12px; }
.advanced > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 4px 0; }
.advanced > summary:hover { color: var(--brand); }
.advanced[open] > summary { margin-bottom: 14px; }

/* --- cards --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }

.tile { padding: 16px; }
.tile .k { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--text-2); font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.error-box { padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-weight: 500; margin-bottom: 12px; }

/* --- tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

/* --- landing --- */
.hero { padding: 72px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 13px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(34px, 5.4vw, 58px); font-weight: 800; letter-spacing: -.03em; }
.hero h1 .grad { background: linear-gradient(135deg, var(--brand), var(--brand-2) 60%, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: 19px; color: var(--text-2); max-width: 580px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 26px 0 14px; }
.section { padding: 56px 0; }
.section h2 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 780; }
.section .sub { color: var(--text-2); font-size: 17px; max-width: 680px; margin-bottom: 30px; }
.feature .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 12px; font-size: 20px; }
.feature p { color: var(--text-2); margin: 0; }
.steps { counter-reset: step; display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.step::before { counter-increment: step; content: counter(step); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.step h4 { margin: 4px 0; font-size: 16px; }
.step p { margin: 0; color: var(--text-2); }
.footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 14px; }
.terminal { background: #0b0c14; color: #d7dbff; border-radius: 12px; padding: 14px 16px; font: 13px/1.6 var(--mono); overflow-x: auto; border: 1px solid #23263b; }
.terminal .p { color: #7f87b8; }

/* --- Orbi avatar (shared by landing & dashboard) --- */
.orbi-panel { display: grid; gap: 14px; }
.orbi-head { display: flex; gap: 16px; align-items: center; }
.orbi { --c1: var(--brand); --c2: var(--brand-2); position: relative; width: 84px; height: 84px; flex: none; }
.orbi .body { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.55), transparent 40%), linear-gradient(140deg, var(--c1), var(--c2)); box-shadow: 0 10px 30px color-mix(in srgb, var(--c1) 45%, transparent), inset 0 -8px 16px rgba(0,0,0,.18); animation: orbi-float 3.2s ease-in-out infinite; }
.orbi .ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--c1) 55%, transparent); animation: orbi-spin 9s linear infinite; }
.orbi.idle .ring { animation-duration: 30s; opacity: .5; }
.orbi .eye { position: absolute; top: 34%; width: 14%; height: 20%; background: #fff; border-radius: 50%; animation: orbi-blink 4.5s infinite; transform-origin: center; }
.orbi .eye::after { content: ""; position: absolute; width: 55%; height: 55%; left: 22%; top: 30%; border-radius: 50%; background: #1a1340; animation: orbi-look 6s ease-in-out infinite; }
.orbi .eye.l { left: 30%; } .orbi .eye.r { right: 30%; }
.orbi .mouth { position: absolute; left: 38%; right: 38%; bottom: 26%; height: 9%; border-bottom: 3px solid rgba(255,255,255,.9); border-radius: 0 0 50% 50%; }
.orbi.fixing { --c1: #f97316; --c2: #f59e0b; }
.orbi.testing { --c1: #2563eb; --c2: #06b6d4; }
.orbi.happy { --c1: #10b981; --c2: #22c55e; }
.orbi.error { --c1: #ef4444; --c2: #f43f5e; }
.orbi.thinking .mouth { left: 42%; right: 42%; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); height: 10%; }
@keyframes orbi-float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
@keyframes orbi-spin { to { transform: rotate(360deg) } }
@keyframes orbi-blink { 0%, 46%, 50%, 100% { transform: scaleY(1) } 48% { transform: scaleY(.1) } }
@keyframes orbi-look { 0%,100% { transform: translateX(0) } 30% { transform: translateX(30%) } 60% { transform: translateX(-30%) } }
@media (prefers-reduced-motion: reduce) { .orbi .body, .orbi .ring, .orbi .eye, .orbi .eye::after { animation: none; } }
.bubble { position: relative; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 14px; border-radius: 14px; font-size: 14px; color: var(--text); }
.bubble::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; background: var(--surface-2); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: rotate(45deg); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: inherit; transition: width .6s ease; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 420px; overflow: auto; }
.tasks li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.tasks li .tick { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); margin-top: 2px; display: grid; place-items: center; font-size: 11px; color: #fff; }
.tasks li.done .tick { background: var(--ok); border-color: var(--ok); }
.tasks li.done .t { text-decoration: line-through; color: var(--muted); }
.tasks li.failed .tick { background: var(--bad); border-color: var(--bad); }
.tasks li.failed .t { color: var(--bad); }
.tasks li.skipped .t { text-decoration: line-through; color: var(--muted); font-style: italic; }
.tasks li.active { background: var(--brand-soft); }
.tasks li.active .tick { border-color: var(--brand); border-top-color: transparent; animation: orbi-spin 1s linear infinite; }
.tasks li .ph { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* The landing demo has a short, fixed plan that it steps through: show every task instead of clipping the last ones in a scroll box. */
.hero .tasks { max-height: none; overflow: visible; }
/* Connect page: live status while waiting for Orbi to use a new key. */
.connect-status { margin: 12px 0 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.connect-status[hidden] { display: none; }
.connect-status.waiting { color: var(--muted); }
.connect-status.ok { color: var(--ok); font-weight: 600; }
.connect-status.bad { color: var(--bad); }
.spinner { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand); animation: orbi-spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* --- app shell --- */
.app-main { padding: 26px 0 60px; }
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 12px; color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { margin-left: 4px; font-size: 11.5px; padding: 1px 6px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.auth-box { max-width: 420px; margin: 40px auto; }
.proj-card { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.proj-card:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.proj-card .url { color: var(--muted); font-size: 13px; word-break: break-all; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.shot { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: zoom-in; }
.shot img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; background: var(--surface-2); }
.shot .cap { padding: 8px 10px; font-size: 12.5px; color: var(--text-2); }
.matrix td.cell { text-align: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.detail { display: grid; gap: 10px; }
.detail .kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px; font-size: 14px; }
@media (max-width: 600px) { .detail .kv { grid-template-columns: 1fr; } }
.detail .kv b { color: var(--muted); font-weight: 600; }
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 10, 20, .55); }
dialog .dhead { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
dialog .dbody { padding: 18px 20px; overflow: auto; }
.chart svg { width: 100%; height: auto; display: block; }
.score-big { font-size: 54px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.uplift { color: var(--ok); font-weight: 700; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.feed li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.feed li time { color: var(--muted); font-variant-numeric: tabular-nums; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 100; box-shadow: var(--shadow); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; padding: 7px 10px; font-size: 14px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: 13.5px; margin-bottom: 6px; }
.bar-row .bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--brand); border-radius: inherit; }

/* --- first-run setup checklist (project overview) --- */
.setup-steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 16px; }
.setup-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.setup-steps .n { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.setup-steps li.current .n { border-color: var(--brand); color: var(--brand); }
.setup-steps li.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-steps h4 { margin: 3px 0 6px; font-size: 15px; }
.setup-steps li.done h4 { color: var(--muted); }
.setup-steps p { margin: 0 0 10px; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .terminal { flex: 1; min-width: 0; white-space: nowrap; }
