:root {
    color-scheme: light;
    font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: #172033;
    background: #eef4ff;
    --primary: #5c6ff2;
    --panel: rgba(255, 255, 255, .97);
    --muted: #7e8798;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #eef4ff; }
body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #eaf2ff 0, #f4f7ff 55%, #eef4ff 100%);
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 10px 10px calc(92px + env(safe-area-inset-bottom));
}
.page-header { display: flex; align-items: center; justify-content: center; min-height: 38px; }
.page-header h1 { margin: 2px 0 9px; font-size: 20px; line-height: 1.25; }
.filter-shell { position: relative; }
.filter-backdrop { display: none; }
.filter-window { width: 100%; }
.filter-shell.is-collapsed { display: none; }
.filter-shell.is-floating {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8px 10px calc(78px + env(safe-area-inset-bottom));
}
.filter-shell.is-floating .filter-backdrop {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(21, 31, 52, .38);
    backdrop-filter: blur(2px);
}
.filter-shell.is-floating .filter-window {
    position: relative;
    z-index: 1;
    width: min(100%, 740px);
    max-height: calc(100vh - 86px - env(safe-area-inset-bottom));
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(218, 226, 240, .95);
    border-radius: 15px;
    background: #eef4ff;
    box-shadow: 0 18px 45px rgba(21, 31, 52, .28);
    animation: filter-window-in .2s ease-out;
}
.filter-shell.is-floating .panel:last-child { margin-bottom: 0; }
.filter-window-open { overflow: hidden; }
@keyframes filter-window-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.panel, .results-section {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid rgba(215, 225, 239, .9);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 4px 14px rgba(70, 94, 139, .06);
}
.filter-panel { display: grid; gap: 8px; }
.selected-block { min-height: 98px; }
.filter-row {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}
.filter-row > label { font-weight: 600; font-size: 14px; }
input, select {
    width: 100%;
    height: 36px;
    border: 1px solid #ccd4df;
    border-radius: 6px;
    background: #fff;
    color: #252c38;
    outline: none;
}
input { padding: 0 10px; }
select { padding: 0 30px 0 10px; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(92, 111, 242, .12); }
.range-input { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
.range-separator { color: var(--muted); font-size: 13px; text-align: center; }
.selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
    padding-top: 9px;
    border-top: 1px solid #edf0f5;
}
.selected-header h2, .role-panel h2, .results-section > h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.clear-btn {
    padding: 5px 10px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: #f04d57;
    cursor: pointer;
}
.clear-btn:disabled { opacity: .45; cursor: default; }
.selected-list {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    min-height: 58px;
    padding: 3px 2px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.empty-selection, .loading-state, .result-placeholder, .account-roles-empty { color: var(--muted); font-size: 14px; }
.empty-selection { align-self: center; }
.role-panel { padding-bottom: 10px; }
.role-panel h2, .results-section > h2 { margin-bottom: 10px; }
.role-scroll {
    height: 182px;
    min-height: 182px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #bac2cf transparent;
}
.role-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px 5px; }
.role-card {
    position: relative;
    display: flex;
    min-width: 0;
    padding: 2px;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid #dfe3ea;
    border-radius: 7px;
    background: #fff;
    color: inherit;
    text-align: center;
    overflow: visible;
}
.role-card.selectable, .selected-list .role-card { cursor: pointer; }
.role-card.is-selected { border-color: #625bf6; box-shadow: 0 0 0 1px #625bf6; }
.role-image-wrap { position: relative; display: block; width: 100%; aspect-ratio: 1; }
.role-image-wrap img { display: block; width: 100%; height: 100%; border-radius: 5px; object-fit: cover; }
.role-name {
    display: block;
    min-width: 0;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quantity-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #f0444f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.selected-list .role-card { width: 52px; min-width: 52px; padding: 0; border: 0; }
.selected-list .role-card.is-selected { box-shadow: none; }
.results-section { padding: 12px; }
.result-container { display: grid; gap: 10px; }
.result-placeholder {
    padding: 22px 8px;
    border: 1px dashed #d9dfeb;
    border-radius: 8px;
    text-align: center;
}
.error { color: #d73a49; }
.result-card {
    padding: 9px;
    border: 1px solid #d9dee7;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(40, 59, 95, .05);
}
.account-meta {
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid #e3e7ee;
    border-radius: 8px;
    background: #fbfcfe;
    color: #626b79;
    font-size: 13px;
}
.account-id-line, .account-stats { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.account-id-line { justify-content: space-between; margin-bottom: 5px; }
.account-id-line strong { color: #303744; }
.copy-btn { padding: 3px 8px; border: 1px solid #d3d9e4; border-radius: 5px; background: #fff; color: #566175; }
.account-role-scroll { max-height: 202px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.account-role-grid { padding: 1px; }
.end-tip { padding: 12px 0 2px; color: var(--muted); font-size: 13px; text-align: center; }
.search-dock {
    position: fixed;
    z-index: 50;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    justify-content: center;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
    background: linear-gradient(180deg, rgba(238, 244, 255, 0), rgba(238, 244, 255, .94) 34%);
}
.search-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: min(78vw, 360px);
    min-height: 46px;
    padding: 10px 18px;
    border: 0;
    border-radius: 13px;
    background: linear-gradient(120deg, #587df6, #7435ac);
    box-shadow: 0 7px 20px rgba(89, 77, 196, .3);
    color: #fff;
    font-weight: 600;
    pointer-events: auto;
    cursor: pointer;
}
.search-button:disabled { opacity: .65; cursor: wait; }
.search-icon { width: 17px; height: 17px; border: 2px solid currentColor; border-radius: 50%; position: relative; }
.search-icon::after {
    content: "";
    position: absolute;
    right: -5px;
    bottom: -3px;
    width: 7px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform: rotate(45deg);
}

@media (min-width: 600px) {
    .page-shell { padding-top: 16px; }
    .role-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 9px; }
    .role-name { font-size: 12px; }
}

@media (max-height: 720px) and (max-width: 599px) {
    .page-shell { padding-top: 5px; }
    .page-header { min-height: 30px; }
    .page-header h1 { margin-bottom: 5px; font-size: 18px; }
    .panel { margin-bottom: 7px; padding: 9px 10px; }
    .filter-panel { gap: 6px; }
    input, select { height: 33px; }
    .selected-list { min-height: 51px; }
    .selected-list .role-card { width: 46px; min-width: 46px; }
    .role-scroll { height: 174px; min-height: 174px; }
}
