/* ---------- tokens ---------- */
:root {
  --bg: #f8f5ef;
  --surface: #ffffff;
  --surface-2: #f1ede5;
  --text: #1f1c18;
  --muted: #6c655c;
  --line: #e3ddd2;
  --primary: #c8102e;          /* Polish red */
  --primary-ink: #ffffff;
  --primary-soft: #fbe5e8;
  --ok: #1d7f47;
  --ok-soft: #e1f3e8;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --warn: #8a5a00;
  --warn-soft: #fdf0d5;
  --locked: #b9b2a7;
  --trail: #d6cfc2;
  --star: #e0a100;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 28, 24, .06), 0 4px 14px rgba(31, 28, 24, .06);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161412;
    --surface: #211e1b;
    --surface-2: #2a2622;
    --text: #f1ece4;
    --muted: #a69e93;
    --line: #38332d;
    --primary: #ff5a6e;
    --primary-ink: #1a0005;
    --primary-soft: #3a1a20;
    --ok: #5fd08f;
    --ok-soft: #173525;
    --bad: #ff7b72;
    --bad-soft: #3d1b19;
    --warn: #f3c15b;
    --warn-soft: #3a2d10;
    --locked: #5a544d;
    --trail: #3d3731;
    --star: #f3c15b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161412; --surface: #211e1b; --surface-2: #2a2622; --text: #f1ece4; --muted: #a69e93;
  --line: #38332d; --primary: #ff5a6e; --primary-ink: #1a0005; --primary-soft: #3a1a20;
  --ok: #5fd08f; --ok-soft: #173525; --bad: #ff7b72; --bad-soft: #3d1b19; --warn: #f3c15b;
  --warn-soft: #3a2d10; --locked: #5a544d; --trail: #3d3731; --star: #f3c15b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--font);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

.page { max-width: 680px; margin: 0 auto; padding: 8px 16px 120px; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 680px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; min-width: 0; }
.brand-name { min-width: 0; line-height: 1.2; }
.brand-logo {
  width: 34px; height: 44px; flex: none; border-radius: 5px;
  box-shadow: 0 1px 3px rgba(31, 28, 24, .18);
}
.lang-switch { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 999px; }
.lang-switch a {
  text-decoration: none; font-size: .8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: var(--muted);
}
.lang-switch a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- menu ---------- */
.menu { position: relative; }
.menu-toggle { list-style: none; color: var(--text); }
.menu-toggle::-webkit-details-marker { display: none; }
.menu-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu[open] .menu-toggle { border-color: var(--muted); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  display: flex; flex-direction: column; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
/* Signed in: the menu button becomes an account pill (avatar initial, email from 560px). */
.account-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 4px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.account-toggle:hover { border-color: var(--muted); }
.account-avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--primary); color: var(--primary-ink); font-size: .9rem; font-weight: 700;
}
.account-email {
  display: none; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .85rem; font-weight: 500;
}
@media (min-width: 560px) { .account-email { display: inline; } }
.menu-list a { text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.menu-list a:hover { background: var(--surface-2); }
.menu-list a[aria-current] { color: var(--primary); font-weight: 700; }

/* ---------- text pages (terms, contact) ---------- */
.prose { max-width: 62ch; }
.prose h2 { font-size: 1.1rem; margin-top: 28px; }
.prose p { line-height: 1.6; }
.contact-email { font-size: 1.15rem; font-weight: 700; color: var(--primary); overflow-wrap: anywhere; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none;
  font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { border-color: var(--primary); filter: brightness(1.05); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn-quiet { background: transparent; box-shadow: none; }
.btn-wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.05rem; flex: none;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn-big { width: 52px; height: 52px; font-size: 1.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 6px 0 0; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: .92rem;
}

.notice {
  background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-size: .92rem;
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 20px; box-shadow: var(--shadow); margin-top: 12px;
}
.big-emoji { font-size: 3rem; margin: 0 0 .2em; }

/* ---------- map ---------- */
.map-intro { padding: 8px 0 4px; }
.hero {
  display: block; width: 100%; height: auto; margin: 0 0 20px;
  border-radius: var(--radius); box-shadow: var(--shadow); background: #5aa6e8;
}
.unit { margin-top: 28px; }
.unit-header {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  padding: 10px 0 8px; border-bottom: 1px solid var(--line);
}
.unit-header h2 { margin: 0; }
.unit-label {
  margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary);
}
.unit-sub { margin: 0; color: var(--muted); font-size: .92rem; }
.unit.is-locked-unit .unit-label { color: var(--muted); }

.trail { position: relative; margin: 0 auto; }
.trail-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trail-line path { fill: none; stroke: var(--trail); stroke-width: 10; stroke-linecap: round; }

.stop {
  position: absolute; transform: translate(-50%, -32px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 140px; text-decoration: none; text-align: center;
  scroll-margin: 120px;
}
.stop-dot {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--locked); color: var(--locked);
  font-weight: 700; font-size: 1.2rem; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.stop:hover .stop-dot { transform: scale(1.06); }
.stop-label {
  display: flex; flex-direction: column; padding: 2px 8px; border-radius: 8px; background: var(--bg);
  font-size: .82rem; line-height: 1.25;
}
.stop-title { font-weight: 700; }
.stop-state { color: var(--muted); font-size: .76rem; white-space: nowrap; }

.stop.is-locked .stop-title { color: var(--muted); }
.stop.is-soon .stop-dot { border-style: dashed; }
.stop.is-available .stop-dot { border-color: var(--primary); color: var(--primary); }
.stop.is-passed .stop-dot { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.stop.is-passed .stop-state { color: var(--star); font-weight: 700; }
.stop.is-current .stop-dot {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
  animation: pulse 2s ease-out infinite;
}
.stop.is-current .stop-state { color: var(--primary); font-weight: 700; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 16px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .stop.is-current .stop-dot { animation: none; }
  .stop-dot { transition: none; }
}

.map-footer { display: flex; justify-content: center; margin-top: 40px; }

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 24px; max-width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- level: learn ---------- */
body.is-testing .crumbs, body.is-testing .level-header { display: none; }
.crumbs { margin: 4px 0 12px; font-size: .92rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.level-header { margin-bottom: 20px; }
.section-title { margin-top: 24px; }

.notes { display: grid; gap: 12px; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.note p:last-child { margin-bottom: 0; }

.cards { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.card-emoji { font-size: 1.9rem; width: 44px; text-align: center; flex: none; }
.card-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.card-pl { font-weight: 700; font-size: 1.15rem; }
.card-tr { color: var(--muted); font-size: .95rem; }
.card-audio { display: flex; gap: 6px; }
.cards-compact { text-align: left; }

.sticky-action {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.sticky-action .btn { display: flex; max-width: 648px; margin: 0 auto; }

/* ---------- level: test ---------- */
.test-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.progress { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }
.progress-count { font-size: .85rem; color: var(--muted); white-space: nowrap; }

.q-label { color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.prompt { display: flex; align-items: center; gap: 14px; margin: 4px 0 20px; flex-wrap: wrap; }
.prompt-pl { font-size: 2rem; font-weight: 700; }
.prompt-tr { font-size: 1.6rem; font-weight: 700; }
.prompt-emoji { font-size: 2.4rem; }
.prompt-listen { justify-content: center; padding: 12px 0; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 14px;
  text-align: left; border-radius: 12px; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 1.05rem; box-shadow: var(--shadow);
}
.option:hover:not(:disabled) { border-color: var(--muted); }
.option:disabled { cursor: default; }
.option-key {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 6px;
  border: 1px solid var(--line); color: var(--muted); font-size: .75rem;
}
.option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.option.is-matched { border-color: var(--ok); background: var(--ok-soft); opacity: .7; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.match .option { justify-content: center; text-align: center; font-size: .98rem; }

.type-input {
  width: 100%; min-height: 56px; padding: 12px 16px; font: inherit; font-size: 1.3rem;
  border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--text);
}
.type-input:focus { outline: none; border-color: var(--primary); }
.type-input.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.type-input.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.accent-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.key {
  min-width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; font-size: 1.15rem;
}
.key:hover { border-color: var(--muted); }

.feedback { margin-top: 18px; padding: 14px 16px; border-radius: 12px; }
.feedback p:last-child { margin-bottom: 0; }
.feedback-title { font-weight: 700; }
.feedback.is-correct { background: var(--ok-soft); color: var(--ok); }
.feedback.is-wrong { background: var(--bad-soft); color: var(--bad); }
.feedback.is-warn { background: var(--warn-soft); color: var(--warn); }
.feedback-answer { color: var(--text); }

/* ---------- level: result ---------- */
.stars { font-size: 2.2rem; color: var(--star); letter-spacing: .1em; margin: 0; }
.result-score { font-size: 1.3rem; font-weight: 700; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }

/* ---------- share & follow (Facebook blue is the brand colour, same in both themes) ---------- */
.share { margin: 20px auto 0; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius); max-width: 480px; }
.share-label { margin: 0 0 10px; font-weight: 700; }
.share-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; min-width: 40px;
  padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.share-btn:hover { border-color: var(--muted); }
.share-btn-fb, .fb-follow { background: #1877f2; border-color: #1877f2; color: #fff; }
.share-btn-fb:hover, .fb-follow:hover { background: #166fe0; border-color: #166fe0; }
.share-btn[data-copied] { border-color: var(--ok); color: var(--ok); }
/* Header "Follow us": a round icon on phones, a labelled pill from 560px. */
.fb-follow {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid #1877f2;
  font-size: .85rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.fb-follow-label { display: none; }

@media (min-width: 560px) {
  .options { grid-template-columns: 1fr 1fr; }
  .fb-follow { width: auto; padding: 0 14px; }
  .fb-follow-label { display: inline; }
  .stop { width: 170px; }
}

/* ---------- account menu & flash messages ---------- */
.menu-account { margin: 0; padding: 8px 12px; font-size: .9rem; line-height: 1.35; overflow-wrap: anywhere; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; width: auto; }
.menu-button {
  width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px;
  background: none; font-weight: 500; cursor: pointer;
}
.menu-button:hover { background: var(--surface-2); }
.flash-messages { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.flash { border-radius: 10px; padding: 10px 14px; font-size: .92rem; background: var(--surface-2); }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }
.flash-error { background: var(--bad-soft); color: var(--bad); }

/* ---------- sign-in pages (django-allauth) ---------- */
.auth-page .page { max-width: 480px; }
.auth-panel { padding: 28px 20px 24px; }
.auth-panel h1 { font-size: 1.6rem; }
.auth-panel h2 { font-size: 1rem; color: var(--muted); font-weight: 500; text-align: center; margin-top: 4px; }
.auth-panel a:not(.btn) { color: var(--primary); }
.auth-form { display: grid; gap: 14px; margin-top: 16px; }
.auth-field { display: grid; gap: 6px; margin: 0; }
.auth-field label { font-weight: 700; font-size: .95rem; }
.auth-field input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
}
.auth-field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-field.has-error input { border-color: var(--bad); }
.auth-check { display: flex; align-items: flex-start; gap: 8px; }
.auth-check label { font-weight: 500; }
.auth-check input { width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.auth-help { display: block; color: var(--muted); font-size: .85rem; }
.auth-help ul { margin: 4px 0 0; padding-left: 18px; }
.auth-error { color: var(--bad); font-size: .9rem; margin: 0; }
p.auth-error { background: var(--bad-soft); border-radius: 10px; padding: 10px 14px; }
.auth-actions, .auth-buttons { display: grid; gap: 10px; }
.auth-panel > .auth-actions { margin-top: 20px; }
.auth-sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0 10px; }
.auth-providers { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.provider-btn { color: var(--text); }
.delete-list { margin: 0 0 14px; padding-left: 22px; }
.delete-list li { margin-bottom: 4px; }
.auth-panel .notice { margin-top: 4px; }
