/* ═══════════════════════════════════════════════════════════════════
   BASE RESET + VARIABLES
═══════════════════════════════════════════════════════════════════ */
html {
  box-sizing: border-box;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  overflow-x: hidden;
  background-color: #111;
}
*, *::before, *::after {
  box-sizing: inherit;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0; padding: 0;
  position: relative;
  border: none;
  font: inherit;
  vertical-align: baseline;
}
:root {
  --gridSize:    3;
  --header-h:    calc(56px + env(safe-area-inset-top, 0px));
  --banner-h:    90px;
  --ease-in:     cubic-bezier(0.32,0,0.67,0);
  --ease-out:    cubic-bezier(0.33,1,0.68,1);
  --ease-io:     cubic-bezier(0.65,0,0.35,1);
  --c-bg:        #111;
  --c-surface:   #1a1a1a;
  --c-border:    rgba(255,255,255,.08);
  --c-text:      #f5f5f5;
  --c-muted:     rgba(255,255,255,.45);
  --c-accent:    #fff;
  --c-verified:  #4a9eff;
  --c-admin:     #f5a623;
  --c-danger:    #e74c3c;
  --c-ok:        #2ecc71;
  --radius-tile: 2rem;
  --radius-ui:   .75rem;
  --blur:        blur(20px);
}
html, body { width: 100%; min-height: 100%; }
.pen, .pen * { pointer-events: none !important; }
body {
  color: var(--c-text);
  background: var(--c-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-overflow-scrolling: touch;
  width: 100vw; height: 100vh;
  overflow: hidden;
}
body.admin-page { overflow: auto; height: auto; }
body.settings-page { overflow: auto; height: auto; }
/* Profile view allows scrolling */
body.profile-view {
  overflow-y: auto;
  height: auto;
  width: 100%;
}
/* Desktop scroll lock: body overflow hidden.
   Mobile uses JS touchmove prevention instead (iOS WebKit bug: overflow:hidden on html/body
   also prevents position:fixed overlay from scrolling its own content). */
body.scroll-locked { overflow: hidden !important; }

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

video  { display: block; width: 100%; height: 100%; }
img    { display: block; max-width: 100%; }
a      { color: inherit; text-decoration: none; }
button { background: none; color: inherit; border: none; padding: 0; font: inherit; cursor: pointer; outline: none; }
input, textarea { background: none; color: inherit; font: inherit; outline: none; border: none; }

.hidden { display: none !important; }
.visuallyhidden {
  border: 0; clip: rect(1px 1px 1px 1px); height: 1px;
  margin: -1px; overflow: hidden; padding: 0;
  position: absolute; width: 1px;
}

/* ═══════════════════════════════════════════════════════════════════
   SITE HEADER
═══════════════════════════════════════════════════════════════════ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(17,17,17,.75);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--c-border);
  transition: transform .45s var(--ease-io);
  /* Push content below Dynamic Island / notch when running as a PWA */
  padding-top: env(safe-area-inset-top, 0px);
}
/* Hide header when a tile is zoomed in — tile fills the full screen */
.open .site-header {
  transform: translateY(-100%);
}
.header-bar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
}
.site-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--c-accent);
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
  cursor: pointer;
}
/* Feed type navigation (Home / Following) */
.feed-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}
.feed-nav-btn {
  padding: .35rem .85rem;
  border-radius: 2rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--c-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  text-transform: uppercase;
}
.feed-nav-btn:hover { color: var(--c-text); background: rgba(255,255,255,.05); }
.feed-nav-btn.active {
  color: var(--c-text);
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.06);
}
.feed-nav-back { color: var(--c-muted); }

/* Search toggle button */
.search-toggle-btn {
  padding: .35rem .55rem;
  border-radius: 2rem;
  font-size: .95rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.search-toggle-btn:hover { background: rgba(255,255,255,.06); color: var(--c-text); }

/* Search area: collapsed by default, expands on .open */
.header-search {
  display: flex;
  align-items: center;
  gap: .35rem;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  flex-shrink: 0;
  transition: max-width .35s var(--ease-io), opacity .25s var(--ease-io);
}
.header-search.open {
  max-width: 300px;
  opacity: 1;
  flex: 1;
}
.header-search input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: 2rem;
  padding: .45rem 1rem;
  font-size: .85rem;
  color: var(--c-text);
  transition: background .2s, border-color .2s;
  -webkit-user-select: text;
  user-select: text;
}
.search-close-btn {
  flex-shrink: 0;
  color: var(--c-muted);
  font-size: .85rem;
  cursor: pointer;
  transition: color .2s;
  padding: .2rem .3rem;
}
.search-close-btn:hover { color: var(--c-text); }
.header-search input:focus {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
}
.search-dropdown {
  position: fixed; /* fixed so it escapes the overflow:hidden header-search */
  top: var(--header-h);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-ui);
  overflow: hidden;
  z-index: 65;
  min-width: 260px;
  max-width: 340px;
  display: none;
}
.search-dropdown.open { display: block; }
.search-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem 1rem;
  cursor: pointer;
  transition: background .15s;
}
.search-item:hover { background: rgba(255,255,255,.06); }
.search-item-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  object-fit: cover;
  flex-shrink: 0;
}
.search-item-info { line-height: 1.2; }
.search-item-name  { font-size: .85rem; font-weight: 600; }
.search-item-handle{ font-size: .75rem; color: var(--c-muted); }

