:root { 
  --sidebar: 360px;
  --controls-h: 64px;
}
    * { box-sizing: border-box; }
    html, body { height:100%; margin:0; }
    #app { position:relative; height:100%; }
    #map { position:absolute; inset:0; right:var(--sidebar); }
    #sidebar {
      position:absolute; top:0; right:0; width:var(--sidebar); height:100%;
      background:#0b0c10; color:#f3f3f3; border-left:1px solid rgba(255,255,255,.1);
      display:flex; flex-direction:column;
      font: 13px/1.35 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    }
    .head {
      padding:10px 12px;
      border-bottom:1px solid rgba(255,255,255,.1);
      background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.0));
    }
    .head .title { font-weight:700; font-size:14px; }
    .head .meta { opacity:.8; margin-top:4px; }
    #list { overflow:auto; padding:6px; }
    .item {
      display:flex; gap:8px; align-items:center;
      padding:8px; border-radius:10px; margin:6px;
      background:rgba(255,255,255,.04); cursor:pointer;
      border:1px solid transparent;
    }
    .item:hover { background:rgba(255,255,255,.08); }
    .item.active { border-color:#4dd; background:rgba(0,200,255,.1); }
    .sw { width:14px; height:14px; border-radius:50%; background:#d00; flex:0 0 14px; }
    .name { font-weight:600; }
    .sub { opacity:.8; font-size:12px; }
    .actions { display:flex; gap:8px; padding:8px; border-top:1px solid rgba(255,255,255,.1); }
    .btn {
      padding:6px 10px; border-radius:8px;
      border:1px solid rgba(255,255,255,.2); background:rgba(255,255,255,.06);
      color:#fff; font-weight:600; cursor:pointer;
    }
    .btn:disabled { opacity:.5; cursor:not-allowed; }
    /* progress bar removed */
  
/* CONTROLS BAR - stabilny layout z flex */
#timelineWrap {
  position: absolute;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
  color: #fff;
  height: var(--controls-h);
}

#timelineWrap,
#timelineWrap * {
  color: #fff;
}

/* === NOWY MODAL EKSPORTU === */
.export-choice-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(2px);
}

.export-choice-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  max-height: 90%;
  overflow: hidden;
  animation: modalAppear 0.2s ease-out;
}

@keyframes modalAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.export-choice-header {
  padding: 20px 20px 15px;
  background: linear-gradient(135deg, #2196F3, #1976D2);
  color: white;
  position: relative;
}

.export-choice-header h3 {
  margin: 0 30px 0 0;
  font-size: 18px;
  font-weight: 600;
}

.export-choice-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.4;
}

.export-choice-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.export-choice-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.export-choice-buttons {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-choice-btn {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.export-choice-btn:hover {
  border-color: #2196F3;
  background-color: #f8f9ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
}

.export-choice-btn:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.export-choice-icon {
  font-size: 28px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 50%;
  flex-shrink: 0;
}

.export-choice-drive:hover .export-choice-icon {
  background: #e3f2fd;
}

.export-choice-walk:hover .export-choice-icon {
  background: #e8f5e8;
}

.export-choice-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-choice-text strong {
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.export-choice-text span {
  font-size: 14px;
  color: #666;
}

/* Responsywność */
@media (max-width: 480px) {
  .export-choice-modal {
    width: 95%;
    margin: 20px;
  }
  
  .export-choice-header {
    padding: 16px;
  }
  
  .export-choice-header h3 {
    font-size: 16px;
  }
  
  .export-choice-buttons {
    padding: 16px;
  }
  
  .export-choice-btn {
    padding: 14px;
    gap: 12px;
  }
  
  .export-choice-icon {
    font-size: 24px;
    width: 36px;
    height: 36px;
  }
  
  .export-choice-text strong {
    font-size: 15px;
  }
}

/* === KONIEC MODALA EKSPORTU === */

/* === KONIEC PANELU BOCZNEGO === */
.mapboxgl-ctrl-geocoder,
.searchFab,
.mapboxgl-ctrl button[aria-label*="Search"],
.mapboxgl-ctrl button[aria-label*="Szukaj"] {
  display: none !important;
}

/* === WYSZUKIWARKA W PANELU BOCZNYM === */
#list .item.hide {
  display: none !important;
}

    /* Pozycjonowanie na desktopie */
    @media screen and (min-width: 1025px) {
      #timelineWrap {
        position: absolute !important;
        left: 20px !important;
        bottom: 26px !important;
        transform: none !important;
        width: 48%;
        min-width: 480px;
      }
    }
    
    /* PRZYCISKI I SELECT - stała szerokość */
    #timelineWrap .btn.chip,
    #timelineWrap select.chip {
      flex: 0 0 auto;
      min-width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 10px;
      white-space: nowrap;
      box-sizing: border-box;
    }
    
    #timelineWrap .btn.chip.icon {
      flex: 0 0 36px;
      width: 36px;
      padding: 0;
    }
    
    /* LICZNIK CZASU - stałe miejsce 11ch */
