/* ===== English Teacher — 渐变浅色主题 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #6366f1;
  --primary-deep: #4f46e5;
  --danger: #ef4444;
  --text: #1e293b;
  --text-2: #64748b;
  --bubble-user: linear-gradient(135deg, #6366f1, #8b5cf6);
  --bubble-bot: #ffffff;
  --mark: #d97706;      /* 纠错标记 */
  --radius: 18px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  /* 淡淡的渐变背景 */
  background: linear-gradient(160deg, #eef2ff 0%, #fdf2f8 45%, #ecfeff 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  height: 100dvh;
}

.hidden { display: none !important; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}
.teacher-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar-big {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  transition: transform 0.15s;
}
.avatar-big:active { transform: scale(0.92); }
#teacher-name { font-weight: 700; font-size: 16px; }
.status { font-size: 12px; color: var(--text-2); }
.top-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-deep);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.call { background: rgba(16, 185, 129, 0.15); color: #059669; }
.icon-btn.dark { background: rgba(0, 0, 0, 0.06); color: var(--text); }

/* ===== 聊天区 ===== */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#view-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(250, 204, 21, 0.18);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: #92400e;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 12px;
}
#btn-back-today {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.msg { display: flex; gap: 8px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot { align-self: flex-start; }

.msg .avatar-mini {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}
.msg.user .avatar-mini { background: linear-gradient(135deg, #c7d2fe, #e0e7ff); }

.bubble-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.msg.user .bubble {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot .bubble {
  background: var(--bubble-bot);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.08);
}
.bubble.partial { opacity: 0.65; font-style: italic; }

/* 口语纠错展示 */
.correction {
  font-size: 13px;
  color: var(--text-2);
  background: rgba(255, 251, 235, 0.9);
  border: 1px dashed rgba(217, 119, 6, 0.4);
  border-radius: 10px;
  padding: 6px 10px;
  line-height: 1.5;
}
.correction .c-label { color: #16a34a; font-weight: 600; margin-right: 4px; }
.correction .mark { color: var(--mark); font-weight: 700; text-decoration: underline wavy rgba(217, 119, 6, 0.5); }

.msg-tools { display: flex; gap: 6px; }
.msg.user .msg-tools { justify-content: flex-end; }
.tool {
  border: none;
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-2);
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tool svg { width: 15px; height: 15px; fill: currentColor; }
.tool.faved { background: rgba(250, 204, 21, 0.25); color: #d97706; }
.tool.playing { background: rgba(99, 102, 241, 0.2); color: var(--primary-deep); }

/* ===== 底部输入栏 ===== */
.inputbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(99, 102, 241, 0.12);
}
#text-input {
  flex: 1;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
#text-input:focus { border-color: var(--primary); }
.send-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* 圆形话筒大按钮 */
.mic-circle {
  width: 60px; height: 60px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
  transition: transform 0.12s, background 0.2s;
  position: relative;
}
.mic-circle svg { width: 26px; height: 26px; fill: currentColor; }
.mic-circle:active { transform: scale(0.92); }
.mic-circle.listening {
  background: linear-gradient(135deg, #ef4444, #f97316);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ===== 划词翻译弹窗 ===== */
#trans-popup {
  position: fixed;
  z-index: 60;
  max-width: 300px;
  min-width: 160px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.15);
  padding: 10px 34px 10px 12px;
}
.trans-src { font-size: 12px; color: var(--text-2); margin-bottom: 4px; word-break: break-word; }
.trans-body { font-size: 15px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
#trans-close {
  position: absolute;
  top: 4px; right: 4px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-2);
  cursor: pointer;
  width: 26px; height: 26px;
}

/* ===== 通话全屏 ===== */
#call-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(160deg, #312e81 0%, #6d28d9 50%, #0e7490 100%);
  color: #fff;
}
.call-timer { font-size: 15px; opacity: 0.85; letter-spacing: 1px; }
.call-avatar {
  width: 132px; height: 132px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.call-avatar.speaking { animation: call-pulse 1s infinite; }
@keyframes call-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
.call-status { font-size: 18px; font-weight: 600; }
.call-caption {
  max-width: 82%;
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  min-height: 48px;
  opacity: 0.92;
  word-break: break-word;
}
.hangup {
  margin-top: 14px;
  width: 68px; height: 68px;
  border: none;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}
.hangup svg { width: 30px; height: 30px; fill: currentColor; transform: rotate(135deg); }
.hangup:active { transform: scale(0.92); }

/* ===== 面板（设置/历史/头像）===== */
.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.panel {
  width: 100%;
  max-width: 720px;
  max-height: 82vh;
  background: #fdfdff;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: slide-up 0.22s ease-out;
}
.panel.small { max-height: 50vh; }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0.5; } }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  font-size: 17px;
  font-weight: 700;
}
.tabs { display: flex; gap: 8px; padding: 0 16px 10px; border-bottom: 1px solid #eef0f7; }
.tab {
  border: none;
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-2);
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; }

.tab-body { overflow-y: auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 12px; }

/* 角色卡片 */
.persona-card {
  border: 1.5px solid rgba(99, 102, 241, 0.18);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}
.persona-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.persona-row { display: flex; align-items: center; gap: 10px; }
.persona-avatar {
  width: 46px; height: 46px;
  border: none;
  border-radius: 50%;
  font-size: 25px;
  cursor: pointer;
  flex: none;
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
}
.persona-name {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
  outline: none;
}
.persona-name:focus { border-color: var(--primary); }
.persona-prompt {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 72px;
  resize: vertical;
  outline: none;
  font-family: inherit;
  color: var(--text-2);
}
.persona-prompt:focus { border-color: var(--primary); }
.persona-ops { display: flex; gap: 8px; }
.chip {
  border: none;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-deep);
}
.chip.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.chip.current { background: var(--primary); color: #fff; }

.wide-btn {
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  cursor: pointer;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-deep);
}
.wide-btn.primary { background: var(--primary); color: #fff; }

/* 通用设置字段 */
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  padding: 10px 4px;
}
.field > span { flex: none; }
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); }
.field select, .field input[type="text"] {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  min-width: 0;
  max-width: 55%;
}
.field input[type="range"] { flex: 1; max-width: 55%; accent-color: var(--primary); }

/* 历史列表 */
.date-item, .fav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #eef0f7;
  cursor: pointer;
}
.date-item:active, .fav-item:active { background: #f5f6ff; }
.date-item .d { font-weight: 600; font-size: 15px; }
.date-item .n { font-size: 12px; color: var(--text-2); }
.fav-item { flex-direction: column; align-items: flex-start; gap: 4px; }
.fav-item .f-date { font-size: 12px; color: var(--text-2); }
.fav-item .f-text {
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fav-item .f-role { font-size: 11px; padding: 1px 8px; border-radius: 6px; background: rgba(99, 102, 241, 0.12); color: var(--primary-deep); }

/* 头像选择 */
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 8px 16px 20px; }
.avatar-cell {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  background: rgba(99, 102, 241, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-cell:active { transform: scale(0.9); background: rgba(99, 102, 241, 0.18); }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(30, 41, 59, 0.9);
  color: #fff;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 80%;
}