.header-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  margin-left: auto; /* always push to the right edge */
}
.btn-ghost {
  padding: .4rem .85rem;
  border-radius: 2rem;
  font-size: .8rem;
  color: var(--c-muted);
  border: 1px solid var(--c-border);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: inline-block;
}
.btn-ghost:hover { color: var(--c-text); border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.04); }
.btn-outline {
  padding: .4rem .85rem;
  border-radius: 2rem;
  font-size: .8rem;
  color: var(--c-text);
  border: 1px solid rgba(255,255,255,.3);
  cursor: pointer;
  transition: background .2s, border-color .2s;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: inline-block;
}
.btn-outline:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.45); }
.btn-primary {
  display: inline-block;
  padding: .55rem 1.4rem;
  border-radius: 2rem;
  font-size: .85rem;
  font-weight: 600;
  color: #111;
  background: #fff;
  cursor: pointer;
  transition: background .2s, opacity .2s;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: none;
}
.btn-primary:hover { background: #e0e0e0; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.header-user {
  display: flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 2rem;
  transition: background .2s;
}
.header-user:hover { background: rgba(255,255,255,.06); }
.header-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  object-fit: cover;
  flex-shrink: 0;
}
.header-user-name  { font-size: .8rem; font-weight: 600; }
.header-user-menu  {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-ui);
  min-width: 160px;
  overflow: hidden;
  z-index: 60;
  display: none;
}
.header-user-menu.open { display: block; }
.user-menu-item {
  display: block;
  width: 100%;
  padding: .7rem 1rem;
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.user-menu-item:hover { background: rgba(255,255,255,.06); }
.user-menu-divider { height: 1px; background: var(--c-border); margin: .25rem 0; }
.user-menu-item.danger { color: var(--c-danger); }

/* ── Notification bell ── */
.notif-bell {
  position: relative;
  padding: .35rem .55rem;
  border-radius: 2rem;
  font-size: 1rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.notif-bell:hover { background: rgba(255,255,255,.06); color: var(--c-text); }
.notif-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--c-danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  transform: translate(30%,-30%);
  line-height: 1;
}

/* ── Notification panel ── */
.notif-panel {
  position: absolute;
  top: calc(var(--header-h) - 1px);
  right: 0;
  width: 360px;
  max-height: 520px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-top: none;
  border-radius: 0 0 var(--radius-ui) var(--radius-ui);
  z-index: 65;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  font-size: .82rem;
  font-weight: 600;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.notif-mark-read {
  font-size: .75rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: color .15s;
}
.notif-mark-read:hover { color: var(--c-text); }
.notif-list {
  overflow-y: auto;
  flex: 1;
}
.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: .85rem;
  color: var(--c-muted);
}
.notif-item {
  display: flex;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .15s;
  align-items: flex-start;
}
.notif-item:hover { background: rgba(255,255,255,.04); }
.notif-unread { background: rgba(74,158,255,.06); }
.notif-actor-link { flex-shrink: 0; display: block; }
.notif-actor-pic {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  object-fit: cover;
  display: block;
}
.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: .83rem; line-height: 1.45; color: var(--c-text); }
.notif-text em { color: var(--c-muted); font-style: normal; }
.notif-time { font-size: .72rem; color: var(--c-muted); margin-top: .2rem; }
.notif-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.notif-status {
  margin-top: .45rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.notif-status-ok    { color: var(--c-ok); }
.notif-status-muted { color: var(--c-muted); }

/* ── Follow button on profile ── */
.btn-follow {
  padding: .4rem 1.1rem;
  border-radius: 2rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--c-verified);
  color: var(--c-verified);
  background: rgba(74,158,255,.1);
  transition: background .2s, color .2s;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.btn-follow:hover { background: rgba(74,158,255,.2); }
.btn-follow-pending { border-color: var(--c-muted); color: var(--c-muted); background: transparent; }
.btn-follow-ing     { border-color: var(--c-border); color: var(--c-muted); background: transparent; }
.btn-follow-ing:hover { border-color: var(--c-danger); color: var(--c-danger); }

/* ── Private profile message ── */
.private-profile-msg {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: 4rem 1rem;
  color: var(--c-muted);
  text-align: center;
}
.pp-icon  { font-size: 2.5rem; opacity: .4; }
.pp-title { font-size: 1rem; font-weight: 700; color: var(--c-text); }
.pp-sub   { font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════════════
   AUTH MODAL TABS (reused in auth-modal)
═══════════════════════════════════════════════════════════════════ */
.drawer-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.drawer-tab {
  padding: .35rem .9rem;
  border-radius: 2rem;
  font-size: .8rem;
  color: var(--c-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.drawer-tab.active { color: var(--c-text); border-color: rgba(255,255,255,.2); }
.auth-form  { display: flex; flex-direction: column; gap: .65rem; }
.auth-form.hidden { display: none; }
.auth-row   { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.auth-error { font-size: .8rem; color: var(--c-danger); min-height: 1em; }

/* Handle input with status indicator */
.handle-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.handle-input-wrap input { padding-right: 2rem; }
.handle-status {
  position: absolute;
  right: .65rem;
  font-size: .75rem;
  font-weight: 700;
  pointer-events: none;
}
.handle-ok  { color: var(--c-ok); }
.handle-bad { color: var(--c-danger); }

/* ═══════════════════════════════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════════════════════════════ */
.field {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: .5rem;
  padding: .6rem .9rem;
  font-size: .9rem;
  color: var(--c-text);
  transition: border-color .2s, background .2s;
  resize: vertical;
  -webkit-user-select: text;
  user-select: text;
}
.field::placeholder { color: var(--c-muted); }
.field:focus { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.09); }
.auth-form input {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: .5rem;
  padding: .6rem .9rem;
  font-size: .9rem;
  color: var(--c-text);
  -webkit-user-select: text;
  user-select: text;
  transition: border-color .2s, background .2s;
}
.auth-form input:focus { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.09); }
.auth-form input::placeholder { color: var(--c-muted); }

/* Post timestamp */
.post-timestamp {
  font-size: .7rem;
  color: var(--c-muted);
  opacity: .7;
  margin-left: .3rem;
}

/* Text post thumbnail background picker */
.text-bg-picker {
  border-top: 1px solid var(--c-border);
  padding-top: .75rem;
  margin-top: .1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.text-bg-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.text-bg-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  align-items: start;
}
.text-bg-col { display: flex; flex-direction: column; gap: .35rem; }
.text-bg-clear-btn {
  font-size: .72rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: color .15s;
  margin-top: .15rem;
  display: inline-block;
}
.text-bg-clear-btn:hover { color: var(--c-danger); }
.text-bg-preview {
  height: 52px;
  border-radius: .65rem;
  border: 1px solid var(--c-border);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  transition: background .25s, background-image .25s;
  flex-shrink: 0;
}
@media (max-width: 500px) {
  .text-bg-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════
   PROFILE BANNER
═══════════════════════════════════════════════════════════════════ */
.profile-banner {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  z-index: 40;
  background: rgba(17,17,17,.85);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--c-border);
  padding: 1rem 1.5rem;
  transition: transform .3s var(--ease-io);
}
.profile-banner-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.1);
}
.avatar-upload-btn {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--c-accent);
  color: #111;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.profile-display-name { font-size: 1.1rem; font-weight: 700; }
.profile-handle { font-size: .8rem; color: var(--c-muted); margin-top: .1rem; display: block; }
.profile-bio    { font-size: .82rem; color: var(--c-muted); margin-top: .3rem; line-height: 1.4; }
.profile-actions { display: flex; gap: .5rem; flex-shrink: 0; align-items: center; }

/* Follower count button in the profile banner */
.profile-follower-btn {
  margin-top: .4rem;
  display: inline-block;
  font-size: .78rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: color .2s;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
}
.profile-follower-btn:hover { color: var(--c-text); text-decoration: underline; }

/* Follower list items inside the modal */
.follower-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: .5rem;
  transition: background .15s;
}
.follower-item:hover { background: rgba(255,255,255,.04); }
.follower-main {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.follower-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.1);
  flex-shrink: 0;
}
.follower-info { min-width: 0; line-height: 1.3; }
.follower-name  { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follower-handle{ font-size: .75rem; color: var(--c-muted); }

/* ═══════════════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════════════ */
.badge-verified {
  font-size: .75rem;
  font-weight: 700;
  color: var(--c-verified);
  background: rgba(74,158,255,.15);
  border-radius: 50%;
  width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.badge-admin {
  font-size: .6rem;
  font-weight: 700;
  color: var(--c-admin);
  background: rgba(245,166,35,.15);
  border: 1px solid rgba(245,166,35,.3);
  border-radius: .25rem;
  padding: .1rem .3rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.tile-badge-v, .tile-badge-a {
  font-size: .6rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tile-badge-v { color: var(--c-verified); }
.tile-badge-a { color: var(--c-admin); }

/* ═══════════════════════════════════════════════════════════════════
   TILE VIEWPORT + CANVAS
═══════════════════════════════════════════════════════════════════ */
.viewport {
  --zoom: 0.32;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: transparent;
  transform: scale3d(var(--zoom),var(--zoom),1);
  transform-origin: center;
  will-change: transform;
  transition: transform .75s var(--ease-io), opacity .9s var(--ease-in) .1s;
  opacity: 1;
  z-index: 4;
}
.canvas {
  --x: 0; --y: 0;
  --gap: 1.5rem;
  position: absolute;
  display: grid;
  grid-template-columns: repeat(var(--gridSize), 100vw);
  width: fit-content;
  gap: var(--gap);
  margin: auto;
  transform: translate3d(
    calc((-100vw * var(--x)) - (var(--gap) * var(--x))),
    calc((-100vh * var(--y)) - (var(--gap) * var(--y))),
    0
  );
  transition: transform .6s var(--ease-io);
  transform-origin: left top;
  will-change: transform;
  z-index: 5;
}
.item {
  width: 100vw; height: 100vh;
  border-radius: var(--radius-tile);
  opacity: 1;
  overflow: hidden;
  background: #1e1e1e;
  transition: opacity .25s var(--ease-io), transform .25s var(--ease-io);
  cursor: pointer;
}
/* All tiles same brightness — focus ring (from .focus) marks the selected row */
.item.selected  { opacity: 1; } /* pointer-events kept auto so all tiles are clickable */
.item:not(.empty):hover { opacity: .82; transform: scale(1.012); z-index: 2; }
.item.empty     { background: rgba(255,255,255,.04); cursor: default; opacity: .35; }
.item.empty:hover { opacity: .35; transform: none; }

/* ── Tile media ── */
.item video {
  position: absolute;
  width: 100%; height: 100%;
  transform: scale3d(2,2,2);
  transition: transform 1s var(--ease-io);
  will-change: transform;
  object-fit: cover;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.item.selected video { transform: scale3d(1,1,1); }
.item img.tile-img {
  position: absolute;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ── Text tile ── */
.tile-text-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.tile-text-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12% 10%;
  z-index: 2;
}
/* Large sizes for zoomed-out view; overridden to normal when open */
.tile-text-title {
  font-size: clamp(3.5rem, 8vw, 6rem);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  margin-bottom: .6em;
  word-break: break-word;
}
.tile-text-summary {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  color: rgba(255,255,255,.72);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Canvas tiles stay at grid scale — zoom layer handles the full-screen view */

/* ── Tile user info overlay (large for zoomed-out, normal when open) ── */
.tile-user-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 5rem 3rem 3rem;
  background: linear-gradient(to top, rgba(0,0,0,.72) 0%, transparent 100%);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  z-index: 3;
  cursor: pointer;
}
.tile-avatar {
  width: 4rem; height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.15);
  flex-shrink: 0;
}
.tile-user-text { line-height: 1.25; }
.tile-user-name  { font-size: 2rem; font-weight: 700; color: #fff; }
.tile-user-handle{ font-size: 1.65rem; color: rgba(255,255,255,.65); }

/* No open-state overrides needed — canvas grid stays at 0.32 zoom always */

/* ── Tile type indicator ── */
.tile-type-indicator {
  position: absolute;
  top: 1.25rem; right: 1.25rem;
  width: 3.5rem; height: 3.5rem;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 3;
}

/* ═══════════════════════════════════════════════════════════════════
   FOCUS + BACK + VOLUME
═══════════════════════════════════════════════════════════════════ */
.focus-container { display: none; }
.focus { pointer-events: none; }

.back {
  position: fixed;
  top: 0; left: 0;
  margin: calc(1.25rem + env(safe-area-inset-top, 0px)) 2rem 0;
  padding: .6rem 1.4rem;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  background: rgba(14,13,13,.55);
  border-radius: 2rem;
  color: whitesmoke;
  opacity: 0;
  transition: opacity .4s var(--ease-out);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .03em;
  pointer-events: none;
  z-index: 60; /* above zoom layer (20) and panels (52) */
}
.back:hover { background: rgba(61,59,59,.6); }
/* Fixed volume button kept in DOM but hidden — volume is now in the tile-info-panel */
.volume { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   ZOOM LAYER
═══════════════════════════════════════════════════════════════════ */
.zoom-layer {
  position: fixed;
  z-index: 20; /* above canvas/viewport (4), below panels (52) */
  overflow: hidden;
  background: #111;
  /* top/left/width/height/border-radius are set dynamically by JS */
}
.zoom-media {
  position: absolute;
  inset: 0;
}

/* Loading spinner */
.mas {
  position: fixed;
  inset: 0;
  margin: auto;
  pointer-events: none;
  z-index: 10;
  width: 2rem; height: 2rem;
  display: flex;
  opacity: 0;
  transition: opacity .3s;
}
.mas .r { width: 5px; height: 5px; z-index:1; background:#fff; margin:auto; }
.mas .v  { background:#fff; position:absolute; margin:auto; width:1px; height:100%; left:calc(1rem - .5px); }
.mas .h  { background:#fff; position:absolute; margin:auto; width:100%; height:1px; top:calc(1rem - .5px); }
.loading .mas { opacity: 1; animation: spin 1s var(--ease-io) infinite; }
@keyframes spin { 0%{transform:rotate(270deg)} 100%{transform:rotate(630deg)} }
.loading .viewport { opacity: 0; }

/* ═══════════════════════════════════════════════════════════════════
   OPEN STATE (zoom layer active — tile grid stays unchanged)
═══════════════════════════════════════════════════════════════════ */
.open .mas { opacity: 0; pointer-events: none; }
/* Header slides out of the way */
/* Focus ring already hidden via .open .focus-container rule above */
.open .back   { opacity: 1; pointer-events: all; }
.open .volume { opacity: 1; pointer-events: all; }
/* Post overlay: no top header, so reduce padding */
.open .post-overlay-content { padding-top: 1.5rem; }

/* ═══════════════════════════════════════════════════════════════════
   TILE INFO PANEL (slides up from bottom when media tile open)
═══════════════════════════════════════════════════════════════════ */
.tile-info-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 52;
  background: rgba(14,14,14,.92);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-top: 1px solid var(--c-border);
  border-radius: 1.25rem 1.25rem 0 0;
  max-height: 55vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .35s var(--ease-out);
  pointer-events: none;
  /* extend the panel flush with the physical screen edge */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tile-info-panel.visible {
  transform: translateY(0);
  pointer-events: all;
}
.tip-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.2);
  margin: .75rem auto .5rem;
}
.tip-body {
  padding: .5rem 1.25rem 1.5rem; /* tile-info-panel itself handles safe-area-inset-bottom */
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
/* Author row in tile-info-panel */
.tip-author {
  display: flex;
  align-items: center;
  gap: .65rem;
  cursor: pointer;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--c-border);
}
.tip-author:hover .tip-author-name { text-decoration: underline; }
.tip-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.15);
  flex-shrink: 0;
}
.tip-author-text { display: flex; flex-direction: column; line-height: 1.25; }
.tip-author-name { font-size: .9rem; font-weight: 700; color: var(--c-text); }
.tip-author-handle { font-size: .75rem; color: var(--c-muted); }

.tip-meta { display: flex; flex-direction: column; gap: .25rem; }
.tip-title { font-size: 1.1rem; font-weight: 700; -webkit-user-select: text; user-select: text; }
.tip-desc  { font-size: .9rem; color: var(--c-muted); line-height: 1.45; -webkit-user-select: text; user-select: text; }
.tip-social {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  color: var(--c-muted);
  cursor: pointer;
  transition: color .2s;
  padding: .3rem .6rem;
  border-radius: 2rem;
  border: 1px solid var(--c-border);
}
.like-btn:hover, .like-btn.liked { color: #e74c3c; border-color: rgba(231,76,60,.35); }
.like-btn.liked .like-icon { color: #e74c3c; }
.like-icon { font-size: 1rem; }
.tip-comment-count-label {
  font-size: .9rem;
  color: var(--c-muted);
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  padding: .3rem .6rem;
  border-radius: 2rem;
  border: 1px solid var(--c-border);
  transition: color .2s, border-color .2s;
}
.tip-comment-count-label:hover { color: var(--c-text); border-color: rgba(255,255,255,.2); }

/* Share button — used in both tile-info-panel and post overlay */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .9rem;
  color: var(--c-muted);
  cursor: pointer;
  padding: .3rem .65rem;
  border-radius: 2rem;
  border: 1px solid var(--c-border);
  transition: color .2s, border-color .2s;
}
.share-btn:hover { color: var(--c-text); border-color: rgba(255,255,255,.2); }
.tip-comments-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 180px;
  overflow-y: auto;
}
.tip-comment-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: .5rem;
  padding: .5rem .85rem;
  font-size: .88rem;
  color: var(--c-text);
  -webkit-user-select: text;
  user-select: text;
  transition: border-color .2s;
}
.tip-comment-input:focus { border-color: rgba(255,255,255,.2); }
.tip-comment-input::placeholder { color: var(--c-muted); }
.tip-comment-form {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  border-top: 1px solid var(--c-border);
  padding-top: .65rem;
  margin-top: .1rem;
}
.tip-comment-submit {
  padding: .5rem 1rem;
  font-size: .8rem;
  flex-shrink: 0;
}

/* Volume button inside the tile-info-panel */
.tip-volume-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .9rem;
  color: var(--c-muted);
  cursor: pointer;
  padding: .3rem .6rem;
  border-radius: 2rem;
  border: 1px solid var(--c-border);
  transition: color .2s, border-color .2s;
}
.tip-volume-btn:hover { color: var(--c-text); border-color: rgba(255,255,255,.2); }

/* Feed disabled overlay */
.feed-disabled-msg {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  flex-direction: column;
  gap: 1rem;
  pointer-events: none;
}
.fdm-icon  { font-size: 3rem; opacity: .3; }
.fdm-title { font-size: 1.2rem; font-weight: 700; color: var(--c-muted); }
.fdm-sub   { font-size: .88rem; color: var(--c-muted); opacity: .7; }

/* ═══════════════════════════════════════════════════════════════════
   POST DETAIL OVERLAY (full overlay for all post types)
═══════════════════════════════════════════════════════════════════ */
.post-overlay {
  position: fixed;
  inset: 0;
  z-index: 52;
  background: rgba(10,10,10,.94);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  overflow-y: auto;
  overscroll-behavior: contain; /* prevent touch scroll bleeding to background */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem calc(4rem + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  transform: translateY(1.5rem);
  transition: opacity .35s var(--ease-out), transform .35s var(--ease-out);
  pointer-events: none;
}
.post-overlay.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.post-overlay-content {
  width: 100%;
  max-width: 720px;
  padding-top: calc(var(--header-h) + .5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.post-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.post-overlay-author {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
  min-width: 0;
}
.post-overlay-author img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.1);
  flex-shrink: 0;
}
.overlay-author-name  { font-weight: 600; font-size: .9rem; }
.overlay-author-handle{ font-size: .78rem; color: var(--c-muted); }
.overlay-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.post-overlay-close {
  font-size: 1.2rem;
  color: var(--c-muted);
  line-height: 1;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.post-overlay-close:hover { background: rgba(255,255,255,.08); color: var(--c-text); }

.overlay-media-wrap {
  border-radius: .75rem;
  overflow: hidden;
  background: #000;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay-media-wrap img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.post-overlay-title {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  -webkit-user-select: text;
  user-select: text;
}
.post-overlay-caption {
  font-size: .95rem;
  color: var(--c-muted);
  line-height: 1.5;
  -webkit-user-select: text;
  user-select: text;
}
.post-overlay-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: rgba(255,255,255,.82);
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
}
.post-overlay-body a { color: var(--c-verified); text-decoration: underline; }

/* ── Social section in overlay ── */
.overlay-social {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  border-top: 1px solid var(--c-border);
  padding-top: .75rem;
}
.overlay-likes-row { display: flex; align-items: center; gap: .75rem; }
.overlay-comments-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 320px;
  overflow-y: auto;
}
.overlay-comment-form {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}
.overlay-comment-form input {
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: .5rem;
  padding: .55rem .9rem;
  font-size: .88rem;
  color: var(--c-text);
  -webkit-user-select: text;
  user-select: text;
  transition: border-color .2s;
}
.overlay-comment-form input:focus { border-color: rgba(255,255,255,.2); outline: none; }
.overlay-comment-form input::placeholder { color: var(--c-muted); }

/* ── Comment items ── */
.comment-item {
  background: rgba(255,255,255,.04);
  border-radius: .5rem;
  padding: .55rem .75rem;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .25rem;
}
.comment-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  object-fit: cover;
  flex-shrink: 0;
}
.comment-name   { font-size: .8rem; font-weight: 600; }
.comment-handle { font-size: .72rem; color: var(--c-muted); flex: 1; }
.comment-delete-btn {
  font-size: .72rem;
  color: var(--c-muted);
  cursor: pointer;
  padding: .1rem .3rem;
  border-radius: .25rem;
  transition: color .15s, background .15s;
  margin-left: auto;
}
.comment-delete-btn:hover { color: var(--c-danger); background: rgba(231,76,60,.1); }
.comment-body {
  font-size: .85rem;
  color: rgba(255,255,255,.8);
  line-height: 1.4;
  -webkit-user-select: text;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
}
.no-comments, .comments-loading {
  font-size: .82rem;
  color: var(--c-muted);
  padding: .5rem 0;
}

/* ═══════════════════════════════════════════════════════════════════
   PROFILE GRID
═══════════════════════════════════════════════════════════════════ */
.profile-grid {
  padding-top: calc(var(--header-h) + var(--banner-h) + 1rem);
  padding-bottom: 4rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  background: transparent; /* lets body gradient show through gaps */
}

/* When a profile theme is active the whole page body carries the gradient */
body.profile-themed {
  background-attachment: scroll; /* gradient scrolls with content */
}
/* Banner becomes a frosted panel over the gradient — handled via inline style in JS */
body.profile-themed .profile-banner {
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.profile-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--c-muted);
  font-size: .9rem;
  padding: 3rem 1rem;
}
.pg-item {
  aspect-ratio: 1 / 1;
  background: #1e1e1e;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-item:hover .pg-overlay { opacity: 1; }
.pg-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.pg-text-thumb {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pg-text-thumb-title {
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pg-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 2rem;
  color: rgba(255,255,255,.85);
  pointer-events: none;
  text-shadow: 0 0 12px rgba(0,0,0,.6);
}
.pg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  opacity: 0;
  transition: opacity .2s;
  padding: .75rem;
}
.pg-type { font-size: 1.5rem; }
.pg-item-title {
  font-size: .75rem;
  color: #fff;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 70;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(.96);
  z-index: 75;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 1.25rem;
  width: calc(100% - 2rem);
  max-width: 520px;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.modal.open {
  opacity: 1;
  transform: translate(-50%,-50%) scale(1);
  pointer-events: all;
}
.modal.wide { max-width: 680px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close {
  font-size: 1rem;
  color: var(--c-muted);
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: rgba(255,255,255,.08); color: var(--c-text); }
.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Type picker */
.type-picker {
  display: flex;
  gap: .5rem;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: .75rem;
}

/* Type lock indicator (edit mode) */
.type-locked {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
  padding-bottom: .6rem;
}

/* Current media preview (edit mode) */
.current-media-wrap { display: flex; flex-direction: column; gap: .4rem; }
.current-media-preview {
  border-radius: .65rem;
  overflow: hidden;
  background: rgba(0,0,0,.3);
  max-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.current-media-preview img,
.current-media-preview video { width: 100%; max-height: 180px; object-fit: cover; display: block; border-radius: .65rem; }

/* Visibility picker */
.vis-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  border-top: 1px solid var(--c-border);
  padding-top: .75rem;
}
.vis-picker {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.vis-btn {
  padding: .35rem .8rem;
  border-radius: 2rem;
  font-size: .78rem;
  color: var(--c-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  white-space: nowrap;
}
.vis-btn:hover { color: var(--c-text); background: rgba(255,255,255,.05); }
.vis-btn.active { color: var(--c-text); border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.06); }
.vis-hint { font-size: .72rem; color: var(--c-muted); line-height: 1.35; min-height: 1em; }
.type-btn {
  padding: .35rem .85rem;
  border-radius: 2rem;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-muted);
  border: 1px solid transparent;
  transition: color .2s, border-color .2s;
}
.type-btn.active { color: var(--c-text); border-color: rgba(255,255,255,.2); }
.type-panel { display: flex; flex-direction: column; gap: .65rem; }

/* Upload zone */
.upload-zone {
  border: 1.5px dashed rgba(255,255,255,.15);
  border-radius: .75rem;
  padding: 1.5rem 1rem 1rem;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-zone.drag-over { border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.05); }
.upload-zone-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
}
.upload-zone-icon {
  font-size: 1.75rem;
  opacity: .45;
  line-height: 1;
}
.upload-zone-label {
  font-size: .82rem;
  color: var(--c-muted);
}
/* Styled "Choose file" button — hides the native input */
.upload-choose-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem 1.1rem;
  border-radius: 2rem;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.06);
  font-size: .8rem;
  color: var(--c-text);
  cursor: pointer;
  transition: background .2s, border-color .2s;
  -webkit-user-select: none;
  user-select: none;
}
.upload-choose-btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.35); }
/* Hide the native file input completely — the label triggers it */
.upload-choose-btn input[type="file"] { display: none; }
.upload-filename {
  font-size: .75rem;
  color: var(--c-ok);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 .5rem;
}
/* Preview shown after file is chosen */
.upload-preview {
  margin-top: .85rem;
  border-radius: .5rem;
  overflow: hidden;
  max-height: 140px;
  background: rgba(0,0,0,.3);
}
.upload-preview img, .upload-preview video { width: 100%; max-height: 140px; object-fit: contain; }
.or-divider {
  display: flex; align-items: center; gap: .75rem;
  font-size: .75rem; color: var(--c-muted);
}
.or-divider::before, .or-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--c-border);
}
.form-error { font-size: .8rem; color: var(--c-danger); min-height: 1em; }

