:root {
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-2: #283548;
    --border: rgba(99, 102, 241, .15);
    --border-hover: rgba(99, 102, 241, .35);
    --primary: #6366F1;
    --primary-glow: rgba(99, 102, 241, .2);
    --accent: #A78BFA;
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --green: #4ADE80;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --transition: .25s ease
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    background-image: radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, .06) 0%, transparent 50%), radial-gradient(ellipse at 80% 100%, rgba(167, 139, 250, .04) 0%, transparent 50%)
}

.header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, .8);
    position: sticky;
    top: 0;
    z-index: 50
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem
}

.logo {
    display: flex;
    align-items: center;
    gap: .75rem
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, .1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 1.25rem
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.header-tagline {
    font-size: .8rem;
    color: var(--text-muted)
}

.main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    width: 100%
}

.builder-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 1.5rem;
    align-items: start
}

.output-panel {
    display: flex;
    flex-direction: column;
    gap: 0
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    animation: fadeIn .5s ease backwards
}

.section-title {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .85rem
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .85rem
}

.builder-actions {
    display: flex;
    gap: .35rem
}

/* Fields */
.fields-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 60px
}

.field-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all .15s ease
}

.field-row:hover {
    border-color: var(--primary)
}

.field-drag {
    color: var(--text-dim);
    font-size: .9rem;
    cursor: grab;
    user-select: none;
    flex-shrink: 0
}

.field-name {
    flex: 1;
    padding: .3rem .5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .8rem;
    outline: none;
    min-width: 0
}

.field-name:focus {
    border-color: var(--primary)
}

.field-type {
    padding: .3rem .5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .75rem;
    outline: none;
    cursor: pointer;
    min-width: 100px
}

.field-type:focus {
    border-color: var(--primary)
}

.field-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0
}

.field-remove:hover {
    background: rgba(248, 113, 113, .15);
    color: #F87171
}

.gen-settings {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    margin-top: 1rem;
    flex-wrap: wrap
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem
}

.form-group label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-muted)
}

.form-group input {
    padding: .45rem .65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .85rem;
    outline: none;
    width: 100px;
    transition: border-color var(--transition)
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

/* Output */
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem
}

.text-muted {
    font-size: .75rem;
    color: var(--text-muted)
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    max-height: 350px;
    overflow-y: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem
}

th {
    background: var(--surface-2);
    padding: .5rem .75rem;
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1
}

td {
    padding: .4rem .75rem;
    border-top: 1px solid var(--border)
}

tr:hover td {
    background: rgba(99, 102, 241, .04)
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: .85rem
}

/* Export */
.export-tabs {
    display: flex;
    gap: .35rem;
    margin-bottom: .75rem
}

.export-tab {
    padding: .3rem .65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    font-family: var(--font-sans)
}

.export-tab:hover,
.export-tab.active {
    background: rgba(99, 102, 241, .1);
    border-color: var(--primary);
    color: var(--text)
}

.code-output {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: .75rem;
    line-height: 1.6;
    color: var(--accent);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 260px;
    overflow-y: auto
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    padding: .6rem 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 16px var(--primary-glow)
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--primary-glow)
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .4rem .75rem
}

.btn--ghost:hover {
    background: rgba(99, 102, 241, .1);
    color: var(--text)
}

.btn--sm {
    font-size: .8rem;
    padding: .35rem .65rem
}

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap
}

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 100
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

.footer {
    text-align: center;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: .8rem
}

@media(max-width:900px) {
    .builder-layout {
        grid-template-columns: 1fr
    }

    .header {
        padding: 1rem
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: .25rem
    }

    .main {
        padding: 1rem
    }

    .gen-settings {
        flex-direction: column;
        align-items: stretch
    }

    .form-group input {
        width: 100%
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}