:root {
  --bg: #14171c;
  --panel: #1e232b;
  --panel-2: #262c36;
  --line: #333b47;
  --text: #e8ebf0;
  --muted: #9aa4b2;
  --accent: #e0524c;
  --accent-dark: #b23c38;
  --green: #3fb96a;
  --amber: #e0a63f;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ---------- 首屏 ---------- */
.screen { min-height: 100vh; }

#lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lobby-inner { width: 100%; max-width: 420px; text-align: center; }

.logo { font-size: 56px; }

#lobby h1 { font-size: 26px; margin: 8px 0 4px; }

.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.warn {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(224, 166, 63, 0.12);
  border: 1px solid rgba(224, 166, 63, 0.35);
  border-radius: 10px;
  color: var(--amber);
  font-size: 13px;
  text-align: left;
}

/* ---------- 卡片与表单 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

#lobby .card { text-align: left; }

.field { display: block; margin-bottom: 14px; }

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select, .chatRow input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}

.field input:focus, .field select:focus, .chatRow input:focus {
  border-color: var(--accent);
}

.field.inline { margin-bottom: 12px; }

.field.inline select { margin-top: 2px; }

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel-2);
  padding: 10px 16px;
  transition: filter 0.15s, transform 0.05s;
}

.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary { background: var(--accent); font-weight: 600; }
.btn.primary.big { width: 100%; padding: 13px; font-size: 17px; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.small { padding: 6px 12px; font-size: 13px; }

.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- 房间页 ---------- */
#room {
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.room-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}

.badge {
  margin-left: auto;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.ok { color: var(--green); border-color: var(--green); }
.badge.bad { color: var(--accent); border-color: var(--accent); }

.banner {
  background: rgba(224, 82, 76, 0.1);
  border: 1px solid rgba(224, 82, 76, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

.banner.info {
  background: rgba(63, 185, 106, 0.08);
  border-color: rgba(63, 185, 106, 0.35);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.card h2 { font-size: 15px; margin-bottom: 12px; color: var(--muted); font-weight: 600; }

/* ---------- 成员行 ---------- */
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.member:last-child { border-bottom: none; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.ok { background: var(--green); }
.dot.bad { background: var(--accent); }
.dot.wait { background: var(--amber); }

.mname { min-width: 90px; font-size: 15px; }

.mstate { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

.meter {
  flex: 1;
  max-width: 220px;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--accent));
  transition: width 0.06s linear;
}

/* ---------- 录音卡 ---------- */
.record-card { grid-row: span 2; display: flex; flex-direction: column; }

.record-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 0 22px;
}

.btn.record {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
  background: var(--panel-2);
  border: 3px solid var(--accent);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn.record .rec-dot { font-size: 22px; }

.btn.record.recording {
  background: var(--accent);
  color: #fff;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 82, 76, 0.45); }
  50% { box-shadow: 0 0 0 16px rgba(224, 82, 76, 0); }
}

.timer {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.timer.on { color: var(--accent); }

.clap {
  margin-top: 10px;
  font-size: 14px;
  color: var(--amber);
  text-align: center;
}

.done {
  margin-top: 10px;
  font-size: 14px;
  color: var(--green);
  text-align: center;
  word-break: break-all;
}

/* ---------- 聊天卡 ---------- */
.chat-card { display: flex; flex-direction: column; min-height: 220px; }

#chatLog {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

#chatLog .line b { color: var(--accent); margin-right: 6px; }

#chatLog .line.sys { color: var(--muted); font-size: 12px; }

.chatRow { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 字幕卡 ---------- */
.caption-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cap-note {
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}

#captionBtn.on {
  color: var(--green);
  border-color: var(--green);
}

#captionLog {
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#captionLog:empty::before {
  content: "开启后，你说的话会实时出现在这里（对方也会看到）";
  color: var(--muted);
  font-size: 13px;
}

.cap-final b, .cap-interim b { color: var(--green); margin-right: 6px; }

.cap-interim {
  color: var(--muted);
  font-style: italic;
}

/* ---------- 整体布局：三瀑布列 ---------- */
#room {
  max-width: 1700px;
  margin: 0 auto;
  padding: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) clamp(280px, 25vw, 400px) clamp(280px, 25vw, 400px);
  gap: 14px;
  align-items: start;
}

/* 第一列：设置 + 录音 + 聊天，单列堆叠 */
.main-col .grid { grid-template-columns: 1fr; }

.record-card { grid-row: auto; }

/* 第二列：提词器，占满视口高度 */
.tele-col {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  min-height: 420px;
  display: flex;
}

.tele-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 0;
}

.tele-card .script-view {
  flex: 1;
  max-height: none;
  min-height: 0;
}

/* 第三列：实时字幕，占满视口高度，内部滚动 */
.caption-col {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  min-height: 420px;
  display: flex;
}

.caption-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 0;
}

.caption-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#captionLog {
  flex: 1;
  max-height: none;
  min-height: 0;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .tele-col, .caption-col { position: static; height: auto; min-height: 0; }
  .tele-card .script-view { max-height: 320px; }
  #captionLog { max-height: 240px; }
}

/* ---------- 提词器卡 ---------- */
.tele-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tele-speed {
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tele-speed input[type="range"] { width: 90px; }

.script-view {
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.9;
}

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

.tl { margin: 3px 0; padding: 0 6px; border-left: 3px solid transparent; }

.tl .sp { margin-right: 8px; }

.tl[data-self="1"] {
  background: rgba(63, 185, 106, 0.07);
  border-left-color: currentColor;
  border-radius: 4px;
}

.tl-heading { font-weight: 700; font-size: 16px; margin: 12px 0 4px; color: var(--text); }

.tl-quote { color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }

.tl-item { padding-left: 18px; position: relative; }

.tl-item::before { content: "•"; position: absolute; left: 6px; color: var(--muted); }

.script-view code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
