:root {
    --bg-base: #0C1222;
    --bg-card: #141c2f;
    --bg-card-hover: #1a253c;

    --primary: #0EA5E9;
    --primary-hover: #0284c7;
    --secondary: #38BDF8;
    --accent: #10B981;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;

    --border-light: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(14, 165, 233, 0.5);

    --danger: #ef4444;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-code: 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Navbar */
.navbar {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(20, 28, 47, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary);
}

.logo svg {
    color: var(--secondary);
}

.logo strong {
    color: var(--text-main);
    font-weight: 600;
}

/* Main Layout */
.app-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.panel-left {
    width: 420px;
    min-width: 320px;
    border-right: 1px solid var(--border-light);
    background: var(--bg-base);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #080c17;
    /* slightly darker for preview area */
    padding: 1.5rem;
    gap: 1.5rem;
}

.scrollable {
    overflow-y: auto;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.card-header.minimal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header.minimal .card-title {
    margin-bottom: 0;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.row-align {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    color: #FFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--border-focus);
}

.error-text {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.hidden {
    display: none !important;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-light);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: #FFF;
}

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

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

.btn-outline:hover {
    background: rgba(14, 165, 233, 0.1);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.btn-icon:hover {
    color: #FFF;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    color: #ef4444;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

/* Dynamic List Iterators */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.empty-state {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem 0;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.list-item .input {
    padding: 0.4rem;
    font-size: 0.85rem;
}

/* Text Editors */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.code-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge.warn {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.code-editor {
    width: 100%;
    height: 180px;
    background: #050810;
    color: #e2e8f0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: var(--font-code);
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.code-editor:focus {
    border-color: var(--primary);
}

/* Right Panel Previews */
.preview-card {
    flex: 0 0 50%;
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 1;
    min-height: 200px;
    background: #ffffff;
    /* White background for preview realism */
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
}

.code-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-container {
    flex: 1;
    background: #050810;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow: auto;
}

.code-container pre,
.code-container code {
    font-family: var(--font-code);
    font-size: 0.85rem;
    color: #a5b4fc;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--accent);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
    z-index: 100;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
        overflow: auto;
    }

    .panel-left {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .preview-card {
        flex: 0 0 400px;
    }
}