/* ── 모바일 토글 버튼 (기본 숨김) ── */
.mobile-toggle-bar {
    display: none;
    margin-top: 8px;
    margin-bottom: 8px;
    gap: 8px;
}

.mobile-toggle-bar button {
    flex: 1;
    padding: 4px 0;
    font-size: 0.8rem;
    border: 1px solid #666;
    background: #222;
    color: #fff;
    border-radius: 4px;
}

.mobile-toggle-bar button.active {
    background: #444;
}

.stock-theme {
    color: red;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* global.css 또는 issue.css 등 적당한 파일에 추가 */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    z-index: 9998;
}

#splash-screen img {
    max-width: 50%;
    max-height: 50%;
}

.chart-toggle-btn {
    background: none;
    border: none;
    padding: 0;
    margin-left: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

/* 펼침/축소 토글 버튼 - 데스크탑에서는 항상 숨김 */
.expand-toggle-btn {
    display: none;
}

/* ── 펼쳐진 테마 뷰 (데스크탑에서는 숨김) ── */
.theme-expanded-view {
    display: none;
}

/* ── 펼쳐진 종목 뷰 (기본 숨김) ── */
.stock-expanded-view {
    display: none;
}

/* 처음엔 Bar 아이콘 숨기고 Line만 보이기 */
.chart-toggle-btn .icon-bar {
    display: none;
    height: 25px;
}

.chart-toggle-btn .icon-line {
    display: inline-block;
    height: 25px;
}

/* active 클래스가 붙으면 Line 숨기고 Bar 보이기 */
.chart-toggle-btn.active .icon-line {
    display: none;
}

.chart-toggle-btn.active .icon-bar {
    display: inline-block;
}

/* 토글 버튼도 inline-flex, 아이콘과 텍스트 사이 간격 유지 */
.combo-title .chart-toggle-btn {
    display: inline-flex;
    align-items: center;
    margin-left: 8px; /* 필요에 따라 조절 */
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

/* 아이콘 크기를 텍스트 높이에 맞추기 */
.combo-title .chart-toggle-btn img {
    height: 1em; /* 텍스트 1em 높이와 동일 */
    width: auto;
    display: block;
}

.panel {
    padding: 0 10px;
}

.combo-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.combo-left, .combo-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.combo-group {
    display: flex;
    gap: 10px;
}

.combo-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #e6e6e6;
    color: #333D4B;
    font-size: 0.85rem;
    padding: 8px 36px 8px 12px;
    border: none;
    border-radius: 6px;
    font-family: Pretendard Variable, Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 50 L70 100 L120 50' stroke='%23333' stroke-width='15' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.combo-group select:hover {
    background-color: #f0f0f0;
}

.combo-group select:focus {
    outline: none;
    box-shadow: 0 0 0 2px #4fabff;
}

/* ETF·ETN 표시 토글 — 켜짐(파랑) = 목록에 포함 / 꺼짐(회색) = 숨김 */
.etf-toggle {
    appearance: none;
    background-color: #e6e6e6;
    color: #9aa1a9;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-family: Pretendard Variable, Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.etf-toggle:hover { background-color: #f0f0f0; }
.etf-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px #4fabff; }

.etf-toggle.on {
    background-color: #4fabff;
    color: #fff;
}

/* ───────────── View Toggle Buttons ───────────── */
.view-toggle {
    display: none;
    gap: 6px;
    margin-bottom: 10px;
}

.view-toggle button {
    height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    background: #333;
    color: #fff;
    border: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    width: 50%;
}

/* ── 모바일에서 view-toggle 버튼 크기 축소 ── */
@media (max-width: 1023px) {
    .view-toggle {
        margin-bottom: 6px;
    }
    .view-toggle button {
        height: 25px;
        font-size: 0.7rem;
        padding: 0 8px;
    }
}

.view-toggle button.active {
    background: linear-gradient(90deg, #e71909, #e71909);
}

/* ───────────── Chart Bars ───────────── */
#bar-container,
#stock-bar-container {
    position: relative;
    height: 500px;
    margin-bottom: 20px;
    padding-left: 10px;
    width: 100%;
}

.chart-wrapper {
    position: relative;
    height: 400px;
    width: 100%;
    display: none;
}

.bar-item {
    position: absolute;
    width: calc(100%);
    height: 40px;
    display: flex;
    align-items: center;
    transition: top 0.5s ease;
    padding-left: 10px;
}

.stock-code {
    display: inline-block; /* 필요에 따라 block or inline-block */
    color: #888; /* 원하는 색으로 변경 */
    font-size: 0.9em; /* 필요하면 크기도 조절 */
    /*margin-top: 2px; !* 줄 간격 조정 *!*/
}

.chart-label .stock-code {
    margin-top: -3px;
}

.chart-theme-label {
    width: 120px;
    text-align: center;
    border-left: 1px solid white;
}

.chart-theme-label[data-theme-id] {
    cursor: pointer;
}

.chart-theme-label[data-theme-id]:hover {
    text-decoration: underline;
}

.chart-rank {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    min-width: 24px;
    text-align: right;
    margin-right: 8px;
    flex-shrink: 0;
}

.chart-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e0e0e0;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
}

.chart-label {
    width: 130px;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

.bar {
    position: relative;
    flex: 1;
    height: 100%;
    background: #686868;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    color: white;
}

.bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.5s ease;
}

.right-panel .chart-value {
    left: 15px;
    color: white;
}

.left-panel .chart-value {
    left: 15px;
}

.chart-value {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.80rem;
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 400px) {
    .chart-value {
        font-size: 0.55rem;
    }
}

/* ───────────── Pagination ───────────── */
#stock-pagination {
    text-align: center;
}

.stock-toggle-btn {
    background-color: #e6e6e6;
    color: #333D4B;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* ───────────── Modal ───────────── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #2b2b3c;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
}

/* ───────────── Filter Bar ───────────── */
.filter-bar {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 1.1rem;
    background: #2b2b3c;
    padding: 20px;
    border-radius: 8px;
}

