/* ======================================================================
 *  BMI 计算器 /tool/bmi-calc
 *  依赖 home.css 全局变量 + tool-detail.css 公共类，支持黑夜模式
 * ====================================================================== */

[hidden] { display: none !important; }

.bmi-layout {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}
.bmi-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}
.bmi-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}

/* ---------- 表单 ---------- */
.bmi-field { margin-bottom: 14px; min-width: 0; }
.bmi-field > label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-sub);
    margin-bottom: 7px;
}
.bmi-input-wrap { position: relative; display: flex; align-items: center; }
.bmi-input {
    width: 100%;
    height: 43px;
    padding: 0 52px 0 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
    -moz-appearance: textfield;
}
.bmi-input::-webkit-outer-spin-button,
.bmi-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bmi-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.bmi-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 36px;
    font-size: 13.5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a8' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}
.bmi-suffix {
    position: absolute;
    right: 14px;
    font-size: 12px;
    color: var(--c-text-muted);
    pointer-events: none;
}
.bmi-help {
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--c-text-muted);
    margin-top: 6px;
}
.bmi-help b { color: var(--c-text-sub); }

/* 性别分段按钮 */
.bmi-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.bmi-seg-btn {
    height: 43px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    color: var(--c-text-sub);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
}
.bmi-seg-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.bmi-seg-btn.active {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.16), rgba(52, 199, 89, 0.08));
    border-color: rgba(52, 199, 89, 0.55);
    color: #1f9d43;
}

.btn-block { width: 100%; margin-top: 8px; }

/* ---------- 结果区 ---------- */
.bmi-result-card { min-height: 360px; }
.bmi-result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 340px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 13.5px;
    line-height: 1.8;
}
.bmi-result-empty .emoji { font-size: 46px; opacity: 0.75; }

.bmi-result-body { animation: bmiFade 0.28s ease; }
@keyframes bmiFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.bmi-hero {
    padding: 20px 24px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.12), rgba(0, 168, 168, 0.08));
    border: 1px solid rgba(52, 199, 89, 0.28);
    margin-bottom: 12px;
    text-align: center;
}
.bmi-hero-label { font-size: 12.5px; color: var(--c-text-sub); margin-bottom: 4px; }
.bmi-hero-num {
    line-height: 1.1;
    color: #1f9d43;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.bmi-hero-cat {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 14px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 800;
}

/* 刻度条 */
.bmi-scale { position: relative; padding-top: 26px; margin-bottom: 16px; }
.bmi-scale-bar {
    display: flex;
    height: 14px;
    border-radius: 99px;
    overflow: hidden;
    border: 1px solid var(--c-border);
}
.bmi-seg { display: block; height: 100%; }
.bmi-scale-labels {
    display: flex;
    margin-top: 7px;
}
.bmi-seg-label {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}
.bmi-scale-pointer {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.35s ease;
}
.bmi-scale-bubble {
    display: block;
    padding: 2px 9px;
    border-radius: 99px;
    color: #fff;
    font-size: 11.5px;
    font-weight: 800;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.bmi-scale-tick {
    width: 3px;
    height: 17px;
    margin-top: 2px;
    border-radius: 2px;
    background: var(--c-text);
}

/* 明细 */
.bmi-bill {
    list-style: none;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}
.bmi-bill li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--c-border);
}
.bmi-bill li:last-child { border-bottom: none; }
.bmi-bill .k { color: var(--c-text-sub); white-space: nowrap; }
.bmi-bill .v { font-weight: 700; color: var(--c-text); text-align: right; }
.bmi-bill li.total { background: var(--c-surface-soft); }
.bmi-bill li.total .v { color: #1f9d43; font-size: 14.5px; }
.bmi-ok { color: #1f9d43; }
.bmi-warn { color: #e0447c; }

.bmi-note {
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--c-text-sub);
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(52, 199, 89, 0.08);
    border: 1px dashed rgba(52, 199, 89, 0.35);
}
.bmi-note b { color: var(--c-text); }

/* ---------- 表格 ---------- */
.bmi-table-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
}
.bmi-table-head { margin-bottom: 14px; }
.bmi-table-head .bmi-title { margin-bottom: 4px; }
.bmi-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}
.bmi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 560px;
}
.bmi-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-text-sub);
    background: var(--c-surface-soft);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.bmi-table tbody td {
    padding: 11px 16px;
    color: var(--c-text-sub);
    border-bottom: 1px solid var(--c-border);
    line-height: 1.6;
}
.bmi-table tbody tr:last-child td { border-bottom: none; }
.bmi-table tbody tr.is-active { background: rgba(52, 199, 89, 0.09); }
.bmi-table tbody tr.is-active td { color: var(--c-text); }
.bmi-td-num { white-space: nowrap; }
.bmi-td-range { white-space: nowrap; font-weight: 800; color: #1f9d43; }
.bmi-td-h { white-space: nowrap; }
.bmi-level-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* ---------- 免责 ---------- */
.bmi-disclaim {
    font-size: 12px;
    line-height: 1.85;
    color: var(--c-text-muted);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 26px;
}
.bmi-disclaim b { color: var(--c-text-sub); }
.bmi-info { margin-bottom: 26px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
    .bmi-layout { grid-template-columns: 1fr; }
    .bmi-result-card { min-height: auto; }
    .bmi-result-empty { min-height: 180px; }
}
@media (max-width: 620px) {
    .bmi-card, .bmi-table-card { padding: 18px; }
    .bmi-hero-num { font-size: 33px; }
    .bmi-bill li { flex-direction: column; align-items: flex-start; gap: 4px; }
    .bmi-bill .v { text-align: left; }
}

/* ============ 黑夜模式 ============ */
[data-theme="dark"] .bmi-input,
[data-theme="dark"] .bmi-seg-btn { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .bmi-input option { background: #131c31; color: #e5e9f0; }
[data-theme="dark"] .bmi-hero {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.16), rgba(0, 168, 168, 0.12));
    border-color: rgba(52, 199, 89, 0.34);
}
[data-theme="dark"] .bmi-hero-num { color: #4ede78; }
[data-theme="dark"] .bmi-seg-btn.active { color: #4ede78; }
[data-theme="dark"] .bmi-bill li.total .v,
[data-theme="dark"] .bmi-td-range { color: #4ede78; }
[data-theme="dark"] .bmi-ok { color: #4ede78; }
[data-theme="dark"] .bmi-note {
    background: rgba(52, 199, 89, 0.12);
    border-color: rgba(52, 199, 89, 0.34);
}
[data-theme="dark"] .bmi-bill li.total,
[data-theme="dark"] .bmi-table thead th,
[data-theme="dark"] .bmi-disclaim { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .bmi-table tbody tr.is-active { background: rgba(52, 199, 89, 0.14); }
[data-theme="dark"] .bmi-scale-tick { background: #e5e9f0; }
