:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1b2130;
  --muted: #5d6679;
  --border: #dde2ec;
  --accent: #ff6b1a;       /* Dutch orange */
  --accent-2: #21468b;     /* flag blue */
  --accent-soft: #fff0e6;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --bad: #d64545;
  --bad-soft: #fbe7e7;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b;
    --surface: #1a1f2a;
    --surface-2: #232a38;
    --text: #e8ecf4;
    --muted: #9aa4b8;
    --border: #2d3546;
    --accent: #ff8a47;
    --accent-2: #7ea2e6;
    --accent-soft: #3a2518;
    --ok: #4cc987;
    --ok-soft: #173325;
    --bad: #f07272;
    --bad-soft: #3a1f22;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 6px; }
.brand small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.topbar nav a.active, .topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.stats { display: flex; gap: 12px; font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 80px; }

.hero {
  background: linear-gradient(135deg, var(--accent-2), #3a66c4 60%, var(--accent));
  color: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
}
.hero p { margin: 0; opacity: .9; }
.hero .btn { background: #fff; color: var(--accent-2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
a.card:hover { border-color: var(--accent); transform: translateY(-1px); }
a.card { transition: transform .12s, border-color .12s; display: block; }
.unit-head { display: flex; align-items: center; gap: 10px; }
.unit-icon { font-size: 1.8rem; }
.unit-title { font-weight: 700; }
.unit-nl { color: var(--accent); font-size: .9rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.level { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: auto; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.section-title { margin: 28px 0 12px; display: flex; align-items: baseline; gap: 10px; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.blue { background: var(--accent-2); }
.btn.sm { padding: 6px 10px; font-size: .9rem; }
.btn.rec { background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(214,69,69,.2); } }
.icon-btn { border: 0; background: var(--surface-2); border-radius: 999px; width: 36px; height: 36px; flex: none; }
.icon-btn:hover { background: var(--accent-soft); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 20px; border-bottom: 1px solid var(--border); }
.tabs button {
  border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Flashcards */
.flash-wrap { max-width: 520px; margin: 0 auto; text-align: center; }
.flash {
  perspective: 1000px; height: 260px; cursor: pointer; margin-bottom: 16px;
}
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.flash-face.back { transform: rotateY(180deg); background: var(--accent-soft); }
.flash-word { font-size: 2rem; font-weight: 700; }
.flash-ex { color: var(--muted); font-style: italic; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate .again { background: var(--bad); }
.rate .good { background: var(--accent-2); }
.rate .easy { background: var(--ok); }

/* Lists / phrases */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; }
.item .txt { flex: 1; min-width: 0; }
.nl { font-weight: 600; }
.en { color: var(--muted); font-size: .92rem; }
.hide-en .en.toggle { filter: blur(5px); transition: filter .2s; }
.hide-en .en.toggle:hover { filter: none; }

/* Dialogue */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.bubble.me { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bubble .who { font-size: .75rem; font-weight: 700; color: var(--accent-2); }
.bubble.playing { outline: 2px solid var(--accent); }
.bubble.hidden-line .nl { filter: blur(6px); }
.bubble .row { margin-top: 6px; }

/* Quiz */
.quiz { max-width: 620px; margin: 0 auto; }
.q-prompt { font-size: 1.4rem; font-weight: 700; margin: 8px 0 18px; }
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 12px 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); font-weight: 500;
}
.opt:hover:not(:disabled) { border-color: var(--accent-2); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.builder-answer { min-height: 56px; padding: 10px; border: 2px dashed var(--border); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 10px; font-weight: 600; }
.chip:hover { border-color: var(--accent); }
.chip.used { visibility: hidden; }

/* Speaking */
.speak-card { text-align: center; max-width: 620px; margin: 0 auto; }
.speak-target { font-size: 1.5rem; font-weight: 700; margin: 10px 0 4px; }
.heard { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--surface-2); min-height: 48px; }
.w-ok { color: var(--ok); font-weight: 700; }
.w-bad { color: var(--bad); font-weight: 700; text-decoration: underline wavy; }
.score { font-size: 2rem; font-weight: 800; }

.tip { border-left: 4px solid var(--accent); }
.tip h3 { font-size: 1rem; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow);
}
.warn { background: var(--accent-soft); padding: 10px 14px; border-radius: 12px; font-size: .9rem; margin-bottom: 14px; }
label.field { display: block; margin-bottom: 16px; }
label.field span { display: block; font-weight: 600; margin-bottom: 4px; }
select, input[type=range] { width: 100%; max-width: 420px; }
select { padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }



/* ---------- Buddy (Bram) ---------- */
.buddy-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border: 2px solid var(--accent); }
.buddy-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none; font-size: 1.9rem;
  display: grid; place-items: center; background: var(--accent-soft);
}
.buddy-avatar.big { width: 84px; height: 84px; font-size: 2.8rem; margin: 0 auto 12px; }
.buddy-head { display: flex; gap: 14px; align-items: center; }
.buddy-chat { min-height: 40vh; padding-bottom: 12px; }
.bubble.bram { max-width: 88%; }
.bubble .body { line-height: 1.6; }
.nlspan {
  color: var(--accent-2); font-weight: 600; cursor: pointer; border-bottom: 1px dashed currentColor;
}
.nlspan::after { content: " 🔊"; font-size: .75em; }
.nlspan:hover { background: var(--accent-soft); border-radius: 4px; }
.fixbox { margin: 8px 0; padding: 8px 12px; border-radius: 10px; background: var(--ok-soft); border-left: 4px solid var(--ok); }
.wordchip {
  display: inline-block; margin: 6px 6px 0 0; padding: 4px 10px; border-radius: 999px;
  border: 1px dashed var(--accent); background: var(--surface); font-size: .88rem;
}
.wordchip:hover { background: var(--accent-soft); }
.wordchip.saved { border-style: solid; border-color: var(--ok); color: var(--ok); cursor: default; }
.stepdone { margin: 10px 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-weight: 700; }
.typing i {
  display: inline-block; width: 7px; height: 7px; margin-right: 4px; 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; } }
