:root {
  /* Paleta „archiwalna" — papier, atrament, stonowane akcenty */
  --paper: #f3efe6;        /* tło aplikacji / płótno */
  --paper-2: #ece6d8;      /* delikatne wypełnienia */
  --panel: #fbf9f4;        /* karty, panele */
  --panel-line: #ffffff;
  --ink: #25292e;          /* główny tekst */
  --ink-soft: #5d6470;     /* tekst drugorzędny */
  --ink-faint: #8b8f98;
  --border: #d8d1c2;       /* obramowania */
  --border-strong: #c3baa6;
  --accent: #2f5d50;       /* głęboka zieleń — akcja główna */
  --accent-dark: #24463d;
  --gold: #9a7b43;         /* detal / data */
  --danger: #9b2c2c;       /* burgund */
  --male: #3a5f86;         /* stonowany granat */
  --female: #8a4f73;       /* stonowany śliwkowy */
  --other: #7a7363;
  --shadow: 0 8px 24px rgba(40, 34, 22, .14);
  --shadow-sm: 0 2px 6px rgba(40, 34, 22, .10);
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --tabbar-h: 50px;                                   /* wysokość dolnego paska (mobile) */
  --tabbar-pad: max(calc(env(safe-area-inset-bottom) - 22px), 2px);  /* minimalny margines pod ikonami */
  --tabbar-total: calc(var(--tabbar-h) + var(--tabbar-pad));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { background: var(--panel); }   /* pas bezpieczeństwa pod aplikacją zlewa się z dolnym paskiem */
body {
  font-family: var(--sans);
  background: var(--panel);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* blokada double-tap zoom (kanwa drzewa nadpisuje touch-action: none) */
  touch-action: manipulation;
}
.hidden { display: none !important; }

.ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  padding: 9px 15px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel); color: var(--ink);
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-2); border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent-dark); color: #f6f4ec; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline { background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--paper-2); }
.btn-danger { color: var(--danger); border-color: #d3b3b3; }
.btn-danger:hover { background: #f3e4e4; border-color: var(--danger); }
.btn-icon { padding: 9px; }
.btn-icon .ic { width: 17px; height: 17px; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }

code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  background: var(--paper-2); padding: 1px 6px; border-radius: 4px;
  color: var(--gold); font-size: 12.5px; border: 1px solid var(--border);
}

/* ---------- Logowanie ---------- */
.login-screen {
  height: 100vh; display: flex; flex-direction: column;
  align-items: flex-end; justify-content: center;
  padding: 0 clamp(40px, 12vw, 220px);
  /* fallback dla starszych przeglądarek */
  background:
    linear-gradient(90deg, rgba(20,15,8,.10) 0%, rgba(20,15,8,.05) 45%, rgba(20,15,8,.42) 100%),
    url('../tlo_jn.jpg');
  /* lekki WebP z fallbackiem do JPG */
  background:
    linear-gradient(90deg, rgba(20,15,8,.10) 0%, rgba(20,15,8,.05) 45%, rgba(20,15,8,.42) 100%),
    image-set(url('../tlo_jn.webp') type('image/webp'), url('../tlo_jn.jpg') type('image/jpeg'));
  background-size: cover;
  background-position: center;
}
.login-card {
  width: 392px; max-width: 92vw;
  background: rgba(251, 249, 244, .68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(154, 123, 67, .45);
  border-radius: 14px; padding: 38px 34px;
  box-shadow: 0 18px 50px rgba(20, 14, 6, .45);
  text-align: center;
}
.login-emblem { color: var(--accent); display: flex; justify-content: center; margin-bottom: 6px; }
.login-emblem svg { width: 60px; height: 60px; }
.login-emblem img { width: 76px; height: 76px; border-radius: 16px; box-shadow: var(--shadow-sm); }
.login-card h1 { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.01em; margin: 4px 0; }
.login-sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }
.role-tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.role-tab {
  flex: 1; padding: 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--paper);
  color: var(--ink-soft); font-family: var(--sans); font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.role-tab.active { background: var(--accent); color: #f6f4ec; border-color: var(--accent-dark); }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 500; }
.login-card input {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,93,80,.15); }
.login-hint { font-size: 12px; color: var(--ink-soft); margin: 9px 0; text-align: left; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.login-footer { color: rgba(243, 239, 230, .82); font-size: 12px; margin-top: 18px; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.6); }

@media (max-width: 720px) {
  .login-screen {
    align-items: center; justify-content: flex-end;
    padding: 0 18px 7vh;
    /* dedykowany kadr pionowy: przedmioty u góry, wolne drewno na dole */
    background:
      linear-gradient(rgba(20,15,8,.10) 35%, rgba(20,15,8,.40) 100%),
      url('../mobile.jpg');
    background:
      linear-gradient(rgba(20,15,8,.10) 35%, rgba(20,15,8,.40) 100%),
      image-set(url('../mobile.webp') type('image/webp'), url('../mobile.jpg') type('image/jpeg'));
    background-size: cover; background-position: center top;
  }
}

/* ---------- Aplikacja ---------- */
/* Powłoka aplikacji: wysokość = dokładny widoczny obszar (--app-h liczone z visualViewport,
   z fallbackiem 100dvh). Niezawodne w PWA i Chrome/Safari na iOS. */
.app { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100dvh); display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 11px 18px;
  padding-top: calc(11px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--border);
  z-index: 20; box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); border-radius: 7px; object-fit: cover; }
