:root {
    --brand: #0e7490;
    --brand-dark: #155e75;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --card-bg: #ffffff;
    --page-bg: #f6f8fa;
}

* { box-sizing: border-box; min-width: 0; }

/* ---- 整屏锁定：页面本身不滚动，只有各面板在固定高度内自行滚动 ---- */
html, body { height: 100%; overflow-x: hidden; }
body {
    overflow: hidden;
    margin: 0;
    background: var(--page-bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.container {
    max-width: 100%;
    padding: 10px 20px 0 20px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, #0e7490 0%, #155e75 100%);
    border-radius: 12px;
    padding: 12px 22px;
    margin-bottom: 8px;
    color: #ffffff;
}
.app-header h1 { font-size: 20px; font-weight: 600; margin: 0 0 2px 0; letter-spacing: 1px; }
.app-header p  { font-size: 12px; margin: 0; opacity: 0.88; line-height: 1.5; }

.section-label {
    font-size: 14px; font-weight: 600; color: var(--ink);
    border-left: 4px solid var(--brand);
    padding-left: 10px; margin: 2px 0 8px 0;
}

/* ---- 标签页 ---- */
.tab-bar {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
}
.tab-btn {
    border: none; background: transparent; cursor: pointer;
    font-size: 14px; padding: 8px 18px; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    font-family: inherit;
}
.tab-btn:hover { color: var(--brand-dark); }
.tab-btn.active { color: var(--brand-dark); font-weight: 600; border-bottom-color: var(--brand); }

.tab-panel.hidden { display: none; }

.main-row { display: flex; gap: 16px; align-items: flex-start; }

/* 面板：占满剩余视口高度，内容超出时仅面板内部上下滚动（杜绝横向滚动） */
.pane {
    height: calc(100vh - 256px);
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    align-content: flex-start;
}

/* ---- 表单控件 ---- */
.field-label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--ink); margin: 8px 0 4px;
}

textarea, input[type="text"] {
    width: 100%; border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; color: var(--ink);
    background: #fff; font-family: inherit; line-height: 1.6;
    resize: none; outline: none;
}
textarea:focus, input[type="text"]:focus { border-color: var(--brand); box-shadow: 0 0 0 2px #a5f3fc55; }

.accordion {
    border: 1px solid var(--line); border-radius: 8px;
    background: #fff; margin-top: 10px;
}
.accordion > summary {
    cursor: pointer; padding: 8px 14px; font-size: 13px;
    color: var(--muted); list-style: none; user-select: none;
}
.accordion > summary::before { content: "▸ "; }
.accordion[open] > summary::before { content: "▾ "; }
.accordion-body { padding: 4px 14px 12px; }

.slider-block { margin-top: 10px; }
.slider-val { float: right; color: var(--brand-dark); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--brand); cursor: pointer; }

/* ---- 按钮 ---- */
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn {
    border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--ink);
    font-size: 14px; padding: 8px 14px; cursor: pointer;
    font-family: inherit; white-space: normal;
    transition: background 0.15s ease;
}
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: #b91c1c; border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.status-line { font-size: 12px; color: var(--muted); padding: 8px 2px 0; }

