:root {
  --bg: #0d0d0d;
  --fg: #ededed;
  --muted: #8c8c8c;
  --line: #2a2a2a;
  --surface: #1a1a1a;
  --accent: #ededed;
  --accent-fg: #0d0d0d;
  --radius: 4px;
  --max: 1100px;
  font-size: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.brand {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: flex-end; }
.site-nav a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.site-nav a:hover { color: var(--fg); }

.site-main { max-width: var(--max); margin: 0 auto; padding: 1.5rem; }

.site-footer {
  max-width: var(--max);
  margin: 3rem auto 1.5rem;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.muted { color: var(--muted); }

/* Home: square previews flowing down the page */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.home-item {
  position: relative;
  margin: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
}
.home-link { display: block; width: 100%; height: 100%; }
.home-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s ease;
}
.home-item:hover img { transform: scale(1.03); }

/* Album admin cover placeholder reused on album cards */
.album-cover-empty { width: 100%; height: 100%; background: var(--surface); }

/* Photo grid (album page) */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.grid-item { margin: 0; }
.grid-thumb { position: relative; }
.grid-item .thumb { width: 100%; height: 220px; object-fit: cover; border-radius: var(--radius); background: var(--surface); display: block; }
.grid-item figcaption { color: var(--muted); font-size: 0.85rem; padding: 0.25rem 0; }

/* Photo detail */
.photo-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 1.5rem; }
.photo-frame { position: relative; }
.photo-frame img { width: 100%; height: auto; border-radius: var(--radius); background: var(--surface); display: block; }
.photo-info h1 { font-size: 1.3rem; font-weight: 600; margin-top: 0; }
.caption { white-space: pre-wrap; }
.photo-albums { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 720px) { .photo-detail { grid-template-columns: 1fr; } }

/* Share trigger: hover-revealed icon overlaid on a photo */
.share-trigger {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 5;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
}
.share-trigger svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.share-trigger:hover { background: rgba(0, 0, 0, 0.82); }
.home-item:hover .share-trigger,
.grid-thumb:hover .share-trigger,
.photo-frame:hover .share-trigger,
.share-trigger:focus-visible { opacity: 1; transform: none; }
/* Touch devices have no hover — keep the icon visible. */
@media (hover: none) { .share-trigger { opacity: 1; transform: none; } }

/* Share popup */
body.modal-open { overflow: hidden; }
.share-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.share-modal[hidden] { display: none; }
.share-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); }
.share-modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.5rem;
  width: calc(100% - 2rem);
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.share-modal-card h3 { margin: 0 0 1rem; font-weight: 600; }
.share-modal-close {
  position: absolute; top: 0.4rem; right: 0.5rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1; padding: 0.2rem 0.5rem; cursor: pointer;
}
.share-modal-close:hover { color: var(--fg); }
.share-targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 0.75rem; }
.share-target {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  padding: 0.6rem 0.3rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg);
  text-decoration: none; cursor: pointer; font-size: 0.78rem;
}
.share-target:hover { border-color: var(--fg); }
.share-target[hidden] { display: none; }
.share-ico {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #2a2a2a;
}
.share-ico svg { width: 1.2rem; height: 1.2rem; fill: #fff; }
.share-ico.tg { background: #229ED9; }
.share-ico.wa { background: #25D366; }
.share-ico.x  { background: #000; border: 1px solid #444; }
.share-ico.fb { background: #1877F2; }

/* Admin */
.admin-bar { display: flex; align-items: baseline; justify-content: space-between; }
.admin-links a { margin-left: 1rem; color: var(--muted); text-decoration: none; }
.admin-links a:hover { color: var(--fg); }
.admin-photos { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; padding-bottom: 5rem; }

/* Floating save bar (always visible while editing) */
.save-bar {
  position: fixed;
  bottom: 1.25rem;
  right: 1.5rem;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.6rem 0.5rem 1.1rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}
.save-bar .hint { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.save-bar button { border-radius: 999px; }
.admin-photo {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.admin-photo-thumb .thumb { width: 100%; height: 180px; object-fit: cover; border-radius: var(--radius); }
.admin-flags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.flag { font-size: 0.7rem; padding: 0.15rem 0.45rem; border-radius: 999px; border: 1px solid var(--line); }
.flag-featured { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.flag-album { background: #1e2a44; border-color: #2e3e5e; }
.flag-none { color: var(--muted); }
.admin-photo-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.field { display: flex; flex-direction: column; font-size: 0.85rem; }
.field span { color: var(--muted); margin-bottom: 0.15rem; }
.field input, .album-create input, .album-edit input {
  padding: 0.4rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit;
  background: var(--surface); color: var(--fg);
}
.check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.albums-field { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem; }
.albums-field legend { color: var(--muted); font-size: 0.8rem; padding: 0 0.3rem; }
button { font: inherit; padding: 0.45rem 0.9rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); border-radius: var(--radius); cursor: pointer; align-self: flex-start; }
button:hover { opacity: 0.9; }
button.danger { background: var(--surface); color: #ff6b6b; border-color: #5a2a2a; }

/* Album admin */
.album-create { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.5rem; max-width: 480px; }
.album-list { display: flex; flex-direction: column; gap: 1rem; }
.album-edit { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.album-edit-cover img { width: 100%; border-radius: var(--radius); }
.album-edit-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.album-edit .row { display: flex; gap: 1rem; }
.field.small { flex: 1; }
.album-edit-actions { display: flex; gap: 0.5rem; }

.pager { display: flex; gap: 1rem; justify-content: center; margin: 2rem 0; }
.pager a { text-decoration: none; color: var(--muted); }