.brand { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
/* margin-left:auto utrzymuje grupę po prawej przy krawędzi również wtedy,
   gdy środkowa wyszukiwarka jest ukryta (sekcje ogłoszeń i wątków) */
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.topbar-left { flex-shrink: 0; }
.role-badge {
  text-transform: uppercase; font-size: 10.5px; font-weight: 600; letter-spacing: .6px;
  padding: 5px 11px; border-radius: 5px; background: var(--paper-2); color: var(--ink-soft);
  border: 1px solid var(--border);
}
.role-badge.admin { background: #e7efe9; color: var(--accent); border-color: #bcd2c6; }

.search-wrap { position: relative; width: min(440px, 50vw); }
.search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); width: 16px; height: 16px; }
.search-wrap input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,93,80,.12); }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; overflow-y: auto; z-index: 30; box-shadow: var(--shadow);
}
.search-item { padding: 10px 14px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--paper-2); }
.search-item .si-name { font-family: var(--serif); font-weight: 600; }
.search-item .si-sub { font-size: 12px; color: var(--ink-soft); }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; background: var(--paper-2); border-bottom: 1px solid var(--border);
}
.toolbar-divider { width: 1px; height: 22px; background: var(--border-strong); }
.toolbar-hint { font-size: 13px; color: var(--ink-soft); }

/* ---------- Diagram ---------- */
.canvas-wrap {
  flex: 1; position: relative; overflow: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(60,50,30,.06) 1px, transparent 1px);
  background-size: 24px 24px;
}
/* absolutne wypełnienie kanwy — WebKit/iOS potrafi liczyć height:100% w flexie jako 0 */
.tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; }
.tree-svg.grabbing { cursor: grabbing; }
.tree-svg.selecting { cursor: crosshair; }
.btn-icon.active { background: var(--accent); border-color: var(--accent-dark); color: #f6f4ec; }
.btn-icon.active .ic { stroke: #f6f4ec; }

.legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 10;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-sm); font-size: 12.5px; color: var(--ink-soft);
}
.legend-title { font-weight: 600; color: var(--ink); margin-bottom: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.legend-row { display: flex; align-items: center; gap: 9px; margin: 5px 0; }
.legend-line { width: 26px; height: 0; border-top-width: 3px; border-top-style: solid; display: inline-block; }
.legend-line.married  { border-top-color: var(--accent); }
.legend-line.partner  { border-top-color: var(--gold); border-top-style: dashed; }
.legend-line.divorced { border-top-color: var(--danger); border-top-style: dotted; }
.legend-line.widowed  { border-top-color: var(--ink-faint); }

.view-controls {
  position: absolute; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 6px; z-index: 10;
}
.view-controls .btn { box-shadow: var(--shadow-sm); }

.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; color: var(--ink-soft);
}
.empty-state h2 { font-family: var(--serif); color: var(--ink); margin-bottom: 6px; font-weight: 600; }

