:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #161a26;
  --muted: #5d6478;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --accent-soft: #e8edff;
  --ok: #1f8a4c; --ok-soft: #e3f5ea;
  --warn: #a35f00; --warn-soft: #fff3dc;
  --bad: #c0392b; --bad-soft: #fde8e6;
  --s1: #fde8e6; --s2: #fdf0e1; --s3: #f1f3f9; --s4: #e4f2ff; --s5: #dff3e7;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 4px 16px rgba(20, 24, 40, .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --surface: #171a23; --surface-2: #1e2230; --border: #2a2f3f;
    --text: #e8eaf2; --muted: #9aa1b5; --accent: #7b93ff; --accent-text: #0f1117; --accent-soft: #232a45;
    --ok: #5fd08f; --ok-soft: #173326; --warn: #f3b453; --warn-soft: #3a2c12; --bad: #ff8a7a; --bad-soft: #3d1d1a;
    --s1: #3d1d1a; --s2: #3a2c12; --s3: #1e2230; --s4: #15283d; --s5: #173326;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }

.logo-mark {
  display: inline-block; width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  -webkit-mask: none; position: relative; flex: none;
}
.logo-mark::after {
  content: ""; position: absolute; inset: 7px 6px 8px; border: 2.5px solid var(--accent-text);
  border-right: 0; border-bottom: 0; transform: rotate(45deg) translate(2px, 2px); border-radius: 1px;
}
.logo-mark.lg { width: 48px; height: 48px; border-radius: 12px; margin-bottom: 16px; }
.logo-mark.lg::after { inset: 14px 12px 15px; border-width: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 18px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: filter .15s, background .15s;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.google { background: var(--surface); color: var(--text); border-color: var(--border); width: 100%; padding: 12px; }
.btn.google:hover { background: var(--surface-2); }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 20px; cursor: pointer; padding: 4px 8px; }

/* Sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow); text-align: center;
}
.signin-card p.muted { margin: 0 0 24px; }

/* Layout */
.app {
  display: grid; min-height: 100vh;
  grid-template-columns: 280px 1fr; grid-template-rows: 60px 1fr;
  grid-template-areas: "top top" "side main";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user img { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); }
.sidebar {
  grid-area: side; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; overflow-y: auto; height: calc(100vh - 60px); position: sticky; top: 60px;
}
.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 8px 8px; }
.history { list-style: none; margin: 0; padding: 0; }
.history a {
  display: block; padding: 10px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px;
}
.history a:hover { background: var(--surface-2); }
.history a.active { background: var(--accent-soft); }
.h-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; }
.h-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.history .empty { color: var(--muted); font-size: 13px; padding: 8px; }
.content { grid-area: main; padding: 36px 40px 60px; max-width: 980px; width: 100%; }

/* Cards & forms */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); margin-top: 16px;
}
textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px 14px; resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.alert { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }

/* Badges */
.badge, .pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.badge.running, .badge.finalizing { background: var(--accent-soft); color: var(--accent); }
.badge.complete { background: var(--ok-soft); color: var(--ok); }
.badge.needs_input { background: var(--warn-soft); color: var(--warn); }
.badge.failed, .badge.stopped, .badge.out_of_scope { background: var(--bad-soft); color: var(--bad); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* Detail */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.d-title { font-size: 21px; font-weight: 600; white-space: pre-wrap; }
.progress { display: flex; gap: 16px; align-items: flex-start; }
.progress p { margin: 4px 0 0; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft);
  border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; margin-top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.rec { border-left: 4px solid var(--accent); }
.rec-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.rec-value { font-size: 24px; font-weight: 700; margin: 4px 0 10px; }
.rec-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.table-wrap { overflow-x: auto; }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.matrix th, .matrix td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { font-weight: 600; color: var(--muted); font-size: 13px; }
.matrix thead th.winner { color: var(--accent); }
.matrix .w { font-size: 12px; color: var(--muted); display: block; font-weight: 400; }
.matrix td.score { font-weight: 600; }
.matrix td.s1 { background: var(--s1); } .matrix td.s2 { background: var(--s2); }
.matrix td.s3 { background: var(--s3); } .matrix td.s4 { background: var(--s4); } .matrix td.s5 { background: var(--s5); }
.matrix tfoot td { font-weight: 700; border-bottom: 0; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { display: inline; }
details > summary::after { content: " ▾"; color: var(--muted); }
details:not([open]) > summary::after { content: " ▸"; }

/* Markdown */
.prose { overflow-wrap: anywhere; }
.prose h1 { font-size: 20px; margin: 24px 0 8px; }
.prose h2 { font-size: 17px; margin: 22px 0 8px; }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 8px 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; margin: 12px 0; font-size: 13.5px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose th { background: var(--surface-2); }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.prose pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; }
.prose blockquote { border-left: 3px solid var(--border); margin: 8px 0; padding: 2px 12px; color: var(--muted); }

.only-mobile { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 280px; height: auto; z-index: 10;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-block; }
  .hide-mobile { display: none; }
  .content { padding: 24px 16px 48px; }
  .topbar { padding: 0 12px; }
  .brand { font-size: 15px; }
  h1 { font-size: 22px; }
}

