:root {
  --bg: #0f0d12;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f4efe9;
  --muted: #b5aca5;
  --accent: #e8a2b0;
  --accent-2: #c98a5a;
  --ok: #7dd3a1;
  --err: #f28b82;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #3a1f2a 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 100%, #2a1f16 0%, transparent 60%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: rgba(15, 13, 18, 0.75);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: 0.3px; }
header h1 small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
nav { display: flex; gap: 8px; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 500; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px; line-height: 1;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a1014; border: none; font-weight: 600; }
.btn.small { padding: 7px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 18px; }
.muted { color: var(--muted); }
input[type="text"], input[type="password"] {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25); color: var(--text); font-size: 16px; outline: none;
}
input:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }

/* ---- code page ---- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.center .card { width: 100%; max-width: 380px; text-align: center; }
.center h1 { margin: 0 0 4px; font-size: 26px; }
.center p { margin: 0 0 18px; }
.center form { display: grid; gap: 12px; }

/* ---- upload page ---- */
.drop {
  margin-top: 14px; border: 2px dashed rgba(255, 255, 255, 0.25); border-radius: 18px; padding: 36px 18px; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: rgba(232, 162, 176, 0.08); }
.drop .big { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.drop p { margin: 6px 0; }
.drop input { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.queue { margin-top: 16px; display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); }
.item img, .item .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #222; display: grid; place-items: center; font-size: 22px; }
.item .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }
.item.done .bar i { background: var(--ok); }
.item.error .bar i { background: var(--err); }
.status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.summary { margin-top: 14px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---- gallery ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select { padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 14px; }
.toolbar .spacer { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; } }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #1c171b; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 32px; color: var(--muted); }
.tile .badge { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: rgba(0, 0, 0, 0.6); padding: 3px 6px; border-radius: 6px; }
.tile .who { position: absolute; left: 0; right: 0; top: 0; font-size: 11px; padding: 6px; background: linear-gradient(rgba(0,0,0,0.6), transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .check { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,0.35); display: none; }
.grid.selecting .tile .check { display: block; }
.tile.selected .check { background: var(--accent); border-color: var(--accent); }
.tile.selected img { opacity: 0.6; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(15,13,18,0.9); border-top: 1px solid var(--border); display: none; gap: 10px; justify-content: center; backdrop-filter: blur(12px); z-index: 20; }
.selbar.show { display: flex; }

/* ---- lightbox ---- */
.lb { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.96); display: none; z-index: 50; flex-direction: column; }
.lb.open { display: flex; }
.lb .top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; gap: 8px; }
.lb .top .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .stage { flex: 1; display: grid; place-items: center; min-height: 0; position: relative; }
.lb .stage img, .lb .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb .nav { position: absolute; top: 0; bottom: 0; width: 25%; cursor: pointer; }
.lb .nav.prev { left: 0; } .lb .nav.next { right: 0; }
.lb .bottom { display: flex; gap: 8px; justify-content: center; padding: 12px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #2a2430; border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: 60; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }
.newpill { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a1014; border: none; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; box-shadow: 0 6px 20px rgba(0,0,0,0.4); cursor: pointer; }
.newpill.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
