/* ===================================================================
   base.css — 设计令牌 + 通用组件
   =================================================================== */
:root {
  --brand: #07c160;
  --brand-dark: #06a552;
  --brand-light: #e8f9ee;
  --bubble-self: #95ec69;

  --bg: #ededed;
  --panel: #f7f7f7;
  --surface: #ffffff;
  --ink: #14171a;
  --ink-2: #4b5359;
  --ink-3: #8a9096;
  --ink-4: #b6bbc0;
  --line: #e6e8ea;
  --line-soft: #eff1f3;
  --danger: #e5484d;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 4px 14px -4px rgba(16, 24, 40, 0.12);
  --shadow-3: 0 18px 50px -18px rgba(16, 24, 40, 0.28);
  --shadow-pop: 0 12px 34px -10px rgba(16, 24, 40, 0.22);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: #3a6ea5;
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.26);
  background-clip: padding-box;
  border: 2px solid transparent;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------- 头像 ------------------------------- */
.av {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  background: #dfe3e8;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
}
.av svg {
  width: 100%;
  height: 100%;
  display: block;
}
.av--agent {
  background: linear-gradient(140deg, #0ac86a, #059a4b);
}
.av--sm {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 11px;
}
.av--lg {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  font-size: 20px;
}
.av--round {
  border-radius: 50%;
}

.av-g0 { background: linear-gradient(140deg, #6aa9ff, #3f7ce0); }
.av-g1 { background: linear-gradient(140deg, #ffb26a, #ef7f3a); }
.av-g2 { background: linear-gradient(140deg, #a78bfa, #7c5cf0); }
.av-g3 { background: linear-gradient(140deg, #4dd0c1, #16a394); }
.av-g4 { background: linear-gradient(140deg, #f78ca0, #e75874); }
.av-g5 { background: linear-gradient(140deg, #f9c74f, #e8a020); }
.av-g6 { background: linear-gradient(140deg, #7ed0f0, #3aa2cf); }
.av-g7 { background: linear-gradient(140deg, #9bd35a, #62a529); }

/* ------------------------------- 通用按钮 ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  background: #f1f3f5;
  color: var(--ink-2);
  transition: background 0.16s, color 0.16s, transform 0.08s, box-shadow 0.16s;
  white-space: nowrap;
}
.btn:hover {
  background: #e8ebee;
}
.btn:active {
  transform: scale(0.975);
}
.btn--primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(7, 193, 96, 0.55);
}
.btn--primary:hover {
  background: var(--brand-dark);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-3);
}
.btn--ghost:hover {
  background: #f1f3f5;
  color: var(--ink);
}
.btn--danger {
  background: #fdecec;
  color: var(--danger);
}
.btn--danger:hover {
  background: #fbdcdc;
}
.btn--block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field {
  display: block;
  margin-bottom: 14px;
}
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 5px;
  line-height: 1.45;
}
.input,
.textarea,
select.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r-md);
  height: 38px;
  padding: 0 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.55;
  min-height: 74px;
}
.input:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.13);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}

/* ------------------------------- 弹层 ------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 22, 28, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
  animation: fadeIn 0.16s ease;
}
.overlay[hidden] {
  display: none;
}
.modal {
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal--wide {
  max-width: 640px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
  background: #fcfcfd;
  flex: 0 0 auto;
}
.x-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.x-btn:hover {
  background: #f1f3f5;
  color: var(--ink);
}

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

/* ------------------------------- Toast ------------------------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: rgba(24, 28, 33, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  animation: toastIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 80vw;
}
.toast--ok { background: #0f7a45; }
.toast--err { background: #b4242b; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.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;
}

/* ------------------------------- 语音气泡 ------------------------------- */
.bubble--voice {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 104px;
  cursor: pointer;
  user-select: none;
}
.bubble--voice .v-play {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(7, 193, 96, 0.1);
  color: #07a055;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: transform 0.12s;
}
.bubble--voice:active .v-play {
  transform: scale(0.9);
}
.bubble--voice .v-play svg {
  width: 12px;
  height: 12px;
  display: block;
}
.bubble--voice .v-wave {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 17px;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.bubble--voice .v-wave i {
  width: 2.5px;
  border-radius: 2px;
  background: #9aa1a7;
  height: 30%;
  transition: height 0.2s;
}
.bubble--voice .v-wave i:nth-child(3n) { height: 55%; }
.bubble--voice .v-wave i:nth-child(4n) { height: 85%; }
.bubble--voice .v-wave i:nth-child(5n) { height: 45%; }
.bubble--voice .v-wave i:nth-child(7n) { height: 70%; }
.bubble--voice .v-dur {
  font-size: 12px;
  color: #7d858c;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.bubble--voice.playing .v-wave i {
  animation: voiceWave 0.9s infinite ease-in-out;
}
.bubble--voice.playing .v-wave i:nth-child(2n) { animation-delay: 0.15s; }
.bubble--voice.playing .v-wave i:nth-child(3n) { animation-delay: 0.3s; }
@keyframes voiceWave {
  0%, 100% { height: 22%; }
  50% { height: 100%; }
}
.msg-row.self .bubble--voice .v-play {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.msg-row.self .bubble--voice .v-wave i {
  background: rgba(255, 255, 255, 0.85);
}
.msg-row.self .bubble--voice .v-dur {
  color: rgba(255, 255, 255, 0.9);
}
.msg-auto-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #b58a1e;
  background: #fdf3dd;
  border-radius: 4px;
  padding: 1px 5px;
}
