:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --background: var(--tg-theme-bg-color, #f2f4f7);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17202a);
  --muted: var(--tg-theme-hint-color, #73808c);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #d84a4a;
  --ready: #7d8b96;
  --listening: #2eaf6d;
  --speaking: #2481cc;
  --problem: #e0a128;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

body {
  min-height: var(--tg-viewport-stable-height, 100vh);
}

.shell {
  min-height: var(--tg-viewport-stable-height, 100vh);
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.card {
  width: min(100%, 420px);
  padding: 32px 24px 28px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 16px 48px rgb(0 0 0 / 10%);
  text-align: center;
}

.avatar {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-text);
  background: var(--accent);
  font-size: 30px;
  font-weight: 650;
}

h1 {
  margin: 0 0 14px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ready);
}

.status-dot[data-state="connecting"],
.status-dot[data-state="requesting"] {
  background: var(--problem);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-dot[data-state="listening"] {
  background: var(--listening);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--listening) 18%, transparent);
}

.status-dot[data-state="speaking"] {
  background: var(--speaking);
  animation: pulse 0.85s ease-in-out infinite;
}

.status-dot[data-state="problem"] {
  background: var(--danger);
}

.timer {
  margin-top: 18px;
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  font-weight: 300;
  letter-spacing: 0.04em;
}

.hint {
  min-height: 42px;
  margin: 12px 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.error {
  margin: -8px 0 18px;
  padding: 11px 12px;
  border-radius: 12px;
  color: #8b1f1f;
  background: rgb(216 74 74 / 12%);
  line-height: 1.35;
}

.transcript {
  margin: 0 0 20px;
  border-block: 1px solid rgb(127 127 127 / 22%);
  padding: 14px 2px;
  text-align: left;
}

.transcript-list {
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.transcript-entry + .transcript-entry {
  margin-top: 13px;
}

.transcript-speaker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.transcript-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.transcript-entry[data-partial="true"] .transcript-text {
  color: var(--muted);
}

.transcript-entry[data-interrupted="true"] .transcript-text::after {
  content: " · перебито";
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.transcript-empty,
.transcript-warning {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.transcript-warning {
  margin-top: 10px;
  color: #8b5c13;
}

.button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.button-primary {
  color: var(--accent-text);
  background: var(--accent);
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.button-secondary {
  margin-top: 10px;
  color: var(--text);
  background: rgb(127 127 127 / 14%);
}

@keyframes pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.86);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot {
    animation: none !important;
  }
}

.detail-shell {
  place-items: start center;
}

.detail-card {
  text-align: left;
}

.detail-card h1 {
  margin-bottom: 6px;
}

.detail-card h2 {
  margin: 24px 0 12px;
  font-size: 17px;
}

.detail-meta {
  margin: 0 0 20px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.detail-summary {
  margin: 18px 0;
  padding: 1px 16px 16px;
  border-radius: 14px;
  background: rgb(127 127 127 / 10%);
}

.detail-summary p {
  margin: 0;
  line-height: 1.5;
}

.detail-message + .detail-message {
  margin-top: 16px;
}

.detail-message[data-interrupted="true"] .transcript-text::after {
  content: " · перебито";
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}
