/* ========== Reset & zmienne ========== */
:root{
  --bg: #ffffff;
  --txt: #1f2937;           /* neutral-800 */
  --muted: #6b7280;         /* neutral-500 */
  --ring: #2563eb;          /* blue-600 */
  --surface: #ffffff;
  --border: #e5e7eb;        /* neutral-200 */
  --btn-bg: #f3f4f6;        /* neutral-100 */
  --btn-bg-hover: #e5e7eb;
  --footer-bg: #f2f2f2;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.08);
}

@media (prefers-color-scheme: dark){
  :root{
    --bg: #202124;
    --txt: #e8eaed;
    --muted: #9aa0a6;
    --ring: #8ab4f8;
    --surface: #202124;
    --border: #3c4043;
    --btn-bg: #303134;
    --btn-bg-hover: #3c4043;
    --footer-bg: #171717;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.45);
  }
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
html{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
               Noto Sans, Arial, sans-serif;
  line-height: 1.5;
}
body{
  margin:0;
  color: var(--txt);
  background: var(--bg);
}

/* ========== Ukryty tekst dla czytników ekranu ========== */
.sr-only{
  position:absolute!important;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

/* ========== Topbar ========== */
.topbar{
  /* position: sticky; */
  top: 0;
  backdrop-filter: saturate(150%) blur(6px);
}
.nav{
  display:flex; align-items:center; justify-content:space-between;
  gap:.5rem;
  padding:.75rem 1rem;
}
.nav-link{
  color: var(--txt); text-decoration:none; font-size:.875rem; font-family: Arial, Sans-serif;
  padding:.25rem .5rem; border-radius:.5rem;
}
.nav-link:hover{ text-decoration: underline; }
.nav-right, .nav-left{ display:flex; align-items:center; gap:.5rem; }

.icon-btn{
  display:inline-grid; place-items:center;
  width:36px; height:36px; border-radius:9999px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
}
.icon-btn:hover{ background: var(--btn-bg); color: var(--txt); }
.icon-btn:focus-visible{
  outline: 3px solid color-mix(in oklab, var(--ring) 65%, transparent);
  outline-offset: 2px;
}
.icon-btn svg{ width:20px; height:20px; }
.login-btn {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--ring);
  padding: 0.45rem 1rem;
  border-radius: 15px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.login-btn:hover {
  opacity: .92;
}

.login-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(66,133,244,0.5);
}
.avatar{
  display:inline-grid; place-items:center;
  width:36px; height:36px; border-radius:9999px;
  border:1px solid var(--border);
  background: linear-gradient(135deg,#6a5acd 0%, #00d4ff 100%);
  color:#fff;
  margin-left:.25rem;
}
.avatar svg{ width:20px; height:20px; fill:#fff; stroke:#fff; stroke-width:1.5; }

/* ========== Main ========== */
.main{
  min-height: calc(100dvh - 165px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* padding: 8vh 1rem 0px; */
}
.logo{
  margin: 0 0 1rem 0;
  text-align:center;
}
.logo-svg{
  width:min(272px, 80vw);
  height:auto;
  display:block;
  margin-inline:auto;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.08));
}
.logo-img{
  width: min(480px, 80vw);
  height: auto;
  display: block;
  margin-inline: auto;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.08));
}
.brand .brand-logo{
  height: 35px;   /* jak poprzednio – dopasowane do headera */
  width: auto;
  display: block;
}

/* ========== Pasek wyszukiwania ==*/
.search{ width:100%; max-width: 640px; margin-inline:auto; }
.searchbar{
  display:flex; align-items:center; gap:.5rem;
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 9999px;
  padding: .5rem .75rem .5rem .75rem;
  box-shadow: var(--shadow);
}
.searchbar:focus-within{
  border-color: color-mix(in oklab, var(--ring) 70%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 18%, transparent), var(--shadow);
}
.search-icon{
  width:20px; height:20px; color: var(--muted);
  margin-left:.25rem;
  fill: currentColor;
}
.search input{
  flex:1; border:0; outline:0; background:transparent;
  font-size:clamp(16px, 2.4vw, 18px);
  padding:.5rem .25rem;
  color: var(--txt);
}
.search input::placeholder{ color: color-mix(in oklab, var(--muted) 75%, transparent); }

