/* 外壳体验增量：在所有既有 workbench 样式之后加载；不覆盖决斗盘和卡牌规则。 */
:is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) {
    --shell-muted: #b0a5bd;
    --shell-edge: rgba(var(--brand-rgb), .3);
}
:is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) :is(button,[role="button"],input,select,textarea):focus-visible {
    outline: 2px solid var(--brand-bright, #c8a4ff);
    outline-offset: 3px;
}
:is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) button {
    touch-action: manipulation;
}
:is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) button:disabled {
    cursor: not-allowed;
}
.shell-inline-action {
    display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
    padding: 7px 13px; border: 1px solid var(--shell-edge, rgba(167,120,255,.35)); border-radius: 9px;
    background: rgba(var(--brand-rgb), .11); color: var(--brand-bright, #d8baff); font: inherit; font-size: 12px; cursor: pointer;
}
.shell-inline-action:hover { background: rgba(var(--brand-rgb), .2); }
.shell-inline-action[hidden] { display: none; }

/* 首页主次入口与真实已保存卡组状态；恢复准备页 CSS 意外隐藏的首页 CTA。 */
#page-main .hero-actions { display: flex !important; gap: 10px; }
#page-main .hero-cta { min-height: 48px; }
#page-main .hero-cta.ghost { color: #d4c8df; border-color: rgba(var(--brand-rgb), .45); }
#page-main .hero-cta .memo { max-width: 210px; }
#page-main .fd, #page-main .h-sub { color: var(--shell-muted); line-height: 1.6; }
#page-main .feat-card { min-height: 76px; }
#page-main .shell-home-context {
    display: flex; align-items: center; gap: 8px; padding-top: 14px; margin-top: 16px;
    border-top: 1px solid rgba(var(--brand-rgb), .22); color: #b4a9c0; font-size: 12px; line-height: 1.6;
}
#page-main .shell-home-context > [data-shell-deck] { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#page-main .shell-home-context .shell-inline-action { flex: none; }
#page-main .shell-context-dot { width: 7px; height: 7px; flex: none; background: #c9ad69; border-radius: 50%; }
#page-main .shell-home-context.is-ready .shell-context-dot { background: #7dd0a0; }
#page-main .asc-recent-empty { color: var(--shell-muted); line-height: 1.8; }
#page-main .asc-recent-empty .shell-inline-action { display: flex; width: fit-content; margin: 12px auto 0; }

/* 搜索：一个输入、一套过滤按钮；列表独立滚动以保留既有分批加载。 */
#page-card-search .sub-page-container { height: 100vh; height: 100dvh; max-height: 100dvh; min-height: 0; overflow: hidden; }
#page-card-search .sub-page-header { flex: none; }
#page-card-search .csw-shell { flex: 1; min-height: 0; overflow: hidden; }
#page-card-search .csw-search-hero, #page-card-search .csw-tools { flex: none; }
#page-card-search .csw-searchbox #card-search-input {
    width: 100%; flex: 1; min-width: 0; min-height: 46px; padding: 8px 0;
    border: 0; border-radius: 0; background: transparent; color: #f4edf9; font-size: 16px; box-shadow: none;
}
#page-card-search .csw-searchbox:focus-within { border-color: var(--brand-bright); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .13); }
#page-card-search .csw-searchbox #card-search-input:focus { box-shadow: none; }
#page-card-search .csw-clear { width: 40px; height: 40px; flex: none; border-radius: 9px; font-size: 22px; }
#page-card-search .csw-quick, #page-card-search .csw-filter-open { min-height: 40px; }
#page-card-search .csw-selected:empty { display: none; }
#page-card-search button.csw-chip { min-height: 32px; border: 1px solid rgba(var(--brand-rgb), .35); cursor: pointer; font: inherit; font-size: 12px; }
#page-card-search .csw-summary { color: var(--shell-muted); }
#page-card-search .csw-tools .sort-btn, #page-card-search .csw-tools .search-reset { min-height: 36px; color: #c7bad6; border-radius: 8px; }
#page-card-search .csw-tools .sort-btn.active { color: #160e24; }
#page-card-search .csw-shell > .card-list-container { min-height: 0; overscroll-behavior: contain; scrollbar-gutter: stable; padding-bottom: 28px; }
#page-card-search .csw-filter-drawer { position: fixed; inset: 0; width: auto; z-index: 100; background: rgba(3,3,10,.72); align-items: center; padding: 18px; }
#page-card-search .csw-filter-panel { width: min(560px,100%); max-height: min(82dvh,700px); margin: auto; border: 1px solid var(--shell-edge); border-radius: 16px; padding: 18px; overscroll-behavior: contain; }
#page-card-search .csw-filter-close { min-width: 44px; min-height: 44px; border: 1px solid var(--shell-edge); border-radius: 10px; }
#page-card-search .csw-filter-panel .filter-btn { min-height: 40px; }
#page-card-search .csw-filter-panel .filter-label { color: #c4b8d1; }
#page-card-search .csw-filter-actions { position: sticky; bottom: -18px; padding: 12px 0 2px; background: #11101d; }
#page-card-search .search-empty { min-height: 220px; padding: 26px 20px; border: 1px dashed var(--shell-edge); border-radius: 14px; color: var(--shell-muted); }
#page-card-search .search-empty .se-tx { max-width: 460px; line-height: 1.8; }
#page-card-search .se-clear { min-height: 44px; }

