/* ============================================================
   普法智能咨询服务系统 · 大屏展示样式（白色调 · 传统聊天布局）
   庄重正式：深蓝主题色 + 白色界面，字体适合远距离阅读
   ============================================================ */

:root {
  --bg: #f5f7fa;             /* 页面浅灰白背景 */
  --white: #ffffff;
  --accent: #1e4e8f;         /* 深蓝主题色（由项目配置动态覆盖） */
  --accent-dark: #163c6f;
  --accent-light: #eaf1fa;   /* 用户气泡（由项目配置动态覆盖） */
  --text: #1f2937;           /* 正文深灰 */
  --text-dim: #6b7688;
  --line: #e2e6ee;           /* 分隔线/描边 */
  --danger: #b03a2e;
  --gold: #c9a44c;           /* 点缀金色 */
  --serif: "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "SimSun", "宋体", serif;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ============================================================
   整体骨架：左侧咨询记录 + 右侧咨询区
   ============================================================ */
.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
}
.main-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------- 左侧栏 ---------------- */
.topic-sidebar {
  flex: none;
  width: 288px;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 10px rgba(20, 40, 80, .04);
  z-index: 20;
}
.sb-brand {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--accent);
}
.sb-emblem {
  width: 42px; height: 42px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 8%, white);
}
.sb-brand-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sb-brand-text strong {
  font-family: var(--serif);
  font-size: 16px; letter-spacing: 1px;
  color: var(--accent-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-brand-text span { font-size: 12px; color: var(--text-dim); letter-spacing: 2px; }

.sb-new {
  flex: none;
  margin: 16px 16px 6px;
  padding: 14px 18px;
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.sb-new:hover { background: var(--accent-dark); }
.sb-new:active { transform: scale(.98); }
.sb-new:disabled { opacity: .5; cursor: not-allowed; }
.sb-plus { font-size: 24px; margin-right: 6px; vertical-align: -1px; }

.sb-section {
  flex: none;
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 20px 10px;
  font-size: 16px; font-weight: 600; letter-spacing: 2px;
  color: var(--text);
}
.sb-count { font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--text-dim); }

.sb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 8px;
}
.sb-list::-webkit-scrollbar { width: 6px; }
.sb-list::-webkit-scrollbar-thumb { background: #ccd5e3; border-radius: 3px; }
.sb-list::-webkit-scrollbar-track { background: transparent; }

.topic-item {
  display: block; width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--sans);
  transition: all .15s;
}
.topic-item:hover { border-color: var(--accent); background: var(--accent-light); }
.topic-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}
.topic-item:disabled { opacity: .55; cursor: not-allowed; }
.ti-title {
  display: block;
  font-size: 18px; line-height: 1.5;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ti-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 7px;
  font-size: 12px; color: var(--text-dim);
}
.ti-cat {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, white);
  color: var(--accent-dark);
  font-size: 11px;
  white-space: nowrap;
}
.ti-time { white-space: nowrap; }
.sb-status {
  flex: none;
  padding: 8px 20px 4px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}
.sb-foot {
  flex: none;
  padding: 10px 20px 14px;
  font-size: 11px;
  color: #a3acba;
  text-align: center;
  border-top: 1px solid var(--line);
}
.sb-empty { padding: 30px 10px; text-align: center; color: var(--text-dim); font-size: 15px; line-height: 1.8; }

/* 当前话题标签（顶部栏） */
.topic-badge {
  display: inline-flex; align-items: center;
  max-width: 220px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, white);
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-btn { display: none; }
.sidebar-mask { display: none; }

/* ---------------- 顶部栏 ---------------- */
.site-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 40px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--accent);   /* 主题色顶边条 */
  box-shadow: 0 1px 6px rgba(20, 40, 80, 0.06);
}

.brand { display: flex; align-items: center; gap: 18px; }

.emblem {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 8%, white);
}