/* ========== Przyciski pod paskiem ==*/
.actions{
  display:flex; gap:.75rem; justify-content:center; flex-wrap:wrap;
  margin-top: 1.25rem;
}
.btn{
  appearance:none; border:1px solid transparent;
  background: var(--btn-bg);
  padding:.6rem 1rem; border-radius:.5rem;
  font-family: Arial, sans-serif;
  font-size:.875rem; color: var(--txt);
  transition: transform .06s ease, border-color .15s ease, background .15s ease;
  text-decoration: none;
}
.btn:hover, .btn.ghost:hover { 
  background: var(--btn-bg-hover);
  border: 1px solid var(--border); 
}
.btn:active{ transform: translateY(1px); }
.btn.ghost{
  appearance:none; border:1px solid transparent;
  background: var(--btn-bg);
  padding:.6rem 1rem; border-radius:.5rem;
  font-family: Arial, sans-serif;
  font-size:.875rem; color: var(--txt);
  transition: transform .06s ease, border-color .15s ease, background .15s ease;
  text-decoration: none;
}
.btn.ghost:active{ transform: translateY(1px); }

@media (prefers-color-scheme: dark){
  .btn,
  .btn.ghost{
    background: #303134;
    color: #e8eaed;
    border: 1px solid #303134;
  }

  .btn:hover,
  .btn.ghost:hover{
    background: #3c4043;
    border-color: #5f6368;
  }
}

.hint{
  text-align:center; color: var(--muted);
  font-size:.9rem; margin-top:.75rem;
}

/* ========== Wygląd Card ========= */
a.card {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}
a.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* ========== Karta jako link = pełnowymiarowy item siatki ==*/
.image-grid a.card{
  display:block;
  border-radius: 0;        /* bez zaokrągleń na kontenerze */
  overflow: visible;       /* nie przycinamy rogów zdjęcia */
  background: transparent; /* bez białego tła wokół zdjęcia */
}

/* ========== Usuwa domyślny margines <figure> w środku linku ==*/
.image-grid a.card figure{ 
  margin:0; 
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

/* ========== Miniatura wypełnia kartę ==*/
.image-grid a.card .thumb{
  display:block;
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  border-radius: 10px;   /* ZAOKRĄGLONE WSZYSTKIE ROGI ZDJĘCIA */
}

/* ========== Stopka ========== */
.footer{
  border-top:1px solid var(--border);
  background-color: var(--footer-bg);
  font-size: .938rem;
  font-family: Arial, Sans-serif;
}
.country{
  padding: .938rem 1.875rem;
  border-bottom:1px solid var(--border);
}
.footer-links{
  display:flex; justify-content:space-between; gap:.5rem;
  flex-wrap:wrap; padding:.50rem 1.875rem;
}
.footer a{
  color: inherit; text-decoration:none; padding:.35rem .5rem; border-radius:.4rem;
}
.footer a:hover{ 
  text-decoration: underline; 
}
.links-left, .links-right{ 
  display:flex; flex-wrap:wrap; gap:.25rem; 
}

@media (prefers-color-scheme: dark){
  .footer,
  .footer a,
  .country{
    color: #e8eaed;
  }
}

/* ========== Responsywność ========== */
@media (max-width: 768px) {
  .footer-links {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .5rem;
  }
  .footer-links .links-left,
  .footer-links .links-right,
  .footer-links .links-center {
    justify-content: center;
  }
}

/* ========== Preferencje ruchu ========== */
@media (prefers-reduced-motion: reduce){
  *{ animation:none!important; transition:none!important; }
}

/* ========== DODATKOWE STYLE TYLKO DLA ZNANE ... ====== */

/* ========== Górny pasek: logo + search + prawa sekcja ========== */
.bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.brand svg { height: 28px; width: auto; display:block; }

/* ========== Wysokość spójna z przyciskiem logowania ========== */
.bar-search { flex: 1 1 auto; }
.bar-search .searchbar{
  height: 40px;
  padding: 0 .5rem;
  border-radius: 24px;
  box-shadow: none;
}
.bar-search .search-icon { width:20px; height:20px; margin-left:.25rem; }
.bar-search input{
  font-size: 16px;
  padding: 0 .25rem;
  height: 100%;
}
.bar-right{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar .login-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: .9rem;
  font-weight: 500;
}
.topbar .icon-btn{ 
  width:36px; height:36px; 
}

/* ========== Pasek narzędzi (zakładki) ========== */
.tools {
  border-bottom: 1px solid var(--border);
  margin-top: .25rem;
}
.tools-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 16px;
}
.tabs{
  display: inline-flex;
  gap: 16px;
  padding: 10px 0;
  font-size: .95rem;
}
.tabs a{
  text-decoration: none;
  color: var(--txt);
  padding: 8px 4px;
}
.tabs a:hover{ text-decoration: underline; }
.tabs a.active{
  color: #1a73e8;
  position: relative;
}
.tabs a.active::after{
  content:"";
  position:absolute; left:0; right:0; bottom:-1px;
  height:3px; background:#1a73e8; border-radius:3px;
}
.tools .spacer{ flex:1; }
.tools .more{ color: var(--muted); font-size:.95rem; }

