:focus-visible {
  outline: 3px solid #ffcc00 !important;  /* Kontrastowy kolor (np. żółty) */
  outline-offset: 3px !important;
  z-index: 9999 !important;               /* Fokus nad innymi */
  position: relative;
}

#keyboard-container {
  position: fixed;
  bottom: 5%;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 10050;
  background: #f5f5f5;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
  width: 90vw;
  max-width: 900px;
  width: 100%;
  border-radius: 12px 12px 0 0;
}

input#colorPicker[type="range"] {
  width: 100%;
  height: 14px;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  margin-top: 8px;
  background: linear-gradient(
    to right,
    red 0%,
    magenta 10%,
    blue 20%,
    cyan 30%,
    lime 40%,
    yellow 50%,
    orange 60%,
    black 75%,
    white 100%
  );
}

input#colorPicker[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0057d9;
  border: 2px solid white;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  margin-top: -3px;
}

input#colorPicker[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0057d9;
  border: 2px solid white;
  cursor: pointer;
}

.color-buttons.new {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.color-buttons.new button {
  flex: 1;
  padding: 10px;
  border: none;
  margin: 0 5px;
  border-radius: 20px;
  background: #eee;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.color-buttons.new button.active {
  background: #0057d9;
  color: white;
}

/* Przyciski WCAG toggle */

#accessibility-toggle {
  position: fixed;
  top: auto;
  right: auto;
  bottom: 16px;
  left: 16px;
  font-size: 30px;
  z-index: 10001;
  background: #0057d9;
  color: white;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

#accessibility-toggle:focus-visible {
  outline: 3px solid #ffbf00;
  outline-offset: 3px;
}

#accessibility-menu {
  display: none;
  position: fixed;
  top: auto;
  right: auto;
  bottom: 78px;
  left: 16px;
  background: #fff;
  padding: 20px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 10000;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-family: sans-serif;
}

#accessibility-menu button {
  display: inline-flex;
  align-items: center;
  margin: 5px;
  padding: 10px;
  font-size: 14px;
  background: #f0f0f0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

#accessibility-menu button:hover {
  background: #e0e0e0;
}

#accessibility-menu i {
  margin-right: 10px;
  min-width: 20px;
  text-align: center;
}

#accessibility-menu .section {
  margin-top: 15px;
  border-top: 1px solid #ddd;
  padding-top: 10px;
}

#colorPicker {
  width: 100%;
  height: 30px;
  margin-top: 5px;
}

#accessibility-menu .color-buttons button {
  margin: 2px;
}


/* Tryb kontrastu */
body.contrast *:not(#accessibility-menu):not(#accessibility-menu *):not(#accessibility-toggle):not(#accessibility-toggle *) {
  background-color: black !important;
  color: yellow !important;
}
body.contrast a *:not(#accessibility-menu):not(#accessibility-menu *):not(#accessibility-toggle):not(#accessibility-toggle *) {
  color: cyan !important;
}
body.contrast img *:not(#accessibility-menu):not(#accessibility-menu *):not(#accessibility-toggle):not(#accessibility-toggle *) {
  filter: invert(1);
}

/* Jasny kontrast */
body.contrast-light *:not(#accessibility-menu):not(#accessibility-menu *):not(#accessibility-toggle):not(#accessibility-toggle *):not(#accessibility-menu button):not(#accessibility-menu i):not(#accessibility-menu .section) {
  background-color: white !important;
  color: black !important;
  border-color: #000 !important;
}

