:root {
  --bg-1: #0f1419;
  --bg-2: #1a2332;
  --bg-3: #0d1b2a;
  --accent: #0A84FF;
  --accent-hover: #0070e0;
  --live: #FF453A;
  --success: #30D158;
  --warning: #FFD60A;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.55);
  --radius: 20px;
  --radius-sm: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  min-height: 100dvh;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}

.blob-1 {
  width: 300px; height: 300px;
  background: #0A84FF;
  top: -5%; left: -10%;
  animation: blobMove1 25s ease-in-out infinite;
}

.blob-2 {
  width: 250px; height: 250px;
  background: #BF5AF2;
  bottom: 10%; right: -5%;
  animation: blobMove2 30s ease-in-out infinite;
}

.blob-3 {
  width: 200px; height: 200px;
  background: #30D158;
  top: 50%; left: 40%;
  animation: blobMove3 22s ease-in-out infinite;
}

@keyframes blobMove1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(60px, 80px); }
}
@keyframes blobMove2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-50px, -60px); }
}
@keyframes blobMove3 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, -50px); }
}

.page {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

@supports not (backdrop-filter: blur(24px)) {
  .glass { background: rgba(30, 40, 55, 0.92); }
}

.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { width: 28px; height: 28px; fill: white; }

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo h1 span { color: var(--accent); }

.logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
}

.card {
  padding: 28px 24px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  min-height: 52px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover { background: rgba(255,255,255,0.12); }

.btn-danger {
  background: rgba(255, 69, 58, 0.2);
  color: var(--live);
  border: 1px solid rgba(255, 69, 58, 0.3);
}

.input-group {
  margin-top: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  padding: 14px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
}

.input-row input::placeholder {
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-secondary);
}

.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--glass-border);
}

.badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.badge-dot.green { background: var(--success); }
.badge-dot.red { background: var(--live); animation: pulse 2s infinite; }
.badge-dot.gray { background: var(--text-secondary); }
.badge-dot.yellow { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 8px;
}

.room-code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
}

.room-code small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: normal;
  color: var(--text-secondary);
}

.top-badges { display: flex; gap: 8px; }

.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 0;
}

.record-btn-wrap {
  position: relative;
  width: 100px; height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--live);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  z-index: 2;
  position: relative;
}

.record-btn:active { transform: scale(0.93); }

.record-btn svg { width: 28px; height: 28px; fill: white; }

.record-btn.recording {
  background: #cc0000;
}

.record-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--live);
  opacity: 0;
  animation: none;
}

.recording .record-pulse {
  opacity: 1;
  animation: recordPulse 2s ease-out infinite;
}

@keyframes recordPulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
  margin-top: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.waveform.active { opacity: 1; }

.waveform span {
  width: 4px;
  background: var(--live);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite alternate;
}

.waveform span:nth-child(1) { animation-delay: 0s; height: 8px; }
.waveform span:nth-child(2) { animation-delay: 0.1s; height: 16px; }
.waveform span:nth-child(3) { animation-delay: 0.2s; height: 24px; }
.waveform span:nth-child(4) { animation-delay: 0.3s; height: 16px; }
.waveform span:nth-child(5) { animation-delay: 0.4s; height: 8px; }

@keyframes wave {
  to { height: 28px; }
}

.record-label {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.qr-section {
  text-align: center;
  padding: 20px;
  margin-bottom: 16px;
}

.qr-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.qr-box {
  background: white;
  border-radius: 12px;
  padding: 12px;
  display: inline-block;
  cursor: pointer;
}

.qr-box canvas, .qr-box img { display: block; }

.qr-url {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  word-break: break-all;
}

.transcript-box {
  flex: 1;
  padding: 16px;
  margin-bottom: 16px;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.transcript-box h3 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: inherit;
  padding-bottom: 4px;
}

#transcriptList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transcript-line.draft,
.line.draft {
  opacity: 0.7;
  border-color: rgba(10, 132, 255, 0.35);
  background: rgba(10, 132, 255, 0.08);
}

.transcript-line.draft::after,
.line.draft .translation::after {
  content: '…';
  color: var(--accent);
  margin-left: 4px;
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.transcript-line {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideIn 0.25s ease-out;
  line-height: 1.55;
  font-size: 15px;
  word-break: break-word;
}

.transcript-line .lang-tag {
  display: block;
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(10, 132, 255, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
  width: fit-content;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bottom-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.lang-picker {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
}

.lang-picker.hidden { display: none; }

.lang-picker .card { width: 100%; max-width: 400px; max-height: 80dvh; overflow-y: auto; }

.lang-picker h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.lang-picker p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.lang-list { display: flex; flex-direction: column; gap: 8px; }

.lang-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-size: 16px;
}

.lang-item:hover, .lang-item.selected {
  background: rgba(10, 132, 255, 0.15);
  border-color: var(--accent);
}

.lang-item .flag { font-size: 24px; }

.listener-transcript {
  flex: 1;
  padding: 20px 16px;
  margin-bottom: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.listener-transcript .line {
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideIn 0.25s ease-out;
}

.listener-transcript .line .translation {
  font-size: 20px;
  line-height: 1.55;
  font-weight: 500;
  word-break: break-word;
}

.listener-transcript .line .original {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  line-height: 1.5;
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 50;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
}

.bottom-bar-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 12px;
  transition: color 0.2s, background 0.2s;
  min-width: 64px;
}

.bar-btn.active { color: var(--accent); }
.bar-btn svg { width: 22px; height: 22px; fill: currentColor; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 200;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  transition: transform 0.3s ease;
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
}

.modal-overlay.hidden { display: none; }

.modal {
  padding: 28px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.modal h2 { font-size: 20px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

.modal .btn { margin-bottom: 8px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.waiting-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.waiting-screen .pulse-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.waiting-screen h2 { font-size: 20px; margin-bottom: 8px; }
.waiting-screen p { color: var(--text-secondary); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