#timelineWrap #timeCounter.chip {
  flex: 0 0 11ch;
  min-width: 11ch;
  max-width: 11ch;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  overflow: hidden;
  color: #fff;
}    #timelineWrap #timeCounter .now,
    #timelineWrap #timeCounter .sep,
    #timelineWrap #timeCounter .total {
      display: inline;
    }
    
    /* SUWAK - pełna dostępna szerokość */
    #timeline {
      flex: 1;
      min-width: 0;
      max-width: none;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      height: 10px;
      background: transparent;
      margin: 0;
      outline: none;
      box-sizing: border-box;
    }
    
    /* TRACK - zaokrąglone końce */
    #timeline::-webkit-slider-runnable-track {
      width: 100%;
      height: 10px;
      background: rgba(255,255,255,0.25);
      border-radius: 999px;
      border: none;
    }
    
    #timeline::-moz-range-track {
      width: 100%;
      height: 10px;
      background: rgba(255,255,255,0.25);
      border-radius: 999px;
      border: none;
    }
    
    /* THUMB - wycentrowany */
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  margin-top: -4px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
  cursor: pointer;
}

#timeline::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
  cursor: pointer;
}    /* HOVER */
    #timeline:focus {
      outline: none;
    }
    
    #timeline:hover::-webkit-slider-runnable-track,
    #timeline:hover::-moz-range-track {
      background: rgba(255,255,255,0.35);
    }
    
    /* UKRYWANIE LICZNIKA BEZ WPŁYWU NA LAYOUT */
    #timelineWrap.hidden-counter #timeCounter {
      visibility: hidden;
    }

    /* === Responsive tweaks === */
    #sidebarToggle{
      position:absolute; top:12px; left:12px; z-index:6;
      display:none; align-items:center; gap:8px;
      padding:8px 12px; border-radius:10px;
      background:rgba(0,0,0,.55); color:#fff; border:1px solid rgba(255,255,255,.2);
      box-shadow:0 4px 12px rgba(0,0,0,.3); cursor:pointer;
      backdrop-filter: blur(6px);
    }
    #sidebarToggle .bar{ width:18px; height:2px; background:#fff; display:block; border-radius:2px; }
    #sidebarToggle .bar + .bar{ margin-top:3px; }

    @media (max-width: 1024px){
      :root { --sidebar: 320px; }
      #timelineWrap{ width:62%; bottom:18px; }
    }
    @media (max-width: 768px){
      :root { 
        --sidebar: 84vw;
        --controls-h: 72px;
      }
      #map { right:0 !important; }
      #sidebar { width: var(--sidebar); right:0; transform: translateX(100%); transition: transform .25s ease; }
      body.sidebar-open #sidebar { transform: translateX(0); }
      #sidebarToggle { display:flex; }
      #timelineWrap{ width: 90%; left:50%; transform: translateX(-50%); bottom: 14px; }
      .btn { padding:10px 14px; }
      .item { padding:10px; }
      .title { font-size:18px; }
    }

  
    /* === FAB (Menu) === */
    #fabMenu{
      position: fixed;
      right: 16px;
      bottom: calc(var(--controls-h) + 16px);
      z-index: 1002;
      width:56px; height:56px; border-radius:50%;
      background:rgba(0,0,0,.6); color:#fff; border:1px solid rgba(255,255,255,.25);
      display:flex; align-items:center; justify-content:center;
      box-shadow:0 6px 16px rgba(0,0,0,.35); cursor:pointer;
      backdrop-filter: blur(6px);
      transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
    }
    #fabMenu:active{ transform: scale(.96); }
    #fabMenu .bars{
      position:relative; width:22px; height:16px;
    }
    #fabMenu .bar{
      position:absolute; left:0; right:0; height:2px; border-radius:2px; background:#fff;
      transition: transform .22s ease, opacity .18s ease, top .22s ease;
    }
    #fabMenu .bar.b1{ top:0; }
    #fabMenu .bar.b2{ top:7px; }
    #fabMenu .bar.b3{ top:14px; }
    /* morph to X when open */
    body.sheet-open #fabMenu .bar.b1{ top:7px; transform: rotate(45deg); }
    body.sheet-open #fabMenu .bar.b2{ opacity:0; }
    body.sheet-open #fabMenu .bar.b3{ top:7px; transform: rotate(-45deg); }

    /* When timeline is visible, nudge FAB up a bit */
    body.timeline-visible #fabMenu{ bottom: 132px; right: 16px; z-index: 10; }

    /* Bottom sheet behavior on phones */
    @media (max-width: 768px){
      #sidebar { 
        width:100vw; left:0; right:0; bottom:0; top:auto;
        height:70vh; margin:0; border-radius:16px 16px 0 0;
        transform: translateY(100%); transition: transform .25s ease;
        background: rgba(0,0,0,.66); border:1px solid rgba(255,255,255,.2);
      }
      body.sheet-open #sidebar{ transform: translateY(0); }
      /* Remove old right-drawer rules */
      #map { right:0 !important; }
      #sidebarToggle{ display:none !important; }
    }

    @media (min-width: 769px){
      /* hide FAB on larger screens */
      #fabMenu{ display:none; }
      /* keep original sidebar layout open */
      body.sheet-open #sidebar{ transform:none; }
    }

  
    .actions-top{
      position: sticky; top: 0; z-index: 3;
      display:flex; justify-content:flex-end; gap:8px;
      padding:8px; margin:0; background:rgba(0,0,0,.45);
      border-bottom:1px solid rgba(255,255,255,.15);
      backdrop-filter: blur(6px);
    }

    /* === Control chips === */
    .chip{
      background: rgba(0,0,0,.45);
      border: 1px solid rgba(255,255,255,.25);
      border-radius: 10px;
      box-shadow: 0 2px 8px rgba(0,0,0,.25);
    }
    #btnPause.chip{ padding:8px 14px; }
    #speedSelect.chip{ height:34px; padding:0 10px; }

    /* Licznik czasowy nie może być powtórzony - używamy tylko tego z górnej sekcji */

  
    /* Prevent page scroll & layout shift when sheet is open */
    body.sheet-open{
      overflow: hidden;
      padding-right: var(--sbw, 0px); /* scrollbar width compensation */
    }
    /* Bottom sheet fixed + internal scroll on mobile/tablet */
    @media (max-width: 1024px){
      #sidebar{
        position: fixed;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
      }
    }

  
    /* Force FAB above the bar */
    body.timeline-visible #fabMenu{
      bottom: 132px !important;
      right: 16px !important;
      z-index: 10 !important;
    }

  
    /* Sidebar item highlighting */
    #list .item{
      display:flex; gap:15px; align-items:center; padding:10px;
      border-radius:12px; cursor:pointer;
      transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
      margin-bottom: 4px;
    }
    #list .item:hover{ background: rgba(255,255,255,.06); }
    #list .item.active{
      background: rgba(0,0,0,.35);
      box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 6px 16px rgba(0,0,0,.25);
    }
    
    /* Trail image styling */
    #list .item .trail-image {
      width: 70px;
      height: 70px;
      flex: 0 0 70px;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0 2px 5px rgba(0,0,0,0.3);
      position: relative;
    }
    
    #list .item .trail-image img {
      width: 130%;
      height: 130%;
      object-fit: cover;
      position: absolute;
      left: -15%;
      top: -15%;
      object-position: center;
      transition: transform 0.3s ease;
    }
    
    #list .item:hover .trail-image img {
      transform: scale(1.1);
    }
    
    #list .item.active .trail-image img {
      transform: scale(1.15);
    }
    
    /* Trail content styling */
    #list .item .trail-content {
      display: flex;
      flex: 1;
      gap: 10px;
      align-items: center;
    }
    
    #list .item .sw{
      width:14px; height:14px; border-radius:50%;
      box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 0 4px rgba(255,255,255,.12) inset;
      flex:0 0 auto;
      transform: scale(1); transition: transform .12s ease;
    }
    #list .item.active .sw{ transform: scale(1.2); }
    #list .item .name{ font-weight:600; }
    #list .item .sub{ opacity:.8; font-size:.9em; }

  
    /* Download button */
    #btnDownload.btn.chip{ padding:8px 14px; }
    /* Hide UI overlays during export for a clean shot */
    body.exporting #sidebar,
    body.exporting #timelineWrap,
    body.exporting #fabMenu{
      display:none !important;
    }

  
    /* Icon-only download button */
    #btnDownload.btn.icon{
      padding: 8px;
      width: 40px;
      display: inline-flex; align-items: center; justify-content: center;
      gap: 0;
    }
    #btnDownload.btn.icon svg{ display:block; }

    .loader {
    position: absolute; inset: 0; display: none; place-items: center;
    background: rgba(0,0,0,.25); backdrop-filter: blur(2px); z-index: 10;
    font: 600 14px system-ui; color: #fff;
    }
    .loader.active { display: grid; }
    
    /* === PATCH: porządek układu === */

