/* ---------- tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-soft: #efefef;
  --bg-hover: #f2f2f2;
  --text: #0f1419;
  --muted: #737373;
  --border: #dbdbdb;
  --primary: #0095f6;
  --primary-hover: #1877f2;
  --like: #ff3040;
  --overlay: rgba(0, 0, 0, 0.65);
  --ring: linear-gradient(45deg, #f9ce34, #ee2a7b 50%, #6228d7);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #262626;
  --bg-soft: #363636;
  --bg-hover: #1a1a1a;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --border: #363636;
  --primary: #0095f6;
  --primary-hover: #4cb5f9;
  --overlay: rgba(0, 0, 0, 0.8);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elev: #262626;
    --bg-soft: #363636;
    --bg-hover: #1a1a1a;
    --text: #f5f5f5;
    --muted: #a8a8a8;
    --border: #363636;
    --primary-hover: #4cb5f9;
    --overlay: rgba(0, 0, 0, 0.8);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* theme icons */
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- side nav (desktop) ---------- */
.sidenav {
  position: fixed; inset: 0 auto 0 0; width: 245px;
  border-right: 1px solid var(--border);
  padding: 28px 12px 20px;
  display: flex; flex-direction: column;
  background: var(--bg); z-index: 20;
}
.logo { display: block; padding: 6px 12px 26px; font-family: "Grand Hotel", "Snell Roundhand", cursive; font-size: 34px; font-weight: 400; line-height: 1.2; letter-spacing: 0.2px; }
.logo-icon { display: none; }
.sidenav nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px; border-radius: 8px; font-size: 16px; text-align: left; width: 100%;
  transition: background .15s;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item:hover svg { transform: scale(1.06); }
.nav-item svg { transition: transform .15s; }
.nav-item.active { font-weight: 700; }
.nav-item.active svg { stroke-width: 2.6; }

@media (max-width: 1263px) {
  .sidenav { width: 73px; }
  .nav-item span, .logo-full { display: none; }
  .logo-icon { display: block; }
  .logo { padding: 6px 0 26px; text-align: center; }
}

/* ---------- top & bottom bars (mobile) ---------- */
.topbar, .bottomnav { display: none; }

/* ---------- profile ---------- */
.profile { margin-left: 245px; max-width: 975px; padding: 30px 20px 0; }
@media (min-width: 1264px) { .profile { margin-left: calc(245px + max(0px, (100vw - 245px - 975px) / 2)); } }
@media (max-width: 1263px) { .profile { margin-left: 73px; margin-inline: auto; padding-left: 93px; } }

.profile-head { display: flex; gap: 30px; align-items: flex-start; margin-bottom: 44px; }
.avatar-ring {
  flex: 0 0 auto; width: 168px; height: 168px; border-radius: 50%;
  padding: 4px; background: var(--ring); margin: 0 50px 0 40px;
  transition: transform .2s;
}
.avatar-ring:hover { transform: scale(1.02); }
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 4px solid var(--bg); }
.avatar-ring.seen { background: var(--border); }

.profile-info { flex: 1; min-width: 0; }
.name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 20px; }
.username { font-size: 20px; font-weight: 400; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  background: var(--bg-soft); padding: 7px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px; transition: background .15s, filter .15s;
}
.btn:hover { filter: brightness(0.94); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); filter: none; }

.stats { list-style: none; display: flex; gap: 40px; font-size: 16px; margin-bottom: 20px; }
.stats b { font-weight: 600; }
.stats-mobile { display: none; }

