/* ============================================================
   ZADANIA MATURALNE CKE — karta zadania (js/matura.js): strona /arkusze i podgląd w panelu edycji
   ============================================================ */
.mt-task {
  background: var(--bg-elevated); border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 1.15rem 1.25rem 1rem; color: var(--text);
  transition: border-color .2s;
}
.mt-task.is-ok { border-color: var(--right); }
.mt-task.is-part { border-color: var(--accent-bright); }
.mt-task.is-bad { border-color: var(--wrong); }
.mt-hd { display: flex; align-items: center; gap: .55rem; margin-bottom: .7rem; }   /* zawsze jedna linijka */
.mt-hd b { white-space: nowrap; }
.mt-hd b { font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif; font-size: 1.05rem; }
.mt-src { white-space: nowrap; min-width: 0; font-size: .78rem; font-weight: 700; color: var(--primary); background: var(--primary-tint); border-radius: 99px; padding: .15rem .6rem; }
.mt-chip { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: .76rem; font-weight: 600; color: var(--text-secondary); background: var(--bg-soft); border-radius: 99px; padding: .15rem .6rem; }
.mt-done { margin-left: auto; font-size: 1rem; line-height: 1; flex-shrink: 0; }
.mt-done.ok { color: var(--right); }
.mt-done.bad { color: var(--wrong); }
.mt-done.seen { color: var(--accent); }
.mt-done:not([hidden]) + .mt-pts { margin-left: 0; }
.mt-pts { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

.mt-txt { line-height: 1.6; overflow-wrap: break-word; }
.mt-txt p { margin: 0 0 .6rem; }
.mt-txt p:last-child { margin-bottom: 0; }
.mt-txt .katex-display { overflow-x: auto; overflow-y: hidden; padding: .15rem 0; }
.mt-scroll { position: relative; padding-bottom: 1.3rem !important; }
.mt-scroll::after { content: "\2190  przesuń w bok  \2192"; position: sticky; left: 0; display: block; width: 100%; text-align: center; margin-top: .3rem;
  font: 600 .72rem 'Inter', 'Inter Fallback', sans-serif; color: var(--text-muted); }
/* długie wyrażenie w zdaniu może przejść do nowej linii po znaku działania */
.mt-txt p .katex, .mt-pf-t .katex, .mt-luka .katex { white-space: normal; }
.mt-wsp { background: var(--bg-soft); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; font-size: .96rem; }
[data-theme="dark"] .mt-wsp { background: rgba(255,255,255,.04); }
.mt-q { margin-bottom: .9rem; }
/* rysunki CKE mają ciemne linie na przezroczystym tle — w trybie ciemnym na jasnej kartce */
.mt-fig { margin: .7rem 0; text-align: center; }
.mt-fig img, .mt-ans-img { max-width: 100%; height: auto; }
[data-theme="dark"] .mt-fig img, [data-theme="dark"] .mt-ans-img { background: #fff; border-radius: 10px; padding: .4rem; }

.mt-hint { margin: 0 0 .5rem; font-size: .85rem; font-weight: 700; color: var(--primary); }
.mt-ans { gap: .6rem; margin-bottom: .2rem; }
.mt-ans.mt-long { grid-template-columns: minmax(0, 1fr); }
.mt-ans:not(.mt-long) { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* kolumny nie rozpychają siatki poza ekran */
@media (max-width: 768px) { .mt-ans:not(.mt-long) { grid-template-columns: minmax(0, 1fr); } }   /* telefon: jedna pod drugą, jak w lekcjach (style.css .answer-grid) */
/* ułamki w odpowiedziach (\frac w linii są drobne): pośredni rozmiar — czytelne, ale wiersz nie rośnie dwa razy */
.mt-ans .katex .mfrac, .mt-opts .katex .mfrac { font-size: 1.3em; }
.mt-ans .ans-card { min-height: 52px; padding: .65rem .9rem; }
.mt-ans .ans-txt { min-width: 0; overflow-wrap: anywhere; }
.mt-ans.mt-measure .ans-txt, .mt-ans.mt-measure .ans-txt * { white-space: nowrap !important; overflow-wrap: normal !important; }   /* pomiar w mtFitAnswers */
/* długi wzór w odpowiedzi może przejść do nowej linii po znaku działania (style.css trzyma wzory w jednej linii) */
.mt-ans .ans-txt .katex { display: inline; white-space: normal; }
.mt-ans .ans-card.dimmed { opacity: .5; }
.mt-luka { margin: .6rem 0 0; color: var(--text-secondary); }
.mt-lacz-w { margin: .55rem 0; font-weight: 700; color: var(--text-secondary); text-align: center; }

/* prawda / fałsz i luki: wiersz = zdanie + przyciski */
.mt-pf { display: flex; flex-direction: column; gap: .5rem; }
.mt-pf-r { display: flex; align-items: center; gap: .8rem; border: 1.5px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
.mt-pf-t { flex: 1; min-width: 0; overflow-wrap: break-word; }
.mt-pf-b { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; flex-shrink: 0; max-width: 55%; }
.mt-chipbtn {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--bg-elevated);
  box-shadow: 0 3px 0 var(--border-strong); color: var(--text-secondary); cursor: pointer;
  font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif; font-weight: 700; font-size: .9rem; transition: all .15s;
}
/* najechanie tylko myszką i tylko na niezaznaczonym — na telefonie „hover” zostaje po dotknięciu i litera znikała na fioletowym tle */
@media (hover: hover) { .mt-chipbtn:hover:not(:disabled):not(.selected):not(.correct):not(.wrong) { border-color: var(--primary); color: var(--primary); } }
.mt-task button { -webkit-tap-highlight-color: transparent; }   /* bez szarej/fioletowej plamy przy dotknięciu na telefonie */
.mt-chipbtn.selected { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-deep); }
.mt-chipbtn.correct { background: var(--right-fill); border-color: var(--right-fill); color: var(--right-on); box-shadow: 0 3px 0 var(--right-deep); }
.mt-chipbtn.wrong { background: var(--wrong-fill); border-color: var(--wrong-fill); color: var(--wrong-on); box-shadow: 0 3px 0 var(--wrong-deep); }
.mt-chipbtn.dimmed { opacity: .45; }
.mt-chipbtn:disabled { cursor: default; }
.mt-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: .35rem .9rem; margin-bottom: .7rem; padding: .7rem .9rem; border-radius: var(--radius); background: var(--bg-soft); }
[data-theme="dark"] .mt-opts { background: rgba(255,255,255,.04); }
.mt-opts-pics { grid-template-columns: repeat(auto-fill, minmax(min(100%, 120px), 1fr)); gap: .6rem; }
.mt-opts-pics figure { margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.mt-opts-pics img { width: 100%; height: auto; background: #fff; border-radius: 8px; }
.mt-opts b { font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif; color: var(--primary); }

/* stopka karty */
.mt-foot { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem .9rem; margin-top: 1rem; }
.mt-foot .btn { padding: .6rem 1.4rem; font-size: .92rem; border-radius: 12px; }
.mt-foot .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.mt-check, .mt-again, .mt-foot:not(.mt-foot-open) .mt-opencheck { margin-left: auto; }   /* z prawej */
/* „Pokaż odpowiedź” i „Sprawdź” / „Jeszcze raz” — ten sam rozmiar */
.mt-foot .mt-showbtn, .mt-foot .mt-solkey, .mt-foot .mt-check, .mt-foot .mt-again, .mt-foot:not(.mt-foot-open) .mt-opencheck {
  box-sizing: border-box; height: 44px; width: 12rem; padding: 0 .8rem; border-radius: 12px; font-size: .92rem; justify-content: center;
}
.mt-foot-open { justify-content: center; }
.mt-foot[hidden], .mt-self[hidden] { display: none; }
.mt-self { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.mt-self-q { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.mt-selfbtn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--bg-elevated); box-shadow: 0 2px 0 var(--border-strong);
  color: var(--text-secondary); font: 700 .85rem 'Space Grotesk', 'Space Grotesk Fallback', sans-serif;
}
.mt-selfbtn.ok:hover, .mt-selfbtn.ok[aria-pressed="true"] { border-color: var(--right); color: var(--right-ink); }
.mt-selfbtn.bad:hover, .mt-selfbtn.bad[aria-pressed="true"] { border-color: var(--wrong); color: var(--wrong-ink); }
.mt-selfbtn.ok[aria-pressed="true"] { background: var(--right-tint); box-shadow: 0 2px 0 var(--right); }
.mt-selfbtn.bad[aria-pressed="true"] { background: var(--wrong-tint); box-shadow: 0 2px 0 var(--wrong); }
.mt-res { display: inline-flex; align-items: center; gap: .4rem; font-weight: 800; font-family: 'Space Grotesk', 'Space Grotesk Fallback', sans-serif; }
.mt-res:empty { display: none; }
.mt-res.ok { color: var(--right-ink); }
.mt-res.part { color: var(--accent); }
.mt-res.bad { color: var(--wrong-ink); }
.mt-solbtn {
  display: inline-flex; align-items: center; gap: .4rem; border: 1.5px solid var(--border); background: none;
  border-radius: 10px; padding: .45rem .8rem; color: var(--text-secondary); font-weight: 700; font-size: .85rem; cursor: pointer;
}
.mt-solbtn:hover, .mt-solbtn.on { border-color: var(--accent-bright); color: var(--accent); }
.mt-solbtn[hidden] { display: none; }
.mt-key { margin-top: .8rem; padding: .7rem 1rem; border-radius: var(--radius); background: var(--right-tint); border: 1.5px solid var(--right); font-size: .95rem; }
.mt-key[hidden] { display: none; }
.mt-key p { margin: 0; }
.mt-key .mt-key-pw { margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--right); font-size: .85rem; font-weight: 600; color: var(--text-secondary); }
.mt-key-pw a { color: var(--accent); font-weight: 800; }
.mt-nosol { color: var(--text-secondary); font-style: italic; }
.mt-sol { margin-top: .8rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--accent-tint); font-size: .95rem; }
[data-theme="dark"] .mt-sol { background: rgba(108,99,245,.07); box-shadow: inset 0 0 0 1px rgba(108,99,245,.2); }   /* fiolet jak rozwiązania w lekcjach */

@media (max-width: 560px) {
  .mt-hd { gap: .4rem; }
  .mt-task { padding: 1rem .9rem .9rem; border-radius: var(--radius); }
  .mt-pf-r { flex-direction: column; align-items: stretch; gap: .5rem; }
  .mt-pf-b { max-width: none; justify-content: flex-start; }
  .mt-foot { column-gap: .5rem; }
  .mt-foot .mt-res { order: 5; flex-basis: 100%; }   /* wynik pod przyciskami */
  .mt-foot .btn { flex: 1; }
  .mt-foot .mt-showbtn, .mt-foot .mt-solkey, .mt-foot .mt-check, .mt-foot .mt-again, .mt-foot:not(.mt-foot-open) .mt-opencheck { flex: none; width: calc(50% - .25rem); padding: 0 .5rem; white-space: nowrap; }
  .mt-foot-open .btn { flex: none; min-width: 11rem; }
}
/* bardzo wąski telefon: nagłówek karty dalej w jednej linijce */
@media (max-width: 400px) {
  .mt-hd b { font-size: .95rem; }
  .mt-src { font-size: .7rem; padding: .12rem .45rem; }
  .mt-pts { font-size: .7rem; }
  .mt-foot .mt-showbtn, .mt-foot .mt-solkey, .mt-foot .mt-check, .mt-foot .mt-again, .mt-foot:not(.mt-foot-open) .mt-opencheck { font-size: .88rem; }
}
/* najwęższe telefony: krótszy napis na przycisku */
.mt-narrow { display: none; }
@media (max-width: 359px) { .mt-wide { display: none; } .mt-narrow { display: inline; } }

/* ===== ZAJAWKA ROZWIĄZANIA BEZ PREMIUM (mtPaywall) ===== */
.mt-pw { position: relative; margin-top: 0; border-radius: 16px; overflow: hidden; }
.mt-pw-fake { display: flex; flex-direction: column; gap: .35rem; padding: .35rem 0 1.2rem; filter: blur(3px); opacity: .7; user-select: none; pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 25%, transparent 95%); mask-image: linear-gradient(180deg, #000 25%, transparent 95%); }
.mt-pw-fake b { font-weight: 700; color: var(--text); }
.mt-pw-fake em { font: italic 1.2rem "Times New Roman", serif; color: var(--text); margin-bottom: .5rem; }
.mt-pw-box { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; padding: .8rem;
  background: radial-gradient(ellipse 60% 55% at 50% 55%, var(--pw-bg) 40%, transparent 100%); }
.mt-pw { --pw-bg: var(--accent-tint); }
[data-theme="dark"] .mt-pw { --pw-bg: #1C1D36; }
.mt-pw-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); }
.mt-pw-box b { font: 700 .95rem 'Space Grotesk', 'Space Grotesk Fallback', sans-serif; color: var(--text); }
.mt-pw-box > span:not(.mt-pw-ic) { font-size: .8rem; color: var(--text-muted); }
.mt-pw-btn { margin-top: .35rem; padding: .5rem 1rem; font-size: .88rem; }
.mt-pw { min-height: 190px; }
