/* ==========================================================================
   声笺 · 多人语音转写
   设计语言：极简、留白、系统字体、柔和圆角与轻阴影
   ========================================================================== */

:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-border: rgba(0, 0, 0, 0.04);
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #86868b;
  --line: rgba(60, 60, 67, 0.1);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --accent: #ff3b30;
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.03), 0 6px 20px rgba(0, 0, 0, 0.04);
  --radius: 26px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --card: #1c1c1e;
    --card-border: rgba(255, 255, 255, 0.06);
    --text: #f5f5f7;
    --text-2: #d2d2d7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.1);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --blue: #0a84ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(760px 420px at 18% -8%, rgba(10, 132, 255, 0.12), transparent 62%),
    radial-gradient(720px 400px at 92% 4%, rgba(255, 59, 48, 0.08), transparent 58%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 3px;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   顶栏
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 28px 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg-elevated);
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}

@media (prefers-color-scheme: dark) {
  .brand-mark {
    background: #f5f5f7;
    color: #1d1d1f;
  }
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-text strong {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-text small {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill[hidden] {
  display: none;
}

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

.pill-dot-muted {
  background: var(--muted);
}

.speaker-pill {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

.speaker-pill .pill-dot {
  background: var(--blue);
}

/* --------------------------------------------------------------------------
   布局与卡片
   -------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  max-width: 1060px;
  margin: 0 auto;
  padding: 18px 28px 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.55s cubic-bezier(0.22, 0.68, 0.24, 1) both;
}

.recorder {
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  animation-delay: 0.03s;
}

.transcript-card {
  display: flex;
  flex-direction: column;
  min-height: 540px;
  max-height: calc(100vh - 168px);
  animation-delay: 0.08s;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s ease;
}

body[data-state="recording"] .status {
  color: var(--text);
}
body[data-state="recording"] .status::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.16);
  animation: blink 1.6s ease-in-out infinite;
}
body[data-state="paused"] .status::before {
  background: var(--orange);
}
body[data-state="error"] .status {
  color: var(--accent);
}
body[data-state="error"] .status::before {
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   录音台
   -------------------------------------------------------------------------- */

.clock {
  margin-top: 16px;
  font-size: 54px;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

body[data-state="paused"] .clock {
  color: var(--orange);
}

.clock-sub {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.record-wrap {
  position: relative;
  display: grid;
  place-items: center;
  height: 168px;
  margin-top: 4px;
}

.record-halo {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 59, 48, 0.1), rgba(255, 59, 48, 0) 68%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

body[data-state="recording"] .record-halo {
  opacity: 1;
  animation: halo 2.4s ease-out infinite;
}

body[data-state="paused"] .record-halo {
  opacity: 1;
  background: radial-gradient(circle, rgba(255, 149, 0, 0.12), rgba(255, 149, 0, 0) 68%);
}

.record-btn {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 59, 48, 0.34), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s cubic-bezier(0.22, 0.68, 0.24, 1), box-shadow 0.2s ease, background 0.2s ease,
    opacity 0.2s ease;
}

.record-btn:hover:not(:disabled) {
  transform: scale(1.035);
  box-shadow: 0 14px 34px rgba(255, 59, 48, 0.42), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.record-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.record-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  box-shadow: none;
}

.record-btn svg {
  width: 34px;
  height: 34px;
}

.record-btn .icon-stop {
  display: none;
  width: 28px;
  height: 28px;
}

.record-btn.is-recording .icon-mic {
  display: none;
}

.record-btn.is-recording .icon-stop {
  display: block;
}

body[data-state="paused"] .record-btn {
  background: var(--orange);
  box-shadow: 0 10px 28px rgba(255, 149, 0, 0.3);
}

body[data-state="paused"] .record-btn .icon-stop {
  display: none;
}

body[data-state="paused"] .record-btn .icon-mic {
  display: block;
}

.secondary-controls {
  display: flex;
  justify-content: center;
  height: 40px;
  margin-top: -6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body[data-state="recording"] .secondary-controls,
body[data-state="paused"] .secondary-controls {
  opacity: 1;
  pointer-events: auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn .icon-play {
  display: none;
}

.icon-btn.is-paused .icon-pause {
  display: none;
}

.icon-btn.is-paused .icon-play {
  display: block;
}

.icon-btn:hover:not(:disabled) {
  background: var(--fill-strong);
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}

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

.icon-btn.is-paused {
  color: var(--orange);
}

.waveform {
  display: block;
  width: 100%;
  height: 54px;
  margin: 2px 0 0;
}

/* 说话人标签 */

.speaker-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.speaker-legend[hidden] {
  display: none;
}

.speaker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--spk-bg, rgba(10, 132, 255, 0.12));
  color: var(--spk, var(--blue));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.speaker-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.speaker-chip small {
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.62;
}

/* 统计 */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stat {
  text-align: center;
}

.stat + .stat {
  border-left: 1px solid var(--line);
}

.stat dd {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat dt {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.stat-speakers dd {
  color: var(--blue);
}

/* 音频回放 */

.audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.audio-row[hidden] {
  display: none;
}

.audio-row audio {
  flex: 1;
  min-width: 160px;
  height: 34px;
}

.hint {
  margin: 16px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   转写
   -------------------------------------------------------------------------- */

.transcript-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 24px 24px 14px;
  border-bottom: 1px solid var(--line);
}

.transcript-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.text-btn:hover:not(:disabled) {
  background: var(--fill);
}

.text-btn:active:not(:disabled) {
  background: var(--fill-strong);
}

.text-btn:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

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

.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 24px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-strong) transparent;
}

.transcript::-webkit-scrollbar {
  width: 8px;
}

.transcript::-webkit-scrollbar-thumb {
  background: var(--fill-strong);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}

/* 空状态 */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(64px, 12vh, 110px) 24px 60px;
  text-align: center;
}

.empty[hidden] {
  display: none;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin-bottom: 18px;
  border-radius: 22px;
  background: var(--fill);
  color: var(--muted);
}

.empty-icon svg {
  width: 42px;
  height: 42px;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.empty-sub {
  margin: 0;
  max-width: 290px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}

/* 句子 */

.sentences {
  display: flex;
  flex-direction: column;
}

.sentence {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  animation: ink-in 0.35s cubic-bezier(0.22, 0.68, 0.24, 1) both;
}

.sentence:last-child {
  border-bottom: 0;
}

.take-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.take-divider span:first-child {
  color: var(--text-2);
}

.sentence-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.sentence-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.sentence-text {
  margin: 0;
  font-size: 17px;
  line-height: 1.56;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

/* 说话人配色 */

.spk-0 {
  --spk: #007aff;
  --spk-bg: rgba(0, 122, 255, 0.12);
}
.spk-1 {
  --spk: #248a3d;
  --spk-bg: rgba(52, 199, 89, 0.16);
}
.spk-2 {
  --spk: #c26a00;
  --spk-bg: rgba(255, 149, 0, 0.16);
}
.spk-3 {
  --spk: #d70015;
  --spk-bg: rgba(255, 59, 48, 0.13);
}
.spk-4 {
  --spk: #8944ab;
  --spk-bg: rgba(175, 82, 222, 0.15);
}
.spk-5 {
  --spk: #0071a4;
  --spk-bg: rgba(100, 210, 255, 0.22);
}

@media (prefers-color-scheme: dark) {
  .spk-0 {
    --spk: #0a84ff;
    --spk-bg: rgba(10, 132, 255, 0.22);
  }
  .spk-1 {
    --spk: #30d158;
    --spk-bg: rgba(48, 209, 88, 0.2);
  }
  .spk-2 {
    --spk: #ff9f0a;
    --spk-bg: rgba(255, 159, 10, 0.2);
  }
  .spk-3 {
    --spk: #ff453a;
    --spk-bg: rgba(255, 69, 58, 0.2);
  }
  .spk-4 {
    --spk: #bf5af2;
    --spk-bg: rgba(191, 90, 242, 0.2);
  }
  .spk-5 {
    --spk: #64d2ff;
    --spk-bg: rgba(100, 210, 255, 0.18);
  }
}

/* 识别中 */

.interim {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 0 8px;
}

.interim[hidden] {
  display: none;
}

.interim-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--blue);
}

.interim-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: blink 1.2s ease-in-out infinite;
}

.interim-text {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.interim-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.02em;
  margin-left: 3px;
  vertical-align: -0.16em;
  border-radius: 1px;
  background: var(--blue);
  animation: caret 1.05s steps(1) infinite;
}

.transcript-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

.foot-muted {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   页脚 / 提示
   -------------------------------------------------------------------------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 4px 30px 26px;
  font-size: 11px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 100;
  max-width: min(92vw, 460px);
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s cubic-bezier(0.22, 0.68, 0.24, 1);
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: rgba(215, 0, 21, 0.94);
}

/* --------------------------------------------------------------------------
   动效
   -------------------------------------------------------------------------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ink-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes caret {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes halo {
  0% {
    transform: scale(0.86);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.28);
    opacity: 0;
  }
  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */

@media (max-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 14px;
  }

  .transcript-card {
    min-height: 440px;
    max-height: none;
  }

  .transcript {
    max-height: 58vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 18px 18px 6px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 17px;
  }

  .brand-text strong {
    font-size: 16px;
  }

  .topbar-meta {
    gap: 6px;
  }

  .pill {
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
  }

  .layout {
    padding: 12px 14px 16px;
    gap: 14px;
  }

  .card {
    border-radius: 22px;
  }

  .recorder {
    padding: 20px 18px 16px;
  }

  .clock {
    font-size: 46px;
  }

  .record-wrap {
    height: 154px;
  }

  .record-btn {
    width: 94px;
    height: 94px;
  }

  .record-btn svg {
    width: 30px;
    height: 30px;
  }

  .transcript-head {
    padding: 20px 18px 12px;
  }

  .transcript-head h1 {
    font-size: 20px;
  }

  .transcript {
    padding: 4px 18px 14px;
  }

  .transcript-foot {
    padding: 12px 18px;
  }

  .sentence-text {
    font-size: 16px;
  }

  .footer {
    padding: 2px 20px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
