@import url('https://fonts.bunny.net/css?family=inter:400,500,600,700&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d12;
  --surface:     #17171f;
  --surface2:    #1f1f2a;
  --border:      #28283a;
  --accent:      #6c63ff;
  --accent-hover:#5b53f0;
  --accent-glow: rgba(108, 99, 255, 0.2);
  --accent-soft: rgba(108, 99, 255, 0.12);
  --text:        #ededf5;
  --text-2:      #9898b0;
  --text-3:      #55556a;
  --success:     #34d399;
  --error:       #f87171;
  --red:         #ff4d6a;
  --red-bg:      #3a1522;
  --radius:      14px;
  --radius-sm:   8px;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== App Layout ===== */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon { font-size: 2rem; line-height: 1; }

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header p {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-top: 2px;
}

.history-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.history-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.history-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ===== Example Strip ===== */
.example-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(108, 99, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.example-label {
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.example-before { color: var(--text-2); font-style: italic; }
.example-arrow  { color: var(--accent); font-weight: 700; }
.example-after  { color: var(--text); font-weight: 500; }

/* ===== Input Section ===== */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Voice Area ===== */
.voice-area {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

/* Idle glow animation */
@keyframes idleGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(108, 99, 255, 0.06); }
  50%       { box-shadow: 0 0 36px rgba(108, 99, 255, 0.18); }
}

.record-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 76px;
  height: 76px;
  min-width: 76px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  animation: idleGlow 3s ease-in-out infinite;
}

.record-btn:active,
.record-btn.recording {
  background: var(--red-bg);
  border-color: var(--red);
  box-shadow: 0 0 0 6px rgba(255, 77, 106, 0.15), 0 0 28px rgba(255, 77, 106, 0.2);
  transform: scale(0.97);
  animation: none;
}

.record-icon { font-size: 1.7rem; }

.voice-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.record-hint {
  font-size: 0.85rem;
  color: var(--text-2);
}

/* ===== Waveform (replaces pulse dot) ===== */
.recording-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 500;
}

.recording-status.hidden,
.transcribing-status.hidden { display: none; }

.waveform {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.waveform-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--red);
  animation: waveBar 0.9s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { height: 7px;  animation-delay: 0s; }
.waveform-bar:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.waveform-bar:nth-child(3) { height: 9px;  animation-delay: 0.3s; }
.waveform-bar:nth-child(4) { height: 16px; animation-delay: 0.1s; }
.waveform-bar:nth-child(5) { height: 7px;  animation-delay: 0.25s; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(0.35); }
  50%       { transform: scaleY(1); }
}

.record-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.transcribing-status {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ===== Textarea ===== */
.text-area-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-area-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.65;
  padding: 14px 16px;
  resize: none;
  min-height: 120px;
}

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

.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.82rem;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.file-label:hover { color: var(--accent); }
.file-icon { font-size: 1rem; }

.file-name {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* ===== Tone Pills ===== */
.tone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tone-label {
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
}

.tone-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tone-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-2);
  font-size: 0.8rem;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tone-pill:hover { border-color: var(--accent); color: var(--accent); }

.tone-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* ===== Submit Button ===== */
.submit-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover:not(:disabled) { background: var(--accent-hover); }
.submit-btn:active:not(:disabled) { transform: scale(0.985); }
.submit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.submit-icon { font-size: 1.1rem; }

/* ===== Loader (dots) ===== */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px;
  color: var(--text-2);
  font-size: 0.9rem;
}

.loader-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.loader-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: dotPulse 1.2s ease-in-out infinite;
}

.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ===== Error ===== */
.error-box {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-sm);
  color: var(--error);
  padding: 10px 14px;
  font-size: 0.9rem;
}

.error-icon { flex-shrink: 0; }
.error-msg  { flex: 1; }

.retry-btn {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.retry-btn:hover { background: rgba(248, 113, 113, 0.2); }

/* ===== Result Section ===== */
.result-section {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.result-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-top-actions { display: flex; gap: 8px; }

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.copied { border-color: var(--success); color: var(--success); }

/* ===== Result Blocks ===== */
.result-blocks { padding: 4px 0; }

.result-block {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

/* Акцентная левая линия у основного варианта */
.result-block.main {
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}

.result-block:last-child { border-bottom: none; }

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

.result-block-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-block-label.alt { color: var(--text-2); }

.copy-block-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.75rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.copy-block-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-block-btn.copied { border-color: var(--success); color: var(--success); }

/* ===== Staggered text animation ===== */
.result-block-text {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}

@keyframes fadeInLine {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-line {
  display: block;
  opacity: 0;
  animation: fadeInLine 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.result-line.spacer { min-height: 0.55em; }

.clear-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.85rem;
  font-family: inherit;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.clear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== History ===== */
.history-section {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.clear-history-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-history-btn:hover { border-color: var(--error); color: var(--error); }

.history-list { padding: 4px 0; }

.history-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--surface2); }

.history-item-date    { font-size: 0.72rem; color: var(--text-3); }
.history-item-input   { font-size: 0.84rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-preview { font-size: 0.88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.history-empty {
  padding: 20px 16px;
  color: var(--text-2);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Footer ===== */
.footer {
  margin-top: 32px;
  padding: 0 0 8px;
  font-size: 0.72rem;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Desktop: центрированная колонка ===== */
@media (min-width: 900px) {
  .app { max-width: 720px; }
}

/* ===== Mobile tweaks ===== */
@media (max-width: 480px) {
  .header h1    { font-size: 1.1rem; }
  .record-btn   { width: 68px; height: 68px; min-width: 68px; }
  .record-icon  { font-size: 1.5rem; }
  .result-section-header { flex-direction: column; align-items: flex-start; }
  .history-toggle-label  { display: none; }
  .example-strip { font-size: 0.75rem; }
}