.composer { position: sticky; bottom: 12px; margin-top: 12px; padding: 12px; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; font: inherit; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); max-height: 160px;
}
.composer .quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip.sm { padding: 4px 10px; font-size: .82rem; font-weight: 500; }
.welcome { max-width: 520px; margin: 0 auto; text-align: left; }
.welcome h1, .welcome > p { text-align: center; }
.welcome input {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.welcome select { max-width: none; }
.welcome .btn { width: 100%; justify-content: center; margin-top: 6px; }
pre { background: var(--surface-2); padding: 8px 12px; border-radius: 8px; overflow-x: auto; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- App chrome & mobile ---------- */
.logo { width: 26px; height: 26px; border-radius: 7px; }
.text-input {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
.tabbar { display: none; }
html { -webkit-tap-highlight-color: transparent; }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }

@media (max-width: 720px) {
  body { font-size: 16px; }
  main { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }
  .topbar { padding: max(8px, env(safe-area-inset-top)) 14px 8px; gap: 8px; }
  .topbar .topnav { display: none; }
  .brand small { display: none; }
  .stats { margin-left: auto; gap: 10px; font-size: .95rem; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .7rem; font-weight: 600; color: var(--muted); padding: 4px 0; border-radius: 10px; min-height: 48px;
  }
  .tabbar a span { font-size: 1.35rem; line-height: 1.2; position: relative; }
  .tabbar a.active { color: var(--accent); background: var(--accent-soft); }
  .tabbar .badge { position: absolute; top: -4px; right: -12px; font-style: normal; font-size: .65rem; }

  h1 { font-size: 1.45rem; }
  .hero { padding: 18px; margin-bottom: 14px; }
  .hero .row { width: 100%; }
  .hero .btn { flex: 1; justify-content: center; }
  .grid { gap: 10px; }
  .card { padding: 14px; }
  .section-title { flex-direction: column; gap: 2px; margin: 22px 0 10px; }

  /* Touch-friendly controls */
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; }
  .icon-btn { width: 44px; height: 44px; font-size: 1.05rem; }
  .opt { padding: 14px 16px; }
  .chip { padding: 9px 14px; }
  select, input, textarea { font-size: 16px !important; } /* stops iOS zooming into fields */

  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 12px -14px 16px; padding: 0 14px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; flex: none; }

  .flash { height: 240px; }
  .flash-word { font-size: 1.5rem; }
  .rate .btn { justify-content: center; }
  .speak-target { font-size: 1.25rem; }
  .bubble, .bubble.bram { max-width: 94%; }

  /* Buddy chat: composer docks above the tab bar */
  .buddy-head .buddy-avatar { width: 44px; height: 44px; font-size: 1.5rem; }
  .buddy-card { gap: 12px; }
  .buddy-card .btn { width: 100%; justify-content: center; }
  .composer { bottom: calc(70px + env(safe-area-inset-bottom)); margin: 10px -6px 0; padding: 10px; border-radius: 16px; }
  .composer .quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .composer .quick::-webkit-scrollbar { display: none; }
  .composer .quick .chip { flex: none; }
  .composer .icon-btn.mic { width: 48px; height: 48px; font-size: 1.3rem; }
  .composer .lang { padding: 0 8px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 90vw; text-align: center; }
  #voiceWarn { margin: 10px 14px 0 !important; }
}