/* Context menu */
.ctx-menu {
  position: fixed;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: .65rem;
  overflow: hidden;
  z-index: 80;
  min-width: 120px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  padding: .6rem 1rem;
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.ctx-menu button:hover { background: rgba(255,255,255,.06); }
#ctx-delete { color: var(--c-danger); }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE BOTTOM TAB BAR
═══════════════════════════════════════════════════════════════════ */
:root { --mob-tab-h: 0px; } /* overridden on mobile below */

.mob-bar {
  display: none; /* hidden on desktop */
}

@media (max-width: 700px) {
  :root { --mob-tab-h: calc(54px + env(safe-area-inset-bottom, 0px)); }

  .mob-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 58;
    background: rgba(17,17,17,.94);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--c-border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: var(--mob-tab-h);
    align-items: stretch;
  }
  .open .mob-bar { display: none !important; }

  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .6rem;
    color: var(--c-muted);
    cursor: pointer;
    transition: color .15s;
    padding-bottom: 2px;
    position: relative;
  }
  .mob-tab:hover, .mob-tab.active { color: var(--c-text); }
  .mob-tab-icon { font-size: 1.2rem; line-height: 1; }
  .mob-tab-label { text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

  .mob-tab-new .mob-tab-icon {
    background: var(--c-text);
    color: #111;
    width: 2rem; height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
  }

  .mob-tab-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,.15);
    display: block;
  }

  .mob-notif-dot {
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--c-danger);
    border: 2px solid #111;
  }

  /* Hide header nav items that are duplicated in the bottom tab bar */
  #feed-nav, #header-nav { display: none !important; }

  /* Keep search functional — previous rule hid it at 480px */
  .header-search { display: flex !important; }

  /* Post overlay covers the header (z52 > z50) so only safe-area needed at top.
     Back button is hidden by JS when the overlay is open (text tile zoom). */
  .post-overlay {
    padding-bottom: calc(2rem + var(--mob-tab-h)) !important;
  }
  .post-overlay-content,
  .open .post-overlay-content {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem) !important;
  }

  /* Notification panel: lift to fixed + full width so it appears above everything */
  .notif-panel {
    position: fixed !important;
    top: var(--header-h) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 65vh !important;
    z-index: 200 !important;
    border-radius: 0 0 var(--radius-ui) var(--radius-ui) !important;
  }

  /* Profile grid: ensure content scrolls above the tab bar */
  body.profile-view { padding-bottom: var(--mob-tab-h); }
  /* tile-info-panel: mob-bar is hidden in .open state so no extra padding needed there */

  /* Bottom-sheet modals on mobile */
  .modal {
    top: unset !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: translateY(100%) !important;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 1.5rem 1.5rem 0 0 !important;
    max-height: 90vh !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    margin: 0 !important;
  }
  .modal.open {
    transform: translateY(0) !important;
    opacity: 1 !important;
  }
}

