:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --card: #ffffff;
  --fg: #111114;
  --muted: #8a8a90;
  --line: #e7e7ec;
  --accent: #0095f6;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 30px rgba(0,0,0,.06);
  --radius: 16px;
  --max: 960px;
}
[data-theme="dark"] {
  --bg: #0b0b0e;
  --surface: #17171c;
  --card: #131318;
  --fg: #f3f3f6;
  --muted: #9a9aa4;
  --line: #26262e;
  --accent: #0095f6;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 14px 34px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a { color: inherit; }
img, video { max-width: 100%; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 22px; font-weight: 800; letter-spacing: 2px;
  color: var(--fg); text-decoration: none;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .tag { color: var(--muted); font-size: 13px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  cursor: pointer; transition: background .15s, transform .1s;
}
.iconbtn:hover { background: var(--surface); }
.iconbtn:active { transform: scale(.92); }

main { max-width: var(--max); margin: 0 auto; padding: 24px 18px 64px; }

/* Profile header — Instagram style: avatar on the side, info beside it */
.profile {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 34px;
  padding: 14px 6px 30px; margin-bottom: 22px; border-bottom: 1px solid var(--line);
}
.profile:empty { display: none; }
.profile .avatar {
  width: 130px; height: 130px; border-radius: 50%; object-fit: cover;
  flex: none; background: var(--surface); border: 1px solid var(--line);
}
.profile .pinfo { min-width: 0; }
.profile .pname { font-size: 23px; font-weight: 800; letter-spacing: 1px; margin: 0 0 12px; }
.profile .pstats { margin-bottom: 10px; }
.profile .pstats b { font-weight: 700; }
.profile .pcategory { color: var(--muted); font-size: 13px; font-weight: 600; }
.profile .pbio { margin-top: 4px; white-space: pre-wrap; max-width: 52ch; }
.profile .plinks { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.linkbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 11px;
  background: var(--accent); color: var(--accent-fg);
  font-weight: 600; font-size: 14px; text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.linkbtn:hover { opacity: .9; }
.linkbtn:active { transform: scale(.97); }

/* Search — single field, press Enter to search */
.search { position: relative; margin: 0 0 16px; }
.search-ic {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; padding: 13px 18px 13px 46px; border: 1px solid var(--line);
  border-radius: 999px; font: inherit; background: var(--card); color: var(--fg);
  transition: border-color .15s;
}
.search input:focus { outline: none; border-color: var(--accent); }
.searchinfo { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.searchinfo b { color: var(--fg); }
.searchinfo a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 10px; }
.searchinfo:empty { display: none; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 736px) { .grid { gap: 14px; } }
.cell {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  background: var(--surface); display: block; border-radius: 12px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.cell.vid { background: #111; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (hover: hover) {
  .cell:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
}
.cell .multi {
  position: absolute; top: 9px; right: 10px; color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.7)); font-size: 16px;
}
.sentinel { height: 1px; }
.status { color: var(--muted); text-align: center; padding: 28px 0; }

/* Single post — player sizes to the media, no letterbox bars */
.post { max-width: 640px; margin: 0 auto; }
.post .stage { position: relative; display: flex; justify-content: center; }
.post .frame {
  width: fit-content; max-width: 100%; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  background: transparent;
}
.post .frame img, .post .frame video {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 82vh;
}
/* Album carousel — all slides preloaded, swipe or arrows, no page reload */
.carousel-wrap { position: relative; }
.carousel {
  display: flex; width: 100%; overflow-x: auto;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface);
}
.carousel::-webkit-scrollbar { display: none; }
.carousel .slide {
  flex: 0 0 100%; scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
}
.carousel .slide img, .carousel .slide video {
  width: 100%; height: auto; max-height: 82vh; object-fit: contain; display: block;
}
.post .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.92); color: #111;
  font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.post .nav.prev { left: 10px; }
.post .nav.next { right: 10px; }
.dots { display: flex; gap: 6px; justify-content: center; padding: 14px 0; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }
.post .meta { padding: 18px 6px; }
.post .date { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.post .caption { white-space: pre-wrap; line-height: 1.7; }
.post .caption a { color: var(--accent); text-decoration: none; font-weight: 600; }
.post .caption a:hover { text-decoration: underline; }

/* Admin */
.admin { max-width: 540px; }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13px; }
.field input, .field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 11px; font: inherit; background: var(--card); color: var(--fg);
}
.btn {
  padding: 12px 22px; border: 0; border-radius: 11px;
  background: var(--accent); color: var(--accent-fg); font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }

/* Footer */
.footer { border-top: 1px solid var(--line); margin-top: 48px; }
.footer-inner {
  max-width: var(--max); margin: 0 auto; padding: 34px 18px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--muted); font-size: 14px;
}
.footer .fbrand { font-weight: 800; letter-spacing: 1px; color: var(--fg); font-size: 16px; }
.footer .flinks { display: flex; gap: 18px; }
.footer .flinks a { color: var(--accent); text-decoration: none; font-weight: 600; }
.footer .fcopy { margin: 0; font-size: 13px; }

/* Responsive */
@media (max-width: 640px) {
  main { padding: 16px 14px 52px; }
  .profile { gap: 18px; padding-bottom: 22px; }
  .profile .avatar { width: 88px; height: 88px; }
  .profile .pname { font-size: 18px; margin-bottom: 8px; }
  .profile .pbio { font-size: 14px; }
  .grid { gap: 4px; }
  .cell { border-radius: 9px; }
}
