:root {
  --bg: #0f1218;
  --panel: #151a23;
  --card: #1b222e;
  --border: #2a3444;
  --text: #e6ebf2;
  --muted: #8b96a8;
  --accent: #4f8cff;
  --green: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #161c27 0%, #12161f 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
}
.status-pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 0 rgba(100, 116, 139, 0.5);
}
.status-pill.connected { color: var(--green); border-color: rgba(34, 197, 94, 0.4); }
.status-pill.connected .dot {
  background: var(--green);
  box-shadow: 0 0 8px 2px rgba(34, 197, 94, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

.status-pill.reconnecting { color: var(--warn); border-color: rgba(245, 158, 11, 0.4); }
.status-pill.reconnecting .dot {
  background: var(--warn);
  animation: pulse-warn 1.2s infinite;
}
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
}

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  padding: 18px 22px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { display: flex; flex-direction: column; gap: 16px; }
.main { min-width: 0; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

/* 表单 */
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 4px;
}
label:first-of-type { margin-top: 0; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121722;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer; margin-top: 12px;
}
.checkbox input { width: auto; accent-color: var(--accent); }
.tts-row { margin-top: 6px; }

/* 按钮 */
.btn {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #24304a;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #2d3c5c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3d78f5; }
.btn.accent { background: #15803d; border-color: #15803d; color: #fff; }
.btn.accent:hover { background: #16a34a; }
.btn.accent.recording { background: var(--danger); border-color: var(--danger); animation: recpulse 1.2s infinite; }
@keyframes recpulse { 0%,100%{ opacity: 1; } 50%{ opacity: 0.75; } }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #24304a; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* 控制区 */
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.controls .btn { flex: 1; min-width: 140px; padding: 12px; font-size: 14px; }

/* 状态输出 */
.stats-head, .transcript-head {
  display: flex; align-items: center; justify-content: space-between;
}
.mono {
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
}
.stats pre.mono {
  margin: 12px 0 0;
  padding: 12px;
  background: #121722;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 200px;
  color: #c7d2e0;
}

/* 翻译结果 */
.transcript-card { display: flex; flex-direction: column; }
.transcript {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
.transcript .empty { color: var(--muted); text-align: center; margin: auto; }
.transcript-item {
  background: #121722;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}
.transcript-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.transcript-meta .pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--accent); background: rgba(79, 140, 255, 0.14);
  padding: 1px 8px; border-radius: 999px;
}
.transcript-meta .time { font-size: 11px; color: var(--muted); margin-left: auto; }
.transcript .rec { color: var(--muted); font-size: 13px; }
.transcript .tr { color: var(--text); font-size: 15px; font-weight: 500; margin-top: 2px; }

/* 日志 */
.log-card { flex: 1; }
.event-log {
  height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  background: #121722;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-line { display: flex; gap: 8px; font-size: 12px; line-height: 1.5; }
.log-line .t { color: #5b6675; flex-shrink: 0; }
.log-line .tag { flex-shrink: 0; font-weight: 700; }
.log-line .msg { word-break: break-all; white-space: pre-wrap; }
.log-line.info .tag { color: var(--accent); }
.log-line.warn .tag { color: var(--warn); }
.log-line.error .tag { color: var(--danger); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #37455c; }
