:root{
  --bg:#fafafa;
  --card:#ffffff;
  --muted:#666;
  --accent:#0b5fff;
  --gap:12px;
  --radius:10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #111;
}
*{box-sizing:border-box}
html,body,#app{height:100%}
body{
  margin:0;
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  display:flex;
  align-items:stretch;
  justify-content:center;
  padding:16px;
}

/* Container fits single viewport height on mobile: avoid vertical scroll */
main#app{
  width:100%;
  max-width:1100px;
  background:transparent;
  display:grid;
  grid-template-rows:auto 1fr;
  gap:12px;
  height:100vh;
}

/* Uploader (collapsible) */
#uploader{
  background:transparent;
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:stretch;
}
#upload-controls{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.file-btn{
  background:var(--accent);
  color:#fff;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-weight:600;
  min-height:44px;
}
.file-btn input{display:none}
#title-input{
  min-width:160px;
  padding:10px;
  border-radius:10px;
  border:1px solid #ddd;
  background:#fff;
  min-height:44px;
}
button.primary{
  background:var(--accent);
  color:#fff;
  border:none;
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  min-height:44px;
}
button.muted{
  background:transparent;
  border:1px solid #ddd;
  padding:10px 12px;
  border-radius:10px;
  color:var(--muted);
  cursor:pointer;
  min-height:44px;
}

/* preview small grid */
#preview-grid{
  display:flex;
  gap:8px;
  padding:8px;
  border-radius:10px;
  background:transparent;
  margin-left:auto;
  align-items:center;
  overflow:auto;
  max-width:55%;
}
#preview-grid img{
  height:64px;
  border-radius:8px;
  object-fit:cover;
  box-shadow:0 1px 2px rgba(0,0,0,0.06);
}

/* Gallery section */
#gallery{
  background:transparent;
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:hidden;
}
#gallery header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
#gallery header h1{
  margin:0;
  font-size:18px;
  font-weight:700;
}
#cards{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(170px,1fr));
  gap:12px;
  overflow:auto;
  padding:6px;
  border-radius:10px;
}

/* card */
.card{
  background:var(--card);
  border-radius:12px;
  padding:8px;
  box-shadow:0 1px 4px rgba(12,12,12,0.04);
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:stretch;
}
.card img{
  width:100%;
  height:120px;
  object-fit:cover;
  border-radius:8px;
}
.card .meta{
  display:flex;
  justify-content:space-between;
  gap:8px;
  align-items:center;
}
.card .meta .title{font-weight:600;font-size:13px}
.card .meta .small{color:var(--muted);font-size:12px}

/* lightbox */
#lightbox{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.6);
  padding:20px;
  z-index:40;
}
#lightbox.hidden{display:none}
#lightbox img{max-width:92%; max-height:72%; border-radius:8px; box-shadow:0 6px 30px rgba(0,0,0,0.5)}
.lb-close{
  position:absolute;
  top:18px;
  right:18px;
  background:transparent;
  color:#fff;
  border:0;
  font-size:22px;
  cursor:pointer;
}
#lb-meta{
  color:#fff;
  margin-top:12px;
  text-align:center;
}
#lb-download{color:#fff; text-decoration:underline; display:inline-block; margin-top:8px}

/* footer small */
#footer{display:flex;align-items:center;justify-content:center;padding:6px 0;color:var(--muted);font-size:12px}

/* responsive tweaks */
@media(min-width:900px){
  #uploader{padding:0 6px}
}