/* Розмовлялька web — интерфейс в духе Vercel UI: белая тема, плоский,
   минимализм, 1px рамки, системные шрифты. */

:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --text: #171717;
  --text-2: #525252;
  --text-3: #8a8a8a;
  --accent: #0070f3;
  --radius: 8px;
  --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--mono); font-size: 12px; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}

/* Шапка */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #171717;
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.brand-name {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--panel);
  text-transform: lowercase;
}

.header-right { display: flex; align-items: center; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--panel);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}

.status--loading .status-dot { background: #d97706; }
.status--ready .status-dot { background: #16a34a; }
.status--error { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.status--error .status-dot { background: #dc2626; }

/* Карточки */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hint { font-size: 12px; color: var(--text-3); }

/* Реплики */
.segments { display: flex; flex-direction: column; gap: 10px; }

.segment {
  display: grid;
  grid-template-columns: 26px 1fr auto 28px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 10px 10px 10px 12px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.segment:focus-within {
  border-color: #bababa;
  box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.12);
}

.segment.is-active {
  border-color: #171717;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.segment-index {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  padding-top: 8px;
  user-select: none;
}

.segment textarea {
  width: 100%;
  min-height: 38px;
  max-height: 220px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  padding: 7px 0;
  color: var(--text);
}

.segment textarea::placeholder { color: var(--text-3); }

.voice-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 2px;
  gap: 2px;
  margin-top: 4px;
}

.voice-switch button {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--text-2);
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.voice-switch button:hover { color: var(--text); }

.voice-switch button[aria-pressed='true'] {
  background: #171717;
  color: #fff;
}

.segment-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.icon-btn:hover { background: var(--panel); color: var(--text); }

.icon-btn.is-muted { opacity: 0.35; }

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:focus-visible,
input[type='range']:focus-visible,
.icon-btn:focus-visible,
.voice-switch button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.btn-primary {
  background: #171717;
  color: #fff;
  min-width: 118px;
}

.btn-primary:hover { background: #2b2b2b; }
.btn-primary:active { background: #000; }

.btn-ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--panel); }

.btn-dashed {
  width: 100%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-2);
  padding: 9px;
  margin-top: 14px;
}

.btn-dashed:hover { border-color: var(--text-3); color: var(--text); background: var(--panel); }

.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

.icon { flex: none; }

/* Слайдеры */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
#settings-card { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

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

.setting-head label { font-size: 12px; color: var(--text-2); font-weight: 500; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #eaeaea;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #171717;
  border: none;
  margin-top: -5px;
  transition: transform 120ms ease;
}

input[type='range']::-webkit-slider-thumb:hover { transform: scale(1.12); }

input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #eaeaea;
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #171717;
  border: none;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-3);
  margin-top: -6px;
}

/* Плеер */
.player-card { padding: 16px 20px 14px; position: sticky; bottom: 16px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px); }

.wave {
  display: block;
  width: 100%;
  height: 48px;
  margin-bottom: 6px;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.transport { display: flex; align-items: center; gap: 8px; }

.time { color: var(--text-2); font-size: 12px; display: flex; gap: 4px; min-width: 84px; }
.time-sep { color: var(--text-3); }

.spacer { flex: 1; }

.exports { display: flex; gap: 8px; }

/* Футер */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  color: var(--text-3);
  font-size: 12px;
  flex-wrap: wrap;
}

/* Оверлей загрузки */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 200ms ease;
}

.overlay.is-hidden { opacity: 0; pointer-events: none; }

.overlay-panel {
  width: 300px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #eaeaea;
  border-top-color: #171717;
  animation: spin 0.9s linear infinite;
  margin-bottom: 14px;
}

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

.overlay-title { font-weight: 600; font-size: 14px; }

.overlay-sub { color: var(--text-3); margin-top: 2px; }

.progress {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #eaeaea;
  overflow: hidden;
  margin-top: 18px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #171717;
  border-radius: 2px;
  transition: width 150ms ease;
}

.overlay-pct { color: var(--text-2); margin-top: 8px; }

/* Тост */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: #171717;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 60;
  max-width: 80vw;
}

.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: #b91c1c; }

/* Отзывчивость */
@media (max-width: 640px) {
  .segment { grid-template-columns: 22px 1fr 24px; }
  .voice-switch { grid-column: 2; }
  #settings-card { grid-template-columns: 1fr; gap: 16px; }
  .player-bar { flex-wrap: wrap; }
  .spacer { display: none; }
  .exports { margin-left: auto; }
  .footer { justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
