/* ---------- theme tokens ---------- */
:root {
    --bg: #0b0e14;
    --panel: #11151f;
    --panel-2: #171c28;
    --border: #232a3a;
    --text: #dbe2ee;
    --muted: #8a94a8;
    --green: #4ade80;
    --cyan: #38bdf8;
    --yellow: #fbbf24;
    --red: #f87171;
    --glow: rgba(56, 189, 248, 0.08);
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    --term-bg: #0a0c11;
    --sans: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f7f8fa;
        --panel: #ffffff;
        --panel-2: #eef1f5;
        --border: #d9dee8;
        --text: #1a2231;
        --muted: #5b6472;
        --green: #15803d;
        --cyan: #0369a1;
        --yellow: #a16207;
        --red: #dc2626;
        --glow: rgba(3, 105, 161, 0.06);
        --shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
        --term-bg: #ffffff;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --panel-2: #eef1f5;
    --border: #d9dee8;
    --text: #1a2231;
    --muted: #5b6472;
    --green: #15803d;
    --cyan: #0369a1;
    --yellow: #a16207;
    --red: #dc2626;
    --glow: rgba(3, 105, 161, 0.06);
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    --term-bg: #ffffff;
    color-scheme: light;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, var(--glow), transparent),
        var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.nav, .hero, main, .footer {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

code { font-family: var(--mono); }

/* ---------- nav ---------- */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
}

.logo {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-accent { color: var(--green); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link:hover { color: var(--text); }

.theme-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.theme-btn:hover { color: var(--text); border-color: var(--muted); }

/* ---------- hero ---------- */
.hero {
    text-align: center;
    padding-top: 3.5rem;
    padding-bottom: 1rem;
}

.hero h1 {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.accent { color: var(--green); }

.hero-sub {
    color: var(--muted);
    font-size: 1.05rem;
    margin: 1.25rem 0 2rem;
}

/* ---------- terminal ---------- */
.term {
    background: var(--term-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    text-align: left;
    margin: 1.25rem 0;
    box-shadow: var(--shadow);
}

.term-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 0.9rem;
}

.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: var(--red); }
.dot.y { background: var(--yellow); }
.dot.g { background: var(--green); }

.term-title {
    margin-left: 0.4rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.8rem;
}

.term-body {
    font-family: var(--mono);
    font-size: 0.86rem;
    color: var(--text);
    padding: 1rem 1.1rem;
}

.term-hero .term-body { height: 10.75em; overflow: hidden; }

.line { margin-bottom: 0.3rem; white-space: nowrap; overflow-x: auto; }
.line.out { color: var(--muted); }

.prompt { color: var(--green); }

.tag-info { color: var(--cyan); }
.tag-req  { color: var(--yellow); }
.tag-llm  { color: var(--green); }

.caret {
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background: var(--green);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- sections ---------- */
.section { padding: 2.5rem 0; }

.section h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 1.25rem;
}

.section-sub {
    color: var(--muted);
    margin: -0.75rem 0 1.25rem;
}

.caption {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 0.75rem;
}

.caption code, .section-sub code {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.85em;
}

/* ---------- diagram (inline svg) ---------- */
.diagram svg {
    display: block;
    width: 100%;
    height: auto;
}

.dg .box { fill: var(--panel); stroke: var(--border); stroke-width: 1.5; }
.dg .dashed { fill: transparent; stroke-dasharray: 6 5; }
.dg .ngbox { fill: var(--green); fill-opacity: 0.05; stroke: var(--green); stroke-width: 1.5; }
.dg .port { fill: var(--panel); stroke: var(--cyan); stroke-width: 2; }

.dg .t   { font-family: var(--sans); font-size: 16px; font-weight: 600; fill: var(--text); }
.dg .s   { font-family: var(--sans); font-size: 12.5px; fill: var(--muted); }
.dg .m   { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.dg .mg  { font-family: var(--mono); font-size: 15px; font-weight: 700; fill: var(--green); }
.dg .mc  { font-family: var(--mono); font-size: 13px; font-weight: 700; fill: var(--cyan); }
.dg .xs  { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.dg .lst { font-family: var(--mono); font-size: 11px; font-weight: 600; fill: var(--green); }
.dg .icon { font-size: 22px; }

.dg .ln  { fill: none; stroke: var(--muted); stroke-width: 1.5; marker-end: url(#arw); }
.dg .arw { fill: var(--muted); }

.dg .pulse-dot { fill: var(--green); animation: dotpulse 1.6s ease-out infinite; }

@keyframes dotpulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

/* ---------- example cards ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 620px) { .grid { grid-template-columns: 1fr; } }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem;
    transition: border-color 0.2s;
}

.card:hover { border-color: var(--green); }

.card-icon { font-size: 1.3rem; margin-bottom: 0.4rem; }

.card h3 { font-size: 1rem; margin-bottom: 0.5rem; }

.card-prompt {
    display: block;
    background: var(--term-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
    color: var(--green);
    margin-bottom: 0.55rem;
}

.card p { color: var(--muted); font-size: 0.85rem; }

/* ---------- code blocks ---------- */
.code-block {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 1rem 0;
    overflow: hidden;
}

.code-block pre {
    padding: 1rem 1.1rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
}

.c { color: var(--muted); }
.str { color: var(--green); }

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--panel-2);
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    cursor: pointer;
}

.copy-btn:hover { color: var(--text); border-color: var(--muted); }
.copy-btn.copied { color: var(--bg); background: var(--green); border-color: var(--green); }

/* ---------- protocols ---------- */
.proto-table {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-family: var(--mono);
    font-size: 0.78rem;
}

.proto-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    border-bottom: 1px solid var(--border);
}

.proto-row:last-child { border-bottom: none; }

.proto-row:nth-child(odd) { background: var(--panel); }

.proto-cat {
    color: var(--cyan);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.8rem;
    border-right: 1px solid var(--border);
}

.proto-list {
    color: var(--muted);
    padding: 0.5rem 0.8rem;
    word-spacing: 0.45em;
}

@media (max-width: 620px) {
    .proto-row { grid-template-columns: 96px 1fr; }
}

/* ---------- install ---------- */
.sub-h {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.25rem;
}

.sub-h:first-of-type { margin-top: 0; }

/* ---------- footer ---------- */
.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding-top: 2rem;
    padding-bottom: 2.5rem;
}

.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }
.sep { margin: 0 0.6rem; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .caret, .pulse-dot { animation: none; }
}