/* 1) Grid – desktop/tablet */
#app {
  display: grid;
  grid-template-columns: 1fr min(var(--sidebar, 360px), 32vw);
  grid-template-rows: 100dvh;
  gap: 0;
  position: relative;
}

/* mapa = lewa kolumna, sidebar = prawa kolumna */
#map {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  height: 100%;
  width: 100%;
  min-height: 80vh;
}

/* sidebar w siatce (BEZ position:absolute na desktopie) */
#sidebar {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  position: static;            /* nadpisanie wcześniejszego absolute */
  height: 100%;
  overflow: auto;
  background: #0b0c10;
  color: #f3f3f3;
  border-left: 1px solid rgba(255,255,255,.1);
}

/* 2) Timeline na dole siatki, pełna szerokość */
#timelineWrap {
  grid-column: 1 / -1;
  grid-row: 1 / 2;
  align-self: end;
  width: 100%;
  left: 0; right: 0;           /* nadpisanie wcześniejszego center-abs */
  transform: none;             /* nadpisanie */
  position: static;            /* nadpisanie */
  display: flex;               /* JS może przełączać display, ale bazowo widoczne */
}

/* 3) Mobile: bottom-sheet jak chciałaś (tu wraca fixed) */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  #sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100vw;
    height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform .25s ease;
    background: rgba(0,0,0,.66);
    border: 1px solid rgba(255,255,255,.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.sheet-open #sidebar { transform: translateY(0); }

  /* timeline podniesiony nad dolną krawędź i w kolumnie */
  #timelineWrap {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    width: 90%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}

/* 4) Posprzątaj kolizje – usuń wymuszanie right na mapie */
#map { right: auto !important; }

/* 5) FAB przesunięcie gdy timeline widoczny (zostawiasz jak miałaś) */


/* === PATCH: pasek sterowania w poziomie === */
#timelineWrap{
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start;
  gap: 12px;
  position: fixed;             /* jeśli chcesz go „doklejonego” na dole */
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(1000px, 92vw);
}

