/* ==========================================================================
   公共组件：hero / 搜索 / 按钮 / 分段控件 / 卡片 / 弹层 / 登录
   各栏目共用，改这里会影响所有页面
   ========================================================================== */

/* hidden 属性优先级最高：组件自带 display:flex 之类的规则会把 [hidden] 顶掉，
   JS 里 el.hidden = true 就失效了（折叠条、分组按钮都踩过这个坑）。 */
[hidden] { display: none !important; }

/* ============================ 回到顶部 ============================ */

/* 列表滚下去以后才出现的悬浮箭头 */
.totop {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
    z-index: 60;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bg-elevated);
    color: var(--blue);
    box-shadow: var(--shadow-pop);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.totop svg { width: 21px; height: 21px; }

.totop.show {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.totop:active { transform: scale(0.94); }

/* 暗色下 #0071e3 太暗，细箭头看不清，用苹果深色模式的蓝 */
[data-theme="dark"] .totop { color: #2997ff; }

/* ============================ 头像浮层（用户信息） ============================ */

.usermenu {
    position: fixed;
    z-index: 95;
    width: 292px;
    max-width: calc(100vw - 24px);
    padding: 16px;
    border-radius: 16px;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-pop);
    animation: um-in 0.16s ease-out;
}

.usermenu[hidden] { display: none; }

@keyframes um-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.um-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--sep);
}

/* 浮层里的头像：是个按钮，点一下就能上传新头像 */
.um-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    border: 0;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.um-avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}
.um-avatar > svg { width: 22px; height: 22px; }

/* 右下角「改头像」徽标：细描边，不叠重阴影 */
.um-avatar-edit {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-elevated);
    pointer-events: none;
}
.um-avatar-edit > svg { width: 11px; height: 11px; }

.um-avatar:active { opacity: 0.8; }

.um-id { flex: 1 1 auto; min-width: 0; }

.um-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.um-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
    letter-spacing: -0.1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.um-list { margin: 0; }

.um-list .profile-row { padding: 9px 0; }

.um-list .profile-row dt { font-size: 13px; }

.um-list .profile-row dd { font-size: 13px; }

.um-wallet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.um-wallet-item {
    background: var(--bg-soft);
    border-radius: 10px;
    padding: 9px 11px;
}

.um-wallet-label {
    font-size: 11px;
    color: var(--text-3);
    letter-spacing: -0.1px;
}

.um-wallet-value {
    margin-top: 1px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}

.um-acts {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.um-acts .btn { flex: 1 1 0; min-width: 0; }

/* ============================ Hero ============================ */

.hero {
    margin: 0 -16px;
    padding: 16px 22px 14px;
    background: #000000;
    color: var(--text-inv);
}

[data-theme="dark"] .hero { background: var(--bg-hero); }

.hero-slim { padding: 14px 22px 12px; }

.hero-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: 3px;
}

.hero-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.14;
}

.hero-sub {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-inv-2);
    letter-spacing: -0.2px;
}

.hero-stats {
    margin-top: 11px;
    display: flex;
    gap: 20px;
}

.stat { display: flex; flex-direction: column; gap: 2px; }

.stat-v {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.4px;
    font-variant-numeric: tabular-nums;
}

