/* Global Styles & Variables */
:root {
    /* Light Mode (Default: Minimalist White Card) */
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-hover: #f1f5f9;
    --bg-zebra: #f8fafc;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    
    /* Positive (Red/Up/Buy) */
    --color-up: #e11d48;
    --bg-up: rgba(225, 29, 72, 0.06);
    --border-up: rgba(225, 29, 72, 0.15);
    
    /* Negative (Green/Down/Sell) */
    --color-down: #059669;
    --bg-down: rgba(5, 150, 105, 0.06);
    --border-down: rgba(5, 150, 105, 0.15);

    --accent-blue: #3b82f6;
    --radius-lg: 10px;
    --radius-md: 6px;
    --transition-fast: 0.15s ease;
}
.app-title {
    position: relative;
    z-index: 10; /* 讓標題浮上來，防止被 header-controls 擋住點擊 */
}

.app-title a {
    color: var(--text-primary); /* 完美融入原本的深淺色主題 */
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.app-title a:hover {
    color: #2563eb; /* 滑鼠移過去變藍色，不加底線維持現代感 */
}

[data-theme="dark"] {
    /* Dark Mode (Sleek Dark Card) */
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-header: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --bg-hover: #334155;
    --bg-zebra: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    
    /* Positive (Red/Up/Buy) */
    --color-up: #fb7185;
    --bg-up: rgba(244, 63, 94, 0.08);
    --border-up: rgba(244, 63, 94, 0.15);
    
    /* Negative (Green/Down/Sell) */
    --color-down: #34d399;
    --bg-down: rgba(16, 185, 129, 0.08);
    --border-down: rgba(16, 185, 129, 0.15);

    --accent-blue: #60a5fa;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* Header Styles */
.main-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    padding-right: 36px;
    font-size: 13px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent-blue);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
    opacity: 0.6;
}

.theme-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background-color var(--transition-fast);
}

.theme-btn:hover {
    background-color: var(--bg-hover);
}

/* Main Content Layout */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards & Layout */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-title-unit {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.date-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    padding: 4px 8px;
    border-radius: var(--radius-md);
}

/* Two-column layout for dashboard */
.dashboard-two-column-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
    /* Grid items default to min-width: auto (their content's min-content
       size), so without this a wide descendant (e.g. the futures type tabs)
       can force this column past its 1fr track and blow out the whole page's
       width on narrow screens, instead of wrapping/scrolling locally. */
    min-width: 0;
}

@media (min-width: 1024px) {
    .dashboard-two-column-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.market-parallel-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .market-parallel-tables {
        grid-template-columns: 1fr 1fr;
    }
}

.table-subtitle {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
}

#apply-streak-btn:hover {
    background-color: #2563eb !important;
}

/* Tables Styles */
.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