/* elementy obok siebie; suwak rozciąga się */
#btnPause, #btnDownload, #speedSelect, #timeCounter { flex: 0 0 auto; }
#timeline { flex: 1 1 auto; }

/* Na bardzo wąskich ekranach pozwól zawijać do dwóch rzędów zamiast kolumny */
@media (max-width: 520px){
  #timelineWrap{
    flex-wrap: wrap;
  }
  #timeline{ flex-basis: 100%; order: 2; } /* suwak w drugim rzędzie, pełna szerokość */
}

/* Mapa na pełną wysokość okna */
#map { 
  min-height: 100dvh !important;   /* było 80vh */
  height: 100dvh !important;
}

/* Strona bez tła i zbędnych marginesów */
html, body { height: 100%; margin: 0; background: transparent; }

/* Kontener ma minimum wysokości okna, by nic nie „wystawało” poniżej mapy */
#app { min-height: 100dvh; }

/* (opcjonalnie) brak horyzontalnego scrolla od cieni/zaokrągleń */
body { overflow-x: hidden; }

/* Style dla etykiet popup - przezroczyste tło */
.mapboxgl-popup-content {
  background-color: rgba(0, 0, 0, 0.2) !important; 
  color: white !important;
  padding: 10px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(4px) !important;
}

/* Style dla strzałki popup */
.mapboxgl-popup-tip {
  border-top-color: rgba(0, 0, 0, 0.7) !important;
  border-bottom-color: rgba(0, 0, 0, 0.7) !important;
}

