/**
 * Card Details Page Stylesheet
 * 
 * Defines the visual styling for the product detail view, including:
 * - Responsive Grid Layout (Mobile/Desktop)
 * - Typography and Color Variables
 * - Component Styling (Cards, Gauges, Tables)
 * - Interactive Elements (Buttons, Toggles)
 * - Accessibility (Touch Targets, Visibility)
 */

:root {
    /* -------------------------------------------------------------------------- */
    /* Design Tokens: Colors */
    /* -------------------------------------------------------------------------- */
    --primary-color: #14213d;       /* Dark Blue */
    --primary-hover: #0a1120;       /* Darker Blue */
    --text-color: #000000;          /* Black */
    --text-muted: #666666;          /* Gray */
    --bg-color: #e5e5e5;            /* Light Grey */
    --card-bg: #ffffff;             /* White */
    --border-color: #e5e5e5;        /* Light Gray */
    --accent-color: #fca311;        /* Orange */
    --shadow: 0 2.5px 0 0 rgba(0, 0, 0, 0.15); /* Solid Pop 實體硬陰影:往下 2.5px、blur 0 — 對齊 iOS solidCard / styles.css .card */
    
    /* -------------------------------------------------------------------------- */
    /* Design Tokens: Layout & Spacing */
    /* -------------------------------------------------------------------------- */
    /* 圓角分級 — 忠實移植 App(huca-ios CLAUDE.md):Hero 22 / 列表卡 18 / 按鈕 16 / 格子 14 */
    --radius: 18px;                 /* 預設=列表卡/資料面板(App hucaListCard) */
    --radius-hero: 22px;            /* 主角面板(App HucaHeroPanel / solidCard 預設 / sheet 圓角) */
    --radius-btn: 16px;             /* CTA / 按鈕(App CTA) */
    --radius-cell: 14px;            /* 格子 / 縮圖 / 商品圖(App 格子) */
    --container-max-width: 1200px;  /* Maximum content width */
    --spacing-xs: 0.5rem;           /* Extra small spacing (8px) */
    --spacing-sm: 1rem;             /* Small spacing (16px) */
    --spacing-md: 1.5rem;           /* Medium spacing (24px) */
    --spacing-lg: 2rem;             /* Large spacing (32px) */
    
    /* -------------------------------------------------------------------------- */
    /* Design Tokens: Typography */
    /* -------------------------------------------------------------------------- */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-base: 1rem;         /* 16px */
    --font-size-sm: 0.875rem;       /* 14px */
    --font-size-xs: 0.75rem;        /* 12px */
    --line-height-base: 1.5;        /* Standard line height */
    
    /* -------------------------------------------------------------------------- */
    /* Accessibility: Touch Targets */
    /* -------------------------------------------------------------------------- */
    --min-touch-target: 44px;       /* Minimum size for clickable elements */
}

/* Dark Mode Theme */
[data-theme="dark"] {
    /* Colors Override */
    --primary-color: #101A31;
    --primary-hover: #0B1222;
    --text-color: #CECAC4;
    --text-muted: #A59F97;
    --bg-color: #272A2C;
    --card-bg: #181A1B;
    --border-color: #34373A;
    --shadow: 0 2.5px 0 0 rgba(0, 0, 0, 0.55); /* 深色:同款硬陰影,黑色加深才在近黑底可見 */

    /* Ensure accent color is visible */
    --accent-color: #C17902;
}

/* -------------------------------------------------------------------------- */
/* Global Reset & Base Styles */
/* -------------------------------------------------------------------------- */

/* Box-sizing reset for consistent sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base size for rem calculations */
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape on iOS */
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: var(--line-height-base);
}

/* -------------------------------------------------------------------------- */
/* Layout Containers */
/* -------------------------------------------------------------------------- */

/* Main Content Container */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;                 /* Center horizontally */
    padding: 0 var(--spacing-xs);   /* Horizontal padding */
    container-type: inline-size;    /* Enable container queries */
    container-name: main-container;
}

/* -------------------------------------------------------------------------- */
/* Header Section */
/* -------------------------------------------------------------------------- */

.page-header {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--primary-color);
    height: 64px;
    padding: 0 var(--spacing-sm);
    border-radius: var(--radius);
    color: #ffffff;
    box-shadow: var(--shadow);
    gap: var(--spacing-xs);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* 移除預設的 gap，因為內部元素已經有寫死 style margin 進行精確控制 (同 index.php) */
.header-right {
    gap: 0;
}

.header-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0; /* Allow text truncation */
    overflow: hidden;
}

/* Back Navigation Link */
.back-link {
    text-decoration: none;
    color: var(--accent-color);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    min-height: var(--min-touch-target);
    padding: 0;
    border-radius: 4px;
    white-space: nowrap;
}

.back-link:hover {
    text-decoration: underline;
    color: #e5940f;
}

.back-link .back-short { display: none; }

/* Page Title & Brand */
.header-title-text {
    display: none;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.header-title-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.header-title-mark img.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    margin: 0;
}

.brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

/* Responsive Header Rules */
@media (min-width: 768px) {
    .page-header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        justify-content: stretch;
    }

    .header-left { justify-content: flex-start; }
    .header-center { justify-content: center; }
    .header-right { justify-content: flex-end; }

    .header-title-text {
        display: inline;
    }

    .header-title-mark {
        display: none;
    }
}

@media (max-width: 767px) {
    .page-header {
        height: 56px;
        padding: 0 8px;
    }

    .back-link {
        font-size: 0.95rem;
    }
    
    .header-title-mark {
        gap: 6px;
        font-size: 1.05rem;
    }
    
    .header-title-mark img.logo {
        height: 32px;
    }
}

@media (max-width: 420px) {
    .back-link .back-long {
        display: none;
    }

    .back-link .back-short {
        display: inline;
    }
}

@media (max-width: 320px) {
    /* Extreme small screen fallback */
    .header-center {
        display: none;
    }
}

/* -------------------------------------------------------------------------- */
/* Main Grid Layout */
/* -------------------------------------------------------------------------- */

/* Responsive Grid for Card Details */
.card-details-grid {
    display: grid;
    grid-template-columns: 1fr;     /* Default: Single column (Mobile) */
    gap: var(--spacing-md);
    background: var(--card-bg);
    padding: var(--spacing-md);
    border-radius: var(--radius-hero);   /* 主角面板 → Hero 圓角 22 */
    box-shadow: var(--shadow);
    align-items: start;
    width: 100%;
    min-height: 500px; /* Reserve space so hot-cards below doesn't CLS during JS render */
}

@media (min-width: 1024px) {
    .card-details-grid {
        min-height: 700px;
    }
}

.promo-footer {
    display: none;
}

