:root {
  --bg: #fff; --fg: #000; --muted: #737373; --line: #dbdbdb;
  --btn: #efefef; --btn-fg: #000; --accent: #ff5e5b; --accent-fg: #fff;
  --tile: #f2f2f2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --fg: #f5f5f5; --muted: #a8a8a8; --line: #262626;
    --btn: #262626; --btn-fg: #f5f5f5; --tile: #121212;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.handle { font-weight: 700; font-size: 20px; letter-spacing: -.3px; }
.top-kofi {
  text-decoration: none; font-weight: 600; font-size: 13px;
  background: var(--accent); color: var(--accent-fg); padding: 6px 12px; border-radius: 8px;
}

main { max-width: 935px; margin: 0 auto; }

/* profile header (mobile first) */
.profile {
  display: grid; grid-template-columns: 86px 1fr; gap: 12px 24px; align-items: center;
  padding: 16px;
}
.avatar {
  width: 86px; height: 86px; border-radius: 50%; padding: 3px;
  background: conic-gradient(#f9ce34, #ee2a7b, #6228d7, #f9ce34);
}
.avatar span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--tile); border: 3px solid var(--bg);
  font-weight: 700; font-size: 26px; color: var(--muted);
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); }
.stats { display: flex; gap: 28px; }
.stats div { display: flex; flex-direction: column; align-items: center; }
.stats b { font-size: 17px; }
.stats span { color: var(--muted); font-size: 13px; }
.bio { grid-column: 1 / -1; }
.bio h1 { font-size: 14px; margin: 0 0 2px; }
.bio p { margin: 0; }
.actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.btn {
  flex: 1; text-align: center; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 8px; background: var(--btn); color: var(--btn-fg);
  border: 0; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); }

.tabs { display: flex; justify-content: center; border-top: 1px solid var(--line); }
.tab { padding: 12px 0; font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); }
.tab.active { color: var(--fg); border-top: 1px solid var(--fg); margin-top: -1px; }

/* the grid: 3 columns, portrait tiles, hairline gaps */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.tile {
  position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--tile);
  border: 0; padding: 0; cursor: pointer; display: block;
}
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .3s;
}
.tile img.loaded { opacity: 1; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.note { text-align: center; color: var(--muted); padding: 24px; }

.foot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 12px;
}

/* larger screens: centred profile like a desktop profile page */
@media (min-width: 736px) {
  .profile { grid-template-columns: 150px 1fr; padding: 32px 16px 40px; column-gap: 64px; }
  .avatar { width: 150px; height: 150px; grid-row: 1 / span 3; }
  .avatar span { font-size: 40px; }
  .stats, .bio, .actions { grid-column: 2; }
  .stats div { flex-direction: row; gap: 5px; }
  .actions { max-width: 420px; }
  .grid { gap: 4px; }
}

/* full-screen viewer */
.viewer {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.94);
  display: flex; align-items: center; justify-content: center; touch-action: pan-y;
}
.viewer[hidden] { display: none; }
.viewer img { max-width: 100vw; max-height: calc(100dvh - 96px); object-fit: contain; user-select: none; }
.viewer button {
  position: absolute; background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 40px; line-height: 1; padding: 12px 16px; opacity: .85;
}
.v-close { top: calc(4px + env(safe-area-inset-top)); right: 4px; font-size: 26px !important; }
.v-prev { left: 0; } .v-next { right: 0; }
@media (hover: none) { .v-prev, .v-next { display: none; } }
.v-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); color: #ccc; font-size: 13px;
}
.v-bar a {
  color: #fff; text-decoration: none; font-weight: 600;
  background: var(--accent); padding: 7px 12px; border-radius: 8px;
}
body.locked { overflow: hidden; }
