:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --border: #e3e3df;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2563eb;
  --danger: #dc2626;
  --success: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.container.wide { max-width: 1100px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.prompt-body {
  white-space: pre-wrap;
  font-size: 1.05rem;
  margin: 0;
}

label { display: block; font-weight: 600; margin: 16px 0 6px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: white;
}

textarea { min-height: 140px; resize: vertical; }

button, .btn {
  display: inline-block;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: #e5e5e2; color: var(--text); }
button.danger { background: var(--danger); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type="text"] { flex: 1; min-width: 0; }

.recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
}

.record-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
}
.record-btn.recording { background: #444; animation: pulse 1.5s infinite; }
.record-btn:disabled { opacity: 0.5; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
  50% { box-shadow: 0 0 0 14px rgba(220,38,38,0); }
}

.timer {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.status { color: var(--muted); margin-top: 8px; min-height: 1.5em; }
.status.success { color: var(--success); font-weight: 600; }
.status.error { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.flash.error { background: #fee2e2; color: #991b1b; }
.flash.success { background: #dcfce7; color: #166534; }

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0 10px;
  margin-top: 12px;
  border-top: 2px solid var(--border);
}
.group-header:first-of-type { border-top: 0; margin-top: 0; padding-top: 4px; }
.group-header .btn { font-size: 0.9rem; padding: 8px 14px; }
.group-header .badge { margin-left: 6px; vertical-align: middle; }
.group-body { margin: 0 0 8px; }
.group-body summary { cursor: pointer; padding: 4px 0; user-select: none; }
.group-body .prompt-body { margin: 8px 0 0; padding: 12px; background: #fafafa; border-radius: 6px; }

.submission-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.submission-list li {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.submission-list li:last-child { border-bottom: 0; }
.submission-list a { color: var(--accent); text-decoration: none; font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.done { background: #dcfce7; color: #166534; }
.badge.processing { background: #fef9c3; color: #854d0e; }
.badge.error { background: #fee2e2; color: #991b1b; }
.badge.pending { background: #e5e5e2; color: #555; }

.meta { color: var(--muted); font-size: 0.85rem; }

pre.transcript {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.95rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.recording-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom)) 16px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
}
.recording-bar .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.recording-bar .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--danger); animation: pulse-dot 1.2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.recording-bar .label { font-weight: 600; }
.recording-bar .timer { font-size: 1.2rem; }
body.is-recording { padding-bottom: 80px; }

.submitted {
  text-align: center;
  padding: 60px 20px;
}
.submitted .checkmark {
  font-size: 4rem;
  color: var(--success);
}
.submitted h1 { font-size: 2rem; }
