/* ========== 基础 ========== */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #172033;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #0f9f8f;
  --primary-strong: #0b766d;
  --primary-soft: #e7f7f5;
  --blue: #2563eb;
  --blue-soft: #eef4ff;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --shadow: 0 18px 50px rgba(15, 23, 42, .10);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, .07);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: var(--vh, 100vh);
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button { border: 0; }

/* 默认 page：满屏高、内部纵向滚动（首页 / 报告页 / 历史页用这个）。
   面试页有自己的特殊样式覆盖，保持一屏不滚动。*/
.page { display: none; min-height: var(--vh, 100vh); }
.page.active { display: flex; flex-direction: column; overflow-y: auto; }

/* 面试页：仍然要保持视口大小，不允许滚动，避免视频画面被压扁 */
#page-interview { height: var(--vh, 100vh); }
#page-interview.active { overflow: hidden; }

/* ========== 顶栏 ========== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  padding: 0 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
}
.top-logo {
  font-size: 15px;
  font-weight: 750;
  color: var(--text);
  cursor: pointer;
}
.top-logo::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.top-user { font-size: 13px; color: var(--muted); }
.btn-top {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .18s, color .18s, box-shadow .18s;
}
.btn-top:hover { border-color: var(--primary); color: var(--primary-strong); box-shadow: var(--shadow-soft); }
body[data-page="interview"] .top-bar { display: none; }

/* ========== 首页 ========== */
#page-home {
  align-items: center;
  /* 用 safe 防止内容超高时被顶到上方裁掉，配合 padding 给上下留出气口 */
  justify-content: safe center;
  background: var(--bg);
  padding: 24px 0;
}
.home-container {
  width: min(460px, calc(100vw - 32px));
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
.logo-area { text-align: left; margin-bottom: 28px; }
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.logo-area h1 { font-size: 26px; line-height: 1.2; font-weight: 780; color: var(--text); }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 8px; }
.form-section { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 9px;
  font-weight: 650;
}
.tag-group { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
.tag:hover { border-color: var(--primary); }
.tag.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); font-weight: 650; }
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mode-btn {
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background .18s, border-color .18s, color .18s;
}
.mode-btn:hover { border-color: var(--primary); }
.mode-btn.active { background: var(--text); border-color: var(--text); color: #fff; }
.mode-btn .mode-title { font-weight: 650; font-size: 14px; }
.mode-btn .mode-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}
.mode-btn.active .mode-sub { color: rgba(255,255,255,.78); }
.btn-primary {
  width: 100%;
  padding: 12px 14px;
  background: var(--primary);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .18s, box-shadow .18s;
}
.btn-primary:hover { background: var(--primary-strong); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(15,159,143,.22); }
.btn-primary:disabled, .btn-send:disabled { opacity: .58; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  width: 100%;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-strong); }