.modal .filter-bar {
    display: flex;
}

.filter-bar input.filter-input {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
    color: #000;
}

.filter-bar button.filter-save-btn {
    padding: 7px 14px;
    background: #4fabff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.filter-bar button.filter-save-btn:hover {
    background: #3486d1;
}


@media (min-width: 1024px) {

    .combo-title {
        font-size: 1.2rem;
        font-weight: 600;
        color: #333D4B;
        white-space: nowrap;
    }

    /* ── 데스크탑 펼쳐보기 버튼 스타일 ── */
    #themeExpandToggle {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #e6e6e6;
        color: #333D4B;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        height: 32px;
        width: 32px;
        padding: 0;
        margin-left: 8px;
    }

    #themeExpandToggle:hover {
        background-color: #f0f0f0;
    }

    #themeExpandToggle:focus {
        outline: none;
        box-shadow: 0 0 0 2px #4fabff;
    }

    #themeExpandToggle svg {
        width: 16px;
        height: 16px;
    }

    /* 기본: expand 아이콘 보이고, collapse 숨김 */
    #themeExpandToggle .icon-expand {
        display: block;
    }
    #themeExpandToggle .icon-collapse {
        display: none;
    }

    /* active 상태: collapse 아이콘 보이고, expand 숨김 */
    #themeExpandToggle.active .icon-expand {
        display: none;
    }
    #themeExpandToggle.active .icon-collapse {
        display: block;
    }

    /* ── 데스크탑 펼쳐보기 뷰 스타일 ── */
    .theme-expanded-view {
        display: none;
        flex-direction: column;
        padding: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .theme-expanded-view.active {
        display: flex;
    }

    .theme-expanded-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .theme-card {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 10px;
        padding: 14px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
        min-width: 0;
        overflow: hidden;
    }

    .theme-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f0f0f0;
        gap: 10px;
    }

    .theme-card-name {
        font-size: 1rem;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
        cursor: pointer;
    }

    .theme-card-name:hover {
        text-decoration: underline;
    }

    .theme-card-metrics {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
        line-height: 1.3;
    }

    .theme-card-change {
        font-size: 0.9rem;
        font-weight: 600;
        white-space: nowrap;
    }

    .theme-card-change.positive {
        color: #e71909;
    }

    .theme-card-change.negative {
        color: #0066cc;
    }

    .theme-card-value {
        font-size: 0.8rem;
        color: #666;
        white-space: nowrap;
    }

    .theme-card-sort-bar {
        display: flex;
        gap: 6px;
        margin-bottom: 8px;
    }

    .theme-card-sort-bar .card-sort-btn {
        flex: 1;
        padding: 5px 8px;
        font-size: 0.75rem;
        border: 1px solid #ddd;
        background: #f9f9f9;
        color: #666;
        border-radius: 5px;
        cursor: pointer;
        transition: all 0.15s;
    }

    .theme-card-sort-bar .card-sort-btn.active {
        background: #e71909;
        color: #fff;
        border-color: #e71909;
    }

    .theme-card-stocks {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .theme-stock-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.95rem;
        padding: 3px 0;
        gap: 10px;
    }

    .theme-stock-item .stock-icon {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background-color: #e0e0e0;
        background-size: cover;
        background-position: center;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        font-weight: 600;
        color: #666;
    }

    .theme-stock-item .stock-info-col {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
        gap: 1px;
    }

    .theme-stock-item .stock-name {
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        cursor: pointer;
    }

    .theme-stock-item .stock-name:hover {
        text-decoration: underline;
    }

    .theme-stock-item .stock-close {
        font-size: 0.8rem;
        color: #888;
    }

    .theme-stock-item .stock-metrics {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
        line-height: 1.3;
    }

    .theme-stock-item .stock-change {
        font-weight: 500;
        white-space: nowrap;
    }

    .theme-stock-item .stock-change.positive {
        color: #e71909;
    }

    .theme-stock-item .stock-change.negative {
        color: #0066cc;
    }

    .theme-stock-item .stock-value {
        font-size: 0.75rem;
        color: #666;
        white-space: nowrap;
    }

    /* 1등주 강조 */
    .theme-stock-item.first .stock-name {
        font-weight: 700;
    }

    .theme-stock-item.first .stock-change {
        font-weight: 700;
    }

    /* ── 종목 펼쳐보기 뷰 스타일 ── */
    .stock-expanded-view {
        display: none;
        flex-direction: column;
        padding: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .stock-expanded-view.active {
        display: flex;
    }

    .stock-expanded-view .desktop-only {
        display: block;
    }

    .stock-expanded-view .stock-expanded-grid.desktop-only {
        display: flex;
    }

    .stock-expanded-view .mobile-only {
        display: none !important;
    }

    .stock-expanded-header {
        font-size: 1rem;
        font-weight: 600;
        color: #333;
        padding: 10px 4px;
        border-bottom: 2px solid #e71909;
        margin-bottom: 12px;
    }

    .stock-expanded-grid {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 0 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .stock-column-headers {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 4px 12px 4px 206px;
        font-size: 0.75rem;
        color: #888;
        border-bottom: 1px solid #eee;
        margin-bottom: 4px;
    }

    .stock-column-headers.desktop-only {
        display: flex;
    }

    .stock-column-headers .col-metrics {
        display: flex;
        flex-direction: row;
        align-items: center;
        flex-shrink: 0;
    }

    .stock-column-headers .col-change {
        flex: 0 0 70px;
        text-align: right;
    }

    .stock-column-headers .col-value {
        flex: 0 0 100px;
        text-align: right;
    }

    .stock-column-headers .col-theme {
        flex: 1;
        text-align: right;
    }

    .stock-expanded-card {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 8px 12px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.06);
        display: flex;
        align-items: center;
        gap: 12px;
        cursor: pointer;
        transition: background 0.15s;
    }

    .stock-expanded-card:hover {
        background: #f9f9f9;
    }

    .stock-expanded-card .stock-rank {
        font-size: 0.85rem;
        font-weight: 700;
        color: #e71909;
        min-width: 24px;
        flex-shrink: 0;
    }

    .stock-expanded-card .stock-icon {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background-color: #e0e0e0;
        background-size: cover;
        background-position: center;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        font-weight: 600;
        color: #666;
    }

    .stock-expanded-card .stock-info {
        display: flex;
        flex-direction: column;
        width: 110px;
        flex-shrink: 0;
    }

    .stock-expanded-card .stock-name {
        font-size: 0.95rem;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .stock-expanded-card .stock-close {
        font-size: 0.8rem;
        color: #888;
    }

    .stock-expanded-card .stock-metrics {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
    }

    .stock-expanded-card .stock-change {
        font-size: 1rem;
        font-weight: 600;
        white-space: nowrap;
        width: 70px;
        text-align: right;
    }

    .stock-expanded-card .stock-change.positive {
        color: #e71909;
    }

    .stock-expanded-card .stock-change.negative {
        color: #0066cc;
    }

    .stock-expanded-card .stock-value {
        font-size: 1rem;
        color: #666;
        white-space: nowrap;
        width: 70px;
        text-align: right;
    }

    .stock-expanded-card .stock-theme {
        flex: 1;
        min-width: 0;
        font-size: 0.95rem;
        font-weight: 700;
        color: #555;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: right;
    }

    /* 종목 펼치기 토글 버튼 */
    #stockExpandToggle {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #e6e6e6;
        color: #333D4B;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        height: 32px;
        width: 32px;
        padding: 0;
        margin-left: 8px;
    }

    #stockExpandToggle:hover {
        background-color: #f0f0f0;
    }

    #stockExpandToggle:focus {
        outline: none;
        box-shadow: 0 0 0 2px #4fabff;
    }

    #stockExpandToggle svg {
        width: 16px;
        height: 16px;
    }

    #stockExpandToggle .icon-expand {
        display: block;
    }
    #stockExpandToggle .icon-collapse {
        display: none;
    }
    #stockExpandToggle.active .icon-expand {
        display: none;
    }
    #stockExpandToggle.active .icon-collapse {
        display: block;
    }
}

