/* ==========================================================================
   BPSP — Bolingbroke Penitentiary State Prison
   Motyw: instytucjonalny, stalowo-granatowy, wzorowany na logo jednostki.
   ========================================================================== */

@font-face {
  font-family: "Oswald";
  src: local("Oswald");
}

:root{
  --md-h1: #4da3f0;      /* nagłówek # (niebieski) */
  --md-h2: #9ccbf2;      /* nagłówek ## (jaśniejszy odcień) */
  --navy-950: #070c14;
  --navy-900: #0c1622;
  --navy-800: #12202f;
  --navy-700: #1a2f42;
  --navy-600: #234061;
  --steel-500: #3c5f82;
  --steel-300: #7ca3c4;
  --ice-100: #d9e6ef;
  --paper: #ece6d6;
  --paper-dim: #b9b29d;
  --accent: #5b8fb9;
  --accent-bright: #8fc6ea;
  --line: rgba(217,230,239,0.12);
  --danger: #b23b3b;

  --font-display: "Oswald", "Bebas Neue", "Arial Narrow", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  --radius: 3px;
}

*{ box-sizing: border-box; }

html{ scroll-behavior: smooth; }

/* ---------- Blokada zaznaczania tekstu ----------
   Pola formularzy (input/textarea) pozostają zaznaczalne,
   bo inaczej admin nie mógłby edytować ogłoszeń/kompendium. */
body{
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
input, textarea{
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

body{
  margin:0;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(60,95,130,0.25), transparent 55%),
    var(--navy-950);
  color: var(--ice-100);
  font-family: var(--font-body);
  line-height: 1.55;
  min-height: 100vh;
}

a{ color: var(--accent-bright); }

/* Subtle steel-mesh texture on the whole page via repeating lines */
body::before{
  content:"";
  position: fixed;
  inset:0;
  pointer-events:none;
  z-index:0;
  background-image: repeating-linear-gradient(
    115deg,
    rgba(255,255,255,0.015) 0px,
    rgba(255,255,255,0.015) 1px,
    transparent 1px,
    transparent 68px
  );
}

/* ---------- Ekran logowania ---------- */
.login-screen{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(60,95,130,0.25), transparent 55%),
    var(--navy-950);
}
.login-card{
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: rgba(18,32,47,0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo{
  width: 96px;
  height: auto;
  margin: 0 auto 18px;
  display: block;
  filter: drop-shadow(0 4px 18px rgba(92,143,185,0.3));
}
.login-card h1{
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--paper);
  margin: 0 0 6px;
}
.login-sub{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--steel-300);
  letter-spacing: 0.1em;
  margin: 0 0 28px;
}
.btn.big{
  width: 100%;
  justify-content: center;
  padding: 13px 20px;
  font-size: 15px;
}
#loginFormFields .field{ text-align: left; margin-bottom: 14px; }
#loginFormFields .btn.big{ margin-top: 4px; }

/* ---------- Header / Nav ---------- */
header.site-header{
  position: sticky;
  top:0;
  z-index: 50;
  background: linear-gradient(180deg, var(--navy-900) 0%, rgba(12,22,34,0.94) 100%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.header-inner{
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 24px;
  display:flex;
  align-items:center;
  gap:20px;
}

.logo-trigger{
  display:flex;
  align-items:center;
  gap:14px;
  min-width: 0;
}

.logo-img-btn, .brand-text-btn{
  background:none;
  border:none;
  cursor:pointer;
  padding:4px;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
  display:flex;
  align-items:center;
  min-width: 0;
}

.logo-img-btn img{
  height:56px;
  width:auto;
  display:block;
  filter: drop-shadow(0 0 6px rgba(143,198,234,0.25));
  transition: transform .15s ease;
}
.logo-img-btn:active img{ transform: scale(0.94); }
.brand-text-btn{ text-align:left; }

.brandblock{ text-align:left; min-width: 0; }
.brandblock .b1{
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--paper);
  line-height:1.15;
}
.brandblock .b2{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--steel-300);
  letter-spacing: 0.12em;
  margin-top:4px;
}