/* ========== 面试房间 ========== */
#page-interview { padding: 0; }
#page-interview .top-bar { display: none; }
.interview-room {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  height: var(--vh, 100vh);
  background:
    radial-gradient(circle at top left, rgba(15,159,143,.08), transparent 22%),
    radial-gradient(circle at top right, rgba(37,99,235,.08), transparent 24%),
    linear-gradient(180deg, #eef3f8 0%, #e7edf4 100%);
  position: relative;
  overflow: hidden;
}
.room-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 26px;
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  backdrop-filter: blur(14px);
}
.room-info-left, .room-info-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.badge {
  background: #ecfdf5;
  color: var(--primary-strong);
  border: 1px solid #b6ebe3;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.room-meta {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-timer {
  padding: 7px 11px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.room-main {
  min-height: 0;
  padding: 14px 352px 10px 18px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
body[data-chat-panel="closed"] .room-main {
  padding-right: 18px;
}
.video-panel { position: relative; }
.ai-panel {
  width: min(1140px, 100%);
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at top left, rgba(15,159,143,.10), transparent 28%),
    radial-gradient(circle at top right, rgba(59,130,246,.10), transparent 24%),
    linear-gradient(180deg, #fcfdff 0%, #f4f7fb 100%);
  border: 1px solid rgba(203,213,225,.95);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
  overflow: hidden;
  position: relative;
}
.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 2px;
  border-bottom: 0;
  background: transparent;
  position: relative;
  z-index: 2;
}
.panel-title {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(203,213,225,.9);
}
.panel-toolbar-right { display: flex; align-items: center; gap: 10px; }
.video-status {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(203,213,225,.9);
}
.avatar-wrapper {
  align-self: end;
  justify-self: center;
  position: relative;
  width: min(1040px, calc(100% - 28px));
  aspect-ratio: 16 / 9;
  max-height: calc(100% - 4px);
  min-height: 0;
  margin: 0 0 -2px;
}
.preview-stage {
  display: none;
  align-self: center;
  justify-self: center;
  width: min(960px, calc(100% - 32px));
  aspect-ratio: 16 / 9;
  max-height: calc(100% - 6px);
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(203,213,225,.95);
  background:
    radial-gradient(circle at top, rgba(255,255,255,.95), rgba(233,240,248,.92) 52%, rgba(218,228,239,.94) 100%);
  box-shadow: 0 20px 40px rgba(148,163,184,.22);
  cursor: grab;
  --pip-video-scale: 1;
  --pip-pan-x: 0px;
  --pip-pan-y: 0px;
}
.preview-stage:active { cursor: grabbing; }
.preview-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate(var(--pip-pan-x), var(--pip-pan-y)) scale(var(--pip-video-scale));
  transform-origin: center center;
  touch-action: none;
}
.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  object-fit: contain;
  border: 1px solid rgba(203,213,225,.95);
  background:
    radial-gradient(circle at top, rgba(255,255,255,.95), rgba(233,240,248,.92) 52%, rgba(218,228,239,.94) 100%);
  transition: transform .35s ease, filter .35s ease;
  position: relative;
  z-index: 2;
  box-shadow: 0 20px 40px rgba(148,163,184,.22);
  transform: none;
  transform-origin: center bottom;
  object-position: center bottom;
}
.live2d-container {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  z-index: 2;
  background:
    radial-gradient(circle at top, rgba(255,255,255,.95), rgba(233,240,248,.92) 52%, rgba(218,228,239,.94) 100%);
}
.live2d-container canvas {
  display: block;
  transform: none;
  transform-origin: center bottom;
}
.avatar-glow {
  position: absolute;
  inset: -10px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity .35s;
  z-index: 1;
  border: 1px solid rgba(15,159,143,.26);
  display: none;
}
.avatar-glow.active { opacity: 1; animation: breathe-glow 2s ease-in-out infinite; }
@keyframes breathe-glow { 0%, 100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.025); opacity: 1; } }
.avatar-mood-ring {
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color .35s;
  z-index: 3;
  pointer-events: none;
  display: none;
}
.avatar-mood-ring.speaking { border: none; animation: none; box-shadow: none; }
.avatar-mood-ring.thinking { border-color: var(--warning); animation: mood-pulse 2s ease-in-out infinite; }
.avatar-mood-ring.listening { border-color: var(--blue); }
@keyframes mood-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(15,159,143,0); } 50% { box-shadow: 0 0 0 5px rgba(15,159,143,.14); } }
.speaking-indicator {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: none !important;
  gap: 4px;
  z-index: 5;
  height: 28px;
  align-items: flex-end;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
}
.speaking-indicator.active { display: none !important; }
.speaking-indicator span { display: block; width: 4px; background: var(--primary); border-radius: 2px; animation: speak-bar .5s ease-in-out infinite; }
.speaking-indicator span:nth-child(1) { height: 8px; animation-delay: 0s; }
.speaking-indicator span:nth-child(2) { height: 16px; animation-delay: .1s; }
.speaking-indicator span:nth-child(3) { height: 22px; animation-delay: .2s; }
.speaking-indicator span:nth-child(4) { height: 16px; animation-delay: .3s; }
.speaking-indicator span:nth-child(5) { height: 8px; animation-delay: .4s; }
@keyframes speak-bar { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1.2); } }
.avatar-wrapper.speaking .avatar-img { animation: avatar-talk .45s ease-in-out infinite alternate; }
.avatar-wrapper.speaking::before {
  content: "";
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 18px;
  background: rgba(15,159,143,.18);
  border-radius: 50%;
  animation: mouth-glow .55s ease-in-out infinite alternate;
  z-index: 4;
  pointer-events: none;
  display: none;
}
@keyframes avatar-talk { 0% { transform: scale(1); } 100% { transform: scale(1.012); } }
@keyframes mouth-glow { 0% { opacity: .45; transform: translateX(-50%) scale(.88); } 100% { opacity: 1; transform: translateX(-50%) scale(1.12); } }
.avatar-wrapper.thinking .avatar-img { filter: brightness(.97) saturate(.98); }
.thinking-hint {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 6;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #7c5600;
  border: 1px solid rgba(251,191,36,.55);
  box-shadow: 0 12px 24px rgba(15,23,42,.18);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.avatar-wrapper.thinking .thinking-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.video-name { font-size: 12px; color: #fff; font-weight: 600; text-align: center; }

.user-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 196px;
  height: 128px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(203,213,225,.95);
  background: #020617;
  z-index: 45;
  box-shadow: 0 20px 40px rgba(15,23,42,.28);
  user-select: none;
  --pip-video-scale: 1;
  --pip-pan-x: 0px;
  --pip-pan-y: 0px;
}
.pip-toolbar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
  cursor: grab;
  touch-action: none;
}
.pip-toolbar:active { cursor: grabbing; }
.pip-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-panel video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate(var(--pip-pan-x), var(--pip-pan-y)) scale(var(--pip-video-scale));
  transform-origin: center center;
  touch-action: none;
  cursor: grab;
}
.user-panel video:active { cursor: grabbing; }