/* Tablet Layout */
@media (min-width: 768px) {
    .card-details-grid {
        padding: var(--spacing-lg); /* Increased padding */
    }
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .card-details-grid {
        grid-template-columns: 320px 1fr; /* Sidebar (Image) + Content */
        gap: var(--spacing-lg);
    }

    /* Desktop: sidebar is sticky, so render as a full-width action button (no floating) */
    .floating-fav-btn {
        position: static !important;
        top: auto !important;
        bottom: auto !important;
        right: auto !important;
        width: 100%;
        min-height: var(--min-touch-target);   /* 44px — matches action-btn */
        height: auto;
        margin-top: 12px;                       /* consistent 12px gap from buy btn */
        border-radius: var(--radius);
        background: var(--bg-secondary, #f5f5f5);
        border: 1.5px solid var(--border-color);
        color: var(--text-color);
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 0 12px;                        /* vertical centering via min-height + align-items */
        font-size: var(--font-size-base, 0.95rem);
        font-weight: 600;
        z-index: auto !important;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        transition: background 0.2s, border-color 0.2s, color 0.2s;
    }

    /* Equalise gap below fav btn — override mt-24 utility class */
    #nicknameQuickBtn {
        margin-top: 12px;
    }

    .floating-fav-btn:hover {
        background: var(--bg-color, #e8eaed);
        box-shadow: none;
    }

    .floating-fav-btn.is-fav {
        background: rgba(239, 68, 68, 0.08);
        border-color: rgba(239, 68, 68, 0.35);
        color: #c53030;
    }

    .floating-fav-btn.is-fav:hover {
        background: rgba(239, 68, 68, 0.14);
    }

    .floating-fav-btn .icon-ball {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .fav-btn-text {
        display: inline;
    }

    [data-theme="dark"] .floating-fav-btn {
        background: var(--color-bg-elevated, #2a2d2e);
        border-color: var(--border-color);
        box-shadow: none;
    }

    [data-theme="dark"] .floating-fav-btn:hover {
        background: var(--bg-color, #1e2122);
    }

    [data-theme="dark"] .floating-fav-btn.is-fav {
        background: rgba(239, 68, 68, 0.15);
        border-color: rgba(239, 68, 68, 0.4);
        color: #fc8181;
    }
}

/* -------------------------------------------------------------------------- */
/* Sticky Sidebar (Card Image) */
/* -------------------------------------------------------------------------- */

.sticky-sidebar {
    position: relative;             /* Default for non-sticky contexts */
    width: 100%;
}

/* Desktop: Stick to top while scrolling */
@media (min-width: 1024px) {
    .sticky-sidebar {
        position: sticky;
        top: calc(var(--spacing-md) + var(--page-header-sticky-offset, 0px));     /* Gap from top of viewport */
        align-self: start;          /* Ensure it sticks to the top of the grid cell */
    }
}

/* Tablet & Mobile: Sticky Title Logic (Single Column Layout) */
@media (max-width: 1023px) {
    /* sticky-sidebar 維持原本排版，不做 sticky 行為 */
    .sticky-sidebar {
        position: relative;
        z-index: auto;
        background: transparent;
        padding-bottom: var(--spacing-sm);
    }

    /* sticky-title 永遠使用 fixed overlay，不佔版面高度 */
    .sticky-title {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999 !important;
        margin-top: 0 !important;
        padding: 0 12px !important; /* 移除 padding-bottom: 8px 讓上下對稱 */
        height: 72px; /* 固定總高度 */
        border-top: none;
        background: var(--card-bg);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
        max-height: none;
        transform: none;
        opacity: 0;
        pointer-events: none;
        display: flex;
        align-items: center;
        gap: 12px; /* 增加一點圖文間距 */
    }

    /* 只透過 visible 切換顯示／隱藏，不改變任何布局 */
    .sticky-title.visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Equalise gap on mobile — fav btn is position:fixed (no flow height), so buy→我是誰? gap = mt-24 = 24px, reduce to 12px */
    #nicknameQuickBtn {
        margin-top: 12px;
    }

    /* Floating Favorite Button (Mobile/Tablet: fixed floating circle) */
    .fav-btn-text {
        display: none;
    }

    .floating-fav-btn {
        position: fixed !important;
        /* 右下角 FAB：改離右上，避免捲動時固定壓在右側內容（表格數字/清單）上。
           抬到底部宣傳藥丸之上（藥丸 bottom16 + 高48 + 間距）。 */
        top: auto !important;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 76px) !important;
        right: 16px !important;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--card-bg);
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999 !important;
        opacity: 0;
        transform: translateY(-20px);
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .floating-fav-btn.visible {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    [data-theme="dark"] .floating-fav-btn {
        background: var(--color-bg-elevated);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .floating-fav-btn .icon-ball {
        width: 24px;
        height: 24px;
    }

    /* sticky-title 出現時隱藏 header */
    body.sticky-active .page-header {
        visibility: hidden !important; /* 改用 visibility 避免 DOM reflow 導致網頁抖動 */
        pointer-events: none;
    }

    /* 顯示 h3 左側縮圖（提高選擇器優先權以覆蓋桌機規則） */
    .sticky-title .sticky-title-image {
        display: block;
        height: 52px; /* 稍微縮小高度，避免貼齊上下邊緣 */
        aspect-ratio: 1 / 1;
        flex-shrink: 0;
        border-radius: 4px;
        border: 1px solid var(--border-color);
        object-fit: contain;
    }

    .sticky-title-text-group {
        display: flex;
        flex-direction: column;
        justify-content: center; /* 讓文字群組在自己區域內垂直置中 */
        gap: 2px;
        min-width: 0;
        height: 100%;
    }

    /* 只顯示 h3 文本，隱藏副標 */
    .sticky-title .sticky-subtitle-text {
        display: none;
    }

    /* h3 文字可換行，最多顯示約兩行填滿上方空間 */
    .sticky-title .sticky-title-text {
        font-size: 0.875rem;
        white-space: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    /* sticky-title 出現只做淡入淡出，不做任何位移動畫 */
    .sticky-sidebar .sticky-title {
        transform: none;
        max-height: none;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        transition: opacity 0.25s ease;
    }

    .sticky-sidebar .sticky-title.visible {
        transform: none;
    }

    .sticky-theme-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Image Loading Animation for Details Page */
.card-image-wrapper {
    position: relative;
    overflow: hidden;
    /* Shimmer Effect for Loading State */
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}

.card-image-wrapper.loaded {
    background: transparent;
    animation: none;
}

[data-theme="dark"] .card-image-wrapper.loaded {
    background: transparent;
    animation: none;
}

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

.card-image {
    /* Initial Loading State */
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.card-image.loaded {
    opacity: 1;
    transform: scale(1);
}

.card-image.error {
    opacity: 1;
    transform: scale(1);
    padding: 30%;
    background-color: #f5f5f5;
}

[data-theme="dark"] .card-image.error {
    background-color: #181A1B;
}

/* Mobile: Other Layout Adjustments */
@media (max-width: 767px) {
    body {
        padding: 0;
    }

    /* 手機版：減少 Header 高度，滿版顯示，移除圓角 */
    .page-header {
        padding: var(--spacing-sm);
        margin-left: calc(-1 * var(--spacing-xs));
        margin-right: calc(-1 * var(--spacing-xs));
        border-radius: 0;
    }

    .container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0 var(--spacing-xs);
    }

    /* 去除「底層白色大面板」→ 透明底讓灰色 body 透出，每個 .data-section 各自成白卡浮在灰底上
       (對齊 iOS：無白色外框、區塊間留灰底間距)。同時清零內距 → 區塊吃滿 container 寬度 = 拉寬。 */
    .card-details-grid {
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        gap: 12px;               /* 手機版：卡圖區→內容區間距收緊為固定 12px（原 24px 太開） */
    }

    /* 手機版：區塊(白卡)之間統一固定 12px 緊湊間距（原 var(--spacing-md)=24px）。
       用 .card-details-grid 前綴提高特異度，蓋過後面的 base .card-info-section gap 規則。 */
    .card-details-grid .card-info-section {
        gap: 12px;
    }

    /* Sticky Logic moved to max-width: 1023px */

    /* 底部保留空間：避免最後一段內容被懸浮宣傳藥丸永久遮住 */
    .container {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
    }

    .promo-footer {
        position: fixed;
        /* 懸浮置中 */
        left: 50%;
        transform: translateX(-50%);
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
        width: auto;
        min-width: 300px;
        max-width: 90%;
        height: 48px;
        
        /* Glassmorphism 毛玻璃效果 */
        background: rgba(20, 33, 61, 0.85); /* 半透明的 primary-color */
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px); /* Safari 支援 */
        
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
        z-index: 9998;
        padding: 0 20px;
        
        /* 藥丸造型 */
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
        gap: 10px;
        
        /* 滾動顯示/隱藏的動畫 */
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    }

    [data-theme="dark"] .promo-footer {
        background: rgba(30, 30, 30, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .promo-footer.is-hidden {
        transform: translate(-50%, 150%);
        opacity: 0;
        pointer-events: none;
    }

    .promo-footer-logo {
        width: 20px;
        height: 20px;
        object-fit: contain;
        flex-shrink: 0;
        margin: 0;
    }

    .promo-footer-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 500;
        letter-spacing: 0.3px;
        margin: 0;
        min-width: 0;
    }

}

/* 桌機預設：不顯示 sticky 標題縮圖，避免影響原本版面 */
.sticky-title-image {
    display: none;
}

/* Images */
.card-image-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.card-image-wrapper {
    flex-shrink: 0;
    position: static;
    aspect-ratio: auto;
    padding-top: 0;
    background: transparent;
    overflow: visible;
}

.card-image-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: url('../img/BG.svg') center / cover no-repeat, #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cell);   /* 卡圖 → 格子圓角 14 */
    overflow: hidden;
    padding: var(--spacing-sm);
    box-sizing: border-box;
}

[data-theme="dark"] .card-image-box {
    background: url('../img/BG-dark.svg') center / cover no-repeat, #181A1B;
}

.card-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
    border-radius: 0;
}

@media (max-width: 767px) {
    .card-image-box {
        padding: var(--spacing-xs);
    }
}

/* Buttons */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--min-touch-target);
    padding: 12px;
    background-color: var(--accent-color);
    color: #000;
    border-radius: var(--radius-btn);   /* CTA → 按鈕圓角 16 */
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
    font-size: var(--font-size-base);
}

.action-btn:hover {
    opacity: 0.9;
}

/* 次要動作（群眾協作補綽號）：白底外框樣式，不與橘色購買 CTA 搶份量、在灰底上清楚成鈕 */
.btn-nickname {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1.5px solid var(--border-color);
    font-weight: 600;
}

.btn-nickname:hover {
    opacity: 1;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

/* Sticky Title */
.sticky-theme-toggle {
    display: none;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-left: auto;
    width: 36px;
    height: 36px;
    padding: 6px;
    font-size: 1rem;
}

.sticky-theme-toggle:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .sticky-theme-toggle {
    color: #ffffff;
}

.sticky-title {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: 1px solid transparent;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sticky-title.visible {
    opacity: 1;
    transform: translateY(0);
    max-height: 100px;
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.sticky-title-text {
    font-size: 1rem;
    margin: 0 0 4px 0;
    font-weight: bold;
}

.sticky-subtitle-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Info Section */
.card-info-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    width: 100%;
    min-width: 0; /* Important for flex/grid children overflow */
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
}

.card-title-jp {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    line-height: 1.3;
}

.card-subtitle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.card-subtitle__nickname {
    flex-shrink: 0;
}

.card-subtitle__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.card-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.6;
    white-space: nowrap;
}

.card-chip--year {
    background: #fca31122;
    color: #b36a00;
    border: 1px solid #fca31155;
}

[data-theme="dark"] .card-chip--year {
    background: #fca31120;
    color: #fca311;
    border-color: #fca31140;
}

.card-chip--code {
    background: var(--bg-color, #f1f3f4);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Data Sections */
.data-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    width: 100%;
    overflow: hidden;
}

/* 目前正在販售區：下方留白再縮小一點，避免空間浪費 */
#active-listings-section {
    padding-bottom: 8px;
}

/* 目前正在販售列表容器：高度固定至少 261px，避免切頁時高度變小造成抖動 */
#active-listings-container {
    min-height: 261px;
}

/* 目前正在販售區內部 carousel：高度至少 261px，但可隨內容自動增高，不遮蔽文字 */
#active-listings-container .listings-carousel {
    min-height: 261px;
}


.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 var(--spacing-sm) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.source-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.source-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    vertical-align: middle;
    line-height: 1.6;
    text-transform: uppercase;
}

