* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #eef4ff 0%, #f9fbff 100%);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  text-align: center;
  padding: 24px 16px 12px;
}
.app-header h1 {
  font-size: 26px;
  color: #2b4c8c;
}
.app-header p {
  font-size: 13px;
  color: #8a97ad;
  margin-top: 4px;
}

.tab-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 8px 16px 16px;
}
.tab-btn {
  flex: 1;
  max-width: 180px;
  padding: 12px 0;
  border: none;
  border-radius: 24px;
  background: #dfe8f7;
  color: #4a5f7e;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.tab-btn.active {
  background: #2b4c8c;
  color: #fff;
}

.page {
  display: none;
  padding: 0 16px 24px;
}
.page.active {
  display: block;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(43, 76, 140, .08);
}
.card h2 {
  font-size: 18px;
  color: #2b4c8c;
  margin-bottom: 8px;
}
.hint {
  font-size: 13px;
  color: #8a97ad;
  line-height: 1.6;
  margin-bottom: 12px;
}

/* 识别页 */
.letter-display {
  font-size: 96px;
  font-weight: 800;
  text-align: center;
  color: #2b4c8c;
  min-height: 120px;
  line-height: 120px;
  background: #f2f7ff;
  border-radius: 12px;
  margin-bottom: 8px;
  letter-spacing: 4px;
  transition: transform .15s;
}
.letter-display.pop {
  transform: scale(1.15);
}
.word-display {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: #333;
  min-height: 44px;
  margin: 8px 0 16px;
  letter-spacing: 8px;
  word-break: break-all;
}
.status-text {
  text-align: center;
  font-size: 14px;
  color: #8a97ad;
  margin-bottom: 12px;
  min-height: 20px;
}

/* 实时录音状态条 */
.rec-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fdeeee;
  border: 1px solid #f5c6c6;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #b04040;
}
.rec-bar[hidden] {
  display: none;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d9534f;
  animation: blink 1s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .2; }
}

.btn {
  border: none;
  border-radius: 28px;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 20px;
  cursor: pointer;
  transition: all .15s;
}
.btn:active {
  transform: scale(.97);
}
.btn-record {
  width: 100%;
  background: #2b4c8c;
  color: #fff;
  padding: 18px;
  font-size: 18px;
}
.btn-record.recording {
  background: #d9534f;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .75; }
}
.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.btn-ghost {
  flex: 1;
  background: #eef2f9;
  color: #4a5f7e;
  font-size: 14px;
}

/* 详情表格 */
.result-detail table {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}
.result-detail td {
  padding: 6px 4px;
  border-bottom: 1px solid #eef2f9;
  color: #555;
}
.result-detail td:last-child {
  text-align: right;
  font-weight: 600;
  color: #2b4c8c;
}
.detail-title {
  font-size: 14px;
  color: #8a97ad;
  margin-bottom: 6px;
}

/* 模板录制页 */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.form-row label {
  width: 72px;
  font-size: 15px;
  color: #4a5f7e;
}
.input-letter {
  flex: 1;
  font-size: 20px;
  text-align: center;
  padding: 10px;
  border: 1px solid #d5e0f2;
  border-radius: 10px;
  background: #f7faff;
  text-transform: lowercase;
}
.input-select {
  flex: 1;
  font-size: 15px;
  padding: 10px;
  border: 1px solid #d5e0f2;
  border-radius: 10px;
  background: #f7faff;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.tpl-item {
  border-radius: 10px;
  padding: 10px 4px;
  text-align: center;
  font-size: 14px;
  background: #f2f5fa;
  color: #8a97ad;
}
.tpl-item .letter {
  font-size: 22px;
  font-weight: 700;
  display: block;
}
.tpl-item .mode {
  font-size: 11px;
  opacity: .7;
  display: block;
}
.tpl-item .count {
  font-size: 11px;
  display: block;
  margin-top: 4px;
}
.tpl-item.ready {
  background: #e6f7ec;
  color: #2e8b57;
}
.tpl-item.notready {
  background: #fff3e6;
  color: #c07a2e;
}
.tpl-item.active {
  outline: 3px solid #2b4c8c;
}
