/* 钢子出击 - 响应式样式 */

/* ═══════════ >= 1400px 完整 5 列 ═══════════ */
@media (min-width: 1400px) {
    .debate-roles {
        grid-template-columns: repeat(5, 1fr);
    }
    .overview {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ═══════════ 1200-1399px 3 列辩论 ═══════════ */
@media (max-width: 1399px) and (min-width: 1200px) {
    .debate-roles {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ═══════════ 768-1199px 2 列 ═══════════ */
@media (max-width: 1199px) {
    .overview {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .grid-2-1 {
        grid-template-columns: 1fr;
    }
    .debate-roles {
        grid-template-columns: repeat(2, 1fr);
    }
    .ai-hero-details {
        grid-template-columns: repeat(3, 1fr);
    }
    .container {
        padding: 16px 20px 60px;
    }
    .header {
        padding: 12px 20px;
    }
}

/* #MEDIUM-12 修复：触摸延迟 */
html {
  touch-action: manipulation;
}
.nav-tab, .header-btn, .chat-send, .debate-btn, .login-btn, .init-btn {
  touch-action: manipulation;
}

/* ═══════════ < 768px 手机端 ═══════════ */
@media (max-width: 767px) {
    .overview {
        grid-template-columns: 1fr;
    }
    .grid-2, .grid-3, .grid-2-1 {
        grid-template-columns: 1fr;
    }
    .debate-roles {
        grid-template-columns: 1fr;
        display: grid;
        gap: 12px;
        overflow: visible;
    }
    .role-card {
        min-width: 0;
        width: 100%;
    }
    .ai-hero-top {
        flex-direction: column;
        align-items: flex-start;
    }
    .ai-hero-gauge {
        align-self: center;
    }
    .ai-hero-details {
        grid-template-columns: repeat(2, 1fr);
    }
    .header {
        padding: 8px 12px;
        gap: 10px;
        flex-wrap: nowrap;
    }
    .logo { min-width: 0; }
    .logo-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 14px;
    }
    .logo h1 {
        font-size: 14px;
        /* iOS Safari 超窄屏时避免中文挤成“竖排” */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 44vw;
    }
    .logo h1 span {
        display: none;
    }
    .header-right {
        gap: 4px;
        flex-wrap: nowrap;
        flex-shrink: 0;
    }
    .header-time {
        display: none;
    }
    .status-pill {
        font-size: 10px;
        padding: 3px 8px;
        gap: 4px;
    }
    .status-pill .dot {
        width: 5px;
        height: 5px;
    }
    .header-btn {
        padding: 6px 8px;
        font-size: 10px;
        border-radius: 6px;
    }
    .header-btn.voice-btn {
        padding: 6px;
        font-size: 15px;
    }
    .header-btn.theme-toggle {
        padding: 6px;
        font-size: 15px;
    }
    .logout-btn .logout-text {
        display: none;
    }
    .logout-btn {
        font-size: 15px !important;
        padding: 6px !important;
    }
    .signal-ticker {
        height: 24px;
    }
    .signal-ticker-item {
        font-size: 10.5px;
    }
    .container {
        padding: 12px 12px 80px;
    }
    .nav-tabs {
        padding: 0 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;          /* Firefox */
        white-space: nowrap;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    /* 右侧渐变遮罩提示可滚动 */
    .nav-tabs::after {
        content: '';
        position: sticky;
        right: 0;
        top: 0;
        width: 28px;
        height: 100%;
        background: linear-gradient(90deg, transparent, var(--bg));
        pointer-events: none;
        flex-shrink: 0;
    }
    .nav-tab {
        padding: 10px 14px;
        font-size: 11px;
        min-height: 44px;
        min-width: 44px;
        flex-shrink: 0;
    }

    /* 聊天窗口全屏 */
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .chat-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }
    .chat-close {
        min-width: 40px;
        min-height: 40px;
    }

    /* 行情条 */
    .ticker-bar {
        height: 30px;
    }
    .ticker-item {
        font-size: 10px;
    }

    #quotaTrendSummary {
        font-size: 11px;
        line-height: 1.4;
    }
    #quotaTrendChart {
        min-height: 170px;
    }

    /* 信号卡片简化 */
    .signal-badge {
        font-size: 24px;
        padding: 6px 16px;
    }

    /* 确保无水平滚动 */
    body {
        overflow-x: hidden;
    }
    .debate-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ═══════════ ≤480px 移动精修：触控命中率 + 文字可读性 ═══════════ */
@media (max-width: 480px) {

    /* ── 触控命中率：所有可点击元素 ≥ 40px ── */

    /* Header 按钮（设置/语音等） */
    .header-btn {
        min-height: 36px;
        min-width: 36px;
        padding: 6px 8px;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .header-btn.voice-btn {
        padding: 6px;
        font-size: 16px;
    }
    .header-btn.theme-toggle {
        padding: 6px;
        font-size: 16px;
    }

    /* 聊天发送按钮 */
    .chat-send {
        min-height: 40px;
        min-width: 44px;
        padding: 10px 14px;
        font-size: 13px;
    }

    /* 聊天关闭按钮（加大至 44px 更易命中） */
    .chat-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 22px;
    }

    /* 系统监控 - 成本监控手机端适配 */
    .cost-analysis-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .cost-item {
        padding: 12px;
        min-width: 0;
    }
    .cost-item .cost-value {
        font-size: 18px;
        word-break: break-all;
    }
    .cost-item .cost-label {
        font-size: 11px;
    }
    .cost-by-model {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    /* 成本监控（extras.js 填充的 costPanel）手机端 */
    .cost-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .cost-stat-card {
        min-width: 0;
        padding: 10px;
    }
    .cost-stat-card .stat-value {
        font-size: 16px;
    }
    .projection-grid {
        grid-template-columns: 1fr;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .metrics-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 辩论按钮 + 币种选择器 */
    .debate-btn {
        min-height: 40px;
        padding: 8px 16px;
    }
    .symbol-select {
        min-height: 40px;
        padding: 8px 10px;
        font-size: 13px;
    }

    /* 确认弹窗按钮（提升至 44px，改善反馈） */
    .app-confirm-actions .header-btn {
        min-height: 44px;
        font-size: 14px;
    }
    .app-confirm-text {
        font-size: 14px;
        line-height: 1.7;
    }

    /* Toast 提示：提升可读性，避开底部栏 */
    .app-toast {
        bottom: 64px;
        padding: 12px 16px;
        font-size: 13px;
        line-height: 1.5;
    }

    /* 状态药丸不可点击但文字偏小 */
    .status-pill {
        font-size: 10px;
        padding: 4px 10px;
    }

    /* ── 文字可读性：密集区域提升字号 + 行高 ── */

    /* 角色分析预览 */
    .role-analysis-preview {
        font-size: 12px;
        line-height: 1.6;
        max-height: 72px;
    }

    /* 完整分析展开区 */
    .role-full-analysis {
        font-size: 12px;
        line-height: 1.7;
    }

    /* 最终裁决理由 */
    .final-reason-block {
        font-size: 12px;
        line-height: 1.7;
    }
    .verdict-reason {
        font-size: 13px;
        line-height: 1.8;
    }

    /* 免责声明 + 风险评估（原11px太密） */
    .disclaimer-text,
    .debate-disclaimer .disclaimer-text {
        font-size: 12px;
        line-height: 1.6;
    }
    .risk-assessment-content,
    .debate-risk-assessment .risk-assessment-content {
        font-size: 12px;
        line-height: 1.7;
    }

    /* 聊天消息气泡 */
    .chat-msg {
        font-size: 13px;
        line-height: 1.7;
        padding: 10px 12px;
    }

    /* 信号日志条目 */
    .signal-msg {
        font-size: 12px;
        line-height: 1.6;
    }

    /* 行情趋势摘要（覆盖 ≤767px 的 11px/1.4） */
    #quotaTrendSummary {
        font-size: 12px;
        line-height: 1.6;
    }

    /* 初始化提示 */
    .init-hint {
        font-size: 12px;
        line-height: 1.5;
    }

    /* 角色卡展开提示、投票标签 */
    .role-analysis-preview::after {
        font-size: 11px;
    }
    .vote-label {
        font-size: 11px;
    }

    /* 卡片内文本间距微调 */
    .card-body {
        padding: 14px 14px;
    }
    .stat-card .label {
        font-size: 11px;
        letter-spacing: 0.2px;
    }
    .stat-card .value {
        font-size: 20px;
    }
}

/* ═══════════ 超小屏 375px ═══════════ */
@media (max-width: 400px) {
    .status-pill span { display: none; }
    .status-pill { padding: 3px 6px; }
    .header-right { gap: 2px; }
    .logo h1 { max-width: 40vw; }

    .ai-hero-details {
        grid-template-columns: 1fr 1fr;
    }
    .ai-hero-details .detail-item:last-child {
        grid-column: span 2;
    }
    .logo-icon {
        display: none;
    }
}