.source-badge--snkr {
    background: #29B6F6;
    color: #fff;
}

.source-badge--psa {
    background: #FF5252;
    color: #fff;
}

.btn-toggle-analysis {
    padding: 8px 12px;
    font-size: 12px;
    color: #fff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 44px;
}

.btn-toggle-analysis:hover {
    background-color: var(--accent-color);
    color: #000;
}

/* Analysis Grid (Gauges) */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

/* Removed media queries to enforce 2-column layout across all screen sizes as requested */

.analysis-card {
    background: var(--card-bg);
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cell);   /* 分析格子 → 圓角 14 */
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow);
    height: 220px; /* Initial fixed height */
    overflow: hidden; /* Hide excess content */
    justify-content: flex-start; /* Align content to top */
    transition: height 0.4s ease; /* Smooth transition */
}

/* Mobile: 分析區每排 2 個指標，每個指標為 1:1 正方形 */
@media (max-width: 767px) {
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 手機：自適應高度卡片（不再鎖 1:1，避免內容被擠爆／裁切）。
       標題保留兩行高度讓四張卡對齊，儀表限寬置中防止 200px 撐寬溢出。 */
    .analysis-card {
        height: auto !important;
        aspect-ratio: auto;
        min-height: 156px;
        padding: 12px 8px;
        justify-content: flex-start;
        gap: 2px;
        overflow: hidden;
    }

    .analysis-card .analysis-title {
        font-size: 0.72rem;
        line-height: 1.25;
        min-height: 2.4em;               /* 預留兩行 → 四張卡的儀表起點齊平 */
        margin-bottom: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .analysis-card .gauge-container {
        height: 62px;
        width: 100%;
        max-width: 118px;                /* 關鍵：限寬置中，修儀表被 200px 撐寬裁切 */
        margin: 0 auto;
    }

    .analysis-card .gauge-value {
        bottom: -2px;
        font-size: 0.95rem;
    }

    .analysis-card .analysis-text {
        margin-top: 4px;
        font-size: 0.72rem;
        line-height: 1.2;
        text-align: center;
    }

    /* 預設收合：不顯示長敘述，避免在小正方形裡爆版 */
    .analysis-card .analysis-desc {
        display: none;
    }

    /* 點擊「分析」後：改為單欄直列，自適應高度，展開完整說明 */
    body:has(.analysis-card.expanded) .analysis-grid {
        grid-template-columns: 1fr;
    }

    .analysis-card.expanded {
        aspect-ratio: auto;
        height: auto !important;
        padding: 12px;
        overflow: visible;
    }

    .analysis-card.expanded .gauge-container {
        height: 90px;
    }

    .analysis-card.expanded .analysis-desc {
        display: block;
        opacity: 1;
    }

    /* 手機：PSA 鑑定分佈三個 stat-item 同一排 */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--spacing-xs);
    }

    /* 手機：對齊 iOS —— PSA 分佈三欄「無邊框、無底色」的置中欄位（已在白色 section 卡內，
       不需再套小白卡+邊框），去框後也不會再擠到裁切。
       用 .stats-grid 前綴提高特異度，蓋過後面的 base .stat-item 邊框規則。 */
    .stats-grid .stat-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 4px 2px;
        background: transparent;
        border: none;
        border-radius: 0;
    }

    .stat-label {
        display: flex;
        align-items: flex-end;
        justify-content: center;
        min-height: 20px;
        max-width: 100%;
        white-space: nowrap;                          /* 一律一行，不換行 */
        font-size: clamp(0.6rem, 2.8vw, 0.75rem);     /* 視寬度自適應變小 */
    }

    .stat-value {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 24px; /* 三個數字區塊高度一致 */
        font-size: 0.95rem;
    }

    .stat-pct {
        margin-left: 4px;
    }
}

.analysis-title {
    font-size: 0.875rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--text-color);
    text-align: center;
    flex-shrink: 0; /* Prevent title from shrinking */
}

.gauge-container {
    position: relative;
    height: 120px;
    width: 200px;
    max-width: 100%; /* Responsive canvas */
    flex-shrink: 0; /* Prevent gauge from shrinking */
}

.gauge-value {
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--text-color);
}

.analysis-text {
    text-align: center;
    margin-top: 10px;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.analysis-desc {
    display: block; /* Always visible in DOM, hidden by parent overflow */
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.analysis-card.expanded .analysis-desc {
    opacity: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--spacing-sm);
}

.stat-item {
    background: var(--card-bg);
    padding: var(--spacing-sm);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-color);
    display: block;
}