/* Formatowanie tekstu w popupie */
.mapboxgl-popup-content strong {
  color: #00FFFF !important;
  margin-bottom: 4px !important;
  display: block !important;
}

/* Style dla niestandardowych okien dialogowych */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
  backdrop-filter: blur(2px);
}

.custom-modal-dialog {
  background-color: rgba(30, 30, 40, 0.85);
  color: white;
  border-radius: 12px;
  padding: 20px;
  width: 340px;
  max-width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  animation: slideUp 0.3s ease-out;
}

.custom-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #00FFFF;
  flex: 1;
}

/* Header z tytułem i przyciskiem X */
.custom-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* Przycisk X do zamykania */
.custom-modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ff4444;
  transform: scale(1.1);
}

.custom-modal-content {
  margin-bottom: 20px;
}

.custom-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.custom-modal-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
}

.custom-modal-btn-primary {
  background-color: #00FFFF;
  color: #111;
}

.custom-modal-btn-primary:hover {
  background-color: #0dffff;
  transform: translateY(-1px);
}

.custom-modal-btn-secondary {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.custom-modal-btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.custom-modal-overlay.closing {
  animation: fadeOut 0.2s ease-in forwards;
}

.custom-modal-dialog.closing {
  animation: slideDown 0.25s ease-in forwards;
}

/* === Wyszukiwarka === USUNIĘTA - zastąpiona searchBox w panelu bocznym */
/*
/* Główny kontener wyszukiwarki */
.search-control {
  position: absolute;
  top: 10px; /* Pozycja obok kontrolek zoom */
  right: 50px; /* Trochę miejsca od prawej krawędzi, tuż obok panelu zoom */
  left: auto;
  z-index: 10;
  display: flex;
  align-items: center;
}

/* Przycisk z ikoną lupy */
.search-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 11;
  padding: 0;
  backdrop-filter: blur(5px);
}

.search-toggle-btn svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.search-toggle-btn:hover {
  background: rgba(0,0,0,0.7);
  border-color: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

/* Wysuwany pasek wyszukiwania */
.search-bar {
  position: absolute;
  right: 42px; /* Umiejscowienie tak, żeby pasek rozwijał się w lewo */
  left: auto;
  top: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 21px;
  height: 42px;
  display: flex;
  align-items: center;
  padding-right: 42px; /* Miejsce na ikonę lupy */
  padding-left: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  transition: width 0.3s ease, opacity 0.2s ease;
  width: 0;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(5px);
  direction: rtl; /* Sprawiamy, że elementy są wyrównane od prawej */
}

.search-control.active .search-bar {
  width: 280px; /* Szerokość po rozwinięciu */
  opacity: 1;
  pointer-events: all;
  right: 42px; /* Umiejscowienie względem prawej krawędzi */
  transform: translateX(-100%); /* Przesunięcie w lewo o całą szerokość */
}

/* Pole input */
.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 15px;
  padding: 0;
  height: 100%;
  outline: none;
  width: 100%;
  direction: ltr; /* Przywracamy normalny kierunek tekstu */
}

.search-bar input::placeholder {
  color: rgba(255,255,255,0.5);
}

/* Przycisk zamykania */
.search-close-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
  direction: ltr; /* Przywracamy normalny kierunek */
}

.search-close-btn:hover {
  background: rgba(255,255,255,0.1);
}

.search-close-btn svg {
  width: 18px;
  height: 18px;
  fill: rgba(255,255,255,0.7);
}

/* Wyniki wyszukiwania */
.search-results {
  position: absolute;
  top: 50px;
  right: 50px; /* Wyrównanie do prawej strony, przy ikonie lupy */
  left: auto;
  width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(0,0,0,0.7);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
  z-index: 9;
  display: none;
  backdrop-filter: blur(8px);
  transform: translateX(-100%); /* Przesunięcie w lewo */
}