nav.tabs{
  display:flex;
  gap:4px;
  flex-wrap: wrap;
}

nav.tabs button{
  background: transparent;
  border: 1px solid transparent;
  color: var(--ice-100);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  padding: 9px 15px;
  cursor:pointer;
  border-radius: var(--radius);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
nav.tabs button:hover{ background: rgba(124,163,196,0.1); }
nav.tabs button.active{
  background: rgba(92,143,185,0.16);
  border-color: rgba(143,198,234,0.35);
  color: var(--accent-bright);
}

/* ---------- Rozwijane menu nawigacji ---------- */
.nav-wrap{
  position: relative;
  margin-left: auto;
}
.menu-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  background: rgba(92,143,185,0.1);
  border: 1px solid var(--line);
  color: var(--ice-100);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.menu-toggle:hover{ background: rgba(124,163,196,0.18); border-color: rgba(143,198,234,0.35); }
.menu-toggle .chev{ transition: transform .18s ease; font-size: 11px; }
.menu-toggle[aria-expanded="true"] .chev{ transform: rotate(180deg); }

nav.tabs{
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  z-index: 80;
}
nav.tabs.open{ display: flex; }
nav.tabs button{
  text-align: left;
  width: 100%;
}

.user-bar{
  margin-left: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-bar-info{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  margin-right: 4px;
}
.user-bar-nick{
  font-family: var(--font-display);
  font-size: 13.5px;
  color: var(--paper);
}
.user-bar-unit{
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--steel-300);
  letter-spacing: 0.05em;
}

/* ---------- Layout ---------- */
main{
  position:relative;
  z-index:1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 100px;
}

section.view{ display:none; animation: fadein .25s ease; }
section.view.active{ display:block; }

@keyframes fadein{ from{ opacity:0; transform: translateY(6px);} to{opacity:1; transform:none;} }

.eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--steel-300);
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}

h1.page-title{
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 46px);
  letter-spacing: 0.02em;
  color: var(--paper);
  margin: 0 0 8px;
}

.page-sub{
  color: var(--paper-dim);
  max-width: 640px;
  margin: 0 0 36px;
  font-size: 15.5px;
}

