:root {
    --bg: #0f1216;
    --card: #151922;
    --text: #e8eaed;
    --muted: #a8b0bf;
    --accent: #4f8cff;
    --accent-2: #22c55e;
    --border: #222836;
}

html[data-theme="light"] {
    --bg: #f7f8fa;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --accent: #2563eb;
    --accent-2: #16a34a;
    --border: #e5e7eb;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
    background: linear-gradient(180deg, #0b0e12, var(--bg));
    color: var(--text);
}

.header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    backdrop-filter: saturate(1.2) blur(8px);
    background: rgba(15, 18, 22, 0.7);
}

html[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.7);
}

.nav {
    display: flex;
    gap: 12px;
}

.nav a {
    color: var(--text);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.nav a.active {
    border-color: var(--accent);
}

.spacer {
    flex: 1;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.desc {
    color: var(--muted);
    font-size: 14px;
}

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    gap: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 20px 30px -20px rgba(0, 0, 0, 0.4);
}

.card h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 860px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
}

.panel {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 14px;
}

.panel h3 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--muted);
}

.field {
    display: grid;
    gap: 6px;
    margin: 10px 0;
    position: relative;
}

.field>span {
    color: var(--muted);
    font-size: 13px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="datetime-local"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f131a;
    color: var(--text);
    outline: none;
}

html[data-theme="light"] .field input[type="text"],
html[data-theme="light"] .field input[type="number"],
html[data-theme="light"] .field input[type="datetime-local"],
html[data-theme="light"] .field select,
html[data-theme="light"] .field textarea {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border);
}

.field textarea {
    min-height: 140px;
    resize: vertical;
}

.select-search {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f131a;
    color: var(--text);
    outline: none;
}

html[data-theme="light"] .select-search {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border);
}

.select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    z-index: 10;
    display: none;
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0f131a;
}

html[data-theme="light"] .select-dropdown {
    background: #ffffff;
}

.select-item {
    padding: 8px 12px;
    cursor: pointer;
}

.select-item:hover {
    background: #0b0f15;
}

html[data-theme="light"] .select-item:hover {
    background: #f8fafc;
}

.tz-offset {
    color: var(--muted);
    margin-top: 6px;
    display: inline-block;
}

.split {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0;
}

button {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f131a;
    color: var(--text);
    cursor: pointer;
}

html[data-theme="light"] button {
    background: #ffffff;
}

button:hover {
    border-color: var(--accent);
}

.result {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 8px;
    align-items: center;
}

.row output {
    padding: 8px 10px;
    border-radius: 8px;
    background: #0b0f15;
    border: 1px solid var(--border);
    min-height: 36px;
}

html[data-theme="light"] .row output {
    background: #ffffff;
}

.error {
    margin-top: 8px;
    color: #ff6b6b;
    font-size: 13px;
    min-height: 18px;
}

.footer {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* JSON page wide layout */
.page-json .main {
    max-width: none;
}

.json-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.json-grid .panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.json-actions {
    justify-content: flex-end;
}

.json-card .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.json-card .card-head h2 {
    margin: 0;
}

.page-json .field textarea,
.page-json .code {
    height: var(--jsonPaneHeight, 60vh);
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    background: #0b0f15;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    overflow: auto;
    width: 100%;
    max-width: 100%;
}

html[data-theme="light"] .code {
    background: #f8fafc;
}

.editor {
    position: relative;
    height: var(--jsonPaneHeight, 60vh);
}

.code-preview {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 48px 1fr;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
    pointer-events: none;
}

.code-gutter {
    padding: 12px 8px;
    background: #0b0f15;
    border-right: 1px solid var(--border);
    color: var(--muted);
    text-align: right;
    user-select: none;
}

html[data-theme="light"] .code-gutter {
    background: #f8fafc;
}

.code-inner {
    margin: 0;
    padding: 12px;
    white-space: pre;
}

.editor-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 12px 12px 12px calc(12px + 48px);
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    resize: none;
}

.tok-key {
    color: #82aaff;
}

.tok-str {
    color: #ffcb6b;
}

.tok-num {
    color: #bae67e;
}

.tok-bool {
    color: #c792ea;
}

.tok-null {
    color: #89ddff;
}

.tok-punc {
    color: var(--muted);
}

/* Collapsible JSON result */
.coll-toggle {
    display: inline-block;
    width: 1em;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    margin-right: 6px;
}

.coll-toggle.disabled {
    cursor: default;
    color: transparent;
}

.prop .coll-summary {
    display: none;
}

.prop.collapsed .coll-content {
    display: none;
}

.prop.collapsed .coll-summary {
    display: inline;
}