/* AI 英语直播间 · 竖屏（9:16）用户向 UI */
:root {
  --bg: #070a0f;
  --stage: #0c1118;
  --panel: #121a24;
  --panel-2: #182130;
  --border: #243041;
  --text: #f0f4f8;
  --muted: #8b9aab;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --gift: #ff3b6b;
  --teach: #a78bfa;
  --live: #ff2d55;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2740 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* 桌面：手机壳居中；移动端：全屏竖屏 */
.phone-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  box-shadow: 0 0 0 1px #00000080, 0 24px 80px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

@media (min-width: 768px) {
  body { padding: 24px 0; align-items: center; }
  .phone-shell {
    min-height: min(900px, calc(100vh - 48px));
    height: min(900px, calc(100vh - 48px));
    border-radius: 28px;
    border: 1px solid var(--border);
  }
}

@media (max-width: 430px) {
  .phone-shell {
    max-width: none;
    border: none;
    box-shadow: none;
  }
}

.live-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--safe-t);
}

/* —— 顶栏 —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 8px;
  background: linear-gradient(180deg, #101825 0%, transparent 100%);
  flex-shrink: 0;
}

.live-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255, 45, 85, 0.6);
  animation: livePulse 1.4s ease-out infinite;
  flex-shrink: 0;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 45, 85, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(255, 45, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 45, 85, 0); }
}

.live-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--live);
  color: #fff;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1;
}

.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text .sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* —— 状态条 —— */
.status-rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 14px 10px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #0a0f16cc;
  flex-shrink: 0;
}

.state-main {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

.remain {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
}

.state-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.conn.ok { color: var(--accent-2); }
.conn.off { color: var(--gift); }
.sep { opacity: 0.45; }

.tts-badge {
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--muted);
}
.tts-badge.bad { color: var(--gift); border-color: var(--gift); }

.audio-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.vol-label { font-size: 11px; color: var(--muted); }
.vol input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent-2);
  cursor: pointer;
  height: 20px;
}

/* —— 按钮 —— */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.75; cursor: default; filter: none; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); }

.btn.icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.btn.icon.is-muted { color: var(--gift); border-color: var(--gift); }

.btn.tiny {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}

.btn.accent {
  background: linear-gradient(180deg, #34d399, #16a34a);
  color: #052e16;
  font-weight: 800;
  font-size: 12px;
  padding: 9px 12px;
  box-shadow: 0 2px 0 #14532d;
}
.btn.accent.ok {
  background: #14532d;
  color: #86efac;
  border: 1px solid #166534;
  box-shadow: none;
}

.btn.play {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

/* —— 浮层 —— */
.welcome-toast {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, #14532d, #166534);
  border: 1px solid #22c55e;
  color: #ecfdf5;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100% - 32px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.welcome-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.speak-hud {
  position: absolute;
  right: 12px;
  bottom: auto;
  top: 50%;
  transform: translateY(-50%);
  background: #1e3a5fee;
  border: 1px solid var(--accent);
  color: #93c5fd;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  z-index: 40;
  pointer-events: none;
}

/* —— 教学主舞台 —— */
.stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.teach-stage {
  flex: 1.35 1 0;
  margin: 10px 10px 0;
  min-height: 220px;
  background:
    linear-gradient(160deg, #152033 0%, var(--panel) 42%),
    var(--panel);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

.stage-head {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1a2433, #141c28);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.stage-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stage-emoji { font-size: 18px; }

.lesson-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-title small {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  margin-left: 8px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  flex: 1;
  min-width: 0;
  outline: none;
}

.teach-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.section-label {
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.section-label .hint {
  font-size: 11px;
  letter-spacing: 0;
  opacity: 0.8;
  flex-shrink: 0;
}

.vocab-list { display: flex; flex-direction: column; gap: 8px; }

.vocab {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.vocab.speaking,
.sentence-list li.speaking {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2), 0 0 16px rgba(34, 197, 94, 0.15);
}

.vocab-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.vocab .w {
  font-weight: 800;
  color: #93c5fd;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.vocab .ph { color: var(--muted); font-size: 12px; }
.vocab .zh {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-left: auto;
}
.vocab .ex {
  font-size: 13px;
  color: #86efac;
  margin-top: 6px;
  font-style: italic;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}
.vocab .ex span { flex: 1; }

.btn-say,
.btn-replay {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  min-width: 36px;
  min-height: 32px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-say:hover,
.btn-replay:hover {
  color: var(--text);
  border-color: var(--accent-2);
}

.sentence-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sentence-list li {
  font-size: 14px;
  line-height: 1.5;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sentence-list li > span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-top: 4px;
}
.s-row { display: flex; align-items: flex-start; gap: 8px; }
.s-en { flex: 1; font-weight: 600; }

.quiz-card {
  background: #1a1630;
  border: 1px solid #4c3d7a;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
}
.quiz-card .q { font-weight: 700; margin-bottom: 6px; }
.quiz-card .opts { color: #c4b5fd; }
.quiz-card .ans { color: var(--accent-2); margin-top: 6px; font-size: 12px; }

/* —— 互动区（弹幕/回复） —— */
.chat-stage {
  flex: 1 1 0;
  margin: 10px;
  min-height: 200px;
  max-height: 42%;
}

.chat-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 8px 0;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 6px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.chat-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.chat-tab .count {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 22px;
}

.chat-panels {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.chat-panel.is-active { display: flex; }

.feed {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.dm {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
}

.dm .meta,
.rp .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}
.meta-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dm .user {
  color: #7dd3fc;
  font-weight: 700;
}
.dm .body {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  font-weight: 600;
}
.tag.learn { background: #3b82f633; color: #93c5fd; }
.tag.question { background: #a78bfa33; color: #c4b5fd; }
.tag.chat { background: #22c55e33; color: #86efac; }
.tag.gift { background: #f43f5e33; color: #fda4af; }
.tag.greeting { background: #38bdf833; color: #7dd3fc; }
.tag.complaint { background: #f59e0b33; color: #fcd34d; }
.tag.ignore,
.tag.unknown { background: #64748b33; color: #94a3b8; }

.rp {
  background: #152033;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 9px 10px;
  animation: slideIn 0.25s ease;
}
.rp.teaching { border-left-color: var(--teach); }
.rp.gift { border-left-color: var(--gift); background: #2a1520; }
.rp.system { border-left-color: var(--warn); background: #2a2215; }
.rp .body {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.rp .to { color: var(--muted); font-size: 12px; }
.rp .to strong { color: #7dd3fc; }

.intent-stats {
  border-top: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--panel-2);
  flex-shrink: 0;
}
.intent-stats span {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
}

.input-row {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
}
.input-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
}
.input-row input:focus { border-color: var(--accent); }
.input-row .btn {
  border-radius: 999px;
  padding: 10px 16px;
  flex-shrink: 0;
}

.quick {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 0 8px 8px;
  background: var(--panel-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.quick::-webkit-scrollbar { display: none; }

.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 14px calc(8px + var(--safe-b));
  font-size: 10px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--stage);
}

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 8px;
}

/* 窄高屏：教学再高一点 */
@media (max-height: 740px) {
  .teach-stage { min-height: 180px; }
  .chat-stage { max-height: 48%; }
  .brand-text .sub { display: none; }
}

/* 系统缩放/横屏仍保持竖屏观感 */
@media (orientation: landscape) and (max-height: 500px) {
  body { padding: 0; align-items: stretch; }
  .phone-shell {
    max-width: none;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border: none;
  }
}