/* ---------- Węzeł osoby (SVG foreignObject) ---------- */
.node-card {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-left-width: 5px;
  border-radius: 9px; padding: 8px 11px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  user-select: none; overflow: hidden; box-shadow: var(--shadow-sm);
}
.node-account {
  position: absolute; top: 5px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 1.5px var(--panel);
}
.node-card:hover { box-shadow: var(--shadow); border-color: var(--ink-faint); }
.node-card.male   { border-left-color: var(--male); }
.node-card.female { border-left-color: var(--female); }
.node-card.other  { border-left-color: var(--other); }
.node-card.deceased { background: var(--paper); }
.node-card.deceased .node-name::after { content: ' †'; color: var(--ink-faint); font-weight: 400; }
.node-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,93,80,.35), var(--shadow); }
.node-card.dragging { box-shadow: var(--shadow); border-color: var(--accent); }
.node-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.marquee { fill: rgba(47,93,80,.10); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; }

/* Węzeł osoby — natywny SVG (działa też na iOS/WebKit, gdzie foreignObject bywa niewidoczny) */
.node { cursor: pointer; }
.node text { font-family: var(--sans); -webkit-user-select: none; user-select: none; }
.node .nc-name { font-weight: 600; }
.node .nc-ini { font-family: var(--serif); }
.node .nc-bg { filter: drop-shadow(0 1px 2px rgba(40,34,22,.12)); }
.node.highlight .nc-bg, .node.dragging .nc-bg { stroke: var(--accent); stroke-width: 2; }
.node.selected .nc-bg { stroke: var(--accent); stroke-width: 2; }
/* skrót „+" pod kaflem (admin) */
.node-add { cursor: pointer; }
.node-add .na-bg { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; transition: fill .12s; }
.node-add .na-plus { stroke: #fff; stroke-width: 2; stroke-linecap: round; fill: none; }
.node-add:hover .na-bg { fill: var(--accent-dark); }

/* szybkie dodawanie krewnych — duszki wokół kafla (w SVG) */
.qa-dim { fill: rgba(20, 16, 10, .55); }
.ghost-node { cursor: pointer; }
.ghost-node text, .qa-focal text { font-family: var(--sans); -webkit-user-select: none; user-select: none; }
.ghost-node .gn-bg { transition: fill .12s; }
.ghost-node:hover .gn-bg { fill: var(--paper-2); }
.qa-close {
  position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%; transform: translateX(-50%);
  z-index: 80; background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink);
  border-radius: 22px; padding: 9px 18px; font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow);
}
.qa-close:hover { background: var(--paper-2); }

.node-avatar {
  width: 44px; height: 44px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 17px; font-weight: 600; overflow: hidden;
  color: #fff; letter-spacing: .5px;
}
.node-avatar.male   { background: var(--male); }
.node-avatar.female { background: var(--female); }
.node-avatar.other  { background: var(--other); }
.node-avatar img { width: 100%; height: 100%; object-fit: cover; }
.node-info { min-width: 0; flex: 1; }
.node-name { font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-dates { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* ---------- Krawędzie ---------- */
.edge-child { stroke: var(--border-strong); stroke-width: 1.8; fill: none; }
.edge-union { stroke-width: 2.6; fill: none; }
.edge-union.married  { stroke: var(--accent); }
.edge-union.partner  { stroke: var(--gold); stroke-dasharray: 7 5; }
.edge-union.divorced { stroke: var(--danger); stroke-dasharray: 2 5; }
.edge-union.widowed  { stroke: var(--ink-faint); }
.union-dot { stroke: var(--panel); stroke-width: 2; }
.union-dot.married  { fill: var(--accent); }
.union-dot.partner  { fill: var(--gold); }
.union-dot.divorced { fill: var(--danger); }
.union-dot.widowed  { fill: var(--ink-faint); }
.union-label { font-family: var(--serif); font-size: 11px; fill: var(--ink-soft); }

/* ---------- Modale ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(40, 34, 22, .42);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(1px);
}
.modal {
  width: 560px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.modal-wide { width: 640px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 4px; display: flex; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.modal-foot .spacer, .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row-full { grid-column: 1 / -1; }
.form-row label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,93,80,.12);
}
.form-row textarea { resize: vertical; }
.claim-form { display: flex; flex-direction: column; gap: 9px; }
.claim-form input {
  width: 100%; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.claim-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,93,80,.12); }
.claim-error { color: var(--danger); font-size: 12.5px; min-height: 1em; }

.photo-field { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.photo-preview {
  width: 80px; height: 80px; border-radius: 10px; background: var(--paper-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid var(--border-strong); color: var(--ink-faint);
  font-family: var(--serif); font-size: 28px; font-weight: 600;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Karta szczegółów ---------- */
.detail-head { display: flex; gap: 18px; margin-bottom: 6px; }
.detail-avatar {
  width: 92px; height: 92px; border-radius: 11px; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 34px; font-weight: 600; color: #fff;
}
.detail-avatar.male { background: var(--male); }
.detail-avatar.female { background: var(--female); }
.detail-avatar.other { background: var(--other); }
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-meta h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.detail-meta .dm-row { font-size: 14px; color: var(--ink-soft); margin: 3px 0; }
.detail-meta .dm-living { color: var(--accent); font-weight: 500; }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-faint); margin-bottom: 9px; font-weight: 600; }
.relation-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 7px; margin: 0 7px 7px 0;
  background: var(--paper); border: 1px solid var(--border-strong); border-radius: 20px; font-size: 13.5px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.relation-chip:hover { border-color: var(--accent); background: var(--panel); }
