/* Poquito: chunky, friendly, phone first. Parrot green + sunny accents. Nunito, 2px borders, 3D buttons.
   Lessons from T-Molingo's WebView: never overflow-x on html/body (kills scrolling), cap selects/inputs at 100%. */
:root {
  --green: #22b573; --green-dark: #168f59; --green-light: #dcf7e8;
  --blue: #1d8fe0; --blue-dark: #1673b5; --blue-light: #ddefff;
  --sun: #ffc93c; --sun-dark: #e0a81f; --sun-light: #fff4d1;
  --orange: #ff7a3d; --orange-dark: #e0602a;
  --red: #ff5a5f; --red-dark: #d9444a; --red-light: #ffe1e2;
  --bg: #ffffff; --bg2: #f6f7f6; --card: #ffffff;
  --ink: #2f3a36; --muted: #75807b; --line: #e3e7e5;
  --font: "Nunito", system-ui, -apple-system, sans-serif;
  --tab-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12201b; --bg2: #0d1814; --card: #192b24; --ink: #eef7f2; --muted: #9db3a9; --line: #2f463c;
    --green-light: #173b2a; --blue-light: #12304a; --sun-light: #3a3116; --red-light: #3f1d1f;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 600; font-size: 16px; line-height: 1.4; }
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
p { margin: 0 0 8px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea, img { max-width: 100%; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--bg2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; }
textarea { resize: none; }
.row > *, .col > * { min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 14px; } .tiny { font-size: 12px; }
.center { text-align: center; } .pad { padding: 24px; }
.row { display: flex; gap: 10px; align-items: center; } .spread { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }

/* header + tabs */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 8px; padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; background: var(--bg); z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 21px; color: var(--green); }
.stat { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 17px; min-width: 52px; }
.stat:last-child { justify-content: flex-end; }
.stat.off { filter: grayscale(1); opacity: .5; }
.goalline { height: 4px; background: var(--line); position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 10; }
.goalline i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .6s; }
.view { padding: 16px 16px 24px; max-width: 560px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--bg); border-top: 2px solid var(--line); z-index: 20; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 800; color: var(--muted); }
.tabs button.on { color: var(--green); }
.tabs .tico { font-size: 22px; height: 26px; display: flex; align-items: center; }
.tabs .tico img { width: 26px; height: 26px; }
.tabs button:not(.on) .tico { filter: grayscale(.7); opacity: .7; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 18px; border-radius: 16px; font-weight: 900; font-size: 16px; letter-spacing: .03em; text-transform: uppercase; background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); transition: transform .06s, box-shadow .06s; width: 100%; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.sun { background: var(--sun); color: #4a3800; box-shadow: 0 4px 0 var(--sun-dark); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.flat { background: none; box-shadow: none; color: var(--blue); min-height: 40px; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { background: var(--line); color: var(--muted); box-shadow: 0 4px 0 var(--line); pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 3px 0 var(--line); flex: none; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.icon-btn.on { border-color: var(--blue); background: var(--blue-light); }

/* cards */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.card.hero { border-color: var(--green); background: var(--green-light); }
.mascot-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.mascot-row img { width: 72px; height: 72px; flex: none; }
.bubble-say { position: relative; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 10px 14px; font-weight: 700; }
.bubble-say::before { content: ""; position: absolute; left: -9px; bottom: 16px; width: 14px; height: 14px; background: var(--card); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(45deg); }
.kicker { font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--green-dark); }
@media (prefers-color-scheme: dark) { .kicker { color: var(--green); } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.tile { border: 2px solid var(--line); border-radius: 18px; padding: 14px 12px; text-align: left; box-shadow: 0 4px 0 var(--line); background: var(--card); }
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.tile .big { font-size: 26px; } .tile b { display: block; font-size: 16px; font-weight: 900; } .tile span { color: var(--muted); font-size: 13px; }
.tile.due { border-color: var(--sun); box-shadow: 0 4px 0 var(--sun-dark); background: var(--sun-light); }

/* the path */
.stage { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; }
.stage h3 { font-size: 18px; } .stage .muted { font-size: 13px; }
.lesson { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; border: 2px solid var(--line); border-radius: 18px; margin-bottom: 10px; background: var(--card); box-shadow: 0 3px 0 var(--line); }
.lesson:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.lesson.next { border-color: var(--green); box-shadow: 0 3px 0 var(--green); }
.lesson .dot { width: 50px; height: 50px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--bg2); border: 2px solid var(--line); }
.lesson.done .dot { background: var(--sun); border-color: var(--sun-dark); }
.lesson.next .dot { background: var(--green); border-color: var(--green-dark); color: #fff; }
.lesson .t { font-weight: 900; } .lesson .s { font-size: 13px; color: var(--muted); }
.stars { color: var(--sun-dark); letter-spacing: 1px; font-size: 13px; }
.meter { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 4px; }

/* fullscreen lesson */
.fullscreen { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; }
.fs-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
.fs-top .x { font-size: 26px; color: var(--muted); width: 36px; height: 36px; flex: none; }
.prog { flex: 1; height: 14px; border-radius: 8px; background: var(--line); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--green); border-radius: 8px; transition: width .4s; }
.fs-body { flex: 1; overflow-y: auto; padding: 8px 18px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.fs-foot { padding: 12px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }
.fs-foot.good { background: var(--green-light); } .fs-foot.close { background: var(--sun-light); } .fs-foot.bad { background: var(--red-light); }
.verdict { font-weight: 900; font-size: 19px; margin-bottom: 8px; }
.fs-foot.good .verdict { color: var(--green-dark); } .fs-foot.close .verdict { color: var(--sun-dark); } .fs-foot.bad .verdict { color: var(--red-dark); }
@media (prefers-color-scheme: dark) { .fs-foot.good .verdict { color: var(--green); } .fs-foot.close .verdict { color: var(--sun); } }

.phrase-card { text-align: center; padding: 20px 6px; }
.phrase-card .label { margin-bottom: 18px; }
.phrase-card .es { font-size: 32px; font-weight: 900; line-height: 1.2; margin: 6px 0; }
.phrase-card .en { font-size: 19px; color: var(--muted); }
.phrase-card .say { display: inline-block; margin-top: 14px; padding: 6px 14px; border-radius: 12px; background: var(--blue-light); color: var(--blue-dark); font-weight: 800; letter-spacing: .02em; }
@media (prefers-color-scheme: dark) { .phrase-card .say { color: #9fd2ff; } }
.phrase-card .tip { margin-top: 14px; font-size: 15px; color: var(--muted); }
.listen-row { display: flex; justify-content: center; gap: 14px; margin: 20px 0 8px; }
.listen-row .icon-btn { width: 60px; height: 60px; font-size: 26px; border-radius: 18px; }
.heard { min-height: 26px; text-align: center; color: var(--muted); font-style: italic; margin-top: 12px; }

.mic { width: 84px; height: 84px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 34px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 5px 0 var(--blue-dark); flex: none; }
.mic:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--blue-dark); }
.mic.live { background: var(--red); box-shadow: 0 5px 0 var(--red-dark); animation: pulse 1.2s infinite; }
.mic.small { width: 58px; height: 58px; font-size: 24px; }
@keyframes pulse { 0%, 100% { outline: 0 solid rgba(255, 90, 95, .35); } 50% { outline: 10px solid rgba(255, 90, 95, .12); } }
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 18px 0 4px; }
.mic-wrap .hint { font-size: 13px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.msg { max-width: 88%; }
.msg.them { align-self: flex-start; }
.msg.me { align-self: flex-end; text-align: right; }
.msg .b { display: inline-block; text-align: left; padding: 12px 14px; border-radius: 18px; border: 2px solid var(--line); background: var(--card); font-size: 18px; font-weight: 700; }
.msg.me .b { background: var(--blue-light); border-color: var(--blue-light); }
.msg .who { font-size: 12px; color: var(--muted); font-weight: 800; margin: 0 4px 3px; }
.msg .en { font-size: 14px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.msg .tools { display: flex; gap: 6px; margin-top: 6px; }
.msg .tools button { font-size: 13px; font-weight: 800; color: var(--blue); padding: 4px 8px; border-radius: 10px; background: var(--blue-light); }
.fb { margin-top: 6px; font-size: 14px; text-align: left; display: inline-block; padding: 8px 12px; border-radius: 14px; }
.fb.ok { color: var(--green-dark); background: var(--green-light); }
.fb.fix { background: var(--sun-light); }
.fb.fix b { display: block; font-size: 16px; }
@media (prefers-color-scheme: dark) { .fb.ok { color: var(--green); } }
.newword { font-size: 13px; margin-top: 6px; padding: 6px 10px; border-radius: 12px; border: 2px dashed var(--sun); display: inline-block; }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; border-radius: 18px; border: 2px solid var(--line); }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sugg .lbl { width: 100%; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chip { padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); text-align: left; box-shadow: 0 2px 0 var(--line); }
.chip b { display: block; font-size: 15px; } .chip span { font-size: 12px; color: var(--muted); }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.type-row { display: flex; gap: 8px; margin-top: 10px; }
.type-row input { flex: 1; }
.turns { font-size: 13px; color: var(--muted); font-weight: 800; white-space: nowrap; }

/* results */
.result { text-align: center; padding-top: 20px; }
.result img.m { width: 120px; height: 120px; }
.big-stars { font-size: 44px; letter-spacing: 6px; margin: 6px 0; }
.big-stars .off { filter: grayscale(1); opacity: .25; }
.xp-pill { display: inline-block; padding: 8px 16px; border-radius: 14px; background: var(--sun-light); color: #7a5a00; font-weight: 900; margin: 10px 0; }
@media (prefers-color-scheme: dark) { .xp-pill { color: var(--sun); } }
.recap { text-align: left; }
.recap .card p { margin: 4px 0 0; }
.levelup { border-color: var(--blue); background: var(--blue-light); text-align: left; }

/* phrasebook */
.ph { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px solid var(--line); width: 100%; text-align: left; }
.ph:last-child { border-bottom: 0; }
.ph .es { font-weight: 800; } .ph .en { font-size: 14px; color: var(--muted); }
.ph .box { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.seg { display: flex; gap: 6px; background: var(--bg2); padding: 4px; border-radius: 14px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 0 var(--line); }
.levels { display: flex; flex-direction: column; gap: 8px; }
.lvl { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px; border: 2px solid var(--line); border-radius: 16px; width: 100%; }
.lvl.on { border-color: var(--green); background: var(--green-light); }
.lvl .n { width: 32px; height: 32px; border-radius: 50%; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-weight: 900; flex: none; }
.lvl.on .n { background: var(--green); color: #fff; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 22px; height: 22px; flex: none; }
.week { display: flex; gap: 6px; align-items: flex-end; height: 70px; margin-top: 10px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 11px; color: var(--muted); }
.week i { display: block; width: 100%; background: var(--sun); border-radius: 6px 6px 3px 3px; min-height: 3px; }

/* misc */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); background: #2f3a36; color: #fff; padding: 12px 16px; border-radius: 14px; z-index: 100; text-align: center; font-weight: 700; }
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 80; display: flex; align-items: flex-end; }
.sheet-card { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0; padding: 20px 18px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.login { max-width: 360px; margin: 40px auto; text-align: center; }
.login img { width: 110px; }
.err { color: var(--red-dark); font-size: 14px; min-height: 20px; }
@media (max-width: 380px) { .phrase-card .es { font-size: 27px; } .msg .b { font-size: 17px; } .two { gap: 8px; } }