/* 卡组：卡面先看详情，增减有明确触达区；手机高级筛选使用原节点。 */
#page-deck-editor .dwb-save, #page-deck-editor .dwb-menu-btn, #page-deck-editor .back-btn { min-height: 42px; }
#page-deck-editor .dwb-menu-btn { min-width: 42px; }
#page-deck-editor .dwb-filters .filter-btn { min-height: 34px; color: #bbaeC9; }
#page-deck-editor .dwb-filters .filter-btn.active { color: #160e24; }
#page-deck-editor .dwb-empty small { color: #aaa0b8; }
#page-deck-editor .dwb-deck-card:focus-within .dwb-minus { opacity: 1; }
#page-deck-editor .mdl-tools { display: flex; align-items: center; flex: none; gap: 8px; padding: 5px 10px; }
#page-deck-editor .mdl-tools [data-md-results] { min-width: 0; flex: 1; font-size: 12px; color: #c5b9d4; }
#page-deck-editor .mdl-tools button { min-height: 38px; border: 1px solid var(--shell-edge); border-radius: 8px; padding: 6px 10px; background: rgba(var(--brand-rgb), .1); color: #d2b8f5; font-size: 12px; cursor: pointer; }
#page-deck-editor .mdl-hint { flex: none; margin: 0; padding: 2px 12px 7px; color: #b3a9c0; font-size: 11px; line-height: 1.6; }
#page-deck-editor .mobile-deck-library { z-index: 75; }
#page-deck-editor .mobile-deck-library .mdl-pool { overscroll-behavior: contain; }

/* 准备：保持原规则校验，修复过量/待选择反馈与 CTA 层级。 */
#page-duel-prep .dpw-flow-hint { margin: 12px 0 0; padding: 9px 11px; border-left: 2px solid var(--brand); border-radius: 0 7px 7px 0; background: rgba(var(--brand-rgb), .06); color: #c0b3cb; font-size: 12px; line-height: 1.7; }
#page-duel-prep .dpw-status-item small, #page-duel-prep .dpw-deck-info small { color: #b8a9c7; }
#page-duel-prep .dpw-deck-pick, #page-duel-prep .diff-seg-btn, #page-duel-prep .more-line.toggle { min-height: 42px; }
#page-duel-prep #player-left-ready { display: inline-flex; align-items: center; min-height: 44px; }
#page-duel-prep .dpw-bottom-start:disabled { cursor: wait; }
#page-duel-prep .dpw-report-head { gap: 12px; }
#page-duel-prep .dpw-report-head span { text-align: right; }

