/* ============================================================
   医学计算工具 - 移动优先样式 (Mobile-First)
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #06b6d4;
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-soft: #64748b;
    --text-faint: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --warn-bg: #fef3c7;
    --warn-border: #f59e0b;
    --warn-text: #78350f;
    --error-bg: #fee2e2;
    --error-border: #ef4444;
    --error-text: #991b1b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --tap-min: 48px;
    --bar-height: 56px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

/* 视图切换 */
.view {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    animation: fadeIn 0.25s ease;
}

.view.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

/* ============================================================
   主页 (Home)
   ============================================================ */
#home {
    background:
        radial-gradient(1200px 600px at 0% -20%, #dbeafe 0%, transparent 60%),
        radial-gradient(1000px 500px at 100% 110%, #cffafe 0%, transparent 55%),
        var(--bg);
}

.home-hero {
    padding: calc(var(--safe-top) + 36px) 24px 28px;
    text-align: center;
}

.logo-wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #dbeafe, #ecfeff);
    color: var(--primary);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-md);
}

.logo-wrap svg {
    width: 34px;
    height: 34px;
}

.home-hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.hero-sub {
    font-size: 0.92rem;
    color: var(--text-soft);
}

.home-main {
    flex: 1;
    padding: 8px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 16px;
    text-align: left;
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
    width: 100%;
    min-height: var(--tap-min);
}

.feature-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.card-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
}

.card-icon svg {
    width: 26px;
    height: 26px;
}

