/* ═══════════════════════════════════════════════════════════════
   JSON 13 — Design System & Styles
   🔪 Slasher-themed JSON Visualizer with Temperature Hierarchy
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Surface colors — deep dark horror */
    --bg-deep: #08060c;
    --bg-surface: #110e18;
    --bg-elevated: #1a1524;
    --bg-hover: #241e30;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.12);

    /* Text */
    --text-primary: #ece8f4;
    --text-secondary: #9e94b8;
    --text-muted: #5e5680;

    /* === TEMPERATURE HIERARCHY COLORS ===
       HOT (depth 0 = root) → COLD (depth 7+ = deep)
       Creates a visual "storytelling" heat map
    */
    /* Depth 0 — Inferno 🔥 */
    --temp-0-bg: rgba(220, 38, 38, 0.18);
    --temp-0-border: rgba(239, 68, 68, 0.5);
    --temp-0-accent: #ef4444;
    --temp-0-glow: rgba(239, 68, 68, 0.12);
    --temp-0-text: #fca5a5;

    /* Depth 1 — Lava 🌋 */
    --temp-1-bg: rgba(234, 88, 12, 0.16);
    --temp-1-border: rgba(249, 115, 22, 0.5);
    --temp-1-accent: #f97316;
    --temp-1-glow: rgba(249, 115, 22, 0.1);
    --temp-1-text: #fdba74;

    /* Depth 2 — Amber 🔶 */
    --temp-2-bg: rgba(217, 169, 10, 0.14);
    --temp-2-border: rgba(234, 179, 8, 0.45);
    --temp-2-accent: #eab308;
    --temp-2-glow: rgba(234, 179, 8, 0.08);
    --temp-2-text: #fde047;

    /* Depth 3 — Lime ☀️ */
    --temp-3-bg: rgba(132, 204, 22, 0.12);
    --temp-3-border: rgba(163, 230, 53, 0.4);
    --temp-3-accent: #84cc16;
    --temp-3-glow: rgba(132, 204, 22, 0.08);
    --temp-3-text: #bef264;

    /* Depth 4 — Emerald 🌿 */
    --temp-4-bg: rgba(16, 185, 129, 0.13);
    --temp-4-border: rgba(52, 211, 153, 0.45);
    --temp-4-accent: #10b981;
    --temp-4-glow: rgba(16, 185, 129, 0.08);
    --temp-4-text: #6ee7b7;

    /* Depth 5 — Cyan 🧊 */
    --temp-5-bg: rgba(6, 182, 212, 0.14);
    --temp-5-border: rgba(34, 211, 238, 0.45);
    --temp-5-accent: #06b6d4;
    --temp-5-glow: rgba(6, 182, 212, 0.08);
    --temp-5-text: #67e8f9;

    /* Depth 6 — Blue 💎 */
    --temp-6-bg: rgba(59, 130, 246, 0.14);
    --temp-6-border: rgba(96, 165, 250, 0.45);
    --temp-6-accent: #3b82f6;
    --temp-6-glow: rgba(59, 130, 246, 0.1);
    --temp-6-text: #93c5fd;

    /* Depth 7 — Frost ❄️ */
    --temp-7-bg: rgba(139, 92, 246, 0.14);
    --temp-7-border: rgba(167, 139, 250, 0.45);
    --temp-7-accent: #8b5cf6;
    --temp-7-glow: rgba(139, 92, 246, 0.1);
    --temp-7-text: #c4b5fd;

    /* Type value colors */
    --type-string: #4ade80;
    --type-number: #60a5fa;
    --type-boolean: #fb923c;
    --type-null: #f87171;
    --type-key: #e8e8f0;

    /* Selection — #8a0303 (Sangue) */
    --select-bg: #8a0303;
    --select-border: #b80d0d;
    --select-glow: rgba(138, 3, 3, 0.6);
    --select-accent: #ff1a1a;

    /* Glass */
    --glass-bg: rgba(17, 14, 24, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 24px;

    /* Spacing */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

    /* Radius */
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms; --duration-normal: 250ms; --duration-slow: 400ms;

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-horror: 'Creepster', cursive;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ─── Ambient Background ────────────────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
    background-size: 48px 48px;
    z-index: 0;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(130px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: glowFloat 25s ease-in-out infinite;
}
.bg-glow--1 {
    width: 600px; height: 600px;
    background: #dc2626;
    top: -200px; left: -100px;
    animation-delay: 0s;
}
.bg-glow--2 {
    width: 500px; height: 500px;
    background: #7c3aed;
    bottom: -150px; right: -100px;
    animation-delay: -8s;
}
.bg-glow--3 {
    width: 400px; height: 400px;
    background: #b91c1c;
    top: 50%; left: 50%;
    animation-delay: -16s;
}

@keyframes glowFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -20px) scale(1.05); }
    50% { transform: translate(-20px, 30px) scale(0.95); }
    75% { transform: translate(10px, 20px) scale(1.02); }
}