/* ---------- Home / Hero ---------- */
.hero{
  display:grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items:center;
  padding: 12px 0 56px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 48px;
}
.hero-logo{
  display:flex;
  justify-content:center;
}
.hero-logo img{
  width: 100%;
  max-width: 340px;
  filter: drop-shadow(0 8px 30px rgba(92,143,185,0.25));
}
.hero-text .eyebrow{ margin-bottom: 14px; }
.hero-text h1{
  font-family: var(--font-display);
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--paper);
  margin: 0 0 18px;
}
.hero-text p{
  color: var(--ice-100);
  opacity: 0.85;
  font-size: 16.5px;
  max-width: 480px;
  margin-bottom: 26px;
}
.hero-cta{ display:flex; gap:12px; flex-wrap:wrap; }
.btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--steel-500);
  background: transparent;
  color: var(--ice-100);
  text-decoration:none;
  transition: all .15s ease;
}
.btn:hover{ border-color: var(--accent-bright); color: var(--accent-bright); }
.btn.primary{
  background: linear-gradient(180deg, var(--steel-500), var(--navy-700));
  border-color: var(--steel-500);
  color: var(--paper);
}
.btn.primary:hover{ filter: brightness(1.12); color: var(--paper); }
.btn.danger{ border-color: var(--danger); color: #e8a3a3; }
.btn.danger:hover{ background: rgba(178,59,59,0.15); color:#f2c4c4; }
.btn.small{ padding: 7px 12px; font-size: 12.5px; }
.btn:disabled{ opacity: 0.4; cursor: not-allowed; }

.stat-strip{
  display:grid;
  grid-template-columns: repeat(3,1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 56px;
}
.stat-strip div{
  background: var(--navy-900);
  padding: 20px 18px;
  min-width: 0;
}
.stat-strip .num{
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--accent-bright);
}
.stat-strip .lab{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--paper-dim);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.home-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
@media (max-width: 860px){
  .home-grid{ grid-template-columns: 1fr; }
  .hero{ grid-template-columns: 1fr; }
  .hero-logo{ order:-1; }
}

.panel{
  border: 1px solid var(--line);
  background: rgba(18,32,47,0.55);
  padding: 24px;
  border-radius: var(--radius);
}
.panel h2{
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.03em;
  color: var(--paper);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Announcements ---------- */
.announcement{
  border: 1px solid var(--line);
  border-left: 3px solid var(--steel-500);
  background: rgba(18,32,47,0.45);
  padding: 18px 20px;
  margin-bottom: 16px;
  border-radius: var(--radius);
}
.announcement .meta{
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--steel-300);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.announcement h3{
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.01em;
  margin: 0 0 8px;
  color: var(--paper);
}
.announcement p{ margin:0; color: var(--ice-100); opacity:0.88; white-space: pre-wrap; }
.announcement .admin-row{ margin-top:12px; display:flex; gap:8px; }

.empty-note{
  color: var(--paper-dim);
  font-style: italic;
  padding: 24px 0;
  text-align:center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Gallery ---------- */
.gallery-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.gallery-item{
  position:relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow:hidden;
  background: var(--navy-900);
  aspect-ratio: 4/3;
  cursor: pointer;
}
.gallery-item img{
  width:100%; height:100%; object-fit: cover; display:block;
  transition: transform .3s ease;
}
.gallery-item:hover img{ transform: scale(1.05); }
.gallery-item .cap{
  position:absolute; left:0; right:0; bottom:0;
  background: linear-gradient(0deg, rgba(7,12,20,0.88), transparent);
  color: var(--ice-100);
  font-size:12.5px;
  padding: 18px 10px 8px;
}
.gallery-item .del{
  position:absolute; top:6px; right:6px;
  z-index: 3;
  background: rgba(178,59,59,0.85);
  border:none; color:#fff; width:24px; height:24px; border-radius:50%;
  cursor:pointer; font-size:14px; line-height:1;
  display:flex; align-items:center; justify-content:center;
}

.lightbox{
  position: fixed; inset:0; background: rgba(4,7,12,0.92);
  display:none; align-items:center; justify-content:center;
  z-index: 200; padding: 40px; flex-direction:column; gap:16px;
}
.lightbox.show{ display:flex; }
.lightbox img{ max-width: min(90vw, 900px); max-height: 76vh; border: 1px solid var(--line); }
.lightbox .cap-full{ color: var(--ice-100); font-size:14px; }
.lightbox button.close{
  position:absolute; top:20px; right:24px;
  background:none; border:1px solid var(--line); color:var(--ice-100);
  width:36px; height:36px; border-radius:50%; cursor:pointer; font-size:16px;
}

/* ---------- Subunits ---------- */
.units-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px,1fr));
  gap: 22px;
}
.unit-card{
  border: 1px solid var(--line);
  border-top: 3px solid var(--unit-color, var(--steel-500));
  background: rgba(18,32,47,0.5);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align:center;
}
.unit-card img{
  width: 120px; height:120px; object-fit:contain;
  margin: 0 auto 16px;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.4));
}
.unit-card .tag{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--unit-color, var(--steel-300));
  margin-bottom: 6px;
}
.unit-card h3{
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--paper);
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}
.unit-card p{
  font-size: 14px;
  color: var(--ice-100);
  opacity: 0.82;
  text-align:left;
  margin:0;
}