.stat-pct {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Transaction Grid */
.transaction-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

@media (min-width: 600px) {
    .transaction-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1000px) {
    .transaction-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Each column is a card */
.transaction-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 10px 8px;
}

.tx-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.tx-record-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Extended grade colours */
.grade-tag.b    { background: #e8f0fe; color: #1967d2; border: 1px solid #c5d8fb; }
.grade-tag.c    { background: #fce8e6; color: #c5221f; border: 1px solid #f5c6c3; }
.grade-tag.d    { background: #fef7e0; color: #b06000; border: 1px solid #fde38a; }
.grade-tag.bgs10bl,
.grade-tag.bgs10gl,
.grade-tag.bgs95,
.grade-tag.bgs9以下 { background: #e6f4ea; color: #137333; border: 1px solid #b7dfbf; }
.grade-tag.ars10\+,
.grade-tag.ars10,
.grade-tag.ars9,
.grade-tag.ars8以下 { background: #f3e8fd; color: #6a0dad; border: 1px solid #d4b0f5; }

[data-theme="dark"] .grade-tag.b    { background: #1967d220; color: #8ab4f8; border-color: #1967d240; }
[data-theme="dark"] .grade-tag.c    { background: #c5221f20; color: #f28b82; border-color: #c5221f40; }
[data-theme="dark"] .grade-tag.d    { background: #b0600020; color: #fdd663; border-color: #b0600040; }
[data-theme="dark"] .grade-tag.bgs10bl,
[data-theme="dark"] .grade-tag.bgs10gl,
[data-theme="dark"] .grade-tag.bgs95,
[data-theme="dark"] .grade-tag.bgs9以下 { background: #13733320; color: #81c995; border-color: #13733340; }
[data-theme="dark"] .grade-tag.ars10\+,
[data-theme="dark"] .grade-tag.ars10,
[data-theme="dark"] .grade-tag.ars9,
[data-theme="dark"] .grade-tag.ars8以下 { background: #6a0dad20; color: #d7aefb; border-color: #6a0dad40; }

/* Limit Visibility Logic */
.transaction-grid:not(.expanded) .transaction-column:nth-child(n+5) {
    display: none;
}

@media (min-width: 1000px) {
    .transaction-grid:not(.expanded) .transaction-column:nth-child(n+5) {
        display: flex;
    }
    .transaction-grid:not(.expanded) .transaction-column:nth-child(n+7) {
        display: none;
    }
    .hide-lg-up {
        display: none !important;
    }
}

.more-btn-container {
    text-align: center;
    margin-top: var(--spacing-md);
    width: 100%;
}

/* ── Transaction list (flex rows, replaced <table> 2026-05-21) ─────────────
   Why not <table>: in narrow column (220px on desktop 3-col), table cell
   padding (8×4=32px wasted) + nowrap content overflows, forcing
   horizontal scroll that hides right-aligned price. Flex row solves it:
   date hugs left, price hugs right via justify-between, no padding waste,
   no horizontal scrollbar, naturally RWD. */
.transaction-list-container {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

/* 2-col grid (date | price-block).
   Each cell can itself stack vertically (year/month-day or price/count). */
.tx-list-header,
.tx-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0 12px;
    padding: 8px 12px;
}

.tx-list-header {
    background: var(--bg-color);
    font-size: 0.8125rem;       /* 13px — header label */
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.tx-list-header > :nth-child(1) { text-align: left; }
.tx-list-header > :nth-child(2) { text-align: right; }

.tx-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tx-row {
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9375rem;       /* 15px — bumped from 14px per user feedback */
    line-height: 1.4;
    align-items: center;
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover     { background: var(--bg-color); }

/* ── Date cell ────────────────────────────────────────────────────────────
   Default: inline → "2026-04-26" via ::after separator on year span.
   Narrow column (container query): stack vertically, year above month-day. */
.tx-date {
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tx-date-y::after { content: '-'; }
.tx-date-y,
.tx-date-md { display: inline; }

/* ── Price block (vertical stack: price on top, count below) ─────────── */
.tx-price-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
    text-align: right;
}

.tx-price {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1rem;             /* 16px — primary price, slightly larger than row base */
    white-space: nowrap;
    color: var(--text-color);
}
.tx-price a {
    color: inherit;
    text-decoration: none;
}

.tx-count {
    font-size: 0.8125rem;        /* 13px — secondary metadata */
    color: var(--text-muted);
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Outlier rows (異常價：錯體卡/特殊品/合售) ─────────────────────────
   資料清洗剔除走勢圖的筆數，列表照顯示：實色橘 badge + 橘色價格 +
   虛線底線提示可點（前往 SNKRDUNK 刊登頁自行查證特殊性）。 */
.tx-outlier-badge {
    display: inline-block;
    background: #FCA311;          /* 品牌橘實色，禁半透明 */
    color: #14213d;
    font-size: 0.6875rem;         /* 11px */
    font-weight: 800;
    line-height: 1.5;
    padding: 0 5px;
    border-radius: 4px;           /* 近直角，Solid Pop */
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.tx-row--outlier .tx-price,
.tx-row--outlier .tx-price a {
    color: #d97706;               /* 白底可讀的深一階橘 */
}
.tx-row--outlier .tx-price a {
    text-decoration: underline dashed 1px;
    text-underline-offset: 3px;   /* 虛線底線＝可點查證的 affordance */
}
[data-theme="dark"] .tx-row--outlier .tx-price,
[data-theme="dark"] .tx-row--outlier .tx-price a {
    color: #FCA311;               /* 深底直接用品牌橘，對比足 */
}

.tx-outlier-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.75rem;           /* 12px — 註解層級 */
    line-height: 1.6;
    color: var(--text-muted);
}
.tx-outlier-hint .tx-outlier-badge {
    flex-shrink: 0;
    margin-top: 2px;
}

/* Container query — narrow column auto-shrink + date split.
   Base row 15px, price 16px. Floor 13px row / 14px price.
   Below 240px: split date into year (top) + month-day (bottom) to free width. */
.transaction-column {
    container-type: inline-size;
    container-name: tx-col;
}
@container tx-col (max-width: 280px) {
    .tx-row         { font-size: 0.875rem; padding: 7px 10px; }   /* 14px row */
    .tx-price       { font-size: 0.9375rem; }                     /* 15px price */
    .tx-list-header { padding: 6px 10px; font-size: 0.75rem; }    /* 12px */
}
@container tx-col (max-width: 240px) {
    .tx-row         { font-size: 0.8125rem; padding: 6px 8px; gap: 0 8px; }  /* 13px row */
    .tx-price       { font-size: 0.875rem; }                                  /* 14px price (floor) */
    .tx-count       { font-size: 0.75rem; }                                   /* 12px count */
    .tx-list-header { padding: 6px 8px; font-size: 0.75rem; }

    /* Stack date vertically: year on top, month-day below (no hyphen separator) */
    .tx-date-y::after { content: none; }
    .tx-date-y,
    .tx-date-md { display: block; }
    .tx-date-y  { font-size: 0.75rem; color: var(--text-muted); line-height: 1.2; }
    .tx-date-md { font-weight: 500; line-height: 1.2; }
}

/* Price cell links — inherit text colour, reveal clickability on hover only */
.tx-price a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tx-price a:hover {
    color: var(--primary-color, #14213d);
    border-bottom-color: var(--primary-color, #14213d);
}
[data-theme="dark"] .tx-price a:hover {
    color: var(--accent-color, #fca311);
    border-bottom-color: var(--accent-color, #fca311);
}

/* ── Pager (kept compatible) ───────────────────────────────────────────── */
.transaction-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px 0 2px;
}

.transaction-pager .listing-nav-btn {
    position: static;
    transform: none;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.tx-page-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 44px;
    text-align: center;
}

.grade-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--border-color);
    color: var(--text-color);
}

.grade-tag.psa10 { background: var(--primary-color); color: #ffffff; }
.grade-tag.psa9 { background: var(--accent-color); color: #000000; }

/* Price Table */
.price-table {
    width: 100%;
    border-collapse: collapse;
    /* display: block; Removed to allow table to fill width */
    /* overflow-x: auto; Moved to .table-responsive */
    white-space: nowrap;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

/* 表格水平捲軸細緻化（原本粗灰捲軸很搶眼）——細、圓、透明軌 */
.table-responsive::-webkit-scrollbar { height: 5px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 999px; }
.table-responsive { scrollbar-width: thin; }

/* 手機：學 iOS PriceReferenceTableCard —— 固定表格佈局 + 數值欄固定寬 + 首欄換行，
   讓表格永遠 100% 寬、完全不水平捲（取代原本會 h-scroll 的自動佈局 nowrap 表）。 */
@media (max-width: 767px) {
    .price-table { table-layout: fixed; width: 100%; }
    /* 源名縮短為「PSA 官方 / Snkrdunk」後首欄不再需要換行 → 改回自動佈局 + 縮小左右 cell 間距，
       讓 4 欄自然塞滿畫面、消除下方水平捲軸 bar。 */
    .price-table { table-layout: auto; }
    .price-table th, .price-table td { padding: 8px 3px; font-size: 0.75rem; white-space: nowrap; }
    .price-table th:not(:first-child), .price-table td:not(:first-child) { text-align: right; }
    /* 每月平均表另有 4 欄且首欄置中，縮表頭字級避免裁字 */
    #monthly-avg-section .monthly-avg-table th { padding: 8px 3px; font-size: 0.7rem; }
    #monthly-avg-section .monthly-avg-table td { padding: 8px 3px; font-size: 0.82rem; }

    /* 套利試算 grade 卡：min-width:0 讓 3 欄縮到內容以下（修右側被裁 75px）；
       用 .market-summary 前綴提高特異度蓋過後面的 base 字級，縮字讓「$43,189」不被 ellipsis 截斷。 */
    .market-summary { gap: 4px; }
    .market-summary .summary-card {
        min-width: 0;
        padding: 8px 4px;
        border-left-width: 3px;
    }
    .market-summary .summary-card-title { font-size: 0.68rem; }
    .market-summary .summary-price { font-size: 0.72rem; }
    .market-summary .summary-vol { font-size: 0.6rem; white-space: normal; }

    /* 時間範圍 chips：改等寬單排（分段控制器感），修 3+2 不平衡換行 */
    .chart-controls,
    .monthly-avg-controls {
        flex-wrap: nowrap;
    }
    .chart-controls .btn-range,
    .monthly-avg-controls .btn-monthly-avg {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 4px;
        padding-right: 4px;
        text-align: center;
        white-space: nowrap;
    }
}

.price-table th, .price-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.875rem;
}

.price-table th {
    color: var(--text-muted);
    font-weight: 500;
    background-color: var(--card-bg);
}

.price-table td.text-right {
    text-align: right;
}

.price-table th:last-child, 
.price-table td:last-child {
    text-align: right; /* Often numbers are on the right */
}

/* Override for specific columns if needed */
.price-table th:first-child,
.price-table td:first-child {
    text-align: left;
}

/* Calculator */
.market-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

@media (max-width: 480px) {
    .market-summary {
        grid-template-columns: repeat(3, 1fr);
    }
}

.summary-card {
    background: var(--card-bg);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
    text-align: center;
}

.summary-card-title { font-size: 0.75rem; font-weight: bold; margin-bottom: 4px; }
.summary-price { font-size: 1rem; font-weight: bold; color: var(--text-color); }
.summary-vol { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 767px) {
    /* 手機：套利 summary 僅顯示一行，去掉 NT 前綴視覺干擾 */
    .summary-price {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* 手機：PSA 套利試算區排版與文字大小微調，提升閱讀性 */
@media (max-width: 767px) {
    /* 下拉選單字體稍微縮小，避免過寬 */
    #psaServiceSelect.form-control {
        font-size: 0.875rem;
    }

    /* 表頭與表格內容在手機上略縮小 */
    .arbitrage-calculator .price-table th {
        font-size: 0.75rem;
    }

    .arbitrage-calculator .price-table td {
        font-size: 0.75rem;
    }

    /* 獲利與 ROI 顏色文字保持可讀，不需再放大 */
    .arbitrage-calculator .text-danger,
    .arbitrage-calculator .text-success {
        font-size: 0.8rem;
    }

    /* 底部說明文字再縮小一階，當備註閱讀 */
    .arbitrage-calculator .calc-note {
        font-size: 0.7rem;
        line-height: 1.4;
    }
}

.text-psa10 { color: var(--accent-color); }
.text-psa9 { color: var(--primary-color); }
.text-other { color: var(--text-muted); }

.calculator-box {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    box-shadow: var(--shadow);
}

.calculator-form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 600px) {
    .calculator-form-row {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: flex-end;
    height: 20px;
}

.cost-value-display {
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text-color);
}

.cost-sub-display {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    min-height: 44px;
    background-color: var(--card-bg);
    color: var(--text-color);
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    max-width: 100%;
}

.chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.monthly-avg-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.btn-monthly-avg {
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 0.75rem;
    min-height: 32px;
    transition: all 0.2s;
}

.btn-monthly-avg:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-monthly-avg.active {
    background: var(--accent-color);
    color: #000000;
    border-color: var(--accent-color);
    font-weight: bold;
}

.btn-range {
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 0.75rem;
    min-height: 44px;
    transition: all 0.2s;
}

.btn-range:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-range.active {
    background: var(--accent-color);
    color: #000000;
    border-color: var(--accent-color);
    font-weight: bold;
}

/* Container Queries */
@container main-container (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr; /* Desktop 窄容器時改為 2 欄 */
    }
    .transaction-grid {
        grid-template-columns: 1fr;
    }
}

/* Hide specific elements on very small mobile screens */
@media (max-width: 400px) {
    .hide-on-mobile-small {
        display: none;
    }
}

/* 手機優先：PSA 分佈三個 stat-item 一律同一排（3 欄），避免落到第 2 排 */
@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.loading-state--skeleton {
    padding: 0;
    text-align: left;
}

/* Skeleton loading layout */
.loading-skeleton {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

@media (min-width: 1024px) {
    .loading-skeleton {
        grid-template-columns: 320px 1fr;
        gap: 24px;
    }
}

.loading-skeleton__card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 260px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 1024px) {
    .loading-skeleton__card { max-width: none; margin: 0; }
}

.loading-skeleton__img {
    width: 100%;
    aspect-ratio: 63 / 88;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--border-color, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}

.loading-skeleton__btn {
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--border-color, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s 0.1s infinite;
}

.loading-skeleton__btn--sm { height: 36px; }

.loading-skeleton__right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 4px;
}

.loading-skeleton__title {
    height: 26px;
    width: 72%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--border-color, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}

.loading-skeleton__price {
    height: 56px;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--border-color, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s 0.05s infinite;
}

.loading-skeleton__section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading-skeleton__line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-secondary, #f0f0f0) 25%, var(--border-color, #e0e0e0) 50%, var(--bg-secondary, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s 0.2s infinite;
}

.loading-skeleton__line--med  { width: 70%; }
.loading-skeleton__line--short { width: 45%; }

[data-theme="dark"] .loading-skeleton__img,
[data-theme="dark"] .loading-skeleton__btn,
[data-theme="dark"] .loading-skeleton__title,
[data-theme="dark"] .loading-skeleton__price,
[data-theme="dark"] .loading-skeleton__line {
    background: linear-gradient(90deg, #2a2d32 25%, #3a3d42 50%, #2a2d32 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}

/* Fade-in when JS renders the card */
.card-details--entering {
    animation: cardDetailsEnter 0.25s ease-out both;
}

@keyframes cardDetailsEnter {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}

/* Helpers */
.text-right { text-align: right; }

/* Print Styles */
@media print {
    body { background: #fff; padding: 0; }
    .container { max-width: 100%; }
    .card-details-grid { display: block; box-shadow: none; border: none; padding: 0; }
    .sticky-sidebar { position: static; }
    .action-btn, .chart-controls, .btn-toggle-analysis { display: none; }
    .transaction-list-container { max-height: none; overflow: visible; }
}

/* Additional Utilities */
.price-ref-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: right;
}

.mt-4 {
    margin-top: 4px;
}

.calc-summary-row {
    font-weight: bold;
    border-top: 2px solid var(--border-color);
}

/* JS Refactoring Utility Classes */
.section-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.listings-controls-flex {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;   /* 窄螢幕讓「只看正在販售/排序/等級」篩選項換行，不被裁出畫面 */
}

.listing-checkbox {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-color);
    white-space: nowrap;
    cursor: pointer;
}

.listing-checkbox input {
    margin-right: 4px;
    cursor: pointer;
}

.form-control-auto {
    width: auto;
    height: 30px;
    font-size: 13px;
    line-height: 30px;
    padding: 0 10px;
}

select.form-control.form-control-auto {
    padding-top: 0;
    padding-bottom: 0;
    line-height: 30px;
}

.text-center-padded {
    text-align: center;
    padding: 20px;
    width: 100%;
}

.text-muted-padded {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.text-error-padded {
    text-align: center;
    padding: 20px;
    width: 100%;
    color: var(--color-error, #d32f2f);
}

.listing-image-wrapper {
    width: 130px; 
    aspect-ratio: 9 / 16;
    height: auto;
    background-size: cover; 
    background-repeat: no-repeat; 
    background-position: center; 
    background-color: var(--card-bg);
    background-image: var(--bg-img);
    border-radius: 4px;
    margin: 0 auto;
    position: relative;
}

.sold-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Slightly darker for better contrast */
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    z-index: 5;
    padding: 4px 0;
}

.sold-overlay span {
    color: white;
    font-weight: bold;
    font-size: 12px;
    line-height: 1;
}

.listing-info-padded {
    padding: 8px;
    text-align: center;
}

.listing-price-text {
    font-weight: bold; 
    color: var(--accent-color); 
    font-size: 14px;
}

.price-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--accent-color);
    display: inline-block;
    margin-right: 4px;
}

.listing-grade-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.grade-badge {
    background: var(--border-color); 
    padding: 2px 6px; 
    border-radius: 4px;
}

.scroll-container-flex {
    display: flex; 
    overflow-x: auto; 
    gap: 16px; 
    padding: 4px; 
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.btn-expand-trans {
    width: auto;
    padding: 8px 24px;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);   /* 按鈕圓角 16 */
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}

.btn-expand-trans:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.more-grades-container {
    margin-top: 20px;
}

.text-bold {
    font-weight: bold;
}

.gauge-label {
    font-weight: bold; 
    font-size: 16px;
    /* Color handled by specific classes */
}

/* Gauge Colors */
.text-gauge-green { color: #4CAF50; }
.text-gauge-light-green { color: #8BC34A; }
.text-gauge-yellow { color: #FFC107; }
.text-gauge-orange { color: var(--accent-color); }
.text-gauge-red { color: #F44336; }

/* Removed duplicate .btn-range.active */

.gauge-desc {
    color: var(--text-muted);
    font-size: 12px;
    display: block;
    text-align: left;
    margin-top: 4px;
}

.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

.text-neutral {
    color: var(--text-color);
}

.monthly-avg-change {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.monthly-avg-change-up {
    color: #dc3545;
}

.monthly-avg-change-down {
    color: #28a745;
}

.monthly-avg-change-neutral {
    color: var(--text-muted);
    font-weight: 600;
}

/* Listings Container & Navigation */
.listings-wrapper {
    display: block;
}

.listings-carousel {
    position: relative;
    padding: 0 48px;
}

/* 手機預設：橫向捲動，每張卡片固定寬度 */
.listing-card {
    display: block;
    text-decoration: none;
    color: inherit;
    flex: 0 0 auto;
    width: 130px;
    transition: transform 0.2s;
}

.listing-card:hover {
    transform: translateY(-2px) scale(1.03);
}

.listing-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.2s;
}

.listing-nav-btn:hover {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
    box-shadow: 0 4px 8px rgba(252, 163, 17, 0.3);
}

.listing-nav-btn.prev {
    left: 0;
}

.listing-nav-btn.next {
    right: 0;
}

.page-indicator {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 4px auto 0;
}

/* 手機版（寬度小於 1000px）：目前正在販售改為三欄平均 */
@media (max-width: 999px) {
    .listings-carousel {
        padding: 0;
    }

    .listings-carousel .scroll-container-flex {
        overflow-x: visible;
        flex-wrap: wrap;
        gap: 20px;
        padding: 4px 0;
        max-width: 480px;
        margin: 0 auto;
    }

    .listings-carousel .listing-image-wrapper {
        width: 100%;
    }

    .listings-carousel .listing-card {
        box-sizing: border-box;
        /* 3 張卡片平均分配整個列寬度（扣除 40px 間距） */
        flex: 0 0 calc((100% - 40px) / 3);
        width: calc((100% - 40px) / 3);
    }
}

@media (min-width: 1000px) {
    .listings-carousel .listing-card {
        box-sizing: border-box;
        /* 5 張卡片 + 4 個間距（10px），寬度平均分成 5 份 */
        width: calc((100% - 4 * 10px) / 5);
    }

    .listings-carousel .scroll-container-flex {
        padding-left: 0;
        padding-right: 0;
        gap: 10px;
    }

    /* 桌機：圖片容器吃滿卡片寬度（保持 9:16 比例），5 張平均分配在一排 */
    .listings-carousel .listing-image-wrapper {
        width: 100%;
    }
}

/* =========================================
   Monthly Average Section (RWD Optimization)
   ========================================= */

#monthly-avg-section {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow);
}

#monthly-avg-section .section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    font-weight: bold;
    color: var(--primary-color);
}

#monthly-avg-section .monthly-avg-controls {
    display: flex;
    gap: 4px;
}

#monthly-avg-section .btn-monthly-avg {
    padding: 4px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

#monthly-avg-section .btn-monthly-avg:hover {
    background-color: var(--border-color);
}

#monthly-avg-section .btn-monthly-avg.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Table Styling */
#monthly-avg-section .monthly-avg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    margin-bottom: 0;
}

#monthly-avg-section .monthly-avg-table th {
    background-color: var(--bg-color);
    color: var(--text-muted);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

#monthly-avg-section .monthly-avg-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 1rem;
}

#monthly-avg-section .monthly-avg-table th:nth-child(1),
#monthly-avg-section .monthly-avg-table td:nth-child(1) {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#monthly-avg-section .monthly-avg-table th:nth-child(2),
#monthly-avg-section .monthly-avg-table td:nth-child(2) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#monthly-avg-section .monthly-avg-table th:nth-child(3),
#monthly-avg-section .monthly-avg-table td:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#monthly-avg-section .monthly-avg-table th:nth-child(4),
#monthly-avg-section .monthly-avg-table td:nth-child(4) {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#monthly-avg-section .monthly-avg-table tbody tr:nth-child(even) td {
    background-color: rgba(0, 0, 0, 0.015);
}

#monthly-avg-section .monthly-avg-table tbody tr:hover td {
    background-color: rgba(20, 33, 61, 0.04);
}

#monthly-avg-section .table-responsive {
    overflow-x: visible;
}

#monthly-avg-section .monthly-avg-table tr:last-child td {
    border-bottom: none;
}

/* Change Colors & Styling */
#monthly-avg-section .monthly-avg-change {
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    text-align: center;
}

#monthly-avg-section .monthly-avg-change-up {
    color: #dc3545; /* Red for Up */
    background-color: rgba(220, 53, 69, 0.08);
}

#monthly-avg-section .monthly-avg-change-down {
    color: #28a745; /* Green for Down */
    background-color: rgba(40, 167, 69, 0.08);
}

#monthly-avg-section .monthly-avg-change-neutral {
    color: var(--text-muted);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Mobile Optimization (< 768px) */
@media (max-width: 767px) {
    #monthly-avg-section {
        padding: 12px;
        margin-left: -4px;
        margin-right: -4px;
        border-radius: 4px;
    }

    #monthly-avg-section .section-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #monthly-avg-section .monthly-avg-controls {
        width: 100%;
    }

    #monthly-avg-section .btn-monthly-avg {
        flex: 1;
        text-align: center;
        padding: 8px 0;
    }

    #monthly-avg-section .monthly-avg-table th,
    #monthly-avg-section .monthly-avg-table td {
        padding: 8px 4px;
        font-size: 0.9rem;
    }
    
    #monthly-avg-section .monthly-avg-change {
        min-width: auto;
        padding: 2px 4px;
        font-size: 0.85rem;
    }

    #monthly-avg-section .table-responsive {
        overflow-x: auto;
    }
}

