/* ==========================================================================
   大盘数据（排行榜页顶部）
   折叠时是一条横向滚动的行情条，展开后是盘面统计 + 指数卡片，
   右上角可以自定义行情（增删 + 拖动排序）。
   ========================================================================== */

body.no-scroll { overflow: hidden; }

.mkbar {
    background: var(--bg-soft);
    border-radius: 14px;
    padding: 10px 12px;
    margin: 0 0 12px;
    /* 行情条：PC 一排 3 条，H5 一排 1 条 */
    --mk-cols: 3;
    --mk-rows: 1;
}

.mkbar-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
}

/* ------------------------------ 折叠条（上下滚动） ------------------------------ */

.mk-marquee {
    flex: 1 1 auto;
    min-width: 0;
    /* 一屏显示几行行情 */
    height: calc(28px * var(--mk-rows, 1));
    overflow: hidden;
    /* 上下两端渐隐，滚进滚出的内容不会硬邦邦地断掉 */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 5px,
                        #000 calc(100% - 5px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 5px,
                        #000 calc(100% - 5px), transparent 100%);
}

.mk-track {
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: mk-scroll-up var(--mk-dur, 40s) linear infinite;
}

/* 每一组行情：一排 --mk-cols 条 */
.mk-run {
    display: grid;
    grid-template-columns: repeat(var(--mk-cols, 3), minmax(0, 1fr));
    column-gap: 18px;
}

/* 兜底：整份行情匀速滚一遍。
   实际用的是 market.js 按行数动态生成的 mk-scroll-up 关键帧
   （每行停 5 秒再滚到下一行），两份内容首尾相接正好无缝。 */
@keyframes mk-scroll-up {
    from { transform: translateY(0); }
    to   { transform: translateY(-50%); }
}

.mk-marquee:hover .mk-track { animation-play-state: paused; }

/* 展开后行情条让位给指数卡片 */
.mkbar.expanded .mk-marquee { display: none; }

.mk-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    height: 28px;
    line-height: 28px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
}

.mk-item .mk-nm {
    flex: 0 0 auto;
    color: var(--text-2);
}

.mk-item b { font-weight: 600; color: var(--text); }
.mk-item b.up { color: var(--up); }
.mk-item b.down { color: var(--down); }
.mk-item .up { color: var(--up); }
.mk-item .down { color: var(--down); }
.mk-item .flat { color: var(--text-3); }
.mk-it-turnover { color: var(--text); font-weight: 600; }
.mk-it-err { color: var(--danger); }
.mk-sep { color: var(--text-3); margin: 0 3px; }

/* 折叠条右边的两个按钮 */
.mk-cfg {
    flex: 0 0 auto;
    border: 0;
    background: var(--bg-card);
    color: var(--blue);
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    padding: 5px 11px;
    border-radius: 980px;
    cursor: pointer;
    white-space: nowrap;
}

.mk-cfg[hidden] { display: none; }
.mk-cfg:active { transform: scale(0.96); }

.mk-fold {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-2);
    cursor: pointer;
}

.mk-fold svg { width: 15px; height: 15px; transition: transform 0.22s ease; }
.mk-fold.up svg { transform: rotate(180deg); }
.mk-fold:active { transform: scale(0.92); }

/* ------------------------------ 展开区 ------------------------------ */

.mkbar-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--sep);
}

/* 统计区在上、行情条在下，中间留一点呼吸 */
.mkbar-top { margin-top: 2px; }

/* 盘面统计：固定展示在顶部，纯文字，不做成卡片（省地方） */
.mk-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 18px;
    margin-bottom: 8px;
}

.mk-stats:empty { display: none; }

.mk-stat {
    font-size: 13px;
    line-height: 20px;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: var(--text-2);
    white-space: nowrap;
}

.mk-stat b {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.mk-stat b.up { color: var(--up); }
.mk-stat b.down { color: var(--down); }
.mk-stat b.flat { color: var(--text-3); }

.mk-stat i.mk-sep {
    font-style: normal;
    color: var(--text-3);
    margin: 0 3px;
}

.mk-stat-loading { color: var(--text-3); }

/* 成交额这一行最长，窄屏要能折行，不然会被卡片裁掉。
   每一小段单独 nowrap，整行才有「三市成交额」/「昨」/「预测成交」三个断点。 */
.mk-stats .mk-stat-turn {
    color: var(--text);
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 8px;
}

.mk-stats .mk-nb {
    display: inline-block;
    white-space: nowrap;
}

/* 「三市成交额」可点开历史记录：蓝色加粗，点哪儿都提示得出来 */
.mk-stats .mk-link {
    font: inherit;
    font-weight: 600;
    letter-spacing: inherit;
    color: var(--blue);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    border-bottom: 1px solid transparent;
}

.mk-stats .mk-link b {
    color: var(--blue);
    font-weight: 600;
}

.mk-stats .mk-link:hover { border-bottom-color: var(--blue); }
.mk-stats .mk-link:active { opacity: 0.55; }

/* ------------------------------ 成交额历史弹层 ------------------------------ */

.mk-turn-note {
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: 10px;
}

.mk-turn-table {
    border-top: 1px solid var(--sep);
}

.mk-turn-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.25fr 1.1fr;
    gap: 4px;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid var(--sep);
    font-size: 13px;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}