/* ========== Sekcja wyników: siatka 5 w rzędzie ========== */
.image-grid-wrap{
  width:100%;
  max-width: 1100px;
  margin: 1rem auto 2.5rem;
  padding: 0 1rem;
}
.image-grid{
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
figure.card{
  margin: 0;
  border-radius: 0;         /* bez zaokrągleń na kontenerze */
  overflow: visible;
  background: transparent;
}
.thumb{
  display:block;
  width:100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  background: var(--btn-bg);
  border-radius: 10px;      /* ZAOKRĄGLONE WSZYSTKIE ROGI ZDJĘCIA */
}
.meta{
  padding: .5rem .6rem .65rem;
}
/* ====== Tytuł z favicon/logo przed tekstem (jak Google Images) ====== */
.meta .title{
  display: inline-flex;
  align-items: center;
  gap: 6px;

  /* zachowujemy Twoje wartości typografii/koloru */
  font-size: .65rem;
  line-height: 1.35;
  color: var(--txt);
  text-decoration: none;
  margin-bottom: .25rem;

  /* elipsę przenosimy na .title-text */
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
}

.meta .title .title-logo{
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 3px;      /* lekko „faviconowo” */
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); /* subtelny relief, opcjonalnie */
}

.meta .title .title-text{
  display: inline-block;
  min-width: 0;            /* kluczowe dla elipsy we flexie */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta .title:hover{ text-decoration: underline; }

.meta .desc{
  font-size: .65rem;
  color: var(--txt);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== Responsywność ========== */
@media (max-width: 1024px){ .image-grid{ grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px){  .image-grid{ grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px){  .image-grid{ grid-template-columns: repeat(2, 1fr); } }

/* ===== Modal w stylu Google Images ===== */
.gi-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  background: rgba(0,0,0,0.85);
  overflow-y: auto;
}
.gi-modal.show { display: flex; justify-content: center; align-items: flex-start; }
.gi-panel {
  background: var(--surface);
  color: var(--txt);
  margin: 2rem auto;
  border-radius: 8px;
  max-width: 900px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gi-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
}
.gi-header img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.gi-header .src-name {
  font-weight: 600;
  font-size: .95rem;
}
.gi-main-img {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: contain;
  background: var(--btn-bg);
}
.gi-meta {
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}
.gi-title {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  flex: 1;
}
.gi-btn-primary {
  display: inline-block;
  background: #1a73e8;
  color: #fff;
  border-radius: 4px;
  padding: .5rem 1rem;
  text-decoration: none;
  font-size: .9rem;
  white-space: nowrap;
}    
.gi-actions {
  display: flex;
  gap: .5rem;
  padding: 0.75rem 1rem;
}
.gi-btn {
  flex: 1;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--txt);
  border-radius: 6px;
  padding: .5rem;
  font-size: .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.gi-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.gi-btn:hover { background: var(--btn-bg-hover); }
.gi-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--txt);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: background .2s ease;
}
.gi-close:hover { background: var(--btn-bg); }

/* ========== Modal miniatury zdjęć ========== */
.gi-thumbs-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.gi-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.gi-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
}
/* Desktop ≥640px: 3 kolumny */
@media (min-width: 640px) {
  .gi-thumbs-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* POPRAWKI */

/* ====== MOBILE LAYOUT (≤ 640px) ====== */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }

  .topbar .bar{
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand right"
      "search search";
    align-items: center;
    max-width: 100%;
    padding: .5rem .75rem;
    gap: 8px;
  }
  .topbar .brand{
    grid-area: brand;
    justify-self: center;
  }
  .topbar .brand .brand-logo{ height: 35px; }
  .topbar .bar-right{
    grid-area: right;
    justify-self: end;
  }
  .topbar .bar-search{
    grid-area: search;
    width: 100%;
  }
  .topbar .bar-search .searchbar{
    height: 44px;
    border-radius: 9999px;
  }

  .tools { margin-top: .25rem; }
  .tools-inner{
    padding: 0 .75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tools-inner::-webkit-scrollbar{ display: none; }
  .tabs{
    display: inline-flex;
    gap: 12px;
    padding: 8px 0;
    white-space: nowrap;
  }
  .tabs a{ flex: 0 0 auto; }

  .image-grid-wrap{ padding: 0 .75rem; }

  .footer{ width: 100%; }
  .footer-links{ padding: .5rem .75rem; }
}