/* Dark Mode Overrides */
[data-theme="dark"] .stat-item,
[data-theme="dark"] .transaction-list-container,
[data-theme="dark"] .summary-card,
[data-theme="dark"] .calculator-box,
[data-theme="dark"] #monthly-avg-section,
[data-theme="dark"] .listing-nav-btn {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .tx-list-header {
    background-color: var(--bg-color);
    color: var(--text-color);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .grade-tag {
    background-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .grade-tag.psa10 {
    background-color: var(--primary-color);
    color: #ffffff;
}

[data-theme="dark"] .grade-tag.psa9 {
    background-color: var(--accent-color);
    color: #000000;
}

[data-theme="dark"] #monthly-avg-section .monthly-avg-table th {
    background-color: var(--bg-color);
    color: var(--text-muted);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] #monthly-avg-section .btn-monthly-avg {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] #monthly-avg-section .btn-monthly-avg:hover {
    background-color: var(--border-color);
}

[data-theme="dark"] #monthly-avg-section .btn-monthly-avg.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

[data-theme="dark"] #monthly-avg-section .monthly-avg-table tbody tr:nth-child(even) td {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] #monthly-avg-section .monthly-avg-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .section-title,
[data-theme="dark"] .analysis-title {
    color: #ffffff;
}

/* Fix: #monthly-avg-section .section-title has specificity 0-1-1-0 which beats
   the generic [data-theme="dark"] .section-title rule (0-1-0). Adding the ID
   raises specificity to 0-2-1-0 so the white override wins in dark mode. */
[data-theme="dark"] #monthly-avg-section .section-title {
    color: #ffffff;
}

