:root{
  --teal:#0F5C4D; --teal-d:#0A4034; --teal-soft:#E7F1EE;
  --ink:#19302a; --muted:#6b7c77; --line:#e2eae8; --bg:#f4f7f6; --card:#fff;
  --green-bg:#E5F6E8; --green-fg:#1B7A34; --green-bd:#BCE5C4;
  --yellow-bg:#FFF3D2; --yellow-fg:#8A6100; --yellow-bd:#F0D585;
  --red-bg:#FDE6E9; --red-fg:#C0152F; --red-bd:#F2B4BD;
  --radius:14px; --shadow:0 1px 3px rgba(16,40,34,.08),0 4px 16px rgba(16,40,34,.05);
  --safe-top:env(safe-area-inset-top,0px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei","Hiragino Sans GB",sans-serif;
  background:var(--bg); color:var(--ink); font-size:15px; line-height:1.6;
  -webkit-font-smoothing:antialiased; padding-bottom:env(safe-area-inset-bottom,0);
}
mark{background:#fff3a8; color:inherit; border-radius:3px; padding:0 1px}

/* ===== Header ===== */
.app-head{
  position:sticky; top:0; z-index:30; background:var(--teal);
  background:linear-gradient(180deg,var(--teal) 0%,var(--teal-d) 100%);
  color:#fff; padding:calc(10px + var(--safe-top)) 14px 10px; box-shadow:var(--shadow);
}
.head-row{display:flex; align-items:flex-start; justify-content:space-between; gap:10px}
.head-title .h-line1{font-size:17px; font-weight:700; letter-spacing:.2px}
.head-title .h-line2{font-size:12px; opacity:.85; margin-top:2px}
.ai-btn{
  flex:0 0 auto; display:inline-flex; align-items:center; gap:6px;
  background:rgba(255,255,255,.16); color:#fff; text-decoration:none;
  border:1px solid rgba(255,255,255,.28); border-radius:999px;
  padding:6px 12px; font-size:13px; font-weight:600; backdrop-filter:blur(4px);
}
.ai-btn:active{background:rgba(255,255,255,.28)}
.ai-dot{width:7px;height:7px;border-radius:50%;background:#7CF2C9;box-shadow:0 0 6px #7CF2C9}

.search-wrap{position:relative; margin-top:10px}
#q{
  width:100%; border:0; border-radius:12px; padding:12px 38px 12px 14px;
  font-size:15px; background:#fff; color:var(--ink); outline:none;
  box-shadow:0 2px 8px rgba(0,0,0,.12);
}
#q::placeholder{color:#9aa8a4}
.clear-btn{position:absolute; right:6px; top:50%; transform:translateY(-50%);
  border:0; background:#e6ecea; color:#5a6b66; width:26px; height:26px; border-radius:50%;
  font-size:18px; line-height:1; cursor:pointer}

.chips{display:flex; gap:8px; margin-top:10px; overflow-x:auto; scrollbar-width:none; padding-bottom:2px}
.chips::-webkit-scrollbar{display:none}
.chip{
  flex:0 0 auto; border:1px solid rgba(255,255,255,.35); background:rgba(255,255,255,.12);
  color:#fff; border-radius:999px; padding:6px 13px; font-size:13px; font-weight:600;
  cursor:pointer; white-space:nowrap;
}
.chip.is-on{background:#fff; color:var(--teal-d); border-color:#fff}
.chip-line{background:rgba(0,0,0,.18); border-color:rgba(255,255,255,.4)}

/* ===== Main ===== */
#main{max-width:780px; margin:0 auto; padding:12px 12px 28px}

/* 专题 pinned cards */
.pinned{display:grid; gap:10px; margin-bottom:14px}
.topic-card{
  background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow);
  border-left:5px solid var(--teal); padding:13px 15px; cursor:pointer;
}
.topic-card .tc-tag{font-size:11px; font-weight:700; color:var(--teal); letter-spacing:.5px}
.topic-card .tc-title{font-size:15.5px; font-weight:700; margin:3px 0 4px}
.topic-card .tc-sub{font-size:13px; color:var(--muted)}
.topic-card .tc-go{float:right; color:var(--teal); font-weight:700; font-size:13px; margin-top:2px}

.section-label{font-size:12.5px; font-weight:700; color:var(--muted); margin:16px 4px 8px; letter-spacing:.5px}

/* 分类（浏览模式） */
.cat{background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); margin-bottom:10px; overflow:hidden}
.cat-head{display:flex; align-items:center; gap:10px; padding:13px 14px; cursor:pointer}
.cat-head .cat-no{flex:0 0 auto; width:24px; height:24px; border-radius:7px; background:var(--teal-soft);
  color:var(--teal-d); font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center}
.cat-head .cat-t{flex:1; font-size:15px; font-weight:700}
.cat-head .cat-meta{flex:0 0 auto; font-size:11.5px; color:var(--muted); display:flex; gap:4px; align-items:center}
.mini{display:inline-block; min-width:18px; text-align:center; border-radius:6px; padding:1px 5px; font-weight:700; font-size:11px}
.mini.g{background:var(--green-bg); color:var(--green-fg)}
.mini.y{background:var(--yellow-bg); color:var(--yellow-fg)}
.mini.r{background:var(--red-bg); color:var(--red-fg)}
.cat-head .chev{flex:0 0 auto; color:#b6c3bf; transition:transform .2s; font-size:13px}
.cat.open .chev{transform:rotate(90deg)}
.cat-body{display:none; padding:0 8px 8px}
.cat.open .cat-body{display:block}
.cat-intro{font-size:13px; color:var(--muted); padding:2px 8px 10px; border-top:1px dashed var(--line)}

/* 条目卡 */
.item{border-radius:11px; border:1px solid var(--line); margin:8px 0; overflow:hidden; background:#fff}
.item-head{display:flex; align-items:center; gap:10px; padding:10px 12px; cursor:pointer}
.item-name{flex:1; font-size:14.5px; font-weight:600}
.badge{flex:0 0 auto; font-size:12px; font-weight:700; border-radius:7px; padding:3px 9px; white-space:nowrap}
.badge.green{background:var(--green-bg); color:var(--green-fg); border:1px solid var(--green-bd)}
.badge.yellow{background:var(--yellow-bg); color:var(--yellow-fg); border:1px solid var(--yellow-bd)}
.badge.red{background:var(--red-bg); color:var(--red-fg); border:1px solid var(--red-bd)}
.badge.none{background:#eef2f1; color:#6b7c77; border:1px solid var(--line)}
.item-cat{font-size:11.5px; color:var(--muted); padding:0 12px 8px; margin-top:-2px}
.item-body{display:none; padding:2px 12px 12px; border-top:1px dashed var(--line)}
.item.open .item-body{display:block}
.kv{display:flex; gap:8px; margin-top:8px; font-size:13.5px}
.kv .k{flex:0 0 auto; width:60px; color:var(--teal); font-weight:700}
.kv .v{flex:1; color:#26352f}
.kv.note .k{color:#9a7a00}
.kv.note .v{color:#7a6300}
.item-edge{height:3px}
.item-edge.green{background:var(--green-fg)} .item-edge.yellow{background:var(--yellow-fg)} .item-edge.red{background:var(--red-fg)} .item-edge.none{background:#cfd9d6}

/* result meta */
.result-meta{font-size:13px; color:var(--muted); margin:2px 4px 10px}
.result-meta b{color:var(--teal-d)}

/* 红线/专题 列表项 */
.rl-item{display:flex; gap:10px; align-items:flex-start; padding:10px 12px; border:1px solid var(--red-bd);
  background:var(--red-bg); border-radius:11px; margin:8px 0}
.rl-item .rl-name{font-weight:700; color:var(--red-fg); font-size:14px}
.rl-item .rl-cat{font-size:11.5px; color:#a23; opacity:.8}
.rl-item .rl-do{font-size:13px; color:#5a2a30; margin-top:3px}

/* QA */
.qa{background:#fff; border:1px solid var(--line); border-radius:11px; margin:8px 0; padding:11px 13px}
.qa .q{font-weight:700; font-size:14.5px; color:var(--teal-d)}
.qa .a{font-size:13.5px; color:#26352f; margin-top:5px; white-space:pre-wrap}

.empty{text-align:center; color:var(--muted); padding:50px 20px}
.empty-emoji{font-size:34px; margin-bottom:8px}
.empty-sub{font-size:12.5px; margin-top:6px; opacity:.8}

/* footer */
.app-foot{max-width:780px; margin:0 auto; padding:14px 16px calc(26px + env(safe-area-inset-bottom,0))}
.disclaimer{font-size:12px; color:var(--muted); background:#fff; border:1px solid var(--line);
  border-left:4px solid var(--yellow-fg); border-radius:10px; padding:10px 12px; line-height:1.7}
.foot-meta{font-size:11px; color:#9aa8a4; text-align:center; margin-top:12px; line-height:1.7}

/* ===== Sheet (详情/专题/红线) ===== */
.sheet{position:fixed; inset:0; z-index:60}
.sheet-mask{position:absolute; inset:0; background:rgba(12,28,24,.45); backdrop-filter:blur(2px)}
.sheet-card{position:absolute; left:0; right:0; bottom:0; max-height:88vh; overflow:auto;
  background:var(--bg); border-radius:18px 18px 0 0; padding:16px 14px calc(24px + env(safe-area-inset-bottom,0));
  max-width:780px; margin:0 auto; animation:slideup .22s ease}
@keyframes slideup{from{transform:translateY(40px);opacity:.6}to{transform:translateY(0);opacity:1}}
.sheet-close{position:absolute; right:12px; top:12px; z-index:2; border:0; background:#e6ecea; color:#5a6b66;
  width:32px; height:32px; border-radius:50%; font-size:21px; line-height:1; cursor:pointer}
.sheet-title{font-size:18px; font-weight:800; color:var(--teal-d); padding-right:36px; margin-bottom:4px}
.sheet-sub{font-size:12.5px; color:var(--muted); margin-bottom:12px}
.callout{border-radius:11px; padding:11px 13px; margin:10px 0; font-size:13.5px; line-height:1.7}
.callout.warn{background:var(--red-bg); border:1px solid var(--red-bd)}
.callout.warn .ct{color:var(--red-fg); font-weight:800; margin-bottom:4px}
.callout.info{background:var(--teal-soft); border:1px solid #cfe5df}
.callout.info .ct{color:var(--teal-d); font-weight:800; margin-bottom:4px}
.callout ul{margin:4px 0 0; padding-left:18px}
.callout li{margin:3px 0}

@media (min-width:680px){
  .pinned{grid-template-columns:1fr 1fr}
  .head-title .h-line1{font-size:19px}
}

/* ============ AI 页 ============ */
.ai-body{display:flex; flex-direction:column; min-height:100vh}
.back-btn{flex:0 0 auto; color:#fff; text-decoration:none; font-size:15px; font-weight:600; padding:6px 8px; opacity:.92}
.quota-tag{flex:0 0 auto; font-size:11.5px; color:#cfe9e1; align-self:center; white-space:nowrap}
.chat{flex:1; max-width:780px; width:100%; margin:0 auto; padding:12px 12px 6px; overflow-y:auto}
.ai-note{font-size:12.5px; color:var(--muted); background:#fff; border:1px solid var(--line);
  border-left:4px solid var(--teal); border-radius:10px; padding:9px 11px; line-height:1.6; margin-bottom:12px}
.msgs{display:flex; flex-direction:column; gap:10px}
.msg{display:flex}
.msg.user{justify-content:flex-end}
.msg .bubble{max-width:85%; padding:10px 13px; border-radius:14px; font-size:14.5px; line-height:1.65; white-space:normal; word-break:break-word}
.msg.ai .bubble{background:#fff; border:1px solid var(--line); border-top-left-radius:4px}
.msg.user .bubble{background:var(--teal); color:#fff; border-top-right-radius:4px}
.msg.sys{justify-content:center}
.msg.sys .bubble{background:#fff4e5; color:#8a5a00; border:1px solid #f0d9a8; font-size:13px; max-width:92%}
.bubble .src{margin-top:8px; padding-top:7px; border-top:1px dashed var(--line); font-size:11.5px; color:var(--muted)}
.bubble .src span{display:inline-block; background:var(--teal-soft); color:var(--teal-d); border-radius:6px; padding:1px 7px; margin:2px 4px 0 0}
.bubble.typing{display:flex; gap:5px}
.bubble.typing span{width:7px;height:7px;border-radius:50%;background:#bcccc7;animation:blink 1.2s infinite}
.bubble.typing span:nth-child(2){animation-delay:.2s}.bubble.typing span:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,60%,100%{opacity:.3}30%{opacity:1}}

.composer{position:sticky; bottom:0; max-width:780px; width:100%; margin:0 auto;
  padding:8px 12px calc(10px + env(safe-area-inset-bottom,0)); background:linear-gradient(180deg,rgba(244,247,246,0),var(--bg) 22%)}
.suggests{display:flex; gap:7px; overflow-x:auto; scrollbar-width:none; padding-bottom:8px}
.suggests::-webkit-scrollbar{display:none}
.sug{flex:0 0 auto; border:1px solid var(--line); background:#fff; color:var(--teal-d); border-radius:999px;
  padding:6px 12px; font-size:12.5px; white-space:nowrap; cursor:pointer}
.composer-row{display:flex; gap:8px; align-items:flex-end; background:#fff; border:1px solid var(--line);
  border-radius:14px; padding:6px 6px 6px 12px; box-shadow:var(--shadow)}
#input{flex:1; border:0; outline:none; resize:none; font-size:15px; line-height:1.5; max-height:120px; font-family:inherit; padding:6px 0; background:transparent}
.send-btn{flex:0 0 auto; border:0; background:var(--teal); color:#fff; border-radius:10px; padding:9px 16px; font-size:14px; font-weight:700; cursor:pointer}
.send-btn:disabled{opacity:.5}

/* 登录遮罩 */
.login-mask{position:fixed; inset:0; z-index:80; background:rgba(12,28,24,.5); backdrop-filter:blur(3px); display:flex; align-items:flex-end; justify-content:center}
.login-card{background:var(--bg); border-radius:18px 18px 0 0; width:100%; max-width:480px; padding:22px 18px calc(26px + env(safe-area-inset-bottom,0)); animation:slideup .22s ease}
.login-title{font-size:18px; font-weight:800; color:var(--teal-d)}
.login-sub{font-size:13px; color:var(--muted); margin:5px 0 16px}
.phone-form{display:flex; flex-direction:column; gap:10px}
.phone-form input{border:1px solid var(--line); border-radius:11px; padding:12px 14px; font-size:16px; outline:none; background:#fff}
.phone-form input:focus{border-color:var(--teal)}
.login-btn{border:0; background:var(--teal); color:#fff; border-radius:11px; padding:13px; font-size:16px; font-weight:700; cursor:pointer}
.login-err{color:var(--red-fg); font-size:13px; min-height:16px}
.login-tip{font-size:12px; color:var(--muted); text-align:center}
.ding-area{display:flex; flex-direction:column; align-items:center; gap:12px; padding:24px; color:var(--muted)}
.ding-spin{width:30px;height:30px;border:3px solid #d6e4e0;border-top-color:var(--teal);border-radius:50%;animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ============ 管理后台 ============ */
.admin-wrap{max-width:920px; margin:0 auto; padding:14px 12px 40px}
.admin-tabs{display:flex; gap:8px; margin-bottom:14px}
.admin-tabs button{flex:1; border:1px solid var(--line); background:#fff; border-radius:10px; padding:10px; font-size:14px; font-weight:600; color:var(--muted); cursor:pointer}
.admin-tabs button.on{background:var(--teal); color:#fff; border-color:var(--teal)}
.card{background:#fff; border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); padding:14px; margin-bottom:14px}
.card h3{margin:0 0 12px; font-size:15px; color:var(--teal-d)}
.utable{width:100%; border-collapse:collapse; font-size:13px}
.utable th,.utable td{text-align:left; padding:8px 6px; border-bottom:1px solid var(--line)}
.utable th{color:var(--muted); font-weight:600; font-size:12px}
.tag{font-size:11px; border-radius:6px; padding:2px 7px; font-weight:700}
.tag.admin{background:#e6e0ff; color:#5b3fd0}.tag.doctor{background:var(--teal-soft); color:var(--teal-d)}
.tag.active{background:var(--green-bg); color:var(--green-fg)}.tag.disabled{background:var(--red-bg); color:var(--red-fg)}
.uact{border:1px solid var(--line); background:#fff; border-radius:7px; padding:4px 9px; font-size:12px; cursor:pointer; margin-right:4px}
.frm label{display:block; font-size:13px; color:var(--muted); margin:10px 0 4px}
.frm input,.frm textarea{width:100%; border:1px solid var(--line); border-radius:9px; padding:9px 11px; font-size:14px; outline:none; font-family:inherit}
.frm .save{margin-top:14px; border:0; background:var(--teal); color:#fff; border-radius:10px; padding:11px 20px; font-size:14px; font-weight:700; cursor:pointer}
.frm .row2{display:flex; gap:10px}.frm .row2>div{flex:1}
.admin-msg{font-size:13px; padding:8px 0; min-height:18px}
.admin-msg.ok{color:var(--green-fg)}.admin-msg.err{color:var(--red-fg)}