.bio p { margin: 0; }
.fullname { font-weight: 600; }
.category { color: var(--muted); }
.bio-link { display: inline-flex; align-items: center; gap: 4px; color: #00376b; font-weight: 600; margin-top: 2px; }
:root[data-theme="dark"] .bio-link { color: #e0f1ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bio-link { color: #e0f1ff; } }
.bio-link svg { width: 14px; height: 14px; }
.bio-link:hover { text-decoration: underline; }

/* ---------- highlights ---------- */
.highlights {
  display: flex; gap: 40px; overflow-x: auto; padding: 0 20px 44px;
  scrollbar-width: none; border-bottom: 1px solid var(--border);
}
.highlights::-webkit-scrollbar { display: none; }
.hl { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 0 0 auto; width: 87px; }
.hl-ring {
  width: 87px; height: 87px; border-radius: 50%; padding: 3px;
  border: 1px solid var(--border); background: var(--bg);
}
.hl-ring span {
  width: 100%; height: 100%; border-radius: 50%; background: var(--bg-soft);
  display: grid; place-items: center; font-size: 32px; transition: transform .2s;
}
.hl:hover .hl-ring span { transform: scale(1.05); }
.hl b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- tabs ---------- */
.tabs { display: flex; justify-content: center; gap: 60px; scroll-margin-top: 10px; }
.tab {
  display: flex; align-items: center; gap: 6px; height: 52px;
  font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); border-top: 1px solid transparent; margin-top: -1px;
}
.tab svg { width: 12px; height: 12px; stroke-width: 2.4; }
.tab.active { color: var(--text); border-top-color: var(--text); }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--bg-soft);
  animation: fadeIn .35s ease both;
}
.tile.reel { aspect-ratio: 3 / 4; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.tile:hover img { transform: scale(1.03); }
.tile .badge { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.tile .badge svg { width: 20px; height: 20px; }
.tile-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  opacity: 0; transition: opacity .2s; padding: 12px; text-align: center;
}
.tile:hover .tile-overlay, .tile:focus-visible .tile-overlay { opacity: 1; }
.tile-overlay h3 { font-size: 16px; }
.tile-overlay .meta { display: flex; gap: 18px; font-weight: 700; }
.tile-overlay .meta span { display: inline-flex; align-items: center; gap: 6px; }
.tile-overlay svg { width: 19px; height: 19px; fill: #fff; stroke: #fff; }
.tile-text {
  width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 16px; text-align: center; color: #fff; gap: 6px;
}
.tile-text .big { font-size: clamp(20px, 4vw, 38px); }
.tile-text h3 { font-size: clamp(12px, 1.6vw, 17px); line-height: 1.25; }
.tile-text p { font-size: clamp(10px, 1.2vw, 13px); opacity: .85; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- footer ---------- */
.foot { text-align: center; padding: 48px 0 40px; font-size: 12px; color: var(--muted); display: grid; gap: 10px; }
.foot a:hover { text-decoration: underline; }

/* ---------- post modal ---------- */
.modal {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 40px 70px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-close { position: absolute; top: 14px; right: 16px; color: #fff; }
.modal-close svg { width: 28px; height: 28px; }
.modal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); color: #000;
  display: grid; place-items: center;
}
.modal-nav.prev { left: 20px; } .modal-nav.next { right: 20px; }
.modal-nav svg { width: 18px; height: 18px; stroke-width: 2.5; }
.post {
  display: flex; background: var(--bg-elev); border-radius: 4px; overflow: hidden;
  width: min(1100px, 100%); height: min(88vh, 760px); box-shadow: var(--shadow);
  animation: pop .22s ease;
}
:root[data-theme="dark"] .post, :root[data-theme="dark"] .sheet-card { background: #000; border: 1px solid var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .post, :root:not([data-theme="light"]) .sheet-card { background: #000; border: 1px solid var(--border); } }
@keyframes pop { from { transform: scale(1.04); opacity: 0; } }
.post-media { flex: 1 1 60%; background: #000; display: grid; place-items: center; position: relative; min-width: 0; }
.post-media img { width: 100%; height: 100%; object-fit: contain; }
.post-media iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
.post-media .tile-text { height: 100%; }
.post-side { flex: 0 0 400px; display: flex; flex-direction: column; border-left: 1px solid var(--border); min-width: 0; }
.post-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.post-head div { display: flex; flex-direction: column; line-height: 1.25; }
.post-head .muted { font-size: 12px; }
.post-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.post-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 10px; align-content: start; }
.post-body h2 { font-size: 16px; }
.post-body ul { padding-left: 18px; display: grid; gap: 6px; }
.tags { color: #00376b; line-height: 1.7; }
:root[data-theme="dark"] .tags { color: #e0f1ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tags { color: #e0f1ff; } }
.post-foot { border-top: 1px solid var(--border); padding: 8px 16px 14px; }
.post-actions { display: flex; gap: 14px; margin-bottom: 6px; }
.post-actions button { padding: 4px 0; transition: transform .12s, color .12s; }
.post-actions button:hover { color: var(--muted); }
.like-btn.liked { color: var(--like); }
.like-btn.liked:hover { color: var(--like); }
.like-btn.liked svg { fill: var(--like); }
.like-btn.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }
.likes { margin-bottom: 12px; }
.post-links { display: flex; gap: 8px; flex-wrap: wrap; }
.post-links a { flex: 1 1 auto; text-align: center; }

/* ---------- story viewer ---------- */
.story {
  position: fixed; inset: 0; background: #1a1a1a; z-index: 60;
  display: grid; place-items: center; animation: fade .2s ease;
}
.story-frame {
  position: relative; width: min(420px, 100vw); height: min(92vh, 760px);
  border-radius: 10px; overflow: hidden; color: #fff;
  background: linear-gradient(160deg, #833ab4, #fd1d1d 55%, #fcb045);
  display: flex; flex-direction: column;
}
.story-frame.t1 { background: linear-gradient(160deg, #0f2027, #2c5364); }
.story-frame.t2 { background: linear-gradient(160deg, #4158d0, #c850c0 60%, #ffcc70); }
.story-frame.t3 { background: linear-gradient(160deg, #11998e, #38ef7d); }
.story-frame.t4 { background: linear-gradient(160deg, #232526, #414345); }
.story-bars { display: flex; gap: 4px; padding: 10px 10px 0; position: relative; z-index: 3; }
.story-bars span { flex: 1; height: 2px; background: rgba(255,255,255,.35); border-radius: 2px; overflow: hidden; }
.story-bars i { display: block; height: 100%; width: 0; background: #fff; }
.story-bars span.done i { width: 100%; }
.story-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: relative; z-index: 3; }
.story-head img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.muted-light { opacity: .75; font-size: 13px; }
.story-close { margin-left: auto; color: #fff; }
.story-content { flex: 1; padding: 20px 28px 40px; display: flex; flex-direction: column; justify-content: center; gap: 14px; position: relative; z-index: 3; overflow-y: auto; pointer-events: none; }
.story-content h2 { font-size: 26px; line-height: 1.15; }
.story-content .kicker { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .8; }
.story-content p { font-size: 15px; opacity: .95; }
.story-content .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.story-content .chip { background: rgba(255,255,255,.18); backdrop-filter: blur(6px); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.story-content .cta { position: relative; z-index: 4; align-self: flex-start; background: #fff; color: #111; padding: 10px 18px; border-radius: 999px; font-weight: 700; margin-top: 6px; }
.story-content .story-avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; }
.story-tap { position: absolute; top: 60px; bottom: 0; width: 35%; z-index: 2; }
.story-tap.left { left: 0; } .story-tap.right { right: 0; width: 65%; }
.story-content a, .story-content button { pointer-events: auto; }

/* ---------- message sheet ---------- */
.sheet { position: fixed; inset: 0; background: var(--overlay); z-index: 70; display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
.sheet-card { background: var(--bg-elev); width: min(400px, 100%); border-radius: var(--radius); overflow: hidden; text-align: center; animation: pop .2s ease; }
.sheet-card h2 { font-size: 20px; padding: 24px 16px 4px; }
.sheet-card > p { padding-bottom: 16px; }
#sheetLinks a, .sheet-cancel {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px; border-top: 1px solid var(--border); font-size: 14px;
}
#sheetLinks a:hover, .sheet-cancel:hover { background: var(--bg-hover); }
#sheetLinks a:first-child { color: var(--primary); font-weight: 700; }
#sheetLinks svg { width: 20px; height: 20px; }

/* ---------- toast & heart ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  background: #262626; color: #fff; padding: 12px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.big-heart { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 80; }
.big-heart svg { width: 110px; height: 110px; fill: #fff; stroke: none; opacity: 0; filter: drop-shadow(0 4px 20px rgba(0,0,0,.4)); }
.big-heart.go svg { animation: heart .8s ease; }
@keyframes heart { 0% { opacity: 0; transform: scale(.3); } 15% { opacity: 1; transform: scale(1.15); } 30% { transform: scale(.95); } 45%, 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0); } }

/* ---------- tablet ---------- */
@media (max-width: 900px) {
  .avatar-ring { width: 150px; height: 150px; margin: 0 24px 0 0; }
  .modal { padding: 40px 54px; }
  .post-side { flex-basis: 340px; }
}

/* ---------- mobile ---------- */
@media (max-width: 767px) {
  .sidenav { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20; height: 50px; padding: 0 16px;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .topbar-user { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 18px; }
  .chev { width: 16px; height: 16px; }
  .topbar-actions { display: flex; gap: 18px; }
  .bottomnav {
    display: flex; justify-content: space-around; align-items: center;
    position: fixed; bottom: 0; left: 0; right: 0; height: 50px; z-index: 20;
    background: var(--bg); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a, .bottomnav button { padding: 10px; display: grid; place-items: center; }
  .mini-avatar img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

  .profile { margin: 0; padding: 16px 0 56px; max-width: none; }
  .profile-head { display: grid; grid-template-columns: auto 1fr; gap: 0 20px; padding: 0 16px; margin-bottom: 20px; }
  .avatar-ring { width: 86px; height: 86px; margin: 0; padding: 3px; grid-row: 1; }
  .avatar-ring img { border-width: 3px; }
  .profile-info { display: contents; }
  .name-row { grid-column: 2; grid-row: 1; align-self: center; margin: 0; flex-direction: column; align-items: flex-start; gap: 10px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; text-align: center; padding: 7px 8px; }
  .stats:not(.stats-mobile) { display: none; }
  .bio { grid-column: 1 / -1; padding-top: 14px; }
  .stats-mobile {
    display: flex; grid-column: 1 / -1; margin: 16px -16px 0; padding: 12px 16px; gap: 0;
    border-top: 1px solid var(--border); justify-content: space-around; text-align: center; font-size: 14px;
  }
  .stats-mobile li { display: flex; flex-direction: column; line-height: 1.3; }
  .stats-mobile span { color: var(--muted); }

  .highlights { gap: 16px; padding: 0 16px 20px; }
  .hl { width: 64px; gap: 6px; }
  .hl-ring { width: 64px; height: 64px; }
  .hl-ring span { font-size: 24px; }

  .tabs { gap: 0; border-top: 1px solid var(--border); }
  .tab { flex: 1; justify-content: center; height: 44px; border-top: 0; margin: 0; border-bottom: 1px solid transparent; }
  .tab span { display: none; }
  .tab svg { width: 24px; height: 24px; stroke-width: 1.8; }
  .tab.active { border-bottom-color: var(--text); }
  .tab.active svg { color: var(--text); }
  .grid { gap: 2px; }
  .tile-overlay { display: none; }
  .foot { padding-bottom: 20px; }

  .modal { padding: 0; align-items: stretch; }
  .modal-nav { display: none; }
  .modal-close { z-index: 2; top: 10px; right: 10px; background: rgba(0,0,0,.5); border-radius: 50%; padding: 4px; }
  .modal-close svg { width: 22px; height: 22px; }
  .post { flex-direction: column; height: 100%; border-radius: 0; overflow-y: auto; }
  .post-media { flex: 0 0 auto; min-height: 240px; }
  .post-media img { max-height: 60vh; }
  .post-side { flex: 1 0 auto; border-left: 0; }
  .post-head { order: -1; }
  .post-body { overflow: visible; }

  .story { background: #000; }
  .story-frame { width: 100vw; height: 100dvh; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