/* Fix: .text-psa9 uses var(--primary-color) which is #101A31 in dark mode —
   nearly invisible on the #181A1B card background. Override to readable text. */
[data-theme="dark"] .text-psa9 {
    color: var(--text-color);
}

/* Link, Button, and Header Colors */
[data-theme="dark"] a:not(.btn),
[data-theme="dark"] button:not(.btn):not(.theme-toggle-btn),
[data-theme="dark"] h1,
[data-theme="dark"] h4 {
    color: #ffffff;
}
/* Gauge and semantic color spans must NOT be overridden — they use specific color classes */

/* Scrollbars */
[data-theme="dark"] *::-webkit-scrollbar {
    width: 12px;
    height: 12px;
    background-color: var(--bg-color);
}

[data-theme="dark"] *::-webkit-scrollbar-track {
    background-color: var(--bg-color);
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 6px;
    border: 3px solid var(--bg-color);
}

/* Form Controls Dark Mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background-color: var(--bg-color);
    border-color: var(--accent-color);
    color: var(--text-color);
}

/* Ensure table headers in dark mode */
[data-theme="dark"] .price-table th {
    background-color: var(--bg-color);
    color: var(--text-muted);
}

/* Ensure monthly avg table rows in dark mode */
[data-theme="dark"] #monthly-avg-section .monthly-avg-table tbody tr:nth-child(even) td {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] #monthly-avg-section .monthly-avg-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Fix any remaining white backgrounds in nested divs */
[data-theme="dark"] .card-details-grid div[style*="background: #fff"],
[data-theme="dark"] .card-details-grid div[style*="background-color: #fff"],
[data-theme="dark"] .card-details-grid div[style*="background: white"],
[data-theme="dark"] .card-details-grid div[style*="background-color: white"] {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    padding: 6px var(--spacing-sm);
    margin-bottom: 4px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumb__item + .breadcrumb__item::before {
    content: "›";
    margin: 0 5px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
}

.breadcrumb__item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.15s, opacity 0.15s;
    opacity: 0.85;
}

.breadcrumb__item a:hover {
    opacity: 1;
    text-decoration: underline;
}

.breadcrumb__item--current span {
    color: var(--text-color);
    font-weight: 500;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: bottom;
}

@media (min-width: 600px) {
    .breadcrumb__item--current span {
        max-width: 360px;
    }
}

[data-theme="dark"] .breadcrumb__item a:hover {
    color: var(--accent-color);
    opacity: 1;
}

/* ── Hot Cards Scroll Strip ─────────────────────────────── */
.hot-cards-section {
    margin-top: 20px;
    padding: 0 var(--spacing-sm) var(--spacing-md);
}

/* Header row: title left, arrows right */
.hot-cards-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.hot-cards-section__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

/* Right-side action group: "查看完整系列" link + arrow buttons */
.hot-cards-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.hot-cards-section__icon {
    display: inline-flex;
    align-items: center;
    margin-right: 5px;
    vertical-align: middle;
    opacity: 0.7;
}

.hot-cards-set-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--primary-color, #1a73e8);
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--primary-color, #1a73e8);
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.hot-cards-set-link:hover {
    background: var(--primary-color, #1a73e8);
    color: #fff;
}

[data-theme="dark"] .hot-cards-set-link {
    color: var(--accent-color, #7baaf7);
    border-color: var(--accent-color, #7baaf7);
}

[data-theme="dark"] .hot-cards-set-link:hover {
    background: var(--accent-color, #7baaf7);
    color: #fff;
}

/* Arrow buttons */
.hot-cards-nav {
    display: flex;
    gap: 6px;
}

.hot-cards-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color, #e8eaed);
    background: var(--card-bg, #fff);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    /* Ensure 44px touch target without changing visual size */
    padding: 0;
    position: relative;
}

.hot-cards-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
}

.hot-cards-btn:hover:not(:disabled) {
    background: var(--primary-color, #14213d);
    color: #fff;
    border-color: var(--primary-color, #14213d);
    box-shadow: 0 2px 8px rgba(20, 33, 61, 0.3);
}

.hot-cards-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Scroll track */
.hot-cards-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;        /* Firefox */
    padding-bottom: 4px;          /* room for box-shadow */
    list-style: none;
    margin: 0;
    padding-left: 0;
    padding-right: 16px;          /* peek gap for last card */
}

.hot-cards-track::-webkit-scrollbar {
    display: none;                /* Chrome / Safari */
}

/* Each card slot */
.hot-cards-track__item {
    flex-shrink: 0;
    scroll-snap-align: start;
    width: 108px;
}

.hot-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-color);
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e8eaed);
    border-radius: var(--radius, 8px);
    padding: 10px 8px 8px;
    height: 100%;
    transition: box-shadow 0.15s, transform 0.15s;
}

.hot-card-link:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    transform: translateY(-2px);
    color: var(--primary-color);
}

