/* 幸运日 - 响应式样式（PC / WAP 通用） */
:root {
    --primary: #2b5cff;
    --primary-dark: #1f42cc;
    --accent: #ff5a3c;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #1a1f36;
    --text-sub: #6b7392;
    --border: #e6e9f2;
    --success: #17b979;
    --warn: #f5a623;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(31, 45, 91, .08);
    --nav-h: 62px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1220;
        --surface: #161b2e;
        --text: #e8ebf5;
        --text-sub: #98a0bd;
        --border: #262c44;
        --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 16px calc(var(--nav-h) + 28px);
}

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: linear-gradient(120deg, var(--primary) 0%, #6b45ff 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-logo {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .3);
    display: grid; place-items: center;
    font-weight: 800; font-size: 13px; letter-spacing: .5px;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: .3px; }
.brand-text small { font-size: 11px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.conn-text { font-size: 12px; opacity: .9; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: #43e08a; box-shadow: 0 0 0 3px rgba(67, 224, 138, .25); }
.dot-warn { background: #ffd166; box-shadow: 0 0 0 3px rgba(255, 209, 102, .25); }
.dot-err { background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255, 107, 107, .25); }

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}

.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

.empty { color: var(--text-sub); font-size: 13px; padding: 12px 0; text-align: center; }
.note { color: var(--text-sub); font-size: 12px; margin: 10px 0 0; line-height: 1.6; }

/* ---------- 头部开奖 ---------- */
.hero {
    background: linear-gradient(135deg, rgba(43, 92, 255, .08), rgba(107, 69, 255, .08));
    border-color: rgba(43, 92, 255, .2);
}

.hero-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.tag {
    background: var(--primary); color: #fff;
    font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
}

.hero-issue { font-size: 17px; font-weight: 800; letter-spacing: .5px; }
.hero-date { font-size: 12px; color: var(--text-sub); }

.balls-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.balls-row-lg .ball { width: 44px; height: 44px; font-size: 18px; }

.balls { display: flex; gap: 7px; flex-wrap: wrap; }

.zone-label { font-size: 12px; color: var(--text-sub); flex-shrink: 0; }
.divider { width: 1px; height: 22px; background: var(--border); }

.ball {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px; color: #fff;
    background: radial-gradient(circle at 30% 25%, #ff8b6f, var(--accent));
    box-shadow: 0 3px 8px rgba(255, 90, 60, .35);
    animation: pop .35s ease both;
}

.ball.ball-back {
    background: radial-gradient(circle at 30% 25%, #6ea8ff, var(--primary));
    box-shadow: 0 3px 8px rgba(43, 92, 255, .35);
}

@keyframes pop {
    from { transform: scale(.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.hero-foot {
    display: flex; gap: 22px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.hero-foot div { display: flex; flex-direction: column; gap: 3px; }
.hero-foot .k { font-size: 11px; color: var(--text-sub); }
.hero-foot b { font-size: 14px; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
    border: 1px solid transparent; border-radius: 10px;
    padding: 9px 16px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: .18s; font-family: inherit;
    background: transparent; color: inherit; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(43, 92, 255, .3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--border); color: var(--primary); background: var(--surface); }
.btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
    outline: none; transition: .18s; width: 100%;
}

.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43, 92, 255, .14); }
.input-sm { width: auto; padding: 7px 10px; font-size: 13px; }

.segmented {
    display: inline-flex; background: var(--bg);
    border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px;
}

.segmented-block { display: flex; width: 100%; margin-bottom: 14px; }

.seg-item {
    border: 0; background: transparent; color: var(--text-sub);
    padding: 7px 13px; border-radius: 8px; font-size: 13px;
    cursor: pointer; font-family: inherit; transition: .18s; flex: 1;
    white-space: nowrap;
}

.seg-item.active { background: var(--surface); color: var(--primary); font-weight: 700; box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-row { display: flex; gap: 8px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 历史列表 ---------- */
.history-list { max-height: 380px; overflow-y: auto; }

.hist-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}

.hist-item:last-child { border-bottom: 0; }
.hist-meta { width: 92px; flex-shrink: 0; }
.hist-meta b { display: block; font-size: 13px; }
.hist-meta span { font-size: 11px; color: var(--text-sub); }
.hist-balls { display: flex; gap: 6px; flex-wrap: wrap; }

.hist-balls .ball { width: 28px; height: 28px; font-size: 12.5px; }

/* ---------- 统计图表 ---------- */
.stats-summary {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
    font-size: 12px; color: var(--text-sub);
}

.stats-summary .pill {
    background: var(--bg); border: 1px solid var(--border);
    padding: 4px 10px; border-radius: 999px;
}

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

.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 34px; flex-shrink: 0; font-size: 13px; font-weight: 700; text-align: right; }
.bar-track { flex: 1; height: 22px; background: var(--bg); border-radius: 6px; overflow: hidden; }

.bar-fill {
    height: 100%; border-radius: 6px;
    background: linear-gradient(90deg, var(--primary), #7b6bff);
    transition: width .5s ease; min-width: 2px;
}

.bar-fill.is-back { background: linear-gradient(90deg, #ff7a5c, var(--accent)); }
.bar-val { width: 42px; flex-shrink: 0; font-size: 12px; color: var(--text-sub); text-align: right; }

/* ---------- 选号 ---------- */
.pick-result { text-align: center; padding: 6px 0; }
.pick-result .balls-row { justify-content: center; margin-bottom: 16px; }
.pick-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 聊天 ---------- */
.chat-card { display: flex; flex-direction: column; }

.chat-log {
    height: 46vh; min-height: 260px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    padding-right: 4px; margin-bottom: 12px;
}

/* 首页聊天窗口：高度更小，避免占据过多首屏 */
.chat-compact .chat-log { height: 26vh; min-height: 170px; }

.msg { max-width: 82%; padding: 10px 13px; border-radius: 13px; font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; }

.msg-bot { background: var(--bg); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }

.msg-user {
    background: var(--primary); color: #fff; align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-load { color: var(--text-sub); font-size: 12px; align-self: flex-start; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.chip {
    border: 1px solid var(--border); background: var(--bg); color: var(--text-sub);
    border-radius: 999px; padding: 6px 11px; font-size: 12px;
    cursor: pointer; font-family: inherit; text-align: left;
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chat-form { display: flex; gap: 8px; }

/* ---------- 键值表 ---------- */
.kv-list { display: flex; flex-direction: column; gap: 8px; }

.kv-item { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.kv-item:last-child { border-bottom: 0; }
.kv-item span { color: var(--text-sub); }
.kv-item b { font-weight: 600; word-break: break-all; text-align: right; }

/* ---------- 底部导航（WAP） ---------- */
.tabbar { display: none; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(12px);
    background: rgba(20, 24, 40, .92); color: #fff; font-size: 13px;
    padding: 9px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
    transition: .25s; z-index: 60; max-width: 80vw; text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 登录/注册弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(10, 14, 30, .5); backdrop-filter: blur(2px); }
.modal-box {
    position: relative; width: min(380px, calc(100vw - 32px)); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; animation: fade .2s ease both;
}
.modal-x {
    position: absolute; top: 10px; right: 12px; border: 0; background: transparent;
    font-size: 22px; line-height: 1; color: var(--text-sub); cursor: pointer;
}
.auth-tabs { margin-bottom: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form .input { width: 100%; }
.auth-msg { font-size: 12px; margin: 2px 0 0; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.auth-msg.is-err { color: var(--accent); }
.auth-msg.is-ok { color: var(--success); }

/* ---------- AI 游客额度提示 ---------- */
.chat-quota { font-size: 12px; color: var(--text-sub); font-weight: 500; }
.chat-quota.is-empty { color: var(--accent); }
.chat-quota.is-vip { color: var(--success); }

.page { display: none; animation: fade .25s ease both; }
.page.active { display: block; }

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

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
    .container { padding: 14px 12px calc(var(--nav-h) + 20px); }
    .card { padding: 14px; border-radius: 12px; }

    .brand-text small { display: none; }
    .conn-text { display: none; }

    .hero-head { gap: 8px; }
    .ball { width: 32px; height: 32px; font-size: 14px; }
    .balls-row-lg .ball { width: 38px; height: 38px; font-size: 16px; }
    .hist-meta { width: 76px; }
    .hist-balls .ball { width: 26px; height: 26px; font-size: 11.5px; }

    .hero-foot { gap: 16px; }
    .card-head { gap: 8px; }
    .filters { width: 100%; }
    .filters .segmented { flex: 1; }
    .chat-log { height: 40vh; }
    .msg { max-width: 90%; }

    .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0;
        height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--border);
        z-index: 50; box-shadow: 0 -2px 14px rgba(31, 45, 91, .07);
    }

    .tab {
        flex: 1; border: 0; background: transparent; color: var(--text-sub);
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px; font-size: 11px; font-family: inherit; cursor: pointer; padding: 6px 0;
    }

    .tab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .tab.active { color: var(--primary); font-weight: 700; }
}

/* PC 端把同一套页签显示在顶部内容区（更宽的布局） */
@media (min-width: 769px) {
    .tabbar {
        display: flex; gap: 6px; max-width: 1080px; margin: 0 auto; padding: 14px 16px 0;
    }

    .tab {
        border: 1px solid var(--border); background: var(--surface); color: var(--text-sub);
        border-radius: 10px; padding: 8px 16px; font-size: 13px; font-family: inherit;
        cursor: pointer; display: flex; align-items: center; gap: 6px; transition: .18s;
    }

    .tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .tab:hover { border-color: var(--primary); color: var(--primary); }
    .tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
}
