/* SiteBrain - shared styles: website (site/build.mjs) + dashboard (/app/) */
:root {
  --brand: #5b4ef0; --brand-2: #a855f7; --brand-ink: #3f33c9; --brand-soft: #eeedfe;
  --bg: #ffffff; --bg-2: #f7f7fb; --card: #ffffff; --fg: #0f172a; --fg-2: #334155; --muted: #566173;
  --line: #e6e8f0; --ok: #059669; --ok-soft: #d1fae5; --warn: #b45309; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 var(--font); }
img, svg { max-width: 100%; }
a { color: var(--brand-ink); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; margin: 0 0 .5em; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font: 600 15px/1.2 var(--font); text-decoration: none; cursor: pointer; transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), #7c4dff); color: #fff; box-shadow: 0 6px 18px rgba(91,78,240,.28); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(91,78,240,.38); }
.btn-ghost { background: var(--card); color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { border-color: #c9cde0; background: var(--bg-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 17px; border-radius: 12px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; color: var(--fg-2); }
.input, input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 15px; background: #fff; color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,78,240,.15); }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 14px; }
.check input { margin-top: 4px; }

/* header / footer */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.86); backdrop-filter: saturate(1.6) blur(10px); border-bottom: 1px solid rgba(230,232,240,.7); }
.nav { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--fg); text-decoration: none; letter-spacing: -.02em; }
.brand img { width: 32px; height: 32px; }
.nav-links { display: flex; gap: 22px; margin-left: 12px; }
.nav-links a { color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.nav-links a:hover, .nav-links a[aria-current=page] { color: var(--brand-ink); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-switch { font-size: 14px; color: var(--muted); text-decoration: none; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; }
.menu-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
@media (max-width: 860px) {
  .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; gap: 0; margin: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 0; }
  .menu-toggle { display: block; }
  .nav-right .btn-ghost { display: none; }
}
.site-footer { background: #0b1020; color: #b8bfd6; padding: 48px 0 28px; margin-top: 64px; font-size: 14px; }
.site-footer a { color: #d9ddef; text-decoration: none; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; }
.footer-title { font-weight: 700; color: #fff; font-size: 14px; margin: 0 0 10px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.footer-bottom { border-top: 1px solid #1f2740; margin-top: 32px; padding-top: 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* landing */
.hero { position: relative; overflow: hidden; padding: 72px 0 56px; background:
  radial-gradient(900px 420px at 85% -10%, rgba(168,85,247,.16), transparent 60%),
  radial-gradient(700px 400px at 0% 0%, rgba(91,78,240,.14), transparent 60%); }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; color: var(--brand-ink); background: var(--brand-soft); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(32px, 5vw, 54px); font-weight: 800; letter-spacing: -.03em; }
.hero h1 .grad { background: linear-gradient(120deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: clamp(17px, 2vw, 20px); color: var(--fg-2); max-width: 600px; }
.hero-form { display: flex; gap: 10px; margin: 28px 0 12px; max-width: 560px; background: #fff; padding: 6px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero-form input { border: 0; box-shadow: none !important; font-size: 16px; }
.hero-note { font-size: 14px; color: var(--muted); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .hero { padding-top: 48px; } }
@media (max-width: 480px) { .hero-form { flex-direction: column; } }

.demo { background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 60px rgba(15,23,42,.14); overflow: hidden; max-width: 400px; margin-left: auto; }
.demo-head { background: linear-gradient(135deg, var(--brand), #7c4dff); color: #fff; padding: 14px 16px; display: flex; gap: 10px; align-items: center; font-weight: 600; }
.demo-head small { display: block; font-weight: 400; opacity: .85; font-size: 12px; }
.demo-body { padding: 16px; display: grid; gap: 10px; background: #fff; font-size: 14px; }
.bubble { padding: 9px 13px; border-radius: 16px; max-width: 88%; }
.bubble.bot { background: #f1f2f8; border-bottom-left-radius: 4px; }
.bubble.user { background: var(--brand); color: #fff; justify-self: end; border-bottom-right-radius: 4px; }
.bubble .src { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; background: #fff; }
@media (max-width: 900px) { .demo { margin: 0 auto; } }

.section { padding: 72px 0; }
.section.alt { background: var(--bg-2); }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 44px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; letter-spacing: -.02em; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.feature .icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); margin-bottom: 14px; }
.feature h3 { font-size: 18px; }
.feature p { margin: 0; color: var(--fg-2); font-size: 15px; }
.steps { counter-reset: step; }
.step { position: relative; padding-top: 52px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 24px; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; display: grid; place-items: center; transform: translateY(24px); }
.step h3 { font-size: 17px; margin-top: 12px; }
.step p { margin: 0; color: var(--fg-2); font-size: 15px; }

/* pricing */
.pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; align-items: stretch; }
@media (max-width: 900px) { .pricing { grid-template-columns: 1fr; max-width: 440px; margin: 0 auto; } }
.plan { display: flex; flex-direction: column; position: relative; }
.plan.featured { border: 2px solid var(--brand); box-shadow: 0 18px 48px rgba(91,78,240,.18); }
.plan .badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 12px; border-radius: 999px; }
.plan h3 { font-size: 20px; margin-bottom: 4px; }
.price { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 0; }
.price small { font-size: 15px; font-weight: 500; color: var(--muted); }
.price-alt { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.plan ul { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 9px; flex: 1; }
.plan li { padding-left: 26px; position: relative; font-size: 15px; }
.plan li::before { content: ""; position: absolute; left: 0; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat; }

/* faq, prose */
.faq { max-width: 820px; margin: 0 auto; display: grid; gap: 12px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--brand); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 10px 0 0; color: var(--fg-2); }
.prose { font-size: 17px; color: var(--fg-2); }
.prose h1 { font-size: clamp(30px, 4vw, 42px); color: var(--fg); font-weight: 800; }
.prose h2 { font-size: 26px; color: var(--fg); margin-top: 1.8em; }
.prose h3 { font-size: 20px; color: var(--fg); margin-top: 1.4em; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 12px; overflow-x: auto; font-size: 14px; }
.prose code { background: var(--bg-2); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 1.2em 0; padding: 12px 18px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.prose img { border-radius: 12px; }
.page-hero { padding: 56px 0 24px; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.post-meta { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.post-list { display: grid; gap: 20px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .post-list { grid-template-columns: 1fr; } }
.post-card { text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
.post-card:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(15,23,42,.1); }
.post-card h2 { font-size: 20px; color: var(--fg); }
.post-card p { margin: 0; color: var(--fg-2); font-size: 15px; }
.cta-band { background: linear-gradient(135deg, #2a1fa8, #6d28d9); color: #fff; border-radius: 24px; padding: 48px 32px; text-align: center; }
.cta-band h2 { color: #fff; font-size: clamp(24px, 3vw, 34px); }
.cta-band p { color: #ddd8ff; margin: 0 auto 22px; max-width: 560px; }
.cta-band .btn-primary { background: #fff; color: var(--brand-ink); box-shadow: none; }

/* ads: reserved space avoids layout shift (CLS); hidden when AdSense is not configured */
.ad-slot { margin: 32px auto; text-align: center; min-height: 100px; }
.ad-slot::before { content: attr(data-label); display: block; font-size: 11px; color: #a0a7bb; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }

/* dashboard */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: var(--bg-2); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { margin: 0 8px 20px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.side-link:hover { background: var(--bg-2); }
.side-link.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 8px; }
.main { padding: 28px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h1 { font-size: 26px; margin: 0; }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .sidebar .brand { margin: 0 auto 0 4px; }
  .side-link { padding: 7px 9px; font-size: 14px; }
  .side-link span.lbl { display: none; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 48px; }
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: 600 15px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tab.active { color: var(--brand-ink); border-color: var(--brand); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--fg-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.warn .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.bot-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.bot-card { text-decoration: none; color: inherit; display: block; }
.bot-card:hover { border-color: #c9cde0; }
.bot-card h3 { font-size: 18px; margin-bottom: 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.progress { height: 8px; background: #e9eaf3; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; transition: width .4s; }
.code-box { position: relative; background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 14px 16px; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; white-space: pre; }
.code-box .btn { position: absolute; top: 8px; right: 8px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td.url { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.two-col > * { min-width: 0; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.preview-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(800px 400px at 50% -10%, rgba(91,78,240,.15), transparent 60%), var(--bg-2); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert.error { background: var(--bad-soft); color: #991b1b; }
.alert.success { background: var(--ok-soft); color: #065f46; }
.alert.info { background: var(--brand-soft); color: var(--brand-ink); }
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.qr { display: block; width: 240px; height: 240px; margin: 8px auto 16px; border-radius: 12px; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; font: 600 14px var(--font); color: var(--fg-2); cursor: pointer; }
.seg button.active { background: var(--brand); color: #fff; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 200; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 48px 20px; }
.empty .icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.log-item { border-bottom: 1px solid var(--line); padding: 14px 0; }
.log-item .q { font-weight: 600; }
.log-item .a { color: var(--fg-2); white-space: pre-wrap; font-size: 14px; margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bar-chart i { flex: 1; background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-radius: 4px 4px 0 0; min-height: 2px; }
