* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f8fa;
  color: #222;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 24px;
  text-align: center;
  margin: 8px 0 16px;
}

textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px;
  border: 1px solid #d7dbe0;
  border-radius: 10px;
  font-size: 16px;
  resize: vertical;
  background: #fff;
}

.speed-wrap {
  margin-top: 14px;
}

.speed-wrap label {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

input[type="range"] {
  width: 100%;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 14px 10px;
  font-size: 16px;
  font-weight: 600;
  background: #2f6feb;
  color: #fff;
  cursor: pointer;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  background: #9aa4b2;
  color: #eef2f7;
  cursor: not-allowed;
  transform: none;
  opacity: 0.85;
}

.panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #e4e7eb;
  border-radius: 10px;
  background: #fff;
}

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

.asr-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #4b5563;
}

.asr-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.asr-light.idle {
  background: #9ca3af;
}

.asr-light.listening {
  background: #22c55e;
}

.asr-light.retrying {
  background: #f59e0b;
}

.asr-light.unsupported {
  background: #ef4444;
}

#ttsStatus,
#asrText,
#diff,
#similarity {
  min-height: 24px;
  line-height: 1.5;
  word-break: break-word;
}

#asrText {
  max-height: 25vh;
  overflow: auto;
  font-size: 15px;
}

#diff {
  white-space: normal;
}

.diff-line {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.miss {
  background: #ffd8d8;
  border-radius: 3px;
}

.extra {
  background: #fff4bf;
  border-radius: 3px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-empty {
  color: #6b7280;
  font-size: 14px;
}

.history-item {
  text-align: left;
  padding: 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f9fbfd;
  color: #1f2937;
}

.history-item.latest {
  border-color: #a8c4ff;
  background: #eef4ff;
}

.history-meta {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}

.history-line {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  margin-top: 2px;
}

.history-label {
  flex: 0 0 auto;
  color: #374151;
  font-size: 12px;
}

.history-preview {
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#myAudio {
  width: 100%;
}

@media (max-width: 360px) {
  button {
    font-size: 15px;
    padding: 13px 8px;
  }
}

@media (max-width: 768px) {
  .realtime-asr {
    position: sticky;
    top: 8px;
    z-index: 10;
    background: #fff;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  }
}
