:root {
  --bg: #fff8f2;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6f655e;
  --line: #f0e3d8;
  --accent: #ff6b1a;
  --accent-ink: #ffffff;
  --accent-soft: #ffe6d6;
  --good: #1f9d55;
  --good-soft: #dcf5e6;
  --bad: #d23c3c;
  --bad-soft: #fbe1e1;
  --blue: #2f6fdd;
  --blue-soft: #e3ecfc;
  --radius: 16px;
  --shadow: 0 2px 10px rgb(80 40 10 / 0.07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f; --card: #221c17; --ink: #f6eee8; --muted: #b3a79d; --line: #3a3029;
    --accent: #ff7a2e; --accent-soft: #4a2a17; --good: #43c97b; --good-soft: #173b27;
    --bad: #f06a6a; --bad-soft: #4a1f1f; --blue: #7aa7ff; --blue-soft: #1d2b47;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
nav { display: flex; gap: 14px; align-items: center; }
nav[hidden] { display: none; }
nav a { text-decoration: none; font-weight: 600; }
.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }

main { max-width: 860px; margin: 0 auto; padding: 16px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
a.card { display: block; color: inherit; text-decoration: none; transition: transform .1s; }
a.card:active { transform: scale(.98); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.big { font-size: 2rem; font-weight: 800; }
.emoji { font-size: 1.6rem; }

.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar.good > i { background: var(--good); }
.bar.blue > i { background: var(--blue); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 700; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.good { background: var(--good-soft); color: var(--good); }

button, .btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
button.secondary, .btn.secondary { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
.full { width: 100%; }

input, textarea, select {
  font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 180px; resize: vertical; }
label { font-weight: 600; display: block; margin-bottom: 4px; }

.options { display: grid; gap: 10px; }
.option {
  text-align: left; justify-content: flex-start; background: var(--card); color: var(--ink); border: 2px solid var(--line); font-weight: 600;
}
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.picked { border-color: var(--accent); }
.passage { white-space: pre-wrap; background: var(--bg); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 8px; }
.feedback { border-radius: 12px; padding: 12px 14px; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }

.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; }
.bubble.tutor { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.learner { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 4px; }
.hint { align-self: flex-end; font-size: .85rem; color: var(--muted); max-width: 85%; }
.mic { width: 72px; height: 72px; border-radius: 50%; font-size: 1.8rem; padding: 0; }
.mic.on { background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 8px; font-size: .9rem; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }

#toasts { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); transform: translateX(-50%); display: grid; gap: 8px; z-index: 20; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / .25); animation: pop .25s; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }

.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.leader { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.leader .medal { width: 28px; text-align: center; font-size: 1.3rem; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Portuguese line under Dutch text, for A0 learners */
.pt { display: block; font-size: .85em; color: var(--muted); font-style: italic; }
h2 .pt, h3 .pt, label .pt, button .pt { display: inline; margin-left: .3em; }
.hero { border-color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--card) 70%); }
.week { display: flex; gap: 6px; margin: 8px 0; }
.week .day { flex: 1; text-align: center; padding: 6px 0; border-radius: 10px; background: var(--line); color: var(--muted); font-size: .8rem; font-weight: 600; }
.week .day.on { background: var(--good); color: #fff; }
button .pt { color: inherit; opacity: .8; }
nav a, nav button { white-space: nowrap; }
@media (max-width: 480px) {
  .brand .name { display: none; }
  nav { gap: 12px; }
}
