.jfb-tool {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f9fbff;
    --text: #172033;
    --muted: #64748b;
    --line: rgba(93, 111, 139, .2);
    --code-bg: #101724;
    --code-text: #dbeafe;
    --accent: #0f766e;
    --accent-2: #2563eb;
    --danger: #c2410c;
    --success: #15803d;
    --shadow: 0 22px 60px rgba(27, 45, 78, .1);
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(15, 118, 110, .12), transparent 34%),
        linear-gradient(225deg, rgba(37, 99, 235, .12), transparent 34%),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    overflow: hidden;
}

.jfb-tool[data-theme="dark"] {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #162033;
    --text: #e5edf8;
    --muted: #9fb0c7;
    --line: rgba(159, 176, 199, .2);
    --code-bg: #07111f;
    --code-text: #e5edf8;
    --accent: #2dd4bf;
    --accent-2: #60a5fa;
    --danger: #fb923c;
    --success: #4ade80;
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.jfb-tool *, .jfb-tool *::before, .jfb-tool *::after { box-sizing: border-box; }
.jfb-tool button, .jfb-tool textarea, .jfb-tool input { font: inherit; }
.jfb-tool button, .jfb-upload { cursor: pointer; }
.jfb-tool a { color: inherit; text-decoration: none; }

.jfb-hero, .jfb-workspace, .jfb-content, .jfb-faq, .jfb-related {
    width: min(1220px, calc(100% - 32px));
    margin: 0 auto;
}

.jfb-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    padding: 56px 0 28px;
}

