:root {
  --bg: #0b0f14;
  --panel: #121822;
  --muted: #1a2230;
  --text: #e6edf3;
  --sub: #a7b1c2;
  --brand: #4cc2ff;
  --danger: #ff6b6b;
}
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;           
}


body {
  margin: 0;
  background: linear-gradient(180deg, #0b0f14 0%, #0f1420 100%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    "Helvetica Neue", Arial;
}
a {
  color: inherit;
}

.app {
  height: 100dvh;              
  overflow: auto;              
  -webkit-overflow-scrolling: touch;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 14, 20, 0.8);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid #1b2433;
  transition: transform .28s ease-in-out;  
  will-change: transform;
}
/* Hidden state */
header.is-hidden { transform: translateY(-100%); }



.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand b {
  font-weight: 700;
  letter-spacing: 0.3px;
}
.chip {
  background: var(--muted);
  color: var(--sub);
  border: 1px solid #2a3344;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.controls {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  grid-template-columns: 1fr;
}
.row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
label {
  font-size: 12px;
  color: var(--sub);
}
input[type="text"],
select {
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  background: #0f1520;
  border: 1px solid #273049;
  color: var(--text);
}
.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.btn {
  cursor: pointer;
  user-select: none;
  border: 1px solid #2a3347;
  background: linear-gradient(180deg, #182233, #121a2a);
  color: #e9f2ff;
  padding: 12px 14px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn.secondary {
  background: #0f1520;
}

.api-key input {
  font-family: monospace;
}

.gallery {
  --gap: 10px;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}
@media (min-width: 560px) {
  .controls {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
  .row {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 880px) {
  .gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #0e1420;
  border: 1px solid #202a3d;
}
.ph {
  aspect-ratio: 1/1.1;
  background: linear-gradient(180deg, #141b29 0, #0f1520 100%);
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.card:hover img {
  transform: scale(1.03);
}
.card .meta {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.badge {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  color: #d7e2f2;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}
.icon-btn {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e9f2ff;
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
}

.sentinel {
  display: grid;
  place-items: center;
  padding: 20px;
}
.loader {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--brand);
  display: inline-block;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.footer {
  font-size: 12px;
  color: var(--sub);
  text-align: center;
}

dialog {
  border: none;
  border-radius: 16px;
  max-width: min(92vw, 1000px);
  width: fit-content;
  padding: 0;
  background: #0b1018;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  position: relative;
  padding: 12px;
}
.modal-content img {
  max-width: min(90vw, 980px);
  max-height: 75vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 12px;
}
.modal-content .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.credit {
  color: var(--sub);
  font-size: 12px;
  margin: 6px 2px 8px;
}
#closeModal {
  position: absolute;
  top: 8px;
  right: 8px;
}



header .wrap{
  display: grid;
  grid-template-columns: auto 1fr;   
  align-items: center;
  gap: 16px;
}


.controls{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;                  
  margin-top: 0;                     
}


.searchbar{
  flex: 1 1 520px;                   
  min-width: 360px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}


.controls .row{
  display: flex;
  align-items: center;
  gap: 10px;
}

.controls .row > div{
  display: flex;
  align-items: center;
  gap: 6px;                       
}

/* Keep selects compact on desktop */
.controls select{
  width: auto;                       
  min-width: 110px;
  padding-inline: 10px;
}

/* API key and buttons sit inline, compact */
.api-key{
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-key input{ width: 220px; }

/* Make buttons a consistent height */
.btn{ height: 44px; }


@media (min-width: 1100px){
  label{
    position: absolute;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* --- Responsive fallback (mobile/tablet keeps your stacked layout) --- */
@media (max-width: 820px){
  header .wrap{ grid-template-columns: 1fr; }
  .controls{ flex-direction: column; align-items: stretch; gap: 10px; }
  .controls .row{ flex-direction: column; align-items: stretch; }
  .searchbar{ min-width: 0; flex: 1 1 auto; }
  .api-key input{ width: 100%; }
}




