:root {
  --black: #000000;
  --gold: #ebc87e;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e3e3e3;
  --ok: #1b7f3b;
  --bad: #b3261e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.4;
}
[hidden] { display: none !important; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom));
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand img { width: 56px; height: 56px; display: block; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 14px; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.hint, .note { font-size: 14px; color: var(--muted); }

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
#gate-form { display: grid; gap: 10px; margin-top: 12px; }
#password {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.primary {
  background: var(--black);
  color: var(--gold);
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.actions { display: grid; gap: 10px; margin: 16px 0 8px; }
.action {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--black);
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.action-primary { background: var(--gold); }
.action:active { transform: scale(0.99); }
.action svg { width: 24px; height: 24px; flex: none; fill: currentColor; }
.action input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.note { display: block; margin: 0 0 16px; }
.note input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* minmax(0, …) and min-width: 0 let long file names shrink and end in "…" instead of pushing the card past the screen edge. */
.queue { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.item.failed { border-color: var(--bad); }
.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #f2f2f2;
  overflow: hidden;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .icon { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); }
.thumb .icon svg { width: 28px; height: 28px; fill: currentColor; }
.thumb.no-preview img, .thumb.no-preview video { display: none; }
.thumb.no-preview .icon { display: grid; }

.line { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.line > * { min-width: 0; }
.name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.size { color: var(--muted); flex: none; }
.bar { height: 6px; margin: 6px 0; background: #e9e9e9; border-radius: 3px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--black); transition: width 0.2s; }
.item.sent .fill { background: var(--ok); }
.status { font-size: 14px; color: var(--muted); }
.item.sent .status { color: var(--ok); font-weight: 600; }
.item.failed .status { color: var(--bad); }
.retry {
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--black);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.all-sent {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #e8f5ec;
  color: var(--ok);
  font-weight: 700;
  font-size: 17px;
  text-align: center;
}
.banner {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff4e5;
  color: #7a4a00;
  font-size: 15px;
}
.error { color: var(--bad); }

/* Gallery link on the upload page */
.gallery-link { margin: 16px 0 0; text-align: center; }
.gallery-link a { color: var(--ink); font-weight: 600; }

/* Gallery page */
.gallery-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.back { color: var(--ink); font-weight: 600; }
.refresh {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--black);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #f2f2f2;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tile-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
#view {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
}
#view[hidden] { display: none !important; }
#view-body img, #view-body video { max-width: 100%; max-height: 88vh; border-radius: 6px; }
#view-body video { width: min(100%, 720px); }
#close {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.view-name {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 0;
  width: 100%;
  text-align: center;
  color: #d9d9d9;
  font-size: 13px;
  padding: 0 48px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
