:root {
  --bg: #0e1116;
  --bg-elevated: #161b22;
  --bg-soft: #1c232d;
  --border: #2a323d;
  --text: #e6edf3;
  --text-muted: #8b98a8;
  --accent: #4f9cf9;
  --accent-strong: #2f7fe0;
  --danger: #e5534b;
  --danger-strong: #c9403a;
  --success: #3fb950;
  --warning: #d29922;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #16202b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2 {
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.05rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.muted {
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- 顶栏 ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.nav a {
  color: var(--text-muted);
}

.nav a:hover {
  color: var(--text);
}

.logout-form {
  margin: 0;
}

.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.linkish:hover {
  color: var(--danger);
}

/* ---------- 布局 ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.page-head {
  margin-bottom: 1.25rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  background: #232c38;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06111f;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(229, 83, 75, 0.12);
}

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 1.35rem;
}

.login-form {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.login-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.18);
}

.login-form .btn {
  margin-top: 0.4rem;
}

.password-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.password-row input {
  flex: 1;
  min-width: 0;
}

.password-row .btn.small {
  margin-top: 0;
  white-space: nowrap;
}

.muted.small {
  font-size: 0.78rem;
  margin: 0;
}

.passcode-mask {
  -webkit-text-security: disc;
}

.form-error {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(229, 83, 75, 0.12);
  border: 1px solid rgba(229, 83, 75, 0.4);
  color: #ffb4ae;
  font-size: 0.88rem;
}

/* ---------- 通话页 ---------- */
.audio-panel audio {
  display: none;
}

.call-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0 1rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 80px;
}

.label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-value {
  font-size: 1.05rem;
  font-weight: 600;
}

.call-actions {
  display: flex;
  gap: 0.75rem;
}

.error-box {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: rgba(229, 83, 75, 0.12);
  border: 1px solid rgba(229, 83, 75, 0.4);
  color: #ffb4ae;
  font-size: 0.9rem;
}

.captions {
  display: grid;
  gap: 1rem;
}

.caption-block {
  border-left: 3px solid var(--border);
  padding-left: 0.85rem;
}

.caption-block:first-child {
  border-left-color: var(--accent);
}

.caption-block:last-child {
  border-left-color: var(--success);
}

.caption-text {
  margin: 0.3rem 0 0;
  min-height: 1.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.call-log {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* ---------- 历史列表 ---------- */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item a {
  display: block;
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.history-item a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.history-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.history-date {
  font-weight: 600;
}

.history-meta {
  margin-top: 0.25rem;
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-ongoing {
  color: var(--accent);
  border-color: rgba(79, 156, 249, 0.5);
}

.badge-finished {
  color: var(--success);
  border-color: rgba(63, 185, 80, 0.5);
}

.badge-interrupted {
  color: var(--warning);
  border-color: rgba(210, 153, 34, 0.5);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

/* ---------- 通话详情 ---------- */
.transcript {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.bubble {
  max-width: 82%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.bubble.user {
  align-self: flex-end;
  background: rgba(79, 156, 249, 0.12);
  border-color: rgba(79, 156, 249, 0.35);
}

.bubble.assistant {
  align-self: flex-start;
}

.bubble-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.bubble-text {
  margin: 0.2rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.score-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.score-item strong {
  font-size: 1.15rem;
}

.suggestion-text {
  margin: 0;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.not-found {
  text-align: center;
  padding: 3rem 1rem;
}

.not-found h1 {
  font-size: 3rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.not-found .detail-actions {
  justify-content: center;
}

/* ---------- 生词本 / 错题本 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.vocab-card,
.mistake-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mistake-card {
  margin-bottom: 0.75rem;
}

.vocab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.vocab-word {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.vocab-meaning {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.vocab-example {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  word-break: break-word;
}

.card-actions {
  margin-top: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn.small {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.inline-form input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.inline-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.18);
}

.form-message {
  margin: 0.6rem 0 0;
  font-size: 0.88rem;
  color: var(--warning);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-tab {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.filter-tab:hover {
  color: var(--text);
  text-decoration: none;
}

.filter-tab.active {
  color: #06111f;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- 复习卡片 ---------- */
.review-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 1.1rem;
  text-align: center;
}

.review-word {
  margin: 0 0 0.6rem;
  font-size: 1.35rem;
  font-weight: 600;
  word-break: break-word;
}

.review-meaning,
.review-example {
  margin: 0.35rem 0;
  word-break: break-word;
}

.review-example {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.review-detail {
  margin-top: 0.75rem;
  text-align: left;
}

.review-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

/* ---------- 详细分析报告 ---------- */
.report-block {
  margin-bottom: 1rem;
}

.report-block:last-of-type {
  margin-bottom: 0.25rem;
}

.report-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.report-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.report-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.report-line {
  margin: 0.25rem 0;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  word-break: break-word;
}

.report-line .label {
  flex: 0 0 auto;
  min-width: 3.4rem;
}

.corrected {
  color: var(--success);
}

.suggestion-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.panel-actions {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.6rem;
}

/* ---------- 移动端 ---------- */
@media (max-width: 480px) {

  .container {
    padding: 1.1rem 0.85rem 1.75rem;
  }

  .call-actions {
    flex-direction: column;
  }

  .call-actions .btn {
    width: 100%;
  }

  .call-meta {
    justify-content: space-between;
    gap: 0.5rem;
  }

  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bubble {
    max-width: 92%;
  }

  .nav {
    gap: 0.65rem;
    font-size: 0.85rem;
  }

  .detail-actions {
    flex-direction: column;
  }

  .detail-actions .btn {
    width: 100%;
  }
}

/* ---------- 通话体验：状态色 / 字幕气泡 / 禁用态 ---------- */
#statusText[data-state="connecting"] {
  color: var(--warning);
}

#statusText[data-state="live"] {
  color: var(--success);
}

#statusText[data-state="ended"] {
  color: var(--text-muted);
}

#timer,
#remaining {
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

#timer {
  font-size: 1.15rem;
}

.call-actions .btn {
  min-width: 132px;
}

.call-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.6);
}

/* 通话中的面板边框提示 */
.call-page[data-call-state="live"] .audio-panel {
  border-color: rgba(63, 185, 80, 0.45);
}

.call-page[data-call-state="connecting"] .audio-panel {
  border-color: rgba(210, 153, 34, 0.45);
}

.error-box:not([hidden]) {
  display: block;
}

/* 字幕气泡：用户靠右、AI 靠左 */
.captions {
  grid-template-columns: minmax(0, 1fr);
}

.caption-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-left: none;
  padding-left: 0;
}

.caption-block:first-child {
  align-items: flex-end;
  text-align: right;
}

.caption-block:last-child {
  align-items: flex-start;
  text-align: left;
}

.caption-block .caption-text {
  display: inline-block;
  max-width: 86%;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.caption-block:first-child .caption-text {
  background: rgba(79, 156, 249, 0.14);
  border-color: rgba(79, 156, 249, 0.35);
  border-bottom-right-radius: 4px;
}

.caption-block:last-child .caption-text {
  background: rgba(63, 185, 80, 0.08);
  border-color: rgba(63, 185, 80, 0.28);
  border-bottom-left-radius: 4px;
}

.caption-text:empty::before {
  content: "…";
  color: var(--text-muted);
}

/* 对话记录气泡与复盘入口 */
.call-log .bubble {
  max-width: 88%;
}

.call-log .bubble.user {
  align-self: flex-end;
}

.call-log .bubble.assistant {
  align-self: flex-start;
}

.call-log .bubble-text {
  font-size: 0.95rem;
}

.call-log .review-link {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.call-log .review-link a {
  font-weight: 600;
}

@media (max-width: 480px) {
  .call-actions .btn {
    width: 100%;
    min-width: 0;
  }

  #timer {
    font-size: 1.25rem;
  }

  .caption-block .caption-text {
    max-width: 100%;
  }

  .call-log .bubble {
    max-width: 95%;
  }
}