/* ---- 历史记录表格：列宽固定均分、内容换行，不撑出横向滚动条 ---- */
.history-table { overflow-x: hidden; }
.history-table table { table-layout: fixed; width: 100%; border-collapse: collapse; background: #fff; }
.history-table th, .history-table td {
    border: 1px solid var(--line); padding: 6px 8px;
    font-size: 12.5px; text-align: left; vertical-align: top;
    word-break: break-all;
}
.history-table th { background: #f8fafc; color: var(--muted); font-weight: 600; }
.history-table tbody tr { cursor: pointer; }
.history-table tbody tr:hover { background: #f0fdfa; }
.history-table tbody tr.selected { background: #ecfeff; }

/* 可点击的占位舌图 */
.tongue-box {
    border: 1px solid var(--line); border-radius: 10px; background: #fff;
    height: 340px; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.tongue-box.view { height: 240px; }
.tongue-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tongue-btn { cursor: pointer; }
.tongue-btn:hover { box-shadow: 0 0 0 3px #a5f3fc; border-radius: 10px; }

/* ---- 结果卡片 ---- */
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 14px;
}
.disease-line { font-size: 15px; color: var(--ink); margin-bottom: 10px; }
.disease-line b { color: var(--brand-dark); }
.sym-tag {
    display: inline-block; background: #ecfeff; color: #0e7490;
    border: 1px solid #a5f3fc; border-radius: 999px;
    padding: 2px 12px; margin: 3px 6px 3px 0; font-size: 13px;
}

/* ---- 组穴方案与方解 ---- */
.formula-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 14px;
}
.fx-points { display: flex; flex-wrap: wrap; gap: 10px; }
.fx-chip {
    display: inline-flex; align-items: baseline; gap: 8px;
    background: #ecfeff; border: 1px solid #a5f3fc;
    border-radius: 10px; padding: 8px 16px;
}
.fx-name { font-size: 18px; font-weight: 600; color: var(--brand-dark); }
.fx-score { font-size: 11px; color: var(--muted); }
.fx-divider { border-top: 1px dashed var(--line); margin: 12px 0 10px; }
.fx-label { font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 6px; }
.fx-text { font-size: 14px; color: var(--ink); line-height: 1.9; white-space: pre-wrap; }

.point-card {
    background: var(--card-bg); border: 1px solid var(--line);
    border-radius: 10px; padding: 14px 18px; margin-bottom: 12px;
}
.point-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.point-name { font-size: 17px; font-weight: 600; color: var(--brand-dark); }
.point-syndrome { font-size: 12px; color: var(--muted); }
.point-rationale { font-size: 14px; color: var(--ink); line-height: 1.8; white-space: pre-wrap; }
.evidence-block { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.evidence-item { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.empty-hint { color: var(--muted); font-size: 14px; padding: 12px 4px; }
.hist-count { font-size: 12px; color: var(--muted); padding: 2px 2px 6px; }

/* ---- 进度动画（组穴推荐 / 舌象分析共用） ---- */
.analyze-progress {
    background: var(--card-bg); border: 1px solid var(--line);
    border-radius: 10px; padding: 26px 22px; text-align: center;
    margin-bottom: 14px;
}
.tp-head {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 15px; font-weight: 600; color: var(--brand-dark); margin-bottom: 14px;
}
.tp-spinner {
    width: 18px; height: 18px; border: 3px solid #a5f3fc;
    border-top-color: var(--brand); border-radius: 50%;
    animation: tp-spin 0.8s linear infinite; display: inline-block;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }
.tp-stage { font-size: 14px; color: var(--ink); margin-bottom: 16px; min-height: 20px; }
.tp-bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.tp-bar-fill {
    height: 100%; background: linear-gradient(90deg, #0e7490, #155e75);
    border-radius: 999px; transition: width 0.3s ease;
}
.tp-step { font-size: 12px; color: var(--muted); }

.disclaimer {
    margin-top: 8px; padding: 6px 14px;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    color: #92400e; font-size: 11px; line-height: 1.5;
}

/* ---- 舌象分析 ---- */
.tongue-result {
    background: var(--card-bg); border: 1px solid var(--line);
    border-radius: 10px; padding: 16px 20px;
}
.tongue-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tongue-row:last-of-type { border-bottom: none; }
.tongue-label {
    flex: 0 0 64px; font-size: 13px; font-weight: 600; color: var(--brand-dark);
}
.tongue-value { flex: 1; font-size: 14px; color: var(--ink); line-height: 1.7; }
.tongue-verdict {
    margin-top: 12px; padding: 14px 18px; border-radius: 10px;
    background: linear-gradient(135deg, #0e7490 0%, #155e75 100%);
    color: #ffffff; display: flex; align-items: baseline; gap: 12px;
}
.tongue-verdict .v-label { font-size: 13px; opacity: 0.85; }
.tongue-verdict .v-text { font-size: 20px; font-weight: 600; letter-spacing: 1px; }

/* ---- Toast 提示 ---- */
#toast-root {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
    border-radius: 8px; padding: 10px 18px; font-size: 13px;
    box-shadow: 0 4px 16px #0f172a22; animation: toast-in 0.2s ease;
    max-width: 70vw;
}
.toast.info { background: #ecfeff; border: 1px solid #a5f3fc; color: var(--brand-dark); }
.toast.warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* 窄窗口（<860px）：两栏自动堆叠为单列，页面改为仅竖向滚动 */
@media (max-width: 860px) {
    body { overflow: auto; }
    .container { height: auto; min-height: 100vh; overflow-y: auto; }
    .main-row { flex-wrap: wrap; }
    .main-row > .pane { flex: 1 1 100% !important; height: auto; max-height: none; }
}
