*{box-sizing:border-box}
:root{color-scheme:light;--bg:#fff;--text:#262626;--muted:#737373;--line:#dbdbdb;--panel:#fff;--button:#0095f6;--hover:#f5f5f5;--tile:#efefef;--viewer:#111}
body.dark{color-scheme:dark;--bg:#000;--text:#f5f5f5;--muted:#a8a8a8;--line:#262626;--panel:#101010;--button:#0095f6;--hover:#1b1b1b;--tile:#181818;--viewer:#080808}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px}body{transition:background-color .15s ease,color .15s ease}button,a{font:inherit}button{cursor:pointer}button:disabled{cursor:default;opacity:.4}
.topbar{height:60px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 max(20px,calc((100% - 975px)/2));background:var(--bg)}.wordmark{font-family:Georgia,serif;font-style:italic;font-size:26px;font-weight:700;color:var(--text);text-decoration:none;letter-spacing:-1px}.icon-button{border:0;background:transparent;color:var(--text);font-size:19px;padding:8px 10px;border-radius:7px}.icon-button:hover,.action-button:hover{background:var(--hover)}.theme-toggle{display:flex;align-items:center;gap:8px}.theme-label{font-size:13px;font-weight:500}
.page-shell{max-width:935px;margin:0 auto;padding:30px 20px 45px}.profile-header{display:grid;grid-template-columns:minmax(160px,1fr) 2fr;gap:30px;min-height:180px;padding:0 0 28px}.avatar-wrap{display:flex;justify-content:center;align-items:flex-start}.profile-avatar{width:150px;height:150px;border-radius:50%;object-fit:cover;background:var(--tile);border:1px solid var(--line)}.profile-details{padding-top:8px}.profile-title{display:flex;align-items:center;gap:12px;margin-bottom:22px}.profile-title h1{font-size:20px;font-weight:400;margin:0}.stats{display:flex;gap:32px;margin-bottom:20px;font-size:15px}.stats strong{font-weight:600}.display-name{font-weight:600}
.tabs{height:53px;border-top:1px solid var(--line);display:flex;justify-content:center;gap:60px}.tab{border:0;border-top:1px solid transparent;margin-top:-1px;padding:0;display:flex;align-items:center;gap:7px;background:transparent;color:var(--muted);font-size:12px;font-weight:600;letter-spacing:1px}.tab.active{border-top-color:var(--text);color:var(--text)}.tab-icon{font-size:19px;line-height:1}
.post-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}.grid-item{position:relative;display:block;aspect-ratio:1/1;overflow:hidden;padding:0;border:0;background:var(--tile)}.grid-media{display:block;width:100%;height:100%;object-fit:cover}.grid-item:focus-visible{outline:3px solid var(--button);outline-offset:-3px}.video-mark{position:absolute;top:9px;right:10px;color:#fff;text-shadow:0 1px 5px #333;font-size:21px;filter:drop-shadow(0 1px 3px #333);pointer-events:none}.grid-item.media-unavailable::after{content:"Media unavailable";position:absolute;inset:0;display:grid;place-items:center;color:var(--muted);font-size:12px;background:var(--tile)}.status{text-align:center;color:var(--muted);padding:15px 0 0;min-height:34px;font-size:12px}
.viewer{position:fixed;inset:0;z-index:20;background:rgba(0,0,0,.88);display:flex;align-items:center;justify-content:center;padding:38px 58px}.viewer[hidden]{display:none}.viewer-close{position:absolute;top:10px;right:16px;z-index:3;border:0;background:transparent;color:#fff;font-size:38px;line-height:1;padding:5px 10px}.post-dialog{display:flex;width:min(1160px,100%);height:min(88vh,850px);min-height:300px;background:var(--panel);color:var(--text);overflow:hidden}.viewer-media{flex:1;min-width:0;min-height:0;display:flex;align-items:center;justify-content:center;background:var(--viewer);position:relative;overflow:hidden}.viewer-media img,.viewer-media video{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;object-position:center}.viewer-media video{width:100%;height:100%;object-fit:contain}.media-loading{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:#eee;font-size:13px;background:var(--viewer);z-index:1}.media-loading video{position:absolute;width:1px;height:1px;opacity:.01;pointer-events:none}.spinner{width:27px;height:27px;border:2px solid #777;border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.media-error{color:#fff;text-align:center;padding:24px;max-width:360px;line-height:1.5}
.post-sidebar{width:335px;flex:0 0 335px;display:flex;flex-direction:column;min-width:0}.post-author{height:62px;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 14px;gap:10px;flex-shrink:0}.mini-avatar{width:32px;height:32px;border-radius:50%;object-fit:cover;background:var(--tile)}.post-author div{display:flex;flex-direction:column;gap:3px}.post-author strong{font-size:13px}.post-author small{color:var(--muted);font-size:11px}.caption-area{padding:18px 16px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;flex:1;min-height:40px}.caption-area .caption-user{font-weight:600;margin-right:7px}.post-actions{border-top:1px solid var(--line);display:flex;align-items:center;padding:7px 10px;gap:2px;flex-shrink:0}.action-button{border:0;background:transparent;color:var(--text);font-size:27px;padding:5px 7px;border-radius:6px;line-height:1.1}.action-button.liked{color:#ff3040}.action-button:disabled{opacity:.35}.save-action{margin-left:auto}.sidebar-footer{display:flex;justify-content:space-between;gap:8px;padding:10px 14px;color:var(--muted);font-size:11px;border-top:1px solid var(--line);flex-shrink:0;min-height:36px}.post-step{position:absolute;top:50%;transform:translateY(-50%);z-index:2;width:40px;height:40px;border:0;border-radius:50%;background:#fff;color:#222;font-size:30px;line-height:1;box-shadow:0 1px 8px #0003}.post-step.prev{left:12px}.post-step.next{right:12px}.post-step:disabled{opacity:.25}
@media(min-width:1100px){.post-dialog{width:min(1160px,calc(100vw - 130px))}}
@media(max-width:760px){.topbar{height:54px;padding:0 16px}.page-shell{padding:22px 0 28px}.profile-header{grid-template-columns:110px 1fr;gap:16px;padding:0 16px 20px;min-height:130px}.profile-avatar{width:86px;height:86px}.profile-details{padding-top:2px}.profile-title{gap:8px;margin-bottom:16px}.profile-title h1{font-size:19px}.stats{gap:18px;font-size:14px;margin-bottom:12px}.tabs{gap:0;justify-content:space-around;height:48px}.tab{justify-content:center;flex:1}.tab span:not(.tab-icon){font-size:10px;letter-spacing:.7px}.post-grid{gap:2px}.viewer{padding:0;align-items:stretch}.post-dialog{width:100%;height:100%;min-height:0;flex-direction:column;overflow:auto}.viewer-media{flex:1 0 48vh;min-height:0;max-height:70vh}.viewer-media img,.viewer-media video{max-width:100%;max-height:100%;width:auto;height:auto}.viewer-media video{width:100%;height:100%;object-fit:contain}.post-sidebar{width:100%;flex:0 0 auto;min-height:160px}.post-author{height:56px}.caption-area{flex:0 0 auto;max-height:18vh;min-height:0;padding:12px 14px}.post-actions{padding:5px 8px}.viewer-close{top:6px;right:8px;width:38px;height:38px;border-radius:50%;background:#0008;font-size:31px}.post-step{width:32px;height:32px;font-size:24px}.post-step.prev{left:8px}.post-step.next{right:8px}.sidebar-footer{padding:8px 12px}.theme-label{font-size:12px}}
@media(max-width:380px){.profile-header{grid-template-columns:80px 1fr;gap:12px}.profile-avatar{width:68px;height:68px}.profile-title h1{font-size:17px}.stats{gap:12px;font-size:13px}.tab span:not(.tab-icon){font-size:9px}.viewer-media{flex-basis:45vh}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}

/* Refined Instagram-style media markers and photo-group carousel controls */
.grid-item{isolation:isolate;cursor:pointer;transition:filter .16s ease,transform .16s ease}
.grid-item:hover{filter:brightness(.88)}
.grid-item:active{transform:scale(.992)}
.video-mark,.carousel-mark{position:absolute;top:10px;right:10px;z-index:2;width:31px;height:31px;display:grid;place-items:center;pointer-events:none}
.video-mark svg{width:27px;height:27px;fill:#fff;stroke:#fff;stroke-width:1.1;filter:drop-shadow(0 1px 5px #000b)}
.video-mark svg path{fill:#111;stroke:#111}
.carousel-mark{top:9px;right:9px;width:28px;height:28px;border-radius:7px;background:rgba(15,15,15,.62);backdrop-filter:blur(5px)}
.carousel-mark svg{width:19px;height:19px;fill:none;stroke:#fff;stroke-width:1.8;stroke-linejoin:round}
.group-count{position:absolute;right:8px;bottom:8px;z-index:2;min-width:24px;height:22px;padding:0 6px;display:grid;place-items:center;border:1px solid #ffffff80;border-radius:999px;background:#111b;color:#fff;font-size:11px;font-weight:700;line-height:1;backdrop-filter:blur(6px);pointer-events:none}
.has-carousel::before{content:"";position:absolute;inset:0;z-index:1;pointer-events:none;box-shadow:inset 0 0 0 1px #fff0}
.carousel-controls{position:absolute;inset:0;display:flex;align-items:center;justify-content:space-between;padding:0 12px;pointer-events:none;z-index:4}
.carousel-step{pointer-events:auto;width:36px;height:36px;border:1px solid #ffffff7d;border-radius:50%;display:grid;place-items:center;background:rgba(20,20,20,.56);color:#fff;box-shadow:0 2px 14px #0003;backdrop-filter:blur(8px);transition:background .15s ease,transform .15s ease}
.carousel-step:hover:not(:disabled){background:rgba(20,20,20,.82);transform:scale(1.06)}
.carousel-step:disabled{opacity:0;pointer-events:none}
.carousel-step svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:2.1;stroke-linecap:round;stroke-linejoin:round}
.carousel-counter{position:absolute;top:14px;left:50%;transform:translateX(-50%);padding:6px 10px;border:1px solid #ffffff50;border-radius:999px;background:#111a;color:#fff;font-size:11px;font-weight:600;letter-spacing:.3px;backdrop-filter:blur(8px)}
.viewer-media .media-loading{z-index:5}
.viewer-media .opened-image{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;object-position:center}
@media(max-width:760px){.video-mark,.carousel-mark{top:5px;right:5px}.video-mark svg{width:24px;height:24px}.carousel-mark{width:25px;height:25px}.group-count{right:5px;bottom:5px;height:19px;min-width:21px;font-size:10px}.carousel-controls{padding:0 8px}.carousel-step{width:33px;height:33px}.carousel-counter{top:10px}}
@media(prefers-reduced-motion:reduce){.grid-item,.carousel-step{transition:none}}


/* Profile tab: round, cropped media tiles that read like a profile/avatar gallery. */
.post-grid.profile-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:clamp(14px,2.5vw,28px);padding:10px clamp(12px,4vw,48px) 24px;max-width:900px;margin:0 auto}
.post-grid.profile-grid .grid-item{aspect-ratio:1/1;border-radius:50%;overflow:hidden;border:2px solid var(--line);padding:3px;background:var(--bg);box-shadow:0 2px 10px #0000000a;transition:transform .18s ease,box-shadow .18s ease}
.post-grid.profile-grid .grid-media{border-radius:50%;object-fit:cover}
.post-grid.profile-grid .grid-item:hover{filter:none;transform:translateY(-2px);box-shadow:0 5px 18px #00000018}
.post-grid.profile-grid .video-mark,.post-grid.profile-grid .carousel-mark{top:12%;right:12%;width:27px;height:27px;border-radius:50%;background:rgba(15,15,15,.68);backdrop-filter:blur(6px)}
.post-grid.profile-grid .video-mark svg{width:20px;height:20px}
.post-grid.profile-grid .carousel-mark svg{width:17px;height:17px}
.post-grid.profile-grid .group-count{right:9%;bottom:9%;height:20px;min-width:20px;font-size:10px}
@media(max-width:760px){.post-grid.profile-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(10px,3.5vw,20px);padding:8px 18px 22px}.post-grid.profile-grid .grid-item{padding:2px}.post-grid.profile-grid .video-mark,.post-grid.profile-grid .carousel-mark{width:23px;height:23px}.post-grid.profile-grid .video-mark svg{width:17px;height:17px}.post-grid.profile-grid .group-count{height:18px;min-width:18px;font-size:9px}}
@media(max-width:380px){.post-grid.profile-grid{gap:9px;padding-inline:14px}}


/* Real video-frame thumbnails: muted, paused, square-cropped and free of native controls. */
.grid-item video.grid-media{background:#161616;object-fit:cover;display:block}
.grid-item video.grid-media:not(.video-frame-ready){background:linear-gradient(135deg,#202020,#454545)}
.grid-item video.grid-media.video-frame-ready{opacity:1}
.virtual-spacer{display:block;min-height:0!important;width:100%;visibility:hidden;border:0;margin:0;padding:0}

/* Reel viewer: thumbnail-first stage, buffering spinner, big play fallback */
.video-stage{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:var(--viewer)}
.video-stage video{width:100%;height:100%;object-fit:contain;background:#000}
.video-buffering{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;z-index:2}
.video-buffering .spinner{background:rgba(0,0,0,.35);box-sizing:content-box;padding:6px;border-radius:50%}
.video-bigplay{position:absolute;z-index:3;width:68px;height:68px;border:0;border-radius:50%;background:rgba(0,0,0,.55);display:grid;place-items:center;cursor:pointer}
.video-bigplay[hidden]{display:none}
.video-bigplay svg{width:34px;height:34px;fill:#fff;margin-left:3px}
.video-buffering{flex-direction:column;gap:10px}.buffer-note{color:#fff;font-size:12px;text-shadow:0 1px 4px #000}
.grid-item video.grid-media[poster]{background:#161616}

/* ---- Up/down post navigation (Instagram reels style) ---- */
.viewer{overscroll-behavior:contain}
.viewer-media{touch-action:pan-x pinch-zoom}
.post-step{left:auto;right:12px;transform:none;display:grid;place-items:center;padding:0}
.post-step svg{width:22px;height:22px;fill:none;stroke:#222;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.post-step.prev{top:calc(50% - 48px);left:auto;right:12px}
.post-step.next{top:calc(50% + 8px);left:auto;right:12px}
.post-step:hover:not(:disabled){background:#f2f2f2}

/* ---- Mobile: full-screen reels layout ---- */
@media(max-width:760px){
  .post-step{display:none}
  .viewer{background:#000;padding:0}
  .post-dialog{position:relative;width:100%;height:100%;flex-direction:column;overflow:hidden;background:#000;color:#fff}
  .viewer-media{flex:1 1 auto;min-height:0;max-height:none;height:100%;width:100%}
  .post-sidebar{position:absolute;left:0;right:0;bottom:0;z-index:3;width:100%;min-height:0;flex:none;color:#fff;
    background:linear-gradient(to top,rgba(0,0,0,.72),rgba(0,0,0,0));padding:46px 64px calc(58px + env(safe-area-inset-bottom)) 0;pointer-events:none}
  .post-sidebar>*{pointer-events:auto}
  .post-author{height:auto;border:0;padding:0 14px 6px;color:#fff}
  .post-author small{color:rgba(255,255,255,.75)}
  .caption-area{padding:2px 14px 0;max-height:14vh;color:#fff;font-size:14px;text-shadow:0 1px 3px #0009}
  .sidebar-footer{display:none}
  .post-actions{position:absolute;right:6px;bottom:calc(86px + env(safe-area-inset-bottom));flex-direction:column;border:0;padding:0;gap:6px;background:transparent}
  .action-button{color:#fff;font-size:29px;width:46px;height:46px;display:grid;place-items:center;text-shadow:0 1px 4px #0008}
  .action-button.liked{color:#ff3040}
  .viewer-close{top:calc(8px + env(safe-area-inset-top));right:10px;z-index:6}
  .video-stage video{background:#000}
}

/* ---- Priority loader visuals ---- */
.grid-item{contain:layout paint}
.grid-item img.grid-media{opacity:0;transition:opacity .28s ease}
.grid-item img.grid-media.img-ready{opacity:1}
.grid-item:not(.media-unavailable){background:linear-gradient(110deg,var(--tile) 30%,rgba(128,128,128,.18) 50%,var(--tile) 70%);background-size:220% 100%;animation:tileShimmer 1.3s linear infinite}
@keyframes tileShimmer{to{background-position:-120% 0}}
.grid-item video.grid-media.previewing{background:#000}
/* low-resolution photo shows blurred, then sharpens when the better version arrives */
.viewer-media .opened-image{transition:filter .35s ease,transform .35s ease}
.viewer-media .opened-image.lowres{filter:blur(9px);transform:scale(1.03)}
@media (prefers-reduced-motion:reduce){.grid-item .grid-media,.viewer-media .opened-image{transition:none!important;animation:none!important}}
