/* ===== 中医Buddy · 视觉风格 ===== */
:root {
  --paper: #f4ecdc;
  --paper-2: #fbf6ea;
  --card: #fffdf7;
  --ink: #2c2620;
  --ink-soft: #6b5f4e;
  --ink-faint: #9a8c76;
  --line: #e3d6bf;
  --jade: #2f6b5e;
  --jade-soft: #e2efe9;
  --gold: #b5892f;
  --gold-soft: #f6ecd6;
  --red: #b23a36;
  --shadow: 0 6px 24px rgba(60, 45, 25, 0.10);
  --radius: 16px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
html[data-theme="dark"] {
  --paper: #16140f;
  --paper-2: #1d1a14;
  --card: #242019;
  --ink: #ece3d2;
  --ink-soft: #b6a98f;
  --ink-faint: #8a7c64;
  --line: #3a3328;
  --jade: #6fc2a8;
  --jade-soft: #1e3a33;
  --gold: #d9b25e;
  --gold-soft: #3a3120;
  --red: #e0736c;
  --shadow: 0 8px 30px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; min-height: 100vh; }

/* ===== 侧边导航 ===== */
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--jade), var(--gold));
  color: #fff; font-family: var(--serif); font-size: 26px; font-weight: 700;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-title { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: 2px; }
.brand-sub { font-size: 12px; color: var(--ink-faint); letter-spacing: 1px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border: none; background: transparent;
  color: var(--ink-soft); font-size: 15px; font-family: var(--sans);
  border-radius: 11px; cursor: pointer; text-align: left; transition: .18s;
}
.nav-item .nav-ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--jade-soft); color: var(--ink); }
.nav-item.active { background: var(--jade); color: #fff; box-shadow: var(--shadow); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.theme-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 17px; }
.foot-note { font-size: 11px; color: var(--ink-faint); }

/* ===== 主区 ===== */
.main { flex: 1; min-width: 0; padding: 28px 34px 60px; max-width: 1180px; }
.view { display: none; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 20px; position: relative; }
.view-head h1 { font-family: var(--serif); font-size: 28px; letter-spacing: 2px; }
.view-desc { color: var(--ink-faint); font-size: 14px; flex: 1; min-width: 200px; }
.ghost-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); padding: 7px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.ghost-btn:hover { border-color: var(--jade); color: var(--jade); }

/* ===== 问诊进度条 ===== */
.diag-progress { display: flex; align-items: flex-start; gap: 2px; max-width: 820px; margin: 0 0 18px; overflow-x: auto; padding-bottom: 4px; }
.dp-step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 0; min-width: 50px; text-align: center; }
.dp-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; border: 2px solid var(--line); background: var(--card); color: var(--ink-faint); transition: .2s; }
.dp-lbl { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.dp-step.cur .dp-dot { border-color: var(--jade); background: var(--jade); color: #fff; }
.dp-step.cur .dp-lbl { color: var(--jade); font-weight: 600; }
.dp-step.done .dp-dot { border-color: var(--jade); background: var(--jade-soft); color: var(--jade); }
.dp-line { flex: 1 1 0; height: 2px; background: var(--line); margin-top: 12px; min-width: 8px; }
.dp-step.done + .dp-line { background: var(--jade); }

/* ===== 问诊历史 ===== */
.diag-history { max-width: 820px; margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.diag-history .hist-title { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.hist-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: .12s; border: 1px solid transparent; }
.hist-item:hover { background: var(--jade-soft); border-color: var(--line); }
.hist-item .hi-main { font-size: 14px; }
.hist-item .hi-main b { color: var(--jade); }
.hist-item .hi-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ===== 问诊聊天 ===== */
.chat { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.bubble { max-width: 88%; padding: 14px 18px; border-radius: 16px; font-size: 15px; }
.bubble.bot { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow); white-space: pre-wrap; }
.bubble.bot .q-title { font-family: var(--serif); font-weight: 700; color: var(--jade); display: block; margin-bottom: 6px; font-size: 16px; }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--jade), #3c8170); color: #fff; border-bottom-right-radius: 4px; }
.options { display: flex; flex-wrap: wrap; gap: 9px; max-width: 820px; }
.opt {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 11px 15px; border-radius: 12px; cursor: pointer; font-size: 14px;
  transition: .15s; text-align: left; flex: 0 0 auto;
}
.opt:hover { border-color: var(--jade); background: var(--jade-soft); transform: translateY(-1px); }
.opt.selected { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); font-weight: 600; }
.opt .opt-emoji { margin-right: 6px; }
.opt .opt-desc { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.primary-btn {
  background: linear-gradient(135deg, var(--jade), #3c8170); color: #fff; border: none;
  padding: 12px 22px; border-radius: 12px; font-size: 15px; cursor: pointer; font-weight: 600;
  box-shadow: var(--shadow); align-self: flex-start;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }
.chat-input { margin-top: 18px; max-width: 820px; }

/* ===== 结果卡片 ===== */
.result-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 860px; }
.meridian-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 14px; }
.result-title { font-family: var(--serif); font-size: 24px; margin: 16px 0 4px; letter-spacing: 1px; }
.result-sub { color: var(--ink-soft); font-size: 15px; }
.result-pattern { background: var(--jade-soft); border-left: 4px solid var(--jade); padding: 12px 16px; border-radius: 10px; margin: 16px 0; font-size: 15px; color: var(--ink); }
.confidence { margin: 14px 0; }
.confidence .bar { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.confidence .fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--jade)); border-radius: 999px; }
.confidence .lbl { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.section-h { font-family: var(--serif); font-size: 17px; color: var(--jade); margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); display: flex; align-items: center; gap: 8px; }
.formula-name { font-family: var(--serif); font-size: 22px; color: var(--red); font-weight: 700; }
.compo-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.compo-table th, .compo-table td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; }
.compo-table th { color: var(--ink-faint); font-weight: 600; font-size: 12px; }
.compo-table .role { color: var(--gold); font-size: 12px; }
.note-box { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 14px; margin: 10px 0; }
.note-box.warn { border-color: var(--red); background: rgba(178,58,54,0.06); }
.note-box.warn .section-h, .note-box.warn b { color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.chip { background: var(--gold-soft); color: var(--ink); padding: 4px 11px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--line); }
.dif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dif-col { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.dif-col h4 { font-family: var(--serif); color: var(--jade); margin-bottom: 6px; font-size: 16px; }
.care-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.care-col h4 { font-size: 14px; color: var(--gold); margin-bottom: 5px; }
.copy-btn { margin-top: 18px; background: var(--ink); color: var(--paper); border: none; padding: 11px 20px; border-radius: 11px; cursor: pointer; font-size: 14px; }

/* ===== 查询 ===== */
.search-bar { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search-bar input, .search-bar select {
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--card); color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.search-bar input { flex: 1; min-width: 240px; }
.split { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.list-panel, .detail-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.list-panel { max-height: 70vh; overflow-y: auto; }
.detail-panel { padding: 22px 26px; min-height: 200px; }
.list-item { padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: .12s; }
.list-item:hover { background: var(--jade-soft); }
.list-item.active { background: var(--jade-soft); border-left: 4px solid var(--jade); }
.list-item .li-title { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.list-item .li-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.empty-hint { color: var(--ink-faint); text-align: center; padding: 60px 20px; font-size: 14px; }
.detail-panel h2 { font-family: var(--serif); font-size: 24px; margin-bottom: 4px; }
.detail-panel .meta { color: var(--gold); font-size: 13px; margin-bottom: 14px; }
.detail-panel p { margin: 8px 0; font-size: 14.5px; }
.detail-panel .label { color: var(--jade); font-weight: 600; font-family: var(--serif); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); padding: 9px 18px; border-radius: 11px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--jade); color: #fff; border-color: var(--jade); }

/* ===== 工具 ===== */
.tool-panel { max-width: 860px; }
.tool-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; }
.tool-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.tool-row label { font-size: 13px; color: var(--ink-soft); min-width: 70px; }
.tool-row input, .tool-row select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); color: var(--ink); font-size: 14px; }
.tool-result { background: var(--jade-soft); border-radius: 14px; padding: 20px; margin-top: 14px; }
.tool-result .big { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--jade); }
.dose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; margin: 10px 0; }
.dose-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.dose-card .dc-name { font-family: var(--serif); font-size: 18px; color: var(--jade); }
.dose-card .dc-val { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
table.ref-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
table.ref-table th, table.ref-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }

