/* ============================================================
   神算子 · 在线问命台（聊天页）
   ============================================================ */

/* 确保 hidden 属性始终生效（.auth-wrap / .chat-user 等会设置 display，
   若不强制，登录成功后登录卡片仍会显示，造成「登不进」的错觉） */
[hidden] {
  display: none !important;
}

/* ---------------- 顶栏 ---------------- */
.chat-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 239, 223, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(158, 43, 37, 0.18);
}

.chat-topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-script);
  font-size: 1.28rem;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.brand-avatar-img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(158, 43, 37, 0.28);
}

.chat-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-phone {
  font-size: 0.86rem;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}

/* ---------------- 登录 / 注册 ---------------- */
.auth-wrap {
  min-height: calc(100vh - 66px);
  display: grid;
  place-items: center;
  padding: 48px 20px;
}

.auth-card {
  width: 100%;
  max-width: 404px;
  position: relative;
  background: linear-gradient(180deg, #faf4e4, #f2ead4);
  border: 1px solid rgba(158, 43, 37, 0.55);
  border-radius: var(--radius);
  padding: 34px 32px 28px;
  box-shadow: var(--shadow);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(158, 43, 37, 0.38);
  border-radius: 9px;
  pointer-events: none;
}

.auth-seal {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 8px;
  background: var(--grad-red);
  color: #f8f1e2;
  display: grid;
  place-items: center;
  font-family: var(--font-script);
  font-size: 1.8rem;
  box-shadow: inset 0 0 0 2px rgba(248, 241, 226, 0.35);
}

.auth-title {
  text-align: center;
  font-family: var(--font-script);
  font-size: 1.7rem;
  font-weight: 400;
  color: var(--ink);
}

.auth-sub {
  text-align: center;
  color: var(--faint);
  font-size: 0.85rem;
  margin: 8px 0 22px;
  letter-spacing: 0.06em;
}

.auth-tabs {
  display: flex;
  background: rgba(38, 33, 26, 0.06);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 8px 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-btn.active {
  background: var(--grad-red);
  color: #f8f1e2;
  box-shadow: 0 6px 16px rgba(158, 43, 37, 0.3);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-2);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(38, 33, 26, 0.2);
  border-radius: 8px;
  background: #fffdf6;
  padding: 11px 13px;
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--red-strong);
  box-shadow: 0 0 0 3px rgba(158, 43, 37, 0.12);
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-error {
  min-height: 20px;
  text-align: center;
  color: var(--red-strong);
  font-size: 0.83rem;
  margin-top: 10px;
  letter-spacing: 0.03em;
}

.auth-foot {
  text-align: center;
  color: var(--faint);
  font-size: 0.76rem;
  margin-top: 14px;
  line-height: 1.9;
}

/* ---------------- 聊天面板 ---------------- */
.chat-wrap {
  padding: 24px 0 56px;
}

.chat-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

.chat-panel {
  position: relative;
  border: 1px solid rgba(158, 43, 37, 0.5);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #faf4e4, #f2ead4);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 名帖双重红框 */
.chat-panel::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(158, 43, 37, 0.35);
  border-radius: 9px;
  pointer-events: none;
  z-index: 1;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px dashed rgba(158, 43, 37, 0.3);
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--grad-red);
  color: #f8f1e2;
  display: grid;
  place-items: center;
  font-family: var(--font-script);
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 2px rgba(248, 241, 226, 0.35);
  overflow: hidden;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-name {
  font-family: var(--font-script);
  font-size: 1.28rem;
  color: var(--ink);
}

.chat-status {
  font-size: 0.76rem;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.05em;
}

.chat-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3f7d4e;
  box-shadow: 0 0 0 3px rgba(63, 125, 78, 0.22);
}

/* ---------------- 快捷问题 ---------------- */
.prompts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px 2px;
}

.prompt-chip {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--red-strong);
  border: 1px solid rgba(158, 43, 37, 0.35);
  background: rgba(255, 253, 246, 0.6);
  border-radius: 999px;
  padding: 5px 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.prompt-chip:hover {
  background: var(--grad-red);
  color: #f8f1e2;
}

/* ---------------- 消息列表 ---------------- */
.msg-list {
  height: 44vh;
  min-height: 320px;
  max-height: 540px;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 84%;
}

.msg-ai {
  align-self: flex-start;
}

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-red);
  color: #f8f1e2;
  display: grid;
  place-items: center;
  font-family: var(--font-script);
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(248, 241, 226, 0.35);
  overflow: hidden;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-user .msg-avatar {
  background: var(--ink);
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-ai .msg-bubble {
  background: #fffdf6;
  border: 1px solid rgba(38, 33, 26, 0.14);
  border-top-left-radius: 3px;
  color: var(--ink);
}

.msg-user .msg-bubble {
  background: var(--grad-red);
  color: #f8f1e2;
  border-top-right-radius: 3px;
}

/* 输入中的三点动画 */
.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 2px;
}

.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(38, 33, 26, 0.4);
  animation: chat-blink 1.2s infinite both;
}

.typing i:nth-child(2) {
  animation-delay: 0.2s;
}
.typing i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chat-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ---------------- 输入区 ---------------- */
.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 16px 16px;
  border-top: 1px dashed rgba(158, 43, 37, 0.25);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid rgba(38, 33, 26, 0.2);
  border-radius: 10px;
  background: #fffdf6;
  padding: 11px 13px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  min-height: 44px;
  max-height: 132px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--red-strong);
  box-shadow: 0 0 0 3px rgba(158, 43, 37, 0.12);
}

.send-btn {
  flex-shrink: 0;
  padding: 0.68em 1.1em;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 480px) {
  .msg {
    max-width: 92%;
  }

  .chat-shell {
    padding: 0 12px;
  }

  .auth-card {
    padding: 28px 22px 24px;
  }
}