/* ─── Glass Panel ───────────────────────────────────────────── */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    position: relative;
    z-index: 1;
}

/* ─── Layout ────────────────────────────────────────────────── */
#app-header {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: var(--sp-10) var(--sp-6) var(--sp-5);
}

.header-inner {
    max-width: 700px;
    margin: 0 auto;
}

/* ─── Logo — Jason Mask Image ───────────────────────────────── */
.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-5);
    margin-bottom: var(--sp-2);
}

.logo-mask-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.4))
            drop-shadow(0 0 40px rgba(239, 68, 68, 0.15));
    animation: maskPulse 3s ease-in-out infinite;
    border-radius: 50%;
}

@keyframes maskPulse {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.4)) drop-shadow(0 0 40px rgba(239, 68, 68, 0.15)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 30px rgba(239, 68, 68, 0.6)) drop-shadow(0 0 60px rgba(239, 68, 68, 0.3)); transform: scale(1.05); }
}

.logo h1 {
    font-family: var(--font-horror);
    font-size: 3rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}
.logo h1 span {
    color: #ef4444;
    text-shadow:
        0 0 20px rgba(239, 68, 68, 0.6),
        0 0 40px rgba(239, 68, 68, 0.3);
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.93rem;
    font-weight: 400;
}

/* ─── Temperature Legend ────────────────────────────────────── */
.temp-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
    font-size: 0.78rem;
}
.temp-legend-label {
    color: var(--text-muted);
    font-weight: 500;
}
.temp-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.temp-hot { color: #fca5a5; font-size: 0.75rem; }
.temp-cold { color: #c4b5fd; font-size: 0.75rem; }
.temp-gradient {
    width: 200px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        #ef4444,
        #f97316,
        #eab308,
        #84cc16,
        #10b981,
        #06b6d4,
        #3b82f6,
        #8b5cf6
    );
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2), 0 0 12px rgba(139, 92, 246, 0.2);
}

/* ─── Main ──────────────────────────────────────────────────── */
#app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--sp-6) var(--sp-12);
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    position: relative;
    z-index: 1;
}

/* ─── Input Section ─────────────────────────────────────────── */
#input-section { padding: var(--sp-5); }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
    gap: var(--sp-3);
}
.section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.section-actions { display: flex; gap: var(--sp-2); }

/* ─── Textarea ──────────────────────────────────────────────── */
.textarea-wrap {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    transition: border-color var(--duration-normal) var(--ease-out);
    background: rgba(0, 0, 0, 0.3);
}
.textarea-wrap:focus-within {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Drag & Drop states */
.textarea-wrap.drag-active {
    border-color: #fbbf24 !important;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.25), 0 0 30px rgba(251, 191, 36, 0.1) !important;
}

.drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 6, 12, 0.85);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-md);
    animation: dropFadeIn 0.2s var(--ease-out);
}
.drop-overlay.hidden { display: none; }

.drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-8);
    border: 2px dashed rgba(251, 191, 36, 0.5);
    border-radius: var(--radius-lg);
    color: #fbbf24;
    animation: dropPulse 1.5s ease-in-out infinite;
}
.drop-overlay-content svg {
    opacity: 0.8;
    animation: dropBounce 1s ease-in-out infinite;
}
.drop-overlay-content span {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
}
.drop-overlay-content small {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

@keyframes dropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes dropPulse {
    0%, 100% { border-color: rgba(251, 191, 36, 0.5); }
    50% { border-color: rgba(251, 191, 36, 0.9); }
}
@keyframes dropBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

#json-input {
    width: 100%;
    min-height: 200px;
    max-height: 400px;
    resize: vertical;
    padding: var(--sp-4) var(--sp-5);
    padding-left: 56px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    tab-size: 2;
}
#json-input::placeholder { color: var(--text-muted); }

.textarea-line-numbers {
    position: absolute;
    top: 0; left: 0;
    width: 44px; height: 100%;
    padding: var(--sp-4) var(--sp-2);
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.7;
    color: var(--text-muted);
    border-right: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
    overflow: hidden;
    user-select: none;
}