/* ── 모바일 전용 (≤1023px) ── */
@media (max-width: 1023px) {
    .container {
        width: 100%;
    }
    .panel {
        padding: 0;
    }

    #bar-container,
    #stock-bar-container {
        position: relative;
        height: 500px;
        margin-bottom: 20px;
        padding-left: 0;
        width: 100%;
    }

    .bar-item {
        padding-left: 0;
    }

    /* 토글 버튼 보이기 */
    .combo-title {
        display: none;
    }

    /*.mobile-toggle-bar {*/
    /*    display: flex;*/
    /*}*/
    .chart-theme-label {
        display: none;
    }

    .right-panel .chart-value {
        left: 10px;
    }

    .left-panel .chart-value {
        left: 10px;
    }
}

#stock-bar-container .chart-label .stock-name {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

#stock-bar-container .chart-label .stock-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* flex 아이템이 축소될 수 있도록 허용 */
}

@media (max-width: 1023px) {
    .combo-title {
        display: none;
    }

    /* 모바일에서 "테마 상위", "종목 상위" 텍스트 숨김 */
    .combo-bar {
        display: flex;
        gap: 5px;
        margin-bottom: 10px;
    }

    /* 래퍼 div는 껍데기 처리 */
    .combo-left,
    .combo-right,
    .combo-group {
        display: contents;
    }

    /* 버튼/셀렉트를 동일 규격으로 (축소) */
    #themeChartToggle,
    #themeMetricType,
    #themeTimeframe,
    #stockChartToggle,
    #stockEtfToggle,
    #stockMetricType,
    #stockTimeframe {
        flex: 1 1 0;
        min-width: 0;
        height: 25px;
        font-size: 0.7rem;
        font-family: 'Inter';
        border-radius: 4px;
    }

    /* ETF 토글은 글자만 들어가면 되므로 좁게 (셀렉트 자리 확보) */
    #stockEtfToggle {
        flex: 0 0 auto;
        padding: 0 10px;
        letter-spacing: 0;
    }

    /* 버튼 공통 스타일 (70% 축소) */
    #themeChartToggle,
    #stockChartToggle {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #e6e6e6;
        color: #333D4B;
        border: none;
        padding: 0 16px 0 16px; /* select padding과 맞춤 (축소) */
        cursor: pointer;
    }

    #themeChartToggle:hover,
    #stockChartToggle:hover {
        background-color: #f0f0f0;
    }

    #themeChartToggle:focus,
    #stockChartToggle:focus {
        outline: none;
        box-shadow: 0 0 0 2px #4fabff;
    }

    #themeChartToggle img,
    #stockChartToggle img {
        height: 12px;
        width: auto;
        display: block;
    }

    /* select 스타일 (70% 축소) */
    #themeMetricType,
    #themeTimeframe,
    #stockMetricType,
    #stockTimeframe {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-color: #e6e6e6;
        color: #333D4B;
        padding: 0 24px 0 8px; /* 버튼과 동일 padding (축소) */
        border: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 50 L70 100 L120 50' stroke='%23333' stroke-width='15' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 8px 8px;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    #themeMetricType:hover,
    #themeTimeframe:hover,
    #stockMetricType:hover,
    #stockTimeframe:hover {
        background-color: #f0f0f0;
    }

    #themeMetricType:focus,
    #themeTimeframe:focus,
    #stockMetricType:focus,
    #stockTimeframe:focus {
        outline: none;
        box-shadow: 0 0 0 2px #4fabff;
    }

    /* 토글 상태 전환 */
    #themeChartToggle .icon-bar,
    #stockChartToggle .icon-bar {
        display: none;
    }

    #themeChartToggle.active .icon-line,
    #stockChartToggle.active .icon-line {
        display: none;
    }

    #themeChartToggle.active .icon-bar,
    #stockChartToggle.active .icon-bar {
        display: inline-block;
    }

    .chart-toggle-btn {
        margin-left: 0;
    }

    /* ── 테마 확장/축소 토글 버튼 (모바일 전용, 70% 축소) ── */
    #themeExpandToggle {
        display: none; /* 기본 숨김, JS에서 테마 활성화 시 표시 */
        justify-content: center;
        align-items: center;
        background-color: #e6e6e6;
        color: #333D4B;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        height: 25px;
        font-size: 0.6rem;
    }

    #themeExpandToggle:hover {
        background-color: #f0f0f0;
    }

    #themeExpandToggle:focus {
        outline: none;
        box-shadow: 0 0 0 2px #4fabff;
    }

    #themeExpandToggle svg {
        width: 12px;
        height: 12px;
    }

    /* 기본: expand 아이콘 보이고, collapse 숨김 */
    #themeExpandToggle .icon-expand {
        display: block;
    }
    #themeExpandToggle .icon-collapse {
        display: none;
    }

    /* active 상태: collapse 아이콘 보이고, expand 숨김 */
    #themeExpandToggle.active .icon-expand {
        display: none;
    }
    #themeExpandToggle.active .icon-collapse {
        display: block;
    }

    /* 테마 모드 활성화 시 themeExpandToggle과 themeChartToggle이 반반 너비 */
    .left-panel.show-expand-toggle #themeExpandToggle {
        display: flex;
        flex: 0.5 1 0;
        min-width: 0;
    }

    .left-panel.show-expand-toggle #themeChartToggle {
        flex: 0.5 1 0;
    }

    /* 종목 모드 활성화 시 stockExpandToggle 표시 */
    #stockExpandToggle {
        display: none;
        justify-content: center;
        align-items: center;
        background-color: #e6e6e6;
        color: #333D4B;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        height: 25px;
        font-size: 0.6rem;
    }

    #stockExpandToggle svg {
        width: 12px;
        height: 12px;
    }

    #stockExpandToggle .icon-expand {
        display: block;
    }
    #stockExpandToggle .icon-collapse {
        display: none;
    }
    #stockExpandToggle.active .icon-expand {
        display: none;
    }
    #stockExpandToggle.active .icon-collapse {
        display: block;
    }

    .right-panel.show-stock-expand-toggle #stockExpandToggle {
        display: flex;
        flex: 0.5 1 0;
        min-width: 0;
    }

    .right-panel.show-stock-expand-toggle #stockChartToggle {
        flex: 0.5 1 0;
    }

    /* ── 펼쳐진 종목 뷰 스타일 (모바일) ── */
    .stock-expanded-view {
        display: none;
        flex-direction: column;
        padding: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .stock-expanded-view.active {
        display: flex;
    }

    .stock-expanded-view .desktop-only {
        display: none !important;
    }

    .stock-expanded-view .mobile-only {
        display: flex !important;
    }

    .stock-expanded-mobile-columns {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .stock-expanded-column {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    .stock-expanded-view .stock-expanded-header {
        font-size: 0.85rem;
        font-weight: 600;
        color: #333;
        padding: 6px 4px;
        margin-bottom: 4px;
    }

    .stock-expanded-view .stock-expanded-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .stock-expanded-view .stock-expanded-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 0 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .stock-expanded-view .stock-expanded-card {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 6px;
        padding: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        display: flex;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        min-width: 0;
        overflow: hidden;
    }

    .stock-expanded-view .stock-expanded-card .stock-rank {
        font-size: 0.75rem;
        font-weight: 700;
        color: #e71909;
        min-width: 10px;
        flex-shrink: 0;
    }

    .stock-expanded-view .stock-expanded-card .stock-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .stock-expanded-view .stock-expanded-card .stock-name {
        font-size: 0.8rem;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .stock-expanded-view .stock-expanded-card .stock-theme {
        font-size: 0.7rem;
        color: #888;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        cursor: pointer;
    }

    .stock-expanded-view .stock-expanded-card .stock-theme[data-theme-id]:hover {
        text-decoration: underline;
    }

    .stock-expanded-view .stock-expanded-card .stock-metrics {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
        line-height: 1.2;
    }

    .stock-expanded-view .stock-expanded-card .stock-change {
        font-size: 0.75rem;
        font-weight: 600;
    }

    .stock-expanded-view .stock-expanded-card .stock-change.positive {
        color: #e71909;
    }

    .stock-expanded-view .stock-expanded-card .stock-change.negative {
        color: #0066cc;
    }

    .stock-expanded-view .stock-expanded-card .stock-value {
        font-size: 0.7rem;
        color: #666;
    }

    /* ── 펼쳐진 테마 뷰 스타일 (모바일) ── */
    .theme-expanded-view {
        display: none;
        flex-direction: column;
        padding: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .theme-expanded-view.active {
        display: flex;
    }

    .expanded-sort-bar {
        display: flex;
        gap: 8px;
        margin-bottom: 12px;
        padding: 0 4px;
    }

    .expanded-sort-bar .sort-btn {
        flex: 1;
        padding: 8px 12px;
        font-size: 0.85rem;
        border: 1px solid #ddd;
        background: #f5f5f5;
        color: #333;
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .expanded-sort-bar .sort-btn.active {
        background: #e71909;
        color: #fff;
        border-color: #e71909;
    }

    .theme-expanded-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .theme-card {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        min-width: 0;
        overflow: hidden;
    }

    .theme-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #f0f0f0;
        gap: 8px;
    }

    .theme-card-name {
        font-size: 0.8rem;
        font-weight: 600;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
        cursor: pointer;
    }

    .theme-card-name:hover {
        text-decoration: underline;
    }

    .theme-card-metrics {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
        line-height: 1.2;
    }

    .theme-card-change {
        font-size: 0.7rem;
        font-weight: 600;
        white-space: nowrap;
    }

    .theme-card-change.positive {
        color: #e71909;
    }

    .theme-card-change.negative {
        color: #0066cc;
    }

    .theme-card-value {
        font-size: 0.65rem;
        color: #666;
        white-space: nowrap;
    }

    .theme-card-sort-bar {
        display: flex;
        gap: 4px;
        margin-bottom: 6px;
    }

    .theme-card-sort-bar .card-sort-btn {
        flex: 1;
        padding: 3px 6px;
        font-size: 0.6rem;
        border: 1px solid #ddd;
        background: #f9f9f9;
        color: #666;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.15s;
    }

    .theme-card-sort-bar .card-sort-btn.active {
        background: #e71909;
        color: #fff;
        border-color: #e71909;
    }

    .theme-card-stocks {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .theme-stock-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.7rem;
        padding: 2px 0;
        gap: 6px;
    }

    .theme-stock-item .stock-icon {
        display: none;
    }

    .theme-stock-item .stock-info-col {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
        gap: 1px;
    }

    .theme-stock-item .stock-name {
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        cursor: pointer;
    }

    .theme-stock-item .stock-name:hover {
        text-decoration: underline;
    }

    .theme-stock-item .stock-close {
        font-size: 0.6rem;
        color: #888;
    }

    .theme-stock-item .stock-metrics {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
        line-height: 1.2;
    }

    .theme-stock-item .stock-change {
        font-weight: 500;
        white-space: nowrap;
    }

    .theme-stock-item .stock-change.positive {
        color: #e71909;
    }

    .theme-stock-item .stock-change.negative {
        color: #0066cc;
    }

    .theme-stock-item .stock-value {
        font-size: 0.6rem;
        color: #666;
        white-space: nowrap;
    }

    /* 1등주 강조 */
    .theme-stock-item.first .stock-name {
        font-weight: 700;
    }

    .theme-stock-item.first .stock-change {
        font-weight: 700;
    }
}

/* ═══════════════════════════════════════════════════════════
   모바일 홈 — 아코디언 피드 (≤1023px)
   테마를 탭하면 그 자리에서 구성 종목이 펼쳐진다.
   PC 레이아웃(패널/레이스 차트)은 건드리지 않는다.
   ═══════════════════════════════════════════════════════════ */
.mh-wrap { display: none; }

@media (max-width: 1023px) {
    /* 기존 모바일 홈(뷰 토글 + 레이스 차트 + 패널)은 피드로 대체.
       JS 의존 없이 미디어쿼리로만 걸어 둔다 — 스크립트가 실패해도
       옛 화면과 새 화면이 같이 보이는 일이 없도록. */
    .view-toggle,
    .container > .panel { display: none !important; }

    /* 캘린더 아코디언의 날짜 헤더는 툴바의 날짜 버튼과 중복이다.
       헤더만 감추고 달력 본체는 그대로 둔다 (툴바 버튼이 이 헤더를
       대신 눌러 주므로 유료회원 확인·아이콘 전환이 전부 유지된다) */
    #calendar-container .accordion-header { display: none !important; }
    /* 헤더를 감추면 접힌 상태는 테두리만 남은 빈 상자가 된다 → 통째로 숨긴다.
       (숨겨진 헤더도 프로그램 클릭은 먹으므로 펼치기는 그대로 동작) */
    #calendar-container.collapsed { display: none !important; }
    #calendar-container.expanded { margin: 0 16px 12px; }

    .mh-wrap { display: block; padding: 0 8px 132px; }   /* 카드 폭 확보 */

    /* ── 툴바 ── */
    .mh-toolbar { display: flex; gap: 6px; padding: 10px 0 8px; }

    .mh-date-btn {
        flex: 1.7; min-width: 0; height: 36px;
        display: flex; align-items: center; justify-content: center; gap: 7px;
        padding: 0 10px; border: none; border-radius: 11px;
        background: #fff; box-shadow: 0 1px 3px rgba(27, 35, 48, .08);
        font-family: inherit; font-size: 13px; font-weight: 700; color: #1b2330;
        cursor: pointer; white-space: nowrap;
    }
    .mh-date-btn .mh-cal {
        width: 15px; height: 15px; flex: none;
        border: 1.6px solid #1b2330; border-top-width: 4px; border-radius: 4px;
    }

    .mh-sel {
        flex: 1; min-width: 0; height: 36px;
        appearance: none; -webkit-appearance: none; -moz-appearance: none;
        padding: 0 26px 0 10px; border: none; border-radius: 11px;
        background-color: #fff; box-shadow: 0 1px 3px rgba(27, 35, 48, .08);
        font-family: inherit; font-size: 12px; font-weight: 600; color: #5b6672;
        cursor: pointer;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 50 L70 100 L120 50' stroke='%235b6672' stroke-width='16' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-position: right 9px center;
        background-size: 10px 10px;
    }

    /* 막대/추이 전환 (알약 안에 아이콘 두 개) */
    .mh-seg {
        flex: none; display: flex; gap: 2px; padding: 3px; height: 36px;
        background: #fff; box-shadow: 0 1px 3px rgba(27, 35, 48, .08);
        border-radius: 11px;
    }
    .mh-seg button {
        width: 28px; height: 30px; flex: none;
        display: flex; align-items: center; justify-content: center;
        border: none; border-radius: 8px; background: transparent;
        color: #8a94a0; cursor: pointer; padding: 0;
    }
    .mh-seg button svg { width: 17px; height: 17px; }
    .mh-seg button svg path { fill: currentColor; }
    .mh-seg button svg[fill="none"] path { fill: none; }
    .mh-seg button.on { background: #1b2330; color: #fff; }

    /* 모두 펼치기 */
    .mh-icobtn {
        flex: none; width: 36px; height: 36px;
        display: flex; align-items: center; justify-content: center;
        border: none; border-radius: 11px;
        background: #fff; box-shadow: 0 1px 3px rgba(27, 35, 48, .08);
        color: #5b6672; cursor: pointer; padding: 0;
    }
    .mh-icobtn svg { width: 17px; height: 17px; }
    .mh-icobtn .ico-collapse { display: none; }
    .mh-icobtn.on { background: #1b2330; color: #fff; }
    .mh-icobtn:disabled { opacity: .35; cursor: default; }   /* 종목 탭엔 펼칠 게 없다 */
    .mh-icobtn.on .ico-expand { display: none; }
    .mh-icobtn.on .ico-collapse { display: block; }

    /* 두 줄 툴바 — 위: 날짜 + 막대/선 + 펼치기, 아래: 등락률 + 기간.
       다섯 칸을 한 줄에 넣으면 375px 에서 320px 남짓이라 글자가 잘린다. */
    .mh-toolbar { flex-direction: column; gap: 6px; }
    .mh-tbrow { display: flex; gap: 6px; }
    .mh-date-btn { flex: 1; justify-content: flex-start; padding: 0 12px; }

    /* ── 추이 차트 (선그래프 모드) ── */
    .mh-line-card {
        margin: 0 0 12px; padding: 13px 12px 11px;
        background: #fff; border: 1px solid #eef0f3; border-radius: 14px;
    }
    .mh-line-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 8px; }
    .mh-line-head span { font-size: 13.5px; font-weight: 800; color: #1b2330; }
    .mh-line-head em {
        margin-left: auto; font-style: normal;
        font-size: 11px; font-weight: 600; color: #a8b0ba;
        font-variant-numeric: tabular-nums;
    }
    .mh-line-svg { width: 100%; height: auto; display: block; overflow: visible; }
    .mh-line-svg line { stroke: #f0f2f5; stroke-width: 1; }
    .mh-line-svg text { font-size: 9px; font-weight: 600; fill: #a8b0ba; }
    .mh-line-svg polyline { fill: none; stroke-linejoin: round; stroke-linecap: round; }

    /* 범례 — 누르면 그 계열만 진하게 */
    /* 차트 아래로 여백이 남으니 좌우 스크롤 대신 줄바꿈으로 다 보여준다 */
    .mh-legend {
        display: flex; flex-wrap: wrap; gap: 6px;
        margin: 10px 0 0;
    }
    .mh-lg {
        flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px;
        height: 30px; padding: 0 11px;
        border: 1px solid #eef0f3; border-radius: 999px; background: #fff;
        font-family: inherit; font-size: 11.5px; font-weight: 700; color: #3f4a58;
        cursor: pointer;
    }
    .mh-lg i { width: 8px; height: 8px; flex: none; border-radius: 50%; }
    /* 이름이 길면 칩 안에서 줄이고, 수치는 그대로 둔다 */
    .mh-lg > span {
        min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-lg b { flex: none; font-variant-numeric: tabular-nums; }
    .mh-lg b.up { color: #e71909; }
    .mh-lg b.down { color: #115bcb; }
    .mh-lg.on { background: #1b2330; border-color: #1b2330; color: #fff; }
    .mh-lg.on b, .mh-lg.on b.up, .mh-lg.on b.down { color: #fff; }

    /* ── 펼쳐보기: 테마 2열 카드 ── */
    .mh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
    .mh-gcard {
        min-width: 0; padding: 9px 8px; background: #fff;
        border: 1px solid #eef0f3; border-radius: 12px;
        display: flex; flex-direction: column; gap: 8px;
    }
    .mh-gtop { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
    .mh-gname {
        font-size: 12.5px; font-weight: 800; letter-spacing: -.02em; color: #1b2330;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-gnums { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
    .mh-gnums b { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
    .mh-gnums b.up { color: #e71909; }
    .mh-gnums b.down { color: #115bcb; }
    .mh-gnums i {
        font-style: normal; font-size: 10px; font-weight: 600; color: #a8b0ba;
        font-variant-numeric: tabular-nums;
    }
    .mh-gchips { display: flex; gap: 4px; }
    .mh-gchips button {
        flex: 1; min-width: 0; height: 22px; padding: 0;
        border: 1px solid #e6e8ec; border-radius: 999px; background: #fff;
        color: #8a94a0; font-family: inherit; font-size: 9.5px; font-weight: 700;
        cursor: pointer;
    }
    .mh-gchips button.on { background: #e71909; border-color: #e71909; color: #fff; }
    .mh-glist { display: flex; flex-direction: column; }
    .mh-grow {
        display: flex; align-items: center; gap: 4px;
        padding: 6px 0; border-bottom: 1px solid #f5f6f8; cursor: pointer;
    }
    .mh-grow:last-child { border-bottom: 0; }
    .mh-gini {
        width: 18px; height: 18px; flex: none; border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        font-size: 9px; font-weight: 700; color: #4a5460; overflow: hidden;
        background-size: cover; background-position: center; background-repeat: no-repeat;
    }
    .mh-gini.img { background-color: #f0f1f4; }
    .mh-gs { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
    /* 2열 카드는 이름 칸이 좁다 — 자르지 말고 두 줄까지 접어 보여준다
       (한글은 단어 단위, 잘리면 무슨 종목인지 알 수가 없다) */
    .mh-gs b {
        font-size: 11px; font-weight: 700; color: #1b2330;
        line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .mh-gs i {
        font-style: normal; font-size: 9.5px; color: #a8b0ba;
        font-variant-numeric: tabular-nums;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-gv {
        flex: none; display: flex; flex-direction: column;
        align-items: flex-end; line-height: 1.25;
    }
    .mh-gv { white-space: nowrap; }
    .mh-gv b { font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
    .mh-gv b.up { color: #e71909; }
    .mh-gv b.down { color: #115bcb; }
    .mh-gv i {
        font-style: normal; font-size: 9px; font-weight: 600; color: #a8b0ba;
        font-variant-numeric: tabular-nums;
    }

    /* ── 펼쳐보기: 종목 2열 ── */
    .mh-egrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; }
    .mh-ecol { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
    .mh-ehead {
        font-size: 11.5px; font-weight: 800; color: #1b2330;
        border-bottom: 2px solid #e71909; padding-bottom: 5px; margin-bottom: 2px;
    }
    .mh-ehead.v { border-bottom-color: #1b2330; }
    .mh-erow {
        display: flex; flex-direction: column; gap: 2px;
        padding: 7px 8px; border: 1px solid #eef0f3; border-radius: 9px; cursor: pointer;
    }
    .mh-etop { display: flex; align-items: center; gap: 5px; min-width: 0; }
    .mh-etop i {
        width: 12px; flex: none; font-style: normal;
        font-size: 10px; font-weight: 700; color: #c9cfd6;
        font-variant-numeric: tabular-nums;
    }
    .mh-etop b {
        flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; color: #1b2330;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-ebot {
        display: flex; align-items: baseline; justify-content: space-between;
        gap: 6px; padding-left: 17px;
    }
    .mh-ebot em {
        min-width: 0; font-style: normal; font-size: 9.5px; font-weight: 600; color: #a8b0ba;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }
    /* 거래대금 열은 금액이 주인공 — 줄이지 않는다 */
    .mh-ebot em.v { flex: none; font-size: 10.5px; color: #5b6672; }
    .mh-ebot b { flex: none; font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
    .mh-ebot b.up { color: #e71909; }
    .mh-ebot b.down { color: #115bcb; }

    /* 잠긴 버튼 (펼쳐보기 중 추이) */
    .mh-seg button:disabled { opacity: .3; cursor: default; }

    /* ── 피드 공통 ── */
    .mh-feed { display: flex; flex-direction: column; gap: 8px; }
    .mh-empty { padding: 34px 0; text-align: center; color: #a8b0ba; font-size: 13px; }

    .mh-card {
        background: #fff; border: 1px solid #eef0f3; border-radius: 14px;
        overflow: hidden;
    }
    .mh-card.open { background: #fff8f7; border-color: #f6cdc8; }

    .mh-head {
        width: 100%; display: flex; align-items: center; gap: 9px;
        padding: 12px; border: none; background: transparent;
        font-family: inherit; text-align: left; cursor: pointer;
    }
    .mh-rank {
        width: 14px; flex: none; font-size: 12px; font-weight: 700;
        color: #a8b0ba; font-variant-numeric: tabular-nums;
    }
    /* 테마/종목 로고. 이미지가 없으면 이니셜 + 배경색으로 대체된다 */
    .mh-ini, .mh-sini {
        flex: none; border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        color: #4a5460; font-weight: 700; overflow: hidden;
        background-size: cover; background-position: center; background-repeat: no-repeat;
    }
    .mh-ini { width: 28px; height: 28px; font-size: 11px; }
    .mh-sini { width: 20px; height: 20px; font-size: 9px; }
    .mh-ini.img, .mh-sini.img { background-color: #f0f1f4; }

    .mh-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
    .mh-name { font-size: 14px; font-weight: 700; color: #1b2330; }
    /* 테마명은 자르지 않고 줄바꿈한다 — 한글은 단어 단위(keep-all),
       한 단어가 너무 길면 그때만 아무 데서나 끊는다 */
    .mh-card .mh-name {
        line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere;
    }
    /* 종목 카드는 코드·테마가 아랫줄에 있어 한 줄 유지 */
    .mh-scard .mh-name {
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-sub {
        font-size: 10.5px; color: #a8b0ba; font-variant-numeric: tabular-nums;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-bar { height: 5px; border-radius: 99px; background: #eff1f4; overflow: hidden; }
    .mh-bar > span { display: block; height: 100%; border-radius: 99px; }
    .mh-bar > span.up { background: #e71909; }
    .mh-bar > span.down { background: #115bcb; }

    .mh-nums {
        flex: none; display: flex; flex-direction: column; align-items: flex-end;
        line-height: 1.3;
    }
    .mh-pct { font-size: 14.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
    .mh-pct.up { color: #e71909; }
    .mh-pct.down { color: #115bcb; }
    .mh-amt {
        font-size: 11px; font-weight: 600; color: #8a94a0;
        font-variant-numeric: tabular-nums;
    }
    .mh-caret { flex: none; width: 14px; text-align: center; font-size: 11px; color: #a8b0ba; }

    /* ── 펼침: 구성 종목 ── */
    .mh-body { padding: 0 12px 12px; }
    .mh-chips { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
    .mh-chips button {
        border: 1px solid #e6e8ec; border-radius: 99px; padding: 4px 9px;
        background: #fff; color: #8a94a0;
        font-family: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
    }
    .mh-chips button.on { background: #e71909; border-color: #e71909; color: #fff; font-weight: 700; }
    .mh-updown { margin-left: auto; font-size: 11px; font-weight: 600; color: #8a94a0; }

    .mh-stocks {
        background: #fff; border: 1px solid #f0e4e2; border-radius: 11px; overflow: hidden;
    }
    .mh-srow {
        display: flex; align-items: center; gap: 7px;
        padding: 9px 10px; border-bottom: 1px solid #f5f6f8; cursor: pointer;
    }
    .mh-srow:last-child { border-bottom: none; }
    .mh-srow:active { background: #fafbfc; }
    .mh-sno {
        width: 11px; flex: none; font-size: 11px; font-weight: 700;
        color: #c9cfd6; font-variant-numeric: tabular-nums;
    }
    .mh-sname { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
    .mh-sname b {
        font-size: 13px; font-weight: 600; color: #1b2330;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .mh-sname i {
        font-style: normal; font-size: 10.5px; color: #a8b0ba;
        font-variant-numeric: tabular-nums;
    }
    /* 고정폭 3열(현재가·거래대금·등락률)로 두면 375px 에서 종목명 자리가
       90px 밖에 안 남아 이름이 잘린다 → 오른쪽을 2줄 한 덩어리로 */
    .mh-snums {
        flex: none; display: flex; flex-direction: column; align-items: flex-end;
        line-height: 1.3;
    }
    .mh-spct { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
    .mh-spa {
        font-size: 10.5px; font-weight: 600; color: #a8b0ba;
        font-variant-numeric: tabular-nums; white-space: nowrap;
    }
    .mh-spct.up { color: #e71909; }
    .mh-spct.down { color: #115bcb; }

    /* ── 더 보기 / 접기 (펼친 테마의 종목 목록) ── */
    .mh-more {
        width: 100%;
        margin-top: 6px;
        padding: 9px 0;
        display: flex; align-items: center; justify-content: center; gap: 5px;
        border: 1px solid #eef0f3; border-radius: 12px;
        background: #fff; color: #5b6672;
        font-family: inherit; font-size: 12.5px; font-weight: 700;
        cursor: pointer;
    }
    .mh-more:active { background: #fafbfc; }
    .mh-more b { color: #e71909; font-weight: 800; }
    .mh-more i { font-style: normal; font-size: 10px; color: #a8b0ba; }

    /* ── 종목 기준 카드 ── */
    .mh-scard {
        display: flex; align-items: center; gap: 9px; padding: 12px;
        background: #fff; border: 1px solid #eef0f3; border-radius: 14px; cursor: pointer;
    }
    .mh-scard:active { background: #fafbfc; }

    /* ═══════════════════════════════════════════════════
       날짜 선택 바텀시트
       ═══════════════════════════════════════════════════ */
    .cal-sheet { position: fixed; inset: 0; z-index: 3500; }
    body.cal-sheet-open { overflow: hidden; }
    .cal-sheet.hidden { display: none; }
    .cal-sheet-dim { position: absolute; inset: 0; background: rgba(11, 14, 19, .4); }

    .cal-sheet-body {
        position: absolute; left: 0; right: 0; bottom: 0;
        max-height: 92vh;
        display: flex; flex-direction: column;
        padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -10px 40px rgba(11, 14, 19, .2);
    }
    .cal-grab {
        width: 38px; height: 4px; margin: 0 auto 12px;
        border-radius: 99px; background: #e0e3e8;
    }

    /* 월 이동 */
    .cal-nav {
        display: flex; align-items: center; justify-content: space-between;
        margin-bottom: 14px;
    }
    .cal-nav span {
        font-size: 15.5px; font-weight: 800; letter-spacing: -.02em; color: #1b2330;
    }
    .cal-nav button {
        width: 32px; height: 32px; border: none; border-radius: 9px;
        background: #f4f5f7; color: #5b6672;
        font-family: inherit; font-size: 15px; cursor: pointer;
    }
    .cal-nav button:disabled { color: #d5d9de; cursor: default; }

    /* 요일 */
    .cal-wd { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
    .cal-wd span {
        text-align: center; font-size: 11px; font-weight: 700; color: #8a94a0;
    }
    .cal-wd span.sun { color: #e0736a; }
    .cal-wd span.sat { color: #7fa4d8; }

    /* 날짜 그리드 */
    .cal-grid {
        display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px;
        overflow-y: auto;
    }
    .cal-cell { height: 42px; display: flex; align-items: center; justify-content: center; }
    .cal-day {
        width: 34px; height: 34px; border: none; border-radius: 50%;
        background: none; cursor: pointer; padding: 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px;
        font-family: inherit; font-size: 13px; font-weight: 600; color: #1b2330;
        font-variant-numeric: tabular-nums; line-height: 1;
    }
    .cal-day.weekend { color: #c0c6cd; }
    .cal-day.future { color: #c9cfd6; }
    .cal-day:disabled { cursor: default; }
    /* 데이터가 있는 날 표식 */
    .cal-day i { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
    .cal-day.has i { background: #f3b7b1; }
    .cal-day.on { background: #e71909; color: #fff; font-weight: 800; }
    .cal-day.on i { background: rgba(255, 255, 255, .7); }

    .cal-div { height: 1px; background: #eef0f3; margin: 12px 0; flex: none; }

    /* 그날 상위 테마 */
    .cal-top-head {
        display: flex; align-items: center; justify-content: space-between;
        margin-bottom: 9px;
    }
    .cal-top-head #cal-top-title { font-size: 13.5px; font-weight: 800; color: #1b2330; }
    .cal-top-sub { font-size: 11px; font-weight: 600; color: #8a94a0; }

    .cal-top { display: flex; flex-direction: column; gap: 6px; }
    .cal-trow {
        display: flex; align-items: center; gap: 9px;
        padding: 10px 12px; background: #f7f8fa; border-radius: 11px;
    }
    .cal-medal {
        width: 20px; height: 20px; flex: none; border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        color: #fff; font-size: 11px; font-weight: 800;
    }
    .cal-tname {
        flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; color: #1b2330;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .cal-tpct {
        flex: none; font-size: 13.5px; font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .cal-tpct.up { color: #e71909; }
    .cal-tpct.down { color: #115bcb; }
    .cal-empty { padding: 18px 0; text-align: center; font-size: 12.5px; color: #a8b0ba; }

    .cal-apply {
        margin-top: 14px; height: 46px; flex: none;
        border: none; border-radius: 13px;
        background: #e71909; color: #fff;
        font-family: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
    }
    .cal-apply:disabled { background: #e5e8eb; color: #a8b0ba; cursor: default; }

    /* ── 플로팅 탭 ── */
    .mh-tabs {
        position: fixed; left: 12px; right: 12px; bottom: 80px; z-index: 30;
        display: flex; gap: 4px; padding: 4px;
        background: rgba(255, 255, 255, .92);
        -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
        border: 1px solid #e6e8ec; border-radius: 999px;
        box-shadow: 0 6px 20px rgba(27, 35, 48, .12);
    }
    .mh-tabs button {
        flex: 1; height: 38px; border: none; border-radius: 999px;
        background: transparent; color: #8a94a0;
        font-family: inherit; font-size: 13px; font-weight: 700;
        cursor: pointer; transition: background-color .18s, color .18s;
    }
    .mh-tabs button.on { background: #1b2330; color: #fff; }
}
