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

:root {
    --bg: #0f1117;
    --bg-surface: #1a1d27;
    --bg-hover: #242836;
    --border: #2e3344;
    --text: #e4e4e7;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 6px;
}

html.light {
    --bg: #f9fafb;
    --bg-surface: #ffffff;
    --bg-hover: #f3f4f6;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --danger: #dc2626;
    --danger-hover: #ef4444;
    --success: #16a34a;
    --warning: #d97706;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

.container { max-width: 480px; margin: 0 auto; padding: 2rem 1rem; }
.container-wide { max-width: 960px; margin: 0 auto; padding: 2rem 1rem; }

.portal-layout {
    display: flex;
    min-height: calc(100vh - 73px);
}

.portal-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
}

.sidebar-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

.sidebar-link:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.sidebar-link.active {
    color: var(--primary);
    font-weight: 600;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.portal-content {
    flex: 1;
    min-width: 0;
    padding: 2rem 1.5rem;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}

input[type="number"] {
    -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    display: inline-block;
    appearance: none;
    -webkit-appearance: none;
    padding: 0.5rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }

.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--danger);
}

.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--success);
}

nav {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

nav .brand { font-weight: 700; font-size: 1.125rem; }
nav .brand a { color: var(--text); }
nav .brand svg { height: 72px; width: auto; }
nav .nav-right { display: flex; gap: 0.75rem; align-items: center; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.25rem;
}

.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    text-decoration: none;
}
.theme-toggle:hover {
    background: var(--text);
    border-color: var(--text);
}
.theme-toggle:hover svg { color: var(--bg); }
.theme-toggle svg { color: var(--text-muted); transition: color 0.2s; }

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.875rem;
}
th { color: var(--text-muted); font-weight: 500; }

.tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.tag-off-topic { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.tag-on-topic { background: rgba(34, 197, 94, 0.15); color: var(--success); }

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.badge-verified { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }

.flex { display: flex; }
.flex-between { justify-content: space-between; align-items: center; }
.flex-gap { gap: 0.5rem; }

.form-group { margin-bottom: 1rem; }
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }

.code-block {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    padding-right: 2.5rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8125rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.code-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.code-block:hover .code-copy { opacity: 1; }
.code-copy:hover { background: var(--border); color: var(--text); }
.code-copy.copied { opacity: 1; color: var(--success); }

.sub-item { border-bottom: 1px solid var(--border); }
.sub-item:last-child { border-bottom: none; }
.sub-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    cursor: pointer;
}
.sub-row:hover { background: var(--bg-hover); margin: 0 -2rem; padding: 0.75rem 2rem; }
.sub-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sub-dot-on { background: var(--success); }
.sub-dot-off { background: var(--danger); }
.sub-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-date { flex-shrink: 0; }
.sub-detail { padding: 0 0 0.75rem 1.75rem; }
.sub-payload { background: var(--bg); border-radius: var(--radius); padding: 1rem; }
.sub-fields { width: 100%; border-collapse: collapse; }
.sub-fields td { padding: 0.375rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.sub-fields tr:last-child td { border-bottom: none; }
.sub-key { color: var(--text-muted); font-weight: 500; width: 160px; white-space: nowrap; }

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 22px;
    transition: 0.2s;
}
.switch .slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* Landing page */
.landing-nav {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.landing-nav .brand { font-weight: 700; font-size: 1.25rem; }
.landing-nav .brand a { color: var(--text); }
.landing-nav .brand svg { height: 72px; width: auto; }
.landing-nav .nav-links { display: flex; gap: 1rem; align-items: center; }
.landing-nav .nav-links a { color: var(--text-muted); font-size: 0.9375rem; }
.landing-nav .nav-links a:hover { color: var(--text); }

.hero {
    text-align: center;
    padding: 5rem 1rem 4rem;
    max-width: 640px;
    margin: 0 auto;
}
.hero h1 { font-size: 2.75rem; font-weight: 700; margin-bottom: 1rem; line-height: 1.15; }
.hero-sub { font-size: 1.125rem; color: var(--text-muted); margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

.power-strip {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.pill {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.works-with {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
    text-align: center;
}

.works-with-list {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.features {
    padding: 4rem 1rem;
    max-width: 960px;
    margin: 0 auto;
}
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}
.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.feature-card h3 { margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-muted); font-size: 0.9375rem; }

.steps {
    padding: 4rem 1rem;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}
.steps h2 { margin-bottom: 2rem; }
.step-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}
.step-num {
    width: 40px; height: 40px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.step h3 { margin-bottom: 0.25rem; }
.step p { color: var(--text-muted); font-size: 0.9375rem; }

.code-example {
    padding: 4rem 1rem;
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
}
.code-example h2 { margin-bottom: 1rem; }
.code-example .code-block { text-align: left; }

.use-cases {
    padding: 2rem 1rem 4rem;
    max-width: 960px;
    margin: 0 auto;
}
.use-cases h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.landing-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1rem 2rem;
    border-top: 1px solid var(--border);
}

.landing-footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1.5rem;
}

.landing-footer h3,
.landing-footer h4 {
    margin-bottom: 0.625rem;
}

.landing-footer h3 {
    font-size: 1.125rem;
}

.landing-footer h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.landing-footer a,
.landing-footer span {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

.landing-footer-bottom {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.cta {
    text-align: center;
    padding: 4rem 1rem 6rem;
    max-width: 480px;
    margin: 0 auto;
}
.cta h2 { margin-bottom: 0.5rem; }
.cta p { color: var(--text-muted); margin-bottom: 1.5rem; }
.cta-login { margin-top: 1rem; }

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
}
.tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.filter-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.5rem;
}
.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    gap: 0.5rem;
}
.filter-header:hover { background: var(--bg-hover); border-radius: var(--radius); }
.filter-header .filter-name { font-weight: 600; font-size: 0.9375rem; }
.filter-header .filter-mode {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: var(--bg-hover);
    color: var(--text-muted);
}
.filter-header .filter-actions { display: flex; gap: 0.375rem; align-items: center; }
.filter-body {
    display: none;
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border);
}
.filter-item.expanded .filter-body { display: block; }
.filter-item.disabled-filter { opacity: 0.6; }

.template-editor {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    min-height: 500px;
    resize: vertical;
    tab-size: 2;
}

.copyable {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}
.copyable:hover { background: var(--bg-hover); }
.copyable.copied { color: var(--success); }

@media (max-width: 640px) {
    .nav-toggle { display: flex; align-items: center; justify-content: center; }
    nav .nav-right,
    .landing-nav .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        padding: 1rem 2rem;
        gap: 0.75rem;
        z-index: 100;
    }
    nav.open .nav-right,
    .landing-nav.open .nav-links {
        display: flex;
    }
    nav { position: relative; }
    .landing-nav { position: relative; }
    .hero h1 { font-size: 1.75rem; }
    .container-wide { padding: 1rem 0.75rem; }
    .card { padding: 1.25rem; }
    .form-row { flex-direction: column; }

    .landing-footer-grid {
        grid-template-columns: 1fr 1fr;
    }
    .landing-footer-bottom {
        flex-direction: column;
    }

    .portal-layout { flex-direction: column; }
    .portal-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0;
    }
    .portal-sidebar .sidebar-heading { display: none; }
    .portal-sidebar .sidebar-links { display: flex; gap: 0; }
    .sidebar-link {
        padding: 0.75rem 1.25rem;
        border-bottom: 2px solid transparent;
        margin-bottom: -1px;
    }
    .sidebar-link.active {
        border-bottom-color: var(--primary);
    }
    .portal-content { padding: 1.25rem 0.75rem; }
}
