:root {
  --bg: #f4efe6;
  --ink: #12263a;
  --muted: #5c6b7a;
  --card: #fffdf8;
  --line: #e4d9c8;
  --red: #e23d4d;
  --gold: #c7962c;
  --wechat: #07c160;
  --shadow: 0 14px 40px rgba(18, 38, 58, 0.1);
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

body {
  padding: env(safe-area-inset-top) 0 var(--safe-bottom);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px 28px;
}

.topbar {
  margin-bottom: 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.view.hidden,
.hidden {
  display: none !important;
}

.hero-card,
.panel,
.live-box,
.result-head,
.tab-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 22px 18px 18px;
  text-align: center;
}

.record-btn {
  width: 100%;
  border: 0;
  background: linear-gradient(180deg, #1b3a4b, #12263a);
  color: #f4efe6;
  border-radius: 24px;
  padding: 28px 16px 22px;
  cursor: pointer;
}

.record-btn .mic {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: block;
  background: radial-gradient(circle at 50% 45%, #ff6b78, var(--red));
  box-shadow: 0 0 0 10px rgba(226, 61, 77, 0.18);
}

.record-btn strong {
  display: block;
  font-size: 22px;
}

.record-btn small {
  display: block;
  margin-top: 8px;
  color: #d7cbb8;
  font-size: 12px;
}

.audio-btn,
.sys-record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 14px;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: #1b3a4b;
  color: #f4efe6;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.sys-record-btn {
  background: #9a3412;
}

html.native-app #btn-pause {
  display: none;
}

html.native-app .screenoff-hint,
html.native-app #btn-sys-record {
  display: none;
}

.screenoff-hint {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.55;
}

.asr-status {
  margin: 12px 0 0;
  color: #9aa8b5;
  font-size: 13px;
  line-height: 1.5;
}

.asr-status.ok {
  color: #8fbf9a;
}

.hero-actions,
.record-actions,
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.result-actions {
  grid-template-columns: 1fr 1fr;
  position: sticky;
  bottom: 8px;
  padding-top: 8px;
  background: linear-gradient(180deg, transparent, var(--bg) 18px);
}

.wechat-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(18, 38, 58, 0.88);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

html.in-wechat #wechatGate {
  display: flex;
}

#wechatGate[hidden] {
  display: none !important;
}

html.in-wechat .wechat-auth-hint {
  color: #9a3412;
  font-weight: 700;
  font-size: 14px;
}

