:root {
    --bg: #f6f7fb;
    --card-bg: #ffffff;
    --border: #e8eaf1;
    --title: #171c2e;
    --muted: #6b7488;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --code-bg: #1e2436;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--title);
    display: flex;
    justify-content: center;
    padding: 36px 20px 60px;
}

.page {
    width: min(860px, 100%);
    animation: fadeIn 0.4s ease;
}

/* 顶部 */
.topbar {
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
}

.sub {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* Token 栏 */
.token-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.token-bar label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.token-bar input {
    flex: 1;
    min-width: 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.tab {
    flex: 1;
    min-width: 220px;
    text-align: left;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--title);
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.tab code {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tab:hover {
    border-color: #cdd3e6;
}

.tab.active {
    border-color: var(--accent);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.14);
}

.tab.active code {
    color: var(--accent);
}

/* 表单面板 */
.panel {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 18px;
}

.panel.active {
    display: block;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.req {
    color: #ef4444;
    font-size: 12px;
    font-weight: 400;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.token-bar input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--title);
    background: #fbfbfe;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field textarea {
    resize: vertical;
    font-family: inherit;
}

.field input:focus,
.field textarea:focus,
.token-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    background: #fff;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 14px;
}

.field-row {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.check input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.tip {
    margin: 0 0 16px;
    font-size: 12px;
    color: var(--muted);
}

/* 按钮 */
.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, opacity 0.18s ease;
}

.btn.primary {
    background: #eef0ff;
    color: var(--accent);
    border: 1px solid #dfe3ff;
}

.btn.primary:hover {
    background: #e2e6ff;
    border-color: #ccd2ff;
}

.btn.primary:disabled {
    background: #f7f8fc;
    color: #aab0c2;
    border-color: #eceef5;
    cursor: not-allowed;
}

.btn.ghost {
    background: #eef0f8;
    color: var(--title);
    padding: 7px 14px;
    font-size: 12px;
}

.btn.ghost:hover {
    background: #e2e6f4;
}

/* 结果 */
.result {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.result-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e8f8ee;
    color: #15803d;
}

.badge.err {
    background: #fdecec;
    color: #b91c1c;
}

.elapsed {
    font-size: 12px;
    color: var(--muted);
    flex: 1;
}

.json {
    margin: 0;
    padding: 16px;
    background: var(--code-bg);
    color: #d6ddf5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    overflow: auto;
    max-height: 520px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* JSON 语法高亮 */
.json .k { color: #93c5fd; }
.json .s { color: #86efac; }
.json .n { color: #fbbf24; }
.json .b { color: #f472b6; }
.json .null { color: #94a3b8; }

@media (max-width: 640px) {
    body {
        padding: 24px 14px 48px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .tab {
        min-width: 100%;
    }
}

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