:root {
    --bg-base: #050505;
    --text: #ffffff;
    --muted: #a1a1aa;
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent: #60a5fa;
    --link: #93c5fd;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;

    --radius: 16px;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-hover: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(16px);
}

:root {
    --vh: 100svh;
}

@supports (height: 100dvh) {
    :root {
        --vh: 100dvh;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0 0 4rem;
    background: var(--bg-base);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    overflow-wrap: break-word;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(37, 99, 235, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(37, 99, 235, 0.1) 0%, transparent 50%);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.container-wide {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {

    .container,
    .container-wide {
        padding: 2rem;
    }
}

/* --- Typography --- */
h1,
h2,
h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-top: 0;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.1;
}

h2 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 1.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2rem;
}

/* --- Navigation --- */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(5, 5, 5, 0.5);
    width: 100%;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .nav-links {
        gap: 0.75rem;
    }
}

@media (max-width: 400px) {
    .nav-links {
        gap: 0.5rem;
    }

    .nav-links a {
        font-size: 0.75rem;
    }
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    transition: all 0.3s;
}

.nav-links a:hover {
    opacity: 1;
    color: var(--link);
}

/* --- Components --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

@media (min-width: 768px) {
    .glass-panel {
        padding: 2.5rem;
    }
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.15);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: #fff;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    border: 1px solid rgba(59, 130, 246, 0.4);
    cursor: pointer;
    font-size: 0.9rem;
}

.primary-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--primary-glow);
    border-color: var(--primary);
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 480px) {

    .primary-btn,
    .secondary-btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

a {
    color: var(--link);
    transition: color 0.3s, text-decoration 0.3s;
    text-decoration: none;
}

a:not(.logo) :not(.nav-links a) :not(.primary-btn) :not(.secondary-btn) :not(.nav-btn) :not(.low-profile a):hover {
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--accent);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted);
    word-break: break-all;
}

input,
textarea,
select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

select option {
    background: #1e293b;
    color: var(--text);
    padding: 0.5rem;
}

select option:hover,
select option:focus,
select option:checked {
    background: #334155;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 4rem 0;
}

.feature-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: var(--radius);
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-10px);
    background: var(--glass-hover);
}

.feature-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.site-footer {
    padding: 3rem 1.5rem 4rem;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    margin-top: 6rem;
    background: rgba(5, 5, 5, 0.95);
    width: 100%;
    position: relative;
    z-index: 1;
}

.site-footer,
.site-footer * {
    text-align: center;
}

.low-profile {
    opacity: 0.6;
    font-size: 0.85rem;
}

.low-profile a {
    color: inherit;
}

.section-nav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
    -ms-overflow-style: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.section-nav::-webkit-scrollbar {
    display: block;
    height: 6px;
}

.section-nav::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.section-nav::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

.section-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.section-nav .nav-btn {
    text-decoration: none;
    color: var(--text);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    transition: all 0.3s;
    opacity: 0.7;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    pointer-events: auto;
}

.section-nav .nav-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.section-nav .nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.form-section {
    display: none;
}

.form-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.form-section-stack {
    margin-bottom: 2rem;
    scroll-margin-top: 100px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dynamic-list-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    flex-wrap: wrap;
    width: 100%;
}

.dynamic-list-item>div {
    flex: 1 1 150px;
}

.remove-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.preview-container {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-panel {
    position: sticky;
    top: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: calc(100vh - 40px);
}

@media (max-width: 1024px) {
    .preview-panel {
        position: static;
        max-height: none;
        height: auto;
        padding: 1rem;
    }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.json-badge {
    font-size: 0.75rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
}

.preview-actions {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.preview-note {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    margin: 0;
}

pre {
    background: #0f172a;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.8rem;
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    flex-grow: 1;
    margin: 0 0 1.5rem 0;
    border: 1px solid var(--glass-border);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.5;
    min-height: 300px;
    max-height: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

pre::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

pre::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 12px;
}

pre::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 12px;
    border: 2px solid #0f172a;
}

pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

pre::-webkit-scrollbar-corner {
    background: transparent;
    border-radius: 12px;
}

@media (min-width: 768px) {
    pre {
        padding: 1.5rem;
        font-size: 0.85rem;
        min-height: 400px;
    }
}

@media (min-width: 1025px) {
    pre {
        min-height: 0;
        flex: 1 1 auto;
    }
}

@media (max-width: 767px) {
    pre {
        height: auto;
        max-height: 50vh;
        min-height: 200px;
    }
}

/* --- Builder Layout: Centered and Symmetric --- */
.builder-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2rem;
    width: 100%;
    max-width: 1600px;
    padding: 2rem 1rem;
    margin: 0 auto;
}

