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

:root {
  --bg: #0a0a0a;
  --card-bg: #1a1a1a;
  --text: #ffffff;
  --text-dim: #888888;
  --blue: #3b82f6;
  --orange: #f97316;
  --red: #ef4444;
  --green: #22c55e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Login Screen */
#login-screen {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.login-container {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.login-container h1 {
  font-size: 64px;
  margin-bottom: 10px;
}

.login-container h2 {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 40px;
  color: var(--text-dim);
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 30px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--text-dim);
  transition: all 0.2s;
}

.pin-dot.filled {
  background: var(--blue);
  border-color: var(--blue);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  margin: 0 auto;
}

.pin-btn {
  aspect-ratio: 1;
  font-size: 28px;
  font-weight: 500;
  background: var(--card-bg);
  border: none;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.pin-btn:active {
  transform: scale(0.95);
  background: var(--blue);
}

.error {
  color: var(--red);
  margin-top: 20px;
  min-height: 24px;
}

/* App Screen */
#app-screen {
  padding: 20px;
  padding-bottom: 140px;
  position: relative;
}

/* API Status Indicator */
.status-indicator {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  z-index: 100;
  font-size: 12px;
  transition: all 0.3s ease;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: gray;
  transition: background 0.3s ease;
}

.status-dot.green { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-dot.yellow { background: #eab308; box-shadow: 0 0 8px #eab308; }
.status-dot.orange { background: #f97316; box-shadow: 0 0 8px #f97316; }
.status-dot.red { background: #ef4444; box-shadow: 0 0 8px #ef4444; animation: pulse-red 1.5s infinite; }
.status-dot.gray { background: #6b7280; }

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text {
  color: var(--text-dim);
  white-space: nowrap;
}

/* Red Overlay - expands from button position */
.red-overlay {
  position: fixed;
  bottom: 70px;
  left: 50%;
  width: 80px;
  height: 80px;
  background: var(--red);
  border-radius: 50%;
  transform: translateX(-50%) scale(0);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  pointer-events: none;
}

.red-overlay.active {
  transform: translateX(-50%) scale(40);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 20;
}

/* Status Message */
.status-message {
  text-align: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 500;
  min-height: 28px;
  padding: 10px 0;
}

/* Language Cards */
.language-card {
  position: relative;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  padding-left: 60px;
  overflow: hidden;
}

.language-card.hidden {
  display: none;
}

.input-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Flag Corner - Triangle mask (top-left, top-right, bottom-left) */
.flag-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 60px;
  height: 60px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.flag-corner svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 90px;
  height: 60px;
}

.card-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.card-text {
  flex: 1;
  font-size: 22px;
  line-height: 1.4;
}

.card-text.loading {
  color: var(--text-dim);
  font-style: italic;
}

.audio-control {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.play-btn {
  background: var(--blue);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn svg {
  width: 24px;
  height: 24px;
}

.play-btn:active {
  transform: scale(0.9);
}

.play-btn.hidden {
  display: none;
}

.play-btn.playing {
  background: var(--red);
}

.play-btn .icon-stop {
  display: none;
}

.play-btn.playing .icon-play {
  display: none;
}

.play-btn.playing .icon-stop {
  display: block;
}

.spinner-small {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-small.hidden {
  display: none;
}

.results-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Record Section - Fixed at bottom */
.record-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 30;
}

/* Record Button States */
.record-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  position: relative;
  z-index: 31;
}

.record-button:active {
  transform: scale(0.95);
}

.record-button .btn-icon {
  width: 36px;
  height: 36px;
}

.record-button .btn-icon.hidden {
  display: none;
}

/* State: Idle (blue, mic icon) */
.record-button.state-idle {
  background: var(--blue);
}

/* State: Preparing (orange, spinner) */
.record-button.state-preparing {
  background: var(--orange);
  pointer-events: none;
}

/* State: Recording (red, stop icon) - but button stays normal, overlay expands */
.record-button.state-recording {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
}

/* State: Processing (orange, spinner) */
.record-button.state-processing {
  background: var(--orange);
  pointer-events: none;
}

/* State: Success (green, check icon) */
.record-button.state-success {
  background: var(--green);
  pointer-events: none;
}

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

/* Responsive */
@media (min-width: 768px) {
  .results-container {
    flex-direction: row;
    justify-content: center;
    gap: 20px;
  }

  .language-card {
    max-width: 400px;
  }

  #app-screen {
    max-width: 900px;
    margin: 0 auto;
  }
}
