/* ==========================================================
   Klasa — arkusz stylów
   Bez CDN, bez kroku budowania. Aplikacja działa offline,
   łącznie z krojem pisma serwowanym z własnego katalogu.
   ========================================================== */

/* Anonymous Pro (c) 2009 Mark Simonson, licencja SIL Open Font License 1.1.
   Zakresy latin i latin-ext — polskie znaki diakrytyczne leżą w latin-ext. */

@font-face {
  font-family: 'Anonymous Pro';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/anonymous-pro-400-italic-latin-ext.c43b8213c110.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/anonymous-pro-400-italic-latin.4d7d1c9a85b3.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/anonymous-pro-400-normal-latin-ext.2222969d9833.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/anonymous-pro-400-normal-latin.6a4b179c40ed.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/anonymous-pro-700-italic-latin-ext.9610f6a4a89d.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/anonymous-pro-700-italic-latin.99cd8393665e.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/anonymous-pro-700-normal-latin-ext.9c4d83bc16a1.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Anonymous Pro';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/anonymous-pro-700-normal-latin.9a6d2abbdaf2.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


:root {
  --top-h: 52px;
  --tint-50:  #eef4fb;
  --tint-100: #d8e6f5;
  --tint-500: #2f6fb0;
  --tint-600: #265d95;
  --tint-700: #1d4a77;

  --ink-900: #14202e;
  --ink-700: #33465c;
  --ink-500: #5d7489;
  --ink-300: #9fb1c2;
  --ink-100: #dde5ed;
  --ink-50:  #f2f6fa;
  --surface: #ffffff;
  --canvas:  #f6f8fb;

  --ok-bg:   #e6f4ec;  --ok-fg:   #1d6b42;  --ok-line: #9dd4b5;
  --warn-bg: #fdf3e0;  --warn-fg: #8a5a12;  --warn-line: #eccb8c;
  --bad-bg:  #fceceb;  --bad-fg:  #a32b23;  --bad-line: #eeb0ac;
  --info-bg: var(--tint-50); --info-fg: var(--tint-700); --info-line: var(--tint-100);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 32, 46, .06), 0 4px 12px rgba(20, 32, 46, .05);
  --gap: 1rem;
  --tap: 44px;

  --font: 'Anonymous Pro', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tint-50:  #16273a;
    --tint-100: #1e3a55;
    --tint-500: #5697d6;
    --tint-600: #6faae2;
    --tint-700: #9cc6ee;

    --ink-900: #e8eef5;
    --ink-700: #c2cede;
    --ink-500: #93a4b8;
    --ink-300: #4a5b6f;
    --ink-100: #2a3846;
    --ink-50:  #1d2836;
    --surface: #161f2b;
    --canvas:  #0f1620;

    --ok-bg:   #143024;  --ok-fg:   #6ed99f;  --ok-line: #256b45;
    --warn-bg: #362713;  --warn-fg: #e8b866;  --warn-line: #6d5223;
    --bad-bg:  #3a1a19;  --bad-fg:  #f09a93;  --bad-line: #7a3630;
    --info-bg: var(--tint-50); --info-fg: var(--tint-700); --info-line: var(--tint-100);

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
  }

  .qr { background: #fff; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-900);
  background: var(--canvas);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0 0 .75rem; }

a { color: var(--tint-600); }
a:hover { color: var(--tint-700); }

:focus-visible {
  outline: 3px solid var(--tint-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.muted { color: var(--ink-500); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* Kwoty: cyfry o stałej szerokości, żeby kolumny się zgadzały w pionie */
.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.money--big { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.money--plus { color: var(--ok-fg); }
.money--minus { color: var(--bad-fg); }

/* ---------- Szkielet strony ---------- */

.skip-link {
  position: absolute; left: -9999px;
  background: var(--tint-600); color: #fff;
  padding: .75rem 1rem; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; top: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }

.page-head {
  display: flex; gap: .75rem; flex-wrap: wrap;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-head p { margin: 0; }

.footer {
  max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem;
  color: var(--ink-500); font-size: .82rem;
  border-top: 1px solid var(--ink-100);
}

/* ---------- Karty ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.card__head h2, .card__head h3 { margin: 0; }

.grid { display: grid; gap: var(--gap); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: 1fr; }
@media (min-width: 780px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Kafelki z liczbami ---------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-left: 4px solid var(--tint-500);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.stat--ok   { border-left-color: var(--ok-fg); }
.stat--bad  { border-left-color: var(--bad-fg); }
.stat--warn { border-left-color: var(--warn-fg); }
.stat__label {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-500); font-weight: 600; margin-bottom: .2rem;
}
.stat__value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__hint { font-size: .8rem; color: var(--ink-500); }

/* ---------- Przyciski ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-100);
  background: var(--surface); color: var(--ink-900);
  font: inherit; font-size: .93rem; font-weight: 550;
  text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--ink-50); }
.btn--primary { background: var(--tint-600); border-color: var(--tint-600); color: #fff; }
.btn--primary:hover { background: var(--tint-700); border-color: var(--tint-700); color: #fff; }
.btn--danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad-fg); }
.btn--danger:hover { background: var(--bad-bg); }
.btn--ghost { background: none; border-color: transparent; color: var(--tint-600); }
.btn--ghost:hover { background: var(--tint-50); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 .6rem; font-size: .84rem; }

/* ---------- Formularze ---------- */

.field { margin-bottom: 1rem; }
.field__label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field__req { color: var(--bad-fg); }
.field__help { font-size: .82rem; color: var(--ink-500); margin-top: .3rem; }
.field__error { font-size: .85rem; color: var(--bad-fg); margin-top: .3rem; font-weight: 500; }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .55rem .7rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-900);
  font: inherit; font-size: 1rem;
}
textarea { min-height: 5rem; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--tint-500); }
.input--code {
  font-size: 1.6rem; letter-spacing: .5em; text-align: center;
  font-variant-numeric: tabular-nums; padding-left: .5em;
}
input[type="checkbox"] { width: auto; min-height: auto; }

.form-actions {
  display: flex; gap: .5rem; flex-wrap: wrap;
  margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--ink-100);
}

.form-errors {
  background: var(--bad-bg); border: 1px solid var(--bad-line); color: var(--bad-fg);
  border-radius: var(--radius-sm); padding: .7rem .9rem; margin-bottom: 1rem;
}
.form-errors ul { margin: 0; padding-left: 1.1rem; }

/* ---------- Komunikaty ---------- */

.alert {
  border: 1px solid var(--info-line); background: var(--info-bg); color: var(--info-fg);
  border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: .6rem;
}
.alert--success { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-fg); }
.alert--warning { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); }
.alert--error   { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-fg); }
.alert p:last-child { margin-bottom: 0; }