.wechat-gate-box {
  background: #fff7ed;
  border: 3px solid #ea580c;
  border-radius: 22px;
  padding: 22px 18px 18px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.wechat-gate-tag {
  display: inline-block;
  background: #ea580c;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.wechat-gate-box h2 {
  margin: 0 0 10px;
  font-size: 28px;
  color: #9a3412;
  line-height: 1.25;
}

.wechat-gate-lead {
  margin: 0 0 14px;
  font-size: 16px;
  color: #7c2d12;
  line-height: 1.55;
  font-weight: 600;
}

.wechat-gate-steps {
  text-align: left;
  margin: 0 0 16px;
  padding: 12px 12px 12px 36px;
  background: #fff;
  border-radius: 14px;
  color: #9a3412;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
}

.wechat-gate-copy {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  background: #ea580c;
  color: #fff;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.wechat-gate-skip {
  width: 100%;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: #9a3412;
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.wechat-banner,
.draft-banner {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.wechat-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #ea580c;
  border: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 14px 12px;
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.35);
}

.wechat-banner strong {
  display: block;
  font-size: 22px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.wechat-banner span {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.wechat-banner-btn {
  margin-top: 10px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #9a3412;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.draft-banner {
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #166534;
}

.wechat-banner button,
.draft-banner button {
  margin-top: 8px;
  margin-right: 8px;
  min-height: 40px;
}

.note-audio-wrap {
  margin: 8px 0 12px;
  padding: 10px;
  background: #f7f1e6;
  border-radius: 14px;
}

.note-audio-wrap audio {
  width: 100%;
  display: block;
}

.ghost-btn,
.primary-btn,
.wechat-btn,
.text-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.ghost-btn,
.primary-btn,
.wechat-btn {
  min-height: 48px;
  border-radius: 16px;
  padding: 0 14px;
}

.ghost-btn {
  background: #efe6d6;
  color: var(--ink);
}

.primary-btn {
  background: var(--ink);
  color: #fff;
}

.wechat-btn {
  background: var(--wechat);
  color: #fff;
}

.text-btn {
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.panel {
  margin-top: 16px;
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-head h2,
.live-box h3,
.result-head h2 {
  margin: 0;
  font-size: 16px;
}

.history {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.history-item,
.empty {
  padding: 12px;
  border-radius: 14px;
  background: #f7f1e6;
  text-align: left;
}

.history-item {
  border: 0;
  width: 100%;
  font: inherit;
  cursor: pointer;
}

.history-item small,
.empty {
  color: var(--muted);
}

.record-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--red);
  font-weight: 600;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s infinite;
}

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

.timer {
  text-align: center;
  font-size: 48px;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 12px;
}

.wave {
  width: 100%;
  height: 88px;
  border-radius: 16px;
  background: #12263a;
}

.live-box {
  margin-top: 14px;
  padding: 14px;
  min-height: 160px;
}

.live-box p {
  margin: 8px 0 0;
  line-height: 1.7;
  color: #2c3e50;
  white-space: pre-wrap;
}

.record-keep {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.55;
}

#keepAlivePlayer {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0.02;
  pointer-events: none;
  left: 0;
  bottom: 0;
}

.result-head {
  padding: 16px;
  margin-bottom: 12px;
}

.result-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  font: inherit;
  color: var(--muted);
}

.tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.tab-panel {
  padding: 16px 16px 28px;
  line-height: 1.75;
  min-height: 220px;
  margin-bottom: 8px;
}

#view-result {
  padding-bottom: 8px;
}

.tab-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.tab-panel ul {
  margin: 0;
  padding-left: 18px;
}

.editor {
  width: 100%;
  min-height: 220px;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 14px;
  font: inherit;
  line-height: 1.7;
  resize: vertical;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 2px 0;
}

.hint input {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #d6d0c4;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
}

.process-card {
  padding: 36px 18px;
  text-align: center;
}

.process-card .pulse-dot {
  margin: 0 auto 16px;
}

.process-card strong {
  display: block;
  font-size: 18px;
}

.process-card p {
  color: var(--muted);
  line-height: 1.6;
}

@media (min-width: 720px) {
  #app {
    padding-top: 28px;
  }
}

#app.auth-locked {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 38, 58, 0.62);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.auth-overlay.is-visible {
  display: flex;
}

.auth-box {
  background: #fffdf8;
  border-radius: 22px;
  padding: 24px 20px 20px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
}

.auth-box h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-box .sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.55;
}

.auth-box .serial-box {
  background: #f4efe6;
  border: 1px dashed #d6d0c4;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  text-align: center;
}

.auth-box .serial-box .label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.auth-box .serial-box strong {
  display: block;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 1px;
  font-size: 15px;
  word-break: break-all;
  margin-bottom: 8px;
}

.auth-box .serial-box .ghost-btn {
  min-height: 36px;
  width: auto;
}

.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0 6px;
}

.auth-box input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #d6d0c4;
  border-radius: 12px;
  font: inherit;
  text-align: center;
  letter-spacing: 1px;
}

.auth-box input:focus {
  outline: none;
  border-color: #12263a;
}

.btn-auth {
  margin-top: 14px;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: #12263a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-auth:disabled {
  opacity: 0.5;
}

.auth-box .error {
  min-height: 20px;
  margin-top: 8px;
  font-size: 13px;
  color: #b91c1c;
}

.auth-remain-bar {
  display: none;
  margin-top: 12px;
  background: linear-gradient(90deg, #ecfdf5, #eff6ff);
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: #065f46;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auth-remain-bar.show {
  display: flex;
}
