:root {
  --bg: #0b0820;
  --bg2: #1a0f3a;
  --panel: rgba(22, 16, 52, .82);
  --line: rgba(124, 255, 203, .22);
  --text: #f1ecff;
  --muted: #a99fcf;
  --pink: #ff3ea5;
  --green: #7cffcb;
  --gold: #ffd23f;
  --danger: #ff5a6e;
  --radius: 16px;
  --display: 'Monoton', 'Orbitron', sans-serif;
  --script: 'Pacifico', cursive;
  --tech: 'Orbitron', sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font: 16px/1.55 var(--body);
  background:
    radial-gradient(ellipse at 50% 120%, rgba(124, 255, 203, .18), transparent 55%),
    radial-gradient(ellipse at 15% -10%, rgba(255, 62, 165, .25), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}

/* starfield */
.stars {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 200px 150px, #ffd23f, transparent),
    radial-gradient(1px 1px at 300px 40px, #fff, transparent),
    radial-gradient(1px 1px at 380px 220px, #7cffcb, transparent),
    radial-gradient(1px 1px at 60px 260px, #fff, transparent);
  background-size: 420px 300px;
  animation: twinkle 6s ease-in-out infinite alternate;
  opacity: .7;
}
@keyframes twinkle { from { opacity: .45; } to { opacity: .9; } }

a { color: var(--green); }
a:hover { color: var(--gold); }

/* header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 8, 32, .7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font: 1.35rem var(--script); }
.brand em { color: var(--pink); font-style: normal; }
.ufo { width: 48px; height: 24px; animation: hover 3s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(124, 255, 203, .6)); }
@keyframes hover { 50% { transform: translateY(-4px) rotate(-3deg); } }
.site-header nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font: 600 .82rem var(--tech); letter-spacing: .04em; text-transform: uppercase; }
.site-header nav a { text-decoration: none; }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.site-footer p { margin: 4px 0; }
.site-footer .version { font: 600 .7rem var(--tech); letter-spacing: .12em; opacity: .7; }

/* photo metadata page */
.photo-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; align-items: start; }
.photo-view img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.meta-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.meta-table td:first-child { color: var(--muted); white-space: nowrap; width: 1%; }
.meta-table td { word-break: break-word; }
.meta-table .raw { color: var(--muted); font-size: .75rem; }
.meta-section { margin-top: 18px; }
.meta-section h2 { display: flex; justify-content: space-between; gap: 8px; }
.meta-section h2 small { color: var(--muted); font: 400 .75rem var(--body); text-transform: none; letter-spacing: 0; }

/* type */
.neon {
  font-family: var(--display); font-weight: 400; line-height: 1.1;
  font-size: clamp(2.4rem, 9vw, 5rem);
  color: #fff;
  text-shadow: 0 0 6px var(--pink), 0 0 18px var(--pink), 0 0 40px rgba(255, 62, 165, .6);
  margin: 0 0 .4em;
}
.neon span { color: #fff; text-shadow: 0 0 6px var(--green), 0 0 18px var(--green), 0 0 40px rgba(124, 255, 203, .6); }
.neon.small { font-size: clamp(1.6rem, 6vw, 2.4rem); }
h2 { font: 700 1rem var(--tech); letter-spacing: .06em; text-transform: uppercase; color: var(--gold); margin: 1.6em 0 .6em; }
.kicker { font: 600 .8rem var(--tech); letter-spacing: .2em; text-transform: uppercase; color: var(--green); }
.lede { font-size: 1.1rem; max-width: 40em; color: #dcd4ff; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; }

/* hero + cards */
.hero { padding: 24px 0 8px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 40px; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.card h2 { margin-top: 0; }
.panel.narrow { max-width: 460px; margin: 0 auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head .neon { margin: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 22px; border-radius: 999px; border: 0; cursor: pointer;
  font: 700 .9rem var(--tech); letter-spacing: .05em; text-transform: uppercase; text-decoration: none;
  color: #1a0f3a; background: linear-gradient(135deg, var(--gold), var(--pink));
  box-shadow: 0 0 18px rgba(255, 62, 165, .45);
}
.btn:hover { color: #1a0f3a; filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--green); border: 1px solid var(--green); box-shadow: none; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: .75rem; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--green); cursor: pointer; font: inherit; text-decoration: underline; }
.link.danger { color: var(--danger); }

/* forms */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.form input:not([type=checkbox]), .search input, select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .35); color: var(--text);
  font: 16px var(--body); /* 16px stops iOS zooming on focus */
}
.form input:focus, select:focus, .search input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.form .check { grid-template-columns: auto 1fr; align-items: start; font-weight: 400; font-size: .82rem; color: var(--muted); }
.form .check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--pink); }
.form.compact { max-width: 420px; }
.errors { background: rgba(255, 90, 110, .12); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 14px 10px 32px; color: #ffc4cc; }
.flash, .notice { background: rgba(124, 255, 203, .1); border: 1px solid var(--green); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; }
.notice { border-color: var(--gold); background: rgba(255, 210, 63, .1); }

/* camera */
.viewfinder {
  position: relative; overflow: hidden; border-radius: var(--radius); border: 2px solid var(--line);
  background: #000 radial-gradient(circle, #1a0f3a, #000); aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto;
  width: 100%; max-width: 560px;
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder video.mirror { transform: scaleX(-1); }
.viewfinder .start { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.viewfinder .start[hidden] { display: none; }
.reticle { position: absolute; inset: 18%; border: 1px dashed rgba(124, 255, 203, .5); border-radius: 50%; pointer-events: none; }
.reticle::before, .reticle::after { content: ''; position: absolute; background: rgba(124, 255, 203, .5); }
.reticle::before { left: 50%; top: -10%; bottom: -10%; width: 1px; }
.reticle::after { top: 50%; left: -10%; right: -10%; height: 1px; }
.shutter-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.shutter-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; max-width: 560px; margin: 16px auto 0; }
.controls .select { display: grid; gap: 4px; font: 600 .7rem var(--tech); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.controls select { padding: 10px; font-size: 16px; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  border: 5px solid #fff; background: radial-gradient(circle, var(--pink) 0 55%, #fff 56%);
  box-shadow: 0 0 24px rgba(255, 62, 165, .7);
}
.shutter:active { transform: scale(.94); }
.shutter:disabled { opacity: .35; cursor: default; }
.last-shot { justify-self: end; width: 56px; height: 56px; border-radius: 12px; border: 2px solid var(--line); background: rgba(0, 0, 0, .4) center / cover no-repeat; }
.last-shot.has-img { border-color: var(--green); }
.status { text-align: center; min-height: 1.5em; color: var(--green); font-size: .9rem; }
.status.error { color: var(--danger); }
.upload-progress { display: flex; align-items: center; gap: 10px; margin: 8px auto 4px; max-width: 420px; }
.upload-progress[hidden] { display: none; }
.upload-bar { flex: 1; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid var(--line); overflow: hidden; }
.upload-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--green)); transition: width .15s linear; }
.upload-progress.working .upload-fill { width: 100%; animation: upload-pulse 1s ease-in-out infinite alternate; }
@keyframes upload-pulse { from { opacity: .45; } to { opacity: 1; } }
.upload-pct { min-width: 3.2em; text-align: right; font: 600 .8rem var(--tech); color: var(--green); }
.ask-name { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.ask-name input { width: 18px; height: 18px; accent-color: var(--pink); }
.tile-name { word-break: break-all; font-size: .8rem; }

/* name-before-saving dialog */
body.no-scroll { overflow: hidden; }
.review {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(5, 3, 18, .85); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.review[hidden] { display: none; }
.review-card {
  width: 100%; max-width: 440px; max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: 0 0 40px rgba(255, 62, 165, .3);
}
.review-card h2 { margin-top: 0; }
.review-card img { width: 100%; max-height: 42vh; object-fit: contain; background: #000; border-radius: 10px; display: block; }
.review-name { display: grid; gap: 6px; margin-top: 14px; font-weight: 600; font-size: .9rem; }
.name-row { display: flex; align-items: center; gap: 6px; }
.name-row input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); color: var(--text); font: 16px var(--body);
}
.name-row input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.name-row span { color: var(--muted); }
.small-print { font-size: .75rem; margin: 6px 0 0; }
.review-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.review-actions .btn { flex: 1; }

/* Phones: preview + shutter always fit on screen, portrait or landscape. */
@media (max-width: 600px) and (orientation: portrait), (max-height: 500px) and (orientation: landscape) {
  .camera-page .site-header { position: static; }
  .camera-page main { padding-top: 8px; }
  .camera-page .panel.camera { padding: 8px; }
  .camera-page .camera > h1 { display: none; }
  .camera-stage {
    display: grid; gap: 8px; scroll-margin-top: 8px;
    height: calc(100vh - 32px); height: calc(100svh - 32px);
  }
  .camera-stage .viewfinder { max-height: none; max-width: 100%; height: 100%; justify-self: center; min-height: 0; }
  .camera-stage .controls { margin: 0; }
  .camera-stage .viewfinder video { object-fit: contain; } /* preview shows exactly what gets captured */
  .stage-status .status { margin: 0; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .camera-stage { grid-template-rows: minmax(0, 1fr) auto auto; }
  .camera-stage .viewfinder { width: auto; aspect-ratio: 3 / 4; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .camera-page main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .camera-stage { grid-template-columns: minmax(0, 1fr) 150px; grid-template-rows: minmax(0, 1fr) auto; }
  .camera-stage .viewfinder { grid-row: 1 / span 2; width: auto; aspect-ratio: 4 / 3; }
  .camera-stage .controls { display: flex; flex-direction: column; justify-content: center; gap: 10px; max-width: none; }
  .camera-stage .controls > * { flex-shrink: 0; }
  .camera-stage .controls .select { width: 100%; }
  .camera-stage .controls select { width: 100%; padding: 6px; }
  .camera-stage .last-shot { justify-self: auto; width: 44px; height: 44px; }
  .camera-stage .shutter { width: 64px; height: 64px; }
  .stage-status .status { font-size: .75rem; line-height: 1.3; }
  .stage-status .upload-progress { gap: 6px; margin: 0 0 4px; }
  .review-card { max-width: 720px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .review-card h2, .review-card img { grid-column: 1; }
  .review-card img { grid-row: 1 / span 4; max-height: calc(100svh - 70px); }
  .review-card > :not(img) { grid-column: 2; }
}

.geo-status { text-align: center; margin: -8px 0 0; font-size: .8rem; color: var(--muted); }
.geo-status.ok { color: var(--gold); }
.fallback { max-width: 560px; margin: 12px auto 0; color: var(--muted); }
.fallback summary { cursor: pointer; font-weight: 600; color: var(--text); }

/* gallery */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-top: 12px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.tile { margin: 0; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
/* thumbnail placeholder: spinner until the image arrives, warning if it fails */
.thumb { position: relative; display: block; background: rgba(0, 0, 0, .35); }
.thumb.loading img, .thumb.failed img { opacity: 0; }
.thumb img { transition: opacity .25s; }
.thumb.loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; border: 3px solid rgba(124, 255, 203, .2); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
.thumb.failed::after { content: '⚠ Not available'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .thumb.loading::after { animation-duration: 2.5s; } }
.tile figcaption { padding: 8px 10px; display: grid; gap: 2px; font-size: .78rem; }
.tile time { color: var(--muted); }
.tile .geo { color: var(--gold); text-decoration: none; }
.tile pre { max-height: 240px; font-size: .65rem; }
.tile-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.tile form { margin: 0; }
.empty { font-size: 1.1rem; }

/* admin */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.stats div { flex: 1 1 120px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.stats strong { display: block; font: 700 1.8rem var(--tech); color: var(--gold); }
.stats span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(124, 255, 203, .1); vertical-align: top; }
th { font: 700 .7rem var(--tech); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: rgba(0, 0, 0, .25); }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font: 700 .65rem var(--tech); letter-spacing: .06em; text-transform: uppercase; }
.badge.ok { background: rgba(124, 255, 203, .15); color: var(--green); }
.badge.off { background: rgba(255, 90, 110, .15); color: var(--danger); }
.badge.admin { background: rgba(255, 210, 63, .15); color: var(--gold); }
.badge.pending { background: rgba(255, 62, 165, .18); color: var(--pink); }
.nav-count { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--pink); color: #fff; font-size: .7rem; text-align: center; }
.pending-notice { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.pending-notice form, .row-actions { display: flex; gap: 8px; margin: 0; }
.pending-list { border-color: var(--pink); }
.badges { display: flex; gap: 6px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.actions form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
pre { white-space: pre-wrap; word-break: break-all; font-size: .75rem; background: rgba(0, 0, 0, .4); padding: 10px; border-radius: 8px; max-height: 360px; overflow: auto; }
details summary { cursor: pointer; }

@media (max-width: 520px) {
  .site-header nav { gap: 10px; font-size: .72rem; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 6px; }
}

/* Debug mode (admin.php?debug=1) */
.debug-panel { margin: 12px 0; padding: 10px; border: 1px dashed var(--gold); border-radius: 12px; font-size: .8rem; }
.debug-panel pre { max-height: 240px; margin: 8px 0 0; font-size: .7rem; }

/* Show/Hide button on password fields (assets/password.js) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px !important; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-width: 56px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(124, 255, 203, .1); color: var(--green); font: 600 .75rem var(--body); cursor: pointer;
}
.pw-toggle:hover, .pw-toggle[aria-pressed=true] { background: rgba(124, 255, 203, .22); }
.pw-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