body.contrast-light a:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light button:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light input[type="button"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light input[type="submit"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light input[type="text"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light select:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light textarea:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast-light [role="button"]:not(#accessibility-menu *):not(#accessibility-toggle *) {
  outline: 1px dashed #000 !important;
  outline-offset: 1px !important;
  border: none !important;
  color: black !important;
  background-color: white !important;
}


body.contrast a:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast button:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast input[type="button"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast input[type="submit"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast input[type="text"]:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast select:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast textarea:not(#accessibility-menu *):not(#accessibility-toggle *),
body.contrast [role="button"]:not(#accessibility-menu *):not(#accessibility-toggle *) {
  outline: 1px dashed yellow !important;
  outline-offset: 1px !important;
  border: none !important;
  color: yellow !important;
  background-color: black !important;
}



body.contrast-light a *:not(#accessibility-menu *){
  color: #003366 !important;
  text-decoration: underline !important;
}
body.contrast-light button *:not(#accessibility-menu *){
  background-color: #eee !important;
  color: #000 !important;
  border: 1px solid #000 !important;
}
body.contrast-light h1,
body.contrast-light h2,
body.contrast-light h3,
body.contrast-light h4,
body.contrast-light h5,
body.contrast-light h6 *:not(#accessibility-menu *){
  color: #111 !important;
}
body.contrast-light table *:not(#accessibility-menu *),
body.contrast-light th *:not(#accessibility-menu *),
body.contrast-light td *:not(#accessibility-menu *){
  background-color: white !important;
  color: black !important;
  border-color: #000 !important;
}
body.contrast-light input *:not(#accessibility-menu *),
body.contrast-light textarea,
body.contrast-light select *:not(#accessibility-menu *){
  background-color: white !important;
  color: black !important;
  border: 1px solid #000 !important;
}
body.contrast-light img {
  filter: none !important;
}
body.contrast-light .dark,
body.contrast-light .footer,
body.contrast-light .banner,
body.contrast-light .navbar {
  background-color: white !important;
  color: black !important;
}

/* Monochromatyczny filtr */
body.monochrome * *:not(#accessibility-menu):not(#accessibility-menu *) {
  filter: grayscale(100%) !important;
}

/* Czytelna czcionka */
body.accessible-font *:not(#accessibility-menu):not(#accessibility-menu *):not(#accessibility-toggle):not(#accessibility-toggle *) {
  font-family: Arial, sans-serif !important;
}



body.cursor-white {
  cursor: url('/cursor/cursor-white-large.cur'), auto !important;
}

body.cursor-black {
  cursor: url('/cursor/cursor-black-large.cur'), auto !important;
}

body.cursor-white a,
body.cursor-white button,
body.cursor-white [role='button'],
body.cursor-white input[type='button'],
body.cursor-white input[type='submit'],
body.cursor-white label,
body.cursor-white select {
  cursor: url('/cursor/hand-cursor-large.cur'), pointer !important;
}

body.cursor-black a,
body.cursor-black button,
body.cursor-black [role='button'],
body.cursor-black input[type='button'],
body.cursor-black input[type='submit'],
body.cursor-black label,
body.cursor-black select {
  cursor: url('/cursor/hand-cursor-black-large.cur'), pointer !important;
}

#font-preview {
  position: fixed;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  font-size: 24px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: Arial, sans-serif;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10002;
  max-width: 400px;
  white-space: normal; /* zamiast nowrap */
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  visibility: hidden;
}

#font-preview.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.font-controls {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.font-option {
  flex: 1;
  margin: 0 3px;
  padding: 8px;
  background: #f0f0f0;
  border: none;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
}
.font-option.active {
  background: #0057d9;
  color: white;
}
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-wrapper input[type='range'] {
  flex: 1;
}


#accessibility-menu button.selected {
  border: 2px solid #0057d9;
  background-color: #ffffff;
  position: relative;
}

#accessibility-menu button.selected::after {
  content: "✔";
  color: #0057d9;
  font-size: 12px;
  position: absolute;
  top: 3px;
  right: 4px;
}

#accessibility-menu .toggle-btn {
  font-weight: bold;
  transition: all 0.2s;
  position: relative;
  cursor: pointer;
}

#accessibility-menu .toggle-btn.active {
  background-color:rgb(10, 32, 105);
  color: white;
}

.cursor-btn.active {
  background-color: #00124c;
  color: white;
  font-weight: bold;
}

/* ── Motyw panelu: jawne kolory (jasny / ciemny) ─────────────
   Panel musi definiować własny `color`. Motyw strony ustawia
   `body.gn-modern { color: var(--gn-text) !important }`, więc w trybie
   ciemnym tekst dziedziczony był jasny na białym tle panelu.
   Stąd `!important` — inaczej reguła z motywu wygrywa. */
#accessibility-menu {
  --wcag-panel: #ffffff;
  --wcag-panel-border: #cccccc;
  --wcag-text: #17222f;
  --wcag-muted: #4a5b6b;
  --wcag-btn: #f0f0f0;
  --wcag-btn-hover: #e0e0e0;
  --wcag-section-border: #dddddd;
  --wcag-accent: #0057d9;
}

body.dark-mode #accessibility-menu {
  --wcag-panel: #132a23;
  --wcag-panel-border: #29463d;
  --wcag-text: #e8eef5;
  --wcag-muted: #9fb0c3;
  --wcag-btn: #1d3b32;
  --wcag-btn-hover: #26493d;
  --wcag-section-border: #29463d;
  --wcag-accent: #7fb3ff;
}

#accessibility-menu {
  background: var(--wcag-panel) !important;
  border-color: var(--wcag-panel-border) !important;
  color: var(--wcag-text) !important;
}

