:root {
  --bg: #fff8ec;
  --ink: #23324a;
  --muted: #5d6b82;
  --card: #ffffff;
  --accent: #2f6fdf;
  --green: #1f9d55;
  --green-bg: #e3f6ea;
  --red: #d64545;
  --red-bg: #fdeaea;
  --tip: #fff1c2;
  --line: #e7dcc8;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-size: 19px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 2rem 1rem 0.5rem; }
.hero h1 { font-size: 2.2rem; margin: 0; }
.hero p { color: var(--muted); margin: 0.4rem 0 0; }
.home { max-width: 960px; margin: 0 auto; padding: 1rem; }
.subject h2 { color: var(--accent); margin: 1.5rem 0 0.8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.lesson-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 0.8rem;
  background: var(--card);
  border: 3px solid transparent;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.1s, border-color 0.1s;
}
.lesson-card:hover, .lesson-card:focus-visible { transform: translateY(-2px); border-color: var(--accent); }
.lesson-card .num {
  grid-row: 1 / 4;
  width: 2.4rem; height: 2.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: grid; place-items: center;
}
.lesson-card .t { font-weight: 700; font-size: 1.1rem; }
.lesson-card .st { color: var(--muted); font-size: 0.9rem; }
.stars { color: #f2a900; font-size: 1.3rem; letter-spacing: 2px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 2rem 1rem; }

/* ---------- lição ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg);
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--line);
}
.back { font-weight: 700; text-decoration: none; white-space: nowrap; }
.bar { flex: 1; height: 14px; background: #fff; border-radius: 99px; overflow: hidden; border: 2px solid var(--line); }
.bar-fill { height: 100%; width: 0; background: var(--green); transition: width 0.3s; }
.counter { font-weight: 700; color: var(--muted); white-space: nowrap; }

.lesson { max-width: 780px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.lesson h1 { font-size: 2rem; margin: 1rem 0 0; color: var(--accent); }
.subtitle { color: var(--muted); margin: 0.2rem 0 0.6rem; font-size: 1.1rem; }
.intro { font-size: 1.1rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 1.2rem 0;
  box-shadow: 0 3px 0 var(--line);
}
.card h2 { margin: 0 0 0.6rem; font-size: 1.35rem; }
.explain { border-left: 8px solid var(--accent); }
.practice { border-left: 8px solid var(--green); }
.text p { margin: 0.4rem 0; }

table.rule { border-collapse: collapse; margin: 0.6rem 0; width: 100%; }
table.rule th, table.rule td { border: 2px solid var(--line); padding: 0.45rem 0.7rem; text-align: left; }
table.rule th { background: #f4efe4; }

.examples { list-style: none; padding: 0; margin: 0.6rem 0; }
.examples li { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }

.compare { display: grid; gap: 0.5rem; margin: 0.6rem 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.pair .no, .pair .ok { border-radius: 12px; padding: 0.4rem 0.7rem; display: flex; align-items: center; gap: 0.4rem; }
.pair .no { background: var(--red-bg); color: var(--red); }
.pair .ok { background: var(--green-bg); color: var(--green); font-weight: 600; }
.mark { font-weight: 800; }
@media (max-width: 560px) { .pair { grid-template-columns: 1fr; } }

.tip { background: var(--tip); border-radius: 12px; padding: 0.6rem 0.9rem; margin-top: 0.8rem; }

.speak {
  border: none; background: #eef3ff; border-radius: 50%;
  width: 2rem; height: 2rem; flex: none;
  cursor: pointer; font-size: 0.95rem; line-height: 1;
}
.speak:hover { background: #dbe6ff; }

.instructions { color: var(--muted); margin-top: 0; }
.items { padding-left: 1.4rem; margin: 0; }
.item { padding: 0.7rem 0 0.9rem; border-bottom: 2px dashed var(--line); }
.item:last-child { border-bottom: none; }
.item .q { margin: 0 0 0.5rem; font-size: 1.15rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.item.done::marker { content: "✅ "; }
.item.done-late::marker { content: "🟡 "; }
.wrongline { color: var(--red); }

.blank {
  display: inline-block; min-width: 4.5rem; text-align: center;
  border-bottom: 3px solid var(--ink); font-weight: 700; color: transparent;
}
.blank.filled { color: var(--green); border-color: var(--green); }

.opts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.opt {
  font: inherit; font-weight: 600;
  padding: 0.45rem 1.1rem;
  border-radius: 12px;
  border: 3px solid var(--line);
  background: #fff; color: var(--ink);
  cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.opt.wrong { background: var(--red-bg); border-color: var(--red); color: var(--red); text-decoration: line-through; }
.opt:disabled { cursor: default; }

.row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.answer {
  font: inherit; flex: 1; min-width: 220px;
  padding: 0.5rem 0.8rem;
  border: 3px solid var(--line); border-radius: 12px;
}
.answer:focus { outline: none; border-color: var(--accent); }
.answer.right { border-color: var(--green); background: var(--green-bg); }
.answer.wrong { border-color: var(--red); background: var(--red-bg); }
.shake { animation: shake 0.4s; border-color: var(--red); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.btn {
  font: inherit; font-weight: 700;
  padding: 0.5rem 1.3rem;
  border-radius: 12px; border: none;
  background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border: 3px solid var(--accent); }
.btn.small { padding: 0.45rem 1rem; }

.feedback { margin-top: 0.5rem; min-height: 1.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.praise { color: var(--green); font-weight: 800; }
.oops { color: var(--red); font-weight: 700; }

.task .check { font-weight: 600; cursor: pointer; }
.task input { width: 1.2rem; height: 1.2rem; vertical-align: middle; }

.result { text-align: center; border: 4px solid #f2a900; }
.stars.big { font-size: 3rem; }
.misses { text-align: left; background: #fbf7ef; border-radius: 12px; padding: 0.6rem 1rem; margin: 1rem 0; }
.misses h3 { margin: 0.3rem 0; }
.misses ul { list-style: none; padding: 0; }
.misses li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.25rem 0; }
.from { color: var(--muted); }
.actions { display: flex; justify-content: center; gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem; }