.search-control.with-results .search-results {
  display: block;
}

/* Animacja przejścia między stanem zamkniętym a otwartym */
.search-toggle-btn {
  transition: transform 0.3s ease, border-radius 0.3s ease, background 0.2s ease;
}

.search-control.active .search-toggle-btn {
  border-radius: 50% 0 0 50%; /* Zaokrąglenie tylko po lewej stronie */
  transform: translateX(-20px); /* Przesuń w lewo */
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.search-control.active .search-toggle-btn svg {
  opacity: 0;
}

/* Style dla wyników wyszukiwania */
.search-result-item {
  padding: 12px 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-result-item:hover {
  background: rgba(255,255,255,0.1);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: rgba(255,255,255,0.2);
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-result-icon svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.search-result-content {
  flex: 1;
}

.search-result-title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.search-result-description {
  margin: 3px 0 0;
  font-size: 13px;
  opacity: 0.7;
}

/* Stany responsywne */
@media (max-width: 768px) {
  .search-control.active .search-bar {
    width: calc(100vw - 120px); /* Szersza wyszukiwarka na mobilnych */
  }
  
  .search-results {
    width: calc(100vw - 60px);
    right: 50px;
    transform: translateX(-100%);
  }
  
  /* Na mobilnych ekranach delikatnie dostosowujemy pozycję */
  .search-control {
    top: 10px;
    right: 50px;
  }
}

/* Animacja wejścia/wyjścia dla wyników */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-control.with-results .search-results {
  animation: fadeIn 0.2s ease forwards;
}

.search-no-results {
  padding: 30px;
  text-align: center;
  color: rgba(255,255,255,0.7);
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(10px); opacity: 0; }
}
*/

/* Wyszukiwarka w panelu bocznym */
#searchBox{
  display:flex; align-items:center; gap:8px;
  padding:8px 10px; margin:8px 0; border-radius:10px;
  background: rgba(0,0,0,.45); border:1px solid rgba(255,255,255,.25);
  flex: 1;
}
#searchInput{
  flex:1 1 auto; min-width:0;
  background:transparent; border:0; outline:0;
  color:#fff; font: 600 14px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
#searchInput::placeholder{ color: rgba(255,255,255,.7); }
#searchClear{
  flex:0 0 auto; width:28px; height:28px; border-radius:8px;
  border:1px solid rgba(255,255,255,.25); background:rgba(255,255,255,.08);
  color:#fff; cursor:pointer; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
#searchClear:hover{
  background:rgba(255,255,255,.15);
}
#list .item.hide{ display:none !important; }

.actions-top{
  display: flex;
  gap: 8px;
  align-items: center;
}

/* neutralne style kart i aktywnej karty */
#list .item{
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: none;
}
#list .item.active{
  background: rgba(0,0,0,.35) !important;
  border-color: rgba(255,255,255,.14) !important;
  box-shadow: none !important;
}
#list .item:focus,
#list .item:focus-visible{ outline: none !important; }

/* jeśli używamy highlight dla tekstu, niech będzie delikatny */
#list .item .name .highlight{
  background: rgba(255,255,255,.18);
  border-radius: 4px;
  padding: 0 2px;
}

/* kontener wyszukiwarki – jedna linia, środkowanie pionowe */
#searchBox{
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

/* pole i X nie łamią się, X nie „spada" niżej */
#searchInput{
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 8px 10px;
}

#searchClear{
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  line-height: 1;
  vertical-align: middle;
}
#searchClear > svg,
#searchClear > span{
  display: block;
}

/* awaryjnie wyłącz wpływ float/position, które mogły zepchnąć X w dół */
#searchClear{ position: static !important; float: none !important; }

/* ukryj natywny X w polu search (WebKit/Chromium/Safari) */
#searchInput[type="search"]::-webkit-search-cancel-button{
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
/* Edge/IE dziedziczą po MS */
#searchInput::-ms-clear,
#searchInput::-ms-reveal{
  display: none;
  width: 0;
  height: 0;
}
/* na wszelki wypadek wyłącz własne tło/cancel */
#searchInput{
  background-repeat: no-repeat;
  background-position: right 8px center;
}
