/* Matura27 mobile v2: pełny interfejs mobilny oparty na istniejących ekranach i routingu. */
@media (max-width: 900px) {
  :root { --m2-bg: #111019; --m2-panel: #1b1925; --m2-line: rgba(255,255,255,.09); --m2-muted: rgba(255,255,255,.62); }
  html, body { width:100%; height:100%; min-height:100%; overflow:hidden; }
  body { padding:0 !important; background:#111019 !important; }
  #app { position:fixed; inset:0; display:block !important; padding:0 !important; height:100dvh !important; min-height:0; overflow:hidden; }
  #main { position:absolute; inset:0; display:flex !important; flex-direction:column; gap:0 !important; width:100%; height:100%; min-height:0; padding:calc(env(safe-area-inset-top) + 8px) 15px calc(88px + env(safe-area-inset-bottom)) !important; overflow:hidden; }
  #gorny { min-height:52px; flex:0 0 auto; display:flex; align-items:center; gap:11px; padding:0 0 10px !important; }
  #menu-btn { width:42px !important; height:42px !important; min-width:42px; border-radius:14px !important; background:rgba(255,255,255,.08) !important; }
  #tytul { min-width:0; flex:1; padding:0 !important; font-size:clamp(20px,5.5vw,25px) !important; line-height:1.15; font-weight:750; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  #gra-pill { display:flex !important; flex:0 1 auto; width:auto; max-width:42%; margin:0 0 0 auto !important; padding:7px 10px !important; gap:8px !important; border-radius:13px !important; overflow:hidden; white-space:nowrap; }
  #gra-pill .p { min-width:0; flex:0 1 auto; }
  #gra-pill .p:not(:first-child) { display:none !important; }
  #gra-pill .xpbar { width:55px !important; }
  #tresc { flex:1 1 auto; min-height:0; width:100%; overflow-x:hidden !important; overflow-y:auto !important; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; padding:3px 0 24px !important; }
  #tresc > .wejscie { min-height:100%; }
  #tresc .karta { padding:16px !important; border-radius:17px !important; margin-bottom:11px; }
  #tresc .karta h2 { font-size:17px !important; line-height:1.3; }
  #tresc .karta h3 { font-size:14px !important; }
  #tresc .siatka { gap:10px !important; }
  #tresc .siatka.s4 { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  #tresc .siatka.s3, #tresc .siatka.s32 { grid-template-columns:minmax(0,1fr) !important; }
  #tresc .kafel { padding:13px !important; border-radius:14px !important; }
  #tresc .kafel .w { font-size:25px !important; }
  #tresc .wiersz { gap:8px; }
  #tresc button, #tresc .chip, #tresc .seg button, #tresc .check { min-height:42px; }
  #tresc input:not([type=checkbox]):not([type=radio]):not([type=range]), #tresc select, #tresc textarea { min-height:44px; font-size:16px !important; }
  #boczny { position:fixed !important; z-index:1002 !important; top:0; bottom:0; left:0; width:min(340px,88vw) !important; max-width:360px; padding:calc(env(safe-area-inset-top) + 18px) 15px calc(env(safe-area-inset-bottom) + 18px) !important; overflow-y:auto; transform:translate3d(-105%,0,0); transition:transform .24s ease; border-radius:0 22px 22px 0 !important; }
  body.menu-otwarte #boczny { transform:translate3d(0,0,0); box-shadow:18px 0 50px rgba(0,0,0,.5); }
  body.menu-otwarte::after { content:""; position:fixed; inset:0; z-index:1001; background:rgba(0,0,0,.58); -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); }
  #boczny .logo { margin:4px 0 20px; }
  #boczny .nav { gap:4px; overflow-y:auto; }
  #boczny .nav button { min-height:46px; padding:11px 13px; border-radius:13px; font-size:14px; }
  #boczny .nav-sekcja { padding:14px 12px 5px; font-size:10px; letter-spacing:.12em; opacity:.65; text-transform:uppercase; }
  #menu-btn { display:inline-flex !important; }
  .m2-tabs { position:fixed; z-index:1000; left:12px; right:12px; bottom:calc(7px + env(safe-area-inset-bottom)); display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px; padding:6px; border:1px solid rgba(255,255,255,.12); border-radius:20px; background:rgba(25,23,34,.97); box-shadow:0 10px 35px rgba(0,0,0,.35); }
  .m2-tabs button { appearance:none; border:0; min-width:0; min-height:54px; padding:5px 2px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; border-radius:14px; background:transparent; color:rgba(255,255,255,.62); font:600 10.5px/1.1 system-ui,sans-serif; }
  .m2-tabs button.is-active { color:#fff; background:rgba(167,139,250,.22); }
  .m2-icon { display:block; width:22px; height:22px; flex:0 0 auto; }
  .m2-quiz-overlay { position:fixed; inset:0; z-index:1100; display:flex; align-items:flex-end; justify-content:center; padding:12px 10px calc(10px + env(safe-area-inset-bottom)); background:rgba(0,0,0,.62); opacity:0; visibility:hidden; transition:opacity .2s,visibility .2s; }
  .m2-quiz-overlay.is-open { opacity:1; visibility:visible; }
  .m2-quiz-sheet { width:min(620px,100%); max-height:min(82dvh,760px); display:flex; flex-direction:column; gap:14px; padding:21px 17px 15px; border:1px solid rgba(255,255,255,.12); border-radius:24px; background:#191722; box-shadow:0 20px 70px rgba(0,0,0,.5); transform:translateY(18px); transition:transform .22s ease; }
  .m2-quiz-overlay.is-open .m2-quiz-sheet { transform:translateY(0); }
  .m2-quiz-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
  .m2-eyebrow { color:#b6a2ff; font-size:10px; font-weight:750; letter-spacing:.13em; }
  .m2-quiz-head h2 { margin:5px 0 3px; font-size:22px; line-height:1.2; }
  .m2-quiz-head p { margin:0; color:var(--m2-muted); font-size:12px; line-height:1.4; }
  .m2-close { width:38px; height:38px; display:grid; place-items:center; border:1px solid var(--m2-line); border-radius:12px; background:rgba(255,255,255,.06); color:#fff; }
  .m2-close .m2-icon { width:19px; height:19px; }
  .m2-search { min-height:46px; display:flex; align-items:center; gap:10px; padding:0 13px; border:1px solid var(--m2-line); border-radius:13px; background:rgba(255,255,255,.055); color:var(--m2-muted); }
  .m2-search .m2-icon { width:19px; height:19px; }
  .m2-search input { width:100%; min-width:0; border:0; outline:0; background:transparent; color:#fff; font:inherit; font-size:16px !important; }
  .m2-subjects { display:grid; grid-template-columns:1fr; gap:7px; overflow-y:auto; overscroll-behavior:contain; padding-bottom:4px; }
  .m2-subject { width:100%; min-height:54px; display:flex; align-items:center; gap:12px; padding:9px 12px; border:1px solid var(--m2-line); border-radius:14px; background:rgba(255,255,255,.045); color:#fff; text-align:left; }
  .m2-subject:active { background:rgba(167,139,250,.2); }
  .m2-subject-icon { width:34px; height:34px; flex:0 0 34px; display:grid; place-items:center; border-radius:10px; background:rgba(167,139,250,.13); color:#c7b8ff; }
  .m2-subject-icon svg { width:21px; height:21px; }
  .m2-subject-name { min-width:0; flex:1; font-size:13px; font-weight:650; }
  .m2-arrow { color:var(--m2-muted); font-size:23px; }
  .m2-empty { padding:18px 8px; color:var(--m2-muted); text-align:center; }
  body.m2-overlay-open { overflow:hidden; }
  #toasty { bottom:calc(78px + env(safe-area-inset-bottom)) !important; }
  .modal { z-index:1200 !important; }
  #widok-zad { min-height:100% !important; height:auto !important; overflow:visible !important; }
  #widok-zad > .panel-zad, #widok-zad > .lg.panel-zad { width:100%; min-width:0; }
  #z-papier { max-height:54dvh; overflow:auto; -webkit-overflow-scrolling:touch; }
  .tab-wrap { height:32dvh; min-height:200px; max-height:380px; }
  .cke-kartka { font-size:15px; line-height:1.5; overflow-wrap:anywhere; }
  .lg-tab-wrap, .tab-scroll, .tabela-wrap { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
}
@media (max-width:380px) {
  #main { padding-left:11px !important; padding-right:11px !important; }
  .m2-tabs { left:7px; right:7px; }
  .m2-tabs button { font-size:9.5px; }
}
@media (min-width:901px) { #m2-tabs, #m2-quiz { display:none !important; } }
/* ===== Dolny pasek jak w iOS: przyklejony do krawędzi, pod spodem przewija się treść (rozmycie) ===== */
@media (max-width:900px) {
  #main { padding-bottom:0 !important; }
  #tresc { padding-bottom:calc(86px + min(env(safe-area-inset-bottom), 34px)) !important; scroll-padding-bottom:90px; }
  .m2-tabs { left:0 !important; right:0 !important; bottom:0 !important; border:0 !important; border-radius:0 !important;
    border-top:1px solid rgba(255,255,255,.08) !important; gap:0 !important;
    padding:6px 6px max(8px, min(env(safe-area-inset-bottom), 30px)) !important;
    background:rgba(16,15,22,.72) !important; -webkit-backdrop-filter:blur(22px) saturate(1.7); backdrop-filter:blur(22px) saturate(1.7);
    box-shadow:none !important; }
  .m2-tabs button { min-height:50px !important; border-radius:12px !important; background:transparent !important; font-size:10.5px !important;
    color:rgba(255,255,255,.5) !important; transition:color .15s, transform .12s cubic-bezier(.2,1.3,.4,1); }
  .m2-tabs button:active { transform:scale(.92); }
  .m2-tabs button.is-active { color:var(--akcent, #a78bfa) !important; }
  .m2-tabs button.is-active .m2-icon { filter:drop-shadow(0 0 6px color-mix(in srgb, var(--akcent, #a78bfa) 55%, transparent)); }
  #toasty { bottom:calc(76px + min(env(safe-area-inset-bottom), 34px)) !important; }
  /* Kreator (powitanie + quiz poziomu): #app ma tu display:block !important, więc display:none z app.js nie działa –
     kreator dostaje własne, pełne tło i leży NAD wszystkim (pulpit nie prześwituje) */
  #kreator-host { z-index:1150 !important; background:#0e0c16; overflow-y:auto; -webkit-overflow-scrolling:touch;
    padding:calc(env(safe-area-inset-top) + 10px) 0 calc(env(safe-area-inset-bottom) + 10px); }
  body:has(#kreator-host) #app, body:has(#kreator-host) .m2-tabs { visibility:hidden !important; }
  #kreator-host .kreator { height:auto; min-height:100%; }
  #kreator-host .kreator > .lg { width:calc(100% - 20px); max-height:none; padding:22px 18px;
    background:rgba(30,26,44,.92) !important; }
  #kreator-host .kreator h1 { font-size:26px; }
  #kreator-host .siatka { grid-template-columns:1fr !important; }
}
