:root {
    --bg: #ffffff;
    --bg-soft: #f6f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef2ff;
    --green: #059669;
    --green-soft: #ecfdf5;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --amber: #b45309;
    --amber-soft: #fffbeb;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f19;
        --bg-soft: #111827;
        --card: #131a2a;
        --text: #e5e7eb;
        --muted: #9ca3af;
        --line: #273044;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: #1e1b4b;
        --green: #34d399;
        --green-soft: #052e22;
        --red: #f87171;
        --red-soft: #3b0d0d;
        --amber: #fbbf24;
        --amber-soft: #3a2a05;
        --code-bg: #0a0e18;
        --shadow: none;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 2rem; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; letter-spacing: -.01em; margin-top: 1.6em; }
h3 { font-size: 1.1rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
code, pre { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: .86em; }
:not(pre) > code { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: .1em .35em; }
pre {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: var(--radius);
    padding: 16px 18px;
    overflow-x: auto;
    line-height: 1.55;
    margin: 0 0 1.2em;
}
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 28px; padding-bottom: 48px; width: 100%; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.logo:hover { text-decoration: none; color: var(--text); }
.logo.small { font-size: .95rem; }
.top-nav { display: flex; align-items: center; gap: 20px; }
.top-nav a:not(.btn) { color: var(--muted); font-weight: 500; }
.top-nav a:not(.btn).active, .top-nav a:not(.btn):hover { color: var(--text); text-decoration: none; }
.sub-nav { display: flex; gap: 4px; align-items: center; overflow-x: auto; }
.sub-nav a { padding: 10px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.sub-nav a:hover { color: var(--text); text-decoration: none; }
.sub-nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.sub-nav-user { margin-left: auto; color: var(--muted); font-size: .875rem; white-space: nowrap; padding-left: 12px; }
.sub-nav-user a { padding: 0; border: 0; }

/* buttons and forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--accent); color: #fff; border: 1px solid var(--accent);
    border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-small { padding: 6px 14px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--line); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
label { display: block; font-weight: 500; margin-bottom: 4px; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 14px; }
.field-error { color: var(--red); font-size: .85rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; flex: 1; min-width: 180px; }

/* notices */
.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.notice-ok { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.notice-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.notice-warn { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.notice-info { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.stat-note { color: var(--muted); font-size: .85rem; }
.meter { height: 8px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter.warn > span { background: var(--amber); }
.meter.full > span { background: var(--red); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.url { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: .78rem; font-weight: 600; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge-error { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge-warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar-free { fill: var(--line); }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: Inter, sans-serif; }

/* landing */
.hero { padding: 72px 0 56px; background: radial-gradient(1200px 400px at 50% -100px, var(--accent-soft), transparent); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.hero-grid > *, .grid > * { min-width: 0; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .hero { padding-top: 40px; } }
.hero h1 { font-size: 2.6rem; }
@media (max-width: 600px) { .hero h1 { font-size: 2rem; } }
.lead { font-size: 1.15rem; color: var(--muted); margin-bottom: 24px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.section { padding: 56px 0; }
.section-soft { background: var(--bg-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { margin-top: 0; }
.feature h3 { margin-top: 0; font-size: 1rem; }
.feature p { color: var(--muted); margin: 0; }
.feature-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; margin-bottom: 12px; }
.plan { display: flex; flex-direction: column; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-name { font-weight: 600; }
.plan-price { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 2px; }
.plan-price small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; flex: 1; }
.plan li { padding: 4px 0 4px 22px; position: relative; }
.plan li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.plan-per { color: var(--muted); font-size: .85rem; }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

/* code tabs */
.tabs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); margin-bottom: 1.2em; }
.tab-buttons { display: flex; gap: 2px; padding: 6px 6px 0; overflow-x: auto; background: var(--code-bg); border-bottom: 1px solid #1f2937; }
.tab-buttons button { background: transparent; border: 0; color: #94a3b8; font: 500 .85rem Inter, sans-serif; padding: 8px 12px; cursor: pointer; border-radius: 8px 8px 0 0; white-space: nowrap; }
.tab-buttons button.active { color: #fff; background: #1e293b; }
.tabs pre { margin: 0; border-radius: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* docs */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; padding-top: 32px; padding-bottom: 56px; }
.docs-nav { position: sticky; top: 80px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.docs-nav a { color: var(--muted); padding: 4px 0; }
.docs-nav a:hover { color: var(--text); }
@media (max-width: 860px) { .docs { grid-template-columns: 1fr; } .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 12px; } }
.endpoint { display: inline-flex; gap: 10px; align-items: center; font-family: "JetBrains Mono", monospace; font-size: .95rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.method { font-weight: 700; color: var(--green); }

/* auth */
.auth { max-width: 420px; margin: 48px auto; padding: 0 16px; }
.auth h1 { font-size: 1.6rem; }

/* key reveal */
.key-box { display: flex; gap: 8px; align-items: center; background: var(--bg-soft); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 12px; font-family: "JetBrains Mono", monospace; word-break: break-all; }
.key-box code { background: none; border: 0; flex: 1; font-size: .95rem; }

.footer { border-top: 1px solid var(--line); padding: 24px 0; margin-top: auto; }
.footer-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: .875rem; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
@media (max-width: 600px) { .top-nav { gap: 12px; } .top-nav a:not(.btn):first-child { display: none; } }
