:root {
  --bg: #f8fafc;
  --fg: #0f172a;
  --muted: #64748b;
  --surface: #ffffff;
  --border: #cbd5e1;
  --idle: #64748b;
  --listening: #dc2626;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --surface: #1e293b;
    --border: #475569;
    --idle: #64748b;
    --listening: #ef4444;
    --accent: #3b82f6;
    --accent-fg: #ffffff;
    --ok: #4ade80;
    --warn: #fbbf24;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

#status {
  margin: 0;
  min-height: 2.4em;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
#status[data-state="copied"] { color: var(--ok); }
#status[data-state="copy-failed"],
#status[data-state="error"] { color: var(--warn); }

#mic {
  width: 160px;
  height: 160px;
  margin: 0 auto;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--idle);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
#mic:disabled { opacity: .4; cursor: not-allowed; }
#mic.listening {
  background: var(--listening);
  animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--listening) 55%, transparent); }
  100% { box-shadow: 0 0 0 36px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  #mic.listening { animation: none; }
}

.result { display: flex; flex-direction: column; gap: 6px; flex: 1; }
#interim {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted);
  opacity: .8;
  font-size: 1rem;
  word-break: break-all;
}
#text {
  width: 100%;
  flex: 1;
  min-height: 120px;
  padding: 12px;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  resize: none;
}

.actions { display: flex; gap: 12px; }
.actions button {
  flex: 1;
  min-height: 48px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.actions button.emphasis {
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}

button:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: .85rem;
  color: var(--muted);
}
.settings label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.settings select {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}
