/* Twige Hamwe — Rwandan blue, sun yellow, green */
:root {
  --blue: #00a1de;
  --blue-ink: #00698f;      /* blue dark enough for text and buttons (AA on white) */
  --blue-soft: #e5f5fc;
  --yellow: #fad201;
  --yellow-soft: #fff8d1;
  --green: #20603d;
  --green-soft: #e6f2eb;
  --ink: #17232b;
  --ink-2: #4b5a63;
  --line: #dfe6ea;
  --bg: #f6f8f9;
  --card: #ffffff;
  --close: #9a6a00;  --close-bg: #fff1c2;
  --unclear: #b34700; --unclear-bg: #ffe3d1;
  --missed: #8a2a2a; --missed-bg: #f8dddd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 40, .06), 0 4px 16px rgba(16, 32, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; font-size: 16px; }
a { color: var(--blue-ink); }
svg[aria-hidden] { width: 1.1em; height: 1.1em; vertical-align: -.18em; flex: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.flag-bar { height: 5px; background: linear-gradient(90deg, var(--blue) 0 50%, var(--yellow) 50% 75%, var(--green) 75%); }

/* header */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.08rem; }
.brand img { width: 38px; height: 38px; }
.brand small { display: block; font-weight: 500; color: var(--ink-2); font-size: .72rem; letter-spacing: .02em; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button.linklike { padding: .45rem .7rem; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .92rem; }
.nav a:hover, .nav a.on { background: var(--blue-soft); color: var(--blue-ink); }
.nav form { margin: 0; }
button.linklike { background: none; border: 0; cursor: pointer; font: inherit; }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 9px; padding: .45rem .6rem; font: inherit; font-weight: 600; }
@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: .6rem; margin: 0; }
  .nav.open { display: flex; }
  .top .wrap { flex-wrap: wrap; }
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 1.4rem; padding-bottom: 3rem; }
.foot { text-align: center; color: var(--ink-2); font-size: .8rem; padding: 1.5rem 16px 2.5rem; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .grid > * + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.pagehead { margin-bottom: 1.2rem; }
.pagehead p { margin: .2rem 0 0; }

/* stat tiles */
.stat { padding: 1rem 1.1rem; }
.stat .label { color: var(--ink-2); font-size: .85rem; font-weight: 600; }
.stat .value { font-size: 2rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.15; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .82rem; color: var(--ink-2); }
.up { color: var(--green); } .down { color: var(--unclear); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border: 1px solid transparent; border-radius: 11px; padding: .62rem 1rem; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; min-height: 44px; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--blue-ink); color: #fff; }
.btn-primary:hover { background: #005878; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #174a2e; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-danger { background: #fff; color: var(--missed); border-color: #efc9c9; }
.btn-sm { min-height: 34px; padding: .35rem .7rem; font-size: .88rem; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid #c9d4da; border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(0, 161, 222, .35); outline-offset: 1px; border-color: var(--blue); }
.field { margin-bottom: .9rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.form-row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }

/* flashes */
.flash { padding: .75rem 1rem; border-radius: 11px; margin-bottom: 1rem; font-weight: 550; border: 1px solid; }
.flash.ok { background: var(--green-soft); border-color: #b9dcc7; color: #134027; }
.flash.error { background: var(--missed-bg); border-color: #efc0c0; color: var(--missed); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .6rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* pills */
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.pill.level { background: var(--blue-soft); color: var(--blue-ink); border-color: #bfe6f6; }
.pill.ok { background: var(--green-soft); color: var(--green); border-color: #b9dcc7; }
.pill.warn { background: var(--yellow-soft); color: #6b5600; border-color: #f0df8a; }
.pill.off { background: #f1f1f1; color: #666; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .12em; font-size: 1.15rem; background: var(--yellow-soft); border: 1px dashed #e6c800; padding: .2rem .6rem; border-radius: 8px; }

/* lesson tiles */
.lesson-tile { display: flex; flex-direction: column; gap: .4rem; }
.lesson-tile h3 { margin: 0; }
.lesson-tile .actions { margin-top: auto; display: flex; gap: .5rem; flex-wrap: wrap; padding-top: .4rem; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink-2); font-weight: 650; font-size: .9rem; }
.tabs a.on { background: var(--blue-ink); color: #fff; border-color: var(--blue-ink); }

/* bar chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 34px; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar i.zero { background: var(--line); }
.bars .bar b { font-size: .72rem; font-weight: 650; color: var(--ink-2); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.bars-x { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 4px; }
.bars-x span { flex: 1; text-align: center; font-size: .68rem; color: var(--ink-2); min-width: 0; overflow: hidden; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .25rem .65rem; border-radius: 999px; background: var(--unclear-bg); color: var(--unclear); font-weight: 650; font-size: .88rem; border: 0; font-family: inherit; cursor: pointer; }
.chip small { opacity: .75; font-weight: 600; }

/* ---------------------------------------------------------------- practice */
.practice { max-width: 760px; margin: 0 auto; }
.progress-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.progress-dots button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font: inherit; font-size: .78rem; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.progress-dots button.on { border-color: var(--blue-ink); color: var(--blue-ink); }
.progress-dots button.pass { background: var(--green); border-color: var(--green); color: #fff; }
.item-card { text-align: center; padding: 1.6rem 1.2rem 1.4rem; }
.item-kind { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; color: var(--ink-2); }
.item-display { font-size: 1.1rem; font-weight: 700; color: var(--green); margin-top: .3rem; }
.item-text { font-size: clamp(1.7rem, 6vw, 2.7rem); font-weight: 720; line-height: 1.3; margin: .5rem 0 1rem; letter-spacing: -.005em; }
.item-text .w { display: inline-block; padding: 0 .12em; margin: .05em 0; border-radius: 8px; border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; }
.item-text .w.clear { background: var(--green-soft); color: var(--green); }
.item-text .w.close { background: var(--close-bg); color: var(--close); }
.item-text .w.unclear { background: var(--unclear-bg); color: var(--unclear); }
.item-text .w.missed { background: var(--missed-bg); color: var(--missed); text-decoration: underline dotted; }
.item-text .w.speaking { outline: 3px solid var(--yellow); }
.item-tip { background: var(--yellow-soft); border-radius: 10px; padding: .55rem .8rem; font-size: .92rem; display: inline-block; margin-bottom: .9rem; }
.meaning { margin-top: .6rem; font-size: 1rem; color: var(--ink-2); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.steps li button { width: 100%; display: flex; align-items: center; gap: .45rem; justify-content: center; padding: .55rem .4rem; border-radius: 11px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; font-size: .88rem; color: var(--ink-2); cursor: pointer; min-height: 48px; }
.steps li button .n { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; flex: none; }
.steps li button.on { border-color: var(--blue-ink); color: var(--blue-ink); background: var(--blue-soft); }
.steps li button.on .n { background: var(--blue-ink); color: #fff; }
.steps li button.done .n { background: var(--green); color: #fff; }
.step-help { color: var(--ink-2); margin-bottom: 1rem; }

.mic { width: 92px; height: 92px; border-radius: 50%; border: 0; background: var(--blue-ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 105, 143, .35); }
.mic svg { width: 40px; height: 40px; }
.mic.rec { background: #c62828; animation: pulse 1.3s infinite; box-shadow: 0 6px 18px rgba(198, 40, 40, .35); }
.mic.busy { background: var(--ink-2); animation: none; }
.mic.child { background: var(--green); box-shadow: 0 6px 18px rgba(32, 96, 61, .35); }
.mic.child.rec { background: #c62828; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, .45); } 70% { box-shadow: 0 0 0 18px rgba(198, 40, 40, 0); } 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); } }
.mic-status { min-height: 1.5em; margin-top: .55rem; color: var(--ink-2); font-weight: 600; }
.result { margin-top: 1rem; text-align: left; display: none; }
.result.show { display: block; }
.score-row { display: flex; align-items: center; gap: 1rem; }
.ring { --p: 0; --c: var(--green); width: 84px; height: 84px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex: none; }
.ring span { width: 66px; height: 66px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; font-size: .8rem; color: var(--ink-2); margin-top: .5rem; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.tip { background: var(--blue-soft); border-left: 4px solid var(--blue); padding: .7rem .9rem; border-radius: 0 10px 10px 0; margin-top: .9rem; }
.tip .hint { margin-top: .4rem; color: var(--ink-2); }
.privacy { font-size: .82rem; color: var(--ink-2); display: flex; gap: .4rem; align-items: flex-start; justify-content: center; margin-top: 1rem; }
.privacy svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.nav-row { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; }

/* classroom (projector) */
body.classroom { background: #0e1a21; color: #fff; }
.class-stage { min-height: calc(100vh - 0px); display: flex; flex-direction: column; }
.class-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; gap: 1rem; flex-wrap: wrap; }
.class-top a, .class-top .t { color: #cfe3ec; text-decoration: none; font-weight: 650; }
.class-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.class-display { color: var(--yellow); font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 700; }
.class-text { font-size: clamp(2.6rem, 8vw, 6.5rem); font-weight: 800; line-height: 1.2; margin: .3em 0 .5em; max-width: 1400px; }
.class-text .w { border-radius: 12px; padding: 0 .1em; transition: background .1s; }
.class-text .w.speaking { background: var(--yellow); color: #0e1a21; }
.class-controls { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.class-controls .btn { min-height: 64px; padding: .8rem 1.4rem; font-size: 1.15rem; border-radius: 16px; }
.class-controls .btn svg { width: 28px; height: 28px; }
.btn-dark { background: #1f3340; color: #fff; border-color: #2d4757; }
.btn-dark:hover { background: #29424f; }
.class-bottom { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 22px; gap: 1rem; }
.class-bottom .btn { min-height: 56px; font-size: 1.05rem; }
.class-count { color: #cfe3ec; font-weight: 700; font-size: 1.1rem; }
.rec-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #ff5252; margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* auth */
.auth { max-width: 440px; margin: 2rem auto; }
.auth .brand-big { text-align: center; margin-bottom: 1.2rem; }
.auth .brand-big img { width: 84px; height: 84px; }
.auth .brand-big h1 { margin: .4rem 0 .1rem; font-size: 1.7rem; }
.lang-pick { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin-bottom: 1rem; }
.lang-pick a { font-size: .8rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); background: #fff; }
.lang-pick a.on { border-color: var(--blue-ink); color: var(--blue-ink); font-weight: 700; }

.homework-item { display: flex; gap: .9rem; align-items: center; justify-content: space-between; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.homework-item:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 1.4rem; color: var(--ink-2); }
details summary { cursor: pointer; font-weight: 650; }
.item-edit { border: 1px solid var(--line); border-radius: 12px; padding: .9rem; margin-bottom: .8rem; background: #fcfdfd; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* mouth / articulation panel */
.mouth { margin: 1rem auto 0; text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: .8rem; background: #fffdf8; max-width: 640px; }
.mouth-title { font-weight: 750; font-size: .95rem; margin-bottom: .4rem; display: flex; justify-content: space-between; align-items: center; }
.mouth-tabs { display: flex; gap: .35rem; margin-bottom: .4rem; }
.mouth-tabs:empty { display: none; }
.mouth-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .2rem .7rem; font: inherit; font-weight: 700; cursor: pointer; }
.mouth-tabs button.on { background: var(--green); color: #fff; border-color: var(--green); }
.mouth-head { margin-bottom: .4rem; }
.mouth-ipa { font-weight: 800; color: var(--green); font-size: 1.1rem; }
.mouth-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .8rem; align-items: start; }
.mouth-pics { display: flex; flex-direction: column; gap: .4rem; }
.mouth-side { width: 100%; max-width: 300px; height: auto; display: block; }
.mouth-fronts { display: flex; gap: .6rem; align-items: flex-end; }
.mouth-fronts svg { width: 110px; height: auto; display: block; }
.mouth-steps { margin: 0; padding-left: 1.2rem; font-size: .95rem; }
.mouth-steps li { margin-bottom: .35rem; }
@media (max-width: 560px) { .mouth-body { grid-template-columns: 1fr; } .mouth-side { max-width: 100%; } }
.classroom .mouth { background: #13242e; border-color: #2d4757; color: #fff; max-width: 820px; }
.classroom .mouth .muted { color: #9fb8c4; }
.classroom .mouth-steps { font-size: 1.15rem; }

/* classroom echo match */
.echo { width: min(820px, 100%); margin: 1.2rem auto 0; background: #13242e; border: 1px solid #2d4757; border-radius: 16px; padding: 1rem 1.2rem; text-align: left; }
.echo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.echo-title { font-weight: 800; font-size: 1.15rem; color: #fff; }
.echo-big { font-size: 2.4rem; font-weight: 850; color: #fff; font-variant-numeric: tabular-nums; }
.echo-track { height: 12px; background: #22394a; border-radius: 999px; overflow: hidden; flex: 1; }
.echo-track.big { height: 22px; margin: .4rem 0 .8rem; }
.echo-track i { display: block; height: 100%; border-radius: 999px; transition: width .6s ease; }
.echo-shape { width: 100%; height: 70px; display: block; background: #0e1a21; border-radius: 10px; }
.echo-legend { display: flex; gap: 1rem; font-size: .85rem; color: #cfe3ec; margin: .35rem 0 .7rem; }
.echo-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.echo-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) 2fr 52px; gap: .8rem; align-items: center; margin: .45rem 0; }
.echo-label { color: #fff; font-weight: 700; font-size: 1rem; }
.echo-label span { color: #9fb8c4; font-weight: 500; font-size: .82rem; }
.echo-num { color: #fff; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.echo-note { color: #fff; font-size: 1.1rem; font-weight: 650; margin: .7rem 0 .3rem; }
.echo-fine { color: #9fb8c4; font-size: .8rem; margin: 0; }
@media (max-width: 640px) { .echo-row { grid-template-columns: 1fr 52px; } .echo-row .echo-track { grid-column: 1 / -1; grid-row: 2; } }