/* 好友：原名片/复制/QR完整移入；危险操作保留且降为次级，不再放无行为的假省略号。 */
#page-friends #friends-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#page-friends .sw-action-sub, #page-friends .sw-stat span, #page-personal .sw-shortcut small { color: var(--shell-muted); line-height: 1.6; }
#page-friends .sw-action-note { color: #ada0bd; font-size: 11px; line-height: 1.7; margin: 9px 0 0; }
#page-friends .sw-actions .lobby-search { min-height: 44px; font-size: 16px; }
#page-friends .sw-actions .refresh-btn { min-height: 44px; min-width: 64px; }
#page-friends [data-sw-code] .my-code-row { margin-top: 10px; width: 100%; }
#page-friends [data-sw-code] .idcard { min-width: 0; width: 100%; }
#page-friends [data-sw-code] .idcard-main { min-width: 0; }
#page-friends [data-sw-code] .idcard-code { max-width: 100%; overflow-wrap: anywhere; }
#page-friends .friend-actions:after { display: none; content: none; }
#page-friends .friend-actions .friend-btn.danger { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: #e0a2ad; border-color: rgba(226,123,147,.28); background: transparent; }
#page-friends .friend-btn { min-height: 40px; }
#page-friends .friend-btn:disabled { opacity: .48; }
#page-friends .friend-inbox .section-title { display: block; }
#page-friends .friend-empty { color: #b6aac4; line-height: 1.8; }
#page-friends .friend-empty .shell-inline-action { display: flex; width: fit-content; margin: 12px auto 0; }
#page-personal .pa-profile-actions .danger { display: inline-flex; color: #e0a2ad; }
#page-personal .sw-collapse-toggle { min-height: 42px; gap: 10px; }
#page-personal .settings-section.collapsed h3 { margin-bottom: 0; }
#page-personal .settings-action, #page-personal .pa-link-btn { min-height: 40px; }
#page-personal .settings-note { color: #b1a5bf; line-height: 1.8; }
#page-personal .pa-col { min-width: 0; width: 100%; }

/* 联机仅改外壳，不发起/替换业务请求。 */
#page-online .lobby-quick-card { border-radius: 12px; }
#page-online .lobby-quick-card .lqc-sub { color: #b0a4be; line-height: 1.6; }
#page-online .lobby-rooms-tools { gap: 8px; }
#page-online .lobby-rooms-tools .refresh-btn { flex:none; min-width:68px; white-space:nowrap; }
#page-online .back-btn, #page-duel-prep .back-btn { display:inline-flex; align-items:center; gap:5px; min-width:64px; min-height:40px; padding:5px 9px; white-space:nowrap; }
#page-online .back-btn svg, #page-duel-prep .back-btn svg { width:16px; height:16px; flex:none; }
#page-online :is(.lobby-search,.room-code-input,.refresh-btn,.lqc-btn) { min-height: 44px; }
#page-online .shell-room-feedback { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; color: #b9acc8; font-size: 12px; line-height: 1.7; }
#page-online .shell-room-feedback > span { min-width: 0; overflow-wrap: anywhere; }
#page-online .shell-room-feedback .shell-inline-action { flex: none; }
#page-online .room-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #b1a4c0; }

