:root {
    --bg: #f3f2ee;
    --panel: #ffffff;
    --head: #faf9f6;
    --hover: #f8f7f4;
    --ink: #14161a;
    --muted: #71757d;
    --line: #e2e0da;
    --line-soft: #edebe6;
    --accent: #a01c22;
    --accent-soft: rgba(160, 28, 34, .09);
    --chip-on-bg: #1b1e24;
    --chip-on-fg: #ffffff;
    --focus-ring: rgba(20, 22, 26, .14);
    --shadow: 0 1px 2px rgba(20, 22, 26, .04);
    --radius: 6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1114;
        --panel: #16181d;
        --head: #1a1d23;
        --hover: #1c2026;
        --ink: #e7e8eb;
        --muted: #8d929b;
        --line: #282d35;
        --line-soft: #21252c;
        --accent: #d2545a;
        --accent-soft: rgba(210, 84, 90, .16);
        --chip-on-bg: #e7e8eb;
        --chip-on-fg: #14161a;
        --focus-ring: rgba(231, 232, 235, .18);
        --shadow: none;
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
    color: inherit;
}

.shell {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* ---------- 顶栏 ---------- */
.site-head {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.head-inner {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-bar {
    width: 3px;
    height: 20px;
    border-radius: 1px;
    background: var(--accent);
    flex: none;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-sep {
    width: 1px;
    height: 14px;
    background: var(--line);
    flex: none;
}

.brand-label {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.stat {
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stat b {
    color: var(--ink);
    font-weight: 600;
}

.stat-sep {
    padding: 0 6px;
    color: var(--line);
}

/* ---------- 主体 ---------- */
main.shell {
    padding-bottom: 8px;
}

.search-panel {
    margin-top: 28px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.field {
    display: flex;
    gap: 10px;
}

#q {
    flex: 1 1 auto;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 15.5px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    appearance: none;
}

#q::placeholder {
    color: var(--muted);
}

#q:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

#q::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background:
        linear-gradient(45deg, transparent 46%, var(--muted) 46%, var(--muted) 54%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, var(--muted) 46%, var(--muted) 54%, transparent 54%);
    cursor: pointer;
}

.submit {
    flex: none;
    height: 46px;
    padding: 0 26px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--ink);
    color: var(--panel);
    font-size: 14.5px;
    font-weight: 500;
    letter-spacing: .02em;
    cursor: pointer;
    transition: opacity .15s ease, transform .1s ease;
}

.submit:hover {
    opacity: .88;
}

.submit:active {
    transform: translateY(1px);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.chip {
    padding: 5px 13px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.chip:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.chip.is-on {
    background: var(--chip-on-bg);
    border-color: var(--chip-on-bg);
    color: var(--chip-on-fg);
}

/* ---------- 结果 ---------- */
.results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    flex-wrap: wrap;
    margin: 26px 2px 10px;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.result-count {
    letter-spacing: .02em;
    white-space: nowrap;
}

.info-sep {
    color: var(--line);
}

.elapsed {
    white-space: nowrap;
}

.tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.tool {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.tool:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.tool:active {
    transform: translateY(1px);
}

.tool.is-on {
    border-color: var(--ink);
    color: var(--ink);
}

.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: .08em;
    color: var(--muted);
    background: var(--head);
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody tr {
    cursor: pointer;
    transition: background .12s ease;
}

tbody tr:hover {
    background: var(--hover);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px dashed var(--line-soft);
    vertical-align: middle;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.cell-name {
    font-weight: 500;
    letter-spacing: .01em;
}

.tel {
    display: inline-block;
    padding: 2px 7px;
    background: var(--head);
    border: 1px solid var(--line);
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
    letter-spacing: .1em;
    line-height: 1.5;
}

.col-py,
.col-sh {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .02em;
}

.col-city {
    color: var(--ink);
}

thead th:nth-child(2) {
    width: 118px;
}

thead th:nth-child(3) {
    width: 26%;
}

thead th:nth-child(4) {
    width: 92px;
}

thead th:nth-child(5) {
    width: 96px;
}

.tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: .02em;
    vertical-align: 2px;
}

.raw-panel {
    margin: 0 0 10px;
    padding: 14px 16px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.raw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 12.5px;
    color: var(--muted);
}

.raw-actions {
    display: flex;
    gap: 6px;
}

.raw-json {
    margin: 0;
    max-height: 420px;
    overflow: auto;
    padding: 12px 14px;
    background: var(--head);
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--ink);
    white-space: pre;
    tab-size: 2;
}

.empty {
    margin: 0;
    padding: 44px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- 页脚 ---------- */
.site-foot {
    margin-top: 52px;
    border-top: 1px solid var(--line);
}

.foot-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 18px;
    padding: 22px 0 34px;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .01em;
}

.foot-inner a {
    color: var(--muted);
    text-decoration: none;
}

.foot-inner a:hover {
    color: var(--ink);
}

/* ---------- 提示 ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 8px);
    padding: 9px 16px;
    background: var(--ink);
    color: var(--panel);
    border-radius: 4px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 40;
    white-space: nowrap;
}

.toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
    .shell {
        padding-left: 16px;
        padding-right: 16px;
    }

    .head-inner {
        height: 56px;
    }

    .search-panel {
        margin-top: 18px;
        padding: 16px;
    }

    #q {
        height: 44px;
    }

    .submit {
        height: 44px;
        padding: 0 18px;
    }

    .col-py,
    .col-sh {
        display: none;
    }

    thead th,
    tbody td {
        padding-left: 12px;
        padding-right: 12px;
    }

    table {
        font-size: 13.5px;
    }
}

@media (max-width: 460px) {
    .results-head {
        margin-top: 20px;
    }

    .brand-label,
    .brand-sep {
        display: none;
    }

    .hint {
        display: none;
    }

    .stat {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
