/* 岐黄医学助手 · 移动端网站端 v1.2 —— 简洁版布局 + 文档阅读结构 */
:root {
  --paper: #F4F0E6;
  --paper-2: #EAE4D6;
  --ink: #1E2421;
  --ink-2: #5A655F;
  --ink-3: #8A938D;
  --green: #14493B;
  --green-2: #1C6150;
  --clay: #B4532F;
  --line: #DCD5C4;
  --white: #FFFDF8;
  --danger: #B23A3A;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(30, 36, 33, .07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 96px;
  background-image: linear-gradient(180deg, rgba(20, 73, 59, .05), rgba(244, 240, 230, 0) 240px);
}

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(244, 240, 230, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(220, 213, 196, .6);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  background: var(--green);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
  font-weight: 700;
}

.brand-name {
  font-family: Georgia, "Songti SC", serif;
  font-size: 16px;
  letter-spacing: .02em;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.btn-ghost:active { background: var(--paper-2); }

.back-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--green);
  text-decoration: none;
  padding-bottom: 2px;
}

/* ---------------------------------------------------------------- 首页搜索 */
.hero {
  padding: 16px 0 6px;
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px 0 14px;
  box-shadow: var(--shadow);
}

.hero-search svg { flex: 0 0 18px; color: var(--ink-3); }

.hero-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15px;
  line-height: 46px;
  height: 46px;
  color: var(--ink);
  font-family: inherit;
}

.hero-search input::placeholder { color: var(--ink-3); }

.hero-search .go {
  flex: 0 0 auto;
  border: 0;
  background: var(--green);
  color: var(--paper);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}

/* ---------------------------------------------------------------- 授权状态 */
.auth-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  padding: 2px 4px 10px;
}

.auth-line .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-2);
  flex: 0 0 6px;
}

.auth-line strong { color: var(--green); font-weight: 600; }

.auth-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(180, 83, 47, .08);
  border: 1px solid rgba(180, 83, 47, .25);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0 12px;
}

.auth-alert p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--clay);
}

.auth-alert .btn-mini {
  flex: 0 0 auto;
  background: var(--clay);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
}

/* ---------------------------------------------------------------- 筛选标签 */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
  font-weight: 600;
}

/* ---------------------------------------------------------------- 栏目区 */
.cat-section { margin-top: 6px; }

.cat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 2px 8px;
}

.cat-head span:first-child {
  font-family: Georgia, "Songti SC", serif;
  font-size: 14px;
  color: var(--green);
  letter-spacing: .02em;
}

.cat-head .cat-total {
  font-size: 11px;
  color: var(--ink-3);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 13px;
  text-decoration: none;
  color: var(--ink);
  min-height: 58px;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.cat-card:active { transform: scale(.97); border-color: var(--green); }

.cat-card .name {
  font-size: 14.5px;
  line-height: 1.35;
  word-break: break-word;
}

.cat-card .count {
  flex: 0 0 auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  color: var(--clay);
  background: rgba(180, 83, 47, .08);
  border-radius: 6px;
  padding: 3px 6px;
}

/* ---------------------------------------------------------------- 卡片 / 表单 */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }

.section-title {
  font-family: Georgia, "Songti SC", serif;
  font-size: 14px;
  color: var(--green);
  margin: 22px 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .04em;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}

.field input:focus { border-color: var(--green); background: var(--white); }

.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  outline: none;
  resize: vertical;
  word-break: break-all;
  font-family: Consolas, "Courier New", monospace;
}

.field textarea:focus { border-color: var(--green); background: var(--white); }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--green);
  color: var(--paper);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .04em;
}

