/* M22 Staff — mobile-first. Duże cele dotykowe, bo obsługa idzie w biegu,
   często jedną ręką i w rękawiczce. */

:root {
    /* Apka ma jeden, jasny motyw. Bez tej deklaracji przeglądarka na telefonie
       z ciemnym motywem systemu sama przemalowuje kolory i załoga widzi coś
       innego niż projektowaliśmy — łącznie z czerwienią M22. */
    color-scheme: only light;

    --tlo: #f4f4f5;
    --karta: #ffffff;
    --tekst: #16161a;
    --tekst-slaby: #6b6b76;
    --linia: #e3e3e8;
    --akcent: #c8102e;
    --akcent-ciemny: #a00d25;
    --ciemny: #161616;
    --ok: #1f7a3f;
    --ostrzezenie: #b4531a;
    --promien: 14px;
    --pasek-h: 56px;
    --nawigacja-h: 62px;
    --dol: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--tlo);
    color: var(--tekst);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

/* ── Powłoka ─────────────────────────────────────────────────────────── */

.pasek {
    position: fixed; top: 0; left: 0; right: 0; height: var(--pasek-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    background: var(--ciemny); color: #fff;
    z-index: 30;
}
.pasek-tytul { font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.pasek-profil {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--akcent); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; text-decoration: none; text-transform: uppercase;
}

.tresc {
    padding: calc(var(--pasek-h) + 12px) 12px calc(var(--nawigacja-h) + var(--dol) + 20px);
    max-width: 780px; margin: 0 auto;
}

.nawigacja {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--nawigacja-h) + var(--dol));
    padding-bottom: var(--dol);
    display: flex;
    background: var(--karta);
    border-top: 1px solid var(--linia);
    z-index: 30;
}
.nawigacja a {
    flex: 1; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--tekst-slaby); text-decoration: none;
    font-size: 11px; font-weight: 600;
}
.nawigacja a.akt { color: var(--akcent); }
.nawigacja .ikona { font-size: 19px; line-height: 1; }
.kropka {
    position: absolute; top: 8px; right: 50%; margin-right: -18px;
    width: 9px; height: 9px; border-radius: 50%; background: var(--akcent);
}

/* ── Elementy wspólne ────────────────────────────────────────────────── */