/* Przyciski ikon po prawej */
.icon-x-btn, .clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.icon-mic-btn, .mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;  
  padding: 0;
  cursor: pointer;
}
.icon-x-btn svg, .icon-mic-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--muted);
}

/* Mikrofon dosunięty do prawej krawędzi paska */
.mic-btn { margin-left: auto; }

/* Opcjonalnie: hover/focus dla lepszej dostępności */
.icon-x-btn:hover, .icon-mic-btn:hover, .icon-x-btn:focus-visible, .icon-mic-btn:focus-visible {
  outline: none;
  background: var(--btn-bg);
  border-radius: 9999px;
}

/* ==== Masonry jak Google Images (telefony) ==== */
.image-grid.masonry{
  display: block !important;
  column-count: 2;
  column-gap: 10px;
}

/* Każde dziecko sekcji to „cegiełka” */
.image-grid.masonry > a.card{
  display: inline-block;
  width: 100%;
  margin: 0 0 10px;
  border-radius: 0;         /* brak zaokrągleń kontenera */
  background: transparent;  /* brak białego tła */
  overflow: visible;

  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

/* W niektórych przeglądarkach trzeba też na <figure> */
.image-grid.masonry a.card figure{
  display: block;
  margin: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

/* Klucz: zdjęcia mają własny radius */
.image-grid.masonry .thumb,
.image-grid.masonry a.card .thumb{
  width: 100% !important;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: cover;
  display: block;
  background: var(--btn-bg);
  border-radius: 10px;      /* ZAOKRĄGLONE ROGI ZDJĘCIA */
}

/* Więcej kolumn na większych szerokościach */
@media (min-width: 640px){  .image-grid.masonry{ column-count: 3; } }
@media (min-width: 1024px){ .image-grid.masonry{ column-count: 4; } }
@media (min-width: 1280px){ .image-grid.masonry{ column-count: 5; } }

/* === FORCE: dokładnie 2 kolumny dla wyników (grid + masonry) === */
.image-grid{
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

/* Nadpisujemy wszelkie breakpointy ustawione wyżej */
@media (max-width: 1024px){ .image-grid{ grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }
@media (max-width: 768px) { .image-grid{ grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }
@media (max-width: 520px) { .image-grid{ grid-template-columns: repeat(2, minmax(0,1fr)) !important; } }

/* Masonry: też zawsze 2 kolumny */
.image-grid.masonry{ column-count: 2 !important; }
@media (min-width: 640px)  { .image-grid.masonry{ column-count: 2 !important; } }
@media (min-width: 1024px) { .image-grid.masonry{ column-count: 2 !important; } }
@media (min-width: 1280px) { .image-grid.masonry{ column-count: 2 !important; } }