th {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Text alignment utilities */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* Badge & Streaks styles */
.badge-up, .badge-down {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.badge-up {
    background-color: var(--bg-up);
    color: var(--color-up);
    border: 1px solid var(--border-up);
}

.badge-down {
    background-color: var(--bg-down);
    color: var(--color-down);
    border: 1px solid var(--border-down);
}

/* Plain colored text (no badge background) - replaces repeated inline styles in app.js */
.text-up {
    color: var(--color-up);
    font-weight: 600;
}

.text-down {
    color: var(--color-down);
    font-weight: 600;
}

/* Chart Styles */
.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.futures-chart {
    width: 100%;
    /*max-height: 350px;*/
    object-fit: contain;
}

.chart-fallback-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Tab Styles */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.tabs-header::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Options & Analysis Grid */
.options-analysis-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settlement-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
}

.settlement-banner.alert {
    background-color: var(--bg-up);
    color: var(--color-up);
    border: 1px solid var(--border-up);
}

.settlement-banner.neutral {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.options-oi-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.options-card {
    display: flex;
    flex-direction: column;
    padding: 14px;
    border-radius: var(--radius-md);
}

.options-card.call {
    background-color: var(--bg-up);
    border: 1px solid var(--border-up);
}

.options-card.put {
    background-color: var(--bg-down);
    border: 1px solid var(--border-down);
}

.options-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.options-strike {
    font-size: 20px;
    font-weight: 700;
    margin: 4px 0;
}

.options-card.call .options-strike {
    color: var(--color-up);
}

.options-card.put .options-strike {
    color: var(--color-down);
}

.options-oi {
    font-size: 12px;
    color: var(--text-secondary);
}

.market-analysis-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.analysis-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.analysis-content {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Stock Detail Search Box Card */
#stock-detail-section {
    border-left: 4px solid var(--accent-blue);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.stock-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.stock-price-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.stock-price-main {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.stock-price-value {
    font-size: 28px;
    font-weight: 700;
}

.stock-price-change {
    font-size: 15px;
    font-weight: 600;
}

.stock-meta-info {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.stock-meta-info .badge {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.stock-ohl-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .stock-ohl-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.ohl-item {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.ohl-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.ohl-value {
    font-size: 14px;
    font-weight: 600;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.stock-streaks-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

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

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

.streak-box {
    display: flex;
    flex-direction: column;
    padding: 14px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.streak-box-title {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.streak-box-value {
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
}

.sbl-section-title {
    margin-top: 20px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border-top: 1px dashed var(--border-color);
    padding-top: 16px;
}

.stock-sbl-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

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

.sbl-summary-banner {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sbl-summary-banner.bearish {
    background-color: rgba(225, 29, 72, 0.06);
    color: #e11d48;
    border-color: rgba(225, 29, 72, 0.15);
}

.sbl-summary-banner.bullish {
    background-color: rgba(5, 150, 105, 0.06);
    color: #059669;
    border-color: rgba(5, 150, 105, 0.15);
}

.hidden {
    display: none !important;
}

/* Footer styles */
.app-footer {
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 24px 20px;
    margin-top: 40px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.page-btn {
    padding: 6px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all var(--transition-fast);
    outline: none;
}

.page-btn:hover:not(:disabled) {
    background-color: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Modal Backdrop Overlay */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    transition: opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Stock Detail Floating Modal */
.stock-detail-modal {
    position: fixed;
    z-index: 999;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Default Mode: Centered floating modal */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--accent-blue);
    opacity: 0;
    pointer-events: none;
}

.stock-detail-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Docked Right Mode (Overlay Drawer) */
.stock-detail-modal.docked-right {
    top: 0;
    right: 0;
    left: auto;
    bottom: 0;
    width: 440px;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    transform: translateX(100%);
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-right: none;
    border-left: 4px solid var(--accent-blue);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
}

.stock-detail-modal.docked-right.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Header Actions Styles */
.card-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dock-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.dock-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Docked Right specific layout adjustments to prevent horizontal scrollbars */
.stock-detail-modal.docked-right .stock-info-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

.stock-detail-modal.docked-right .stock-price-card {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    align-items: center;
    text-align: center;
}

.stock-detail-modal.docked-right .stock-price-main {
    justify-content: center;
}

.stock-detail-modal.docked-right .stock-meta-info {
    justify-content: center;
}

.stock-detail-modal.docked-right .stock-ohl-grid {
    grid-template-columns: repeat(2, 1fr) !important;
}

.stock-detail-modal.docked-right .stock-streaks-grid {
    grid-template-columns: repeat(2, 1fr) !important;
}

/* Search Suggestions Autocomplete Dropdown */
.search-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1010;
    margin-top: 4px;
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active-suggestion {
    background-color: var(--bg-hover);
}

.suggestion-symbol {
    font-weight: 700;
    color: var(--accent-blue);
    font-variant-numeric: tabular-nums;
}

.suggestion-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-left: 8px;
    flex-grow: 1;
}

.suggestion-market {
    font-size: 10px;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Futures Tab Buttons Styling */
.futures-type-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.futures-tab-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.futures-tab-btn:hover {
    color: var(--text-primary);
}

.futures-tab-btn.active {
    background-color: var(--bg-card);
    color: var(--accent-blue);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    /* Hide the dock to right button on mobile because split drawer screen is too narrow */
    .dock-btn {
        display: none !important;
    }
    
    /* Override docked mode on mobile to force it to render as a centered floating modal */
    .stock-detail-modal.docked-right {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) scale(0.95) !important;
        width: 90% !important;
        max-width: 550px !important;
        height: auto !important;
        max-height: 90vh !important;
        border-radius: var(--radius-lg) !important;
        border: 1px solid var(--border-color) !important;
        border-left: 4px solid var(--accent-blue) !important;
        box-shadow: var(--shadow-md) !important;
    }
    
    .stock-detail-modal.docked-right.active {
        transform: translate(-50%, -50%) scale(1) !important;
    }
    
    /* Stack card headers vertically on mobile/tablet for dashboard cards to avoid squishing */
    .card:not(.stock-detail-modal) .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .card:not(.stock-detail-modal) .card-header .card-title {
        text-align: center;
    }
    
    /* Futures type tabs full-width stretch on mobile/tablet */
    .futures-type-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .futures-type-tabs .futures-tab-btn {
        flex: 1;
        text-align: center;
        padding: 6px 4px;
        font-size: 11px;
    }
}

@media (max-width: 576px) {
    /* Adjust header layout to stack nicely on mobile */
    .header-container {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
        gap: 12px;
    }
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        flex-grow: 1;
        width: auto;
    }
    
    /* Reduce card padding slightly to maximize content space */
    .card {
        padding: 16px;
    }
    

    
    /* Reduce table cell padding to prevent overflow scroll on mobile */
    table th {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    /* Remove badge background/borders in futures table on mobile to save space */
    #futures-oi-table .badge-up,
    #futures-oi-table .badge-down {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        font-weight: 600;
    }
    
    /* Hide 'Industry' (3rd) and 'Market' (4th) columns in rankings tables on mobile to prevent scrolling entirely */
    #table-foreign-buy th:nth-child(3),
    #table-foreign-buy td:nth-child(3),
    #table-foreign-buy th:nth-child(4),
    #table-foreign-buy td:nth-child(4),
    #table-foreign-sell th:nth-child(3),
    #table-foreign-sell td:nth-child(3),
    #table-foreign-sell th:nth-child(4),
    #table-foreign-sell td:nth-child(4),
    #table-trust-buy th:nth-child(3),
    #table-trust-buy td:nth-child(3),
    #table-trust-buy th:nth-child(4),
    #table-trust-buy td:nth-child(4),
    #table-trust-sell th:nth-child(3),
    #table-trust-sell td:nth-child(3),
    #table-trust-sell th:nth-child(4),
    #table-trust-sell td:nth-child(4) {
        display: none !important;
    }
    
    /* Main container padding */
    .main-content {
        padding: 16px 12px;
    }
    
    /* Stack options Call & Put cards vertically */
    .options-oi-cards {
        grid-template-columns: 1fr;
    }
    
    /* Chart container aspect ratio scaling to fit phone screens without empty spaces */
    .chart-container {
        min-height: auto;
        aspect-ratio: 5 / 3;
        width: 100%;
    }
    
    .futures-chart {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

/* Watchlist Styles */
.watchlist-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.watchlist-placeholder {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.watchlist-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    user-select: none;
}

.watchlist-chip:hover {
    transform: translateY(-2px);
    background-color: var(--bg-hover);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

.watchlist-chip-title {
    font-weight: 600;
    color: var(--text-primary);
}

.watchlist-chip-price {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--text-primary);
    margin-left: 2px;
}

.watchlist-chip-change {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.watchlist-chip-remove {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    transition: all var(--transition-fast);
    margin-left: 2px;
}

.watchlist-chip-remove:hover {
    background-color: var(--bg-hover);
    color: var(--color-up);
}

/* Favorite Star Button Styles in Modal */
.favorite-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.favorite-btn:hover {
    background-color: var(--bg-hover);
    border-color: #eab308;
    color: #eab308;
}

.favorite-btn.active {
    color: #eab308;
    background-color: rgba(234, 179, 8, 0.08);
    border-color: #eab308;
}

/* Yahoo Link Button Styles in Modal */
.yahoo-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.yahoo-btn:hover {
    background-color: var(--bg-hover);
    border-color: #7b00d3;
    color: #7b00d3;
}

/* Intraday Live Indicator Banner */
.live-indicator-banner {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid rgba(217, 119, 6, 0.2);
    background-color: rgba(217, 119, 6, 0.05);
    color: #b45309; /* warm amber text */
    text-align: left;
}

/* ==========================================
   Google AdSense & Mock Ads Preview Styles
   ========================================== */

.ad-container {
    margin-bottom: 24px;
    width: 100%;
}

/* Specific margins for different sections */
.ad-top-leaderboard {
    margin-top: 8px;
    margin-bottom: 24px;
}

.ad-bottom-banner {
    margin-top: 24px;
    margin-bottom: 8px;
}

.ad-modal-rect {
    margin-top: 20px;
    margin-bottom: 8px;
}

/* Elegant header label for the ad slots */
.ad-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.7;
}

.ad-label::after {
    content: "";
    flex-grow: 1;
    height: 1px;
    border-bottom: 1px dotted var(--border-color);
    margin-left: 8px;
}

/* Premium Ad Card Mockup */
.ad-mockup {
    background-color: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.ad-mockup:hover {
    border-color: var(--accent-blue);
    background-color: var(--bg-hover);
}

/* Google Ad Badge */
.ad-badge {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-block;
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: var(--bg-primary);
    line-height: 1;
}

/* Ad content alignment (horizontal) */
.ad-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.ad-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.ad-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-blue);
    line-height: 1.3;
}

.ad-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Ad Call To Action Button */
.ad-cta-btn {
    background-color: var(--accent-blue);
    color: #ffffff !important;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    transition: all var(--transition-fast);
}

.ad-cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    filter: brightness(1.08);
}

.ad-cta-btn:active {
    transform: translateY(0);
}

/* Stock Details Modal Ad (Rectangle Slot) */
.ad-rect-mockup {
    min-height: 180px;
    padding: 20px;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.ad-content-rect {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.ad-rect-mockup .ad-title {
    font-size: 15px;
    margin-top: 4px;
}

.ad-rect-mockup .ad-desc {
    font-size: 12px;
    max-width: 320px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.ad-rect-mockup .ad-badge {
    position: absolute;
    top: 12px;
    left: 12px;
}

@media (max-width: 768px) {
    .ad-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 14px;
    }
    
    .ad-mockup {
        padding: 16px;
        align-items: center;
    }
    
    .ad-info {
        align-items: center;
    }
    
    .ad-cta-btn {
        width: 100%;
        text-align: center;
    }
} 

.footer-container p {
    margin: 0;
    margin-bottom: 8px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* 文章列表卡片 */
.article-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 20px;
}

.article-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.article-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}

.article-card-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.article-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.article-card:hover .article-card-title {
    color: var(--accent-blue);
}

.article-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.article-card-arrow {
    flex-shrink: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-secondary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.article-card:hover .article-card-arrow {
    color: var(--accent-blue);
    transform: translateX(4px);
}

/* Header 主導覽 */
.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.main-nav a:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* 內文與 footer 連結配色（跟隨深淺主題） */
.footer-container a,
.instruction-body a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-container a:hover,
.instruction-body a:hover {
    text-decoration: underline;
}

.instruction-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    padding: 24px;
    box-sizing: border-box;
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.instruction-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    position: relative;
}

.instruction-title::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--accent-blue);
}

.instruction-body {
    line-height: 1.7;
    color: var(--text-primary);
}

.instruction-subtitle {
    font-size: 14px;
    font-weight: 600;
    margin-top: 18px;
    margin-bottom: 6px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
}

.instruction-body p {
    margin-bottom: 12px;
    font-size: 13.5px;
    color: var(--text-primary);
}

.instruction-list {
    padding-left: 20px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

.instruction-list li {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.instruction-list strong {
    color: var(--text-primary);
}

.instruction-summary-box {
    background-color: var(--bg-primary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    border-left: 4px solid #f59e0b;
    margin-top: 18px;
    line-height: 1.6;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 576px) {
    .instruction-section {
        padding: 18px 16px;
    }
    .instruction-title {
        font-size: 15px;
    }
    .instruction-body p,
    .instruction-list {
        font-size: 13px;
    }
}

section.card {
    margin-bottom: 24px;
}

/* 捲動至最上面/最下面浮動按鈕 */
.scroll-buttons {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.scroll-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    outline: none;
}

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

.scroll-btn:hover {
    background-color: var(--bg-hover);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
}

.scroll-btn:active {
    transform: translateY(1px);
}

.scroll-btn svg {
    transition: transform var(--transition-fast);
}

.scroll-btn:hover svg {
    transform: scale(1.1);
}

@media (max-width: 576px) {
    #tab-dual-buy .table-container,
    #tab-dual-sell .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #table-dual-buy, #table-dual-sell {
        min-width: 460px;
    }

    #table-dual-buy th, #table-dual-buy td,
    #table-dual-sell th, #table-dual-sell td {
        padding: 10px 6px !important;
        font-size: 12px !important;
    }

    #table-foreign-buy th:nth-child(3), #table-foreign-buy td:nth-child(3),
    #table-foreign-sell th:nth-child(3), #table-foreign-sell td:nth-child(3),
    #table-trust-buy th:nth-child(3), #table-trust-buy td:nth-child(3),
    #table-trust-sell th:nth-child(3), #table-trust-sell td:nth-child(3),
    #table-dual-buy th:nth-child(3), #table-dual-buy td:nth-child(3),
    #table-dual-sell th:nth-child(3), #table-dual-sell td:nth-child(3) {
        display: none !important;
    }
}

/* ========== OI Info Accordion ========== */
.oi-info-accordion {
    margin-top: 16px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.oi-info-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease;
    text-align: left;
    gap: 12px;
    font-family: inherit;
}

.oi-info-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04));
    color: var(--text-primary);
}

.oi-info-toggle[aria-expanded="true"] {
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.oi-info-chevron {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.oi-info-toggle[aria-expanded="true"] .oi-info-chevron {
    transform: rotate(180deg);
}

.oi-info-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    padding: 0 18px;
}

.oi-info-body.open {
    max-height: 550px;
    padding: 16px;
}

.oi-info-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.oi-info-section {
    margin-bottom: 0;
}

.oi-info-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

/* Info Table */
.oi-info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.oi-info-table thead th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    font-size: 12px;
}

.oi-info-table tbody td {
    padding: 9px 10px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    line-height: 1.55;
    vertical-align: top;
}

.oi-info-table tbody tr:last-child td {
    border-bottom: none;
}

.oi-info-table tbody td strong {
    color: var(--text-primary);
}

/* Text & List */
.oi-info-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 10px 0;
}

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

.oi-info-list li {
    position: relative;
    padding: 8px 0 8px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.oi-info-list li:last-child {
    border-bottom: none;
}

.oi-info-list li::before {
    content: "▸";
    position: absolute;
    left: 2px;
    top: 8px;
    color: var(--accent-blue);
    font-size: 12px;
}

.oi-info-list li strong {
    color: var(--text-primary);
}

.oi-info-list li em {
    color: var(--accent-gold);
    font-style: normal;
    font-weight: 600;
}

/* Badge */
.oi-info-badge-up {
    display: inline-block;
    background: rgba(0, 200, 83, 0.15);
    color: #4cdf8b;
    font-size: 12px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 4px;
    margin: 0 2px;
}

/* Tip box */
.oi-info-tip {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.06));
    border-left: 3px solid var(--accent-blue);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.oi-info-tip strong {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .oi-info-toggle {
        padding: 12px 14px;
        font-size: 13px;
    }
    .oi-info-body.open {
        padding: 14px;
    }
    .oi-info-table {
        font-size: 11.5px;
    }
    .oi-info-table thead th,
    .oi-info-table tbody td {
        padding: 7px 6px;
    }
    .oi-info-table thead th:nth-child(4),
    .oi-info-table tbody td:nth-child(4) {
        display: none;
    }
    .oi-info-body.open {
        max-height: 650px;
    }
}
/* ---------- Pre-open morning brief ---------- */

.brief-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brief-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 10px;
    letter-spacing: 0.02em;
}

/* Tiles wrap rather than scroll: the brief is read at a glance, and a hidden
   row of numbers is worse than a taller card. */
.brief-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.brief-tile {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.brief-tile-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.brief-tile-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.brief-tile-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}

.brief-lists {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.brief-list-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 6px;
}

.brief-list ol {
    margin: 0;
    padding-left: 18px;
}

.brief-list li {
    font-size: 13px;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-variant-numeric: tabular-nums;
}

.brief-li-name {
    cursor: pointer;
    color: var(--text-primary);
}

.brief-li-name:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.brief-alert {
    background: var(--bg-up);
    border: 1px solid var(--border-up);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
}

.brief-disclaimer {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 14px 0 0;
    line-height: 1.6;
}

.brief-focus-link {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0 0;
}

.brief-focus-link a {
    color: var(--accent-blue);
    font-weight: 600;
    text-decoration: none;
}

.brief-focus-link a:hover {
    text-decoration: underline;
}

/* ---------- Streak reference price ---------- */

.avg-price-cell {
    line-height: 1.35;
}

.avg-price-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.avg-price-diff {
    display: block;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.avg-price-empty {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ---------- Signal scoreboard ---------- */

.scoreboard-intro {
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-secondary);
    margin: 0 0 18px;
}

.scoreboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.score-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.score-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.score-card-main {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin: 6px 0 2px;
    font-variant-numeric: tabular-nums;
}

.score-card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.score-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

.score-k {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
}

.score-v {
    display: block;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.score-caveat {
    margin-top: 16px;
    line-height: 1.7;
}

.score-pending {
    color: var(--text-secondary);
    font-size: 12px;
}

.score-partial {
    display: inline-block;
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* Chips wrap: the picked names are the evidence behind each average, so they
   stay visible rather than being collapsed behind a toggle. */
.stock-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 460px;
}

.stock-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.chip-ret {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .stock-chips { max-width: none; }
    .score-card-main { font-size: 26px; }
}

.scoreboard-rule {
    font-size: 13px;
    line-height: 1.75;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-blue);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin: 0 0 16px;
}

.score-pending {
    white-space: nowrap;
}

/* ---------- Morning brief collapse ---------- */

.brief-collapse {
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Used while restoring the saved state on load, so a card that starts
   collapsed does not visibly fold itself shut on every page view. */
.brief-collapse.no-transition {
    transition: none;
}

.brief-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.brief-toggle:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.brief-chevron {
    transition: transform 0.3s ease;
}

.brief-toggle.collapsed .brief-chevron {
    transform: rotate(-90deg);
}

/* =========================================================================
   手機版體驗優化
   1. 瘦身 sticky header（原本佔掉 22% 螢幕高度）
   2. 排行榜頁籤改為換行，避免「雙買/雙賣」被藏在畫面外
   3. 觸控目標放大到好按的尺寸
   4. 表格內容字級微調
   ========================================================================= */
@media (max-width: 576px) {
    /* 1. header 瘦身：標題原本吃 h1 預設 28px，長標題會折成三行 */
    .app-title {
        font-size: 17px;
        line-height: 1.35;
    }

    .header-container {
        padding: 10px 14px;
        gap: 10px;
    }

    .main-nav a {
        padding: 6px 10px;
        font-size: 12.5px;
    }

    /* 2. 頁籤換行，六個分頁一次全部看得到（原本需 732px 卻只顯示 317px） */
    .tabs-header {
        flex-wrap: wrap;
        overflow-x: visible;
        white-space: normal;
        gap: 6px;
    }

    .tabs-header .tab-btn {
        flex: 1 1 calc(33.333% - 6px);
        min-height: 44px;
        padding: 10px 4px;
        font-size: 12px;
        text-align: center;
    }

    /* 3. 觸控目標：iOS/Android 建議至少 44px，這些原本只有 13～29px */
    .close-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .favorite-btn,
    .dock-btn,
    .yahoo-btn,
    .brief-toggle {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    .futures-type-tabs .futures-tab-btn {
        min-height: 40px;
    }

    .streak-filter-control input,
    .streak-filter-control select,
    #apply-streak-btn {
        min-height: 36px;
    }

    /* 4. 表格內容字級：12px 在手機上偏小 */
    table td {
        font-size: 13px;
    }

    /* 5.「每日訊號紀錄」改為堆疊卡片。
       六欄表格在手機需要 548px、容器只有 317px，會有 231px 被藏在右側，
       且「選出個股」擠在 158px 內讓每列高達 123px。改成一筆一張卡後
       不再需要左右捲動，欄位標題由 td 的 data-label 提供。 */
    #scoreboard-table thead {
        display: none;
    }

    #scoreboard-table,
    #scoreboard-table tbody,
    #scoreboard-table tr,
    #scoreboard-table td {
        display: block;
        width: 100%;
    }

    /* 五個短欄位兩欄並排，避免卡片過高（單欄時整頁要捲十個螢幕） */
    #scoreboard-table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px 14px;
        background-color: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 12px 14px;
        margin-bottom: 12px;
    }

    #scoreboard-table td {
        border-bottom: none;
        padding: 5px 0;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        white-space: normal;
        text-align: left;
    }

    #scoreboard-table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        color: var(--text-secondary);
        font-size: 12px;
        font-weight: 600;
    }

    /* 「待次一交易日結算」原設 nowrap，在半寬欄位會撐出去，改為可換行 */
    #scoreboard-table .score-pending {
        white-space: normal;
        text-align: right;
        font-size: 11.5px;
    }

    /* 選出個股：橫跨兩欄，標題自成一行，股票標籤全寬流動排列 */
    #scoreboard-table td[data-label="選出個股"] {
        display: block;
        grid-column: 1 / -1;
        margin-top: 6px;
        padding-top: 8px;
        border-top: 1px dashed var(--border-color);
    }

    #scoreboard-table td[data-label="選出個股"]::before {
        display: block;
        margin-bottom: 6px;
    }

    /* 「載入中…／尚無紀錄／載入失敗」這類整列訊息不套卡片欄位樣式 */
    #scoreboard-table td[colspan] {
        display: block;
        grid-column: 1 / -1;
        text-align: center;
    }

    #scoreboard-table td[colspan]::before {
        content: none;
    }
}