/* ---------- Compendium ---------- */
.comp-toolbar{
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.comp-search{
  flex:1; min-width: 220px;
  background: var(--navy-900);
  border: 1px solid var(--line);
  color: var(--ice-100);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
/* ---------- Kompendium: układ z panelem spisu treści ---------- */
.comp-layout{
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}
.comp-layout.no-toc{ grid-template-columns: minmax(0, 1fr); }
.comp-layout.no-toc .comp-toc{ display: none; }
.comp-main{ min-width: 0; }

.comp-toc{
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 4px;
}
.comp-toc-title{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel-300);
  margin: 0 0 10px 3px;
}
.comp-toc-list{
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}
.toc-item{
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  margin-left: -1px;
  padding: 8px 12px;
  color: var(--ice-100);
  opacity: 0.72;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, opacity .15s ease, border-color .15s ease;
}
.toc-item:hover{ opacity: 1; background: rgba(124,163,196,0.08); }
.toc-item.active{
  opacity: 1;
  color: var(--md-h1);
  font-weight: 600;
  border-left-color: var(--md-h1);
  background: rgba(77,163,240,0.09);
}

.comp-body{
  border: 1px solid var(--line);
  background: rgba(18,32,47,0.4);
  padding: 32px clamp(18px, 4vw, 46px);
  border-radius: var(--radius);
  max-width: 880px;
}

/* ---------- Renderowany Markdown (Kompendium + Szkolenia) ---------- */
.comp-body .md-h1,
.train-body-inner .md-h1,
.rich-preview .md-h1{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--md-h1);
  margin: 46px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 92px;
}
.comp-body .md-h1:first-child,
.train-body-inner .md-h1:first-child{ border-top: none; margin-top: 0; padding-top: 0; }
.comp-body .md-h2,
.train-body-inner .md-h2,
.rich-preview .md-h2{
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--md-h2);
  margin: 26px 0 8px;
}
.comp-body strong, .train-body-inner strong, .rich-preview strong{ font-weight: 700; color: var(--paper); }
.comp-body em, .train-body-inner em, .rich-preview em{ font-style: italic; }
.comp-body h4{
  font-family: var(--font-body);
  color: var(--paper);
  font-size: 15.5px;
  margin: 18px 0 6px;
}
.comp-body p,
.rich-preview p{
  color: var(--ice-100);
  opacity: 0.86;
  font-size: 14.5px;
  margin: 0 0 10px;
  white-space: pre-wrap;
}
.comp-body mark{ background: rgba(143,198,234,0.35); color: inherit; }
.comp-edit-area{
  width:100%; min-height: 60vh;
  background: var(--navy-950);
  color: var(--ice-100);
  border: 1px solid var(--steel-500);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height:1.6;
}

