:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e5e5e5;
    --text: #1a1a1a;
    --text-muted: #6b6b6b;
    --text-softer: #8a8a8a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --green: #16a34a;
    --green-hover: #15803d;
    --red: #dc2626;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', monospace;
    --max-width: 1280px;
    --transition: 0.25s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0f0f;
        --surface: #1a1a1a;
        --border: #2e2e2e;
        --text: #e8e8e8;
        --text-muted: #a0a0a0;
        --text-softer: #7a7a7a;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --green: #22c55e;
        --green-hover: #4ade80;
        --red: #ef4444;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    max-width: var(--max-width);
    margin: 0 auto;
    gap: 16px;
}
.nav-logo {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-logo span {
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0;
}
.nav-cta {
    background: var(--accent);
    color: #fff !important;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background var(--transition);
}
.nav-cta:hover { background: var(--accent-hover); }

/* Hero */
.hero {
    max-width: 820px;
    margin: 60px auto 40px;
    padding: 0 24px;
    text-align: center;
}
.hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 16px;
}
.hero h1 .highlight {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 640px;
    margin: 0 auto 28px;
    line-height: 1.7;
}
.hero .btn-primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 14px 36px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: background var(--transition), transform 0.15s;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.hero .btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}
.hero .badge {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Features */
.features {
    max-width: var(--max-width);
    margin: 0 auto 56px;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 28px;
}
.feature-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform 0.15s;
}
.feature-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}
.feature-item h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.feature-item p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* Builder section */
.builder-head {
    max-width: 720px;
    margin: 0 auto 32px;
    padding: 0 24px;
    text-align: center;
}
.builder-head h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.builder-head p {
    color: var(--text-muted);
    font-size: 1rem;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    max-width: var(--max-width);
    margin: 0 auto 48px;
    padding: 0 24px;
}
@media (max-width: 860px) {
    .main-grid { grid-template-columns: 1fr; }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}
.card h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}
.card .subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Form */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.form-group textarea {
    resize: vertical;
    min-height: 56px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}
@media (max-width: 600px) { .form-row-3 { grid-template-columns: 1fr 1fr; } }

.file-fetch-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.file-fetch-group .form-group { flex: 1; min-width: 180px; margin-bottom:0; }
.fetch-btn {
    padding: 8px 12px;
    white-space: nowrap;
    height: 36px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.fetch-btn:hover { border-color: var(--accent); color: var(--accent); }
.fetch-btn:disabled { opacity:0.5; cursor:not-allowed; }
.spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.url-bar {
    display: flex;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-top: 16px;
    align-items: center;
}
.url-bar input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 6px 4px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.url-bar input:focus { outline: none; }
.url-bar button {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font);
    transition: background 0.15s;
}
.url-bar button:hover { background: var(--accent-hover); }
.url-bar button.copied { background: var(--green); }

.preview-frame {
    width: 100%;
    height: 600px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0d1117;
    overflow: hidden;
}
.preview-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
}
.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #8b949e;
    font-size: 0.9rem;
    text-align: center;
    padding: 24px;
}
.preview-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.preview-actions button {
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: all 0.15s;
}
.preview-actions button:hover { border-color: var(--accent); color: var(--accent); }

.integration {
    max-width: 720px;
    margin: 0 auto 56px;
    padding: 0 24px;
}
.integration h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}
.integration h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 6px;
}
.integration p {
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.7;
    font-size: 0.95rem;
}
.integration code {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    word-break: break-all;
}
.integration pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.55;
    margin-bottom: 16px;
    color: var(--text);
}
.integration .note {
    background: rgba(37, 99, 235, 0.04);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-softer);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    max-width: var(--max-width);
    margin: 0 auto;
}
.footer a {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.footer a:hover { color: var(--accent); }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 999;
    font-family: var(--font);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.section-divider {
    max-width: var(--max-width);
    margin: 0 auto 48px;
    padding: 0 24px;
    border-top: 1px solid var(--border);
}

/* Hidden widget mode */
body.widget-mode .nav,
body.widget-mode .hero,
body.widget-mode .features,
body.widget-mode .builder-head,
body.widget-mode .main-grid,
body.widget-mode .integration,
body.widget-mode .footer,
body.widget-mode .section-divider {
    display: none;
}
body.widget-mode {
    background: #0d1117;
    overflow: hidden;
    height: 100dvh;
}
#widget-root { display: none; height: 100dvh; }
body.widget-mode #widget-root { display: block; }