@media (min-width: 1025px) {
    .builder-layout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 2.5rem;
        padding: 2rem 2rem;
    }
}

/* Form Scroll Area */
.form-scroll-area {
    width: 100%;
    max-width: 700px;
    height: auto;
    overflow: visible;
    padding-right: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

@media (min-width: 1025px) {
    .form-scroll-area {
        flex: 0 1 60%;
        max-width: 700px;
        height: calc(100vh - 200px);
        overflow: hidden;
        padding-right: 0;
    }

    .form-scroll-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 1.5rem;
        padding-top: 0;
        scrollbar-width: thin;
        scrollbar-color: var(--glass-border) transparent;
        position: relative;
    }

    .form-scroll-content::-webkit-scrollbar {
        width: 8px;
    }

    .form-scroll-content::-webkit-scrollbar-thumb {
        background: var(--glass-border);
        border-radius: 4px;
    }

    .form-scroll-content::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* Preview Sticky Side */
.preview-sticky-side {
    width: 100%;
    max-width: 500px;
    position: static;
    height: auto;
}

@media (min-width: 1025px) {
    .preview-sticky-side {
        flex: 0 0 40%;
        max-width: 500px;
        position: sticky;
        top: 100px;
        height: calc(100vh - 200px);
        align-self: flex-start;
    }
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
}

@media (max-width: 1024px) {
    .preview-panel {
        position: static;
        max-height: none;
        height: auto;
    }
}

/* Preview Actions */
.preview-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

@media (max-width: 768px) {
    nav {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.75rem 1rem;
    }

    .nav-links {
        gap: 0.75rem;
    }

    .nav-links a {
        font-size: 0.7rem;
    }

    h1 {
        font-size: clamp(2rem, 8vw, 2.5rem);
    }

    .section-nav {
        position: static !important;
        top: auto !important;
        margin-bottom: 2rem;
        padding: 0.75rem;
        background: rgba(5, 5, 5, 0.95);
        border-radius: 0;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        width: calc(100% + 1.5rem);
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .glass-panel {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .container-wide {
        padding: 0.75rem;
    }

    .builder-layout {
        gap: 1.5rem;
        padding: 1rem 0.75rem;
    }

    .form-scroll-area,
    .preview-sticky-side {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .nav-links {
        display: none;
    }

    .nav-links.show {
        display: flex;
    }
}

@media (max-width: 1024px) {
    .preview-container,
    .preview-panel,
    .preview-sticky-side {
        position: static !important;
        top: auto !important;
        max-height: none !important;
        height: auto !important;
    }
}

.page-header {
    margin: 2rem 0 3rem;
    text-align: center;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.muted-text {
    color: var(--muted);
}

.section-nav-sticky {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    pointer-events: auto;
    isolation: isolate;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
}

.add-item-btn {
    width: 100%;
    border-style: dashed;
    margin-top: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-inline {
    width: auto;
}

.color-picker-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.color-input {
    width: 64px;
    height: 48px;
    border: none;
    background: transparent;
    cursor: pointer;
}

.text-input-flex {
    flex-grow: 1;
}

.preview-title {
    margin: 0;
}

.full-width-btn {
    width: 100%;
}

.footer-text {
    text-align: center;
    margin: 0 auto;
}

.flex-1 {
    flex: 1;
}

.flex-2 {
    flex: 2;
}