.chip-avatar {
  width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 11px; font-weight: 600; color: #fff;
}
.chip-avatar.male { background: var(--male); }
.chip-avatar.female { background: var(--female); }
.chip-avatar.other { background: var(--other); }
.chip-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chip-rel { color: var(--ink-faint); }
.chip-remove {
  margin-left: 2px; width: 19px; height: 19px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; cursor: pointer; line-height: 1;
  font-size: 15px; color: var(--ink-faint); background: transparent;
  transition: background .12s, color .12s;
}
.chip-remove:hover { background: #e5484d; color: #fff; }
.detail-notes { font-size: 14px; line-height: 1.65; color: var(--ink); white-space: pre-wrap; }
/* Oś czasu życia */
.timeline { display: flex; flex-direction: column; margin-left: 4px; }
.tl-event { position: relative; display: flex; gap: 12px; align-items: baseline;
  padding: 8px 0 8px 16px; border-left: 2px solid var(--border); }
.tl-event:last-child { border-left-color: transparent; }
.tl-event::before { content: ''; position: absolute; left: -5px; top: 13px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); }
.tl-year { font-family: var(--serif); font-weight: 600; color: var(--accent); font-size: 14px;
  min-width: 46px; flex-shrink: 0; }
.tl-label { color: var(--ink); font-size: 14px; line-height: 1.4; }
.grave-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); text-decoration: none; font-weight: 600; }
.grave-link:hover { text-decoration: underline; }

