/* ─── 色彩系统 ─── */
:root {
  --bg: #F5F0EB;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --gold: #B28247;
  --gold-dim: #8A7555;
  --gold-soft: rgba(178, 130, 71, .08);
  --gold-hover: rgba(178, 130, 71, .15);
  --text: #1A1816;
  --text-dim: #8A8278;
  --text-muted: #B0A89A;
  --line: #E5DDD4;
  --line-light: #EDE8E0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .06);
}

/* ─── 重置 ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Serif SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100dvh;
  height: 100vh;           /* fallback */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.7;
  user-select: none;
}

button {
  font-family: inherit;
}

/* ══════════════════════════════════════ */
/*  顶栏 .hd                              */
/* ══════════════════════════════════════ */
.hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  z-index: 10;
  background: var(--bg);
}

.hl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hl a {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hl .b {
  font-size: 18px;
  color: var(--gold);
  line-height: 1;
}

.hl .h {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.hl .s {
  color: var(--text-muted);
  font-size: 14px;
}

.hl .l {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.3px;
}

.hl .l span {
  color: var(--text);
}

.hr {
  display: flex;
  align-items: center;
}

.hbtn {
  height: 32px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gold);
  transition: all .2s ease;
  font-size: 12px;
  padding: 0 16px;
  font-weight: 500;
}

.hbtn:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.hbtn:active {
  transform: scale(0.97);
}

/* ══════════════════════════════════════ */
/*  话题卡片 .topic                       */
/* ══════════════════════════════════════ */
.topic {
  background: linear-gradient(135deg, #F5F0EB, #EDE8E0);
  border-radius: 14px;
  padding: 20px 24px;
  margin: 4px 16px 8px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: border-color .3s ease;
}

.topic .lbl {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.topic .r {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topic .r .l {
  flex: 1;
  min-width: 0;
}

.topic .r .l .tt {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
  color: var(--text);
}

.topic .r .l .ds {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}

.topic .r .kn {
  text-align: center;
  padding: 8px 18px;
  background: rgba(255, 255, 255, .55);
  border-radius: 12px;
  flex-shrink: 0;
  min-width: 56px;
}

.topic .r .kn .n {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  letter-spacing: 2px;
}

.topic .r .kn .nm {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 1px;
}

/* ══════════════════════════════════════ */
/*  建议按钮 .sug                         */
/* ══════════════════════════════════════ */
.sug {
  display: flex;
  gap: 8px;
  margin: 0 16px 8px;
  flex-shrink: 0;
}

.sug .s {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all .2s ease;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--card);
  font-weight: 500;
  white-space: nowrap;
}

.sug .s:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
  box-shadow: var(--shadow-sm);
}

.sug .s:active {
  transform: scale(0.97);
  background: var(--gold-hover);
}

.sug .s svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color .2s ease;
}

.sug .s:hover svg {
  color: var(--gold);
}

/* ══════════════════════════════════════ */
/*  对话区 .ch                            */
/* ══════════════════════════════════════ */
.ch {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.ch::-webkit-scrollbar {
  width: 3px;
}

.ch::-webkit-scrollbar-track {
  background: transparent;
}

.ch::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

/* 消息包装 */
.mw {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.mw.x {
  align-items: flex-start;
}

.mw.u {
  align-items: flex-end;
}

/* 消息行 */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 85%;
}

.mw.x .msg {
  flex-direction: row;
}

.mw.u .msg {
  flex-direction: row-reverse;
}

/* 头像 */
.av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.mw.x .av {
  background: var(--gold);
  color: #fff;
}

.mw.u .av {
  background: var(--line);
  color: var(--text-dim);
}

/* 气泡容器 */
.bw {
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

/* 气泡 */
.bub {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.8;
  color: #2a2725;
  word-break: break-word;
  white-space: pre-wrap;
}

.mw.x .bub {
  background: var(--card);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.mw.u .bub {
  background: #E8E3DB;
  border-bottom-right-radius: 4px;
}

/* 气泡内高亮 */
.bub .hl {
  color: var(--gold);
  font-weight: 600;
}

/* 时间戳 */
.bt {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.mw.x .bt {
  align-self: flex-start;
}

.mw.u .bt {
  align-self: flex-end;
}

/* ══════════════════════════════════════ */
/*  输入框 .ib                            */
/* ══════════════════════════════════════ */
.ib {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--line-light);
  flex-shrink: 0;
  background: var(--bg);
}

.ib input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 20px;
  font-family: "Noto Serif SC", "PingFang SC", sans-serif;
  border: 1px solid var(--line);
  transition: border-color .2s ease;
}

.ib input:focus {
  border-color: var(--gold);
}

.ib input::placeholder {
  color: var(--text-muted);
}

/* 输入框侧按钮（表情/语音） */
.ibtn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  flex-shrink: 0;
}

.ibtn:hover {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: var(--gold);
}

.ibtn:active {
  transform: scale(0.92);
  background: var(--gold-hover);
}

.ibtn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* 发送按钮 */
.snd {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  flex-shrink: 0;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(178, 130, 71, .25);
}

.snd:hover {
  opacity: .9;
  transform: scale(1.05);
}

.snd:active {
  transform: scale(0.95);
  opacity: .85;
}

/* ══════════════════════════════════════ */
/*  工具弹出面板 .ep                       */
/* ══════════════════════════════════════ */
.ep {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .08);
  padding: 16px 16px 24px;
  max-height: 280px;
  overflow-y: auto;
  animation: slideUp .25s ease;
}

.ep.o {
  display: block;
}

.eg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ─── 动画 ─── */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mw {
  animation: fadeIn .3s ease;
}

/* ─── 响应式微调 ─── */
@media (max-width: 400px) {
  .topic {
    padding: 16px;
    margin: 4px 8px 8px;
  }
  .topic .r .l .tt {
    font-size: 17px;
  }
  .sug {
    margin: 0 8px 8px;
  }
  .ch {
    padding: 4px 8px;
  }
  .ib {
    padding: 6px 8px 10px;
  }
  .msg {
    max-width: 92%;
  }
}