.hero .stat-v.up { color: #ff6961; }
.hero .stat-v.down { color: #4ade80; }

.stat-k {
    font-size: 11px;
    color: var(--text-inv-3);
}

/* ---- 估值榜：统计和标题并排，hero 高度和别的栏目一致 ---- */

.hero-headrow {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.hero-split .hero-stats {
    margin-top: 0;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* 数值和说明文字并排（默认 .stat 是上下排的） */
.hero-split .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 3px;
}

.hero-split .stat-v { font-size: 13px; line-height: 1.15; }
.hero-split .stat-k { font-size: 10px; line-height: 1.15; }

/* ============================ 工具栏 ============================ */

.toolbar {
    display: flex;
    gap: 10px;
    margin: 18px 0 14px;
}

.search {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
}

[data-theme="dark"] .search { background: var(--bg-soft); }

.search-ico {
    width: 18px;
    height: 18px;
    color: var(--text-3);
    flex: 0 0 auto;
}

.search input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    outline: none;
    font-size: 16px;
    letter-spacing: -0.2px;
}

.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }

.btn {
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 980px;
    /* 底色和文字都要跟随主题。
       不写的话浏览器会给按钮套默认样式（浅灰底 + buttontext），
       深色模式下文字继承了页面的浅色，就成了「白底白字」，整排按钮都看不见。 */
    background: var(--bg-soft);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.2px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, opacity 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }
.btn:hover { opacity: 0.85; }

/* 排序切换按钮：点一下切一种（默认 / 涨幅升 / 涨幅降） */
.btn-sort {
    flex: 0 0 auto;
    min-width: 76px;
    font-variant-numeric: tabular-nums;
}

.btn-primary { background: var(--blue); color: #fff; flex: 0 0 auto; }
.btn-primary:hover { background: var(--blue-hover); }

.btn-ghost {
    background: var(--bg-soft);
    color: var(--text);
    height: 42px;
    flex: 0 0 auto;
}

/* 满宽按钮单独用这个类：放在 flex 行里时不该抢整行宽度 */
.btn-block { width: 100%; }

.btn-ghost:hover { opacity: 0.85; }
.btn[disabled] { opacity: 0.45; cursor: default; }

/* 图标按钮：只有图标、没有文字（垃圾桶等） */
.btn-icon {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, transform 0.12s;
}

.btn-icon svg { width: 18px; height: 18px; display: block; }
.btn-icon:hover { color: var(--text); background: var(--bg-soft); }
.btn-icon:active { transform: scale(0.9); }

/* 破坏性操作（移除 / 删除）—— 红色垃圾桶 */
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { color: var(--danger); background: var(--danger-soft); }

/* 破坏性主按钮（确认弹层里的「移出 / 删除」） */
.btn-danger-solid { background: var(--danger); color: #fff; flex: 0 0 auto; }
.btn-danger-solid:hover { background: var(--danger); opacity: 0.88; }

/* ============================ 分段控件 ============================ */

.seg {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: 11px;
    background: var(--bg-soft);
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
}

.seg::-webkit-scrollbar { display: none; }
.seg-scroll .seg-btn { flex: 0 0 auto; }

.seg-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(0, 0, 0, 0.62);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.2px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.seg-btn.active {
    background: var(--bg-elevated);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-pop);
}

/* 分组名后面的数量：小一号、淡一点，不抢分组名的视觉重心 */
.seg-count {
    margin-left: 4px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.55;
    vertical-align: 1px;
}

.seg-inline { margin-bottom: 0; flex: 0 0 auto; max-width: 60%; }
.seg-inline .seg-btn { padding: 0 12px; }

/* ============================ 列表卡片 ============================ */

.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .card { background: var(--bg-card); }

.card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.card-main { flex: 1 1 auto; min-width: 0; }

.card-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip-type {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    background: var(--bg-soft);
    border-radius: 5px;
    padding: 1px 5px;
}

.card-sub {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-3);
    letter-spacing: -0.05px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-side {
    flex: 0 0 auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-val {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
    font-variant-numeric: tabular-nums;
}

.chg {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.star {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.2s, transform 0.15s;
}

.star:hover { color: var(--blue); }
.star:active { transform: scale(0.88); }
.star.on { color: var(--blue); }


.empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--text-3);
    font-size: 14px;
    background: var(--bg-soft);
    border-radius: 14px;
}

.loadmore { margin-top: 14px; }
.loadmore[hidden] { display: none; }

.profile {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-soft);
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.3px;
    flex: 0 0 auto;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar svg { width: 26px; height: 26px; }

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

.profile-name {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.4px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-sub {
    margin-top: 3px;
    font-size: 13px;
    color: var(--text-3);
    letter-spacing: -0.2px;
}

/* 资料明细表 */
.profile-list { margin: 0; }

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-top: 1px solid var(--sep);
}

.profile-row dt {
    flex: 0 0 auto;
    font-size: 14px;
    color: var(--text-3);
    letter-spacing: -0.2px;
}

.profile-row dd {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
    font-size: 14px;
    color: var(--text);
    letter-spacing: -0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-row dd.mono { font-variant-numeric: tabular-nums; letter-spacing: 0; }

.profile-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.profile-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 980px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.1px;
    white-space: nowrap;
}

.profile-badge.muted { background: var(--bg-soft); color: var(--text-3); }

.profile-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.profile-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--down);
    flex: 0 0 auto;
}

