:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --fg: #101010;
  --fg-dim: #737373;
  --line: #dbdbdb;
  --tile: #efefef;
  --ring-a: #f9ce34;
  --ring-b: #ee2a7b;
  --ring-c: #6228d7;
  --overlay: rgba(0, 0, 0, .72);
  --maxw: 935px;
  --gap: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elev: #121212;
    --fg: #f5f5f5;
    --fg-dim: #a8a8a8;
    --line: #262626;
    --tile: #1a1a1a;
    --overlay: rgba(0, 0, 0, .85);
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #121212;
  --fg: #f5f5f5;
  --fg-dim: #a8a8a8;
  --line: #262626;
  --tile: #1a1a1a;
  --overlay: rgba(0, 0, 0, .85);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--font);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font: 700 22px/1 var(--font);
  letter-spacing: -.02em;
  color: var(--fg);
  text-decoration: none;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.theme-toggle::before { content: "◐"; font-size: 15px; line-height: 1; }

/* ---------- profile ---------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.profile {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.avatar-wrap { display: grid; place-items: center; }

.avatar-ring {
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--ring-a), var(--ring-b), var(--ring-c), var(--ring-a));
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
  background: var(--tile);
}

.profile-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.username {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -.01em;
}

.stats {
  display: flex;
  gap: 40px;
  list-style: none;
  margin: 20px 0;
  padding: 0;
  color: var(--fg);
}

.stats strong { font-weight: 600; }

.bio { max-width: 40ch; }
.fullname { font-weight: 600; }
.bio-text { margin: 0; white-space: pre-wrap; }
.bio-link { color: #00376b; font-weight: 600; text-decoration: none; word-break: break-all; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bio-link { color: #e0f1ff; } }
:root[data-theme="dark"] .bio-link { color: #e0f1ff; }

/* ---------- highlights ---------- */

.highlights {
  display: flex;
  gap: 28px;
  padding: 8px 0 28px;
  overflow-x: auto;
  scrollbar-width: none;
}

.highlights::-webkit-scrollbar { display: none; }

.hl { border: 0; background: none; cursor: pointer; text-align: center; padding: 0; }

.hl-circle {
  width: 77px;
  height: 77px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--tile) center/cover no-repeat;
  margin-bottom: 8px;
}

.hl-label {
  display: block;
  width: 84px;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  justify-content: center;
  gap: 60px;
  border-top: 1px solid var(--line);
}

.tab {
  border: 0;
  border-top: 1px solid transparent;
  background: none;
  cursor: pointer;
  padding: 16px 0;
  margin-top: -1px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.tab.is-active { color: var(--fg); border-top-color: var(--fg); }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  padding: 24px 0 48px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--tile);
  overflow: hidden;
}

.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; }

.tile-ph { width: 100%; height: 100%; }

.tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
  pointer-events: none;
}

.tile-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-weight: 600;
  opacity: 0;
  transition: opacity .15s ease;
}

.tile:hover .tile-hover, .tile:focus-visible .tile-hover { opacity: 1; }

.stats-mobile { display: none; }

.empty { text-align: center; color: var(--fg-dim); padding: 0 0 64px; }
.empty code { background: var(--tile); padding: 2px 6px; border-radius: 4px; }

.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 48px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ---------- lightbox ---------- */

.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--fg);
}

.lightbox::backdrop { background: var(--overlay); }

.lb-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  width: min(1100px, 92vw);
  height: min(720px, 88vh);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.lb-media {
  position: relative;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-media .tile-ph { width: 100%; height: 100%; }

.lb-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
}

.lb-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.lb-dot.is-on { background: #fff; }

.lb-step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  color: #111;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.lb-step-prev { left: 10px; }
.lb-step-next { right: 10px; }

.lb-side { display: flex; flex-direction: column; border-left: 1px solid var(--line); min-width: 0; }

.lb-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--tile); }
.lb-user { font-weight: 600; }
.lb-loc { font-size: 12px; color: var(--fg-dim); }

.lb-body { flex: 1; overflow-y: auto; padding: 16px; }
.lb-caption { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.lb-foot { border-top: 1px solid var(--line); padding: 12px 16px; }
.lb-counts { font-weight: 600; }
.lb-date { display: block; margin-top: 4px; font-size: 11px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .3px; }

.lb-close, .lb-nav {
  position: fixed;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}

.lb-close { top: 12px; right: 20px; font-size: 34px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 48px; padding: 0 14px; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }

/* ---------- responsive ---------- */

@media (max-width: 735px) {
  :root { --gap: 2px; }

  .page { padding: 0 0 0 0; }

  .profile {
    grid-template-columns: auto 1fr;
    gap: 16px;
    padding: 16px;
    align-items: start;
  }

  .avatar { width: 88px; height: 88px; }

  .profile .stats { display: none; }

  .profile-meta .bio { max-width: none; }

  .stats-mobile {
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: center;
  }

  .stats-mobile li { display: flex; flex-direction: column; font-size: 12px; color: var(--fg-dim); }
  .stats-mobile strong { color: var(--fg); font-size: 14px; }

  .highlights { padding: 12px 16px 16px; gap: 18px; }
  .tabs { gap: 0; }
  .tab { flex: 1; padding: 12px 0; }
  .grid { padding: 2px 0 32px; }

  .lb-card {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .lb-side { border-left: 0; border-top: 1px solid var(--line); max-height: 42vh; }
  .lb-nav { display: none; }
  .lb-close { top: 8px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