.hot-card-link:focus-visible {
    outline: 2px solid var(--primary-color, #14213d);
    outline-offset: 2px;
}

.hot-card-link__img {
    width: 100%;
    aspect-ratio: 63 / 88;   /* standard PTCG card ratio */
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.hot-card-link__name {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.3;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.hot-card-link__num {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Mobile: slightly smaller cards, still 4+ visible */
@media (max-width: 480px) {
    .hot-cards-track__item {
        width: 82px;
    }
    /* hot-card-link__img uses width:100% + aspect-ratio, no override needed */
    .hot-cards-btn {
        width: 28px;
        height: 28px;
    }

    .hot-cards-btn svg {
        width: 12px;
        height: 12px;
    }
    /* Expand touch target to 44px minimum on mobile (WCAG 2.5.5) */
    .hot-cards-btn::before {
        inset: -8px;
    }
}

/* Respect user's reduced-motion preference — covers all animations on this page */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode */
[data-theme="dark"] .hot-card-link {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .hot-card-link:hover {
    color: var(--accent-color);
    box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

[data-theme="dark"] .hot-cards-btn {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .hot-cards-btn:hover:not(:disabled) {
    background: var(--primary-color, #101A31);
    color: #fff;
}

/* ── PSA 官方成交走勢 ──────────────────────────────────────────────── */

.psa-trend-loading,
.psa-trend-empty,
.psa-trend-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-muted, #888);
}

.psa-trend-retry {
    margin-left: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--primary-color, #14213d);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color, #14213d);
    cursor: pointer;
}

.psa-trend-retry:hover {
    background: var(--primary-color, #14213d);
    color: #fff;
}

/* =========================================
   UX Enhancement Block
   - Focus visibility (WCAG 2.1 §2.4.7)
   - Interaction press feedback
   - Breadcrumb dark-mode contrast fix
   - Data section visual hierarchy
   - Transaction table readability
   ========================================= */

/* ── Focus Visible — keyboard navigation ─────────────────────────── */
.action-btn:focus-visible,
.back-link:focus-visible,
.btn-toggle-analysis:focus-visible,
.btn-expand-trans:focus-visible,
.btn-monthly-avg:focus-visible,
.btn-limit-plan:focus-visible,
.btn-limit-secondary:focus-visible,
.btn-limit-primary:focus-visible,
.floating-fav-btn:focus-visible,
.hot-cards-set-link:focus-visible,
.psa-trend-retry:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(252, 163, 17, 0.4));
}

/* ── Action button press feedback ────────────────────────────────── */
.action-btn:active {
    transform: translateY(1px);
}

.btn-expand-trans:active,
.btn-monthly-avg:active {
    transform: translateY(1px);
}

/* ── Breadcrumb — dark-mode contrast fix ─────────────────────────── */
/* var(--primary-color) = #101A31 in dark mode; contrast ~1.2:1 on #272A2C → WCAG fail */
[data-theme="dark"] .breadcrumb__item a {
    color: var(--accent-color);
    opacity: 0.9;
}

[data-theme="dark"] .breadcrumb__item a:hover {
    color: var(--accent-color);
    opacity: 1;
}

/* ── Data section — subtle elevation for visual hierarchy ─────────── */
.data-section {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .data-section {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* ── Transaction list — row striping for readability ─────────────── */
.tx-list > .tx-row:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.018);
}

[data-theme="dark"] .tx-list > .tx-row:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.04);
}

/* ── Error color token in dark mode ──────────────────────────────── */
[data-theme="dark"] .text-error-padded {
    color: #ef5350;
}

/* ── touch-action: manipulation — removes 300ms tap delay on Android ─ */
button,
a,
.action-btn,
.back-link,
.btn-range,
.btn-toggle-analysis,
.btn-expand-trans,
.btn-monthly-avg,
.btn-limit-plan,
.listing-nav-btn,
.hot-cards-btn,
.floating-fav-btn,
[role="button"] {
    touch-action: manipulation;
}

/* ── Safe area inset — PWA / notch / Dynamic Island devices ──────── */
/* When running as home-screen PWA, position:fixed top:0 is at the physical
   top of screen (behind the notch). padding-top override restores visual clearance. */
@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 1023px) {
        .sticky-title {
            padding-top: env(safe-area-inset-top, 0px) !important;
            height: calc(72px + env(safe-area-inset-top, 0px));
        }

        /* fav 已改為右下角 FAB（見上方 .floating-fav-btn 主規則），不再釘頂端；
           底部安全區已由主規則的 bottom calc 處理 */
        .floating-fav-btn {
            top: auto !important;
        }
    }
}

/* ── Landscape compact mode — mobile portrait → landscape ────────── */
/* At <500px viewport height (typical phone landscape), reduce fixed element
   heights so content area doesn't get crushed. */
@media (orientation: landscape) and (max-height: 500px) {
    .page-header {
        height: 48px;
    }

    .card-details-grid {
        padding: var(--spacing-xs);
    }

    @media (max-width: 1023px) {
        .sticky-title {
            height: 52px;
        }
    }

    .promo-footer {
        height: 40px;
        font-size: 0.72rem;
        padding: 0 14px;
    }
}

/* ──────────────────────────────────────────────────────────────────────────
   Related-products grid (shared with box_details.php .box-related)
   Used by card_details.php's hot-cards / same-set section so that both
   pages render the same visual grid. Class names kept identical to box
   to avoid duplicating selectors — single source of truth for both pages.
   ────────────────────────────────────────────────────────────────────────── */
.box-related {
    padding: var(--spacing-sm);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.box-related__heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 var(--spacing-sm);
}
.box-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--spacing-sm);
}
@media (max-width: 480px) {
    .box-related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }
}
.box-related-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-cell);   /* 相關卡格子 → 圓角 14 */
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.box-related-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--accent-color);
}
.box-related-card:focus-visible {
    outline: none;
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}
.box-related-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Textured pattern background (mirrors box_details.php) — same BG.svg asset */
    background: url('../img/BG.svg') center / cover no-repeat, #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: var(--spacing-xs);
    box-sizing: border-box;
}
[data-theme="dark"] .box-related-img-wrap {
    background: url('../img/BG-dark.svg') center / cover no-repeat, #181A1B;
}
/* 卡圖尚未載入時,先以 PTCG 卡背當預設圖(BG.svg 底不變,真卡圖載入後淡出)。 */
.box-related-img-wrap::before {
    content: "";
    position: absolute;
    inset: var(--spacing-xs);
    background: url('../img/ptcg-card-back.webp') center / contain no-repeat;
    opacity: 1;
    transition: opacity 0.4s ease-out;
    pointer-events: none;
    z-index: 0;
}
.box-related-img-wrap:has(.box-related-img.loaded)::before {
    opacity: 0;
}
/* Placeholder when card has no image (mirrors box .box-detail-img-placeholder) */
.box-detail-img-placeholder {
    color: var(--color-text-muted, var(--text-muted));
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: 0.05em;
}
/* Reduced motion — disable hover transitions/animations for a11y (mirrors box) */
@media (prefers-reduced-motion: reduce) {
    .box-related-img,
    .box-related-card {
        transition: none !important;
        animation: none !important;
    }
}
.box-related-img {
    position: relative;
    z-index: 1; /* 卡正面疊在卡背佔位圖(::before)之上 */
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.25s ease;
}
.box-related-card:hover .box-related-img { transform: scale(1.05); }
.box-related-info {
    padding: 0.625rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}
.box-related-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.box-related-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.box-related-price {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--accent-color);
    margin: 0;
    margin-top: auto;
    padding-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.box-related-price--na {
    color: var(--text-muted);
    font-weight: 400;
}

/* Related section header — heading left, "see all" link right */
.box-related-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 var(--spacing-sm);
    flex-wrap: wrap;
}
.box-related-head .box-related__heading {
    margin: 0;
}
.box-related-see-all {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    transition: background-color 0.15s, color 0.15s;
}
.box-related-see-all:hover {
    background-color: var(--bg-secondary, rgba(0,0,0,0.04));
    color: var(--primary-hover);
}
.box-related-see-all:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ── Tag badge (mirrors box .box-type-badge — small pill, semantic tint) ────
   Used on card-side related-cards to show rarity (SAR, AR, RR, etc.).
   Card rarity vocabulary is open, so we use only the base style (no per-value
   variant). Future enhancement: add data-rarity color tiers if needed. */