.jfb-kicker {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.jfb-hero h1 {
    margin: 0;
    max-width: 800px;
    font-size: clamp(2.25rem, 5vw, 4.75rem);
    line-height: 1;
    letter-spacing: 0;
}

.jfb-hero-copy > p:not(.jfb-kicker) {
    max-width: 760px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.jfb-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.jfb-hero-stats span, .jfb-theme-toggle, .jfb-commandbar, .jfb-searchbar, .jfb-panel, .jfb-tree-panel, .jfb-stats-panel, .jfb-content article, .jfb-faq details, .jfb-related a {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.jfb-tool[data-theme="dark"] .jfb-hero-stats span,
.jfb-tool[data-theme="dark"] .jfb-theme-toggle,
.jfb-tool[data-theme="dark"] .jfb-commandbar,
.jfb-tool[data-theme="dark"] .jfb-searchbar,
.jfb-tool[data-theme="dark"] .jfb-panel,
.jfb-tool[data-theme="dark"] .jfb-tree-panel,
.jfb-tool[data-theme="dark"] .jfb-stats-panel,
.jfb-tool[data-theme="dark"] .jfb-content article,
.jfb-tool[data-theme="dark"] .jfb-faq details,
.jfb-tool[data-theme="dark"] .jfb-related a {
    background: rgba(17, 24, 39, .86);
}

.jfb-hero-stats span {
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--muted);
}

.jfb-hero-stats strong { color: var(--text); }

.jfb-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    padding: 12px 15px;
    color: var(--text);
    background: var(--panel);
    transition: transform .18s ease, border-color .18s ease;
}

.jfb-theme-toggle:hover { transform: translateY(-1px); border-color: var(--accent); }
.jfb-theme-toggle span {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.jfb-workspace { padding: 0 0 34px; }

.jfb-commandbar, .jfb-searchbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

.jfb-segment {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.jfb-segment button, .jfb-btn, .jfb-searchbar button {
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    padding: 10px 14px;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.jfb-segment button.is-active, .jfb-btn.is-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #ffffff;
}

.jfb-btn, .jfb-searchbar button {
    border-color: var(--line);
    background: rgba(100, 116, 139, .1);
}

.jfb-btn:hover, .jfb-segment button:hover, .jfb-searchbar button:hover { transform: translateY(-1px); }
.jfb-upload + input, #jfb-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.jfb-live { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); user-select: none; }
.jfb-status { margin-left: auto; color: var(--muted); min-width: 130px; text-align: right; }

.jfb-searchbar label {
    color: var(--muted);
    font-weight: 800;
}

.jfb-searchbar input {
    flex: 1 1 260px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
    color: var(--text);
    padding: 11px 12px;
}

.jfb-editor-grid, .jfb-inspector-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}

.jfb-panel, .jfb-tree-panel, .jfb-stats-panel {
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
}

.jfb-panel header, .jfb-tree-panel header, .jfb-stats-panel header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.jfb-panel header p, .jfb-tree-panel header p, .jfb-stats-panel header p {
    margin: 0;
    color: var(--accent);
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.jfb-panel h2, .jfb-tree-panel h2, .jfb-stats-panel h2, .jfb-content h2, .jfb-faq h2, .jfb-related h2 {
    margin: 0;
    letter-spacing: 0;
}

.jfb-panel header span { color: var(--muted); font-size: .88rem; }

.jfb-editor-shell, .jfb-output-shell {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    min-height: 520px;
    background: var(--code-bg);
}

.jfb-lines {
    margin: 0;
    padding: 18px 10px;
    color: rgba(219, 234, 254, .42);
    background: rgba(0, 0, 0, .16);
    border-right: 1px solid rgba(219, 234, 254, .12);
    text-align: right;
    user-select: none;
    overflow: hidden;
}

.jfb-editor-shell textarea, .jfb-code, .jfb-lines {
    font: 500 14px/1.7 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    tab-size: 2;
}

.jfb-editor-shell textarea, .jfb-code {
    width: 100%;
    min-width: 0;
    height: 520px;
    margin: 0;
    border: 0;
    outline: 0;
    resize: none;
    overflow: auto;
    padding: 18px;
    color: var(--code-text);
    background: transparent;
    white-space: pre;
}

.jfb-code { white-space: pre-wrap; }
.jfb-editor-shell textarea::placeholder { color: rgba(219, 234, 254, .45); }
.jfb-editor-shell.is-dragging { outline: 2px dashed var(--accent); outline-offset: -6px; }
.jfb-editor-shell textarea[data-error-line]:not([data-error-line=""]) { box-shadow: inset 4px 0 0 var(--danger); }

.jfb-token.is-key { color: #7dd3fc; }
.jfb-token.is-string { color: #86efac; }
.jfb-token.is-number { color: #fbbf24; }
.jfb-token.is-boolean { color: #c4b5fd; }
.jfb-token.is-null { color: #fda4af; }
.jfb-token.is-punctuation { color: #bfdbfe; }
.jfb-token.is-match, .jfb-node-name.is-match, .jfb-leaf-value.is-match {
    background: rgba(250, 204, 21, .3);
    border-radius: 4px;
}

.jfb-message {
    min-height: 52px;
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    color: var(--muted);
    background: var(--panel);
}

.jfb-message[data-type="success"] { color: var(--success); border-color: rgba(21, 128, 61, .35); }
.jfb-message[data-type="error"] { color: var(--danger); border-color: rgba(194, 65, 12, .4); }

.jfb-inspector-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
    margin-top: 24px;
}

.jfb-tree, .jfb-stats { padding: 16px; }

.jfb-tree {
    max-height: 460px;
    overflow: auto;
    background: var(--panel-soft);
}

.jfb-node, .jfb-leaf { margin: 7px 0 7px var(--level); }
.jfb-node summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}
.jfb-node summary::-webkit-details-marker { display: none; }
.jfb-node summary::before {
    content: ">";
    color: var(--accent);
    transition: transform .18s ease;
}
.jfb-node[open] > summary::before { transform: rotate(90deg); }
.jfb-node-type, .jfb-node-count {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .78rem;
    padding: 2px 8px;
}
.jfb-leaf {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.jfb-node-name { color: var(--text); font-weight: 800; }
.jfb-leaf-value {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.jfb-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}
.jfb-stats div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--panel-soft);
}
.jfb-stats dt { color: var(--muted); font-size: .82rem; }
.jfb-stats dd { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; }

.jfb-content, .jfb-faq, .jfb-related { padding: 38px 0; }
.jfb-content > div:first-child { max-width: 850px; }
.jfb-content p, .jfb-faq p { color: var(--muted); }
.jfb-card-grid, .jfb-related nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}
.jfb-content article, .jfb-faq details, .jfb-related a {
    border-radius: 8px;
    padding: 22px;
}
.jfb-content h3 { margin: 0 0 8px; }
.jfb-faq details { margin-top: 14px; }
.jfb-faq summary { cursor: pointer; font-weight: 800; }
.jfb-faq summary::-webkit-details-marker { display: none; }
.jfb-faq summary::before { content: ">"; display: inline-block; margin-right: 10px; color: var(--accent); transition: transform .18s ease; }
.jfb-faq details[open] summary::before { transform: rotate(90deg); }
.jfb-related nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.jfb-related a { font-weight: 800; }

.jfb-tool :focus-visible {
    outline: 3px solid rgba(45, 212, 191, .48);
    outline-offset: 3px;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .jfb-btn, .jfb-upload, .jfb-segment button, .jfb-searchbar button, .jfb-theme-toggle {
        min-height: 48px;
        min-width: 48px;
    }
    .jfb-btn:active, .jfb-upload:active, .jfb-segment button:active {
        transform: scale(0.98);
    }
}

@media (max-width: 980px) {
    .jfb-editor-grid, .jfb-inspector-grid, .jfb-card-grid, .jfb-related nav { grid-template-columns: 1fr; }
    .jfb-status { width: 100%; margin-left: 0; text-align: left; }
}

@media (max-width: 768px) {
    .jfb-hero { grid-template-columns: 1fr; padding-top: 28px; padding-bottom: 20px; }
    .jfb-hero h1 { font-size: 2rem; }
    .jfb-workspace { padding: 0 0 24px; }
    .jfb-commandbar { flex-wrap: wrap; align-items: center; }
    .jfb-segment { width: 100%; justify-content: space-around; }
    .jfb-segment button { flex: 1; }
    .jfb-btn, .jfb-upload { flex: 1 1 calc(50% - 5px); min-width: 100px; }
    .jfb-live { flex: 1 1 100%; }
    .jfb-status { width: 100%; text-align: left; margin-top: 10px; }
    .jfb-editor-shell, .jfb-output-shell { grid-template-columns: 44px minmax(0, 1fr); min-height: 340px; }
    .jfb-editor-shell textarea, .jfb-code { height: 340px; padding: 12px; font-size: 13px; line-height: 1.6; }
    .jfb-lines { padding: 12px 6px; font-size: 12px; }
    .jfb-stats { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .jfb-hero { padding-top: 20px; padding-bottom: 16px; }
    .jfb-hero h1 { font-size: 1.5rem; margin-bottom: 12px; }
    .jfb-hero-copy > p:not(.jfb-kicker) { font-size: 0.95rem; margin-top: 12px; }
    .jfb-hero-stats { gap: 8px; }
    .jfb-hero-stats span { padding: 8px 10px; font-size: 0.7rem; }
    .jfb-workspace, .jfb-content, .jfb-faq, .jfb-related { width: min(100%, calc(100% - 16px)); }
    .jfb-commandbar { padding: 10px; margin-bottom: 10px; gap: 8px; }
    .jfb-btn, .jfb-upload { flex: 1 1 100%; padding: 10px 8px; font-size: 13px; min-height: 44px; }
    .jfb-segment button { padding: 8px 10px; font-size: 12px; }
    .jfb-theme-toggle { padding: 10px 12px; margin-top: 10px; width: 100%; justify-content: center; }
    .jfb-panel header, .jfb-stats-panel header { padding: 12px 14px; gap: 8px; }
    .jfb-editor-shell, .jfb-output-shell { min-height: 300px; }
    .jfb-editor-shell textarea, .jfb-code { height: 300px; padding: 10px; font-size: 12px; }
    .jfb-lines { padding: 10px 4px; font-size: 11px; }
    .jfb-faq details { padding: 16px; }
    .jfb-content article { padding: 16px; }
    .jfb-stats dt { font-size: 0.75rem; }
    .jfb-stats dd { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .jfb-tool *, .jfb-tool *::before, .jfb-tool *::after {
        transition: none !important;
        animation: none !important;
    }
}
