:root {
    /* Color Palette */
    --bg-dark: #09090b;
    --bg-card: #121216;
    --bg-surface: #1a1a20;
    --bg-hover: #22222a;
    
    --border-light: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(255, 255, 255, 0.2);
    
    --text-primary: #ededed;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent: #e2e2e2;
    --accent-hover: #ffffff;
    
    /* Code Editor Colors */
    --syntax-key: #a78bfa;     /* Purple */
    --syntax-string: #fde047;  /* Yellow */
    --syntax-number: #6ee7b7;  /* Green */
    --syntax-boolean: #fca5a5; /* Red-ish */
    --syntax-null: #9ca3af;    /* Gray */
    --syntax-bg: #0d0d10;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* SVG Standardize */
svg { width: 1.25rem; height: 1.25rem; vertical-align: middle; }

/* =======================================
   Header & Nav
   ======================================= */
.app-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem 2rem;
    gap: 2rem;
    border-bottom: 1px solid var(--border-light);
    background: radial-gradient(circle at top, rgba(30, 30, 38, 0.5) 0%, var(--bg-dark) 100%);
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.8rem;
}

.brand-logo {
    width: 3.5rem;
    height: 3.5rem;
    color: var(--text-primary);
}

.brand-text h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
    background: linear-gradient(180deg, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.tool-nav {
    display: flex;
    background: var(--bg-card);
    padding: 0.4rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    gap: 0.25rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.install-float {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(18, 18, 22, 0.92);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    padding: 0.25rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
}

.install-float-action {
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.42rem 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
}

.install-float-action:hover {
    background: var(--bg-surface);
}

.install-float-action svg {
    width: 1rem;
    height: 1rem;
}

.install-float-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.install-float-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.install-float.icon-only .install-float-text,
.install-float.icon-only .install-float-close {
    display: none;
}

.install-float.icon-only .install-float-action {
    padding: 0.45rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.nav-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

/* =======================================
   Main Content
   ======================================= */
.content-container {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.tool-view {
    display: none;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tool-view.active {
    display: block;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Centered Utilities (Merge, Split) */
.centered-tool {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 0.5rem;
}
.tool-header h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.tool-header p { color: var(--text-secondary); font-size: 0.95rem; }

/* Buttons */
.primary-btn {
    background: var(--text-primary);
    color: var(--bg-dark);
    border: none;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    width: 100%;
}
.primary-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,255,255,0.1);
}
.primary-btn:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: not-allowed;
}

.ghost-btn, .secondary-btn {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ghost-btn:hover, .secondary-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

.icon-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.icon-btn.danger-hover:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Card Boxes */
.card-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

/* Inputs & Forms */
.modern-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}
.modern-input:focus {
    border-color: var(--border-focus);
    background: var(--bg-surface);
}

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Editor Styles */
.editor-wrap {
    background: var(--syntax-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    height: 65vh;
    display: flex;
    flex-direction: column;
}

.editor-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-surface);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    font-family: inherit;
}

.window-controls {
    display: flex;
    gap: 6px;
    margin-left: 1rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.close { background: #ed6a5e; }
.dot.minimize { background: #f4bf4f; }
.dot.maximize { background: #61c554; }

.file-name {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn.active {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.line-numbers {
    padding: 1rem 0.5rem 1rem 0.75rem;
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    border-left: 1px solid var(--bg-surface);
    min-width: 52px;
    white-space: pre;
    overflow: hidden;
}

.code-area {
    position: relative;
    flex: 1;
}

textarea#json-input, pre#highlight-layer {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: none;
    overflow: auto;
    white-space: pre;
    direction: ltr;
    text-align: left;
}

textarea#json-input {
    background: transparent;
    color: transparent;
    caret-color: var(--text-primary);
    resize: none;
    outline: none;
    z-index: 2;
}

pre#highlight-layer {
    background: transparent;
    color: var(--text-primary);
    z-index: 1;
    pointer-events: none;
}

.syntax-key { color: var(--syntax-key); }
.syntax-string { color: var(--syntax-string); }
.syntax-number { color: var(--syntax-number); }
.syntax-boolean { color: var(--syntax-boolean); }
.syntax-null { color: var(--syntax-null); }

.editor-status-bar {
    height: 30px;
    border-top: 1px solid var(--bg-surface);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.status-pill {
    padding: 0.16rem 0.45rem;
    border-radius: 999px;
    border: 1px solid transparent;
    line-height: 1;
}

.status-pill.status-valid {
    color: #86efac;
    border-color: rgba(134, 239, 172, 0.4);
    background: rgba(34, 197, 94, 0.12);
}

.status-pill.status-invalid {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.4);
    background: rgba(239, 68, 68, 0.12);
}


/* Drag & Drop Upload Areas */
.dragger-box input[type="file"] {
    display: none;
}
.dragger-box label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: var(--bg-card);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    gap: 1rem;
}
.dragger-box label svg { width: 2.5rem; height: 2.5rem; color: var(--text-muted); }
.dragger-box label:hover {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
    color: var(--text-primary);
}
.dragger-box label:hover svg { color: var(--text-primary); }

.dragger-box.drag-active label {
    border-color: var(--text-secondary);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.dragger-box.drag-active label svg { color: var(--text-primary); }

.file-list-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}
ul#merge-file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
ul#merge-file-list li {
    background: var(--bg-surface);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    direction: ltr;
}
ul#merge-file-list li::before {
    content: "📄";
    font-size: 0.9rem;
}

/* Radio Buttons */
.radio-group { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}
.radio-label input { display: none; }
.custom-radio {
    width: 18px; height: 18px;
    border: 1px solid var(--border-focus);
    border-radius: 50%;
    position: relative;
    transition: var(--transition);
}
.radio-label input:checked + .custom-radio { border-color: var(--accent); }
.radio-label input:checked + .custom-radio::after {
    content: ''; position: absolute;
    inset: 4px; border-radius: 50%; background: var(--text-primary);
}
.split-controls { transition: var(--transition); }
.selected-file-label { text-align: center; color: var(--syntax-number); font-size: 0.9rem; font-family: 'JetBrains Mono', monospace; direction: ltr; }


/* Create View (Builder) */
.create-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.create-header h2 { font-size: 1.75rem; font-weight: 600; }

.create-layout {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 1.5rem;
    align-items: start;
}

@media(max-width: 900px) {
    .create-layout { grid-template-columns: 1fr; }
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.list-controls { display: flex; gap: 0.25rem; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    gap: 0.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-light);
}
.empty-state svg { width: 2rem; height: 2rem; opacity: 0.5; }
.empty-state.small { padding: 1.5rem; font-size: 0.9rem; border: none; background: transparent; }

.examples-container {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

ul#examples-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
ul#examples-list li {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.example-json {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
}

.multiline {
    resize: vertical;
    min-height: 84px;
}

.nested-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.nested-input {
    margin-top: 0.5rem;
}

.nested-repeat-block {
    margin-top: 0.7rem;
    padding: 0.55rem;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
}

.submit-card-btn { margin-top: auto; }


/* Modal Settings */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.modal-box {
    background: var(--bg-card);
    width: 100%;
    max-width: 450px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    transform: scale(0.95);
    transition: var(--transition);
}
.modal-overlay.open .modal-box { transform: scale(1); }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 500; }

.modal-body { padding: 1.5rem; }
.add-field-row { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }

h4 { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.75rem; font-weight: 500; }

ul#active-fields-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
ul#active-fields-list li {
    background: var(--bg-surface);
    padding: 0.5rem 0.75rem 0.5rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    direction: ltr;
}