.icon-1 { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.icon-2 { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.icon-3 { background: linear-gradient(135deg, #10b981, #06b6d4); }
.icon-4 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.icon-5 { background: linear-gradient(135deg, #6366f1, #a855f7); }
.icon-6 { background: linear-gradient(135deg, #0ea5e9, #22c55e); }
.icon-stage-1 { background: linear-gradient(135deg, #ef4444, #f59e0b); }
.icon-stage-2 { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.icon-stage-3 { background: linear-gradient(135deg, #f43f5e, #8b5cf6); }

.card-text {
    flex: 1;
    min-width: 0;
}

.card-text h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-text p {
    font-size: 0.82rem;
    color: var(--text-soft);
}

.card-arrow {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--text-faint);
}

.home-footer {
    padding: 16px 24px calc(20px + var(--safe-bottom));
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-faint);
}

/* ============================================================
   子页面通用
   ============================================================ */
.page-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    height: var(--bar-height);
    padding: var(--safe-top) 8px 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border-light);
}

.page-bar h1 {
    flex: 1;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.icon-btn {
    width: var(--tap-min);
    height: var(--tap-min);
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--text);
    transition: background 0.15s;
}

.icon-btn:active {
    background: var(--border-light);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
}

.bar-spacer {
    width: var(--tap-min);
    height: var(--tap-min);
}

.page-main {
    flex: 1;
    padding: 12px 14px calc(20px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 面板 */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.panel h3 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    letter-spacing: 0.5px;
}

/* 表单 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label,
.group-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.form-group input[type="number"] {
    width: 100%;
    height: var(--tap-min);
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 500;
    background: #fff;
    transition: all 0.15s;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* 分段控件 (Segmented Control) */
.seg-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.seg-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.seg-control label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    min-height: var(--tap-min);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.92rem;
    line-height: 1.35;
    justify-content: center;
}

.seg-control label strong {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.seg-control label small {
    font-size: 0.78rem;
    color: var(--text-soft);
    font-weight: 400;
}

.seg-control input[type="radio"]:checked + label {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.seg-control input[type="radio"]:checked + label strong {
    color: var(--primary-dark);
}

.seg-control label:active {
    transform: scale(0.98);
}

/* 信息提示 */
.info-box {
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border-left: 4px solid var(--primary);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.info-box strong {
    display: block;
    color: var(--primary-dark);
    margin-bottom: 4px;
    font-weight: 600;
}

.info-box p {
    color: var(--text-soft);
    line-height: 1.55;
}

/* 按钮 */
.btn-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin-top: 6px;
}

.calculate-btn,
.reset-btn {
    height: 50px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
}

.calculate-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.calculate-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.reset-btn {
    background: var(--border-light);
    color: var(--text-soft);
}

.reset-btn:active {
    background: var(--border);
}

/* 结果占位 */
.result-placeholder {
    text-align: center;
    color: var(--text-soft);
    padding: 40px 16px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: var(--radius-sm);
    border: 1.5px dashed var(--border);
    font-size: 0.9rem;
}

/* 摘要卡片 (BSA/HAIC/GC 结果顶部) */
.summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 14px;
}

.summary .item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary .label {
    font-size: 0.72rem;
    color: var(--text-soft);
}

.summary .value {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* BSA 公式列表 */
.formula-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: #fff;
}

.formula-item .formula-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.formula-tag {
    font-size: 0.68rem;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 999px;
    font-weight: 500;
}

.formula-expr {
    font-size: 0.74rem;
    color: var(--text-soft);
    font-family: "Courier New", "Consolas", monospace;
    margin-bottom: 6px;
    word-break: break-word;
}

.formula-result {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.formula-result .unit {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-left: 4px;
    font-weight: 500;
}

/* 药物卡片 */
.drug-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 14px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ffffff, #fafbff);
}

.drug-card:last-of-type {
    margin-bottom: 0;
}

.drug-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.drug-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.drug-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.drug-en {
    font-size: 0.72rem;
    color: var(--text-soft);
    font-weight: 400;
}

.drug-stage {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--primary-dark);
    background: var(--primary-light);
    border-radius: 999px;
    vertical-align: middle;
}

.drug-dose {
    flex: 0 0 auto;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    white-space: nowrap;
}

.drug-dose .unit {
    font-size: 0.78rem;
    color: var(--text-soft);
    -webkit-text-fill-color: var(--text-soft);
    font-weight: 500;
    margin-left: 1px;
}

.drug-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.drug-detail .row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.drug-detail .row .label {
    color: var(--text-soft);
    flex: 0 0 auto;
}

.drug-detail .row .value {
    color: var(--text);
    font-weight: 500;
    text-align: right;
}

/* 5-FU 明细 */
.fu-breakdown {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 0.85rem;
}

.fu-breakdown .fu-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.fu-breakdown .fu-row + .fu-row {
    border-top: 1px dashed var(--border);
}

.fu-breakdown .label {
    color: var(--text-soft);
}

.fu-breakdown .value {
    font-weight: 600;
    color: var(--primary-dark);
}

/* 注意事项 */
.note-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--warn-bg);
    border-left: 4px solid var(--warn-border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--warn-text);
    line-height: 1.6;
}

.note-box strong {
    display: block;
    margin-bottom: 4px;
    color: #92400e;
    font-weight: 600;
}

/* 错误提示 */
.error-msg {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--error-border);
    margin-bottom: 12px;
    font-size: 0.88rem;
}

/* ============================================================
   自定义计算器
   ============================================================ */
.label-hint {
    font-size: 0.78rem;
    color: var(--text-faint);
    font-weight: 400;
    margin-left: 4px;
}

.select-input {
    width: 100%;
    height: var(--tap-min);
    padding: 0 38px 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    background: #fff
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'><path d='M6 9l6 6 6-6' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
        no-repeat right 12px center / 14px 14px;
    color: var(--text);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.15s;
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* 药物输入卡片 */
.drug-input-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 14px 12px;
    margin-bottom: 10px;
    background: #fff;
    transition: border-color 0.2s;
    animation: drugSlideIn 0.2s ease;
}

.drug-input-card:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

@keyframes drugSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.drug-input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.drug-input-no {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 3px 10px;
    border-radius: 999px;
}

.drug-input-remove {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #ef4444;
    transition: background 0.15s;
}

.drug-input-remove:active {
    background: var(--error-bg);
}

.drug-input-remove svg {
    width: 18px;
    height: 18px;
}

.drug-name-input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: #fff;
    margin-bottom: 8px;
    transition: all 0.15s;
}

.drug-name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.drug-dose-row {
    display: grid;
    grid-template-columns: 1fr 130px;
    gap: 8px;
}

.drug-dose-input {
    height: 44px;
    padding: 0 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: #fff;
    transition: all 0.15s;
    width: 100%;
}

.drug-dose-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.drug-unit-select {
    height: 44px;
    padding: 0 32px 0 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    background: #fff
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'><path d='M6 9l6 6 6-6' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
        no-repeat right 10px center / 12px 12px;
    color: var(--text);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.15s;
    width: 100%;
    cursor: pointer;
}

.drug-unit-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* 添加药物按钮 */
.add-drug-btn {
    width: 100%;
    height: 46px;
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}

.add-drug-btn svg {
    width: 18px;
    height: 18px;
}

.add-drug-btn:active {
    transform: scale(0.98);
}

.add-drug-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* 自定义计算结果 - 公式徽章 */
.formula-used {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.78rem;
    border-radius: 999px;
    font-weight: 500;
}

/* ============================================================
   肝癌分期评估
   ============================================================ */

/* 分期 hub 页 */
.staging-hub {
    gap: 12px;
}

/* 垂直分段控件（用于较长选项） */
.seg-control.seg-vertical {
    flex-direction: column;
}

@media (min-width: 768px) {
    .seg-control.seg-vertical {
        flex-direction: column;
    }
}

/* 分段控件中的 small 标签 */
.seg-control label small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-soft);
    font-weight: 400;
    margin-top: 2px;
}

/* PS 评分选项（带描述） */
.ps-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ps-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    min-height: var(--tap-min);
}

.ps-option:hover {
    border-color: var(--primary);
}

.ps-option:active {
    transform: scale(0.99);
}

.ps-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ps-option .ps-radio {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: grid;
    place-items: center;
    margin-top: 1px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

.ps-option .ps-text {
    flex: 1;
    min-width: 0;
}

.ps-option .ps-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.ps-option .ps-desc {
    font-size: 0.78rem;
    color: var(--text-soft);
    line-height: 1.5;
}

.ps-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 分级输入行（Child-Pugh / ALBI 按钮 + 显示） */
.grade-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.grade-display {
    flex: 1;
    min-height: var(--tap-min);
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    overflow: hidden;
}

.grade-display .grade-empty {
    color: var(--text-faint);
    font-size: 0.92rem;
}

.grade-display .grade-result-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.grade-display .grade-result-detail {
    font-size: 0.75rem;
    color: var(--text-soft);
    font-weight: 400;
}

.grade-btn {
    flex: 0 0 auto;
    height: var(--tap-min);
    padding: 0 18px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22);
    transition: transform 0.1s, box-shadow 0.2s;
}

.grade-btn:active {
    transform: translateY(1px);
}

/* 字段提示（弹窗内输入框下方的小提示） */
.field-hint {
    font-size: 0.75rem;
    color: var(--text-soft);
    margin-top: 6px;
    line-height: 1.5;
}

/* 大型弹窗（Child-Pugh / ALBI） */
.modal.modal-lg {
    align-items: stretch;
    padding: 0;
}

@media (min-width: 600px) {
    .modal.modal-lg {
        align-items: center;
        padding: 20px;
    }
}

.modal-card-lg {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

@media (min-width: 600px) {
    .modal-card-lg {
        max-width: 480px;
        max-height: calc(100vh - 40px);
        border-radius: 18px;
    }
}

.modal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-top) + 12px) 16px 12px;
    border-bottom: 1px solid var(--border-light);
    flex: 0 0 auto;
}

