:root {
  --navy: #173f63;
  --navy-deep: #0f2d47;
  --blue: #276b9e;
  --blue-soft: #eaf3f9;
  --paper: #f5f7f8;
  --white: #ffffff;
  --ink: #152433;
  --muted: #627181;
  --line: #dce4ea;
  --green: #2b8a65;
  --green-soft: #e6f5ef;
  --amber: #c67b21;
  --amber-soft: #fff3df;
  --shadow: 0 20px 55px rgba(28, 55, 78, 0.1);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(39, 107, 158, 0.11), transparent 30rem),
    linear-gradient(180deg, #f8fafb 0%, #edf2f5 100%);
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1460px, calc(100% - 48px));
  margin: 0 auto;
  padding: 20px 0 16px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 6px 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: linear-gradient(145deg, var(--navy), #2c78ad);
  box-shadow: 0 10px 20px rgba(23, 63, 99, 0.22);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand h1 { margin: 3px 0 0; font-size: 23px; line-height: 1.25; letter-spacing: 0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfe6dc;
  border-radius: 999px;
  padding: 8px 13px;
  color: #276d54;
  background: #f0faf6;
  font-size: 13px;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #29a575; box-shadow: 0 0 0 4px rgba(41,165,117,.12); }
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
}
.ghost-button:hover { color: var(--navy); border-color: #b7c8d5; }
.admin-entry {
  border: 1px solid #c8d8e3;
  border-radius: 10px;
  padding: 8px 13px;
  color: var(--navy);
  background: rgba(255,255,255,.86);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.admin-entry:hover { border-color: #91b4ca; background: #f4f9fc; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(340px, 0.85fr);
  gap: 20px;
  align-items: stretch;
}

.chat-card, .side-card {
  border: 1px solid rgba(210, 220, 228, 0.86);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}
.chat-card {
  min-height: calc(100vh - 142px);
  max-height: 820px;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  border-radius: 22px;
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 17px;
  border-bottom: 1px solid var(--line);
}
.chat-head h2, .side-heading h2 { margin: 3px 0 0; font-size: 19px; }
.online-label { display: inline-flex; align-items: center; gap: 7px; color: #347157; font-size: 12px; }
.online-label span { width: 8px; height: 8px; border-radius: 50%; background: #35a77a; }

.messages {
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(246, 249, 251, 0.88), rgba(246, 249, 251, 0.88)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(31, 78, 120, 0.035) 32px);
}
.message { display: flex; gap: 10px; margin-bottom: 20px; align-items: flex-start; animation: rise .22s ease-out; }
.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(145deg, var(--navy), #347fae);
  font-weight: 800;
  font-size: 14px;
}
.user-message { justify-content: flex-end; }
.user-avatar { color: var(--navy); background: #dfeaf1; }
.message-content { max-width: min(690px, 82%); }
.user-message .message-content { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  padding: 14px 16px;
  border: 1px solid #d9e3ea;
  border-radius: 6px 17px 17px 17px;
  color: #273746;
  background: white;
  box-shadow: 0 8px 22px rgba(44, 74, 98, 0.06);
  line-height: 1.68;
  font-size: 14px;
}
.bubble p { margin: 0; }
.bubble p + p { margin-top: 7px; }
.message-title { color: var(--navy); font-weight: 800; }
.user-message .bubble { color: white; border-color: var(--navy); border-radius: 17px 6px 17px 17px; background: var(--navy); }
.message-time { display: block; margin-top: 5px; color: #93a0ac; font-size: 11px; }

.answer-summary { color: var(--ink); font-weight: 700; }
.answer-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid #e7edf1; }
.answer-label { display: block; margin-bottom: 7px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.flow li { display: inline-flex; align-items: center; gap: 6px; }
.flow li:not(:last-child)::after { content: "→"; color: #91a1ad; font-weight: 500; }
.flow span { display: inline-block; padding: 5px 8px; border-radius: 8px; color: var(--navy); background: var(--blue-soft); font-size: 12px; }
.flow li:last-child span { color: #246c51; background: var(--green-soft); font-weight: 800; }
.source-line { margin-top: 12px !important; color: #778693; font-size: 11px; }
.warning-line { margin-top: 10px !important; padding: 8px 10px; border-radius: 9px; color: #8b5a1e; background: var(--amber-soft); font-size: 12px; }
.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid #cfe0ec;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  background: #f6fbfe;
  transition: .18s ease;
}
.file-card:hover { transform: translateY(-1px); border-color: #8eb7d2; box-shadow: 0 8px 18px rgba(45, 101, 141, .09); }
.file-type { display: grid; place-items: center; width: 38px; height: 42px; border-radius: 9px; color: white; background: #2c6fa0; font-size: 10px; font-weight: 800; }
.file-copy { min-width: 0; flex: 1; }
.file-copy strong, .file-copy small { display: block; }
.file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-copy small { margin-top: 3px; color: #71818e; font-size: 11px; }
.download-mark { color: var(--blue); font-size: 18px; }

.typing .bubble { display: flex; gap: 5px; padding: 15px 18px; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #8aa1b1; animation: pulse 1s infinite; }
.typing-dot:nth-child(2) { animation-delay: .14s; }
.typing-dot:nth-child(3) { animation-delay: .28s; }

.quick-zone { padding: 11px 20px 13px; border-top: 1px solid #e6edf2; background: white; }
.quick-label { display: block; margin: 0 0 8px 4px; color: #7d8a96; font-size: 11px; }
.quick-list { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.quick-list button {
  flex: 0 0 auto;
  border: 1px solid #d6e1e9;
  border-radius: 999px;
  padding: 7px 11px;
  color: #3d596d;
  background: #f8fbfc;
  font-size: 12px;
}
.quick-list button:hover { color: var(--navy); border-color: #9fbdd1; background: var(--blue-soft); }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px 20px 7px; background: white; }
.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  border: 1px solid #cbd8e2;
  border-radius: 13px;
  padding: 13px 14px;
  outline: none;
  color: var(--ink);
  background: #fbfcfd;
  line-height: 1.5;
}
.composer textarea:focus { border-color: #5892b9; box-shadow: 0 0 0 3px rgba(39, 107, 158, .1); }
.send-button {
  align-self: stretch;
  min-width: 86px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, var(--navy), #2d76a9);
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(23, 63, 99, .18);
}
.send-button:hover { filter: brightness(1.05); }
.composer-note { margin: 0; padding: 0 23px 14px; color: #8a97a2; background: white; font-size: 10px; }

.side-panel { display: flex; flex-direction: column; gap: 14px; }
.side-card { border-radius: 19px; padding: 19px; }
.side-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.side-heading.compact { margin-bottom: 10px; }
.mini-badge { padding: 4px 7px; border-radius: 6px; color: #596d7c; background: #edf2f5; font-size: 10px; }
.service-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.service-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 69px;
  padding: 10px;
  border: 1px solid #e0e7ec;
  border-radius: 13px;
  color: var(--ink);
  text-align: left;
  background: #fbfcfd;
}
.service-item:hover { border-color: #a9c3d4; background: #f4f9fc; }
.service-icon { width: 33px; height: 33px; flex: 0 0 33px; display: grid; place-items: center; border-radius: 10px; font-weight: 800; font-size: 13px; }
.service-icon.blue { color: #25648f; background: #e2f0f8; }
.service-icon.amber { color: #9b641f; background: #fff0d9; }
.service-icon.violet { color: #6a5a9d; background: #eee9fa; }
.service-icon.green { color: #2d775d; background: #e1f2eb; }
.service-item strong, .service-item small { display: block; }
.service-item strong { font-size: 13px; }
.service-item small { margin-top: 3px; color: #84919c; font-size: 10px; }

.matrix-card { flex: 1; }
.matrix-list { border-top: 1px solid var(--line); }
.matrix-row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 12px 2px; border-bottom: 1px solid #e8edf1; }
.matrix-row p { margin: 0; color: #586a78; font-size: 12px; line-height: 1.6; }
.matrix-row strong { color: var(--ink); font-size: 13px; }
.days { justify-self: start; padding: 5px 8px; border-radius: 8px; color: #285f84; background: var(--blue-soft); font-size: 11px; font-weight: 800; }
.legal-row { background: linear-gradient(90deg, transparent, #f2faf6); }
.legal-row .days { color: #2d7459; background: var(--green-soft); }
.matrix-note { margin: 12px 0 0; color: #758591; font-size: 11px; line-height: 1.6; }

.notice-card { display: flex; gap: 10px; padding: 14px 16px; border: 1px solid #d8e6ee; border-radius: 16px; color: #597080; background: rgba(238, 246, 250, .88); }
.notice-card p { margin: 0; font-size: 11px; line-height: 1.6; }
.notice-card strong { color: var(--navy); }
.notice-icon { width: 21px; height: 21px; flex: 0 0 21px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--blue); font-size: 11px; font-weight: 800; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 13px 7px 0; color: #82909b; font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 70%, 100% { opacity: .35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

@media (max-width: 980px) {
  .page-shell { width: min(100% - 24px, 820px); }
  .workspace { grid-template-columns: 1fr; }
  .chat-card { min-height: 720px; max-height: none; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .notice-card { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .page-shell { width: 100%; padding: 0; }
  .topbar { min-height: 72px; padding: 10px 14px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
  .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 12px; }
  .brand h1 { font-size: 17px; }
  .brand .eyebrow { display: none; }
  .topbar-actions { gap: 6px; }
  .status-pill { font-size: 0; padding: 8px; }
  .status-pill::after { content: "规则已确认"; font-size: 11px; }
  .ghost-button { display: none; }
  .admin-entry { display: none; }
  .workspace { display: block; }
  .chat-card { min-height: calc(100vh - 72px); max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .chat-head { padding: 15px 16px; }
  .messages { min-height: 50vh; padding: 18px 14px; }
  .message-content { max-width: 86%; }
  .bubble { padding: 12px 13px; font-size: 13px; }
  .quick-zone { padding-inline: 13px; }
  .composer { position: sticky; bottom: 0; padding: 10px 12px 6px; }
  .send-button { min-width: 64px; }
  .send-button span:first-child { display: none; }
  .composer-note { padding: 0 15px 10px; }
  .side-panel { display: block; padding: 14px; background: #eef3f6; }
  .side-card, .notice-card { margin-bottom: 12px; }
  footer { display: none; }
}