/* Credits & billing */
.credits { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.credits.low { color: var(--warn); background: var(--warn-soft); }
.legal { font-size: 12.5px; color: var(--muted); margin: 16px 0 0; }
.legal a { color: var(--muted); }
.side-legal { padding: 0 8px; margin-top: 28px; }
.banner { padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); margin-bottom: 20px; font-weight: 500; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
#new-error-buy { margin-top: 10px; }
.modal { position: fixed; inset: 0; background: rgba(10, 12, 20, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { position: relative; width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 12px; right: 12px; font-size: 24px; color: var(--muted); }
.packs { display: grid; gap: 10px; margin-top: 16px; }
.pack {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.pack:hover { border-color: var(--accent); }
.pack:disabled { opacity: .6; cursor: progress; }
.pack-name { font-weight: 600; }
.pack-sub { font-size: 13px; color: var(--muted); }
.pack-price { font-size: 20px; font-weight: 700; }
@media (max-width: 820px) { #buy-btn { display: none; } .credits { font-size: 12px; } }

/* Legal pages */
.doc { max-width: 760px; margin: 0 auto; padding: 40px 16px 64px; }
.doc h1 { margin-bottom: 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 8px; }
.doc p, .doc li { color: var(--text); }
.doc .updated { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.doc .back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 24px; text-decoration: none; font-weight: 600; color: var(--text); }

/* ---------- Landing page ---------- */
.lp { --lp-max: 1120px; overflow-x: hidden; }
.lp-nav {
  max-width: var(--lp-max); margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 24px;
}
.lp-links { display: flex; gap: 22px; margin-left: auto; }
.lp-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.lp-links a:hover { color: var(--text); }
.lp-alert { max-width: var(--lp-max); margin: 0 auto 8px; width: calc(100% - 48px); }
.btn.lg { padding: 14px 24px; font-size: 16px; border-radius: 11px; }

.lp-hero {
  max-width: var(--lp-max); margin: 0 auto; padding: 56px 24px 40px;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; position: relative;
}
.lp-hero::before {
  content: ""; position: absolute; inset: -120px -200px auto auto; width: 620px; height: 620px; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  pointer-events: none;
}
.lp-eyebrow { display: inline-block; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; margin: 0 0 18px; }
.lp-h1 { font-size: clamp(36px, 5vw, 56px); line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 20px; font-weight: 700; }
.lp-accent { background: linear-gradient(90deg, var(--accent), #9b5de5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-lead { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 0 28px; max-width: 560px; }
.lp-cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.lp-trust { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.lp-trust.center { justify-content: center; }

.lp-window {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(20,24,40,.05), 0 24px 60px rgba(20,24,40,.12); transform: rotate(0.6deg);
}
.lp-window-bar { display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.lp-window-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.lp-window-bar em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); font-weight: 500; }
.lp-window-body { padding: 18px 20px 20px; }
.lp-q { font-size: 14px; color: var(--muted); margin: 0 0 14px; font-style: italic; }
.lp-rec { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; margin-bottom: 14px; }
.lp-rec-value { font-size: 20px; font-weight: 700; margin: 2px 0 8px; }
.lp-matrix { font-size: 13px; }
.lp-matrix th, .lp-matrix td { padding: 7px 8px; }

.lp-strip { max-width: var(--lp-max); margin: 0 auto; padding: 8px 24px 48px; text-align: center; }
.lp-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.lp-chips .chip { text-decoration: none; font-size: 13.5px; padding: 7px 14px; }

.lp-section { padding: 80px 24px; }
.lp-section > * { max-width: var(--lp-max); margin-left: auto; margin-right: auto; }
.lp-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.lp-h2 { font-size: clamp(26px, 3.4vw, 36px); letter-spacing: -0.02em; line-height: 1.15; text-align: center; margin-bottom: 12px; }
.lp-sub { text-align: center; color: var(--muted); font-size: 17px; max-width: 640px !important; margin: 0 auto 40px; }
.lp-section .lp-h2 + .lp-steps { margin-top: 40px; }
.lp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-step { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); }
.lp-step h3, .lp-feature h3, .lp-price h3 { font-size: 17px; margin: 0 0 8px; }
.lp-step p, .lp-feature p { color: var(--muted); margin: 0; font-size: 15px; }
.lp-num { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; margin-bottom: 16px; }
.lp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-feature { padding: 22px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); }
.lp-ico { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 18px; margin-bottom: 14px; }

.lp-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 900px !important; }
.lp-price { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.lp-price.featured { border: 2px solid var(--accent); }
.lp-amt { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 4px; }
.lp-price p { color: var(--muted); margin: 0 0 22px; flex: 1; }
.fine.center { text-align: center; margin-top: 20px; }

.lp-faq { max-width: 760px !important; }
.lp-faq details { border-bottom: 1px solid var(--border); padding: 18px 4px; }
.lp-faq summary { font-weight: 600; font-size: 16px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.lp-faq summary::after { content: "+"; color: var(--muted); font-size: 20px; line-height: 1; }
.lp-faq details[open] summary::after { content: "–"; }
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq p { color: var(--muted); margin: 12px 0 0; }

.lp-final { text-align: center; padding: 96px 24px; }
.lp-final .lp-sub { margin-bottom: 28px; }
.lp-footer {
  max-width: var(--lp-max); margin: 0 auto; padding: 28px 24px 40px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted);
}
.lp-footer a { color: var(--muted); }

@media (max-width: 900px) {
  .lp-hero { grid-template-columns: 1fr; gap: 40px; padding-top: 32px; }
  .lp-window { transform: none; }
  .lp-steps, .lp-grid, .lp-prices { grid-template-columns: 1fr; }
  .lp-links { display: none; }
  .lp-signin { margin-left: auto; }
  .lp-section { padding: 56px 16px; }
  .lp-nav, .lp-hero, .lp-strip { padding-left: 16px; padding-right: 16px; }
  .lp-alert { width: calc(100% - 32px); }
  .lp-matrix th, .lp-matrix td { padding: 6px 5px; font-size: 12px; }
}
@media (min-width: 901px) and (max-width: 1100px) { .lp-grid { grid-template-columns: repeat(2, 1fr); } }
