/* ==========================================================
   Design tokens
   Type scale: 12 / 13 / 14 / 15 / 16 / 17 / 18 px + fluid h1/h2
   Spacing: multiples of 4px (8, 12, 16, 20, 24, 32, 40, 48, 64, 80, 96)
   Radii: 16 (cards, terminal) / 12 (code, chips) / 10 (buttons) / 8 (small)
   ========================================================== */
:root {
    /* surfaces */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: rgba(15, 23, 42, .08);
    --border-strong: rgba(15, 23, 42, .16);
    /* text */
    --text: #0f172a;
    --muted: #475569;
    /* accent (blue-600 / blue-700 / cyan-600) */
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, .08);
    --accent-line: rgba(37, 99, 235, .25);
    --teal: #0891b2;
    /* success (emerald) */
    --success: #059669;
    --success-strong: #047857;
    --success-soft: rgba(16, 185, 129, .1);
    --success-line: rgba(16, 185, 129, .35);
    /* command blocks: terminal + code (light) */
    --code-bg: #ffffff;
    --code-head: rgba(15, 23, 42, .03);
    --code-edge: rgba(15, 23, 42, .16);
    --code-line: rgba(15, 23, 42, .12);
    --code-border: rgba(15, 23, 42, .08);
    --code-text: #0f172a;
    --code-muted: #475569;
    --code-dim: #94a3b8;
    --code-prompt: #2563eb;
    --code-ok: #059669;
    /* shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 10px 30px -14px rgba(15, 23, 42, .45);
    --shadow-lg: 0 30px 70px -30px rgba(15, 23, 42, .55);
    /* radii */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-btn: 10px;
    --radius-sm: 8px;
    /* type scale */
    --fs-12: .75rem;
    --fs-13: .8125rem;
    --fs-14: .875rem;
    --fs-15: .9375rem;
    --fs-17: 1.0625rem;
    --fs-18: 1.125rem;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
svg { display: block; }
::selection { background: rgba(37, 99, 235, .18); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.hero-copy, .hero-demo, .feature, .card, .code-block, .terminal, .install-list { min-width: 0; }

.skip-link {
    position: absolute; left: -999px; top: 8px; z-index: 100;
    background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(248, 250, 252, .8);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 64px; }
.logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: var(--fs-17); letter-spacing: -.02em; color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-mark {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .06), 0 6px 16px -6px rgba(37, 99, 235, .55);
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
    color: var(--muted); font-size: var(--fs-14); font-weight: 500;
    padding: 8px 12px; border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: rgba(15, 23, 42, .05); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 20px; border-radius: var(--radius-btn);
    font-weight: 600; font-size: var(--fs-15); line-height: 1; white-space: nowrap;
    border: 1px solid transparent; cursor: pointer;
    transition: transform .15s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12), 0 10px 30px -10px rgba(37, 99, 235, .6);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12), 0 14px 34px -10px rgba(37, 99, 235, .7);
}
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: rgba(15, 23, 42, .28); }
.btn-sm { padding: 8px 14px; font-size: var(--fs-14); }
.btn-sm svg { width: 16px; height: 16px; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 96px 0; }
.hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(800px 420px at 12% -10%, rgba(59, 130, 246, .16), transparent 60%),
        radial-gradient(700px 400px at 95% 10%, rgba(34, 211, 238, .14), transparent 60%);
}
.hero::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, .06) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
}
.hero-grid {
    position: relative;
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 64px; align-items: center;
}
.badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 8px; border-radius: 999px;
    border: 1px solid var(--success-line); background: var(--success-soft);
    color: var(--success-strong); font-size: var(--fs-13); font-weight: 600; letter-spacing: .01em;
}
.badge .dot {
    width: 8px; height: 8px; border-radius: 50%; background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .18);
}
.hero-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.live-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 8px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--muted); font-size: var(--fs-13); font-weight: 600; letter-spacing: .01em;
    box-shadow: var(--shadow-sm);
}
.live-pill:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none;
}
.live-pill.is-live {
    border-color: var(--success-line); background: var(--success-soft); color: var(--success-strong);
}
.live-pill.is-live:hover { border-color: var(--success); color: var(--success-strong); }
.live-pill.is-live .live-dot {
    background: #10b981;
    animation: live-pulse 1.8s ease-out infinite;
}
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); }
    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.live-pill.is-offline { color: var(--muted); }
