:root {
    --radius: 8px;
    --font-display: "Microsoft YaHei UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    --font-body: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
    --font-utility: "DIN Alternate", "SFMono-Regular", Consolas, monospace;
    --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
}

:root[data-theme="dark"] {
    --background: #0c0e11;
    --background-alt: #101318;
    --surface: #14171c;
    --surface-hover: #191d24;
    --text: #f3f5f6;
    --text-strong: #ffffff;
    --muted: #949ca8;
    --muted-strong: #b7bec8;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --accent: #5da9ff;
    --accent-strong: #86c0ff;
    --accent-ink: #07111c;
    --accent-soft: rgba(93, 169, 255, 0.12);
    --header-bg: rgba(12, 14, 17, 0.82);
    --search-surface: #171a20;
    --search-text: #f3f5f7;
    --search-muted: #89929f;
    --search-border: rgba(255, 255, 255, 0.14);
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
    --asset-opacity: 0.48;
    --asset-filter: none;
    --dock-bg: rgba(20, 23, 28, 0.94);
}

:root[data-theme="light"] {
    --background: #f4f6f8;
    --background-alt: #edf1f5;
    --surface: #ffffff;
    --surface-hover: #f7f9fb;
    --text: #171b21;
    --text-strong: #090b0e;
    --muted: #6a727e;
    --muted-strong: #505864;
    --border: rgba(19, 31, 46, 0.13);
    --border-strong: rgba(19, 31, 46, 0.24);
    --accent: #176fc3;
    --accent-strong: #0c569b;
    --accent-ink: #ffffff;
    --accent-soft: rgba(23, 111, 195, 0.1);
    --header-bg: rgba(244, 246, 248, 0.84);
    --search-surface: #ffffff;
    --search-text: #11151a;
    --search-muted: #68717c;
    --search-border: rgba(19, 31, 46, 0.12);
    --shadow: 0 22px 64px rgba(35, 53, 72, 0.14);
    --asset-opacity: 0.22;
    --asset-filter: saturate(0.76) contrast(0.88);
    --dock-bg: rgba(255, 255, 255, 0.94);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: 0;
    transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

button,
select {
    cursor: pointer;
}

button {
    color: inherit;
}

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

svg {
    display: block;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

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

.brand-mark {
    position: relative;
    width: 29px;
    height: 29px;
    flex: none;
    border: 5px solid var(--accent);
    border-right-color: var(--border-strong);
    border-radius: 50%;
    transform: rotate(-28deg);
    transition: transform 280ms var(--ease), border-color 180ms ease;
}

.brand-mark span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-strong);
    transform: translate(-50%, -50%);
}

.icon-button {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted-strong);
    transition: background-color 150ms ease, color 150ms ease;
}

.icon-button:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.icon-button svg {
    width: 19px;
    height: 19px;
}

.theme-toggle {
    position: relative;
}

.theme-icon {
    position: absolute;
    transition: opacity 160ms ease, transform 200ms var(--ease);
}

[data-theme="dark"] .theme-icon-sun,
[data-theme="light"] .theme-icon-moon {
    opacity: 1;
    transform: scale(1) rotate(0);
}

[data-theme="dark"] .theme-icon-moon,
[data-theme="light"] .theme-icon-sun {
    opacity: 0;
    transform: scale(0.55) rotate(45deg);
}

.form-error {
    min-height: 22px;
    margin: 8px 8px 0;
    color: #d95764;
    font-size: 13px;
    text-align: left;
}

.recent-searches {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.recent-list {
    min-width: 0;
    display: flex;
    gap: 6px;
}

.recent-list a {
    max-width: 180px;
    padding: 3px 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted-strong);
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: border-color 150ms ease, color 150ms ease;
}

.recent-list a:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.query-receipt {
    width: min(460px, 100%);
    margin: 9px auto 0;
    padding: 10px 10px 10px 12px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-align: left;
}

.receipt-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.receipt-icon svg {
    width: 17px;
    height: 17px;
}

.query-receipt > div {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.query-receipt span {
    color: var(--muted);
    font-size: 11px;
}

.query-receipt strong {
    overflow: hidden;
    color: var(--text-strong);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.query-receipt .icon-button {
    width: 30px;
    height: 30px;
}

.toast-region {
    position: fixed;
    z-index: 400;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    min-width: 250px;
    max-width: min(360px, calc(100vw - 40px));
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms var(--ease);
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast span {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.toast p {
    margin: 0;
    font-size: 13px;
}

.global-loading {
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 0;
    background: rgba(4, 6, 9, 0.36);
    color: var(--accent-strong);
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(3px);
    transition: opacity 150ms ease, visibility 150ms ease;
}

.global-loading[open] {
    display: grid;
}

.global-loading.is-visible {
    opacity: 1;
    visibility: visible;
}

.global-loading::backdrop {
    background: transparent;
}

.global-loading-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 8px var(--accent-soft);
    animation: global-loading-spin 760ms linear infinite;
}

@keyframes global-loading-spin {
    to { transform: rotate(360deg); }
}

@keyframes reveal-up {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes search-scan {
    0%, 14% { transform: translateX(-110%); }
    72%, 100% { transform: translateX(950px); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