.note {
  border-left: 3px solid var(--tint-500);
  background: var(--tint-50);
  padding: .75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem;
  color: var(--ink-700);
}
.note strong { color: var(--ink-900); }

/* ---------- Odznaki ---------- */

.badge {
  display: inline-block; padding: .15rem .55rem;
  border-radius: 999px; font-size: .76rem; font-weight: 650;
  border: 1px solid var(--ink-100); background: var(--ink-50); color: var(--ink-700);
  white-space: nowrap;
}
.badge--ok   { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-line); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.badge--bad  { background: var(--bad-bg);  color: var(--bad-fg);  border-color: var(--bad-line); }
.badge--info { background: var(--tint-50); color: var(--tint-700); border-color: var(--tint-100); }

/* ---------- Tabele ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.1rem; padding: 0 1.1rem; }

.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid var(--ink-100); }
.table th {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-500); font-weight: 650; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--ink-50); }
.table td.right, .table th.right { text-align: right; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--ink-100); border-bottom: 0; padding-top: .7rem; }

/* Na wąskich ekranach tabela zmienia się w listę kart z etykietami z data-label */
@media (max-width: 640px) {
  .table--cards thead { position: absolute; left: -9999px; }
  .table--cards tbody tr {
    display: block; margin-bottom: .6rem; padding: .7rem;
    border: 1px solid var(--ink-100); border-radius: var(--radius-sm); background: var(--surface);
  }
  .table--cards tbody tr:hover { background: var(--surface); }
  .table--cards td {
    display: flex; justify-content: space-between; gap: 1rem;
    border: 0; padding: .25rem 0; text-align: right;
  }
  .table--cards td::before {
    content: attr(data-label);
    font-size: .78rem; font-weight: 650; color: var(--ink-500);
    text-align: left; flex: 0 0 auto;
  }
  .table--cards tfoot td { border-top: 1px solid var(--ink-100); }

  /* W układzie kart etykietę wiersza podsumowania niesie data-label,
     więc osobna komórka z napisem "Razem" dublowałaby tekst. */
  .table--cards tfoot .tfoot-label { display: none; }

  .nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  /* Wygaszenie prawej krawędzi sygnalizuje, że pasek przewija się dalej. */
  .nav.grow {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
  }
  .topbar__inner { gap: .5rem; padding: .5rem .75rem; }
}

/* ---------- Pasek postępu ---------- */

.progress {
  height: 9px; background: var(--ink-100);
  border-radius: 999px; overflow: hidden; margin: .4rem 0;
}
.progress__bar { height: 100%; background: var(--tint-500); border-radius: 999px; transition: width .3s ease; }
.progress__bar--full { background: var(--ok-fg); }
.progress__bar--low  { background: var(--warn-fg); }

/* ---------- Stan pusty ---------- */

.empty-state {
  text-align: center; padding: 2.25rem 1rem;
  color: var(--ink-500); border: 1px dashed var(--ink-300);
  border-radius: var(--radius); background: var(--ink-50);
}
.empty-state h3 { color: var(--ink-700); margin-bottom: .3rem; }
.empty-state p { margin-bottom: 1rem; }

/* ---------- Paragony ---------- */

.receipts { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.receipt {
  border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface); display: flex; flex-direction: column;
}
.receipt__thumb {
  display: block; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--ink-50); display: flex; align-items: center; justify-content: center;
}
.receipt__thumb img { width: 100%; height: 100%; object-fit: cover; }
.receipt__icon { font-size: 2rem; color: var(--ink-300); font-weight: 700; }
.receipt__meta { padding: .5rem .6rem; font-size: .78rem; color: var(--ink-500); }
.receipt__name {
  color: var(--ink-900); font-weight: 600; font-size: .84rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.receipt__hash { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .7rem; }

/* ---------- Ekrany logowania ---------- */

.auth { max-width: 26rem; margin: 3rem auto; padding: 0 1rem; }
.auth__card {
  background: var(--surface); border: 1px solid var(--ink-100);
  border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow);
}
.auth__brand { text-align: center; margin-bottom: 1.25rem; }
.auth__brand h1 { font-size: 1.3rem; margin-bottom: .2rem; }
.auth__alt { text-align: center; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--ink-100); font-size: .88rem; }

.qr {
  display: block; width: 210px; height: 210px; margin: 1rem auto;
  padding: .6rem; background: #fff; border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
}
.secret-key {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--ink-50); border: 1px solid var(--ink-100);
  padding: .55rem .7rem; border-radius: var(--radius-sm);
  word-break: break-all; font-size: .85rem; text-align: center;
}

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { counter-increment: step; position: relative; padding-left: 2rem; margin-bottom: .5rem; font-size: .92rem; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: .05rem;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--tint-500); color: #fff;
  font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Paginacja ---------- */

