/* ==== БАЗА ==== */
html, body {
  height: 100%;
  margin: 0;
}
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom right, #020617, #0f172a, #1e293b);
  color: #f1f5f9;
}
.container {
  max-width: 768px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}

/* ==== ТЕКСТ ==== */
h1 {
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}
p { margin: 0.5rem 0 0; color: #cbd5e1; }
code { color: #38bdf8; }

/* ==== ПАНЕЛИ ==== */
.glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  padding: 1.5rem;
}

/* ==== КНОПКИ ==== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 1rem;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: white;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
#btnRecord { background: #0ea5e9; box-shadow: 0 4px 12px rgba(14,165,233,0.3); }
#btnRecord:hover { background: #38bdf8; }
#btnRecord:active { background: #0284c7; }

#btnStop { background: #f43f5e; box-shadow: 0 4px 12px rgba(244,63,94,0.3); }
#btnStop:hover { background: #fb7185; }
#btnStop:active { background: #e11d48; }

#btnSend { background: #10b981; margin-left: auto;
           box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
#btnSend:hover { background: #34d399; }
#btnSend:active { background: #059669; }

/* ==== ВЕРСТКА ==== */
.row { display: flex; align-items: center; gap: 1rem; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: 2fr 1fr; }
}

/* ==== ВОЛНЫ ==== */
canvas { width: 100%; height: 96px; display: block; }

/* ==== ТАЙМЕР ==== */
#timer {
  font-size: 1.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#status { color: #cbd5e1; font-size: 0.875rem; }

.dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: #fb7185;
  border-radius: 50%;
  animation: pulse 1.2s infinite ease-in-out;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.2); opacity: .5; }
}

/* ==== ОТЛАДКА ==== */
#result { white-space: pre-wrap; color: #e2e8f0; }
#log {
  max-height: 200px;
  overflow: auto;
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: pre-wrap;
}
small { color: #94a3b8; font-size: 0.75rem; }

/* ==== Общая сетка ==== */
.container {
  max-width: 768px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==== Блоки (glassmorphism) ==== */
.glass {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* ==== Заголовок ==== */
.header {
  text-align: center;
}
.header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}
.header p {
  margin-top: 0.5rem;
  color: #94a3b8;
}

/* ==== Транскрипция ==== */
.transcript {
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #e2e8f0;
}
.transcript .placeholder {
  text-align: center;
  color: #64748b;
  font-style: italic;
  margin-top: 2rem;
}
.message {
  margin: 0.4rem 0;
  padding: 0.6rem 0.9rem;
  border-radius: 0.75rem;
}
.message.ai {
  background: rgba(59,130,246,0.2);
}
.message.system {
  background: rgba(16,185,129,0.2);
  font-size: 0.85rem;
}
.message.error {
  background: rgba(244,63,94,0.2);
  color: #fecaca;
}

/* ==== Кнопки ==== */
.btn {
  background: #0ea5e9;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: 0.2s;
}
.btn:hover {
  background: #38bdf8;
}
.btn:active {
  transform: scale(0.97);
}
.btn.big {
  font-size: 1.25rem;
  width: 100%;
  justify-content: center;
}
.btn-reconnect {
  background: transparent;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  padding: 0.6rem 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
}
.btn-reconnect:hover {
  background: rgba(56,189,248,0.1);
}

/* ==== Статус ==== */
.status {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: #cbd5e1;
}
.status-indicator {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #64748b;
}
.status-indicator.connected { background: #10b981; }
.status-indicator.recording { background: #f43f5e; animation: pulse 1s infinite; }
.status-indicator.disconnected { background: #64748b; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

/* ==== Индикатор громкости ==== */
.audio-level {
  margin-top: 0.5rem;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.audio-level-bar {
  height: 100%;
  width: 0%;
  background: #38bdf8;
  transition: width 0.1s linear;
}

/* ==== Поле ввода ==== */
input[type="text"] {
  width: 50%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  font-size: 1rem;
  color: #f1f5f9;
  outline: none;
  transition: border 0.2s, background 0.2s, box-shadow 0.2s;
}

input[type="text"]::placeholder {
  color: #94a3b8;
}

input[type="text"]:focus {
  border-color: #38bdf8;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.25);
}

.lesson-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lesson-controls div {
  margin-top: 10px;
  margin-bot: 10px;
}

.lesson-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.lesson-row input {
  flex: 1;
}

.lesson-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stop-btn {
    background: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
}

.stop-btn:disabled {
    background: var(--disabled-color) !important;
    border-color: var(--disabled-color) !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.stop-btn.active {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