.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.stat-box { background: var(--paper); border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
.stat-num { font-family: var(--serif); font-size: 32px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* ---------- Statystyki / wykresy ---------- */
.stats-inner { max-width: 980px; }
.stat-grid.summary { grid-template-columns: repeat(3,1fr); margin-bottom: 18px; }
.stats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.stats-cols .stat-card { margin-bottom: 0; }
.stat-card > h4 { margin: 0 0 12px; font-family: var(--serif); font-size: 16px; color: var(--ink); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sc-sub { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--ink-faint); }
.sc-note { font-size: 12px; color: var(--ink-faint); margin: 8px 0 0; }
.chart-svg { display: block; max-width: 220px; height: auto; margin: 0 auto; }
.chart-svg.wide { max-width: 100%; }
.chart-empty { color: var(--ink-faint); font-size: 13px; text-align: center; padding: 18px 0; }
.donut-num { font-family: var(--serif); font-size: 26px; font-weight: 700; fill: var(--ink); }
.donut-cap { font-size: 11px; fill: var(--ink-faint); }
.ax-lbl { font-size: 10px; fill: var(--ink-faint); }
.bar-val { font-size: 10px; fill: var(--ink-soft); font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.chart-legend { font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 5px; }
.cl-row { display: flex; align-items: center; gap: 7px; }
.cl-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.cl-pct { color: var(--ink-faint); }
.mini-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.mini-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb-row { display: grid; grid-template-columns: 96px 1fr 28px; align-items: center; gap: 8px; font-size: 13px; }
.hb-lbl { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { background: var(--paper); border: 1px solid var(--border); border-radius: 6px; height: 14px; overflow: hidden; }
.hb-fill { display: block; height: 100%; border-radius: 5px 0 0 5px; }
.hb-num { text-align: right; color: var(--ink-soft); font-weight: 600; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th { text-align: left; color: var(--ink-faint); font-weight: 600; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.stat-table td { padding: 5px 8px; border-bottom: 1px solid var(--panel-line); color: var(--ink); }
.big-stats { display: flex; justify-content: space-around; gap: 10px; text-align: center; padding: 6px 0; }
.bs-num { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; }
.bs-lbl { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.lead-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink); }
.lead-list li { padding: 4px 0; display: flex; justify-content: space-between; gap: 10px; }
.lead-list li b { color: var(--accent); white-space: nowrap; }
.stats-empty { text-align: center; padding: 36px 16px; color: var(--ink-soft); }
.stats-empty h3 { font-family: var(--serif); color: var(--ink); margin: 0 0 8px; }
.stats-foot { font-size: 12px; color: var(--ink-faint); margin: 4px 0 0; line-height: 1.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); border: 1px solid #000; color: #f6f4ec;
  padding: 12px 20px; border-radius: 9px; box-shadow: var(--shadow); z-index: 200; font-size: 14px;
}
.toast.success { background: var(--accent); border-color: var(--accent-dark); }
.toast.error { background: var(--danger); border-color: #7a1f1f; }

/* ---------- Przełącznik widoków ---------- */
.view-nav {
  display: flex; gap: 4px; margin-left: 16px;
  background: var(--paper-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px;
}
.view-tab {
  font-family: var(--sans); font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  background: transparent; border: none; padding: 7px 13px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  transition: all .12s;
}
.view-tab:hover { color: var(--ink); }
.view-tab.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------- Tablica ogłoszeń ---------- */
.board { flex: 1; overflow-y: auto; background: var(--paper); }
.board-inner { max-width: 1120px; margin: 0 auto; padding: 30px 24px 64px; }
.board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.board-title { font-family: var(--serif); font-size: 29px; font-weight: 700; letter-spacing: -.01em; }
.board-sub { color: var(--ink-soft); font-size: 14px; margin-top: 5px; max-width: 660px; line-height: 1.5; }
.board-filters { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.board-search { width: min(420px, 100%); }
.board-search input { padding-left: 36px; }
.board-filters select {
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--ink); font-family: var(--sans); font-size: 14px;
}
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.board-empty { text-align: center; color: var(--ink-soft); padding: 64px 20px; }
.board-empty h2 { font-family: var(--serif); color: var(--ink); margin-bottom: 6px; font-weight: 600; }

.ad-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.ad-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.ad-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ad-cat {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); background: #e7efe9; border: 1px solid #bcd2c6; padding: 4px 10px; border-radius: 20px;
}
.ad-actions { display: flex; gap: 2px; }
.ad-icon-btn { background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 5px; border-radius: 6px; display: flex; }
.ad-icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.ad-icon-btn.danger:hover { color: var(--danger); }
.ad-icon-btn .ic { width: 16px; height: 16px; }
.ad-photo { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ad-title { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.25; }
.ad-company { font-size: 13px; color: var(--gold); font-weight: 600; margin-top: -4px; }
.ad-desc { font-size: 14px; line-height: 1.55; color: var(--ink); }
.ad-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.ad-mi { display: inline-flex; align-items: center; gap: 5px; }
.ad-mi .ic { width: 14px; height: 14px; }
.ad-author { font-weight: 600; color: var(--ink); }
.ad-price { font-weight: 600; color: var(--ink); }
.ad-contact { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.ad-contact a {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500;
  text-decoration: none; color: var(--accent); border: 1px solid var(--border-strong); padding: 7px 12px; border-radius: 8px;
}
.ad-contact a:hover { background: var(--paper-2); border-color: var(--accent); }
.ad-contact a .ic { width: 15px; height: 15px; }
.ad-date { font-size: 11.5px; color: var(--ink-faint); border-top: 1px solid var(--border); padding-top: 9px; }

/* ---------- Konto / menu użytkownika ---------- */
.account { position: relative; }
.btn-account { gap: 8px; padding: 6px 10px; }
.acc-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #f6f4ec;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 12px; font-weight: 600;
}
.acc-name { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute; right: 0; top: 46px; width: 260px; z-index: 40;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.am-head { padding: 14px; border-bottom: 1px solid var(--border); }
.am-name { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.am-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.am-pairing { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--ink-soft); }
.am-pairing:empty { display: none; }
.am-pair-ok { color: var(--accent); }
.am-pair-pending { color: var(--gold); }
.am-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 11px 14px; font-family: var(--sans); font-size: 14px; color: var(--ink); cursor: pointer; }
.am-item:hover { background: var(--paper-2); }
.badge-dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; background: var(--danger); border-radius: 50%; border: 2px solid var(--panel); }

/* ---------- Czat ---------- */
.chat-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: 360px; max-width: 92vw; z-index: 35;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(40,34,22,.14);
  display: flex; flex-direction: column;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-family: var(--serif); font-weight: 600; font-size: 16px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; }
.cm-meta { font-size: 11px; color: var(--ink-faint); margin-bottom: 3px; }
.cm-meta span { opacity: .8; }
.cm-body { background: var(--paper-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.chat-msg.mine .cm-body { background: var(--accent); color: #f6f4ec; border-color: var(--accent-dark); }
.chat-msg.mine .cm-meta { text-align: right; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; font-family: var(--sans); font-size: 14px; }
.chat-input input:focus { outline: none; border-color: var(--accent); }

/* ---------- Wiadomości prywatne (DM 1:1) ---------- */
.dm-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dm-pane.hidden { display: none; }
.dm-convo-head { gap: 8px; }
.dm-convo-head #dmConvoName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-back { background: none; border: none; cursor: pointer; padding: 4px; color: var(--ink); display: inline-flex; }
.dm-back .ic { width: 20px; height: 20px; }
.dm-contacts { flex: 1; overflow-y: auto; }
.dm-contact { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 14px; background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer; font-family: var(--sans); }
.dm-contact:hover { background: var(--paper-2); }
.dm-avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #f6f4ec; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; overflow: hidden; }
.dm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dm-c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dm-c-name { font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-c-last { font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-c-last em { color: var(--ink-faint); }
.dm-time { flex: 0 0 auto; font-size: 11px; color: var(--ink-faint); }
.dm-unread { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.dm-empty { padding: 24px 18px; color: var(--ink-faint); font-size: 13px; line-height: 1.5; text-align: center; }
#btnChat, #btnAdmin { position: relative; }
.dm-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.dm-badge.hidden { display: none; }

/* ---------- Wątki ---------- */
.thread-list { display: flex; flex-direction: column; gap: 10px; }
.thread-item { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.thread-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.thread-main { display: flex; align-items: center; gap: 10px; }
.thread-title { font-family: var(--serif); font-weight: 600; font-size: 16px; }
.thread-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }
.thread-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; padding: 3px 9px; border-radius: 20px; }
.thread-type.t-suggestion { background: #e7efe9; color: var(--accent); }
.thread-type.t-bug { background: #f3e4e4; color: var(--danger); }
.thread-type.t-family { background: #f1ead8; color: var(--gold); }
.thread-status.s-open { color: var(--accent); font-weight: 600; }
.thread-status.s-resolved { color: var(--ink-faint); }
.tv-head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.tv-messages { display: flex; flex-direction: column; gap: 12px; }
.tv-msg { max-width: 90%; align-self: flex-start; }
.tv-msg.mine { align-self: flex-end; }
.tv-msg .cm-body { background: var(--paper-2); }
.tv-msg.mine .cm-body { background: var(--accent); color: #f6f4ec; }
.tv-reply { flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; font-family: var(--sans); font-size: 14px; min-width: 140px; }
.tv-reply:focus { outline: none; border-color: var(--accent); }

/* ---------- Panel administratora ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.admin-tab { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink-soft); font-family: var(--sans); font-size: 14px; cursor: pointer; }
.admin-tab.active { background: var(--accent); color: #f6f4ec; border-color: var(--accent-dark); }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; font-size: 14px; }
.admin-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.log-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }
.log-row { display: grid; grid-template-columns: 160px 1fr 1fr auto; gap: 10px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.log-row.log-fail { border-color: #e3b7b7; background: #fbf2f2; }
.log-type { font-weight: 600; color: var(--ink); }
.log-row.log-fail .log-type { color: var(--danger); }
.log-actor { color: var(--ink-soft); word-break: break-word; }
.log-detail { color: var(--ink-faint); word-break: break-word; }
.log-time { color: var(--ink-faint); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .log-row { grid-template-columns: 1fr 1fr; } .log-time { grid-column: 1 / -1; text-align: left; } }
.muted { color: var(--ink-faint); font-size: 13px; }

/* ---------- Wyróżnianie kafelków (w szczegółach) ---------- */
.hl-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.hl-label { font-size: 13px; color: var(--ink-soft); width: 64px; }
.hl-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--paper); cursor: pointer; color: var(--ink-faint); font-size: 14px; line-height: 1; }
.hl-swatch.sel { outline: 2px solid var(--ink); outline-offset: 2px; }
.hl-size { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--paper); font-family: var(--sans); font-size: 13px; cursor: pointer; }
.hl-size.sel { background: var(--accent); color: #f6f4ec; border-color: var(--accent-dark); }
.pair-note { font-size: 13.5px; padding: 10px 12px; border-radius: 8px; }
.pair-note.ok { background: #e7efe9; color: var(--accent); }
.pair-note.pending { background: #f1ead8; color: var(--gold); }

/* ---------- Kadrowanie ---------- */
.crop-stage { display: flex; justify-content: center; margin-bottom: 16px; }
#cropCanvas { width: 320px; height: 320px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--paper-2); cursor: grab; touch-action: none; }
#cropCanvas:active { cursor: grabbing; }
.crop-controls label { display: block; font-size: 13px; color: var(--ink-soft); margin: 8px 0 4px; }
.crop-controls input[type=range] { width: 100%; }
.crop-buttons { display: flex; gap: 8px; margin-top: 14px; }
.crop-buttons .btn.active, #cropGray.active { background: var(--accent); color: #f6f4ec; border-color: var(--accent-dark); }

/* ---------- Linia rozwodu ---------- */
.divorce-label { fill: var(--danger); }

/* ---------- Responsywność tablicy/czatu ---------- */
@media (max-width: 640px) {
  .view-nav { display: none; }
  .acc-name { display: none; }
  /* Menu konta: przypięte do prawej krawędzi ekranu, nigdy poza widok. */
  .account-menu {
    position: fixed; left: auto; right: 8px;
    top: calc(env(safe-area-inset-top) + 52px);
    width: min(280px, calc(100vw - 16px));
  }
  /* Czat: absolutnie w obrębie .app (które samo podąża za klawiaturą), nad dolnym paskiem. */
  .chat-panel {
    position: absolute; left: 0; right: 0; top: 0; bottom: var(--tabbar-total);
    width: 100%; max-width: 100%; z-index: 55;
  }
  .chat-head { padding-top: calc(14px + env(safe-area-inset-top)); }
  .chat-input { padding-bottom: 12px; }
}

/* ===================== MOBILE / DOTYK / PWA ===================== */

/* Gesty dotyku na płótnie obsługujemy sami (pan + pinch) — wyłącz domyślne. */
.tree-svg, .node-card { touch-action: none; }

/* Pełna wysokość widoczna na mobile (pasek adresu): preferuj dvh. */
@supports (height: 100dvh) {
  .login-screen { height: 100dvh; }
}

/* Mobilny przełącznik widoków — zastąpiony dolnym paskiem zakładek. */
.mobile-viewbar { display: none; }

/* Dolny pasek zakładek (mobilny) — domyślnie ukryty na desktopie. */
.mobile-tabbar { display: none; }

@media (max-width: 720px) {
  /* Topbar: ciaśniej; nawigacja widoków trafia na dolny pasek. */
  .topbar { gap: 10px; padding: 9px 12px; padding-top: calc(9px + env(safe-area-inset-top)); }
  .view-nav { display: none; }
  .mobile-viewbar { display: none !important; }
  .topbar-center { order: 3; flex-basis: 100%; }
  .search-wrap { width: 100%; }
  /* Ikony wiadomości i statystyk są już w dolnym pasku — nie dubluj w topbarze. */
  #btnChat, #btnStats { display: none; }

  /* Panel czatu nie zachodzi na dolny pasek. */
  .chat-panel { bottom: var(--tabbar-total); }

  /* Dolny pasek zakładek — ostatni element w przepływie #app, zawsze na realnym dole. */
  .mobile-tabbar {
    display: flex; flex-shrink: 0;
    height: var(--tabbar-total);
    background: var(--panel); border-top: 1px solid var(--border);
    padding-bottom: var(--tabbar-pad);
    box-shadow: 0 -2px 10px rgba(40,34,22,.08);
  }
  .tabbar-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    position: relative; background: none; border: none; cursor: pointer;
    padding: 6px 2px; font-family: var(--sans); font-size: 10.5px; font-weight: 500;
    color: var(--ink-faint); -webkit-tap-highlight-color: transparent;
  }
  .tabbar-btn .ic { width: 22px; height: 22px; }
  .tabbar-btn.active,
  .mobile-tabbar .view-tab.active { color: var(--accent); background: none; box-shadow: none; font-weight: 600; }
  .tabbar-btn .dm-badge { top: 4px; right: calc(50% - 22px); }

  /* Pasek narzędzi admina: chowamy długą podpowiedź, zostają przyciski. */
  .toolbar { padding: 9px 12px; overflow-x: auto; }
  .toolbar-hint, .toolbar-divider { display: none; }

  /* Legenda zabiera miejsce nad sterowaniem — ukrywamy na małych ekranach. */
  .legend { display: none; }
  .view-controls { right: 12px; bottom: 12px; }

  /* Tablica / wątki — mniejsze marginesy. */
  .board-inner { padding: 20px 14px 28px; }
  .board-title { font-size: 24px; }
  .board-grid { grid-template-columns: 1fr; }
  .board-filters select { flex: 1; }

  /* Modale: pełna szerokość/wysokość, wygodny scroll. */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 14px 14px 0 0; }
  .modal-wide { width: 100%; }
  .stats-cols { grid-template-columns: 1fr; }
  .stat-grid.summary { grid-template-columns: repeat(2,1fr); }
  .hb-row { grid-template-columns: 80px 1fr 26px; }
  .modal-body { -webkit-overflow-scrolling: touch; }
  .form-grid { grid-template-columns: 1fr; }

  /* iOS: inputy ≥16px, by przeglądarka nie robiła auto-zoomu przy focusie. */
  .form-row input, .form-row select, .form-row textarea,
  .login-card input, .search-wrap input,
  .chat-input input, .tv-reply, .board-filters select, #adSearch, #threadSearch {
    font-size: 16px;
  }

  /* Kadrowanie: kanwa dopasowana do szerokości. */
  #cropCanvas { width: 80vw; height: 80vw; max-width: 320px; max-height: 320px; }
}

@media (max-width: 540px) {
  .brand { display: none; }              /* zostaje sam znak graficzny */
  .topbar { gap: 8px; }
  .topbar-right { gap: 4px; }
  .login-card { padding: 30px 22px; }
}

/* ---------- Zgoda / baner cookie ---------- */
.login-consent { display: flex !important; align-items: flex-start; gap: 8px; text-align: left;
  font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 4px; font-weight: 400 !important; cursor: pointer; }
.login-consent input { width: auto !important; margin-top: 2px; }
.login-consent a { color: var(--accent); }
.cookie-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 300;
  display: flex; align-items: center; gap: 14px; max-width: 720px; width: calc(100% - 32px);
  background: var(--ink); color: #f3efe6; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.45;
}
.cookie-bar a { color: #e6cf9a; }
.cookie-bar .btn { flex-shrink: 0; }

/* ---------- Strony dokumentów (regulamin / polityka) ---------- */
.doc-page { max-width: 820px; margin: 0 auto; padding: 48px 24px 80px; }
.doc-brand { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--border); text-decoration: none; }
.doc-brand img { width: 52px; height: 52px; border-radius: 10px; box-shadow: var(--shadow-sm); }
.doc-brand .db-title { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.doc-brand .db-sub { font-size: 12.5px; color: var(--ink-soft); }
.doc-page h1 { font-family: var(--serif); font-size: 30px; margin-bottom: 6px; }
.doc-page h2 { font-family: var(--serif); font-size: 20px; margin: 28px 0 10px; }
.doc-page h3 { font-size: 16px; margin: 18px 0 6px; }
.doc-page p, .doc-page li { font-size: 15px; line-height: 1.7; color: var(--ink); }
.doc-page ul { margin: 8px 0 8px 22px; }
.doc-meta { color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }
.doc-back { display: inline-block; margin-bottom: 24px; color: var(--accent); text-decoration: none; font-weight: 500; }
.doc-note { background: var(--paper-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; font-size: 14px; margin: 16px 0; }

/* ---------- Aktywacja / tryb gościa ---------- */
.activate-intro { background: var(--paper-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 14px; text-align: center; margin-bottom: 14px; line-height: 1.5; }
.act-link { display: flex; gap: 6px; margin-top: 8px; }
.act-link input { flex: 1; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: var(--paper); color: var(--ink); }

/* Gość: ukryj sekcje wymagające pełnego konta */
body.role-guest #btnChat,
body.role-guest #btnStats,
body.role-guest #tabMessages,
body.role-guest #btnChangePass,
body.role-guest .view-tab[data-view="board"],
body.role-guest .view-tab[data-view="threads"] { display: none !important; }

/* Ukrywanie elementów admina dla viewera */
body.role-viewer .admin-only { display: none !important; }