.modal-card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close-btn {
    margin-right: -8px;
}

.modal-card-body {
    flex: 1;
    padding: 16px 16px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-actions-lg {
    padding: 12px 16px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border-light);
    background: var(--card-bg);
    flex: 0 0 auto;
}

/* 分级实时结果 */
.grade-result {
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border: 1.5px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.2s;
}

.grade-result.warn {
    background: var(--warn-bg);
    border-color: var(--warn-border);
}

.grade-result-label {
    font-size: 0.78rem;
    color: var(--text-soft);
    font-weight: 500;
}

.grade-result-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.grade-result.warn .grade-result-value {
    color: var(--warn-text);
}

.grade-result-incomplete .grade-result-value {
    font-size: 0.95rem;
    color: var(--text-soft);
    font-weight: 500;
}

/* 分期评估结果 - 大徽章 */
.stage-result-card {
    text-align: center;
    padding: 28px 20px 24px;
    background: linear-gradient(135deg, #eff6ff, #ecfeff);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid var(--primary-light);
}

.stage-result-card.stage-color-0 { background: linear-gradient(135deg, #d1fae5, #a7f3d0); border-color: #10b981; }
.stage-result-card.stage-color-1 { background: linear-gradient(135deg, #dbeafe, #bfdbfe); border-color: #3b82f6; }
.stage-result-card.stage-color-2 { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #f59e0b; }
.stage-result-card.stage-color-3 { background: linear-gradient(135deg, #fed7aa, #fdba74); border-color: #f97316; }
.stage-result-card.stage-color-4 { background: linear-gradient(135deg, #fee2e2, #fecaca); border-color: #ef4444; }

.stage-result-card .stage-system {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-bottom: 6px;
    letter-spacing: 1px;
    font-weight: 500;
}

.stage-result-card .stage-label {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.stage-result-card .stage-name {
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 8px;
}

.stage-result-card .stage-desc {
    font-size: 0.82rem;
    color: var(--text-soft);
    line-height: 1.55;
    max-width: 360px;
    margin: 0 auto;
}

/* 评估依据卡片 */
.eval-basis {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.eval-basis h4 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}

.eval-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.eval-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
}

.eval-row .label {
    color: var(--text-soft);
    flex: 0 0 auto;
}

.eval-row .value {
    color: var(--text);
    font-weight: 500;
    text-align: right;
}

.eval-row .value.highlight {
    color: var(--primary-dark);
    font-weight: 600;
}

.eval-row .value.warn {
    color: #b45309;
    font-weight: 600;
}

/* TNM 单项徽章 */
.tnm-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.tnm-badge {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   异常输入确认弹窗
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 24px 22px 18px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--warn-bg);
    color: var(--warn-border);
    display: grid;
    place-items: center;
}

.modal-icon svg {
    width: 30px;
    height: 30px;
}

.modal-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.modal-list {
    list-style: none;
    background: var(--warn-bg);
    border-left: 4px solid var(--warn-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
    color: var(--warn-text);
    font-size: 0.88rem;
    line-height: 1.6;
}

.modal-list li {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.modal-list li::before {
    content: '•';
    flex: 0 0 auto;
    color: var(--warn-border);
    font-weight: 700;
}

.modal-list li + li {
    margin-top: 4px;
}

.modal-tip {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-bottom: 18px;
    line-height: 1.55;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-btn {
    height: 46px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform 0.1s, background 0.2s;
}

.modal-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.modal-btn-primary:active {
    transform: translateY(1px);
}

.modal-btn-secondary {
    background: var(--border-light);
    color: var(--text);
}

.modal-btn-secondary:active {
    background: var(--border);
}

@media (min-width: 480px) {
    .modal-card {
        padding: 28px 26px 22px;
    }
    .modal-title {
        font-size: 1.2rem;
    }
}

/* ============================================================
   桌面适配 (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
    body {
        background:
            radial-gradient(1200px 600px at 0% -10%, #dbeafe 0%, transparent 60%),
            radial-gradient(1000px 500px at 100% 110%, #cffafe 0%, transparent 55%),
            var(--bg);
    }

    .home-hero {
        padding: 48px 32px 32px;
    }

    .home-hero h1 {
        font-size: 2.2rem;
    }

    .hero-sub {
        font-size: 1rem;
    }

    .home-main {
        max-width: 720px;
        width: 100%;
        margin: 0 auto;
        padding: 8px 24px 32px;
    }

    .feature-card {
        padding: 22px 22px;
    }

    .card-icon {
        width: 56px;
        height: 56px;
    }

    .card-text h2 {
        font-size: 1.2rem;
    }

    .card-text p {
        font-size: 0.92rem;
    }

    .page-bar {
        padding: var(--safe-top) 16px 0;
    }

    .page-bar h1 {
        font-size: 1.2rem;
    }

    .page-main {
        max-width: 960px;
        width: 100%;
        margin: 0 auto;
        padding: 20px 24px 40px;
        display: grid;
        grid-template-columns: minmax(0, 380px) 1fr;
        gap: 20px;
        align-items: start;
    }

    .panel {
        padding: 24px 22px;
    }

    .seg-control {
        flex-direction: row;
    }

    .seg-control.seg-vertical {
        flex-direction: column;
    }

    .seg-control label {
        flex: 1;
    }
}

@media (min-width: 1100px) {
    .page-main {
        max-width: 1100px;
    }
}

/* 暗色模式（如系统启用） */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card-bg: #1e293b;
        --text: #f1f5f9;
        --text-soft: #94a3b8;
        --text-faint: #64748b;
        --border: #334155;
        --border-light: #1e293b;
        --primary-light: #1e3a8a;
    }

    body {
        background:
            radial-gradient(1200px 600px at 0% -20%, rgba(37, 99, 235, 0.18) 0%, transparent 60%),
            radial-gradient(1000px 500px at 100% 110%, rgba(6, 182, 212, 0.12) 0%, transparent 55%),
            var(--bg);
    }

    .form-group input[type="number"] {
        background: #0f172a;
        color: var(--text);
        border-color: var(--border);
    }

    .seg-control label {
        background: #0f172a;
    }

    .seg-control input[type="radio"]:checked + label {
        background: rgba(37, 99, 235, 0.18);
    }

    .seg-control input[type="radio"]:checked + label strong {
        color: #93c5fd;
    }

    .info-box {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(6, 182, 212, 0.08));
    }

    .summary {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(6, 182, 212, 0.1));
    }

    .summary .value {
        color: #93c5fd;
    }

    .drug-card {
        background: linear-gradient(135deg, #1e293b, #1a2235);
    }

    .formula-result {
        color: #60a5fa;
    }

    .fu-breakdown {
        background: rgba(15, 23, 42, 0.6);
    }

    .fu-breakdown .value {
        color: #93c5fd;
    }

    .reset-btn {
        background: #334155;
        color: #cbd5e1;
    }

    .result-placeholder {
        background: rgba(15, 23, 42, 0.5);
        border-color: var(--border);
    }

    .page-bar {
        background: rgba(15, 23, 42, 0.85);
    }

    .note-box {
        background: rgba(245, 158, 11, 0.14);
        color: #fde68a;
    }

    .note-box strong {
        color: #fbbf24;
    }

    .error-msg {
        background: rgba(239, 68, 68, 0.15);
        color: #fca5a5;
    }
}
