:root[data-theme="light"] {
    --bg-color: #f4f4f9;
    --surface-color: #ffffff;
    --text-color: #2c3e50;
    --border-color: #d1d8e0;
    --primary-color: #4a90e2;
    --hover-color: #357abd;
    --error-bg: #ffeaa7;
    --error-color: #d63031;
    --success-color: #00b894;
    --panel-shadow: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --bg-color: #14141b;
    --surface-color: #202028;
    --text-color: #f4f4f9;
    --border-color: #383847;
    --primary-color: #5da9f6;
    --hover-color: #4a90e2;
    --error-bg: #4a1919;
    --error-color: #ff7675;
    --success-color: #55efc4;
    --panel-shadow: rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

body {
    display: flex;
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(93, 169, 246, 0.15), transparent 28%),
                radial-gradient(circle at bottom right, rgba(255, 121, 117, 0.12), transparent 32%),
                var(--bg-color);
}

.app-shell {
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    padding: 1.25rem 1.5rem 0.5rem;
    text-align: center;
}

header h1 {
    margin: 0;
    font-size: clamp(1.8rem, 2.5vw, 2.75rem);
    letter-spacing: 1px;
}

.workspace {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    padding: 0 1.5rem 1.5rem;
    min-height: 0;
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
        padding: 0 1rem 1rem;
    }
}

.panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16);
    min-height: 0;
    overflow: hidden;
}

.panel-header,
.panel-footer,
.panel-subheader {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.panel-header {
    background: linear-gradient(135deg, rgba(93, 169, 246, 0.12), rgba(85, 239, 196, 0.08));
}

.panel-footer {
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.footer-title {
    font-weight: 700;
    color: var(--text-color);
}

.panel-footer {
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.panel-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

textarea,
pre {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

textarea {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.json-tree {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.json-tree details {
    margin-bottom: 0.6rem;
}

.json-tree summary {
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    background: rgba(93, 169, 246, 0.08);
}

.tree-node .leaf-node {
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    margin: 0.3rem 0;
    background: rgba(255, 255, 255, 0.04);
}

.json-tree .object-meta,
.json-tree .array-meta {
    color: var(--primary-color);
}

textarea {
    flex: 1;
    min-height: 280px;
    padding: 1rem 1rem 1rem 0.95rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0 0 0 12px;
    overflow: auto;
}

pre {
    flex: 1;
    min-height: 260px;
    overflow: auto;
    padding: 1rem;
    border-radius: 0 0 12px 12px;
    background: rgba(0, 0, 0, 0.03);
    white-space: pre-wrap;
    word-break: break-word;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

button {
    border: none;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    transition: transform 0.15s ease, background-color 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    background-color: var(--hover-color);
}

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

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

.btn-danger {
    border-color: var(--error-color);
    color: var(--error-color);
}

.btn-danger:hover {
    background: var(--error-color);
    color: white;
}

.error-message,
.success-message {
    padding: 1rem 1.25rem;
    border-radius: 0 0 12px 12px;
    font-family: 'Courier New', Courier, monospace;
    display: none;
    white-space: pre-line;
}

.error-message {
    background: var(--error-bg);
    color: var(--error-color);
}

.success-message {
    color: var(--success-color);
}

.saved-items-container {
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
}

.saved-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80%;
}

.delete-item {
    background: var(--error-color);
    border: none;
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
}

.output-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem 1.25rem 1.25rem;
    flex: 1;
    min-height: 0;
}

@media (max-width: 980px) {
    .output-body {
        grid-template-columns: 1fr;
    }
}

.output-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.output-pane .panel-subheader {
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    padding: 0.9rem 1rem;
    background: rgba(0, 0, 0, 0.03);
}

.json-output,
.json-tree {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    min-height: 220px;
}

.json-tree {
    background: rgba(0, 0, 0, 0.03);
}

.json-tree details {
    margin-bottom: 0.45rem;
}

.json-tree summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    background: rgba(255, 255, 255, 0.05);
}

.json-tree .leaf-node {
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    margin: 0.15rem 0;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.95rem;
}

.json-tree .object-meta,
.json-tree .array-meta {
    color: var(--primary-color);
}

footer {
    text-align: center;
    padding: 1rem;
    margin-top: auto;
    font-weight: 500;
}

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--surface-color);
    color: var(--text-color);
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    font-size: 1.3rem;
}

.mobile-warning {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 28, 0.92);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
    text-align: center;
}

.mobile-warning-card {
    max-width: 420px;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    padding: 1.75rem;
    backdrop-filter: blur(16px);
}

.mobile-warning-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
}

.mobile-warning-card p {
    margin: 0 0 1.25rem;
    line-height: 1.6;
}

@media (max-width: 760px) {
    .mobile-warning {
        display: flex;
    }
}

.panel-content,
.output-body,
textarea,
.json-output,
.json-tree {
    min-height: 300px;
}

.output-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.panel-subheader {
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    padding: 0.9rem 1rem;
    background: rgba(0, 0, 0, 0.03);
}

.json-output,
.json-tree {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    min-height: 220px;
}

.json-tree {
    background: rgba(255, 255, 255, 0.03);
}
@media (max-width: 760px) {
    body {
        background: var(--bg-color);
    }

    .workspace {
        gap: 1rem;
        padding: 0.75rem;
    }

    .panel-header,
    .panel-footer,
    .panel-subheader {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-header > div,
    .panel-footer > .controls,
    .panel-subheader {
        width: 100%;
    }

    .panel-header .controls,
    .panel-footer .controls {
        justify-content: flex-start;
    }

    .controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .controls button,
    .btn-outline,
    .btn-danger {
        width: 100%;
        text-align: center;
    }

    .output-body {
        grid-template-columns: 1fr;
        padding: 0.75rem 0.5rem 1rem;
    }

    textarea,
    .json-output,
    .json-tree {
        min-height: 220px;
    }

    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
    }
}