/* ===== 表格横向滚动（移动端） ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; }
.table-scroll table { width: 100%; }

/* ===== 移动端底部导航 ===== */
.bottom-nav { display: none; }

/* ===== 触摸优化 ===== */
button, .opt, .tab, .nav-item, .bn-item, .list-item, .ghost-btn, .primary-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ===== 响应式 ===== */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .main { padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); max-width: 100%; }
  .view-head { margin-bottom: 14px; }
  .view-head h1 { font-size: 22px; letter-spacing: 1px; }
  .view-desc { flex-basis: 100%; }
  #restartBtn { width: 100%; text-align: center; }

  /* 底部导航 */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 22px rgba(60,45,25,.12);
    padding: 5px 2px calc(5px + env(safe-area-inset-bottom));
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: transparent; border: none; cursor: pointer; padding: 5px 1px;
    color: var(--ink-faint); font-family: var(--sans); font-size: 10.5px; line-height: 1.2;
  }
  .bn-item .bn-ico { font-size: 20px; line-height: 1.1; }
  .bn-item.active { color: var(--jade); }
  .bn-item.active .bn-ico { transform: translateY(-1px); }
  .bn-theme { flex: 0 0 52px; }

  /* 搜索与查询 */
  .search-bar { flex-direction: column; gap: 10px; }
  .search-bar input, .search-bar select { width: 100%; min-width: 0; font-size: 16px; }
  .split { grid-template-columns: 1fr; gap: 12px; }
  .list-panel { max-height: 40vh; }
  .detail-panel { padding: 18px 15px; }

  /* 聊天 / 选项 */
  .bubble { max-width: 94%; font-size: 15px; padding: 12px 15px; }
  .options { gap: 8px; }
  .opt { flex: 1 1 100%; padding: 12px 15px; font-size: 15px; }

  /* 结果卡片 */
  .result-card { padding: 18px 15px; }
  .result-title { font-size: 21px; }
  .dif-grid, .care-grid { grid-template-columns: 1fr; }
  .compo-table th, .compo-table td, .ref-table th, .ref-table td { padding: 8px 9px; font-size: 13px; }

  /* 工具 */
  .tool-card { padding: 18px 15px; }
  .tool-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .tool-row label { min-width: 0; }
  .tool-row input, .tool-row select { width: 100%; font-size: 16px; }
  .tool-result .big { font-size: 24px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  input[type="date"], input[type="time"], input[type="number"], input[type="search"] { font-size: 16px; }
}