/* preview 模式：把 #avatar-wrapper 移到这个 slot 里，PIP 显示真正的 Live2D 面试官 */
.pip-avatar-slot {
  position: absolute;
  inset: 0;
  display: none;
}
.pip-avatar-slot > * { pointer-events: auto; }
body[data-camera-view="preview"] .user-panel video { display: none; }
body[data-camera-view="preview"] .user-panel .pip-avatar-slot { display: block; }
body[data-camera-view="preview"] #pip-video-name { background: rgba(79,124,255,.85); }

/* avatar-wrapper 被搬进 PIP 时撑满；正常情况下用原始布局 */
.pip-avatar-slot .avatar-wrapper {
  width: 100% !important;
  height: 100% !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  margin: 0 !important;
}
.pip-avatar-slot .live2d-container,
.pip-avatar-slot .avatar-img {
  width: 100% !important;
  height: 100% !important;
}
.pip-avatar-slot .thinking-hint,
.pip-avatar-slot .speaking-indicator,
.pip-avatar-slot .user-speaking-indicator,
.pip-avatar-slot .avatar-glow,
.pip-avatar-slot .avatar-mood-ring { display: none; }
.user-panel .video-name {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15,23,42,.72);
  color: #fff;
}
.pip-action {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(15,23,42,.72);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.pip-zoom-value {
  min-width: 44px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(15,23,42,.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.pip-resize-handle {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  border-right: 2px solid rgba(255,255,255,.92);
  border-bottom: 2px solid rgba(255,255,255,.92);
  border-bottom-right-radius: 4px;
  cursor: nwse-resize;
  z-index: 4;
  opacity: .92;
}

.question-bar {
  display: flex;
  justify-content: center;
  padding: 0 16px 10px;
  background: transparent;
  border: 0;
  box-shadow: none;
  max-height: none;
  overflow: visible;
  z-index: 10;
}
.question-text {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  width: min(920px, 100%);
  width: min(860px, 100%);
  min-width: min(360px, 100%);
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(203,213,225,.95);
  box-shadow: 0 18px 34px rgba(148,163,184,.18);
  font-size: 15px;
  color: var(--text);
  line-height: 1.65;
  max-height: 120px;
  overflow-y: auto;
}
.loading-dots { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; }
.loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.85); animation: loading-dot 1s ease-in-out infinite; }
.loading-dots span:nth-child(2) { animation-delay: .12s; }
.loading-dots span:nth-child(3) { animation-delay: .24s; }
@keyframes loading-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.room-bottom-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 18px 10px;
  background: transparent;
  z-index: 25;
}
.control-group {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(203,213,225,.9);
  box-shadow: 0 14px 30px rgba(148,163,184,.18);
  backdrop-filter: blur(14px);
}
.ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(248,250,252,.96);
  border: 1px solid rgba(203,213,225,.9);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s, background .18s, border-color .18s, box-shadow .18s;
}
.ctrl-btn:hover { background: #fff; border-color: var(--line-strong); transform: translateY(-1px); }
.ctrl-btn.active { background: rgba(96,165,250,.18); border-color: rgba(147,197,253,.48); }
.ctrl-btn.recording { background: rgba(220,38,38,.24); border-color: rgba(252,165,165,.32); animation: pulse-rec 1s infinite; }
@keyframes pulse-rec { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.22); } 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); } }
.ctrl-danger { background: var(--danger) !important; color: #fff; border-color: var(--danger) !important; }
.ctrl-danger:hover { background: #b91c1c !important; }
.ctrl-btn.conversation { background: rgba(15,159,143,.24); border-color: rgba(94,234,212,.26); animation: pulse-conv 2s infinite; }
@keyframes pulse-conv { 0%, 100% { box-shadow: 0 0 0 0 rgba(15,159,143,.2); } 50% { box-shadow: 0 0 0 7px rgba(15,159,143,0); } }
.ctrl-btn.user-speaking { background: rgba(37,99,235,.26); border-color: rgba(147,197,253,.3); animation: none; box-shadow: 0 0 0 5px rgba(37,99,235,.12); }
.ctrl-chat.active {
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  border-color: #111827;
}
.user-speaking-indicator {
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(37,99,235,.94);
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .25s;
  white-space: nowrap;
  z-index: 10;
}
.user-speaking-indicator.active { opacity: 1; animation: pulse-indicator 1s infinite; }
@keyframes pulse-indicator { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

.chat-panel {
  position: fixed;
  top: 70px;
  right: 18px;
  bottom: 82px;
  width: 318px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border: 1px solid rgba(203,213,225,.86);
  z-index: 35;
  overflow: hidden;
  background: rgba(255,255,255,.96);
  transition: transform .25s ease, opacity .25s ease;
  border-radius: 18px;
  box-shadow: 0 18px 38px rgba(148,163,184,.16);
}
.chat-panel.collapsed {
  transform: translateX(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
}
.chat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: .04em;
  flex-shrink: 0;
  background: rgba(248,250,252,.96);
  text-transform: uppercase;
}
.btn-toggle-chat {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.btn-toggle-chat:hover { color: var(--primary-strong); border-color: var(--primary); }
.chat-history {
  overflow-y: auto;
  padding: 12px 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg {
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(15,23,42,.03);
  margin-bottom: 0;
}
.msg-ai { background: #fff; }
.msg-user {
  background: linear-gradient(135deg, #0f9f8f, #0b766d);
  color: #fff;
  border-color: var(--primary);
  margin-left: 28px;
}
.msg-system {
  background: rgba(251, 191, 36, .12);
  border: 1px dashed rgba(251, 191, 36, .55);
  color: #b45309;
  font-size: 12.5px;
  text-align: center;
  padding: 6px 10px;
}
.msg-system .msg-role { color: #92400e; text-align: center; }
.msg-role { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }
.msg-user .msg-role { color: rgba(255,255,255,.76); }
.msg-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-input-area {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: rgba(248,250,252,.96);
}
.chat-input-area textarea {
  width: 100%;
  flex: 0 0 auto;
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  resize: none;
  max-height: 96px;
  outline: none;
  overflow-y: auto;
}
.chat-input-area textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn-send {
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  min-width: 108px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-send:hover { background: linear-gradient(135deg, #0f172a, #111827); }
.btn-expand-chat {
  position: static;
  width: 48px;
  height: 48px;
  font-size: 19px;
  box-shadow: none;
}
.btn-expand-chat:hover { border-color: var(--line-strong); color: var(--text); background: #fff; }

body[data-camera-view="preview"] .ai-panel .avatar-wrapper { display: none; }
body[data-camera-view="preview"] .preview-stage { display: block; }

/* ========== 评分加载页 ========== */
#page-scoring { align-items: center; justify-content: safe center; background: var(--bg); padding: 24px 0; }
.scoring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: scoring-fade-in .4s ease;
}
@keyframes scoring-fade-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.scoring-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: scoring-spin .7s linear infinite;
}
@keyframes scoring-spin { to { transform: rotate(360deg); } }
.scoring-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }
.scoring-desc { font-size: 14px; color: var(--muted); margin: 0; }
.scoring-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 80vw);
  margin-top: 4px;
}
.scoring-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .35s ease, transform .35s ease, color .35s ease;
}
.scoring-step.visible { opacity: 1; transform: translateX(0); }
.scoring-step.done { color: var(--text); }
.scoring-step-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  color: var(--muted);
  transition: border-color .35s ease, background .35s ease, color .35s ease;
}
.scoring-step.done .scoring-step-icon {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* ========== 报告页和历史页 ========== */
#page-report, #page-history {
  align-items: center;
  justify-content: flex-start;
  background: var(--bg);
  overflow-y: auto;
  padding-top: 28px;
  padding-bottom: 42px;
}
.report-container, .history-container {
  width: min(520px, calc(100vw - 32px));
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
.report-container h2, .history-container h2 { font-size: 21px; color: var(--text); text-align: left; margin-bottom: 20px; }
.score-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.score-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 16px; text-align: left; }
.score-card.total { grid-column: 1 / -1; background: var(--text); border-color: var(--text); }
.score-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.score-card.total .score-label { color: rgba(255,255,255,.72); }
.score-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.score-card.total .score-value { color: #fff; font-size: 38px; }
.feedback-section { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 18px; }
.feedback-section h3 { font-size: 14px; color: var(--text); margin-bottom: 8px; }
#feedback-text { font-size: 13px; color: var(--muted); line-height: 1.75; }
.dynamic-score-cards { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.suggestions-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.suggestions-list li + li { margin-top: 6px; }
.report-actions { display: flex; flex-direction: column; gap: 10px; }
.history-list { margin-bottom: 16px; max-height: 60vh; overflow-y: auto; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .18s, transform .18s;
  font: inherit;
  text-align: left;
}
.history-item:hover { border-color: var(--primary); transform: translateX(3px); }
.h-title { font-size: 14px; color: var(--text); font-weight: 700; }
.h-time { font-size: 12px; color: var(--muted); margin-top: 3px; }
.h-score { font-size: 20px; font-weight: 800; color: var(--primary); }
.empty-hint { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* ========== 登录页 ========== */
.modal {
  position: fixed;
  inset: 0;
  background: #f6f8fb;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-content {
  width: min(860px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: .92fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { color: var(--text); border-color: var(--line-strong); }
.auth-brand {
  padding: 44px;
  background: #10201e;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
}
.auth-brand h2 { font-size: 28px; line-height: 1.2; margin-bottom: 10px; }
.auth-brand p { font-size: 14px; line-height: 1.7; color: rgba(255,255,255,.72); max-width: 250px; }
.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 54px 52px;
}
.auth-form h3 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 24px;
}
.auth-label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}
.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 15px;
  outline: none;
}
.auth-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-help {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px; }
.auth-switch a { color: var(--primary-strong); cursor: pointer; font-weight: 700; text-decoration: none; }
.auth-error { color: var(--danger); font-size: 12px; text-align: center; margin-top: 10px; min-height: 16px; }

.play-hint {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  z-index: 999;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== 移动端 ========== */
@media (max-width: 980px) {
  .interview-room { grid-template-rows: 58px minmax(0, 1fr) auto; }
  .room-main { padding: 18px 18px 18px; }
  .ai-panel { width: 100%; }
  .chat-panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 88px;
    width: auto;
    max-height: 46vh;
  }
  .question-bar { padding: 0 18px 18px; }
  .question-text { width: min(100%, 780px); min-width: 0; }
  .user-panel { right: 28px; bottom: 108px; width: 150px; height: 98px; }
}

@media (max-width: 720px) {
  .top-bar { padding: 0 16px; }
  .home-container { padding: 24px; }
  .modal { padding: 0; }
  .modal-content {
    min-height: var(--vh, 100vh);
    border-radius: 0;
    grid-template-columns: 1fr;
  }
  .auth-brand {
    min-height: 190px;
    padding: 32px 28px;
    justify-content: flex-end;
  }
  .auth-form { padding: 30px 28px 42px; }
  .room-top-bar { padding: 0 16px; }
  .room-main { padding: 14px; }
  .panel-toolbar { padding: 12px 12px 0; }
  .panel-toolbar-right { gap: 8px; }
  .panel-controls { gap: 6px; }
  .panel-control-btn { min-width: 34px; }
  .avatar-wrapper {
    width: min(260px, 78vw);
    max-height: none;
  }
  .preview-stage {
    width: min(100%, 640px);
    max-height: none;
  }
  .question-bar { padding: 0 14px 14px; }
  .question-text { font-size: 14px; min-width: 0; width: 100%; }
  .chat-panel { left: 8px; right: 8px; bottom: 82px; max-height: 50vh; }
  .chat-input-area { padding: 10px 12px 12px; }
  .btn-send { min-width: 96px; }
  .user-panel { width: 118px; height: 78px; right: 20px; bottom: 104px; }
  .thinking-hint { top: 14px; font-size: 11px; }
}

@media (max-width: 480px) {
  .top-user { display: none !important; }
  .home-container { width: calc(100vw - 24px); padding: 20px; }
  .logo-area h1 { font-size: 23px; }
  .mode-toggle { grid-template-columns: 1fr; }
  .score-cards { grid-template-columns: 1fr; }
  .score-card.total { grid-column: auto; }
  .ctrl-btn { width: 44px; height: 44px; font-size: 18px; }
  .control-group { gap: 9px; }
  .auth-brand { min-height: 170px; }
  .auth-brand h2 { font-size: 24px; }
}


/* 备课用的简历输入框 */
.brief-input {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border, #d8dde5);
  background: var(--surface, #fff);
  color: var(--text, #1a1a1a);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color .15s;
}
.brief-input:focus {
  outline: none;
  border-color: #4f7cff;
}
.brief-hint {
  margin-top: 6px;
  color: var(--muted, #888);
  font-size: 12px;
  line-height: 1.4;
}

/* 简历导入按钮 + 状态文字（在 textarea 上方） */
.brief-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.brief-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}
.brief-import-status {
  font-size: 12px;
  color: var(--muted, #888);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brief-import-status.success { color: #16a34a; }
.brief-import-status.error { color: #dc2626; }
.brief-import-status.loading { color: #4f7cff; }


/* 备课页进度条 */
.prep-progress-track {
  width: min(420px, 80vw);
  height: 10px;
  margin: 18px auto 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}
.prep-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f7cff, #38bdf8);
  border-radius: 999px;
  transition: width 0.3s ease-out;
  box-shadow: 0 0 8px rgba(79, 124, 255, 0.4);
}
.prep-progress-label {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #4f7cff;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}
