/* 律问 · 样式（暖纸 / 墨蓝，夜间模式切换） */
:root {
  --bg: #f6f4ef; --card: #fffdf8; --card2: #f0ede4;
  --ink: #2c2a25; --ink2: #6b675e; --line: #e4dfd3;
  --accent: #2b5aa0; --accent2: #1d4680; --gold: #a8842c;
  --ok: #2e7d4f; --warn: #b05a2a; --shadow: 0 1px 3px rgba(60,55,40,.08);
}
body.dark {
  --bg: #17181b; --card: #1f2126; --card2: #262931;
  --ink: #d9d6cf; --ink2: #8f8c85; --line: #31343c;
  --accent: #7ba3e0; --accent2: #5a86c4; --gold: #c9a24d;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.75 "Noto Serif SC", "Songti SC", "SimSun", serif;
  display: flex; flex-direction: column;
}

/* ---------- header ---------- */
header {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
  background: var(--card); position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 21px; font-weight: 700; letter-spacing: 1px; }
.brand .sub { font-size: 12.5px; color: var(--ink2); margin-left: 9px; font-weight: 400; letter-spacing: 2px; }
nav { display: flex; gap: 6px; margin-left: 8px; }
.tab-btn {
  border: none; background: none; color: var(--ink2); font: inherit; font-size: 15px;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ghost-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink2);
  border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }

main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px 22px 30px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- 问答布局 ---------- */
.ask-grid.active { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }
.chat-col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.chat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  min-height: 52vh; max-height: calc(100vh - 250px); overflow-y: auto; padding: 20px; box-shadow: var(--shadow);
}
.welcome h2 { margin: 12vh 0 6px; text-align: center; font-size: 22px; }
.welcome p { text-align: center; color: var(--ink2); margin: 0 auto; max-width: 480px; }
.suggests { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-top: 26px; }
.suggests button {
  border: 1px solid var(--line); background: var(--card2); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.suggests button:hover { border-color: var(--accent); color: var(--accent); }

.msg { margin-bottom: 18px; }
.msg .who { font-size: 12.5px; color: var(--ink2); margin-bottom: 4px; letter-spacing: 1px; }
.msg.user .bubble { background: var(--accent); color: #fff; margin-left: 15%; border-radius: 12px 12px 3px 12px; }
.msg.assistant .bubble { background: var(--card2); border-radius: 12px 12px 12px 3px; }
.bubble { padding: 12px 16px; line-height: 1.85; word-break: break-word; }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0 10px; padding-left: 22px; }
.bubble .h { font-weight: 700; }
.bubble strong { color: var(--accent2); }
.bubble.cursor::after { content: "▌"; color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.cite { color: var(--gold); text-decoration: none; border-bottom: 1px dashed var(--gold); cursor: pointer; }
.cite:hover { color: var(--accent); border-color: var(--accent); }

.composer { display: flex; gap: 10px; align-items: flex-end; }
textarea#q {
  flex: 1; resize: none; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; max-height: 140px;
}
textarea#q:focus { outline: 2px solid var(--accent); border-color: transparent; }
button.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 11px 26px; font: inherit; font-size: 15.5px; cursor: pointer; letter-spacing: 2px;
}
button.primary:disabled { opacity: .55; cursor: wait; }
.disclaimer { text-align: center; color: var(--ink2); font-size: 12.5px; margin: 2px 0 0; }

/* ---------- 法条面板 ---------- */
.hits-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  position: sticky; top: 76px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.hits-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; letter-spacing: 1px;
}
.hits { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.hits-empty { color: var(--ink2); text-align: center; margin: 30px 0; font-size: 14px; }
.hit-card {
  border: 1px solid var(--line); background: var(--card2); border-radius: 10px; padding: 10px 12px;
}
.hit-card.flash { outline: 2px solid var(--gold); }
.hit-title { font-weight: 700; font-size: 14.5px; cursor: pointer; }
.hit-badges { margin: 5px 0; display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.badge.gold { background: color-mix(in srgb, var(--gold) 13%, transparent); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }
.badge.ghost { background: var(--card2); color: var(--ink2); border-color: var(--line); }
.score-bar { height: 3px; border-radius: 2px; background: var(--line); margin: 7px 0; }
.score-bar i { display: block; height: 100%; border-radius: 2px; background: var(--gold); }
.hit-text { font-size: 13.5px; color: var(--ink2); line-height: 1.7; cursor: pointer; }
.hit-text.expanded { color: var(--ink); }
.hit-text.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hit-text mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; padding: 0 1px; }

/* ---------- 法条库 ---------- */
.laws-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.laws-side {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; position: sticky; top: 76px; max-height: calc(100vh - 130px); overflow-y: auto; box-shadow: var(--shadow);
}
.laws-side input {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: var(--card2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin-bottom: 12px;
}
.dept-list { display: flex; flex-direction: column; gap: 4px; }
.dept-item {
  text-align: left; border: none; background: none; color: var(--ink2); font: inherit;
  font-size: 14px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 6px;
}
.dept-item:hover { background: var(--card2); }
.dept-item.active { background: var(--accent); color: #fff; }
.dept-item .cnt { font-size: 12px; opacity: .75; }
.laws-main-head { margin: 2px 4px 12px; color: var(--ink2); font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.law-card, .article-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.law-card { cursor: pointer; }
.law-card:hover { border-color: var(--accent); }
.law-card h4 { margin: 0 0 6px; font-size: 15.5px; }
.law-card .meta { color: var(--ink2); font-size: 12.5px; margin-top: 6px; }
.article-card { font-size: 14.5px; }
.article-card .no { font-weight: 700; color: var(--accent2); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.article-card .txt { white-space: pre-wrap; color: var(--ink); }
.article-card .txt mark { background: color-mix(in srgb, var(--gold) 32%, transparent); color: inherit; }
.laws-pager { text-align: center; color: var(--ink2); font-size: 13px; padding: 8px 0 20px; }

/* ---------- modal / toast ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,18,12,.45); display: grid; place-items: center; z-index: 50; }
.modal {
  background: var(--card); border-radius: 16px; padding: 28px 30px; width: min(92vw, 380px);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 6px; }
.modal p { margin: 0 0 14px; }
.modal input {
  width: 100%; font: inherit; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card2); color: var(--ink); margin-bottom: 12px;
}
.muted { color: var(--ink2); font-size: 13.5px; }
.err { color: #c0392b !important; font-size: 13px; margin: -6px 0 10px !important; }
#toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 20px; border-radius: 999px;
  font-size: 14px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

/* ---------- 移动端 ---------- */
.only-mobile { display: none; }
@media (max-width: 960px) {
  .ask-grid.active { display: flex; flex-direction: column; }
  .only-mobile { display: inline-block; }
  header { padding: 10px 14px; gap: 10px; }
  .brand .sub { display: none; }
  main { padding: 12px 12px 90px; }
  .chat { min-height: 46vh; max-height: none; }
  .hits-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    max-height: 62vh; border-radius: 18px 18px 0 0; transform: translateY(105%);
    transition: transform .25s ease; box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  }
  .hits-panel.open { transform: translateY(0); }
  .hits-fab {
    position: fixed; right: 16px; bottom: 18px; z-index: 39;
    border: none; border-radius: 999px; padding: 11px 18px; font: inherit; font-size: 14px;
    background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.3); cursor: pointer;
  }
  .laws-grid { grid-template-columns: 1fr; }
  .laws-side { position: static; max-height: none; }
  .msg.user .bubble { margin-left: 0; }
}
