/* Tofu — private preview. Local assets only. No trackers. */
:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --ink: #0f0f0f;
  --muted: #737373;
  --line: #efefef;
  --line-strong: #dbdbdb;
  --hashtag: #7a5cbf;
  --overlay: rgba(0, 0, 0, 0.65);
  --ring: linear-gradient(145deg, #ffb39a 0%, #f4a3c2 48%, #c9b6ee 100%);
  --banner-bg: #fff3f6;
  --banner-ink: #8a3d62;
  --radius-full: 50%;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --max: 935px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --bg-soft: #1a1a1a;
    --ink: #f5f5f5;
    --muted: #a8a8a8;
    --line: #262626;
    --line-strong: #363636;
    --hashtag: #c4b6f2;
    --overlay: rgba(0, 0, 0, 0.78);
    --banner-bg: #2a1c24;
    --banner-ink: #f0c3d4;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html { scroll-behavior: smooth; color-scheme: light dark; }
body { min-height: 100vh; overflow-x: hidden; }
img, video { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}
.skip:focus { top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.preview-banner {
  margin: 0;
  padding: 8px 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--banner-ink);
  background: var(--banner-bg);
  border-bottom: 1px solid var(--line);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  width: min(var(--max), 100%);
  margin: 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.topbar-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* ---------- profile ---------- */
.profile {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "avatar stats"
    "bio bio"
    "highlights highlights";
  column-gap: 28px;
  row-gap: 14px;
  align-items: center;
}

.avatar-wrap {
  grid-area: avatar;
  width: 86px;
  height: 86px;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--ring);
  flex: 0 0 auto;
}
.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg);
  background: var(--bg-soft);
}