#accessibility-menu p,
#accessibility-menu label,
#accessibility-menu legend {
  color: var(--wcag-text) !important;
}

#accessibility-menu small {
  color: var(--wcag-muted) !important;
}

#accessibility-menu button,
#accessibility-menu .color-buttons.new button,
#accessibility-menu .font-option,
#accessibility-menu .slider-wrapper button {
  background: var(--wcag-btn) !important;
  color: var(--wcag-text) !important;
}

#accessibility-menu button:hover,
#accessibility-menu .color-buttons.new button:hover,
#accessibility-menu .font-option:hover {
  background: var(--wcag-btn-hover) !important;
}

#accessibility-menu button i {
  color: inherit !important;
}

#accessibility-menu .section {
  border-top-color: var(--wcag-section-border) !important;
}

/* Stany aktywne — powtórzone z `!important`, bo reguła bazowa powyżej
   też jest `!important` i inaczej zgasiłaby podświetlenie.
   Kolory jak w trybie jasnym; białe napisy na granacie są czytelne
   również na ciemnym panelu. */
#accessibility-menu .cursor-btn.active {
  background-color: #00124c !important;
  color: #ffffff !important;
}

/* Po `.cursor-btn`, bo przyciski kursora mają obie klasy — tak jak dotąd
   wygrywa granat z `.toggle-btn`. */
#accessibility-menu .toggle-btn.active {
  background-color: rgb(10, 32, 105) !important;
  color: #ffffff !important;
}

#accessibility-menu .color-buttons.new button.active,
#accessibility-menu .font-option.active {
  background-color: #0057d9 !important;
  color: #ffffff !important;
}

/* `selected` miał na sztywno białe tło — w trybie ciemnym dawało to
   jasny tekst na białym tle. */
#accessibility-menu button.selected {
  background-color: var(--wcag-panel) !important;
  color: var(--wcag-text) !important;
  border: 2px solid var(--wcag-accent) !important;
}

#accessibility-menu button.selected::after {
  color: var(--wcag-accent) !important;
}

/* Wirtualna klawiatura — klawisze niezależne od motywu strony */
body.dark-mode #keyboard-container {
  background: #0d211c;
}

body.dark-mode #keyboard-container .hg-button {
  background: #1d3b32 !important;
  color: #e8eef5 !important;
}

@media (max-width: 1200px) {
  #accessibility-menu {
    width: 95vw;
    right: auto;
    left: 2.5vw;
    max-height: 80vh;
    overflow-y: auto;
    padding: 16px;
    font-size: 14px;
  }

  #accessibility-toggle {
    top: auto;
    right: auto;
    bottom: 12px;
    left: 12px;
  }

  #accessibility-menu button {
    width: 100%;
    justify-content: flex-start;
    font-size: 14px;
  }

  .color-buttons.new {
    flex-direction: column;
  }

  .color-buttons.new button {
    margin: 4px 0;
  }

  .font-controls {
    flex-direction: column;
    gap: 5px;
  }

  .slider-wrapper {
    flex-direction: column;
  }
}