/* First-time push notification prompt */
.push-prompt {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  z-index: 190;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  width: calc(100% - 2rem);
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
  pointer-events: none;
}
.push-prompt.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: all; }
.push-prompt-content {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.push-prompt-content div { display: flex; flex-direction: column; gap: .15rem; }
.push-prompt-content strong { font-size: .9rem; font-weight: 700; }
.push-prompt-content span  { font-size: .8rem; color: var(--c-muted); line-height: 1.4; }
.push-prompt-btns { display: flex; gap: .5rem; }

/* iOS Add-to-Home-Screen prompt */
.ios-prompt {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 300;
  background: rgba(28,28,30,.97);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,.12);
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.1rem 1.25rem calc(.9rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  transform: translateY(100%);
  transition: transform .4s cubic-bezier(0.33,1,0.68,1);
  pointer-events: none;
}
.ios-prompt.visible { transform: translateY(0); pointer-events: all; }
.ios-prompt-close {
  position: absolute;
  top: .75rem; right: .9rem;
  font-size: .9rem;
  color: var(--c-muted);
  width: 1.8rem; height: 1.8rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ios-prompt-close:hover { background: rgba(255,255,255,.08); }
.ios-prompt-icon {
  width: 52px; height: 52px;
  border-radius: .9rem;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  flex-shrink: 0;
}
.ios-prompt-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  text-align: center;
}
.ios-prompt-text strong:first-child {
  font-size: .95rem;
  font-weight: 700;
  color: var(--c-text);
}
.ios-prompt-text span {
  font-size: .82rem;
  color: var(--c-muted);
  line-height: 1.45;
}
.ios-prompt-arrow {
  font-size: .7rem;
  color: var(--c-muted);
  opacity: .5;
  animation: ios-bounce .9s var(--ease-io) infinite alternate;
}
@keyframes ios-bounce { from { transform: translateY(0); } to { transform: translateY(4px); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,.12);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: .6rem 1.25rem;
  border-radius: 2rem;
  font-size: .85rem;
  z-index: 200;
  white-space: nowrap;
  animation: toastIn .25s var(--ease-out);
}
.toast.toast-error { background: rgba(231,76,60,.25); border-color: rgba(231,76,60,.4); }
@keyframes toastIn { from {opacity:0;transform:translateX(-50%) translateY(.5rem)} to {opacity:1;transform:translateX(-50%) translateY(0)} }

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS PAGE
═══════════════════════════════════════════════════════════════════ */
.settings-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 2rem) 1.5rem 4rem;
}
.settings-wrap h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
}
.settings-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.settings-section h2 {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  margin-bottom: 1rem;
}
.settings-row {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.settings-field-label {
  font-size: .8rem;
  color: var(--c-muted);
  margin-bottom: .2rem;
  display: block;
}
.settings-success {
  font-size: .82rem;
  color: var(--c-ok);
  min-height: 1em;
}

/* Profile theme picker */
.theme-preview-bar {
  height: 52px;
  border-radius: .75rem;
  transition: background .25s;
  flex-shrink: 0;
}
.theme-color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.color-picker-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 42px;
  border: 1px solid var(--c-border);
  border-radius: .5rem;
  background: rgba(255,255,255,.06);
  cursor: pointer;
  padding: 3px;
  transition: border-color .2s;
}
.color-picker-input:hover { border-color: rgba(255,255,255,.25); }
.color-picker-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-input::-webkit-color-swatch { border-radius: .35rem; border: none; }
.color-picker-input::-moz-color-swatch { border-radius: .35rem; border: none; }
/* Locked notice for non-verified users */
.theme-locked-notice {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .85rem 1rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--c-border);
  border-radius: .65rem;
  color: var(--c-muted);
  font-size: .88rem;
  line-height: 1.4;
}
.theme-lock-icon { font-size: 1.5rem; flex-shrink: 0; opacity: .6; }
.theme-locked-notice strong { color: var(--c-text); display: block; margin-bottom: .2rem; }

