:root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --brand-primary: #2563eb;
    --brand-hover: #1d4ed8;
    --danger: #ff1616;
    --danger-high: #af0606;
    --border-light: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    padding: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--brand-primary);
}

.btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--brand-hover);
}

.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.container {
    flex: 1;
    width: 100%;
    max-width: 85%;
    margin: 20px auto;
    padding: 0 20px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

/* Builder Specifics */
.toolbox-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: var(--radius);
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    transition: border-color 0.2s;
}

.toolbox-item:hover {
    border-color: var(--brand-primary);
}

.canvas-block {
    background: white;
    border: 1px solid var(--border-light);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: var(--radius);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.canvas-block:hover {
    border-color: var(--brand-primary);
}

.block-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.block-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.8rem;
}

.block-btn:hover {
    background: #e2e8f0;
}

.btn-delete:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #ef4444;
}

.block-input {
    width: 100%;
    border: none;
    outline: none;
    font-family: inherit;
    background: transparent;
    resize: vertical;
}

.block-input.heading {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-main);
}

.block-input.paragraph {
    font-size: 1rem;
    color: var(--text-main);
    min-height: 80px;
}

.block-input.image-url {
    border: 1px solid var(--border-light);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}

:root {
    --brand-primary: #4f46e5;
    --brand-hover: #4338ca;
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-light: #e2e8f0;
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- Header --- */
header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brand-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    margin-left: 20px;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--brand-primary);
}

.btn {
    display: inline-block;
    background: var(--brand-primary);
    color: white !important;
    padding: 10px 20px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--brand-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-main) !important;
    border: 1px solid var(--border-light);
}


.btn-outline:hover {
    background: var(--border-light);
}

.btn-warning {
    background: var(--danger);
    color: white !important;
    border: 1px solid var(--border-light);
}

.btn-warning:hover {
    background: var(--danger-high);
}

/* --- Hero Section --- */
.hero {
    padding: 100px 0;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-main) 100%);
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    letter-spacing: -1px;
    color: var(--text-main);
}

.hero h1 span {
    color: var(--brand-primary);
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 40px auto;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* --- Code Showcase --- */
.code-showcase {
    margin: -40px auto 60px auto;
    max-width: 800px;
    background: #1e293b;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    overflow: hidden;
    text-align: left;
}

.code-header {
    background: #0f172a;
    padding: 10px 15px;
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ef4444;
}

.dot.yellow {
    background: #f59e0b;
}

.dot.green {
    background: #10b981;
}

.code-body {
    padding: 20px;
    color: #f8fafc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95rem;
    overflow-x: auto;
}

.code-keyword {
    color: #c678dd;
}

.code-string {
    color: #98c379;
}

.code-func {
    color: #61afef;
}

/* --- Features Section --- */
.features {
    padding: 80px 0;
    background: var(--bg-surface);
}

.section-title {
    text-align: center;
    margin-bottom: 60px;
}

.section-title h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.section-title p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.feature-card {
    padding: 30px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-main);
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 20px;
    display: inline-block;
}

.feature-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--text-muted);
    margin: 0;
}

/* --- CTA Section --- */
.cta {
    padding: 100px 0;
    text-align: center;
    background: var(--brand-primary);
    color: white;
}

.cta h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: white;
}

.cta p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 40px;
}

.cta .btn {
    background: white;
    color: var(--brand-primary) !important;
}

.cta .btn:hover {
    background: #f8fafc;
}

/* --- Alerts & Flash Messages --- */
.alert {
    padding: 15px 40px 15px 15px;
    /* Extra right padding for the close button */
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.95rem;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #f87171;
}

.alert-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #34d399;
}

.alert-close {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    color: inherit;
    padding: 0;
}

.alert-close:hover {
    opacity: 1;
}



/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

/* Hide mobile toggle on desktop */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-main);
}

@media (max-width: 768px) {

    /* Navbar Stacking */
    .mobile-menu-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        /* Hidden by default on mobile, toggled via JS */
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 70px;
        left: 0;
        background: var(--bg-surface);
        padding: 20px;
        border-bottom: 1px solid var(--border-light);
        box-shadow: var(--shadow-md);
        gap: 15px;
    }

    .nav-links.active {
        display: flex;
    }

    /* Grid & Layout Adjustments */
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .card {
        padding: 15px;
    }

    /* Forms */
    form[style*="display: flex"] {
        flex-direction: column;
        align-items: stretch !important;
    }

    .btn {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    /* Modals */
    .modal-content {
        min-width: 90vw;
        margin: 20px;
        padding: 15px;
    }
}

dialog {
    border: none;
    padding: 0;
    background: transparent;
    margin: auto;
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--bg-surface);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    min-width: 350px;
    max-width: 450px;
    border: 1px solid var(--border-light);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-surface);
    min-width: 220px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    top: 100%;
    left: 0;
    overflow: hidden;
}

.nav-links .dropdown-content a {
    color: var(--text-main);
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
    font-weight: 500;
}

.nav-links .dropdown-content a:last-child {
    border-bottom: none;
}

.nav-links .dropdown-content a:hover {
    background-color: #f8fafc;
    color: var(--brand-primary);
}

.dropdown-content.show {
    display: block;
}

/* Desktop Hover Dropdown */
@media (min-width: 769px) {
    .dropdown:hover .dropdown-content {
        display: block;
    }
}

/* Mobile Responsive Menu Updates */
@media (max-width: 768px) {
    .navbar {
        position: relative;
    }

    .nav-links.active {
        position: absolute;
        top: 100%;
        /* Drops the menu just below the navbar */
        left: 0;
        width: 100%;
        background-color: var(--bg-surface);
        flex-direction: column;
        align-items: flex-end;
        padding: 15px 20px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border-top: 1px solid var(--border-light);
        z-index: 1000;
        gap: 15px;
    }

    .nav-links.active a {
        width: 100%;
        display: block;
        text-align: right;
    }

    .nav-links.active .dropdown {
        width: 100%;
        text-align: right;
    }

    .nav-links.active .dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        border-right: 2px solid var(--border-light);
        border-radius: 0;
        margin-top: 10px;
        padding-right: 10px;
    }

    .nav-links.active form {
        width: 100%;
        text-align: right;
    }
}