:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --card: #ffffff;
  --fg: #111114;
  --muted: #8a8a90;
  --line: #e7e7ec;
  --accent: #0095f6;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 30px rgba(0,0,0,.06);
  --radius: 16px;
  --max: 960px;
}
[data-theme="dark"] {
  --bg: #0b0b0e;
  --surface: #17171c;
  --card: #131318;
  --fg: #f3f3f6;
  --muted: #9a9aa4;
  --line: #26262e;
  --accent: #0095f6;
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 14px 34px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
  overflow-x: clip; max-width: 100%;
}
a { color: inherit; }
img, video { max-width: 100%; }
/* Never let long words/URLs push the layout wider than the screen */
.post .caption, .cmt-body, .profile .pbio { overflow-wrap: anywhere; word-break: break-word; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 24px; font-weight: 800; letter-spacing: 2px;
  color: var(--fg); text-decoration: none;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .tag { color: var(--muted); font-size: 13px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  cursor: pointer; transition: background .15s, transform .1s;
}
.iconbtn:hover { background: var(--surface); }
.iconbtn:active { transform: scale(.92); }

main { max-width: var(--max); margin: 0 auto; padding: 24px 18px 64px; }

/* Profile header — Instagram style: avatar on the side, info beside it */
.profile {
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 34px;
  padding: 14px 6px 30px; margin-bottom: 22px; border-bottom: 1px solid var(--line);
}
.profile:empty { display: none; }
.profile .avatar {
  width: 130px; height: 130px; border-radius: 50%; object-fit: cover;
  flex: none; background: var(--surface); border: 1px solid var(--line);
}
.profile .pinfo { min-width: 0; }
.profile .pname { font-size: 23px; font-weight: 800; letter-spacing: 1px; margin: 0 0 12px; }
.profile .pstats { margin-bottom: 10px; }
.profile .pstats b { font-weight: 700; }
.profile .pcategory { color: var(--muted); font-size: 13px; font-weight: 600; }
.profile .pbio { margin-top: 4px; white-space: pre-wrap; max-width: 52ch; }
.profile .plinks { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.linkbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 11px;
  background: var(--accent); color: var(--accent-fg);
  font-weight: 600; font-size: 14px; text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.linkbtn:hover { opacity: .9; }
.linkbtn:active { transform: scale(.97); }

/* Search — single field, press Enter to search */
.search { position: relative; margin: 0 0 20px; }
.search-ic {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; transition: color .15s;
}
.search:focus-within .search-ic { color: var(--accent); }
.search input {
  width: 100%; padding: 15px 20px 15px 50px; border: 1px solid var(--line);
  border-radius: 16px; font: inherit; font-size: 15px; background: var(--surface); color: var(--fg);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:hover { background: var(--card); }
.search input:focus {
  outline: none; background: var(--card); border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.searchinfo { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.searchinfo b { color: var(--fg); }
.searchinfo a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 10px; }
.searchinfo:empty { display: none; }

/* Grid — flexible/responsive like the blog feed */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; gap: 12px; } }
.cell {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  background: var(--surface); display: block; border-radius: 12px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.cell.vid { background: #111; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (hover: hover) {
  .cell:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
}
.cell .multi {
  position: absolute; top: 9px; right: 10px; color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.7)); font-size: 16px;
}
.sentinel { height: 1px; }
.status { color: var(--muted); text-align: center; padding: 28px 0; }

/* Single post — player sizes to the media, no letterbox bars */
.post { max-width: 640px; margin: 0 auto; }
.post .stage { position: relative; display: flex; justify-content: center; }
.post .frame {
  width: fit-content; max-width: 100%; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  background: transparent;
}
.post .frame img, .post .frame video {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 82vh;
}
/* Album carousel — all slides preloaded, swipe or arrows, no page reload */
.carousel-wrap { position: relative; }
.carousel {
  display: flex; width: 100%; overflow-x: auto;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface);
}
.carousel::-webkit-scrollbar { display: none; }
.carousel .slide {
  flex: 0 0 100%; scroll-snap-align: start;
  display: flex; align-items: center; justify-content: center;
}
.carousel .slide img, .carousel .slide video {
  width: 100%; height: auto; max-height: 82vh; object-fit: contain; display: block;
}
.post .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.92); color: #111;
  font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.post .nav.prev { left: 10px; }