/* Active session items */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .75rem;
  background: rgba(255,255,255,.04);
  border-radius: .5rem;
  border: 1px solid var(--c-border);
}
.session-device {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .88rem;
  font-weight: 600;
}
.session-meta {
  font-size: .74rem;
  color: var(--c-muted);
  margin-top: .15rem;
}

/* Post management list in settings */
.posts-manage-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 400px;
  overflow-y: auto;
}
.post-manage-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  background: rgba(255,255,255,.04);
  border-radius: .5rem;
  border: 1px solid var(--c-border);
}
.post-manage-thumb {
  width: 44px; height: 44px;
  border-radius: .35rem;
  object-fit: cover;
  background: rgba(255,255,255,.08);
  flex-shrink: 0;
}
.post-manage-text { flex: 1; min-width: 0; }
.post-manage-title {
  font-size: .88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-manage-meta {
  font-size: .75rem;
  color: var(--c-muted);
  margin-top: .1rem;
}

/* ═══════════════════════════════════════════════════════════════════
   ADMIN PAGE
═══════════════════════════════════════════════════════════════════ */
.admin-header .header-bar { border-bottom: none; }
.admin-badge-header {
  font-size: .75rem;
  font-weight: 700;
  color: var(--c-admin);
  background: rgba(245,166,35,.12);
  border: 1px solid rgba(245,166,35,.25);
  border-radius: .25rem;
  padding: .2rem .5rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.admin-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 2rem) 1.5rem 4rem;
}
.admin-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 1.5rem;
}
.admin-tab {
  padding: .6rem 1.2rem;
  font-size: .85rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.admin-tab.active { color: var(--c-text); border-color: var(--c-text); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.admin-panel-header h2 { font-size: 1.05rem; font-weight: 700; }
.admin-search {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--c-border);
  border-radius: 2rem;
  padding: .4rem .9rem;
  font-size: .82rem;
  color: var(--c-text);
  width: 220px;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color .2s;
}
.admin-search:focus { border-color: rgba(255,255,255,.2); }
.admin-search::placeholder { color: var(--c-muted); }
.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.admin-table th {
  text-align: left;
  padding: .6rem .75rem;
  color: var(--c-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.admin-table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(255,255,255,.025); }
.row-inactive td { opacity: .45; }
.loading-cell { color: var(--c-muted); text-align: center; padding: 2rem; }
.action-cell { white-space: nowrap; }
.act-btn {
  font-size: .75rem;
  padding: .28rem .7rem;
  border-radius: 2rem;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  cursor: pointer;
  margin-right: .3rem;
  transition: color .15s, border-color .15s, background .15s;
}
.act-btn:hover      { color: var(--c-text); border-color: rgba(255,255,255,.2); }
.act-btn.act-warn   { color: #e67e22; border-color: rgba(230,126,34,.3); }
.act-btn.act-ok     { color: var(--c-ok); border-color: rgba(46,204,113,.3); }
.act-btn.act-danger { color: var(--c-danger); border-color: rgba(231,76,60,.3); }

.tag {
  font-size: .68rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: .2rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: inline-block;
  margin-right: .25rem;
}
.tag-verified { color: var(--c-verified); background: rgba(74,158,255,.12); }
.tag-admin    { color: var(--c-admin);    background: rgba(245,166,35,.12); }
.tag-disabled { color: var(--c-danger);   background: rgba(231,76,60,.1); }
.tag-normal   { color: var(--c-ok);       background: rgba(46,204,113,.1); }
.type-tag { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .15rem .4rem; border-radius: .2rem; background: rgba(255,255,255,.08); }
.type-tag.type-text  { color: #a89cff; }
.type-tag.type-photo { color: #7ec8f5; }
.type-tag.type-video { color: #f5a623; }

/* Settings card (admin) */
.settings-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  font-size: .9rem;
}
.toggle-input { display: none; }
.toggle-track {
  width: 44px; height: 24px;
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  border: 1px solid var(--c-border);
  flex-shrink: 0;
  transition: background .2s;
}
.toggle-input:checked + .toggle-track { background: rgba(255,255,255,.5); }
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.settings-hint { font-size: .78rem; color: var(--c-muted); }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .auth-row { grid-template-columns: 1fr; }
  .profile-banner-inner { gap: .75rem; }
  .header-search { max-width: 140px; }
  .admin-wrap { padding-top: calc(var(--header-h) + 1rem); }
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-wrap { padding-left: 1rem; padding-right: 1rem; }
  .notif-panel { width: 100vw; right: 0; border-radius: 0; }
  .feed-nav-btn { padding: .3rem .6rem; font-size: .72rem; }
}
@media (max-width: 480px) {
  /* header-search is kept visible — search is useful on mobile */
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
  .overlay-comment-form { flex-direction: column; }
}