.mk-turn-row > span { text-align: right; }
.mk-turn-row > span:first-child { text-align: left; }

.mk-turn-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    border-bottom-color: var(--sep-strong);
}

.mk-turn-date {
    color: var(--text);
    font-weight: 500;
}

.mk-turn-sum {
    color: var(--text);
    font-weight: 600;
}

.mk-turn-pager {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.mk-pg {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 980px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.mk-pg:active { transform: scale(0.96); }
.mk-pg[disabled] { opacity: 0.35; cursor: default; }
.mk-pg[disabled]:active { transform: none; }

.mk-pg-info {
    flex: 1 1 auto;
    text-align: center;
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.mk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 10px;
}

.mk-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 11px 13px;
}

.mk-card-name {
    font-size: 13px;
    line-height: 19px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mk-card-val {
    font-size: 21px;
    line-height: 1.24;
    font-weight: 600;
    letter-spacing: -0.4px;
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

.mk-card.up .mk-card-val,
.mk-card.up .mk-card-chg { color: var(--up); }
.mk-card.down .mk-card-val,
.mk-card.down .mk-card-chg { color: var(--down); }
.mk-card.flat .mk-card-val { color: var(--text); }
.mk-card.flat .mk-card-chg { color: var(--text-3); }

.mk-card-chg {
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.mk-empty {
    font-size: 13px;
    color: var(--text-3);
    padding: 8px 0;
}

/* ------------------------------ 自定义行情弹层 ------------------------------ */

.mk-mask {
    z-index: 92;
    align-items: center;
}

.mk-sheet {
    width: 100%;
    max-width: 560px;
    margin: 0 16px;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-radius: 18px;
    padding: 18px 18px 16px;
    animation: sheet-up 0.24s ease-out;
}

.mk-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.mk-sheet-title {
    flex: 1 1 auto;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.4px;
    line-height: 1.19;
}

.mk-sheet-close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--text-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.mk-sheet-close:active { transform: scale(0.92); }

.mk-sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mk-sec {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 8px;
}

.mk-sec-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.mk-sec-tip {
    font-size: 12px;
    color: var(--text-3);
}

.mk-group {
    font-size: 12px;
    color: var(--text-3);
    margin: 14px 0 8px;
}

.mk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mk-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 980px;
    padding: 7px 13px;
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    background: var(--bg-soft);
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.mk-chip-add:active { transform: scale(0.96); }

.mk-chip-on {
    background: var(--blue-soft);
    color: var(--blue);
    cursor: grab;
}

.mk-chip-on.dragging {
    cursor: grabbing;
    box-shadow: var(--shadow-pop);
    opacity: 0.95;
}

.mk-chip-ph {
    background: transparent;
    border: 1px dashed var(--sep-strong);
    cursor: default;
}

.mk-chip-name { font-weight: 500; }

.mk-chip-val {
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.mk-chip-val.up { color: var(--up); }
.mk-chip-val.down { color: var(--down); }

.mk-chip-plus {
    font-weight: 600;
    font-size: 14px;
}

.mk-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: -4px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-3);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.mk-chip-x:active { transform: scale(0.9); }

.mk-sheet-foot {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.mk-sheet-foot .btn { flex: 1 1 0; height: 44px; border-radius: 8px; font-size: 15px; }

/* 窄屏：指数卡片两列，统计两列 */
@media (max-width: 560px) {
    .mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mk-card-val { font-size: 19px; }
    .mk-item { font-size: 12px; gap: 8px; }
    /* H5 一行只留一条，PC 一行三条 */
    .mkbar { --mk-cols: 1; }
    .mk-marquee { height: calc(28px * var(--mk-rows, 1)); }
    .mk-stat { font-size: 12px; }
    .mk-stats { gap: 2px 14px; }
    .mk-turn-row { font-size: 12px; grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr 1.05fr; }
    .mk-turn-head { font-size: 11px; }
    .mk-pg { height: 30px; padding: 0 12px; font-size: 12px; }
    .mk-pg-info { font-size: 11px; }
    /* 展开后统计和卡片都有了，窄屏就不占位置显示行情条了 */
    .mkbar.expanded .mk-marquee { display: none; }
}

/* 尊重「减弱动效」设置：不滚动 */
@media (prefers-reduced-motion: reduce) {
    .mk-track { animation: none; }
    .mk-run:last-child { display: none; }
}