/* Installed app (standalone): no browser chrome, so respect the notch everywhere. */
@media (display-mode: standalone) {
  .topbar { position: sticky; }
}

/* Account: Google / LinkedIn sign-in */
.social { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.social:empty { display: none; }
.social-btn { justify-content: center; width: 100%; border: 1px solid var(--border); }
.social .or { text-align: center; margin: 6px 0 4px; }

/* Let's talk: the sentence to say, and pronunciation feedback */
.saybox { margin: 8px 0 2px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); font-weight: 700; }
.bubble.pron { background: var(--bad-soft); }
.pron-words { font-size: 1.1rem; line-height: 1.6; }

/* Azure pronunciation scores */
.pw { font-weight: 700; white-space: nowrap; }
.pw sub { font-size: .65em; font-weight: 600; opacity: .8; margin-left: 1px; }

.pw.name { color: var(--muted); font-weight: 500; }
.composer.listening textarea::placeholder { color: var(--bad); font-weight: 600; }
.composer .icon-btn.mic.rec { animation: pulse 1s infinite; }
.pw.extra { color: var(--muted); font-weight: 400; text-decoration: line-through; opacity: .6; }

/* Word drill, disputes, quiz */
.bubble.drillnote { background: var(--surface-2); }
.dispute-box { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-2); text-decoration: underline; cursor: pointer; }
.dispute-line { margin-top: 4px; }
.qres { margin: 0 0 6px; font-weight: 800; }
.qres.ok { color: var(--ok); }
.qres.bad { color: var(--bad); }
.quiz-score { font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); }

/* Trial banner */
.plan-banner { max-width: 980px; margin: 12px auto 0; padding: 10px 14px; border-radius: 12px; background: var(--ok-soft); font-size: .92rem; }
.plan-banner.ended { background: var(--bad-soft); }
@media (max-width: 720px) { .plan-banner { margin: 10px 14px 0; } }

.legal-links a { color: var(--accent-2); text-decoration: underline; }
.welcome .small a { color: var(--accent-2); text-decoration: underline; }

/* Plans */
.plan-banner a { color: inherit; text-decoration: underline; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.plan-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.plan-card.best { border: 2px solid var(--accent); }
.plan-card h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.plan-card ul { margin: 0; padding-left: 18px; font-size: .9rem; color: var(--muted); }
.plan-card .btn { justify-content: center; }
.plan-price { font-size: 1.6rem; font-weight: 800; margin: 0; }
.plan-price span { font-size: .9rem; font-weight: 500; color: var(--muted); }
@media (max-width: 640px) { .plan-grid { grid-template-columns: 1fr; } }
