* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--tg-theme-bg-color, #f4f4f7);
  color: var(--tg-theme-text-color, #111);
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.2px;
}

.brand-logo {
  width: 24px;
  height: 24px;
  color: var(--tg-theme-button-color, #2481cc);
}

.balance-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--tg-theme-secondary-bg-color, #e7e9ed);
  color: var(--tg-theme-hint-color, #6b7280);
}

.recorder-card {
  background: var(--tg-theme-section-bg-color, #fff);
  border-radius: 20px;
  padding: 32px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mic-btn {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: var(--tg-theme-button-color, #2481cc);
  color: var(--tg-theme-button-text-color, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.mic-btn:active {
  transform: scale(0.94);
}

.mic-btn svg {
  width: 32px;
  height: 32px;
  position: relative;
  z-index: 1;
}

.mic-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--tg-theme-button-color, #2481cc);
  opacity: 0;
}

.mic-btn.recording {
  background: #e0453f;
}

.mic-btn.recording .mic-ring {
  background: #e0453f;
  opacity: 0.45;
  animation: pulse-ring 1.6s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.45; }
  100% { transform: scale(1.9); opacity: 0; }
}

.timer {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tg-theme-hint-color, #6b7280);
}

.timer.hidden {
  display: none;
}

.hint {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--tg-theme-hint-color, #6b7280);
  text-align: center;
}

.upload-link {
  font-size: 13px;
  color: var(--tg-theme-link-color, #2481cc);
  cursor: pointer;
  margin-top: 2px;
}

.status-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, #e7e9ed);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-banner.hidden {
  display: none;
}

.status-banner.error {
  background: rgba(224, 69, 63, 0.12);
  color: #c8362f;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result-card {
  margin-top: 16px;
  background: var(--tg-theme-section-bg-color, #fff);
  border-radius: 20px;
  padding: 18px 18px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.result-card.hidden {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-header h2 {
  font-size: 16px;
  margin: 0;
}

.icon-btn {
  border: none;
  background: var(--tg-theme-secondary-bg-color, #e7e9ed);
  color: var(--tg-theme-hint-color, #6b7280);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.icon-btn.copied {
  color: #2bb673;
}

.summary-text {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.transcript-details {
  margin-top: 12px;
  font-size: 13px;
  color: var(--tg-theme-hint-color, #6b7280);
}

.transcript-details summary {
  cursor: pointer;
  font-weight: 600;
}

.transcript-details p {
  white-space: pre-wrap;
  line-height: 1.5;
}