/* ─── Error Bar ─────────────────────────────────────────────── */
.error-bar {
    display: flex; align-items: center; gap: var(--sp-2);
    margin-top: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    animation: shakeIn 0.4s var(--ease-spring);
}
.error-bar.hidden { display: none; }
@keyframes shakeIn {
    0% { transform: translateX(-8px); opacity: 0; }
    50% { transform: translateX(4px); }
    100% { transform: translateX(0); opacity: 1; }
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
    user-select: none;
}
.btn:active { transform: scale(0.96); }

.btn--primary {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.35);
}
.btn--primary:hover {
    box-shadow: 0 4px 24px rgba(220, 38, 38, 0.5);
    transform: translateY(-1px);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}
.btn--ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.btn--sm { padding: var(--sp-1) var(--sp-3); font-size: 0.78rem; }

.btn--export-main {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.4), rgba(127, 29, 29, 0.25));
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
    font-weight: 600;
}
.btn--export-main:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.6), rgba(153, 27, 27, 0.4));
    box-shadow: 0 0 18px rgba(220, 38, 38, 0.35);
    color: #ffffff;
}
.btn--export-main:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─── Toolbar ───────────────────────────────────────────────── */
#toolbar {
    padding: var(--sp-3) var(--sp-5);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: var(--sp-3);
    animation: fadeSlideIn 0.3s var(--ease-out);
}
#toolbar.hidden { display: none; }

.toolbar-left, .toolbar-right {
    display: flex; align-items: center; gap: var(--sp-2);
}
.toolbar-divider {
    width: 1px; height: 20px;
    background: var(--border-subtle);
    margin: 0 var(--sp-1);
}

.search-wrap {
    display: flex; align-items: center; gap: var(--sp-2);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-3);
    transition: border-color var(--duration-fast) var(--ease-out);
}
.search-wrap:focus-within { border-color: #ef4444; }
.search-wrap svg { color: var(--text-muted); flex-shrink: 0; }

#search-input {
    background: transparent; border: none; outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    width: 180px;
}
#search-input::placeholder { color: var(--text-muted); }

.stats {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

/* ─── Output Section ────────────────────────────────────────── */
#output-section {
    position: relative; z-index: 1;
    animation: fadeSlideIn 0.4s var(--ease-out);
}
#output-section.hidden { display: none; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   JSON TREE — LEGO BLOCKS WITH TEMPERATURE COLORS
   ═══════════════════════════════════════════════════════════════ */
#json-tree {
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.6;
}

/* ── Block Container ──────────────────────────────────────── */
.jb {
    position: relative;
    margin: var(--sp-2) 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--duration-normal) var(--ease-out);

    /* Default — will be overridden by depth */
    background: var(--temp-bg);
    border: 1.5px solid var(--temp-border);
    box-shadow: 0 2px 8px var(--temp-glow), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* LEGO nub — thick colored bar on the left */
.jb::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 5px;
    background: var(--temp-accent);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    transition: width var(--duration-fast) var(--ease-out);
}

.jb:hover {
    box-shadow: 0 4px 20px var(--temp-glow), 0 0 0 1px var(--temp-border);
    z-index: 2;
}
.jb:hover::before {
    width: 7px;
}

/* ── Depth Temperature Assignment ─────────────────────────── */
.jb[data-depth="0"] {
    --temp-bg: var(--temp-0-bg); --temp-border: var(--temp-0-border);
    --temp-accent: var(--temp-0-accent); --temp-glow: var(--temp-0-glow);
    --temp-text: var(--temp-0-text);
}
.jb[data-depth="1"] {
    --temp-bg: var(--temp-1-bg); --temp-border: var(--temp-1-border);
    --temp-accent: var(--temp-1-accent); --temp-glow: var(--temp-1-glow);
    --temp-text: var(--temp-1-text);
}
.jb[data-depth="2"] {
    --temp-bg: var(--temp-2-bg); --temp-border: var(--temp-2-border);
    --temp-accent: var(--temp-2-accent); --temp-glow: var(--temp-2-glow);
    --temp-text: var(--temp-2-text);
}
.jb[data-depth="3"] {
    --temp-bg: var(--temp-3-bg); --temp-border: var(--temp-3-border);
    --temp-accent: var(--temp-3-accent); --temp-glow: var(--temp-3-glow);
    --temp-text: var(--temp-3-text);
}
.jb[data-depth="4"] {
    --temp-bg: var(--temp-4-bg); --temp-border: var(--temp-4-border);
    --temp-accent: var(--temp-4-accent); --temp-glow: var(--temp-4-glow);
    --temp-text: var(--temp-4-text);
}
.jb[data-depth="5"] {
    --temp-bg: var(--temp-5-bg); --temp-border: var(--temp-5-border);
    --temp-accent: var(--temp-5-accent); --temp-glow: var(--temp-5-glow);
    --temp-text: var(--temp-5-text);
}
.jb[data-depth="6"] {
    --temp-bg: var(--temp-6-bg); --temp-border: var(--temp-6-border);
    --temp-accent: var(--temp-6-accent); --temp-glow: var(--temp-6-glow);
    --temp-text: var(--temp-6-text);
}
.jb[data-depth="7"] {
    --temp-bg: var(--temp-7-bg); --temp-border: var(--temp-7-border);
    --temp-accent: var(--temp-7-accent); --temp-glow: var(--temp-7-glow);
    --temp-text: var(--temp-7-text);
}

