:root {
  --bg: #f7f6f2; --card: #fff; --text: #1d1d1f; --muted: #6b6b70; --line: #e3e1da;
  --accent: #c8102e; --good: #1f8a4c; --mid: #b7791f; --low: #c0392b; --wait-bg: #fbeef0;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161618; --card: #222225; --text: #f2f2f3; --muted: #a0a0a6; --line: #34343a; --wait-bg: #3a2428; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h1 small { font-size: .8rem; color: var(--muted); font-weight: 500; }
h3 { font-size: 1rem; margin: 16px 0 4px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
select, input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 16px 0; }
.target { font-size: 1.5rem; font-weight: 600; margin: 0 0 4px; }
.translation { color: var(--muted); margin: 0 0 12px; }
button { font: inherit; border-radius: 10px; border: 0; cursor: pointer; }
.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); padding: 8px 14px; }
.record { display: block; width: 100%; padding: 28px 16px; font-size: 1.2rem; font-weight: 600; background: var(--accent); color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.record.on { background: var(--good); animation: pulse 1s infinite; }
.record:disabled { opacity: .5; cursor: wait; }
@keyframes pulse { 50% { opacity: .8; } }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
header h1 { margin: 0; }
.narrow { max-width: 420px; }
.primary { width: 100%; padding: 12px; background: var(--accent); color: #fff; font-weight: 600; margin-top: 8px; }
.status { min-height: 1.5em; color: var(--muted); text-align: center; }
.warn, .error { color: var(--low); }
.score { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.score.good { color: var(--good); } .score.mid { color: var(--mid); } .score.low { color: var(--low); }
.feedback { font-size: 1.15rem; }
audio { width: 100%; margin: 4px 0 8px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; }
dt { color: var(--muted); } dd { margin: 0; }
.words { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.words li { border-radius: 8px; padding: 4px 10px; border: 1px solid var(--line); }
.words li.ok { border-color: var(--good); }
.words li.bad { border-color: var(--low); flex-basis: 100%; }
.words li.bad span { display: block; font-size: .9rem; }
.words .tip { color: var(--muted); }
/* Waiting card: a speech bubble with dancing sound bars and changing lines. */
.waiting { text-align: center; padding: 28px 18px; }
.bubble { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 120px; height: 72px; border-radius: 36px; background: var(--wait-bg); }
.bubble::after { content: ""; position: absolute; bottom: -10px; left: 26px; border: 10px solid transparent; border-top-color: var(--wait-bg); border-bottom: 0; }
.bubble span { width: 8px; height: 14px; border-radius: 4px; background: var(--accent); animation: dance 1s ease-in-out infinite; }
.bubble span:nth-child(2) { animation-delay: .12s; background: var(--mid); }
.bubble span:nth-child(3) { animation-delay: .24s; background: var(--good); }
.bubble span:nth-child(4) { animation-delay: .36s; background: var(--mid); }
.bubble span:nth-child(5) { animation-delay: .48s; }
@keyframes dance { 0%, 100% { height: 14px; } 50% { height: 40px; } }
.wait-line { margin: 22px 0 0; font-size: 1.1rem; color: var(--text); }
.wait-line.show { animation: fadein .5s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .bubble span { animation: none; height: 24px; }
  .wait-line.show { animation: none; }
}
.meta { color: var(--muted); font-size: .8rem; margin-top: 16px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