.btn:active { background: var(--green-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn-sm { width: auto; padding: 10px 14px; font-size: 13px; }

.btn-outline {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
}

.msg {
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
  color: var(--ink-2);
}

.msg.error { color: var(--danger); }
.msg.ok { color: var(--green); }

/* ---------------------------------------------------------------- 设备码 */
.code-card {
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

.code-label {
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--ink-2);
  text-transform: uppercase;
}

.code-val {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.code-val span {
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--green);
  word-break: break-all;
}

.code-val .is-loading,
.code-val .is-error { color: var(--ink-2); font-weight: 400; font-size: 13px; }
.code-val .is-error { color: var(--danger); cursor: pointer; }

.copy {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.code-tip {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.7;
  margin: 10px 0 0;
}

/* ---------------------------------------------------------------- 列表 */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
  padding: 2px 4px 10px;
  letter-spacing: .03em;
}

.list-page { font-family: Consolas, monospace; color: var(--clay); }

.list {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.list:empty { display: none; }

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.list-row:last-child { border-bottom: 0; }
.list-row:active { background: var(--paper); }

.row-main { flex: 1; min-width: 0; }

.row-title {
  font-size: 15px;
  line-height: 1.42;
  color: var(--ink);
  word-break: break-word;
}

.row-sub {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-arrow { color: var(--line); font-size: 16px; flex: 0 0 auto; }

.tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-solid { background: rgba(20, 73, 59, .1); color: var(--green); }
.tag-seq { font-family: Consolas, monospace; color: var(--clay); }

/* 加载骨架 */
.sk-row {
  height: 66px;
  border-bottom: 1px solid var(--line);
  padding: 16px 14px;
  background: linear-gradient(90deg, var(--white) 25%, #F6F2E8 37%, var(--white) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
}

.sk-row:last-child { border-bottom: 0; }

.sk-line { height: 10px; border-radius: 5px; background: var(--paper-2); margin-bottom: 8px; }
.sk-line.w60 { width: 60%; }
.sk-line.w90 { width: 90%; }

@keyframes sk {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ---------------------------------------------------------------- 详情 */
.detail-head { padding: 16px; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.detail-title {
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
  line-height: 1.45;
  color: var(--green);
  margin: 12px 0 0;
  word-break: break-word;
}

.detail-sub {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 8px 0 0;
}

.kv {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}

.kv:last-child { border-bottom: 0; padding-bottom: 0; }
.kv:first-child { padding-top: 0; }

.kv-k {
  flex: 0 0 82px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .02em;
  padding-top: 2px;
}

.kv-v {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.72;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
}

.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; color: var(--ink-2); }

.fold {
  border-bottom: 1px dashed var(--line);
  padding: 11px 0;
}

.fold:last-child { border-bottom: 0; padding-bottom: 0; }

.fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--green);
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.fold summary::-webkit-details-marker { display: none; }

.fold-hint { font-size: 11px; color: var(--ink-2); font-weight: 400; }
.fold[open] .fold-hint { color: var(--clay); }

.fold pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ---------------------------------------------------------------- 文档阅读（详情页） */
.read-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--clay);
  z-index: 60;
  transition: width .12s linear;
}

.doc-toc { margin: 16px 0 2px; }

.doc-toc-label {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-3);
  padding: 0 2px 6px;
}

.doc-links {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.doc-links::-webkit-scrollbar { display: none; }

.doc-links a {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.doc-links a.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
  font-weight: 600;
}

.doc-sec {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 15px;
  margin-top: 10px;
  scroll-margin-top: 76px;
}

.doc-sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--green);
  letter-spacing: .02em;
}

.doc-sec-title::before {
  content: "";
  flex: 0 0 3px;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--clay);
}

.doc-body {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 9px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  list-style: none;
}

.doc-fold summary::-webkit-details-marker { display: none; }
.doc-fold[open] summary { color: var(--clay); border-color: rgba(180, 83, 47, .3); }

.doc-fold pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, .96);
  color: var(--green);
  font-size: 16px;
  font-family: inherit;
  box-shadow: 0 6px 18px rgba(30, 36, 33, .12);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 31;
}

.to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ---------------------------------------------------------------- 搜索 */
.searchbar {
  display: flex;
  gap: 8px;
  margin: 12px 0 8px;
}

.searchbar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  box-shadow: var(--shadow);
}

.searchbar input:focus { border-color: var(--green); }
.searchbar .btn { width: auto; border-radius: 999px; padding: 0 18px; }

.search-scope {
  font-size: 12px;
  color: var(--ink-2);
  padding: 0 4px 8px;
}

.search-scope a { color: var(--clay); text-decoration: none; }

/* ---------------------------------------------------------------- 底部导航 */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: calc(100% - 32px);
  max-width: 488px;
  background: rgba(255, 253, 248, .96);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  box-shadow: 0 10px 30px rgba(30, 36, 33, .14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  z-index: 30;
}

.tabbar a {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}

.tabbar a.active { color: var(--green); font-weight: 700; }

/* ---------------------------------------------------------------- 提示与页脚 */
.notice {
  border-left: 3px solid var(--clay);
  background: rgba(180, 83, 47, .06);
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-top: 12px;
}

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  padding: 24px 0 8px;
  line-height: 1.8;
}


/* ---------------------------------------------------------------- 详情页配图（v1.3） */
.doc-img-card {
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
  background: #EFEAE0;
}

.doc-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 58vh;
  object-fit: contain;
}
