:root {
  color-scheme: dark;
  --bg: #080c11;
  --panel: rgba(20, 28, 38, 0.86);
  --panel-solid: #141c26;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9f0f8;
  --muted: #8a9aad;
  --dim: #5f7085;
  --accent: #33d6c0;
  --accent-2: #3ea6ff;
  --danger: #ff5d73;
  --warn: #f5b455;
  --radius: 20px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 18% -8%, rgba(51, 214, 192, 0.13), transparent 62%),
    radial-gradient(900px 520px at 88% -4%, rgba(62, 166, 255, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px 300px at 50% 110%, rgba(62, 166, 255, 0.06), transparent 70%);
}

.page {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 26px 20px 54px;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.hidden, [hidden] { display: none !important; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 2px 24px;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.logo {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #06141a;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px -12px rgba(51, 214, 192, 0.75);
}
.logo svg { width: 23px; height: 23px; }

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--dim);
  font-family: var(--mono);
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.conn.ok .conn-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(51, 214, 192, 0.16); }
.conn.bad .conn-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 93, 115, 0.16); }

/* -------------------------------------------------------------------- card */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 24px 60px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
}

.card + .card { margin-top: 14px; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; font-size: 18px; }

.tag {
  font-size: 11px;
  color: var(--accent);
  border: 1px solid rgba(51, 214, 192, 0.35);
  background: rgba(51, 214, 192, 0.08);
  padding: 3px 9px;
  border-radius: 999px;
}

/* -------------------------------------------------------------- 采集说明 */
.guide-card { padding: 16px 20px 18px; }

.guide-head { display: flex; align-items: center; gap: 10px; }

.guide-kicker {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(51, 214, 192, 0.09);
  border: 1px solid rgba(51, 214, 192, 0.3);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.guide-sub { font-size: 12.5px; color: var(--dim); }
.guide-head .btn { margin-left: auto; height: 28px; }

.wakeword-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.wakeword-label { font-size: 12.5px; color: var(--muted); }
.wakeword {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1.2;
  background: linear-gradient(120deg, #5eead4, #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wakeword-alt { font-size: 13px; color: var(--muted); }

.guide-body { margin-top: 12px; }
.guide-body[hidden] { display: none; }

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.guide-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.guide-key { font-size: 11px; color: var(--dim); letter-spacing: 0.03em; }
.guide-val { font-size: 12.5px; line-height: 1.5; color: #cfdae6; }

.guide-extra {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(62, 166, 255, 0.055);
  border: 1px solid rgba(62, 166, 255, 0.16);
}
.guide-extra .guide-key { white-space: nowrap; padding-top: 1px; color: #7fb7e8; }
.guide-extra p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #aebdcd; }

#recorderCard { margin-top: 14px; }

.login-card { max-width: 540px; margin: 14px auto 0; padding: 28px; }
.login-card .muted { margin: 10px 0 20px; font-size: 13.5px; }

.field { display: block; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 11, 16, 0.72);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input::placeholder { color: var(--dim); }
.field input:focus {
  border-color: rgba(51, 214, 192, 0.65);
  box-shadow: 0 0 0 4px rgba(51, 214, 192, 0.12);
}

.hint { margin: 12px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.6; }
.hint.error { color: #ff97a6; }

.banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.banner.warn {
  color: #ffd79a;
  background: rgba(245, 180, 85, 0.09);
  border: 1px solid rgba(245, 180, 85, 0.32);
}
.banner code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ------------------------------------------------------------------ button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, filter 0.18s, border-color 0.18s, background 0.18s, opacity 0.18s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, #43e0ca, #3ea6ff);
  color: #04141b;
  box-shadow: 0 14px 30px -16px rgba(62, 166, 255, 0.75);
}
.btn.wide { width: 100%; height: 52px; margin-top: 18px; font-size: 15px; }

.btn.rec {
  flex: 1.25;
  height: 56px;
  font-size: 15.5px;
  color: #fff;
  background: linear-gradient(135deg, #ff5d73, #f43f68);
  box-shadow: 0 16px 34px -18px rgba(255, 61, 110, 0.95);
}
.btn.rec svg { width: 17px; height: 17px; }
.btn.rec:disabled {
  background: rgba(255, 93, 115, 0.12);
  border-color: rgba(255, 93, 115, 0.22);
  color: #ff9daa;
  box-shadow: none;
}

.btn.stop {
  flex: 1;
  height: 56px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line-strong);
  color: #dfe8f2;
}
.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: #b8c6d6;
}
.btn.small { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.btn.tiny { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); }

/* ----------------------------------------------------------------- userbar */
.userbar { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }

.avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-weight: 700;
  font-size: 18px;
  color: #05141a;
  background: linear-gradient(140deg, #5eead4, #60a5fa);
  text-transform: uppercase;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.count {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--dim);
  font-size: 12px;
  padding-right: 6px;
}
.count b { font-size: 20px; color: var(--text); font-family: var(--mono); font-weight: 600; }

/* ------------------------------------------------------------------ studio */
.studio { padding: 18px 20px 14px; }

.studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.pill.recording {
  color: #ff8b9c;
  border-color: rgba(255, 93, 115, 0.4);
  background: rgba(255, 93, 115, 0.09);
}
.pill.recording::before { animation: pulse 1.15s infinite ease-in-out; }
.pill.processing {
  color: #8ec5ff;
  border-color: rgba(62, 166, 255, 0.38);
  background: rgba(62, 166, 255, 0.09);
}
.pill.error {
  color: #ff97a6;
  border-color: rgba(255, 93, 115, 0.35);
  background: rgba(255, 93, 115, 0.08);
}
.pill.saved {
  color: #6ee7c8;
  border-color: rgba(51, 214, 192, 0.35);
  background: rgba(51, 214, 192, 0.08);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

/* -------------------------------------------------------------------- wave */
.wave-wrap {
  position: relative;
  height: 132px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(8, 14, 20, 0.95), rgba(10, 17, 24, 0.9));
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.45);
}
.wave-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.wave-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 20px;
  text-align: center;
  font-size: 12.5px;
  color: #64788f;
  pointer-events: none;
  transition: opacity 0.25s;
}
.wave-empty span {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(8, 14, 20, 0.66);
  backdrop-filter: blur(3px);
}
.wave-wrap.active .wave-empty { opacity: 0; }

.wave-scale {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 7px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #35455a;
  pointer-events: none;
}

/* ------------------------------------------------------------------- meter */
.meter-row { display: flex; align-items: center; gap: 10px; margin: 10px 2px 0; }
.meter {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #33d6c0, #6ee7b7 55%, #fbbf24 88%, #ff5d73);
  transition: width 70ms linear;
}
.meter-row span { color: var(--dim); min-width: 66px; text-align: right; }

/* ------------------------------------------------------------------- timer */
.timer-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 6px 0 10px; }
.timer {
  font-size: 36px;
  font-weight: 300;
  letter-spacing: 0.015em;
  color: var(--text);
  line-height: 1.1;
}
.timer-limit { font-size: 12px; color: var(--dim); }

.controls { display: flex; gap: 10px; }

/* ------------------------------------------------------------------ upload */
.upload { margin-top: 14px; }
.progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}
.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.upload-actions { display: inline-flex; gap: 8px; }
.upload.error .progress i { background: var(--danger); }
.upload.error .upload-row { color: #ff97a6; }

/* -------------------------------------------------------------- studio foot */
.studio-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--dim);
  flex-wrap: wrap;
}
.select { display: inline-flex; align-items: center; gap: 8px; }
.select span { color: var(--muted); }
.select select {
  max-width: 240px;
  height: 32px;
  padding: 0 26px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8798ac 50%), linear-gradient(135deg, #8798ac 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select select:focus { border-color: rgba(51, 214, 192, 0.6); }
.select select:disabled { opacity: 0.5; }

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.kbd-hint { margin-left: auto; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: #9fb0c3;
}

/* ------------------------------------------------------------------ records */
.list-card { padding: 18px 18px 10px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.list-head h2 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 9px; }
.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 1px 8px;
}
.list-actions { display: inline-flex; gap: 8px; }