.brand-text h1 {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: 5px;
  font-weight: 700;
  color: var(--accent-dark);
}

.subtitle {
  margin-top: 4px;
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.header-actions { display: flex; gap: 14px; }

/* 右上角小图标按钮 */
.icon-btn {
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.icon-btn svg { width: 28px; height: 28px; }
.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 通用按钮（设置页用） ---------------- */
.btn {
  font-family: var(--sans);
  font-size: 24px;
  padding: 12px 32px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: filter .15s, transform .1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn.ghost {
  background: var(--white);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn.ghost:hover { background: var(--accent-light); }
.btn.small { font-size: 19px; padding: 8px 20px; }

/* ---------------- 未配置提示横幅 ---------------- */
.banner {
  flex: none;
  padding: 12px 40px;
  font-size: 22px;
  text-align: center;
  background: #fdf3e0;
  border-bottom: 1px solid #f0dcb4;
  color: #8a5b16;
}
.banner a { color: var(--accent); text-decoration: underline; font-weight: 600; }
.hidden { display: none !important; }

/* ---------------- 对话区 ---------------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 36px 10%;
}
.chat::-webkit-scrollbar { width: 10px; }
.chat::-webkit-scrollbar-thumb { background: #c9d2e0; border-radius: 5px; }
.chat::-webkit-scrollbar-track { background: transparent; }

/* 欢迎页 */
.welcome {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
}
.welcome-icon {
  font-size: 96px;
  color: var(--accent);
  text-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.welcome h2 {
  font-family: var(--serif);
  font-size: 52px;
  letter-spacing: 14px;
  color: var(--accent-dark);
}
.welcome p { font-size: 28px; color: var(--text); letter-spacing: 2px; }
.welcome-tip { font-size: 22px !important; color: var(--text-dim) !important; }

.chips {
  display: flex;
  flex-wrap: nowrap;          /* 大屏一行显示 */
  justify-content: center;
  gap: 14px;
  max-width: 1500px;
  margin-top: 16px;
}
.chip {
  font-family: var(--sans);
  font-size: 22px;
  padding: 13px 28px;
  color: var(--text);
  background: var(--white);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, white);
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 2px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(20, 40, 80, 0.06);
  transition: all .15s;
}
.chip:hover:enabled {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 2px 8px rgba(30, 78, 143, 0.15);
}
.chip:disabled { opacity: .45; cursor: not-allowed; }

/* 消息行：头像 + 气泡（传统聊天布局） */
.msg {
  display: flex;
  gap: 18px;
  margin-bottom: 34px;
  animation: fadeUp .25s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

.msg.user { flex-direction: row-reverse; }

.avatar {
  flex: none;
  width: 62px; height: 62px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  font-weight: 600;
  background: #e7ebf2;
  color: #5a6578;
}
.avatar.bot-avatar {
  background: color-mix(in srgb, var(--accent) 8%, white);
  color: var(--accent);
  border: 2px solid var(--accent);
  font-size: 30px;
}

.msg-main { max-width: 78%; display: flex; flex-direction: column; }
.msg.user .msg-main { align-items: flex-end; }

.role-label {
  font-size: 20px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.bubble {
  padding: 24px 32px;
  border-radius: 14px;
  font-size: 30px;
  line-height: 1.85;
  letter-spacing: 1px;
  word-break: break-word;
}
.msg.user .bubble {
  background: var(--accent-light);
  border: 1px solid #d3e2f5;
  border-top-right-radius: 4px;
  text-align: left;
}
.msg.bot .bubble {
  background: var(--white);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(20, 40, 80, 0.05);
}
.msg.bot .bubble strong { color: var(--accent-dark); font-weight: 700; }
.msg.bot .bubble .law { color: var(--accent); font-weight: 600; }

.msg.error .bubble {
  background: #fdeeee;
  border-color: #ecc8c5;
  color: var(--danger);
}

/* 思考中动画 */
.thinking::after {
  content: "…";
  animation: dots 1.2s steps(4) infinite;
  color: var(--text-dim);
}
@keyframes dots { 0% { content: ""; } 25% { content: "·"; } 50% { content: "··"; } 75% { content: "···"; } }

/* ---------------- 底部输入区 ---------------- */
.composer {
  flex: none;
  padding: 20px 10% 24px;
  background: var(--white);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 6px rgba(20, 40, 80, 0.05);
}
.composer-inner { display: flex; gap: 20px; align-items: stretch; }

#input {
  flex: 1;
  font-family: var(--sans);
  font-size: 27px;
  line-height: 1.6;
  padding: 18px 26px;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: none;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 78, 143, 0.12);
}
#input::placeholder { color: #a8b0bd; font-size: 23px; }

#btn-send {
  min-width: 170px;
  font-size: 28px;
  border-radius: 12px;
}

/* logo 图片自适应（后台配置了 logo 时替换天平图标） */
.emblem img, .welcome-icon img { object-fit: contain; border-radius: 50%; }
.emblem img { width: 100%; height: 100%; }
.welcome-icon img { width: 90px; height: 90px; }

.hint {
  margin-top: 12px;
  font-size: 18px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-align: center;
}

/* 窄屏兜底：快捷问题允许换行 */
@media (max-width: 1024px) {
  .chips { flex-wrap: wrap; }
}

/* ============================================================
   多端同步：状态指示 / 手机输入镜像 / 轻提示
   ============================================================ */
.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 0 6px;
}
.sync-state::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #c3cad6;
  flex: none;
}
.sync-state.on::before { background: #2e9e5b; box-shadow: 0 0 0 3px rgba(46,158,91,.15); }
.sync-state.wait::before { background: #d99a2b; }
.sync-state.off::before { background: #c0392b; }

.remote-draft {
  max-width: 1200px;
  margin: 0 auto 12px;
  padding: 10px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 7%, white);
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, white);
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-all;
}
.rd-label {
  display: inline-block;
  font-size: 15px;
  color: var(--accent);
  font-weight: 600;
  margin-right: 12px;
  white-space: nowrap;
}
.rd-text { color: var(--text-dim); }

.toast {
  position: fixed;
  left: 50%; bottom: 150px;
  transform: translateX(-50%);
  max-width: 82vw;
  padding: 14px 26px;
  border-radius: 10px;
  background: rgba(28, 38, 56, .94);
  color: #fff;
  font-size: 20px;
  line-height: 1.5;
  text-align: center;
  z-index: 50;
  box-shadow: 0 6px 24px rgba(10, 20, 40, .22);
}

/* ============================================================
   手机端适配：大屏字号全面收缩，重排 header / 欢迎页 / 输入区
   断点 768px；另对 400px 以下超窄屏再收紧
   ============================================================ */
@media (max-width: 768px) {
  html, body { height: 100dvh; }

  /* --- 顶部栏 --- */
  .site-header {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 10px;
    border-top-width: 3px;
  }
  .brand { gap: 10px; min-width: 0; }
  .emblem {
    width: 40px; height: 40px;
    font-size: 22px;
    border-width: 1.5px;
    flex: none;
  }
  .brand-text { min-width: 0; }
  .brand-text h1 {
    font-size: 17px;
    letter-spacing: 1px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .subtitle {
    font-size: 11px;
    letter-spacing: 0;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62vw;
  }
  .header-actions { gap: 8px; flex: none; }
  .sync-state { font-size: 0; padding: 0 2px; }
  .sync-state::before { width: 8px; height: 8px; }
  .icon-btn { width: 36px; height: 36px; border-radius: 8px; }
  .icon-btn svg { width: 19px; height: 19px; }

  /* --- 提示横幅 --- */
  .banner { padding: 9px 14px; font-size: 13px; }

  /* --- 对话区 --- */
  .chat { padding: 16px 14px 20px; }
  .chat::-webkit-scrollbar { width: 5px; }

  /* --- 欢迎页 --- */
  .welcome { gap: 14px; padding: 12px 2px 20px; height: auto; min-height: 100%; }
  .welcome-icon { font-size: 52px; }
  .welcome-icon img { height: 52px !important; width: 52px !important; }
  .welcome h2 {
    font-size: 25px;
    letter-spacing: 3px;
    line-height: 1.4;
  }
  .welcome p { font-size: 15px; letter-spacing: 0; line-height: 1.7; }
  .welcome-tip { font-size: 12px !important; line-height: 1.6; }
  .chips {
    gap: 8px;
    margin-top: 6px;
    width: 100%;
    justify-content: center;
  }
  .chip {
    font-size: 13px;
    padding: 8px 14px;
    letter-spacing: 0;
    white-space: normal;
    line-height: 1.4;
  }

  /* --- 消息气泡 --- */
  .msg { gap: 10px; margin-bottom: 18px; }
  .avatar { width: 34px; height: 34px; font-size: 15px; }
  .avatar.bot-avatar { font-size: 17px; border-width: 1.5px; }
  .msg-main { max-width: 84%; }
  .role-label { font-size: 11px; letter-spacing: 0; margin-bottom: 4px; }
  .bubble {
    padding: 11px 14px;
    font-size: 15px;
    line-height: 1.7;
    letter-spacing: 0;
    border-radius: 12px;
  }

  /* --- 底部输入区 --- */
  .composer {
    padding: 10px 12px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .composer-inner { gap: 8px; }
  #input {
    font-size: 15px;
    line-height: 1.5;
    padding: 10px 12px;
    border-radius: 9px;
    min-height: 46px;
    max-height: 110px;
  }
  #input::placeholder { font-size: 13px; }
  #btn-send {
    min-width: 76px;
    font-size: 15px;
    padding: 8px 10px;
    border-radius: 9px;
    letter-spacing: 1px;
  }
  .hint {
    margin-top: 8px;
    font-size: 10px;
    line-height: 1.5;
    letter-spacing: 0;
  }
  .remote-draft { font-size: 12px; padding: 7px 10px; margin-bottom: 8px; }
  .rd-label { font-size: 11px; margin-right: 6px; }
  .toast { bottom: 120px; font-size: 14px; padding: 10px 18px; }
}

/* 超窄屏再收紧一点 */
@media (max-width: 400px) {
  .brand-text h1 { font-size: 15px; }
  .subtitle { max-width: 52vw; }
  .welcome h2 { font-size: 22px; }
  .welcome-icon { font-size: 44px; }
  #btn-send { min-width: 66px; font-size: 14px; }
  .chip { font-size: 12px; padding: 7px 11px; }
}

/* ============================================================
   咨询记录侧栏 · 手机端抽屉适配
   ============================================================ */
@media (max-width: 900px) {
  .topic-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 6px 0 24px rgba(10, 20, 40, .18);
    z-index: 60;
    padding-top: env(safe-area-inset-top);
  }
  .topic-sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: block;
    position: fixed; inset: 0;
    background: rgba(12, 22, 42, .42);
    opacity: 0; visibility: hidden;
    transition: opacity .22s;
    z-index: 55;
  }
  .sidebar-mask.show { opacity: 1; visibility: visible; }
  .menu-btn { display: inline-flex; }
  .sb-brand { padding-top: 14px; }
  .sb-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .topic-badge { max-width: 120px; font-size: 12px; padding: 4px 10px; }
}
@media (max-width: 768px) {
  .menu-btn { width: 36px; height: 36px; border-radius: 8px; }
  .menu-btn svg { width: 19px; height: 19px; }
  .sb-new { font-size: 16px; padding: 12px 16px; }
  .sb-section { font-size: 14px; padding-top: 14px; }
  .ti-title { font-size: 15px; }
  .topic-badge { max-width: 96px; }
}
