@font-face {
  font-family: 'GenWanMinF';
  src: url('../../fonts/源古黑體-F.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 聊天页背景 */
body {
  background-color: #1a1a2e;
  background-image: url('../../bg-vertical.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  font-family: 'Lilita One', Arial, sans-serif;
}

html[data-lang='zh'] body,
html[data-lang='zh'] .chat-profile__value,
html[data-lang='zh'] .chat-main__input {
  font-family: 'GenWanMinF', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

html[data-lang='zh'] .archive-tab,
html[data-lang='zh'] .archive-tab__label,
html[data-lang='zh'] .chat-profile__section-title,
html[data-lang='zh'] .chat-main__name {
  font-family: 'Lilita One', 'LilitaOne-Regular', Arial, sans-serif;
}

.chat-page {
  position: relative;
}

a.archive-tab {
  text-decoration: none;
  cursor: pointer;
}

.chat-page a.archive-tab--back,
.chat-page a.archive-tab--back:link,
.chat-page a.archive-tab--back:visited,
.chat-page a.archive-tab--back:hover,
.chat-page a.archive-tab--back:active,
.chat-page a.archive-tab--back .archive-tab__label {
  color: #ffffff;
}

.chat-page .archive-card {
  overflow: hidden;
}

.chat-page .archive-card::before {
  display: none;
}

.chat-page .archive-tab--active {
  min-height: 120px;
}

/* 双栏布局 */
.chat-layout {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 36%) minmax(0, 64%);
  min-height: 0;
  background: #fff;
  border-radius: inherit;
}

/* —— 左侧档案 —— */
.chat-profile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px 14px 16px;
  background: #badaff;
  border-right: var(--archive-frame-border) solid var(--archive-accent);
  min-height: 0;
  overflow: hidden;
}

.chat-profile__avatar-wrap {
  flex: 0 0 auto;
  align-self: stretch;
  border: 2px solid #3a96ff;
  border-radius: 14px;
  background: #fff;
  /* 横版插画比例（与 avatar_*_horizontal.jpg 一致） */
  aspect-ratio: 874 / 742;
  max-height: 38%;
  overflow: hidden;
}

.chat-profile__avatar-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.chat-profile__identity {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-profile__field {
  border: 2px solid #3a96ff;
  border-radius: 10px;
  background: #fff;
  padding: 6px 8px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-profile__field--name {
  cursor: text;
}

.chat-profile__name-input {
  width: 100%;
  margin: 0;
  padding: 0 4px;
  border: none;
  outline: none;
  background: transparent;
  color: #000;
  font-size: clamp(14px, 1.45vw, 20px);
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  font-family: inherit;
}

.chat-profile__name-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
  font-weight: 400;
}

.chat-profile__value {
  margin: 0;
  width: 100%;
  font-size: clamp(14px, 1.45vw, 20px);
  font-weight: 400;
  color: #000;
  line-height: 1.2;
  word-break: break-word;
  text-align: center;
}

.chat-profile__value--id,
.chat-profile #user-id {
  font-family: 'Lilita One', Arial, sans-serif;
  font-size: clamp(12px, 1.2vw, 17px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-profile__personality-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.chat-profile__section-title {
  margin: 0;
  font-size: clamp(10px, 1vw, 13px);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #000;
  line-height: 1.15;
}

.chat-profile__stats .chat-profile__section-title {
  font-size: clamp(13px, 1.25vw, 17px);
  letter-spacing: 0.04em;
}

html[data-lang='zh'] .chat-profile__stats .chat-profile__section-title {
  font-weight: 700;
  padding-left: 6px;
}

.chat-profile__personality,
.chat-profile #leopard-personality {
  border: 2px solid #3a96ff;
  border-radius: 10px;
  background: #fff;
  min-height: 56px;
  max-height: 96px;
  padding: 8px 10px;
  font-size: clamp(13px, 1.3vw, 18px);
  line-height: 1.25;
  color: #000;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  word-break: break-word;
}

.chat-profile__stats {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.chat-profile__stat {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 覆盖 panel.css：侧栏进度条为白底圆角条 + #3a96ff 填充（内缩留白边）+ Lilita 白字 */
.chat-profile .stat-bar {
  --stat-ring: 3px;
  position: relative;
  left: auto;
  top: auto;
  width: 100%;
  height: auto;
  flex: 1 1 auto;
  min-height: 24px;
}

.chat-profile .stat-bar__track {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 24px;
  height: 100%;
  border-radius: 9999px;
  overflow: hidden;
}

.chat-profile .stat-bar__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #fff;
  background-image: url('../../panel1/progress-bg.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.chat-profile .stat-bar__fill {
  position: absolute;
  top: var(--stat-ring);
  bottom: var(--stat-ring);
  left: var(--stat-ring);
  z-index: 1;
  width: 0%;
  max-width: calc(100% - 2 * var(--stat-ring));
  height: auto;
  box-sizing: border-box;
  background: #3a96ff;
  background-image: none;
  border-radius: 9999px;
  transition: width 0.8s ease;
}

.chat-profile .stat-bar__value {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lilita One', 'LilitaOne-Regular', Arial, sans-serif;
  font-size: clamp(11px, 1vw, 15px);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 2px rgba(8, 89, 182, 0.35);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .chat-profile .stat-bar__fill {
    transition: none;
  }
}

/* —— 右侧聊天 —— */
.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
  background: #fff;
}

.chat-main__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
  background: #1477eb;
  color: #fff;
}

.chat-main__header-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.chat-main__name {
  margin: 0;
  max-width: 100%;
  font-size: var(--chat-name-fit-size, 28px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chat-main__status {
  margin: 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 400;
  letter-spacing: 0.04em;
  opacity: 0.95;
}

.chat-main__status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4caf50;
  flex-shrink: 0;
}

.chat-main__header-actions {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 10px;
  flex-shrink: 0;
}

.chat-header-btn {
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-btn:active {
  filter: brightness(0.92);
}

.chat-header-btn--download {
  width: 52px;
  height: 52px;
  background-image: url('../../panel1/download.png');
  transform: translate(-8px, 5px);
}

.chat-header-btn--download:active {
  transform: translate(-8px, 5px);
}

.chat-main__messages {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
}

.msg-row--leopard {
  align-self: flex-start;
}

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

.msg-avatar {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #d8dde6;
  border: 2px solid #b0bcc9;
  flex-shrink: 0;
}

.msg-row--leopard .msg-avatar {
  background: #fff url('../img/头像.jpg') center / cover no-repeat;
  border-color: #3a96ff;
}

.message {
  padding: 10px 14px;
  line-height: 1.45;
  font-size: clamp(13px, 1.2vw, 16px);
  white-space: pre-wrap;
  word-break: break-word;
}

.message--leopard {
  background: #3a96ff;
  color: #fff;
  border-radius: 4px 14px 14px 14px;
}

.message--user {
  background: #3a96ff;
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

.thinking {
  opacity: 0.55;
  font-style: italic;
}

.chat-main__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #1477eb;
}

.chat-main__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: #fff;
  padding: 0 14px;
  color: #0a1628;
  font-size: clamp(14px, 1.2vw, 16px);
  outline: none;
}

.chat-main__input::placeholder {
  color: rgba(10, 22, 40, 0.45);
}

.chat-main__send {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent url('../img/send-bg.png') center / contain no-repeat;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-main__send-arrow {
  position: absolute;
  inset: 0;
  background: url('../img/send-arrow.png') center / contain no-repeat;
  pointer-events: none;
  transform: translateX(7px);
}

.chat-main__send:active {
  filter: brightness(0.92);
}

/* panel.css 会改 body 布局，恢复档案页视口行为 */
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  isolation: auto;
}

@media (max-width: 720px) {
  .chat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .chat-profile {
    border-right: none;
    border-bottom: var(--archive-frame-border) solid var(--archive-accent);
    max-height: 42%;
  }

  .chat-profile__avatar-wrap {
    aspect-ratio: 874 / 742;
    max-height: 120px;
    width: auto;
    max-width: 100%;
    align-self: stretch;
  }
}

/* 手机横屏：保持横版插画框，与桌面一致 */
@media (orientation: landscape) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  .chat-profile__avatar-wrap {
    aspect-ratio: 874 / 742;
    align-self: stretch;
    width: auto;
    max-width: 100%;
    max-height: 34%;
  }
}