@media (max-width: 767px) {
    #page-main .hero-actions { flex-direction:column; flex-wrap:nowrap; align-items:stretch; }
    #page-main .hero-actions .hero-cta { flex:0 0 auto; justify-content:center; min-height:56px; padding:12px 16px; }
    #page-main .hero-actions .hero-cta.ghost { min-height:44px; padding:10px 16px; }
    #page-main .hero-cta .memo { font-size: 11px; }
    #page-main .shell-home-context { align-items: flex-start; font-size: 11px; }
    #page-main .shell-context-dot { margin-top: 7px; }
    #page-main .feat-card .fd { font-size: 11px; }
    #page-card-search .csw-shortcuts { flex-wrap: wrap; overflow: visible; }
    #page-card-search .csw-quick, #page-card-search .csw-filter-open { padding: 7px 10px; min-height: 40px; }
    #page-card-search .csw-filter-open { margin-left: 0; }
    #page-card-search .csw-tools { gap: 7px; }
    #page-card-search .csw-tools .sort-seg { gap: 5px; }
    #page-card-search .csw-tools .sort-btn { padding: 6px 10px; min-height: 38px; }
    #page-card-search .csw-tools .search-reset { grid-column: 1/-1; justify-self: end; }
    #page-card-search .csw-filter-drawer { align-items: flex-end; padding: 0; }
    #page-card-search .csw-filter-panel { margin: 0 auto; border-radius: 16px 16px 0 0; max-height: 88dvh; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
    #page-card-search .csw-filter-panel .filter-btn { min-height: 44px; }
    #page-card-search .csw-shell > .card-list-container { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
    #page-card-search .csw-shell > .card-list-container .search-card-item { height: auto; min-height: 0; aspect-ratio: 450/629; }
    #page-card-search .csw-shell > .card-list-container .search-card-img { width: 100%; height: 100%; object-fit: cover; }
    #page-card-search .csw-shell > .card-list-container .search-card-overlay { inset: auto 0 0; padding: 32px 8px 8px; background: linear-gradient(transparent,#050510ed 38%); }
    #page-card-search .csw-shell > .card-list-container .sc-name { white-space: normal; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
    #page-card-search .csw-shell > .card-list-container :is(.sc-type,.search-card-stats) { font-size: 11px; line-height: 1.5; }
    #page-card-search .csw-shell > .card-list-container .search-card-item { border-radius: 10px; }
    #page-deck-editor.mobile-deck-workbench-active .deck-workbench { height: 100dvh; }
    #page-deck-editor.mobile-deck-workbench-active .dwb-name { height: 42px; font-size: 16px; }
    #page-deck-editor.mobile-deck-workbench-active .dwb-save { height: 42px; }
    #page-deck-editor.mobile-deck-workbench-active .dwb-menu-btn { height: 42px; width: 42px; }
    #page-deck-editor.mobile-deck-workbench-active .dwb-grp-row { gap: 6px; margin-left: 8px; margin-right: 8px; }
    #page-deck-editor.mobile-deck-workbench-active .dwb-grp-row .grp-btn { width: 42px; height: 44px; flex-basis: 42px; }
    #page-deck-editor .mobile-deck-bottom button { min-height: 46px; }
    #page-deck-editor .mobile-deck-library .mdl-close { width: 44px; height: 44px; }
    #page-deck-editor .mobile-deck-library .mdl-filters button { min-height: 40px; }
    #page-deck-editor .mobile-deck-library.filters-open .dwb-right > .dwb-filters { display: flex !important; max-height: 35dvh; overflow-y: auto; padding: 8px 4px; margin-bottom: 8px; }
    #page-deck-editor .mobile-deck-library.filters-open .dwb-filters .filter-row { display: flex !important; }
    #page-deck-editor .mobile-deck-library.filters-open .dwb-filters .filter-row:first-child { display: none !important; }
    #page-deck-editor .mobile-deck-library .dwb-filters .filter-btn { min-height: 40px; }
    #page-deck-editor .mobile-deck-library .mdl-pool { padding-top: 0; padding-bottom: max(12px,env(safe-area-inset-bottom,0px)); }
    #page-duel-prep .duel-brief-wrap { padding-bottom: calc(90px + env(safe-area-inset-bottom,0px)); }
    #page-duel-prep .dpw-bottom { z-index: 35; bottom: 0; }
    #page-duel-prep .dpw-bottom button { min-height: 46px; }
    #page-duel-prep .dpw-deck-summary { flex-wrap: wrap; }
    #page-duel-prep .dpw-status-item b { font-size: 12px; }
    #page-friends .friend-actions { padding-left: 0; gap: 8px; flex-wrap: wrap; }
    #page-friends .friend-actions .friend-btn { min-height: 44px; }
    #page-friends .friend-actions .friend-btn.danger { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
    #page-personal .pa-profile-card { flex-wrap: wrap; gap: 12px; }
    #page-personal .pa-profile-actions { width: 100%; gap: 8px; }
    #page-personal .pa-profile-actions .pa-link-btn { min-height: 42px; }
    #page-personal .pa-profile-actions .danger { margin-left: auto; display: inline-flex; }
    #page-online .lobby-rooms-head { flex-wrap: wrap; gap: 10px; }
    #page-online .lobby-rooms-tools { width: 100%; min-width: 0; }
    #page-online .lobby-rooms-tools .lobby-search { flex: 1; min-width: 0; font-size: 16px; }
}
@media (max-width: 359px) {
    #page-card-search .csw-shell > .card-list-container { grid-template-columns: 1fr; }
    #page-card-search .csw-shell > .card-list-container .search-card-item { min-height: 112px; }
    #page-main .shell-home-context { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    :is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) *,
    :is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) *::before,
    :is(#page-main,#page-card-search,#page-deck-editor,#page-duel-prep,#page-friends,#page-personal,#page-online) *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
}