.post .nav.next { right: 10px; }
.dots { display: flex; gap: 6px; justify-content: center; padding: 14px 0; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }
.post .meta { padding: 18px 6px; }
.post .date { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.post .caption { white-space: pre-wrap; line-height: 1.7; }
.post .caption a { color: var(--accent); text-decoration: none; font-weight: 600; }
.post .caption a:hover { text-decoration: underline; }

/* Post actions (like / comment / share) */
.actions { display: flex; align-items: center; gap: 20px; padding: 16px 6px 2px; }
.act {
  display: inline-flex; align-items: center; gap: 7px; padding: 0;
  background: none; border: 0; color: var(--fg); cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none;
}
.act svg { transition: transform .12s ease; }
.act:active svg { transform: scale(.82); }
.act.like.on svg { fill: #ed4956; stroke: #ed4956; }
.act.share.copied::after {
  content: "Link copied"; margin-left: 8px; font-size: 13px; color: var(--muted);
}

/* Telegram full-story embed — centered, proportional, theme-matched */
.tgwrap { margin: 20px auto 6px; max-width: 480px; }
.chead-lite { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.tg-embed { margin: 6px 0; width: 100%; }
.tg-embed iframe {
  width: 100% !important; min-width: 0 !important; max-width: 100% !important;
  margin: 0 auto !important; border: 0; border-radius: 12px;
}
.tglink { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 14px; }
.tglink:hover { text-decoration: underline; }
.premium-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 18px; border-radius: 14px; background: var(--accent); color: var(--accent-fg);
  font-weight: 700; text-decoration: none; margin: 20px 0 6px; text-align: center;
}
.premium-cta:hover { opacity: .92; }

/* Comments */
.comments { margin-top: 6px; padding-top: 20px; border-top: 1px solid var(--line); }
.ctitle { font-size: 16px; font-weight: 700; margin: 0 0 16px; }
.cform { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.cinput { display: flex; gap: 8px; align-items: flex-end; }
.cinput .emojibtn {
  flex: 0 0 auto; width: 48px; height: 48px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--fg); font-size: 20px;
  cursor: pointer; line-height: 1;
}
.cinput .emojibtn:hover { background: var(--surface); }
.cform .cbody {
  flex: 1; height: 48px; min-height: 48px; max-height: 200px; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; font: inherit;
  background: var(--card); color: var(--fg); resize: none; overflow-y: auto; line-height: 1.4;
}
.cform .cbody:focus { outline: none; border-color: var(--accent); }
.cinput .btn { flex: 0 0 auto; height: 48px; padding: 0 24px; }
.emojipanel { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.emojipanel[hidden] { display: none; }
.emojipanel button { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 5px; border-radius: 8px; line-height: 1; }
.emojipanel button:hover { background: var(--surface); }
.cform .cmsg { font-size: 13px; color: var(--muted); min-height: 16px; }
.clist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.cmt { display: flex; flex-direction: column; gap: 3px; }
.cmt-name { font-weight: 700; font-size: 14px; }
.cmt-body { white-space: pre-wrap; line-height: 1.55; }
.clist:empty::after { content: "No comments yet — be the first."; color: var(--muted); font-size: 14px; }

/* Admin */
.admin { max-width: 540px; }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13px; }
.field input, .field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 11px; font: inherit; background: var(--card); color: var(--fg);
}
.btn {
  padding: 12px 22px; border: 0; border-radius: 11px;
  background: var(--accent); color: var(--accent-fg); font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }

/* Footer */
.footer { border-top: 1px solid var(--line); margin-top: 48px; }
.footer-inner {
  max-width: var(--max); margin: 0 auto; padding: 34px 18px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--muted); font-size: 14px;
}
.footer .fbrand { font-weight: 800; letter-spacing: 1px; color: var(--fg); font-size: 16px; }
.footer .flinks { display: flex; gap: 18px; }
.footer .flinks a { color: var(--accent); text-decoration: none; font-weight: 600; }
.footer .fcopy { margin: 0; font-size: 13px; }

/* Responsive */
@media (max-width: 640px) {
  main { padding: 16px 14px 52px; }
  .profile { gap: 18px; padding-bottom: 22px; }
  .profile .avatar { width: 88px; height: 88px; }
  .profile .pname { font-size: 18px; margin-bottom: 8px; }
  .profile .pbio { font-size: 14px; }
  .grid { gap: 4px; }
  .cell { border-radius: 9px; }
}

/* Shared Blog|Instagram tabs (unified header) */
.topbar { position: relative; }
.topbar .tabs { display: flex; gap: 6px; position: absolute; left: 50%; transform: translateX(-50%); }
.topbar .tab { font-weight: 600; font-size: 15px; text-decoration: none; color: var(--muted); padding: 6px 13px; border-radius: 999px; transition: background .15s, color .15s; }
.topbar .tab:hover { color: var(--fg); }
.topbar .tab.on { color: #fff; background: var(--accent, #ff3366); }
.topbar .topbar-actions { margin-left: auto; }

/* Section switcher — long buttons above the content */
.segtabs { display: flex; gap: 8px; margin: 4px 0 16px; }
.segtab { flex: 1; text-align: center; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 15px; text-decoration: none; transition: background .15s, color .15s; }
.segtab:hover { color: var(--fg); }
.segtab.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Editable header nav links */
.navlinks { display: flex; gap: 16px; align-items: center; }
.navlinks a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.navlinks a:hover { color: var(--fg); }

/* Collapsible header menu (chevron slides links left↔right) */
.navmenu { display: flex; align-items: center; }
.navchev { display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--fg); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; transition: transform .28s ease; }
.navmenu.open .navchev { transform: rotate(180deg); }
.navlinks { max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0; transition: max-width .35s ease, opacity .25s ease, margin .35s ease; }
.navmenu.open .navlinks { max-width: 70vw; opacity: 1; margin-left: 10px; }

/* Chevron matches the theme icon button */
.navchev { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; color: var(--fg); padding: 0; font-size: 18px; }
.navmenu.open .navlinks { margin-left: 0; margin-right: 10px; }

/* Related posts (Instagram post page) */
.related { max-width: 640px; margin: 36px auto 0; }
.rtitle { font-family: "Montserrat", sans-serif; font-weight: 800; font-size: 18px; margin: 0 0 14px; }
.relgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.relcell { position: relative; aspect-ratio: 4/5; border-radius: 10px; overflow: hidden; background: var(--surface); display: block; }
.relcell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.relvid { position: absolute; top: 7px; right: 8px; color: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,.7)); font-size: 13px; }

.navchev { font-size: 26px; line-height: 1; }

.navchev { display: flex; align-items: center; justify-content: center; padding: 0; }