/* ── Selected State — #8a0303 ───────────────────────────── */
.jb.selected {
    background: #8a0303 !important;
    border-color: #c91010 !important;
    box-shadow: 0 0 0 2px #8a0303, 0 4px 24px rgba(138, 3, 3, 0.6) !important;
}
.jb.selected::before {
    background: #ff2b2b !important;
    width: 8px;
    box-shadow: 0 0 15px #ff2b2b;
}
.jb.selected > .jb-header .jb-checkbox {
    background: #5e0202;
    border-color: #ff3b3b;
}
.jb.selected > .jb-header .jb-checkbox::after {
    opacity: 1;
    color: #ffffff;
}

/* ── Search hit ───────────────────────────────────────────── */
.jb.search-hit > .jb-header {
    background: rgba(234, 179, 8, 0.1);
}
.jb.search-hit::before { background: #eab308 !important; }

/* ── Block Header ─────────────────────────────────────────── */
.jb-header {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3); padding-left: 18px;
    cursor: pointer;
    user-select: none;
    transition: background var(--duration-fast) var(--ease-out);
    min-height: 38px;
}
.jb-header:hover { background: rgba(255, 255, 255, 0.025); }

/* Checkbox */
.jb-checkbox {
    width: 16px; height: 16px;
    border: 2px solid var(--temp-accent, var(--text-muted));
    border-radius: 3px;
    flex-shrink: 0;
    position: relative;
    transition: all var(--duration-fast) var(--ease-out);
    cursor: pointer;
    background: transparent;
}
.jb-checkbox::after {
    content: '✓';
    position: absolute;
    top: -2px; left: 1px;
    font-size: 12px;
    color: #0a0a0a;
    font-weight: 900;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.jb-checkbox:hover {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
}

/* Toggle arrow */
.jb-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px;
    flex-shrink: 0;
    color: var(--temp-accent, var(--text-muted));
    transition: transform var(--duration-normal) var(--ease-spring);
}
.jb.collapsed > .jb-header > .jb-toggle { transform: rotate(-90deg); }

/* Key name */
.jb-key {
    font-weight: 700;
    color: var(--temp-text, var(--type-key));
    margin-right: var(--sp-1);
}
.jb-key::after {
    content: ':';
    color: var(--text-muted);
    margin-left: 2px;
}

/* Type badge */
.jb-type {
    font-size: 0.65rem; font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.jb-type--object {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.jb-type--array {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.25);
}

/* Item count */
.jb-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

.jb-spacer { flex: 1; }

/* Block actions */
.jb-actions {
    display: flex; gap: 2px;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.jb-header:hover .jb-actions,
.jb.selected > .jb-header .jb-actions { opacity: 1; }

.jb-act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.jb-act:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* ── Block Body ───────────────────────────────────────────── */
.jb-body {
    padding: 0 var(--sp-3) var(--sp-2) 14px;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out),
                padding var(--duration-slow) var(--ease-out),
                opacity var(--duration-normal) var(--ease-out);
}
.jb.collapsed > .jb-body {
    max-height: 0 !important;
    padding-top: 0; padding-bottom: 0;
    opacity: 0;
}

/* ── Collapsed Preview ────────────────────────────────────── */
.jb-preview {
    font-size: 0.73rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    display: none;
}
.jb.collapsed > .jb-header > .jb-preview { display: inline-block; }

/* ═══════════════════════════════════════════════════════════════
   LEAF VALUES (primitives) — also temperature colored
   ═══════════════════════════════════════════════════════════════ */
.jl {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3); padding-left: 18px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    min-height: 32px;
    background: transparent;
}

/* Color dot */
.jl::before {
    content: '';
    position: absolute;
    left: 6px; top: 50%;
    transform: translateY(-50%);
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--leaf-dot, var(--text-muted));
    box-shadow: 0 0 6px var(--leaf-dot, transparent);
}

.jl:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-subtle);
}