.pagination { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination__info { color: var(--ink-500); font-size: .87rem; padding: 0 .5rem; }

/* ---------- Dziennik zdarzeń ---------- */

.changes { margin: .3rem 0 0; font-size: .8rem; color: var(--ink-500); }
.changes li { margin-bottom: .1rem; }
.changes del { color: var(--bad-fg); text-decoration: line-through; }
.changes ins { color: var(--ok-fg); text-decoration: none; }

/* ---------- Ruch ---------- */

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

/* ---------- Druk (rozliczenie na zebranie z rodzicami) ---------- */

@media print {
  .topbar, .footer, .form-actions, .btn, .no-print, .pagination { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .card, .stat { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  .table { font-size: 10pt; }
  .table th { color: #000; }
  a { text-decoration: none; color: #000; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
}

/* ---------- Odznaka licznikowa (nieprzeczytane) ---------- */

.pill {
  display: inline-block; min-width: 1.35rem; padding: .05rem .4rem;
  border-radius: 999px; background: var(--bad-fg); color: #fff;
  font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.35;
}

/* ---------- Wybór w głosowaniu ---------- */

.choices { display: grid; gap: .5rem; margin: .75rem 0; }
.choice {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); padding: .5rem .8rem;
  border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.choice:hover { background: var(--ink-50); border-color: var(--tint-500); }
.choice input { width: auto; min-height: auto; margin: 0; accent-color: var(--tint-600); }
.choice:has(input:checked) { border-color: var(--tint-500); background: var(--tint-50); }

/* ==========================================================
   Czat — układ dwukolumnowy z paskiem kanałów
   ========================================================== */

:root {
  --chat-side-bg: #1f2b3a;
  --chat-side-fg: #c7d3e0;
  --chat-side-dim: #8496a8;
  --chat-side-active: #2f6fb0;
  --chat-side-hover: #2a394b;
}

body.is-chat main { max-width: none; padding: 0; }
body.is-chat .footer { display: none; }
body.is-chat .shell { min-height: 100dvh; }

.chat {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  /* Wiersz siatki domyślnie rośnie do treści i przebija jawną wysokość kontenera.
     minmax(0, 1fr) pozwala mu się skurczyć, dzięki czemu kolumny przewijają się
     wewnętrznie zamiast rozpychać czat. */
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
  height: 100dvh;
}

/* ---------- Pasek boczny ---------- */

.chat__sidebar {
  background: var(--chat-side-bg);
  color: var(--chat-side-fg);
  display: flex; flex-direction: column;
  overflow-y: auto;
  /* Element siatki ma domyślnie min-height: auto i nie skurczy się poniżej swojej
     treści — bez tego długa lista kontaktów rozpycha cały kontener czatu. */
  min-height: 0;
}

.chat__sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.chat__workspace { font-weight: 700; color: #fff; font-size: .98rem; }
.chat__add {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255, 255, 255, .12);
  color: #fff; text-decoration: none; font-size: 1.1rem; line-height: 1;
}
.chat__add:hover { background: rgba(255, 255, 255, .22); color: #fff; }

.chat__channels { padding: .6rem 0 1rem; }
.chat__section {
  padding: .35rem 1rem; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--chat-side-dim);
}

.chat__channel {
  display: flex; align-items: center; gap: .1rem;
  padding: .38rem 1rem; min-height: 34px;
  color: var(--chat-side-fg); text-decoration: none;
  font-size: .92rem;
}
.chat__channel:hover { background: var(--chat-side-hover); color: #fff; }
.chat__channel.is-active { background: var(--chat-side-active); color: #fff; font-weight: 600; }
.chat__channel.has-unread { color: #fff; font-weight: 700; }
.chat__channel.is-archived { opacity: .55; }
.chat__channel-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat__channel .pill { flex: 0 0 auto; }

.chat__hash { opacity: .65; margin-right: .3rem; font-weight: 400; }
.chat__empty-side { padding: .5rem 1rem; color: var(--chat-side-dim); font-size: .85rem; }

/* ---------- Kolumna główna ---------- */

.chat__main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.chat__header {
  padding-inline: 1.25rem;
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--ink-100);
  background: var(--surface);
}
.chat__tolist {
  display: none; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; flex: 0 0 2.2rem;
  border-radius: var(--radius-sm); color: var(--ink-700); text-decoration: none;
}
.chat__tolist:hover { background: var(--ink-50); }

.chat__title {
  font-size: 1.05rem; margin: 0;
  display: flex; align-items: center; gap: .5rem;
}
.chat__topic { margin: .1rem 0 0; font-size: .84rem; color: var(--ink-500); }

.chat__thread {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  scroll-behavior: smooth;
}

/* ---------- Separator dnia ---------- */

.chat__day {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.1rem 0 .8rem;
  color: var(--ink-500); font-size: .78rem; font-weight: 600;
}
.chat__day::before, .chat__day::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--ink-100);
}
.chat__day span {
  padding: .1rem .7rem; border: 1px solid var(--ink-100);
  border-radius: 999px; background: var(--surface);
}

/* ---------- Wiadomość ---------- */

.chat__msg {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: .6rem;
  padding: .3rem .5rem .3rem .3rem;
  border-radius: var(--radius-sm);
}
.chat__msg:hover { background: var(--ink-50); }
.chat__msg--continued { margin-top: -.1rem; }

.chat__avatar {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: #fff;
  user-select: none;
}
.chat__avatar--0 { background: #2f6fb0; }
.chat__avatar--1 { background: #1d6b42; }
.chat__avatar--2 { background: #8a5a12; }
.chat__avatar--3 { background: #a32b23; }
.chat__avatar--4 { background: #5b4b8a; }
.chat__avatar--5 { background: #16706e; }
.chat__avatar--6 { background: #99512b; }
.chat__avatar--7 { background: #43536b; }

.chat__avatar-slot { width: 36px; display: flex; justify-content: flex-end; align-items: flex-start; }
.chat__hover-time {
  font-size: .68rem; color: var(--ink-500);
  opacity: 0; transition: opacity .1s ease; padding-top: .2rem;
}
.chat__msg:hover .chat__hover-time { opacity: 1; }

.chat__msg-body { min-width: 0; }
.chat__msg-head {
  display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap;
  margin-bottom: .05rem;
}
.chat__author { font-weight: 700; font-size: .93rem; }
.chat__time { font-size: .74rem; color: var(--ink-500); }
.chat__edited { font-size: .74rem; color: var(--ink-500); }

.chat__text { overflow-wrap: anywhere; font-size: .95rem; line-height: 1.5; }
.chat__text--deleted { color: var(--ink-500); font-style: italic; font-size: .88rem; }

/* ---------- Akcje przy wiadomości ---------- */

.chat__actions {
  position: absolute; top: -.5rem; right: .5rem;
  display: flex; gap: .15rem;
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .1s ease;
}
.chat__msg:hover .chat__actions,
.chat__msg:focus-within .chat__actions { opacity: 1; pointer-events: auto; }

.chat__action {
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .78rem; color: var(--ink-700);
  padding: .25rem .5rem; border-radius: 4px; text-decoration: none;
  display: inline-block;
}
.chat__action:hover { background: var(--ink-50); color: var(--ink-900); }

/* Na urządzeniach dotykowych hover nie istnieje — akcje muszą być stale widoczne. */
@media (hover: none) {
  .chat__actions {
    opacity: 1; pointer-events: auto;
    position: static; box-shadow: none; border: 0; background: none;
    /* Bez wskazania kolumny akcje wpadają do 36-pikselowej kolumny awatara
       i łamią etykiety na pojedyncze litery. */
    grid-column: 2;
    margin-top: .3rem; padding: 0; gap: .4rem;
  }
  .chat__action {
    border: 1px solid var(--ink-100); border-radius: 999px;
    padding: .2rem .6rem; background: var(--surface);
  }
}

/* ---------- Pole pisania ---------- */

.chat__composer {
  padding-inline: 1.25rem;
  flex: 0 0 auto;
  border-top: 1px solid var(--ink-100);
  padding: .8rem 1.1rem 1rem;
  background: var(--surface);
}
.chat__composer-box {
  display: flex; gap: .5rem; align-items: flex-end;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  padding: .4rem .4rem .4rem .6rem;
  background: var(--surface);
}
.chat__composer-box:focus-within { border-color: var(--tint-500); }
.chat__input {
  flex: 1 1 auto; border: 0; outline: none; resize: vertical;
  background: none; color: var(--ink-900);
  font: inherit; font-size: .95rem; min-height: 2.6rem; padding: .2rem 0;
  width: 100%; min-width: 0;
}
.chat__hint { margin: .5rem 0 0; font-size: .76rem; color: var(--ink-500); }
.chat__composer--locked {
  flex: 0 0 auto;
  border-top: 1px solid var(--ink-100);
  padding: 1rem 1.1rem; color: var(--ink-500); font-size: .88rem;
  background: var(--ink-50);
}

/* ---------- Ekran powitalny i przegląd kanałów ---------- */

.chat__welcome { padding: 2rem 0; max-width: 34rem; }
.chat__welcome h2 { font-size: 1.35rem; }

.chat__overview { display: grid; gap: .6rem; }
.chat__card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  padding: .75rem .9rem; background: var(--surface);
}
.chat__card:hover { border-color: var(--tint-500); background: var(--ink-50); color: inherit; }
.chat__card.is-archived { opacity: .7; }
.chat__preview { font-size: .85rem; color: var(--ink-700); margin-top: .35rem; }

/* ---------- Wąskie ekrany: pasek kanałów nad wątkiem ---------- */

@media (max-width: 760px) {
  .chat {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100dvh - var(--top-h) - var(--bar-h, 54px)
                 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  /* Czat sam odlicza wysokość dolnego paska, więc dodatkowy odstęp powłoki
     dawał 20 px przewijania całej strony i drugi pasek przewijania obok wątku. */
  body.is-chat.has-rail .shell { padding-bottom: 0; min-height: 0; }

  /* Na telefonie lista rozmów i sama rozmowa to dwa osobne ekrany — tak działają
     komunikatory. Ściskanie obu naraz zostawiało wątkowi 390 px z 844 px okna. */
  .chat { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }

  .chat--list .chat__main { display: none; }
  .chat--list .chat__sidebar { max-height: none; border-radius: 0; }

  .chat--room .chat__sidebar { display: none; }

  /* W otwartej rozmowie dolny pasek ustępuje miejsca treści: wyjście prowadzi
     strzałką do listy, a reszta menu jest pod burgerem u góry. */
  body.is-room .siderail { display: none; }
  body.is-room .chat {
    height: calc(100dvh - var(--top-h)
                 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .chat__sidebar { flex-direction: column; }
  .chat__sidebar-head { padding: .7rem .9rem; }
  .chat__channel { min-height: 46px; padding-inline: .9rem; }
  .chat__channel-name { max-width: none; overflow: visible; }
  .chat__contact { min-height: 52px; padding-block: .45rem; }
  .chat__contact + .chat__contact { border-top: 1px solid rgba(255, 255, 255, .05); }

  /* Pasek przewijania na telefonie zabiera szerokość i wygląda obco */
  .chat__sidebar { scrollbar-width: none; }
  .chat__sidebar::-webkit-scrollbar { display: none; }

  /* Przy dłuższej nazwie kanału pełna etykieta przycisku łamała nagłówek */
  .chat__header .btn--sm { padding-inline: .55rem; }

  /* Akcje pod wiadomością w jednej linii — wąskie kolumny łamały napisy pionowo */
  .chat__actions { flex-wrap: nowrap; gap: .5rem; }
  .chat__action { white-space: nowrap; }
  .chat__header .btn-label-long { display: none; }

  /* Powrót do listy widoczny tylko na wąskim ekranie */
  .chat__tolist { display: inline-flex; }

  .chat__header { padding: .6rem .8rem; gap: .6rem; }
  .chat__title { font-size: .98rem; }
  .chat__topic { display: none; }

  .chat__thread { padding: .7rem .8rem; }
  .chat__msg { padding-left: 2.6rem; }
  .chat__avatar { width: 2rem; height: 2rem; font-size: .68rem; }

  /* Pole pisania zajmowało 199 px — teraz jedna linia z przyciskiem obok */
  .chat__composer { padding: .5rem .6rem calc(.5rem + env(safe-area-inset-bottom, 0px)); }
  .chat__composer-box { flex-direction: row; align-items: flex-end; gap: .4rem; padding: .35rem; }
  .chat__composer-box textarea { min-height: 40px; max-height: 96px; resize: none; }
  .chat__composer-box .btn { width: auto; flex: 0 0 auto; padding-inline: .9rem; }
  .chat__hint { display: none; }
}

/* ---------- Jabłuszko statusu (dostępny / niedostępny) ---------- */

.apple { display: inline-flex; align-items: center; flex: 0 0 auto; line-height: 0; }
.apple svg { width: var(--apple-size, 21px); height: var(--apple-size, 21px); display: block; }

.chat__contact .apple { --apple-size: 23px; }
.chat__title .apple { --apple-size: 30px; }
.siderail__status .apple { --apple-size: 22px; }

.menu-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.mobiletop, .menu-backdrop { display: none; }

.chat__status { padding: .5rem .75rem; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.chat__status-btn {
  display: flex; align-items: center; gap: .45rem; width: 100%;
  background: rgba(255, 255, 255, .06); border: 0; cursor: pointer;
  color: var(--chat-side-fg); font: inherit; font-size: .84rem;
  padding: .4rem .6rem; border-radius: var(--radius-sm); min-height: 34px;
}
.chat__status-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

.chat__channel--muted { color: var(--chat-side-dim); font-style: italic; }
.chat__channel--muted:hover { color: #fff; font-style: normal; }

/* ---------- Lista osób w klasie ---------- */

.chat__overview-head {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-500); margin: 1.4rem 0 .6rem;
}
.chat__overview-head:first-child { margin-top: 0; }

.roster { display: grid; gap: .3rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.roster__item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .7rem; min-height: var(--tap);
  border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  background: var(--surface); text-decoration: none; color: inherit;
}
.roster__item:hover { border-color: var(--tint-500); background: var(--ink-50); color: inherit; }
.roster__name { display: flex; flex-direction: column; font-size: .9rem; min-width: 0; }
.roster__role { font-size: .74rem; color: var(--ink-500); }

/* ---------- Karta głosowania w wątku ---------- */

.pollcard {
  border: 1px solid var(--ink-100); border-left: 3px solid var(--tint-500);
  border-radius: var(--radius-sm); padding: .7rem .85rem;
  background: var(--surface); margin-top: .2rem; max-width: 34rem;
}
.pollcard__head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.pollcard__tag {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--tint-700);
  background: var(--tint-50); border-radius: 999px; padding: .1rem .5rem;
}
.pollcard__title { font-weight: 650; font-size: .96rem; }
.pollcard__desc { font-size: .86rem; color: var(--ink-700); margin: .35rem 0 .1rem; }
.pollcard__options { display: grid; gap: .35rem; margin: .6rem 0; }
.pollcard__options .choice { min-height: 36px; padding: .35rem .6rem; }
.pollcard__results { display: grid; gap: .5rem; margin: .6rem 0 .2rem; }
.pollcard__foot {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .6rem; font-size: .78rem;
}

/* ==========================================================
   Szyna boczna — menu główne po lewej
   ========================================================== */

:root {
  --rail-w: 13.5rem;
  --rail-bg: #1f2b3a;
  --rail-fg: #c7d3e0;
  --rail-dim: #8496a8;
  --rail-hover: #2a394b;
  --rail-active: #2f6fb0;
}

.has-rail .shell { margin-left: var(--rail-w); }

.siderail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w); z-index: 30;
  background: var(--rail-bg); color: var(--rail-fg);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.siderail__brand {
  display: flex; flex-direction: column; gap: .1rem;
  padding: 1rem 1.1rem .9rem;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.siderail__brand-name { font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: -.01em; }
.siderail__brand-class { font-size: .75rem; color: var(--rail-dim); }

.siderail__list { list-style: none; margin: .6rem 0; padding: 0; flex: 1 1 auto; }

.siderail__list a,
.siderail__bell,
.siderail__me,
.siderail__logout,
.siderail__status button {
  display: flex; align-items: center; gap: .65rem;
  width: 100%; min-height: var(--tap);
  padding: .45rem 1.1rem;
  color: var(--rail-fg); text-decoration: none;
  font: inherit; font-size: .9rem;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.siderail__list a:hover,
.siderail__bell:hover,
.siderail__me:hover,
.siderail__logout:hover,
.siderail__status button:hover { background: var(--rail-hover); color: #fff; }

.siderail__list a[aria-current="page"],
.siderail__bell.is-active,
.siderail__me.is-active {
  background: var(--rail-active); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, .55);
}

.ico { width: 20px; height: 20px; flex: 0 0 20px; }
.siderail__list a span:not(.pill),
.siderail__bell span:not(.pill),
.siderail__me span,
.siderail__logout span,
.siderail__status span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.siderail__me em { font-style: normal; font-size: .7rem; color: var(--rail-dim); }
.siderail__me.is-active em { color: rgba(255, 255, 255, .8); }

.siderail__foot { border-top: 1px solid rgba(255, 255, 255, .09); padding: .4rem 0 .6rem; }
.siderail__status button { font-size: .84rem; }
.siderail__logout { color: var(--rail-dim); }

/* Wąska szyna: same ikony, etykiety poza polem widzenia ale dostępne dla czytnika */
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --rail-w: 3.75rem; }
  .siderail__brand-class,
  .siderail__list a span:not(.pill),
  .siderail__bell span:not(.pill),
  .siderail__me span,
  .siderail__logout span,
  .siderail__status span { position: absolute; left: -9999px; }
  .siderail__brand { align-items: center; padding: 1rem .5rem; }
  .siderail__brand-name { font-size: .8rem; }
  .siderail__list a,
  .siderail__bell,
  .siderail__me,
  .siderail__logout,
  .siderail__status button { justify-content: center; padding: .45rem .5rem; }
  .siderail__list a[aria-current="page"] { box-shadow: inset 3px 0 0 rgba(255, 255, 255, .55); }
}

/* Telefon: szyna staje się dolnym paskiem. Sześć pozycji dzieli szerokość po równo —
   przewijany pasek nawigacji na dole to pułapka, bo nie widać, że coś jeszcze jest. */
@media (max-width: 760px) {
  .has-rail .shell {
    margin-left: 0;
    padding-top: calc(var(--top-h) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px));
  }

  .siderail {
    inset: auto 0 0 0; width: auto; height: auto;
    flex-direction: row; overflow: hidden;
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .siderail__brand { display: none; }
  .siderail__list { display: flex; margin: 0; flex: 1 1 auto; }
  .siderail__list li { position: relative; flex: 1 1 0; display: flex; min-width: 0; }

  /* Na pasku zostają cztery pozycje. Dwunastu ikon nie da się zmieścić w 375 px —
     przy takiej liczbie część z nich dostawała zerową szerokość i przestawała
     być klikalna. Reszta chowa się pod przyciskiem „Więcej”. */
  .siderail__list li:not(.is-primary) { display: none; }

  .siderail__foot { display: flex; border-top: 0; padding: 0; }
  .siderail__status,
  .siderail__me,
  .siderail__foot form:last-child { display: none; }

  .siderail__list a,
  .siderail__bell,
  .siderail__me {
    flex-direction: column; gap: .12rem;
    padding: .5rem .2rem; width: 100%; min-width: 0;
    font-size: .6rem; letter-spacing: -.02em; justify-content: center;
  }
  .siderail__me { min-width: 4rem; }
  .siderail__list a span:not(.pill),
  .siderail__bell span:not(.pill),
  .siderail__me span { text-align: center; }
  .siderail__list a[aria-current="page"],
  .siderail__bell.is-active,
  .siderail__me.is-active {
    background: transparent; color: #fff;
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .8);
  }
  .menu-toggle:checked ~ .siderail .siderail__list a[aria-current="page"] {
    background: var(--rail-active); box-shadow: none;
  }

  /* ---- Górny pasek z burgerem ---- */

  .mobiletop {
    display: flex; align-items: center; gap: .6rem;
    position: fixed; inset: 0 0 auto 0; z-index: 42;
    height: var(--top-h); padding: 0 .3rem 0 .9rem;
    background: var(--rail-bg); color: var(--rail-fg);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .mobiletop__brand {
    display: flex; align-items: center; gap: .5rem;
    color: inherit; text-decoration: none; flex: 1 1 auto; min-width: 0;
  }
  .mobiletop__brand .logo { width: 26px; flex: 0 0 26px; }
  .mobiletop__name { font-weight: 700; font-size: .98rem; }
  .mobiletop__class { font-size: .72rem; opacity: .6; }

  .burger {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .18rem; width: 3.2rem; min-height: var(--top-h); cursor: pointer;
    color: inherit; font-size: .58rem; letter-spacing: .02em;
  }
  .burger__box { display: flex; flex-direction: column; gap: 4px; width: 20px; }
  .burger__box i {
    display: block; height: 2px; background: currentColor; border-radius: 2px;
    transition: transform .16s ease, opacity .16s ease;
  }
  .menu-toggle:checked ~ .mobiletop .burger__box i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .menu-toggle:checked ~ .mobiletop .burger__box i:nth-child(2) { opacity: 0; }
  .menu-toggle:checked ~ .mobiletop .burger__box i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .menu-toggle:checked ~ .mobiletop .burger__label::after { content: " "; }
  .menu-toggle:focus-visible ~ .mobiletop .burger { outline: 2px solid #fff; outline-offset: -3px; }

  /* ---- Panel otwierany burgerem ---- */

  .menu-toggle:checked ~ .siderail {
    /* Panel musi znaleźć się nad przyciemnieniem (39), inaczej jest przez nie
       przykryty: wygląda na wyszarzony i nie reaguje na dotknięcia. Pod górnym
       paskiem (42), żeby burger dalej zamykał menu. */
    z-index: 41;
    inset: calc(var(--top-h) + env(safe-area-inset-top, 0px)) 0 0 0;
    height: auto; overflow-y: auto; scrollbar-width: none;
    flex-direction: column; align-items: stretch;
    border-top: 0; border-radius: 0;
    padding-bottom: calc(var(--bar-h, 54px) + env(safe-area-inset-bottom, 0px));
  }
  .menu-toggle:checked ~ .siderail::-webkit-scrollbar { display: none; }

  .menu-toggle:checked ~ .siderail .siderail__list {
    flex-direction: column; padding: .4rem 0;
  }
  .menu-toggle:checked ~ .siderail .siderail__list li { display: flex; flex: 0 0 auto; }
  .menu-toggle:checked ~ .siderail .siderail__list li.is-primary,
  .menu-toggle:checked ~ .siderail .siderail__bell.is-primary { display: none; }
  .menu-toggle:checked ~ .siderail .siderail__list a,
  .menu-toggle:checked ~ .siderail .siderail__bell,
  .menu-toggle:checked ~ .siderail .siderail__me {
    flex-direction: row; justify-content: flex-start; gap: .75rem;
    padding: .75rem 1.1rem; font-size: .96rem; min-height: 48px;
  }
  .menu-toggle:checked ~ .siderail .siderail__list a span:not(.pill),
  .menu-toggle:checked ~ .siderail .siderail__bell span:not(.pill),
  .menu-toggle:checked ~ .siderail .siderail__me span { text-align: left; }
  .menu-toggle:checked ~ .siderail .siderail__list a .pill,
  .menu-toggle:checked ~ .siderail .siderail__bell .pill { position: static; margin: 0 0 0 auto; }
  .menu-toggle:checked ~ .siderail .siderail__foot {
    flex-direction: column; align-items: stretch; margin-right: 0;
    border-top: 1px solid rgba(255, 255, 255, .12); padding: .3rem 0;
  }
  .menu-toggle:checked ~ .siderail .siderail__status,
  .menu-toggle:checked ~ .siderail .siderail__me,
  .menu-toggle:checked ~ .siderail .siderail__foot form:last-child { display: block; }
  .menu-toggle:checked ~ .siderail .siderail__logout {
    flex-direction: row; justify-content: flex-start; gap: .75rem;
    padding: .75rem 1.1rem; font-size: .96rem; width: 100%;
  }
  .menu-toggle:checked ~ .siderail .siderail__status button {
    flex-direction: row; justify-content: flex-start; gap: .6rem; padding: .6rem 1.1rem;
  }
  .menu-toggle:checked ~ .siderail .siderail__status span { flex: 0 1 auto; }

  .menu-toggle:checked ~ .menu-backdrop {
    display: block; position: fixed; inset: 0; z-index: 39;
    background: rgba(8, 12, 18, .5);
  }
  .siderail__me em { display: none; }
  .siderail__list a .pill { position: absolute; top: .2rem; left: 50%; margin-left: .4rem; }
  .siderail__bell { position: relative; min-width: 3.6rem; }
  .siderail__bell .pill { position: absolute; top: .2rem; left: 50%; margin-left: .3rem; }
}

@media print {
  .siderail { display: none !important; }
  .has-rail .shell { margin-left: 0; }
}

/* ---------- Lista kontaktów w pasku czatu (układ z GG) ---------- */

.chat__section--split { display: flex; align-items: center; justify-content: space-between; }
.chat__count {
  font-size: .7rem; color: var(--chat-side-dim);
  background: rgba(255, 255, 255, .1); border-radius: 999px; padding: .05rem .45rem;
  letter-spacing: 0;
}

.chat__contact {
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem 1rem; min-height: 30px;
  color: var(--chat-side-fg); text-decoration: none; font-size: .87rem;
}
.chat__contact:hover { background: var(--chat-side-hover); color: #fff; }
.chat__contact.is-active { background: var(--chat-side-active); color: #fff; font-weight: 600; }
.chat__contact.has-unread { color: #fff; font-weight: 700; }
.chat__contact.is-offline { color: var(--chat-side-dim); }
.chat__contact.is-offline:hover { color: var(--chat-side-fg); }

.chat__offline summary {
  list-style: none; cursor: pointer;
  padding: .35rem 1rem; min-height: 30px;
  display: flex; align-items: center;
  font-size: .74rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--chat-side-dim);
}
.chat__offline summary::-webkit-details-marker { display: none; }
.chat__offline summary::before {
  content: "▸"; margin-right: .4rem; transition: transform .12s ease; display: inline-block;
}
.chat__offline[open] summary::before { transform: rotate(90deg); }
.chat__offline summary:hover { color: var(--chat-side-fg); }

/* Skróty do sekcji, które na telefonie nie mieszczą się w dolnym pasku */
.profile__extra { display: none; }
@media (max-width: 760px) { .profile__extra { display: flex; } }

/* ---------- Skrzynka powiadomień ---------- */

.notif { list-style: none; margin: 0; padding: 0; }
.notif__item { border-bottom: 1px solid var(--ink-100); }
.notif__item:last-child { border-bottom: 0; }

.notif__link {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .75rem .3rem; text-decoration: none; color: inherit;
}
.notif__link:hover { background: var(--ink-50); color: inherit; }

.notif__dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px;
  background: transparent; margin-top: .45rem;
}
.notif__item.is-unread .notif__dot { background: var(--tint-500); }
.notif__item.is-unread .notif__title { font-weight: 700; }

.notif__body { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.notif__title { font-size: .95rem; }
.notif__detail { font-size: .86rem; color: var(--ink-700); }
.notif__meta { font-size: .75rem; color: var(--ink-500); }

/* Wiadomość wskazana kotwicą — np. po wejściu z listy głosowań */
.chat__msg.is-targeted {
  background: var(--warn-bg);
  box-shadow: inset 3px 0 0 var(--warn-fg);
  animation: podswietl 2.4s ease-out 1s forwards;
}
@keyframes podswietl { to { background: transparent; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .chat__msg.is-targeted { animation: none; } }

/* ---------- Logo ---------- */

.logo { width: 100%; height: auto; display: block; color: var(--brand-red); }
:root { --brand-red: #e3051b; }

.siderail__brand { flex-direction: row; align-items: center; gap: .6rem; }
.siderail__brand .logo { width: 30px; flex: 0 0 30px; }
.siderail__brand-text { display: flex; flex-direction: column; min-width: 0; }

.auth__brand .logo { width: 72px; margin: 0 auto .6rem; }

@media (min-width: 761px) and (max-width: 1100px) {
  .siderail__brand-text { position: absolute; left: -9999px; }
  .siderail__brand .logo { width: 28px; flex: 0 0 28px; }
}

.field__label--inline { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.field__label--inline input { flex: 0 0 auto; }

/* ---------- Zakładki etapów ---------- */

.tabs {
  display: flex; gap: .25rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--ink-100);
}
.tabs__item {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem .85rem;
  text-decoration: none; color: var(--ink-500);
  font-size: .92rem; font-weight: 550;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: var(--tap);
}
.tabs__item:hover { color: var(--ink-900); background: var(--ink-50); }
.tabs__item.is-active { color: var(--tint-700); border-bottom-color: var(--tint-500); }

.tabs__count {
  font-size: .75rem; font-weight: 700;
  background: var(--ink-100); color: var(--ink-700);
  padding: .05rem .4rem; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.tabs__item.is-active .tabs__count { background: var(--tint-500); color: #fff; }

@media (max-width: 560px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs__item { white-space: nowrap; }
}

/* ---------- Urodziny ---------- */

.bdays, .plain { list-style: none; margin: 0; padding: 0; }

.bday {
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem .2rem; border-bottom: 1px solid var(--ink-100);
}
.bday:last-child { border-bottom: 0; }

.datebox {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 3.4rem; flex: 0 0 3.4rem; padding: .32rem 0;
  background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
}
.datebox__dm {
  font-size: 1.02rem; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.datebox__dow { font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); }

.bday.is-today .datebox { background: var(--ok-bg); border-color: var(--ok-line); }
.bday.is-soon .datebox { background: var(--warn-bg); border-color: var(--warn-line); }

.bday__who { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.bday__name { font-weight: 600; }
.bday__when { font-size: .82rem; color: var(--ink-500); }

.bday.is-today .bday__when { color: var(--ok-fg); font-weight: 700; }

/* ---------- Galeria ---------- */

.albums { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.album {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--ink-100);
  border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.album:hover { border-color: var(--tint-500); color: inherit; }

.album__cover {
  aspect-ratio: 4 / 3; background: var(--ink-50);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.album__cover img { width: 100%; height: 100%; object-fit: cover; }
.album__empty { color: var(--ink-300); font-size: .85rem; }

.album__body { padding: .7rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.album__title { font-weight: 650; }
.album__meta { font-size: .8rem; color: var(--ink-500); }

.photos { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.photo {
  margin: 0; position: relative;
  border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface);
}
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo__meta {
  padding: .4rem .55rem; font-size: .76rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.photo__caption { color: var(--ink-900); }
.photo__del { position: absolute; top: .4rem; right: .4rem; opacity: 0; transition: opacity .12s; }
.photo:hover .photo__del { opacity: 1; }
@media (hover: none) { .photo__del { opacity: 1; } }

.photos--mini { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.photos--mini .photo img { aspect-ratio: 1; }

/* ---------- Kalendarz ---------- */

.cal__bar {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .9rem; flex-wrap: wrap;
}
.cal__label { font-size: 1.05rem; flex: 1 1 auto; }

.cal { display: flex; flex-direction: column; gap: 2px; }

.cal__head, .cal__week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal__head span {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-500); font-weight: 650; text-align: center; padding: .3rem 0;
}

.cal__day {
  min-height: 5.5rem; padding: .3rem;
  background: var(--surface); border: 1px solid var(--ink-100); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: .15rem; overflow: hidden;
}
.cal__day.is-outside { background: var(--ink-50); opacity: .55; }
.cal__day.is-weekend { background: var(--ink-50); }
.cal__day.is-today { border-color: var(--tint-500); box-shadow: inset 0 0 0 1px var(--tint-500); }

.cal__num {
  font-size: .78rem; font-weight: 650; color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.cal__day.is-today .cal__num { color: var(--tint-700); }

.chip {
  font-size: .7rem; line-height: 1.25;
  padding: .12rem .3rem; border-radius: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none; display: block;
  background: var(--ink-100); color: var(--ink-900);
  border-left: 3px solid var(--ink-300);
}
.chip:hover { color: var(--ink-900); filter: brightness(.96); }
.chip--school   { background: var(--tint-50);  border-left-color: var(--tint-500); color: var(--tint-700); }
.chip--class    { background: var(--ok-bg);    border-left-color: var(--ok-fg);    color: var(--ok-fg); }
.chip--trip     { background: var(--warn-bg);  border-left-color: var(--warn-fg);  color: var(--warn-fg); }
.chip--meeting  { background: #ece8f7;         border-left-color: #5b4b8a;         color: #453a6b; }
.chip--deadline { background: var(--bad-bg);   border-left-color: var(--bad-fg);   color: var(--bad-fg); }
.chip--holiday  { background: #e4f3f3;         border-left-color: #16706e;         color: #10514f; }
.chip--birthday { background: #fdf0f5;         border-left-color: #c2457c;         color: #8f2f59; }

@media (max-width: 760px) {
  .cal__day { min-height: 3.6rem; padding: .2rem; }
  .cal__num { font-size: .7rem; }
  .chip {
    font-size: 0; padding: 0; height: 5px; border-radius: 999px; border-left: 0;
    background: var(--ink-300);
  }
  .chip--school { background: var(--tint-500); }
  .chip--class { background: var(--ok-fg); }
  .chip--trip { background: var(--warn-fg); }
  .chip--meeting { background: #5b4b8a; }
  .chip--deadline { background: var(--bad-fg); }
  .chip--holiday { background: #16706e; }
  .chip--birthday { background: #c2457c; }
}

/* Trójkę klasową poznaje się po fioletowym listku — działa niezależnie od tego,
   czy osoba jest akurat dostępna. Dostępność niesie kolor korpusu: gradient
   czerwono-zielony u obecnych, zwykła czerwień u nieobecnych. */
/* Kolory wypełnień podaje szablon, nie CSS: url(#gradient) wpisany w arkuszu
   rozwiązuje się względem adresu arkusza, więc gradient nigdy nie zostałby
   znaleziony. Tutaj zostaje wyłącznie sterowanie rozmiarem. */

.chat__who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; gap: .05rem; }
.chat__role {
  font-size: .68rem; line-height: 1.1;
  color: #b18ae8; letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat__contact.is-offline .chat__role { color: var(--chat-side-dim); }

.chat__channel--committee .chat__hash { color: #b18ae8; }

/* ---------- Wątki ---------- */

/* Pasek wątku jest bezpośrednim dzieckiem siatki wiadomości, więc bez wskazania
   kolumny ląduje w 36-pikselowej kolumnie awatara i zapada się do zera. */
.chat__replies {
  grid-column: 2;
  display: flex; align-items: center; gap: .4rem; flex-wrap: nowrap;
  margin-top: .2rem; padding: .18rem .45rem .18rem .2rem;
  border-radius: 6px; width: fit-content; max-width: 100%;
  text-decoration: none; line-height: 1.2;
}
.chat__replies:hover { background: var(--surface); box-shadow: 0 0 0 1px var(--ink-100); }

.chat__replies-faces { display: flex; }
.chat__face {
  width: 20px; height: 20px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: .56rem; font-weight: 700; color: #fff;
  border: 2px solid var(--surface);
}
.chat__face + .chat__face { margin-left: -6px; }
.chat__msg:hover .chat__face { border-color: var(--ink-50); }

.chat__replies-count { font-size: .8rem; font-weight: 650; color: var(--tint-600); }
.chat__replies:hover .chat__replies-count { text-decoration: underline; }
.chat__replies-when {
  font-size: .74rem; color: var(--ink-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat__replies-count { white-space: nowrap; }

.chat__back { color: inherit; text-decoration: none; }
.chat__back:hover { color: var(--tint-600); }

.chip--party { background: #fdf0f5; border-left-color: #c2457c; color: #8f2f59; }
@media (max-width: 760px) { .chip--party { background: #c2457c; } }

.chat__msg--root {
  background: var(--ink-50);
  border-left: 3px solid var(--tint-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: .5rem;
}
.chat__msg--root:hover { background: var(--ink-50); }

.chat__hint-keys { display: none; }
@media (hover: hover) { .chat__hint-keys { display: inline; } }

/* ---------- Lista braków konfiguracji ---------- */

.setup { border-left: 4px solid var(--tint-500); margin-bottom: var(--gap); }
.setup__list { list-style: none; margin: .8rem 0 0; padding: 0; }
.setup__item {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  padding: .6rem 0; border-bottom: 1px solid var(--ink-100);
}
.setup__item:last-child { border-bottom: 0; }
.setup__body { display: flex; flex-direction: column; gap: .1rem; flex: 1 1 14rem; min-width: 0; }
.setup__title { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: .4rem; }
.setup__desc { font-size: .84rem; color: var(--ink-500); }
.setup__item.is-urgent { border-left: 3px solid var(--warn-fg); padding-left: .6rem; margin-left: -.6rem; }
.setup__item.is-done .setup__title { color: var(--ink-500); font-weight: 500; }
.setup__item.is-done .setup__title::before { content: "✓ "; color: var(--ok-fg); font-weight: 700; }
.setup__done { margin-top: .8rem; }
.setup__done summary { cursor: pointer; font-size: .85rem; color: var(--ink-500); }
