/* ═══════════════════════════════════════════════════════════════════════════
   Market Analysis — Visual Design
   UX: Von Restorff (accent colors), System-1 (stat hero), Serial Position
       (top-3 badge), Skeleton (spatial memory), RWD-first layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── FAB label: hidden on mobile, shown on desktop ────────────────────── */
.fab-label {
    display: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}

/* ── Shared FAB base (all 3 floating action buttons) ──────────────────── */
.gacha-fab,
.market-analysis-btn {
    position: fixed;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.gacha-fab:hover,
.market-analysis-btn:hover { transform: scale(1.1); }
.gacha-fab:active,
.market-analysis-btn:active { transform: scale(0.95); }
.gacha-fab:focus-visible,
.market-analysis-btn:focus-visible {
    outline: 3px solid rgba(255,255,255,0.85);
    outline-offset: 2px;
}

/* ── Gacha FAB (抽卡模擬器) ────────────────────────────────────────────── */
.gacha-fab {
    bottom: calc(160px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(135deg, #14213d 0%, #6c3eb8 100%);
    box-shadow: 0 4px 14px rgba(108, 62, 184, 0.45);
    text-decoration: none;
}
.gacha-fab:hover { box-shadow: 0 6px 20px rgba(108, 62, 184, 0.65); }
.gacha-fab img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    pointer-events: none;
}

/* ── Market Analysis FAB ────────────────────────────────────────────────── */
.market-analysis-btn {
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.5);
}
.market-analysis-btn:hover { box-shadow: 0 6px 20px rgba(255, 107, 53, 0.65); }

@media (max-width: 480px) {
    .gacha-fab,
    .market-analysis-btn {
        right: 16px;
        width: 48px;
        height: 48px;
    }
    .gacha-fab {
        bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    }
    .gacha-fab img { width: 26px; height: 26px; }
    .market-analysis-btn {
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .gacha-fab,
    .market-analysis-btn { transition: none; }
}

/* ── LINE Bot FAB ─────────────────────────────────────────────────────────── */
.line-bot-btn {
    position: fixed;
    right: 24px;
    bottom: calc(228px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #06C755;
    box-shadow: 0 4px 14px rgba(6, 199, 85, 0.5);
    color: white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.line-bot-btn__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    pointer-events: none;
}
.line-bot-btn__label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    color: white;
}
.line-bot-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(6, 199, 85, 0.65);
}
.line-bot-btn:active { transform: scale(0.95); }
.line-bot-btn:focus-visible {
    outline: 3px solid rgba(255,255,255,0.85);
    outline-offset: 2px;
}

/* ── LINE QR Popover ──────────────────────────────────────────────────────── */
/* 置中模態:手機 / 平板 / 窄桌 / overlap 全部統一用「置中 + 暗遮罩」,
   只有 ≥1280 非 overlap 的 icon rail(hover 互動,本質不同)才改用 fly-out。 */
.line-qr-popover {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    transform-origin: center;
    background: var(--color-bg-elevated);
    border: 1.5px solid rgba(20,33,61,0.18);
    border-radius: 16px;
    box-shadow: 0 3px 0 0 rgba(20,33,61,0.16), 0 12px 26px rgba(20,33,61,0.16);
    padding: 15px 15px 14px;
    z-index: 1010;
    width: 208px;
    max-height: 86vh;
    overflow-y: auto;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
}
.line-qr-popover.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}
/* 暗底遮罩:與置中模態成對出現(≥1280 非 overlap 的 rail 模式關閉,見下方 media) */
.line-qr-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1009;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.line-qr-backdrop.show { opacity: 1; visibility: visible; }
.line-qr-popover__close {
    position: absolute;
    top: 8px;
    right: 9px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 16px;
    line-height: 1;
    padding: 4px;
    touch-action: manipulation;
}
/* 眉標:深藍 800 + 灰黑細線 */
.line-qr-popover__title {
    font-weight: 800;
    font-size: 13px;
    color: #14213d;
    letter-spacing: 0.02em;
    margin: 2px 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(34,40,56,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.line-qr-popover__group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.line-qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}
/* 實色方塊徽標(近直角):官方帳號=深藍 / 交流社群=橘 */
.line-qr-item__label {
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #ffffff;
    padding: 3px 13px;
    border-radius: 5px;
    line-height: 1.45;
}
.line-qr-item__label--official { background: #14213d; }
.line-qr-item__label--group    { background: #fca311; color: #14213d; }
.line-qr-item__cap {
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--color-text-secondary);
    margin: 1px 0 0;
    max-width: 160px;
    text-align: center;
}
/* QR 掃描相框:白底 + 橘 L 角標 + 實體硬陰影 */
.line-qr-frame {
    padding: 10px;
    border-radius: 10px;
    background-color: #ffffff;
    border: 1.5px solid rgba(20,33,61,0.16);
    box-shadow: 0 2.5px 0 0 rgba(20,33,61,0.15);
    background-image:
        linear-gradient(#fca311,#fca311), linear-gradient(90deg,#fca311,#fca311),
        linear-gradient(#fca311,#fca311), linear-gradient(90deg,#fca311,#fca311),
        linear-gradient(#fca311,#fca311), linear-gradient(90deg,#fca311,#fca311),
        linear-gradient(#fca311,#fca311), linear-gradient(90deg,#fca311,#fca311);
    background-size:
        3px 14px, 14px 3px, 3px 14px, 14px 3px,
        3px 14px, 14px 3px, 3px 14px, 14px 3px;
    background-position:
        6px 6px, 6px 6px, calc(100% - 6px) 6px, calc(100% - 6px) 6px,
        6px calc(100% - 6px), 6px calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) calc(100% - 6px);
    background-repeat: no-repeat;
}
.line-qr-popover__img {
    width: 138px;
    height: 138px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}
.line-qr-popover__desc {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(20,33,61,0.1);
    line-height: 1.5;
}
/* ── 深色模式:硬陰影轉黑、眉標暖白、相框留白供掃描 ── */
[data-theme="dark"] .line-qr-popover {
    border-color: rgba(232,237,248,0.18);
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.5), 0 12px 26px rgba(0,0,0,0.5);
}
[data-theme="dark"] .line-qr-popover__title {
    color: #f5f2ec;
    border-bottom-color: rgba(232,237,248,0.38);
}
[data-theme="dark"] .line-qr-item__label--official { background: #2f4a8a; }
[data-theme="dark"] .line-qr-frame {
    background-color: #ffffff;
    border-color: rgba(232,237,248,0.22);
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.5);
}
[data-theme="dark"] .line-qr-popover__desc {
    border-top-color: rgba(232,237,248,0.14);
}

@media (max-width: 480px) {
    .line-bot-btn {
        right: 16px;
        bottom: calc(212px + env(safe-area-inset-bottom, 0px));
        width: 48px;
        height: 48px;
    }
    /* 手機小螢幕:QR 略縮,置中模態定位沿用 base(已統一) */
    .line-qr-popover__img { width: 128px; height: 128px; }
}

@media (prefers-reduced-motion: reduce) {
    .line-bot-btn { transition: none; }
    .line-qr-popover { transition: none; }
}

/* ── Desktop Side Widget Panel (≥ 1280px) ────────────────────────────────
 * Design: "Icon Rail" — 52px fixed right strip, full-height (below header).
 * Each item = colored icon tab + fly-out card panel sliding to the left on
 * hover. No height-overflow issues: rail spans full viewport height, icons
 * are centered vertically. No glow, flat solid colors, cute aesthetic.
 * ──────────────────────────────────────────────────────────────────────── */
#desktopSidePanel { display: none; }

@media (min-width: 1280px) {
    .gacha-fab,
    .market-analysis-btn,
    .line-bot-btn,
    .line-qr-popover,
    .line-qr-backdrop { display: none !important; }

    /* Rail: full-height strip anchored to right edge, below site header.
       Icons cluster at the BOTTOM-right (conventional FAB anchor) instead of
       floating mid-screen; fly-outs stay vertically centered on each icon. */
    #desktopSidePanel {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: stretch;
        gap: 8px;
        position: fixed;
        right: 0;
        top: 76px;   /* matches site header height (logo 60px + padding 8px×2) */
        bottom: 0;
        width: 52px;
        z-index: 1000;
        padding: 16px 0 56px;
    }

    /* Each item: position: relative so the fly-out can break out */
    .dsp-item {
        position: relative;
        display: block;
    }

    /* Icon tab: 52×52 colored square with rounded left corners (right flush to edge) */
    .dsp-item-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 52px;
        border: none;
        border-radius: 10px 0 0 10px;
        color: #ffffff;
        cursor: pointer;
        text-decoration: none;
        transition: transform 0.14s;
        font-family: inherit;
        font-size: 0;   /* hide any stray text nodes */
        flex-shrink: 0;
    }
    .dsp-item-btn svg { flex-shrink: 0; }
    .dsp-item-btn img { filter: brightness(0) invert(1); }
    .dsp-item-btn:hover  { transform: translateX(-3px); }
    .dsp-item-btn:active { transform: translateX(-1px); }
    .dsp-item-btn:focus-visible { outline: 2px solid #fca311; outline-offset: 2px; border-radius: 10px 0 0 10px; }

    /* Per-item rail colors */
    .dsp-item--line     .dsp-item-btn { background: #07A047; }
    .dsp-item--gacha    .dsp-item-btn { background: #E05428; }
    .dsp-item--market   .dsp-item-btn { background: #2563EB; }
    .dsp-item--feedback .dsp-item-btn { background: #D97706; }

    /* Fly-out panel: absolutely positioned to the LEFT of the 52px rail.
     * Starts slightly right and faded; slides in and fades on hover.
     * right: 52px = flush against the rail with no gap, so hover state
     * doesn't break when the mouse moves from icon into the panel.
     * The cute "Sticker Stack" design (solid color header + white body) is
     * preserved here — same visual language, now used as a tooltip panel. */
    .dsp-card {
        position: absolute;
        right: 52px;  /* flush against the 52px rail tab */
        top: 50%;
        transform: translateY(-50%) translateX(8px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s, transform 0.18s;
        z-index: 10;
        /* card chrome */
        width: 182px;
        border-radius: 18px;
        overflow: hidden;
        border: 2px solid rgba(0,0,0,0.14);
        box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        display: flex;
        flex-direction: column;
        font-family: inherit;
        font-size: 13px;
        color: #ffffff;
        text-decoration: none;
    }

    /* Show fly-out on hover or keyboard focus within the item */
    .dsp-item:hover .dsp-card,
    .dsp-item:focus-within .dsp-card {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(-50%) translateX(0);
    }

    /* ── Fly-out header: colored strip with icon + label ── */
    .dsp-card__hero {
        display: flex;
        align-items: center;
        gap: 7px;
        padding: 13px 14px 9px;
        font-size: 13px;
        font-weight: 800;
        line-height: 1.2;
        color: #ffffff;
    }
    .dsp-card__hero svg,
    .dsp-card__hero img { flex-shrink: 0; }
    .dsp-card__hero img { filter: brightness(0) invert(1); }

    /* ── White inset body — "label on sticker" ── */
    .dsp-card__body {
        background: #ffffff;
        border-radius: 12px;
        margin: 4px 8px 8px;
        padding: 11px 12px 12px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* ── QR scan frame: light bg + orange L-bracket corner marks ── */
    .dsp-card__qr-frame {
        border-radius: 8px;
        padding: 7px;
        background-color: #ffffff;
        border: 1.5px solid rgba(20,33,61,0.14);
        box-shadow: 0 2px 0 0 rgba(20,33,61,0.14);
        background-image:
            linear-gradient(#fca311, #fca311),
            linear-gradient(90deg, #fca311, #fca311),
            linear-gradient(#fca311, #fca311),
            linear-gradient(90deg, #fca311, #fca311),
            linear-gradient(#fca311, #fca311),
            linear-gradient(90deg, #fca311, #fca311),
            linear-gradient(#fca311, #fca311),
            linear-gradient(90deg, #fca311, #fca311);
        background-size:
            2.5px 11px, 11px 2.5px,
            2.5px 11px, 11px 2.5px,
            2.5px 11px, 11px 2.5px,
            2.5px 11px, 11px 2.5px;
        background-position:
            0    0,    0    0,
            100% 0,    100% 0,
            0    100%, 0    100%,
            100% 100%, 100% 100%;
        background-repeat: no-repeat;
    }
    .dsp-card__qr { width: 100%; height: auto; border-radius: 3px; display: block; }

    /* ── Two-up QR blocks (官方帳號 + 交流社群) ── */
    .dsp-card__qr-block {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    /* 實色方塊徽標(近直角):官方帳號=深藍 / 交流社群=橘 */
    .dsp-card__qr-label {
        align-self: center;
        display: inline-block;
        font-size: 10.5px;
        font-weight: 800;
        letter-spacing: 0.05em;
        color: #ffffff;
        padding: 2px 11px;
        border-radius: 5px;
        line-height: 1.45;
    }
    .dsp-card__qr-label--official { background: #14213d; }
    .dsp-card__qr-label--group    { background: #fca311; color: #14213d; }
    .dsp-card__qr-cap {
        font-size: 10px;
        line-height: 1.4;
        color: #3d4451;
        margin: 5px 0 0;
        text-align: center;
    }

    /* ── Body text + CTA ── */
    .dsp-card__desc {
        font-size: 11.5px;
        color: #3d4451;
        line-height: 1.5;
        margin: 0;
    }
    .dsp-card__cta {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        align-self: flex-end;
        font-size: 11px;
        font-weight: 800;
        border-radius: 20px;
        padding: 4px 11px;
        color: #ffffff;
        white-space: nowrap;
        margin-top: 2px;
    }

    /* ── Fly-out card colors ── */
    .dsp-card--line     { background: #07A047; }
    .dsp-card--gacha    { background: #E05428; }
    .dsp-card--market   { background: #2563EB; }
    .dsp-card--feedback { background: #D97706; }

    .dsp-card--line     .dsp-card__cta { background: #07A047; }
    .dsp-card--gacha    .dsp-card__cta { background: #E05428; }
    .dsp-card--market   .dsp-card__cta { background: #2563EB; }
    .dsp-card--feedback .dsp-card__cta { background: #D97706; }

    /* ── 可點卡片（gacha / market / feedback）── LINE 卡屬資訊型，維持 cursor:auto */
    .dsp-item--gacha    .dsp-card,
    .dsp-item--market   .dsp-card,
    .dsp-item--feedback .dsp-card,
    .dsp-item--gacha    .dsp-card__cta,
    .dsp-item--market   .dsp-card__cta,
    .dsp-item--feedback .dsp-card__cta { cursor: pointer; }

    /* CTA 可點 affordance：卡片 hover 時膠囊底色加深 + 箭頭微右移 2px */
    .dsp-item--gacha    .dsp-card__cta,
    .dsp-item--market   .dsp-card__cta,
    .dsp-item--feedback .dsp-card__cta { transition: filter .15s ease, transform .15s ease; }
    .dsp-item--gacha:hover    .dsp-card__cta,
    .dsp-item--market:hover   .dsp-card__cta,
    .dsp-item--feedback:hover .dsp-card__cta { filter: brightness(0.9); transform: translateX(2px); }

    /* ── Dark mode ── */
    [data-theme="dark"] .dsp-card { border-color: rgba(0,0,0,0.4); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
    [data-theme="dark"] .dsp-card__body { background: #22252F; }
    [data-theme="dark"] .dsp-card__qr-frame { background-color: #ffffff; border-color: rgba(232,237,248,0.2); }
    [data-theme="dark"] .dsp-card__desc { color: rgba(255,255,255,0.82); }
    [data-theme="dark"] .dsp-card__qr-cap { color: rgba(255,255,255,0.72); }
    [data-theme="dark"] .dsp-card__qr-label--official { background: #2f4a8a; }

    /* 遮擋搜尋格子時切回小圓形 FAB */
    body.dsp-overlap #desktopSidePanel { display: none !important; }
    body.dsp-overlap .gacha-fab,
    body.dsp-overlap .market-analysis-btn,
    body.dsp-overlap .line-bot-btn,
    body.dsp-overlap .feedback-btn { display: flex !important; }
    /* FAB 救回時,LINE QR popover + 遮罩也要一併救回(置中模態,與其他寬度一致) */
    body.dsp-overlap .line-qr-popover { display: block !important; }
    body.dsp-overlap .line-qr-backdrop { display: block !important; }

    @media (prefers-reduced-motion: reduce) {
        .dsp-card,
        .dsp-card__cta,
        .dsp-item-btn { transition: none; }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Market Analysis — Solid Pop 版
   品牌三色骨架（深藍 #14213D / 橘 #FCA311 / 白 + 中性灰）
   實體硬陰影、實色方塊標籤（近直角 4~6px）、眉標＝深藍 800 + 灰黑細線
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Source Badges：實色方塊（鞋店＝深藍白字 / PSA商店＝橘底深藍字）────────── */
.ma-source-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.8;
    white-space: nowrap;
    flex-shrink: 0;
}
.ma-source-badge--snkr { background: #14213d; color: #fff; }
.ma-source-badge--psa  { background: #fca311; color: #14213d; }

/* ── Notice Banner：白卡＋灰細邊＋硬陰影，不用淡彩底 ─────────────────────── */
.ma-notice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: 11px var(--space-md);
    margin-bottom: var(--space-lg);
    background: var(--color-bg-surface);
    border: 1px solid rgba(20,33,61,0.16);
    border-radius: 10px;
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.15);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    line-height: 1.6;
}
.ma-notice-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.ma-notice strong { color: #14213d; font-weight: 800; }

/* ── Page Shell ───────────────────────────────────────────────────────────── */
.ma-page {
    min-height: 100dvh;
    background: #eef1f6;
    padding-bottom: var(--space-xxl);
    font-family: var(--font-family-base);
}

/* ── Container ────────────────────────────────────────────────────────────── */
.ma-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ── Header：深藍面板＋硬陰影 ─────────────────────────────────────────────── */
.ma-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    height: 64px;
    padding: 0 var(--space-md);
    background: #14213d;
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.2);
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.18);
    position: static;
    border-bottom: none;
    margin-bottom: var(--space-md);
}

.ma-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.ma-header-back {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fca311;
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 700;
    white-space: nowrap;
    min-height: 44px;
    transition: color 0.15s;
}
.ma-header-back:hover { color: #ffd57e; text-decoration: underline; }

.ma-header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    white-space: nowrap;
}
.ma-header-brand h1 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.01em;
}
.ma-flame { font-size: 20px; }

.ma-header-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    font-size: var(--font-size-xs);
    color: rgba(255,255,255,0.45);
    opacity: 0;
    transition: opacity 0.4s ease;
    font-variant-numeric: tabular-nums;
}
.ma-header-center.visible { opacity: 1; }
.ma-meta-label { color: rgba(255,255,255,0.5); white-space: nowrap; }
.ma-meta-value { color: #fff; font-weight: 700; white-space: nowrap; }
.ma-meta-arrow { color: #fca311; font-size: 11px; }

.ma-header-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.ma-header-right .theme-toggle-btn,
.ma-header-right .currency-toggle-btn { margin-left: 0; }

/* 重新整理：橘實心方塊鈕＋按壓下沉 */
.ma-refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #fca311;
    border: none;
    border-radius: 6px;
    color: #14213d;
    font-size: var(--font-size-xs);
    font-weight: 800;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    min-height: 40px;
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.3);
    transition: filter 0.15s, transform 0.1s, box-shadow 0.1s;
}
.ma-refresh-btn:hover { filter: brightness(1.06); }
.ma-refresh-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0.5px 0 0 rgba(0,0,0,0.3);
}
.ma-refresh-icon { font-size: 15px; display: inline-block; }
.ma-refresh-btn.spinning .ma-refresh-icon { animation: ma-spin 0.7s linear infinite; }

@media (max-width: 640px) {
    .ma-container { padding: 0 var(--space-sm); }
    .ma-header { height: 52px; padding: 0 var(--space-sm); border-radius: 12px; margin-bottom: var(--space-sm); }
    .ma-header-center { display: none; }
    .ma-refresh-label { display: none; }
    .ma-refresh-btn { padding: 7px 10px; min-height: 36px; }
    .ma-header-brand h1 { font-size: var(--font-size-sm); }
    .ma-back-label { display: none; }
}

/* ── Groups ───────────────────────────────────────────────────────────────── */
.ma-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* 章節眉標：深藍 800 + 下方 2px 灰黑細線 */
.ma-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: 0 2px 9px;
    border-bottom: 2px solid rgba(34,40,56,0.55);
}

.ma-group-icon { font-size: 17px; flex-shrink: 0; }

.ma-group-label {
    font-size: 13px;
    font-weight: 800;
    color: #14213d;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.ma-group-line { flex: 1; }

.ma-group-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

@media (max-width: 860px) { .ma-group-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) {
    .ma-group-grid   { gap: var(--space-md); }
    .ma-groups       { gap: var(--space-lg); }
    .ma-group-label  { font-size: 12px; }
}

/* ── Store sub-groups：實色方塊徽標＋灰細線 ──────────────────────────────── */
.ma-store-group { margin-bottom: var(--space-xl); }
.ma-store-group:last-child { margin-bottom: 0; }

.ma-store-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: 0 2px 8px;
    border-bottom: 1px solid rgba(34,40,56,0.28);
}

.ma-store-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.ma-store-badge--snkr { background: #14213d; color: #fff; }
.ma-store-badge--psa  { background: #fca311; color: #14213d; }

.ma-store-name {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-text-tertiary);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.ma-store-header .ma-group-line { flex: 1; }

/* ── Section Card：白卡＋灰細邊＋實體硬陰影 ──────────────────────────────── */
.ma-section {
    background: var(--color-bg-surface);
    border: 1px solid rgba(20,33,61,0.16);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.15);
    transition: box-shadow 0.15s, transform 0.15s;
    position: relative;
}
.ma-section:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 0 rgba(0,0,0,0.15);
}

.ma-section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 4px;
    gap: var(--space-sm);
    padding: 13px var(--space-md) 11px;
    border-bottom: 2px solid rgba(34,40,56,0.5);
    background: transparent;
}

/* 圖示盒：中性淺灰底＋灰細邊（近直角） */
.ma-section-icon {
    width: 30px;
    height: 30px;
    background: #f1f3f8;
    border: 1px solid rgba(20,33,61,0.12);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    line-height: 1;
}

.ma-section-title {
    font-size: var(--font-size-base);
    font-weight: 800;
    color: #14213d;
    margin: 0;
    flex: 0 1 auto;
    letter-spacing: -0.01em;
}

.ma-section-sub {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    margin-left: auto;
}

/* ── Ranking List ─────────────────────────────────────────────────────────── */
.ma-list { list-style: none; margin: 0; padding: 0; }

.ma-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-md);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
    position: relative;
}
.ma-item:last-child { border-bottom: none; }
.ma-item:hover  { background: #f4f6fa; }
.ma-item:active { background: #e9edf4; }
.ma-item:focus-visible { outline: 2px solid #fca311; outline-offset: -2px; }

/* 名次徽章：實色方塊（近直角）。1＝橘底深藍字、2＝深藍、3＝中性灰 */
.ma-rank {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    background: var(--color-bg-surface);
    color: var(--color-text-tertiary);
    border: 1px solid rgba(20,33,61,0.18);
    font-variant-numeric: tabular-nums;
}
.ma-rank-1 {
    background: #fca311;
    color: #14213d;
    border-color: transparent;
    width: 32px;
    height: 32px;
    font-size: 14px;
    box-shadow: 0 2px 0 0 rgba(0,0,0,0.18);
}
.ma-rank-2 { background: #14213d; color: #fff; border-color: transparent; }
.ma-rank-3 { background: #6b7280; color: #fff; border-color: transparent; }

/* 卡圖縮圖：直式卡比例＋小硬陰影 */
.ma-thumb {
    width: 40px;
    height: 56px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--color-bg-elevated);
    border: 1px solid rgba(20,33,61,0.14);
    box-shadow: 0 1.5px 0 0 rgba(0,0,0,0.12);
}

.ma-info { flex: 1; min-width: 0; }

.ma-name {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.ma-meta {
    font-size: 11px;
    color: var(--color-text-tertiary);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

/* Stat — 數據主角：深藍粗體、tabular-nums */
.ma-stat {
    text-align: right;
    flex-shrink: 0;
    min-width: 60px;
}

.ma-stat-main {
    font-size: 20px;
    font-weight: 800;
    color: #14213d;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.ma-stat-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* 功能色（漲跌）— 文字用 */
.ma-up   { color: #15803d; }
.ma-down { color: #b91c1c; }
.ma-flat { color: var(--color-text-tertiary); }

/* ── 漲跌主徽章：實色方塊（絕不半透明）──────────────────────────────────── */
.ma-stat-main .ma-up,
.ma-stat-main .ma-down,
.ma-stat-main .ma-flat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 9px;
    border-radius: 5px;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    line-height: 1.35;
    box-shadow: 0 2px 0 0 rgba(0,0,0,0.15);
}
.ma-stat-main .ma-up   { background: #16a34a; color: #fff; }
.ma-stat-main .ma-down { background: #dc2626; color: #fff; }
.ma-stat-main .ma-flat { background: #6b7280; color: #fff; }

.ma-stat-sub .ma-up   { color: #15803d; font-weight: 700; }
.ma-stat-sub .ma-down { color: #b91c1c; font-weight: 700; }

/* ── Skeleton ─────────────────────────────────────────────────────────────── */
.ma-skeleton {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-md);
    border-bottom: 1px solid var(--color-border);
}
.ma-skeleton:last-child { border-bottom: none; }

.ma-sk-rank,
.ma-sk-thumb,
.ma-sk-line,
.ma-sk-stat {
    border-radius: 4px;
    background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg-elevated) 50%, var(--color-border) 75%);
    background-size: 200% 100%;
    animation: ma-shimmer 1.4s ease-in-out infinite;
}

.ma-sk-rank  { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }
.ma-sk-thumb { width: 40px; height: 56px; flex-shrink: 0; border-radius: 4px; }
.ma-sk-info  { flex: 1; }
.ma-sk-line-name { display: block; width: 72%; height: 13px; margin-bottom: 6px; }
.ma-sk-line-meta { display: block; width: 48%; height: 11px; }
.ma-sk-stat  { width: 52px; height: 40px; flex-shrink: 0; }

@keyframes ma-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ma-sk-rank, .ma-sk-thumb, .ma-sk-line, .ma-sk-stat { animation: none; background: var(--color-border); }
    .ma-section { transition: none; }
    .ma-refresh-btn.spinning .ma-refresh-icon { animation: none; }
    .ma-item { transition: none; }
}

/* ── Empty / Error ────────────────────────────────────────────────────────── */
.ma-empty {
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: var(--font-size-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.ma-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--space-lg);
    background: #14213d;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: var(--font-size-sm);
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.2);
    transition: filter 0.15s, transform 0.1s, box-shadow 0.1s;
}
.ma-retry-btn:hover { filter: brightness(1.15); }
.ma-retry-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0.5px 0 0 rgba(0,0,0,0.2);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.ma-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    margin-top: var(--space-md);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    font-variant-numeric: tabular-nums;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   深色模式：硬陰影轉黑加重、眉標暖白＋亮線、徽章實色深一號（絕不半透明）
   ═══════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] .ma-page { background: #131415; }

[data-theme="dark"] .ma-header {
    background: #1a2440;
    border-color: rgba(0,0,0,0.45);
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.5);
}

[data-theme="dark"] .ma-notice {
    border-color: rgba(232,237,248,0.18);
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.5);
}
[data-theme="dark"] .ma-notice strong { color: #f5f2ec; }

[data-theme="dark"] .ma-group-header {
    border-bottom-color: rgba(232,237,248,0.38);
}
[data-theme="dark"] .ma-group-label { color: #f5f2ec; }

[data-theme="dark"] .ma-store-header { border-bottom-color: rgba(232,237,248,0.22); }
[data-theme="dark"] .ma-store-badge--snkr { background: #2f4a8a; color: #fff; }
[data-theme="dark"] .ma-source-badge--snkr { background: #2f4a8a; color: #fff; }

[data-theme="dark"] .ma-section {
    border-color: rgba(232,237,248,0.16);
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.5);
}
[data-theme="dark"] .ma-section:hover { box-shadow: 0 4px 0 0 rgba(0,0,0,0.5); }

[data-theme="dark"] .ma-section-header { border-bottom-color: rgba(232,237,248,0.38); }
[data-theme="dark"] .ma-section-title { color: #f5f2ec; }
[data-theme="dark"] .ma-section-icon {
    background: #232526;
    border-color: rgba(232,237,248,0.16);
}

[data-theme="dark"] .ma-item:hover  { background: #202324; }
[data-theme="dark"] .ma-item:active { background: #26292b; }

[data-theme="dark"] .ma-rank {
    background: #232526;
    border-color: rgba(232,237,248,0.2);
    color: var(--color-text-secondary);
}
[data-theme="dark"] .ma-rank-1 { background: #fca311; color: #14213d; border-color: transparent; box-shadow: 0 2px 0 0 rgba(0,0,0,0.5); }
[data-theme="dark"] .ma-rank-2 { background: #2f4a8a; color: #fff; border-color: transparent; }
[data-theme="dark"] .ma-rank-3 { background: #4b5563; color: #fff; border-color: transparent; }

[data-theme="dark"] .ma-thumb {
    border-color: rgba(232,237,248,0.16);
    box-shadow: 0 1.5px 0 0 rgba(0,0,0,0.45);
}

[data-theme="dark"] .ma-stat-main { color: #f5f2ec; }

[data-theme="dark"] .ma-up   { color: #4ade80; }
[data-theme="dark"] .ma-down { color: #f87171; }

[data-theme="dark"] .ma-stat-main .ma-up,
[data-theme="dark"] .ma-stat-main .ma-down,
[data-theme="dark"] .ma-stat-main .ma-flat { box-shadow: 0 2px 0 0 rgba(0,0,0,0.5); }
[data-theme="dark"] .ma-stat-main .ma-up   { background: #166534; color: #fff; }
[data-theme="dark"] .ma-stat-main .ma-down { background: #991b1b; color: #fff; }
[data-theme="dark"] .ma-stat-main .ma-flat { background: #4b5563; color: #fff; }

[data-theme="dark"] .ma-stat-sub .ma-up   { color: #4ade80; }
[data-theme="dark"] .ma-stat-sub .ma-down { color: #f87171; }

[data-theme="dark"] .ma-retry-btn {
    background: #2f4a8a;
    box-shadow: 0 2.5px 0 0 rgba(0,0,0,0.5);
}
[data-theme="dark"] .ma-retry-btn:active { box-shadow: 0 0.5px 0 0 rgba(0,0,0,0.5); }

/* ══════════════════════════════════════════════════════════════════════
   SNKRDUNK 市場熱力圖 (squarified treemap)
   ══════════════════════════════════════════════════════════════════════ */

.ma-heatmap {
    background: #ffffff;
    border: 1px solid rgba(20,33,61,0.22);
    border-radius: 14px;
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.15);
    padding: 14px;
    margin-bottom: 24px;
}

.ma-heatmap-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 2px solid rgba(34,40,56,0.55);
}

.ma-heatmap-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.ma-heatmap-title {
    font-size: 1rem;
    font-weight: 800;
    color: #14213d;
    margin: 0;
}

.ma-heatmap-sub {
    font-size: 0.75rem;
    color: #6b7280;
}

.ma-heatmap-legend {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.ma-hm-lg {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.ma-heatmap-canvas {
    position: relative;
    width: 100%;
    height: clamp(480px, 68vh, 760px);
    overflow: hidden;
    border-radius: 8px;
}

.ma-hm-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
    font-size: 0.9rem;
}

.ma-hm-tile {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px 3px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.65);
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}
.ma-hm-tile:hover { filter: brightness(1.1); z-index: 2; }
.ma-hm-tile:focus-visible { outline: 2px solid #fca311; outline-offset: -2px; z-index: 2; }

.ma-hm-name {
    flex-shrink: 0; /* 只准圖片被壓縮,文字不可被壓扁裁半 */
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ma-hm-pct {
    flex-shrink: 0;
    font-size: 0.66rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ma-hm-tile--tiny .ma-hm-name { display: none; }
.ma-hm-tile--dot  .ma-hm-pct  { display: none; }

/* 大格:卡圖 + 名字 + %(圖片吃掉剩餘高度,等比縮放) */
.ma-hm-tile--img { padding: 4px 3px 3px; }
.ma-hm-img {
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* 色階:實色不透明(Solid Pop 鐵律,禁半透明淡彩) */
.ma-hm--up1   { background: #bbf7d0; color: #14532d; }
.ma-hm--up2   { background: #4ade80; color: #14532d; }
.ma-hm--up3   { background: #15803d; color: #ffffff; }
.ma-hm--down1 { background: #fecaca; color: #7f1d1d; }
.ma-hm--down2 { background: #f87171; color: #7f1d1d; }
.ma-hm--down3 { background: #b91c1c; color: #ffffff; }

/* 檢視切換按鈕:沿用 refresh 按鈕外觀,active 態橘底 */
.ma-view-btn[aria-pressed="true"] {
    background: #fca311;
    color: #14213d;
}

@media (max-width: 767px) {
    .ma-heatmap { padding: 10px; }
    .ma-heatmap-canvas { height: clamp(420px, 62vh, 560px); }
    .ma-view-btn .ma-view-label { display: none; }
}

/* ── 深色模式 ── */
[data-theme="dark"] .ma-heatmap {
    background: #1f2224;
    border-color: rgba(232,237,248,0.18);
    box-shadow: 0 3px 0 0 rgba(0,0,0,0.5);
}
[data-theme="dark"] .ma-heatmap-head { border-bottom-color: rgba(232,237,248,0.38); }
[data-theme="dark"] .ma-heatmap-title { color: #f5f2ec; }
[data-theme="dark"] .ma-heatmap-sub,
[data-theme="dark"] .ma-hm-empty { color: #9ca3af; }

[data-theme="dark"] .ma-hm-tile { border-color: rgba(0,0,0,0.5); }

[data-theme="dark"] .ma-hm--up1   { background: #1c4532; color: #a7f3d0; }
[data-theme="dark"] .ma-hm--up2   { background: #166534; color: #d1fae5; }
[data-theme="dark"] .ma-hm--up3   { background: #16a34a; color: #ffffff; }
[data-theme="dark"] .ma-hm--down1 { background: #4c1d1d; color: #fecaca; }
[data-theme="dark"] .ma-hm--down2 { background: #991b1b; color: #fee2e2; }
[data-theme="dark"] .ma-hm--down3 { background: #dc2626; color: #ffffff; }

[data-theme="dark"] .ma-view-btn[aria-pressed="true"] {
    background: #fca311;
    color: #14213d;
}