.sekcja { margin-bottom: 18px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 46px; padding: 0 18px;
    border: 1px solid var(--linia); border-radius: var(--promien);
    background: var(--karta); color: var(--tekst);
    font-size: 15px; font-weight: 600; font-family: inherit;
    text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn-glowny { background: var(--akcent); border-color: var(--akcent); color: #fff; }
.btn-ostrzegawczy { color: var(--akcent); border-color: #f0c7ce; }
.btn-blok { display: flex; width: 100%; margin-top: 10px; }
.btn-tekst {
    background: none; border: none; padding: 12px 4px;
    color: var(--tekst-slaby); font-size: 15px; font-weight: 600;
    font-family: inherit; cursor: pointer;
}
.btn-ikona {
    display: grid; place-items: center;
    width: 44px; height: 44px; flex: 0 0 44px;
    border: none; border-radius: 50%;
    background: #efeff2; color: var(--tekst);
    font-size: 19px; cursor: pointer;
}
.btn-wyslij { background: var(--akcent); color: #fff; }
.para-przyciskow { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

label { display: block; margin: 14px 0 5px; font-size: 13px; font-weight: 650; color: var(--tekst-slaby); }
input[type=text], input[type=tel], input[type=password], input[type=color], select, textarea {
    width: 100%; min-height: 46px; padding: 11px 13px;
    border: 1px solid var(--linia); border-radius: 11px;
    background: #fff; color: var(--tekst);
    font-size: 16px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akcent); outline-offset: -1px; }
input[type=color] { padding: 4px; height: 46px; }

.karta-form {
    background: var(--karta); border: 1px solid var(--linia); border-radius: var(--promien);
    padding: 16px; margin-top: 12px;
}
.karta-form h2, .karta-form h3 { margin: 0 0 4px; font-size: 17px; }

.pola-wyboru { border: none; padding: 0; margin: 14px 0 0; }
.pola-wyboru legend { font-size: 13px; font-weight: 650; color: var(--tekst-slaby); padding: 0; }
.pole-wyboru { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; font-size: 15px; color: var(--tekst); font-weight: 500; }
.pole-wyboru input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: var(--akcent); }

.podpowiedz { color: var(--tekst-slaby); font-size: 13px; margin: 8px 0 0; }
.blad { background: #fdeaed; color: #8c0c22; padding: 11px 13px; border-radius: 11px; font-size: 14px; margin: 0 0 12px; }
.info { background: #eef4ff; color: #1c3d7a; padding: 11px 13px; border-radius: 11px; font-size: 14px; margin: 0 0 12px; }
.plakietka {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    background: #efeff2; color: var(--tekst-slaby);
    border-radius: 20px; font-size: 11px; font-weight: 700; vertical-align: middle;
}
.nieaktywna { opacity: .55; }

.pusto { text-align: center; padding: 44px 18px; color: var(--tekst-slaby); }
.pusto-kod { font-size: 40px; font-weight: 800; color: var(--linia); }
.pusto-male { text-align: center; color: var(--tekst-slaby); padding: 28px 12px; font-size: 14px; }
.srodek { text-align: center; }
.wstecz-link { display: inline-block; margin-bottom: 10px; color: var(--tekst-slaby); text-decoration: none; font-weight: 600; font-size: 14px; }

.komunikat {
    position: fixed; left: 12px; right: 12px; bottom: calc(var(--nawigacja-h) + var(--dol) + 12px);
    background: var(--ciemny); color: #fff;
    padding: 12px 15px; border-radius: 12px;
    font-size: 14px; text-align: center; z-index: 60;
}
.komunikat.blad-ton { background: var(--akcent); }

/* ── Ekran logowania ─────────────────────────────────────────────────── */

.ekran-wejscia { background: var(--ciemny); min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.wejscie { width: 100%; max-width: 380px; background: var(--karta); border-radius: 18px; padding: 26px 22px 22px; }
.wejscie-logo { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 16px; }
.wejscie-h1 { font-size: 18px; margin: 0 0 12px; }
.wejscie .btn-glowny { width: 100%; margin-top: 20px; }

/* ── Lista kanałów ───────────────────────────────────────────────────── */

.kanal, .osoba, .lokal, .kanal-wiersz {
    display: flex; align-items: center; gap: 12px;
    background: var(--karta); border: 1px solid var(--linia);
    border-radius: var(--promien); padding: 12px 14px; margin-bottom: 8px;
    text-decoration: none; color: var(--tekst);
}
.kanal-ikona, .osoba-awatar {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 17px; text-transform: uppercase;
}
.osoba-awatar { background: var(--ciemny); border-radius: 50%; }
.kanal-tekst, .osoba-tekst, .lokal-tekst { min-width: 0; flex: 1; }
.kanal-nazwa, .osoba-imie, .lokal-nazwa { font-weight: 650; font-size: 15px; }
.kanal-opis, .osoba-opis, .lokal-opis {
    color: var(--tekst-slaby); font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.licznik {
    min-width: 23px; height: 23px; padding: 0 7px;
    background: var(--akcent); color: #fff; border-radius: 12px;
    display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.stawka { font-size: 13px; font-weight: 700; color: var(--tekst-slaby); white-space: nowrap; }
.lokal-kolor { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; }

/* ── Ogłoszenia do potwierdzenia ─────────────────────────────────────── */

.do-potwierdzenia { margin-bottom: 18px; }
.do-potwierdzenia h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--tekst-slaby); margin: 0 0 8px; }
.ack-karta {
    background: #fffaf0; border: 1px solid #f2d9a8; border-left: 4px solid #e0a13c;
    border-radius: var(--promien); padding: 13px 15px; margin-bottom: 8px;
}
.ack-gdzie { font-size: 12px; color: var(--tekst-slaby); font-weight: 600; }
.ack-tresc { margin: 6px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ack-akcje { display: flex; align-items: center; gap: 10px; }
.ack-akcje .btn { min-height: 40px; }

/* ── Kanał ───────────────────────────────────────────────────────────── */

.kanal-widok { display: flex; flex-direction: column; min-height: calc(100vh - var(--pasek-h) - var(--nawigacja-h) - var(--dol) - 32px); }
.kanal-naglowek { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wstecz { font-size: 22px; text-decoration: none; color: var(--tekst); padding: 4px 6px; }
.kanal-naglowek-nazwa { font-weight: 700; font-size: 17px; }
.kanal-naglowek-typ { font-size: 12px; color: var(--tekst-slaby); }

.strumien { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }

.wiadomosc {
    background: var(--karta); border: 1px solid var(--linia);
    border-radius: var(--promien); padding: 11px 13px;
    max-width: 88%; align-self: flex-start;
}
.wiadomosc.moja { align-self: flex-end; background: #eef5ff; border-color: #d6e4fb; }
.wiadomosc.ogloszenie { background: #fffaf0; border-color: #f2d9a8; border-left: 4px solid #e0a13c; max-width: 100%; align-self: stretch; }
.w-glowa { display: flex; align-items: baseline; gap: 7px; font-size: 12px; color: var(--tekst-slaby); margin-bottom: 3px; }
.w-autor { font-weight: 700; color: var(--tekst); }
.w-tresc { white-space: pre-wrap; overflow-wrap: anywhere; }
.w-zdjecia { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.w-zdjecia img { max-width: 100%; width: 200px; border-radius: 10px; display: block; background: #efeff2; }
.w-stopka { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.w-stopka .btn { min-height: 36px; font-size: 13px; padding: 0 13px; }
.w-potwierdzone { color: var(--ok); font-size: 13px; font-weight: 650; }
.w-usun { background: none; border: none; color: var(--tekst-slaby); font-size: 12px; cursor: pointer; font-family: inherit; padding: 4px; }

/* ── Pisanie ─────────────────────────────────────────────────────────── */

.pisanie {
    position: sticky; bottom: 0;
    background: var(--tlo); padding-top: 8px;
    border-top: 1px solid var(--linia); margin-top: 8px;
}
.pisanie-wiersz { display: flex; align-items: flex-end; gap: 8px; }
.pisanie textarea {
    flex: 1; min-height: 44px; max-height: 140px; resize: none;
    border-radius: 22px; padding: 11px 15px; line-height: 1.35;
}
.opcje-ogloszenia { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.przelacznik { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 13px; font-weight: 600; color: var(--tekst-slaby); }
.przelacznik input { width: 20px; height: 20px; accent-color: var(--akcent); }
.podglad-zalacznikow { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.podglad-zalacznikow figure { position: relative; margin: 0; }
.podglad-zalacznikow img { width: 62px; height: 62px; object-fit: cover; border-radius: 10px; display: block; }
.podglad-zalacznikow button {
    position: absolute; top: -6px; right: -6px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: var(--ciemny); color: #fff;
    font-size: 13px; line-height: 1; cursor: pointer;
}
.tylko-odczyt { text-align: center; color: var(--tekst-slaby); font-size: 13px; padding: 14px; }

/* ── Hasło startowe i okno odczytów ──────────────────────────────────── */

.karta-sukces { background: #eefaf1; border: 1px solid #bfe6cc; border-radius: var(--promien); padding: 15px; margin-top: 12px; }
.haslo-box {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 20px; font-weight: 700; letter-spacing: .02em;
    background: #fff; border: 1px dashed #9ed3b1; border-radius: 10px;
    padding: 13px; text-align: center; margin: 10px 0; user-select: all;
}
.okno { border: none; border-radius: 16px; padding: 20px; max-width: 400px; width: calc(100% - 32px); }
.okno::backdrop { background: rgba(0,0,0,.45); }
.okno h3 { margin: 0 0 12px; font-size: 17px; }
.odczyt-grupa { margin-bottom: 14px; }
.odczyt-grupa h4 { margin: 0 0 6px; font-size: 13px; color: var(--tekst-slaby); text-transform: uppercase; letter-spacing: .03em; }
.odczyt-osoba { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--linia); font-size: 14px; }
.odczyt-osoba span { color: var(--tekst-slaby); font-size: 12px; }

.dane-konta { margin-top: 14px; }
.dane-konta div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--linia); font-size: 14px; }
.dane-konta span { color: var(--tekst-slaby); }

/* ── Desktop: grafik i zarządzanie wymagają większego ekranu ──────────── */

@media (min-width: 820px) {
    .tresc { padding-left: 20px; padding-right: 20px; }
    .lista-kanalow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .lista-kanalow .kanal { margin-bottom: 0; }
    .wiadomosc { max-width: 70%; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