.box-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.6;
    white-space: nowrap;
    width: fit-content;
    border: 1px solid var(--color-border, var(--border-color));
    background: var(--color-bg-secondary, var(--bg-secondary));
    color: var(--color-text-secondary, var(--text-muted));
}
.box-type-badge--sm {
    font-size: var(--font-size-xs);
    padding: 0 6px;
}

/* ── Tags row: 2 badges side by side (rarity + set_code) ─────────────────── */
.box-related-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Rarity color tiers (PTCG conventions) ──────────────────────────────────
   Top tier (gold)  : UR / SR / SSR / SAR / SIR / HR / IR
   High tier (purple): AR / CHR / CSR
   Mid (blue)        : RR
   Standard (yellow) : R
   Basic (green)     : U
   Common (gray)     : C
   Promo (pink)      : P / PR                                                  */

/* Top tier — gold */
.box-type-badge[data-rarity="UR"],
.box-type-badge[data-rarity="SR"],
.box-type-badge[data-rarity="SSR"],
.box-type-badge[data-rarity="SAR"],
.box-type-badge[data-rarity="SIR"],
.box-type-badge[data-rarity="HR"],
.box-type-badge[data-rarity="IR"] {
    background: #ea870014; color: #b35900; border-color: #ea870040;
}
[data-theme="dark"] .box-type-badge[data-rarity="UR"],
[data-theme="dark"] .box-type-badge[data-rarity="SR"],
[data-theme="dark"] .box-type-badge[data-rarity="SSR"],
[data-theme="dark"] .box-type-badge[data-rarity="SAR"],
[data-theme="dark"] .box-type-badge[data-rarity="SIR"],
[data-theme="dark"] .box-type-badge[data-rarity="HR"],
[data-theme="dark"] .box-type-badge[data-rarity="IR"] {
    background: #ea870024; color: #ffb74d; border-color: #ea870055;
}

/* High tier — purple */
.box-type-badge[data-rarity="AR"],
.box-type-badge[data-rarity="CHR"],
.box-type-badge[data-rarity="CSR"] {
    background: #7b1fa214; color: #7b1fa2; border-color: #7b1fa233;
}
[data-theme="dark"] .box-type-badge[data-rarity="AR"],
[data-theme="dark"] .box-type-badge[data-rarity="CHR"],
[data-theme="dark"] .box-type-badge[data-rarity="CSR"] {
    background: #7b1fa224; color: #ce93d8; border-color: #7b1fa240;
}

/* Mid tier — blue */
.box-type-badge[data-rarity="RR"] {
    background: #1967d214; color: #1967d2; border-color: #1967d233;
}
[data-theme="dark"] .box-type-badge[data-rarity="RR"] {
    background: #1967d220; color: #8ab4f8; border-color: #1967d240;
}

/* Standard — amber */
.box-type-badge[data-rarity="R"] {
    background: #f9ab0014; color: #b16800; border-color: #f9ab0040;
}
[data-theme="dark"] .box-type-badge[data-rarity="R"] {
    background: #f9ab0024; color: #fdd663; border-color: #f9ab0055;
}

/* Basic — green */
.box-type-badge[data-rarity="U"] {
    background: #13733314; color: #137333; border-color: #13733333;
}
[data-theme="dark"] .box-type-badge[data-rarity="U"] {
    background: #13733324; color: #81c995; border-color: #13733340;
}

/* Common — gray (uses base styles — no override needed, but explicit for clarity) */
.box-type-badge[data-rarity="C"] {
    background: var(--color-bg-secondary, var(--bg-secondary));
    color: var(--color-text-secondary, var(--text-muted));
    border-color: var(--color-border, var(--border-color));
}

/* Promo — pink/magenta */
.box-type-badge[data-rarity="P"],
.box-type-badge[data-rarity="PR"] {
    background: #d81b6014; color: #b91c5c; border-color: #d81b6033;
}
[data-theme="dark"] .box-type-badge[data-rarity="P"],
[data-theme="dark"] .box-type-badge[data-rarity="PR"] {
    background: #d81b6024; color: #f48fb1; border-color: #d81b6040;
}

/* Set code badge — neutral teal so it visually pairs with but doesn't compete
   with the rarity badge above */
.box-type-badge[data-set-code] {
    background: #00897b14; color: #00695c; border-color: #00897b33;
    font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .box-type-badge[data-set-code] {
    background: #00897b24; color: #4db6ac; border-color: #00897b40;
}

/* ── PSA / 等級 badge 色階 (data-grade) ──────────────────────────────────
   PSA10 / PSA9 → 鑑定卡（金 / 琥珀）
   A / B / C / D → 裸卡狀態（綠 / 青綠 / 藍 / 灰）
   其他（PSA8以下 / BGS / ARS）→ 中性紫                                 */
.box-type-badge[data-grade="PSA10"] {
    background: #ea870014; color: #b35900; border-color: #ea870040;
}
[data-theme="dark"] .box-type-badge[data-grade="PSA10"] {
    background: #ea870024; color: #ffb74d; border-color: #ea870055;
}
.box-type-badge[data-grade="PSA9"] {
    background: #f9ab0014; color: #b16800; border-color: #f9ab0040;
}
[data-theme="dark"] .box-type-badge[data-grade="PSA9"] {
    background: #f9ab0024; color: #fdd663; border-color: #f9ab0055;
}
.box-type-badge[data-grade="A"] {
    background: #13733314; color: #137333; border-color: #13733333;
}
[data-theme="dark"] .box-type-badge[data-grade="A"] {
    background: #13733324; color: #81c995; border-color: #13733340;
}
.box-type-badge[data-grade="B"] {
    background: #00897b14; color: #00695c; border-color: #00897b33;
}
[data-theme="dark"] .box-type-badge[data-grade="B"] {
    background: #00897b24; color: #4db6ac; border-color: #00897b40;
}
.box-type-badge[data-grade="C"] {
    background: #1967d214; color: #1967d2; border-color: #1967d233;
}
[data-theme="dark"] .box-type-badge[data-grade="C"] {
    background: #1967d220; color: #8ab4f8; border-color: #1967d240;
}
.box-type-badge[data-grade="D"] {
    background: var(--color-bg-secondary, var(--bg-secondary));
    color: var(--color-text-secondary, var(--text-muted));
    border-color: var(--color-border, var(--border-color));
}
/* 其他鑑定機構（PSA8以下 / BGS / ARS）統一紫色 */
.box-type-badge[data-grade^="PSA8"],
.box-type-badge[data-grade^="BGS"],
.box-type-badge[data-grade^="ARS"] {
    background: #7b1fa214; color: #7b1fa2; border-color: #7b1fa233;
}
[data-theme="dark"] .box-type-badge[data-grade^="PSA8"],
[data-theme="dark"] .box-type-badge[data-grade^="BGS"],
[data-theme="dark"] .box-type-badge[data-grade^="ARS"] {
    background: #7b1fa224; color: #ce93d8; border-color: #7b1fa240;
}

/* ════════════════════════════════════════════════════════════════════
   手機版設計系統統一（2026-07-13）— 圓角 / 陰影收斂成一致規範
   放檔案最末：source order 最高 → 蓋過前面所有零散值，不必逐條提特異度。
   僅 @media (max-width:767px)，桌面零影響。
   規範：卡/容器/鈕圓角=16 · 小標籤/控制/縮圖=8 · 膠囊=999 · 圓形=50%
        所有 elevated UI 陰影一律 var(--shadow)（Solid Pop 實體硬陰影）
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* 圓角 token 統一 → 一次收斂所有 var(--radius*) 用法（卡/hero/鈕/格子=16、小=8） */
    :root {
        --radius: 16px;
        --radius-hero: 16px;
        --radius-btn: 16px;
        --radius-cell: 16px;
        --radius-sm: 8px;
    }

    /* 硬編碼圓角 → 小標籤 / 控制 / 輸入 / 縮圖 統一 8px */
    .grade-tag,
    .grade-badge,
    .monthly-avg-change,
    .btn-range,
    .btn-monthly-avg,
    #monthly-avg-section .btn-monthly-avg,
    .btn-toggle-analysis,
    .psa-trend-retry,
    .form-control,
    .source-badge,
    .summary-card,
    .sticky-title .sticky-title-image,
    .hot-card-link__img {
        border-radius: 8px;
    }

    /* 膠囊統一 999px */
    .card-chip,
    .box-type-badge {
        border-radius: 999px;
    }

    /* 陰影統一 → 所有 elevated UI 一律 Solid Pop var(--shadow)（含深色，token 已自適應） */
    .data-section,
    [data-theme="dark"] .data-section,
    .floating-fav-btn,
    [data-theme="dark"] .floating-fav-btn,
    .listing-nav-btn:hover,
    .hot-cards-btn:hover:not(:disabled),
    .hot-card-link:hover,
    [data-theme="dark"] .hot-card-link:hover {
        box-shadow: var(--shadow);
    }

    /* 兩張折線圖：負邊距縮小左右距離、讓圖表吃更多寬度 */
    .chart-container {
        margin-left: -8px;
        margin-right: -8px;
    }
}
