*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0f;
  --surface: #18181b;
  --surface2: #222228;
  --border: #2e2e36;
  --text: #f4f4f5;
  --text-muted: #71717a;
  --text-dim: #3f3f46;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 1100px;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all .3s;
}

.status-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background .3s;
}

.status-badge.ok .dot   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-badge.err .dot  { background: var(--danger); }
.status-badge.ok .label { color: var(--success); }
.status-badge.err .label{ color: var(--danger); }

/* ── Language Bar ────────────────────────────────────────────── */
.lang-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.lang-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.lang-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lang-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.lang-group select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  padding: 9px 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%2371717a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  transition: border-color .2s;
}

.lang-group select:hover,
.lang-group select:focus { border-color: var(--accent); }

.arrow-icon {
  color: var(--text-muted);
  padding-bottom: 10px;
  flex-shrink: 0;
}

.lang-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.lang-group--model { flex: 1.4; }

/* ── Panels ──────────────────────────────────────────────────── */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 260px;
  overflow: hidden;
  transition: border-color .3s;
}

.panel-input.listening { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }

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

.panel-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-clear, .btn-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 0;
  transition: color .2s, background .2s;
}

.btn-clear:hover { color: var(--danger); background: rgba(239,68,68,.1); }
.btn-copy:hover  { color: var(--accent); background: var(--accent-glow); }

.panel-body {
  padding: 20px;
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.7;
  overflow-y: auto;
  word-break: break-word;
}

.placeholder { color: var(--text-dim); font-style: italic; font-size: 0.95rem; }

.listening-pulse {
  animation: pulse-text 1.5s ease-in-out infinite;
  color: var(--accent) !important;
  font-style: normal !important;
}
@keyframes pulse-text { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Interim (grey) + final text */
.interim { color: var(--text-muted); }
.final   { color: var(--text); }

/* Streaming cursor */
.cursor {
  display: inline-block;
  width: 2px; height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink .7s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Mic Area ────────────────────────────────────────────────── */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: 8px 0;
}

.mic-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
}

.mic-rings.active .ring {
  animation: ripple 1.6s ease-out infinite;
}

.ring-1 { animation-delay: 0s !important; }
.ring-2 { animation-delay: .5s !important; }

@keyframes ripple {
  0%   { width: 72px; height: 72px; opacity: .5; }
  100% { width: 140px; height: 140px; opacity: 0; }
}

.mic-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: background .25s, border-color .25s, color .25s, transform .15s;
}

.mic-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

.mic-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse-btn 1.5s ease-in-out infinite;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50%       { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
}

.mic-btn .icon-stop { display: none; }
.mic-btn.recording .icon-mic  { display: none; }
.mic-btn.recording .icon-stop { display: block; }

.mic-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  .panels { grid-template-columns: 1fr; }
  .lang-bar { flex-direction: column; gap: 12px; }
  .arrow-icon { display: none; }
}