/* ---------- Szkolenia (rozwijana lista) ---------- */
.train-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}
.train-item{
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(35,64,97,0.35), rgba(18,32,47,0.5));
  overflow: hidden;
}
.train-head-row{ display:flex; align-items:stretch; }
.train-head-row .train-header{ flex: 1; min-width: 0; }
.train-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.01em;
  text-align: left;
  padding: 16px 20px;
  cursor: pointer;
  transition: background .15s ease;
}
.train-header:hover{ background: rgba(124,163,196,0.1); }
.train-header .chev{
  flex-shrink: 0;
  color: var(--steel-300);
  transition: transform .2s ease;
  font-size: 18px;
}
.train-item.open .train-header .chev{ transform: rotate(90deg); color: var(--accent-bright); }
.train-item.open .train-header{ background: rgba(92,143,185,0.12); }
.train-body{
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}
.train-item.open .train-body{ max-height: 60000px; }
.train-body-inner{
  padding: 0 20px 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.train-body-inner h4{
  font-family: var(--font-body);
  color: var(--accent-bright);
  font-size: 14.5px;
  margin: 14px 0 6px;
}
.train-body-inner h4:first-child{ margin-top: 0; }
.train-body-inner p{
  color: var(--ice-100);
  opacity: 0.86;
  font-size: 14.5px;
  margin: 0 0 10px;
  white-space: pre-wrap;
}
.train-body-inner mark{ background: rgba(143,198,234,0.35); color: inherit; }
.train-item.hidden{ display: none; }

/* ---------- Panel administratora — tabela użytkowników ---------- */
.users-table-wrap{
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.users-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
.users-table thead th{
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--steel-300);
  background: rgba(18,32,47,0.7);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.users-table tbody td{
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ice-100);
  vertical-align: middle;
}
.users-table tbody tr:last-child td{ border-bottom: none; }
.users-table tbody tr:hover{ background: rgba(124,163,196,0.06); }
.users-actions{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- Footer ---------- */
footer{
  border-top: 1px solid var(--line);
  padding: 26px 24px 40px;
  text-align:center;
  color: var(--paper-dim);
  font-size: 12.5px;
  position:relative; z-index:1;
}

/* ---------- Modal (login / admin add forms) ---------- */
.modal-backdrop{
  position: fixed; inset:0; background: rgba(4,7,12,0.75);
  display:none; align-items:center; justify-content:center;
  z-index: 300; padding: 20px;
}
.modal-backdrop.show{ display:flex; }
.modal{
  background: var(--navy-800);
  border: 1px solid var(--steel-500);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal.wide{ max-width: 560px; }
.modal h2{
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--paper);
  margin: 0 0 4px;
}
.modal .sub{ color: var(--paper-dim); font-size: 13px; margin-bottom: 20px; }
.field{ margin-bottom: 14px; }
.field label{
  display:block; font-size: 12.5px; color: var(--steel-300);
  margin-bottom: 6px; font-family: var(--font-mono); letter-spacing: 0.04em;
}
.field input, .field textarea, .field select{
  width:100%;
  background: var(--navy-950);
  border: 1px solid var(--line);
  color: var(--ice-100);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
}
.field textarea{ min-height: 110px; resize: vertical; font-family: var(--font-body); }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top: 18px; }
.modal .error{ color: #e8a3a3; font-size: 13px; margin-top: 10px; display:none; }
.modal .error.show{ display:block; }

.discord-divider{
  display:flex; align-items:center; gap:12px;
  margin: 18px 0 14px; color: var(--paper-dim); font-size: 12px;
}
.discord-divider::before, .discord-divider::after{
  content:""; flex:1; height:1px; background: var(--line);
}
.btn.discord{
  width:100%; justify-content:center;
  background: #5865F2; border-color:#5865F2; color:#fff;
}
.btn.discord:hover{ background:#4752c4; color:#fff; }

.toast{
  position: fixed; bottom: 24px; left:50%; transform: translateX(-50%);
  background: var(--navy-800); border:1px solid var(--accent);
  color: var(--ice-100); padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; z-index: 400; opacity:0; pointer-events:none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(-6px); }

.admin-bar{
  display:none;
  background: rgba(178,59,59,0.14);
  border: 1px solid rgba(178,59,59,0.4);
  color: #f0c0c0;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 13px;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
}
body.admin-mode .admin-bar{ display:flex; }
body.admin-mode .admin-only{ display:inline-flex; }
.admin-only{ display:none; }

@media (max-width: 600px){
  .header-inner{ flex-wrap: wrap; }
  nav.tabs{ left:0; right:0; min-width:0; }
  .brandblock .b1{ font-size: 15px; letter-spacing: 0.03em; }
  .brandblock .b2{ display: none; }
}

@media (max-width: 900px){
  .comp-layout{ grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .comp-toc{
    position: static;
    max-height: 240px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(18,32,47,0.5);
    padding: 12px;
  }
  .comp-body .md-h1, .train-body-inner .md-h1{ font-size: 25px; }
}


/* ==========================================================================
   Spis treści kompendium — dodawanie / usuwanie sekcji (tylko admin)
   ========================================================================== */
.comp-toc-head{
  display:flex; align-items:center; justify-content:space-between;
  gap: 8px; margin: 0 0 10px 3px;
}
.comp-toc-head .comp-toc-title{ margin: 0; }
.toc-row{ display:flex; align-items:stretch; }
.toc-row .toc-item{ flex: 1; min-width: 0; }
.toc-del{
  flex-shrink: 0;
  align-items:center; justify-content:center;
  width: 28px;
  background: none; border: none;
  color: var(--steel-300);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: color .15s ease, background .15s ease, opacity .15s ease;
}
.toc-del:hover{ opacity: 1; color: #f2c4c4; background: rgba(178,59,59,0.18); }

/* ==========================================================================
   Szkolenia — przyciski administratora przy każdej pozycji
   ========================================================================== */
.train-admin{
  align-items:center;
  gap: 4px;
  padding: 0 12px 0 4px;
}
.icon-btn{
  width: 32px; height: 32px;
  display:inline-flex; align-items:center; justify-content:center;
  background: rgba(18,32,47,0.6);
  border: 1px solid var(--steel-500);
  border-radius: var(--radius);
  color: var(--ice-100);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover:not(:disabled){ border-color: var(--accent-bright); color: var(--accent-bright); }
.icon-btn.danger{ border-color: var(--danger); color: #e8a3a3; }
.icon-btn.danger:hover:not(:disabled){ background: rgba(178,59,59,0.18); color: #f2c4c4; border-color: var(--danger); }
.icon-btn:disabled{ opacity: 0.3; cursor: not-allowed; }

/* ==========================================================================
   Edytor z podglądem na żywo (kompendium, nowa sekcja, szkolenia)
   ========================================================================== */
.modal.editor-modal{ max-width: 1120px; }
.rich-toolbar{
  display:flex; align-items:center; gap: 6px; flex-wrap: wrap;
  padding: 8px;
  background: rgba(18,32,47,0.7);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.rich-toolbar button{
  min-width: 38px; height: 32px;
  padding: 0 10px;
  background: var(--navy-950);
  border: 1px solid var(--steel-500);
  border-radius: var(--radius);
  color: var(--ice-100);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.rich-toolbar button:hover{ border-color: var(--accent-bright); color: var(--accent-bright); }
.rich-toolbar button[data-md="h1"]{ color: var(--md-h1); }
.rich-toolbar button[data-md="h2"]{ color: var(--md-h2); }
.rich-sep{ width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.rich-panes{
  display:grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.rich-pane{ min-width: 0; display:flex; flex-direction:column; }
.rich-pane + .rich-pane{ border-left: 1px solid var(--line); }
.rich-pane-label{
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--steel-300);
  padding: 6px 12px;
  background: rgba(18,32,47,0.45);
  border-bottom: 1px solid var(--line);
}
.rich-editor .rich-input{
  display:block;
  width: 100%;
  height: 300px;
  min-height: 0;
  resize: vertical;
  border: none;
  border-radius: 0;
  background: var(--navy-950);
  color: var(--ice-100);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}
.rich-editor .rich-input:focus{ outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.rich-editor.tall .rich-input{ height: 46vh; min-height: 240px; }
.rich-preview{
  height: 300px;
  overflow-y: auto;
  padding: 14px 18px;
  background: rgba(18,32,47,0.35);
}
.rich-editor.tall .rich-preview{ height: 46vh; min-height: 240px; }
.rich-preview .md-h1{ font-size: 24px; margin: 22px 0 10px; padding-top: 14px; }
.rich-preview .md-h2{ font-size: 18px; margin: 18px 0 6px; }
.rich-preview .md-h1:first-child, .rich-preview .md-h2:first-child{ margin-top: 0; }
.rich-preview .md-h1:first-child{ border-top: none; padding-top: 0; }
.rich-preview .rich-empty{ opacity: 0.45; font-style: italic; }

@media (max-width: 800px){
  .rich-panes{ grid-template-columns: minmax(0,1fr); }
  .rich-pane + .rich-pane{ border-left: none; border-top: 1px solid var(--line); }
  .rich-editor .rich-input, .rich-preview{ height: 240px; }
  .rich-editor.tall .rich-input, .rich-editor.tall .rich-preview{ height: 34vh; }
  .train-admin{ padding-right: 8px; }
  .icon-btn{ width: 30px; height: 30px; }
}