.records { max-height: 400px; overflow-y: auto; overscroll-behavior: contain; }
.records::-webkit-scrollbar { width: 8px; }
.records::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 8px; }

.rec {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-top: 1px solid var(--line);
}
.rec:first-child { border-top: none; }
.rec-seq {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  width: 44px;
}
.rec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rec-name {
  font-family: var(--mono);
  font-size: 12.5px;
  color: #d3deea;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rec-meta { font-size: 11.5px; color: var(--dim); font-family: var(--mono); }
.rec .btn.play {
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  color: #cfe0ee;
}
.rec .btn.play svg { width: 14px; height: 14px; }
.rec .btn.play.playing {
  color: #6ee7c8;
  border-color: rgba(51, 214, 192, 0.5);
  background: rgba(51, 214, 192, 0.14);
}

.empty {
  margin: 8px 0 14px;
  padding: 30px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

/* --------------------------------------------------------------------- foot */
.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.foot code { font-family: var(--mono); font-size: 11.5px; color: #7f90a5; }

/* -------------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  max-width: min(92vw, 460px);
  padding: 11px 17px;
  border-radius: 12px;
  background: rgba(24, 34, 46, 0.97);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 50;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 93, 115, 0.45); color: #ffc3cc; }
.toast.ok { border-color: rgba(51, 214, 192, 0.4); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 720px) {
  .page { padding: 16px 14px 40px; }
  .topbar { padding-bottom: 16px; }
  .brand-text h1 { font-size: 17px; }
  .card { padding: 17px; border-radius: 17px; }
  .guide-card { padding: 14px 15px 15px; }
  .guide-head { flex-wrap: wrap; row-gap: 4px; }
  .guide-head .btn { height: 26px; }
  .guide-sub { order: 3; flex: 1 1 100%; font-size: 12px; }
  .wakeword { font-size: 21px; }
  .wakeword-row { margin-top: 10px; }
  .guide-grid { grid-template-columns: 1fr; }
  .login-card { margin-top: 12px; padding: 22px; }
  .userbar { flex-wrap: wrap; row-gap: 8px; }
  .userbar .who { flex: 1 1 auto; }
  .userbar .btn { order: 3; margin-left: auto; }
  .count { order: 4; margin-left: 0; flex: 1 1 100%; padding-left: 58px; }
  .wave-wrap { height: 108px; }
  .timer { font-size: 30px; }
  .controls { flex-wrap: wrap; }
  .btn.rec { flex: 1 1 100%; height: 52px; }
  .btn.stop { flex: 1 1 50%; height: 52px; }
  .controls .btn.ghost { flex: 1 1 34%; height: 52px; }
  .toast { bottom: 14px; }
  .studio-foot { gap: 10px; }
  .kbd-hint { display: none; }
  .select { width: 100%; }
  .select select { flex: 1; max-width: none; }
  .rec { flex-wrap: wrap; }
  .rec-main { flex: 1 1 150px; }
  .rec .btn.play { order: 2; }
  .rec .btn.ghost { order: 3; }
  .rec-seq { width: auto; }
  .records { max-height: none; }
  .foot { font-size: 11.5px; }
}

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