.profile-stats {
  grid-area: stats;
  display: flex;
  align-items: center;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.stat b {
  font-size: 18px;
  font-weight: 700;
}
.stat span {
  font-size: 14px;
  color: var(--ink);
}

.profile-bio { grid-area: bio; }
.profile-bio h1 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
}
.bio {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}
.place {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- highlights ---------- */
.highlights {
  grid-area: highlights;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 0 12px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.highlights::-webkit-scrollbar { display: none; }

.highlight {
  flex: 0 0 auto;
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.highlight-ring {
  width: 68px;
  height: 68px;
  padding: 2.5px;
  border-radius: var(--radius-full);
  background: var(--ring);
}
.highlight.is-active .highlight-ring {
  padding: 3.5px;
}
.highlight-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg);
  background: var(--bg-soft);
}
.highlight:focus-visible .highlight-ring {
  outline: 2px solid var(--hashtag);
  outline-offset: 2px;
}
.highlight-label {
  font-size: 12px;
  line-height: 1.2;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.highlight.is-active .highlight-label { font-weight: 700; }

/* ---------- tabs ---------- */
.tabs {
  width: min(var(--max), 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tab svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.tab:focus-visible { outline: 2px solid var(--hashtag); outline-offset: -2px; }

/* ---------- grid ---------- */
.feed { width: min(var(--max), 100%); margin: 0 auto 32px; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-soft);
  isolation: isolate;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
}
.tile:hover img,
.tile:focus-visible img { filter: brightness(0.92); }
.tile:focus-visible { outline: 2px solid var(--hashtag); outline-offset: -2px; }

.badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 20px;
  height: 20px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.badge svg { width: 20px; height: 20px; display: block; }

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

.site-footer {
  padding: 8px 16px 36px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.site-footer p { margin: 0; }

/* ---------- post view ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: var(--bg);
}
.lightbox[hidden] { display: none; }

.lightbox-backdrop { display: none; }
.post-step { display: none; }

.post-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100dvh;
  background: var(--bg);
  overflow: auto;
}

.post-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px 0 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.post-back,
.post-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.post-close { display: none; margin-left: auto; }
.post-back svg,
.post-close svg,
.post-step svg,
.slide-nav svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.post-back:focus-visible,
.post-close:focus-visible,
.post-step:focus-visible,
.slide-nav:focus-visible,
.highlight:focus-visible {
  outline: 2px solid var(--hashtag);
  outline-offset: 1px;
}
.post-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--ring);
  padding: 1.5px;
  background-clip: padding-box, border-box;
  border: 1.5px solid transparent;
  /* simpler: use a thin gradient ring via box */
  padding: 0;
  box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 3px #f4a3c2;
}
.post-user {
  font-weight: 700;
  font-size: 14px;
}

.post-media {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  overflow: hidden;
}
.slides {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide {
  position: relative;
  isolation: isolate;
  display: none;
  width: 100%;
  align-items: center;
  justify-content: center;
}
.slide.is-active { display: flex; }
.slide-bg {
  position: absolute;
  inset: -16px;
  z-index: 0;
  background: center / cover no-repeat;
  filter: blur(28px) brightness(0.4);
  transform: scale(1.08);
  pointer-events: none;
}
.slide img,
.slide video {
  position: relative;
  z-index: 1;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(125vw, 78dvh);
  object-fit: contain;
  background: #000;
}
.dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 5px;
  z-index: 2;
  pointer-events: none;
}
.dots[hidden],
.slide-nav[hidden] { display: none; }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.dot.is-active { background: #fff; }

.slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: #111;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.slide-nav.prev { left: 8px; }
.slide-nav.next { right: 8px; }
.slide-nav svg { width: 16px; height: 16px; }

.post-body { padding: 12px 16px 24px; }
.post-caption {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  word-wrap: break-word;
}
.post-caption strong {
  font-weight: 700;
  margin-right: 6px;
}
.post-tags {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--hashtag);
  word-break: break-word;
}
.post-status {
  margin: 10px 0 0;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--banner-ink);
  background: var(--banner-bg);
}
.post-status[hidden] { display: none; }
.post-date {
  margin: 10px 0 0;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

body.modal-open { overflow: hidden; }
body.modal-open .topbar { z-index: 0; }

@media (min-width: 800px) {
  .topbar-inner { padding: 0 20px; height: 52px; }
  .topbar-name { font-size: 22px; }

  .profile {
    padding: 36px 20px 16px;
    grid-template-columns: 200px 1fr;
    grid-template-areas:
      "avatar stats"
      "avatar bio"
      "highlights highlights";
    column-gap: 48px;
    row-gap: 8px;
    align-items: start;
  }
  .avatar-wrap {
    width: 150px;
    height: 150px;
    padding: 4px;
    align-self: center;
    grid-row: 1 / 3;
  }
  .avatar-wrap img { border-width: 3px; }
  .profile {
    row-gap: 16px;
  }
  .profile-stats { align-self: end; padding-top: 28px; padding-bottom: 2px; }
  .stat { flex-direction: row; align-items: baseline; gap: 8px; }
  .stat b { font-size: 20px; }
  .profile-bio { align-self: start; padding-bottom: 12px; }
  .profile-bio h1 { font-size: 16px; margin-bottom: 6px; }
  .place { margin-top: 8px; }
  .highlights {
    margin: 12px 0 4px;
    padding: 8px 0 12px;
    gap: 24px;
  }

  .tabs { margin-top: 8px; }
  .tab { letter-spacing: 0.1em; }
  .feed { margin-bottom: 48px; }
  .grid { gap: 3px; }

  /* Desktop post: overlay + two-pane */
  .lightbox {
    align-items: center;
    background: transparent;
    padding: 0 56px;
  }
  .lightbox-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--overlay);
    border: 0;
  }
  .post-step {
    display: grid;
    place-items: center;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  .post-step[hidden] { display: none; }
  .post-step.prev { left: 12px; }
  .post-step.next { right: 12px; }
  .post-step:hover { background: #fff; }

  .post-view {
    position: relative;
    z-index: 1;
    flex-direction: row;
    align-items: stretch;
    width: min(100%, 1080px);
    height: min(86dvh, 820px);
    max-height: min(86dvh, 820px);
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  }
  .post-head {
    position: absolute;
    top: 0;
    right: 0;
    width: 340px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }
  .post-back { display: none; }
  .post-close { display: grid; }
  .post-media {
    flex: 1 1 58%;
    min-width: 0;
    min-height: 0;
    height: 100%;
  }
  .slides,
  .slide,
  .slide.is-active { height: 100%; }
  .slide img,
  .slide video { max-height: 100%; }
  .slide-nav { display: none; }
  .post-body {
    flex: 0 0 340px;
    width: 340px;
    padding: 60px 16px 20px;
    overflow: auto;
    border-left: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile img { filter: none; }
}
