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

:root {
  --bg: #fafafa;
  --text: #333;
  --text-muted: #888;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --border: #e5e5e5;
  --card-bg: #fff;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* iOS safe areas */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

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

#login-screen h1 {
  font-size: 2rem;
  margin-bottom: 30px;
  text-align: center;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

input[type="password"] {
  width: 100%;
  padding: 16px;
  font-size: 16px; /* Prevents iOS zoom */
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}

input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover, .btn.primary:active {
  background: var(--primary-hover);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px;
}

/* Recording Controls */
#recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

#idle-state .hint {
  color: var(--text-muted);
  margin-bottom: 30px;
}

.controls {
  width: 100%;
}

.record-btn {
  width: 100%;
  background: var(--danger);
  color: white;
  padding: 20px;
  font-size: 1.1rem;
}

.record-btn:hover, .record-btn:active {
  background: var(--danger-hover);
}

.record-icon {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
}

.stop-btn {
  width: 100%;
  background: #374151;
  color: white;
  padding: 20px;
  font-size: 1.1rem;
}

.stop-btn:hover, .stop-btn:active {
  background: #1f2937;
}

.stop-icon {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 2px;
}

/* Recording Indicator */
#recording-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-bottom: 40px;
}

.pulse-container {
  position: relative;
  width: 80px;
  height: 80px;
}

.pulse-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: var(--danger);
  border-radius: 50%;
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border: 3px solid var(--danger);
  border-radius: 50%;
  animation: pulse 2s ease-out infinite;
  opacity: 0;
}

.pulse-ring.delay {
  animation-delay: 1s;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

#elapsed-time {
  font-size: 2.5rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--danger);
}

.recording-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Processing Status */
#status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#status-text {
  color: var(--text-muted);
}

/* Confirmation */
#confirmation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 15px;
  text-align: center;
}

.confirmation-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 10px;
}

#confirmation h2 {
  font-size: 1.5rem;
  margin: 0;
}

.confirmation-text {
  color: var(--text-muted);
  max-width: 280px;
  margin-bottom: 20px;
}

/* Results */
#results {
  padding-top: 20px;
}

#results h2 {
  font-size: 1.25rem;
  margin-bottom: 15px;
}

.summary-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  line-height: 1.8;
  white-space: pre-wrap;
  margin-bottom: 20px;
}

.transcription-details {
  margin-bottom: 20px;
}

.transcription-details summary {
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 0;
}

.transcription-box {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 15px;
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.email-status {
  text-align: center;
  margin-bottom: 20px;
  color: var(--success);
}

.email-status.failed {
  color: var(--text-muted);
}

/* Interrupted Recording Prompt */
#interrupted-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 15px;
  text-align: center;
}

.interrupted-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

.interrupted-text {
  color: var(--text-muted);
  max-width: 280px;
  margin-bottom: 10px;
}

.interrupted-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn.secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover, .btn.secondary:active {
  background: var(--bg);
}

/* Error */
.error {
  color: var(--danger);
  text-align: center;
}

#error-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

#error-text {
  max-width: 300px;
}

/* Journal screen main */
#journal-screen main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Make buttons full width on mobile */
@media (max-width: 500px) {
  .container {
    padding: 15px;
  }

  .btn {
    width: 100%;
  }
}
