:root {
  --bg: #111;
  --fg: #f4f4f4;
  --muted: #9a9a9a;
  --card: #1e1e1e;
  --accent: #ff4f7b;
  --danger: #d33;
  --ok: #3cb371;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--fg); }
h1 { font-size: 2rem; margin: 0 0 1.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
[hidden] { display: none !important; }

.center { text-align: center; }
main.center { max-width: 480px; margin: 0 auto; padding: 2rem 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: #ff7070; }
.row { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 16px; border-bottom: 1px solid #2a2a2a; font-weight: 600;
}
.bar a { text-decoration: none; color: var(--muted); font-weight: 400; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .7rem 1.3rem; border: 0; border-radius: var(--radius);
  background: #2c2c2c; color: var(--fg); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-huge { width: 100%; min-height: 96px; font-size: 1.5rem; }

/* login */
.login-form { display: flex; flex-direction: column; gap: .75rem; text-align: left; }
.login-form input {
  font: inherit; font-size: 1.25rem; padding: .8rem 1rem; border-radius: var(--radius);
  border: 1px solid #333; background: var(--card); color: var(--fg); text-align: center;
}

/* home */
.big-icons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.big-icon {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1.75rem .5rem; border-radius: var(--radius); background: var(--card);
  text-decoration: none; font-size: 1.2rem; font-weight: 600;
}
.big-icon span { font-size: 3.5rem; line-height: 1; }

/* camera */
.camera-main section { display: flex; flex-direction: column; gap: 1rem; align-items: stretch; }
.preview { width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--radius); background: #000; }
.status { min-height: 1.5em; margin: 0; }
.status.busy::before {
  content: ""; display: inline-block; width: 1em; height: 1em; margin-right: .5em; vertical-align: -2px;
  border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
.status.error { color: #ff7070; }
.done { font-size: 2rem; color: var(--ok); margin: 1rem 0 0; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* gallery */
.gallery-main { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
.latest { margin: 1rem 0 1.5rem; }
.latest img {
  display: block; width: 100%; max-height: 70vh; object-fit: contain;
  background: #000; border-radius: var(--radius); cursor: zoom-in;
}
.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(170px, 1fr)); } }
.tile { position: relative; margin: 0; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--card); }
.tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.tile-delete {
  position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .65); font-size: 1.1rem; cursor: pointer;
}
.lightbox {
  position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; }

/* slideshow */
body.slideshow { background: #000; overflow: hidden; padding: 0; }
body.hide-cursor, body.hide-cursor * { cursor: none !important; }
#stage { position: fixed; inset: 0; }
.slide {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity 1s ease-in-out;
}
.slide.visible { opacity: 1; }
.badge {
  position: absolute; top: 3vh; right: 3vw; padding: .4em 1em; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: clamp(1rem, 3vw, 2.5rem);
  letter-spacing: .1em; box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
}
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: clamp(1.5rem, 4vw, 3.5rem); text-align: center;
}
.empty p { margin: .3em; }
.empty .url { color: var(--accent); font-weight: 700; }
