:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-2: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding: 24px 16px 80px;
}

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

.screen {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

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

.lead {
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 16px;
}

.bullets {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text-muted);
  line-height: 1.6;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 8px 0;
  width: 100%;
  transition: transform 0.05s ease, background 0.15s ease;
}

button:active { transform: scale(0.98); }

button.primary {
  background: var(--accent-strong);
  color: white;
  font-weight: 600;
}
button.primary:hover { background: var(--accent); }

button.secondary {
  background: var(--bg-card-2);
  color: var(--text);
}

button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 16px;
}

button.link {
  background: transparent;
  color: var(--text-muted);
  text-decoration: underline;
  padding: 8px;
  font-size: 0.9rem;
}

.field {
  display: block;
  margin: 16px 0;
}
.field > span {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--bg-card-2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.progress {
  margin-bottom: 24px;
}
.progress-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.phoneme-card {
  text-align: center;
  background: var(--bg-card-2);
  border-radius: var(--radius);
  padding: 32px 16px;
  margin-bottom: 24px;
}
.ipa {
  font-size: 5rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 8px;
}
.example {
  color: var(--text-muted);
  margin-bottom: 16px;
}
.example-word {
  display: inline-block;
  margin-left: 6px;
  font-size: 1.4rem;
  color: var(--text);
  font-weight: 500;
}
.example-word .target {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.record-area {
  text-align: center;
  margin: 24px 0;
}

.record-state {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 1.2em;
}

.record-button {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-strong);
  color: white;
  margin: 0 auto;
  position: relative;
  padding: 0;
  display: block;
}
.record-button::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  margin: 0 auto;
}
.record-button.recording {
  background: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}
.record-button.recording::before {
  border-radius: 4px;
  width: 24px;
  height: 24px;
}
.record-button:disabled {
  opacity: 0.5;
  cursor: default;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6); }
  50% { box-shadow: 0 0 0 18px rgba(248, 113, 113, 0); }
}

.level {
  width: 60%;
  margin: 16px auto 0;
  height: 4px;
  background: var(--bg-card-2);
  border-radius: 2px;
  overflow: hidden;
}
#level-bar {
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width 0.05s linear;
}

.playback {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius);
  margin: 16px 0;
}
.playback-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.playback audio {
  width: 100%;
  margin-bottom: 12px;
}
.playback .actions {
  display: flex;
  gap: 8px;
}
.playback .actions button {
  flex: 1;
  margin: 0;
}

.footer-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.footer-actions button { width: auto; }

.error {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
  padding: 12px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-2: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
  }
  .screen { box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08); }
}