/* Leaf checkbox */
.jl-checkbox {
    width: 14px; height: 14px;
    border: 1.5px solid var(--text-muted);
    border-radius: 3px;
    flex-shrink: 0;
    position: relative;
    transition: all var(--duration-fast) var(--ease-out);
    cursor: pointer;
    background: transparent;
}
.jl-checkbox::after {
    content: '✓';
    position: absolute;
    top: -3px; left: 0px;
    font-size: 11px;
    color: #0a0a0a;
    font-weight: 900;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.jl-checkbox:hover {
    border-color: #f43f5e;
    background: rgba(136, 19, 55, 0.3);
}

.jl.selected {
    background: #8a0303 !important;
    border-color: #c91010 !important;
}
.jl.selected .jl-checkbox {
    background: #5e0202;
    border-color: #ff3b3b;
}
.jl.selected .jl-checkbox::after {
    opacity: 1;
    color: #ffffff;
}

.jl.search-hit {
    background: rgba(234, 179, 8, 0.08);
    border-color: rgba(234, 179, 8, 0.25);
}

.jl-key {
    font-weight: 600;
    color: var(--type-key);
    flex-shrink: 0;
}
.jl-key::after {
    content: ':';
    color: var(--text-muted);
    margin-left: 2px;
    margin-right: var(--sp-2);
}

.jl-value { word-break: break-all; }

.jl-value--string {
    color: var(--type-string);
    --leaf-dot: var(--type-string);
}
.jl-value--string::before,
.jl-value--string::after { content: '"'; opacity: 0.5; }

.jl-value--number {
    color: var(--type-number);
    --leaf-dot: var(--type-number);
    font-weight: 600;
}
.jl-value--boolean {
    color: var(--type-boolean);
    --leaf-dot: var(--type-boolean);
    font-weight: 700;
}
.jl-value--null {
    color: var(--type-null);
    --leaf-dot: var(--type-null);
    font-style: italic;
}

.jl-spacer { flex: 1; }

.jl-actions {
    display: flex; gap: 2px;
    opacity: 0; flex-shrink: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.jl:hover .jl-actions { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   EXPORT MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none !important; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
.modal-content {
    position: relative; z-index: 1;
    width: 90%; max-width: 650px;
    padding: var(--sp-6);
    animation: modalSlideIn 0.35s var(--ease-spring);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-5);
}
.modal-header h2 {
    font-family: var(--font-horror);
    font-size: 1.6rem;
    font-weight: 400;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

.export-preview { margin-bottom: var(--sp-5); }
.export-preview-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-2);
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.export-code {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--type-string);
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

.export-actions {
    display: flex; gap: var(--sp-3); flex-wrap: wrap;
}

.btn--export {
    flex: 1; min-width: 160px;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    font-weight: 600;
    justify-content: center;
    font-size: 0.85rem;
    transition: all var(--duration-fast) var(--ease-out);
}
.btn--export:hover { transform: translateY(-2px); }

.btn--export-json {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.12));
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
.btn--export-json:hover { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2); }

.btn--export-html {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(14, 165, 233, 0.12));
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.35);
}
.btn--export-html:hover { box-shadow: 0 4px 20px rgba(6, 182, 212, 0.2); }

.btn--export-clip {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.12));
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.35);
}
.btn--export-clip:hover { box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2); }

/* ─── Toast ─────────────────────────────────────────────────── */
#toast-container {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column-reverse; gap: 8px;
    z-index: 9999; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    animation: toastIn 0.35s var(--ease-spring);
}
.toast.leaving { animation: toastOut 0.25s var(--ease-out) forwards; }
.toast svg { color: #4ade80; flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.95); } }

/* ─── Footer ────────────────────────────────────────────────── */
#app-footer {
    text-align: center;
    padding: var(--sp-8) var(--sp-4);
    color: var(--text-muted);
    font-size: 0.78rem;
    position: relative; z-index: 1;
}

/* ─── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Screen reader only — visible to crawlers & assistive tech */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    html { font-size: 14px; }
    #app-main { padding: 0 var(--sp-3) var(--sp-8); }
    .section-header { flex-direction: column; align-items: flex-start; }
    #toolbar { flex-direction: column; align-items: flex-start; }
    .toolbar-left, .toolbar-right { width: 100%; flex-wrap: wrap; }
    #search-input { width: 100%; }
    .jb-preview { max-width: 150px; }
    .temp-gradient { width: 120px; }
    .export-actions { flex-direction: column; }
    .btn--export { min-width: auto; }
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

::selection { background: rgba(239, 68, 68, 0.35); color: white; }
