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

:root {
  --bg: #f5f5f9;
  --bg-card: #ffffff;
  --fg: #1a1a2e;
  --muted: #6b6b80;
  --accent: #d6336c;
  --accent-dim: #f0e0e8;
  --success: #2b8a3e;
  --warning: #e67700;
  --danger: #c92a2a;
}

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Status Bar */
.status-bar {
  padding: 1.5rem;
  text-align: center;
  background: var(--bg-card);
  border-bottom: 1px solid #e0e0e8;
}

.status-bar.listening { background: #e8f0e8; }
.status-bar.capturing { background: #e8e0f0; }

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.25rem;
}

.help-btn {
  margin-left: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mic-icon { font-size: 1.5rem; }
.mic-icon.pulse { animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.status-text { font-weight: 500; }
.status-text.listening { color: var(--accent); }

.confirmation {
  margin-top: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent-dim);
  border-radius: 999px;
  display: inline-block;
  font-weight: 500;
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.section-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* Timer Grid */
.timers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.timer-card {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
  position: relative;
}

.timer-card.urgent {
  background: var(--accent);
  animation: urgent-pulse 0.5s infinite;
}

.timer-card.interval { border: 2px solid var(--accent); }

.timer-cancel {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  color: var(--fg);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.timer-card:hover .timer-cancel {
  opacity: 1;
}

.timer-id {
  position: absolute;
  top: 0.25rem;
  left: 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.8;
}

.timer-card.urgent .timer-id {
  color: var(--fg);
}

@keyframes urgent-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.timer-name {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-countdown {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Events */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.event {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: 8px;
}

.event.birth { background: var(--accent); color: white; }

.event-time {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  min-width: 5rem;
}

.event-text { flex: 1; }

/* Birth Log */
.birth-log { margin-bottom: 1rem; }

.birth-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  border: 2px solid var(--accent);
}

.birth-time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e0e0e8;
  margin-bottom: 0.75rem;
}

.birth-label { font-size: 1rem; font-weight: 600; }

.birth-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.apgar-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.apgar-item {
  text-align: center;
  padding: 0.75rem;
  background: #f0f0f5;
  border-radius: 8px;
}

.apgar-item.recorded { background: var(--accent-dim); }

.apgar-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.apgar-score {
  font-size: 2rem;
  font-weight: 700;
}

/* Quick Actions */
.quick-actions {
  position: fixed;
  bottom: 4rem;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid #e0e0e8;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.action-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s, opacity 0.1s;
}

.action-btn:active { transform: scale(0.95); }

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

.action-btn.secondary {
  background: #e0e0e8;
  color: var(--fg);
}

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

/* Inline Form */
.inline-form {
  padding: 1rem;
  background: var(--bg-card);
  border-top: 1px solid #e0e0e8;
}

.inline-form input,
.inline-form select {
  padding: 0.5rem;
  border: 1px solid #d0d0d8;
  border-radius: 6px;
  background: #fff;
  color: var(--fg);
  font-size: 1rem;
}

.inline-form input { flex: 1; min-width: 0; }
.inline-form select { min-width: 80px; }

.form-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Transcript Bar */
.transcript-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  text-align: center;
  background: var(--bg-card);
  border-top: 1px solid #e0e0e8;
}

.transcript {
  color: var(--muted);
  font-style: italic;
  font-size: 0.875rem;
}

/* Loading */
.loading-bar {
  padding: 0;
  margin-top: 1.5rem;
}

.loading-status {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 8px;
  background: #e0e0e8;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* Loading Screen */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem;
  gap: 2.5rem;
}

.loading-hero {
  text-align: center;
  max-width: 400px;
}

.loading-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.loading-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
}

.loading-subtitle {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.loading-note {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 1rem;
  opacity: 0.7;
}

/* Command Reference */
.cmd-ref {
  max-width: 400px;
  width: 100%;
}

.cmd-ref-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.cmd-ref-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cmd-ref-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-radius: 8px;
}

.cmd-phrase {
  font-size: 0.8rem;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--accent);
  white-space: nowrap;
}

.cmd-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Error Screen */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem;
  text-align: center;
}

.error-card {
  max-width: 400px;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem;
  border: 2px solid var(--danger);
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.error-message {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.error-instruction {
  font-size: 0.85rem;
  color: var(--fg);
  background: #f8f8fa;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.error-reload {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* SW Update Banner */
#sw-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--warning);
  color: white;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
}

#sw-update-banner button {
  margin-left: 0.5rem;
  padding: 0.3rem 1rem;
  border: 2px solid white;
  border-radius: 999px;
  background: transparent;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

#sw-update-banner button:hover {
  background: white;
  color: var(--warning);
}

/* Help Page */
.help-page {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 6rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.help-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.help-close {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: #e0e0e8;
  color: var(--fg);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.help-intro {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.help-section {
  margin-top: 1.5rem;
}

.help-steps {
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--fg);
}

.help-steps li {
  margin-bottom: 0.25rem;
}

.help-note {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  opacity: 0.7;
}
