:root {
  --bg: #121417;
  --bg-elev: #1b1f24;
  --bg-input: #0d0f12;
  --border: #2b313a;
  --text: #e8eaed;
  --text-muted: #9aa3ad;
  --accent: #f5b642;
  --accent-text: #1a1200;
  --danger: #e5534b;
  --ok: #4cc38a;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- Layout ---------- */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}

.topbar h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: 0.01em;
}

.topbar nav { display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---------- Controls ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  width: 100%;
  font-size: 1.05rem;
}

.btn-small { padding: 6px 12px; min-height: 36px; font-size: 0.9rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="password"],
textarea {
  font: inherit;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

textarea { resize: vertical; min-height: 88px; }

input:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field { margin-bottom: 16px; }

.hint { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0 0; }
.hint.over { color: var(--danger); }

.msg { padding: 12px; border-radius: 10px; margin: 0 0 12px; }
.msg-error { background: rgba(229, 83, 75, 0.15); color: #ffb4ae; }
.msg-ok { background: rgba(76, 195, 138, 0.15); color: #a6f0c6; }

/* ---------- Photo picker ---------- */

.picker {
  position: relative;
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  color: var(--text-muted);
  background: var(--bg-input);
}

.picker:focus-within { border-color: var(--accent); }
.picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.picker.has-image { border-style: solid; min-height: 0; }
.picker img { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: #000; }
.picker-empty { padding: 24px; }
.picker-empty strong { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 4px; }

progress {
  width: 100%;
  height: 8px;
  margin: 8px 0 0;
  appearance: none;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
}
progress::-webkit-progress-bar { background: var(--bg-input); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

/* ---------- Feed ---------- */

.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 12px;
}

.feed-head h2 { font-size: 1.1rem; margin: 0; }
.feed-head span { color: var(--text-muted); font-size: 0.9rem; }

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.entry {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.entry img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
}

.entry figcaption { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.entry p { margin: 0; overflow-wrap: anywhere; }
.entry time { color: var(--text-muted); font-size: 0.8rem; margin-top: auto; }
.entry .actions { margin-top: 8px; }

.empty { color: var(--text-muted); text-align: center; padding: 32px 0; }

/* ---------- Login ---------- */

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card { width: min(100%, 380px); }
.login-card h1 { margin: 0 0 16px; font-size: 1.5rem; text-align: center; }

/* ---------- Presenter ---------- */

body.present {
  background: #000;
  overflow: hidden;
  height: 100dvh;
  cursor: none;
}

body.present.show-ui { cursor: default; }

.stage {
  position: fixed;
  inset: 0;
  background: #000;
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 900ms ease;
}

.slide.active { opacity: 1; }

.slide .bg {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(28px) brightness(0.45);
}

.slide .fg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slide .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 5vh 6vw 6vh;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  font-size: clamp(1.4rem, 3.2vw, 3rem);
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  overflow-wrap: anywhere;
  text-align: center;
}

.slide .caption:empty { display: none; }

.waiting {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  text-align: center;
  padding: 24px;
}

.hud {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
  font-size: 0.95rem;
}

body.show-ui .hud {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.hud .sep { width: 1px; height: 24px; background: var(--border); }
.hud .info { color: var(--text-muted); padding: 0 8px; white-space: nowrap; }
.hud .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.hud .seg .btn { border: none; border-radius: 0; min-height: 36px; padding: 6px 14px; }

.hud input[type="number"] {
  font: inherit;
  width: 64px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

/* ---------- Admin ---------- */

.admin-stats { color: var(--text-muted); margin: 0 0 12px; }

@media (max-width: 480px) {
  .feed { grid-template-columns: repeat(2, 1fr); }
  .topbar h1 { font-size: 1.15rem; }
}