.profile-status.off::before { background: var(--text-3); }

/* 钱包余额（算力 / 积分） */
.profile-wallet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.profile-wallet-item {
    background: var(--bg-soft);
    border-radius: 12px;
    padding: 12px 14px;
}

.profile-wallet-label {
    font-size: 12px;
    color: var(--text-3);
    letter-spacing: -0.1px;
}

.profile-wallet-value {
    margin-top: 2px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.4px;
    font-variant-numeric: tabular-nums;
}

.mask {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--bg-scrim);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.mask[hidden] { display: none; }

/* 确认弹层要盖在页面内任何遮罩（含分组管理面板）之上 */
#confirmMask { z-index: 94; }

/* 居中弹层：叠在别的弹层（分组管理面板）上面时用，
   底部弹层会把下面的列表盖掉一半，居中卡片看着更清楚 */
.mask.mask-center {
    align-items: center;
}

.mask.mask-center .sheet {
    width: auto;
    max-width: 380px;
    margin: 0 16px;
    border-radius: 18px;
    padding: 22px 20px;
}


.sheet {
    width: 100%;
    max-width: 560px;
    background: var(--bg-elevated);
    border-radius: 18px 18px 0 0;
    padding: 22px 20px calc(22px + var(--safe-b));
    animation: sheet-up 0.24s ease-out;
}

@keyframes sheet-up {
    from { transform: translateY(24px); opacity: 0.4; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.4px;
    line-height: 1.19;
    margin-bottom: 14px;
}

/* 弹层里的按钮统一成整行 Apple 风（8px 圆角）。
   之前主按钮是窄药丸、取消按钮却是整行灰块，两个叠在一起很别扭。 */
.sheet .btn {
    width: 100%;
    flex: none;
    height: 46px;
    border-radius: 8px;
    font-size: 16px;
}

/* 只有直接挂在 sheet 上的按钮才叠行；登录表单里的按钮是 flex gap 排的，别重复加间距 */
.sheet > .btn + .btn { margin-top: 10px; }

.sheet .btn-ghost { height: 44px; font-size: 15px; }

/* 输入框与主按钮之间留点呼吸感 */
#groupNameMask .field,
#watchAddMask .field { margin-bottom: 14px; }

.sheet-text {
    font-size: 14px;
    line-height: 1.62;
    color: var(--text-2);
    max-height: 56vh;
    overflow-y: auto;
    margin-bottom: 16px;
}

.sheet-text p { margin-bottom: 10px; }

.sheet-close { width: 100%; }

/* 确认弹层：标题 + 说明 + 并排的取消 / 确定 */
.sheet-confirm .sheet-title { margin-bottom: 8px; }
.sheet-confirm .sheet-text { margin-bottom: 18px; }

.confirm-acts {
    display: flex;
    gap: 10px;
}

.confirm-acts .btn {
    flex: 1 1 0;
    height: 46px;
    border-radius: 8px;
    font-size: 16px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
    transform: translateX(-50%);
    z-index: 95;
    background: var(--bg-toast);
    /* 底色永远是深色的，文字也得固定用白色，
       跟着 --text 走的话浅色模式下就是深字压深底，看不见 */
    color: #fff;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 980px;
    animation: fade-in 0.2s ease-out;
}

.toast[hidden] { display: none; }

@keyframes fade-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================ 登录 ============================ */

.btn-sm {
    height: 34px;
    padding: 0 16px;
    font-size: 14px;
    flex: 0 0 auto;
}

.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form[hidden] { display: none; }

/* 登录 / 注册 分段切换 */
.seg-auth { margin-bottom: 16px; }

.field {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: var(--bg-soft);
    outline: none;
    font-size: 16px;
    letter-spacing: -0.2px;
}

/* 聚焦环收细一点，2px 实蓝太抢眼 */
.field:focus { box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.28); }
.field::placeholder { color: var(--text-3); }

.login-err {
    font-size: 13px;
    color: var(--up);
    padding: 0 2px;
}

.login-err[hidden] { display: none; }

.login-note {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-3);
}