.live-pill.is-offline .live-dot { background: #94a3b8; animation: none; }
h1 {
    margin: 20px 0 16px;
    font-size: clamp(2.5rem, 5.2vw, 3.75rem); line-height: 1.06;
    letter-spacing: -.035em; font-weight: 800;
}
.grad {
    background: linear-gradient(92deg, var(--accent) 0%, var(--teal) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: var(--fs-18); line-height: 1.55; color: var(--muted); max-width: 52ch; margin: 0 0 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }
.hero-installs { display: grid; gap: 8px; width: 100%; }
.hero-install {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 8px 8px 8px 16px; border-radius: var(--radius-md);
    border: 1px solid var(--code-edge); background: var(--code-bg);
    box-shadow: var(--shadow-md);
    font-family: var(--mono); font-size: var(--fs-14);
}
.hero-install code { flex: 1; min-width: 0; white-space: nowrap; overflow-x: auto; color: var(--code-text); }
.hero-install .copy-btn { flex: none; }

/* ---------- Terminal ---------- */
.terminal {
    background: var(--code-bg); color: var(--code-text);
    border: 1px solid var(--code-edge); border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-lg), 0 20px 60px -20px rgba(37, 99, 235, .18);
    font-family: var(--mono); font-size: var(--fs-13); line-height: 1.7;
}
.terminal-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; border-bottom: 1px solid var(--code-border);
    background: var(--code-head);
}
.terminal-bar em { margin: 0 auto; font-style: normal; color: var(--code-muted); font-size: var(--fs-12); }
/* macOS-style window dots, shared by the hero terminal and command blocks */
.dots { display: flex; align-items: center; gap: 8px; flex: none; }
.dots span { width: 12px; height: 12px; border-radius: 50%; }
.dots span:nth-child(1) { background: #ff5f57; }
.dots span:nth-child(2) { background: #febc2e; }
.dots span:nth-child(3) { background: #28c840; }
.terminal-screen { position: relative; height: 392px; padding: 16px 16px 12px; font-size: 12.5px; line-height: 1.45; }
.demo-shell, .demo-dash { position: absolute; inset: 16px 16px 12px; }
.demo-shell { font-size: 13.5px; }
.prompt { color: var(--code-prompt); font-weight: 600; user-select: none; }
.demo-cursor {
    display: inline-block; width: 8px; height: 1.05em; background: var(--code-text);
    vertical-align: text-bottom; margin-left: 1px; animation: blink 1s steps(2) infinite;
}
.demo-cursor.off { animation: none; opacity: 0; }
@keyframes blink { 50% { opacity: 0; } }
.demo-dash { display: flex; flex-direction: column; gap: 12px; opacity: 0; }
.demo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.demo-brand { font-weight: 700; letter-spacing: -.01em; }
.demo-brand .mark { color: var(--accent); margin-right: 6px; }
.demo-brand .sep { color: var(--code-muted); font-weight: 500; }
.demo-status { font-weight: 700; white-space: nowrap; }
.demo-status.connecting { color: #b45309; }
.demo-status.connected { color: var(--success); }
.demo-panel {
    position: relative; flex: 1; min-height: 0;
    border: 1px solid var(--code-edge); border-radius: 12px; padding: 16px 14px 12px;
}
.demo-panel-title {
    position: absolute; top: -0.65em; left: 14px; padding: 0 8px;
    background: var(--code-bg); color: #334155;
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
}
.demo-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; height: 100%; }
.demo-cols.with-qr { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.demo-label { margin-top: 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: #334155; }
.demo-label:first-child { margin-top: 0; }
.demo-url { color: var(--accent); font-weight: 700; word-break: break-all; }
.demo-url.wait { color: var(--code-muted); font-weight: 500; }
.demo-forward, .demo-latest, .demo-muted { color: var(--code-muted); }
.demo-latest.hit { color: var(--code-text); }
.demo-grow { flex: 1; }
.demo-details { display: flex; flex-direction: column; min-width: 0; min-height: 248px; }
.demo-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.demo-stats b { display: block; font-size: 18px; line-height: 1.1; color: var(--code-text); }
.demo-stats span { color: var(--code-muted); font-size: 12px; }
.demo-qr-col { width: 168px; text-align: center; opacity: 0; transform: translateY(6px); }
.demo-qr-col .demo-muted { font-size: 11px; white-space: nowrap; }
.demo-qr-col.show { opacity: 1; transform: none; transition: opacity .35s ease, transform .35s ease; }
.demo-qr-col .demo-label { margin-top: 0; }
.demo-qr {
    display: grid; width: 116px; height: 116px; margin: 8px auto 6px; padding: 6px;
    background: #fff; border: 1px solid var(--code-edge); border-radius: 4px;
}
.demo-qr i { display: block; background: #fff; }
.demo-qr i.on { background: #000; }
.demo-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0 2px 2px; color: var(--code-muted); font-size: 12px; }
.demo-legend kbd {
    display: inline-block; margin-right: 4px; padding: 0 5px;
    background: #0f172a; color: #fff; border-radius: 4px;
    font-family: inherit; font-weight: 800; font-size: 12px;
}

/* ---------- Sections ---------- */
.section { padding: 80px 0; border-top: 1px solid var(--border); }
.section-head { max-width: 720px; margin-bottom: 40px; }
.section-head h2 {
    margin: 0 0 12px;
    font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.15;
    letter-spacing: -.03em; font-weight: 700;
}
.section-head h2:last-child { margin-bottom: 0; }
.section-head p { color: var(--muted); font-size: var(--fs-17); line-height: 1.6; }
.section-head p + p { margin-top: 8px; }
.narrow { max-width: 760px; }

/* Features */
.features-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.feature {
    padding: 24px; border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .2s, transform .2s, box-shadow .2s;
}
.feature:hover {
    border-color: rgba(37, 99, 235, .35); transform: translateY(-2px);
    box-shadow: 0 20px 40px -24px rgba(37, 99, 235, .35);
}
.feature-icon {
    width: 40px; height: 40px; border-radius: var(--radius-btn); margin-bottom: 16px;
    display: grid; place-items: center;
    background: var(--accent-soft); border: 1px solid rgba(37, 99, 235, .18); color: var(--accent);
}
.feature-icon svg { width: 20px; height: 20px; }
.feature h3 { margin: 0 0 8px; font-size: var(--fs-17); line-height: 1.35; font-weight: 600; letter-spacing: -.01em; }
.feature p { color: var(--muted); font-size: var(--fs-15); line-height: 1.6; }
.feature p + p { margin-top: 12px; font-size: var(--fs-14); }

/* Code blocks */
.code-block {
    border: 1px solid var(--code-edge); border-radius: var(--radius-md); background: var(--code-bg); overflow: hidden;
    box-shadow: var(--shadow-md);
}
.code-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--code-border);
    background: var(--code-head);
}
.code-label { margin: 0; font-size: var(--fs-12); font-weight: 600; color: var(--code-muted); letter-spacing: .04em; text-transform: uppercase; }
.code-block pre {
    margin: 0; padding: 16px 20px; overflow-x: auto;
    font-family: var(--mono); font-size: var(--fs-14); line-height: 1.6; color: var(--code-text);
}
.code-block code { font-family: inherit; }
.copy-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--code-line); background: var(--code-bg);
    color: var(--code-muted); font: inherit; font-size: var(--fs-13); font-weight: 600; line-height: 1.2; cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
}
.copy-btn:hover { color: var(--code-text); border-color: rgba(15, 23, 42, .24); background: rgba(15, 23, 42, .04); }
.copy-btn svg { width: 15px; height: 15px; }
.copy-btn .ico-check { display: none; }
.copy-btn.copied { color: var(--success); border-color: var(--success-line); background: var(--success-soft); }
.copy-btn.copied .ico-copy { display: none; }
.copy-btn.copied .ico-check { display: block; }
.install-list { display: grid; gap: 16px; max-width: 760px; }
.install-standalone {
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    max-width: 760px; margin-top: 16px; padding: 20px;
}
.install-standalone > div { min-width: 0; flex: 1 1 320px; }
.install-standalone h3 { margin: 0 0 4px; font-size: var(--fs-17); line-height: 1.35; font-weight: 600; letter-spacing: -.01em; }
.install-standalone p { color: var(--muted); font-size: var(--fs-15); line-height: 1.6; }
.install-standalone .btn { flex: none; max-width: 100%; white-space: normal; line-height: 1.4; }
.inline {
    font-family: var(--mono); font-size: .9em; padding: 2px 6px; border-radius: 6px;
    background: rgba(15, 23, 42, .06); border: 1px solid var(--border); color: var(--text);
}
.note { color: var(--muted); font-size: var(--fs-15); margin: 16px 0 0; }

/* Self-hosting */
.selfhost-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 20px; align-items: start; }
.card {
    padding: 32px; border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.card p { margin: 0 0 16px; }
.card-title { font-weight: 600; }
.steps { list-style: none; margin: 0 0 24px; padding: 0; counter-reset: step; }
.steps li { position: relative; padding: 0 0 20px 44px; min-height: 28px; counter-increment: step; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
    content: counter(step);
    position: absolute; left: 0; top: -1px; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: var(--fs-13); font-weight: 700; color: var(--accent-hover);
    background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.steps li:not(:last-child)::after {
    content: ""; position: absolute; left: 13.5px; top: 29px; bottom: 2px; width: 1px;
    background: var(--border-strong);
}
.requirements h3 { margin: 0 0 8px; font-size: var(--fs-17); line-height: 1.35; font-weight: 600; letter-spacing: -.01em; }
.checklist { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.checklist li { position: relative; padding-left: 32px; }
.checklist li::before {
    content: ""; position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 6px;
    background: var(--success-soft); border: 1px solid var(--success-line);
}
.checklist li::after {
    content: ""; position: absolute; left: 7px; top: 6px; width: 5px; height: 9px;
    border: solid var(--success); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.muted { color: var(--muted); font-size: var(--fs-14); line-height: 1.6; }
.card .muted:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border); padding: 48px 0;
    background: var(--surface-2);
}
.footer-grid { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer-brand .logo { margin-bottom: 12px; }
.footer-brand p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-14); line-height: 1.6; }
.footer-links { display: flex; gap: 8px 24px; flex-wrap: wrap; align-content: flex-start; }
.footer-links a {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--muted); font-size: var(--fs-14); font-weight: 500;
    transition: color .15s;
}
.footer-links a:hover { color: var(--text); text-decoration: none; }
.footer-links svg { width: 16px; height: 16px; flex: none; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 60;
    transform: translate(-50%, 12px);
    padding: 10px 16px; border-radius: var(--radius-btn);
    background: var(--surface); border: 1px solid var(--success-line); color: var(--text);
    font-size: var(--fs-14); font-weight: 500;
    box-shadow: 0 10px 30px -10px rgba(15, 23, 42, .3);
    opacity: 0; pointer-events: none;
    transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .hero { padding: 64px 0; }
    .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
    .features-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .nav-links { display: none; }
}
@media (max-width: 760px) {
    .selfhost-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .section { padding: 64px 0; }
    .section-head { margin-bottom: 32px; }
    .features-grid { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 24px; }
    .hero-actions .btn { flex: 1; justify-content: center; }
    .hero-install { width: 100%; }
    .hero-install code { white-space: pre-wrap; word-break: break-all; }
    .terminal-screen { height: 560px; }
    .demo-cols.with-qr { grid-template-columns: minmax(0, 1fr); }
    .demo-qr-col { width: 100%; }
    .demo-qr-col .demo-muted { white-space: normal; }
    .demo-details { min-height: 0; }
    .code-block pre { white-space: pre-wrap; word-break: break-all; }
    .btn-sm span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .demo-cursor { animation: none; }
    .demo-qr-col { transition: none; }
    .btn:hover, .feature:hover { transform: none; }
    .live-pill.is-live .live-dot { animation: none; box-shadow: 0 0 0 4px rgba(16, 185, 129, .18); }
}
