:root {
  --brand: #7b3fe4; --brand-2: #9b6bff; --brand-soft: #efe8fd; --brand-ink: #5a24c4;
  --bg: #f0f2f5; --card: #ffffff; --ink: #050505; --ink-2: #65676b; --ink-3: #8a8d91;
  --line: #e4e6eb; --hover: #f2f2f2; --input: #f0f2f5; --shadow: 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg: 0 12px 28px rgba(0,0,0,.2), 0 2px 4px rgba(0,0,0,.1);
  --green: #31a24c; --red: #e41e3f; --bubble-other: #e4e6eb; --overlay: rgba(244,244,244,.8);
  --radius: 8px; --nav-h: 56px;
}
:root[data-theme="dark"] {
  --bg: #18191a; --card: #242526; --ink: #e4e6eb; --ink-2: #b0b3b8; --ink-3: #8a8d91;
  --line: #3e4042; --hover: #3a3b3c; --input: #3a3b3c; --brand-soft: #2f2544; --bubble-other: #3e4042;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --overlay: rgba(11,11,11,.8);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI Historic", "Segoe UI", Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.34; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--brand); cursor: pointer; }
a.link:hover, .link:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font: inherit; color: var(--ink); }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px; }
.card h2, .card h3 { margin: 0 0 8px; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; height: 36px; border-radius: 6px;
  background: var(--input); color: var(--ink); font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(.95); }
:root[data-theme="dark"] .btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--red); color: #fff; }
.btn.green { background: #42b72a; color: #fff; }
.btn.block { width: 100%; }
.btn.lg { height: 48px; font-size: 20px; border-radius: 6px; }
.btn.sm { height: 30px; font-size: 13px; padding: 0 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--input); display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; position: relative; flex-shrink: 0; }
.icon-btn:hover { filter: brightness(.93); }
.icon-btn.active { background: var(--brand-soft); color: var(--brand); }
.ghost-btn { padding: 6px 8px; border-radius: 6px; color: var(--ink-2); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.ghost-btn:hover { background: var(--hover); }
.badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; min-width: 19px; height: 19px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.pill { display: inline-block; background: var(--input); border-radius: 12px; padding: 2px 10px; font-size: 13px; }

/* inputs */
.input, .textarea, .select { width: 100%; background: var(--input); border: 1px solid transparent; border-radius: 6px; padding: 10px 12px; outline: none; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); }
.textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.auth .input { background: #fff; border: 1px solid #dddfe2; font-size: 17px; padding: 14px 16px; color: #1c1e21; }

/* avatar */
.av { border-radius: 50%; object-fit: cover; background: var(--line); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; overflow: hidden; position: relative; }
.av-wrap { position: relative; display: inline-block; flex-shrink: 0; line-height: 0; }
.dot { position: absolute; right: 0; bottom: 0; width: 30%; height: 30%; min-width: 10px; min-height: 10px; max-width: 16px; max-height: 16px;
  background: var(--green); border: 2px solid var(--card); border-radius: 50%; }
.story-ring { padding: 2px; border: 3px solid var(--brand); border-radius: 50%; }

/* ---------- top nav */
#nav { position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); background: var(--card); box-shadow: var(--shadow); display: flex;
  align-items: center; justify-content: space-between; padding: 0 16px; z-index: 100; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; width: 320px; }
.nav-right { justify-content: flex-end; }
.logo { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 26px; font-family: Georgia, serif; flex-shrink: 0; }
.search-box { position: relative; flex: 1; }
.search-box input { width: 100%; background: var(--input); border: 0; border-radius: 20px; padding: 10px 12px 10px 36px; outline: none; }
.search-box .s-icon { position: absolute; left: 12px; top: 9px; color: var(--ink-2); }
.nav-center { display: flex; gap: 6px; height: 100%; }
.nav-tab { width: 110px; display: flex; align-items: center; justify-content: center; color: var(--ink-2); font-size: 24px; position: relative;
  border-bottom: 3px solid transparent; margin-top: 3px; border-radius: 8px 8px 0 0; }
.nav-tab:hover { background: var(--hover); }
.nav-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.nav-tab .badge { top: 6px; right: 26px; }
.dropdown { position: fixed; top: calc(var(--nav-h) - 4px); right: 12px; width: 360px; max-height: calc(100vh - 80px); overflow-y: auto; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 200; }
.dropdown h2 { margin: 6px 8px 10px; font-size: 24px; }
.search-results { position: absolute; top: 44px; left: -8px; width: 320px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 200; }

/* ---------- layout */
#app { padding-top: var(--nav-h); }
.layout { display: flex; justify-content: space-between; min-height: calc(100vh - var(--nav-h)); }
.side-left, .side-right { width: 360px; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto; padding: 16px 8px; flex-shrink: 0; }
.side-left::-webkit-scrollbar, .side-right::-webkit-scrollbar { width: 0; }
.feed-col { width: 100%; max-width: 680px; padding: 24px 16px; margin: 0 auto; }
.wide-col { width: 100%; max-width: 1100px; padding: 24px 16px; margin: 0 auto; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; font-weight: 500; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.menu-item.active { background: var(--brand-soft); }
.menu-item .mi-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--input); flex-shrink: 0; }
.section-title { color: var(--ink-2); font-weight: 600; font-size: 17px; margin: 12px 8px 6px; display: flex; justify-content: space-between; align-items: center; }
.divider { height: 1px; background: var(--line); margin: 8px 0; }
.sub-layout { display: flex; min-height: calc(100vh - var(--nav-h)); }
.sub-side { width: 360px; background: var(--card); box-shadow: var(--shadow); padding: 16px 8px; position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h)); overflow-y: auto; flex-shrink: 0; }
.sub-side h1 { margin: 0 8px 12px; }
.sub-main { flex: 1; padding: 24px 32px; min-width: 0; }

/* ---------- stories */
.stories { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.stories::-webkit-scrollbar { height: 0; }
.story-card { width: 112px; height: 200px; border-radius: 10px; flex-shrink: 0; position: relative; overflow: hidden; cursor: pointer;
  background: #333 center/cover; box-shadow: var(--shadow); }
.story-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 60%, rgba(0,0,0,.6)); }
.story-card:hover { filter: brightness(.9); }
.story-card .story-av { position: absolute; top: 10px; left: 10px; z-index: 2; border: 4px solid var(--brand); border-radius: 50%; line-height: 0; }
.story-card.seen .story-av { border-color: #999; }
.story-card .story-name { position: absolute; bottom: 8px; left: 8px; right: 8px; color: #fff; font-size: 13px; font-weight: 600; z-index: 2; }
.story-card .story-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #fff;
  font-weight: 700; padding: 10px; font-size: 13px; }
.story-create { background: var(--card); }
.story-create .sc-img { height: 150px; background: var(--input) center/cover; }
.story-create .sc-plus { position: absolute; top: 132px; left: 50%; transform: translateX(-50%); width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; border: 4px solid var(--card); z-index: 3; }
.story-create .story-name { color: var(--ink); text-align: center; bottom: 10px; }
.story-create::after { display: none; }
.story-viewer { position: fixed; inset: 0; background: #000; z-index: 500; display: flex; }
.sv-side { width: 360px; background: var(--card); color: var(--ink); padding: 16px; overflow-y: auto; }
.sv-stage { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.sv-frame { width: min(420px, 95vw); height: min(92vh, 750px); border-radius: 12px; overflow: hidden; position: relative; background: #222; display: flex;
  align-items: center; justify-content: center; }
.sv-frame img, .sv-frame video { width: 100%; height: 100%; object-fit: contain; }
.sv-text { color: #fff; font-size: 28px; font-weight: 700; text-align: center; padding: 24px; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.sv-caption { position: absolute; bottom: 80px; left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; font-size: 20px; text-shadow: 0 1px 4px #000; padding: 0 16px; }
.sv-bars { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 3; }
.sv-bar { flex: 1; height: 3px; background: rgba(255,255,255,.35); border-radius: 2px; overflow: hidden; }
.sv-bar i { display: block; height: 100%; width: 0; background: #fff; }
.sv-head { position: absolute; top: 22px; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; color: #fff; z-index: 3; text-shadow: 0 1px 3px #000; }
.sv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.85);
  color: #000; font-size: 22px; z-index: 4; }
.sv-reply { position: absolute; bottom: 14px; left: 12px; right: 12px; display: flex; gap: 6px; align-items: center; z-index: 3; }
.sv-reply input { flex: 1; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 20px; padding: 10px 14px; outline: none; }
.sv-reply button.em { font-size: 24px; }
.sv-close { position: absolute; top: 12px; left: 12px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; font-size: 22px; }

/* ---------- composer */
.composer-top { display: flex; gap: 8px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.fake-input { flex: 1; background: var(--input); border-radius: 20px; padding: 10px 12px; color: var(--ink-2); cursor: pointer; }
.fake-input:hover { filter: brightness(.96); }
.composer-actions { display: flex; justify-content: space-around; padding-top: 8px; }
.composer-actions .ghost-btn { flex: 1; justify-content: center; }
.composer-box textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; font-size: 24px; min-height: 120px; }
.composer-box textarea.small-text { font-size: 15px; }
.composer-bg { border-radius: 8px; min-height: 280px; display: flex; align-items: center; justify-content: center; }
.composer-bg textarea { color: #fff; text-align: center; font-weight: 700; font-size: 28px; min-height: 80px; }
.composer-bg textarea::placeholder { color: rgba(255,255,255,.8); }
.bg-choices { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.bg-choice { width: 32px; height: 32px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.bg-choice.sel { border-color: var(--ink); }
.add-to { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.add-to .tools { display: flex; gap: 2px; }
.add-to .tools button { width: 36px; height: 36px; border-radius: 50%; font-size: 22px; }
.add-to .tools button:hover { background: var(--hover); }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin: 8px 0; }
.preview-grid .pv { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #000; }
.preview-grid .pv img, .preview-grid .pv video { width: 100%; height: 100%; object-fit: cover; }
.preview-grid .pv button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--card); font-size: 14px; }
.privacy-sel { background: var(--input); border: 0; border-radius: 6px; padding: 2px 6px; font-size: 13px; font-weight: 600; }
.poll-edit input { margin-bottom: 6px; }

/* ---------- post */
.post { padding: 12px 0 0; }
.post-head { display: flex; gap: 8px; padding: 0 16px; align-items: flex-start; }
.post-head .who { flex: 1; min-width: 0; }
.post-head .who a.bold:hover { text-decoration: underline; }
.post-head .meta { color: var(--ink-2); font-size: 13px; display: flex; gap: 4px; align-items: center; }
.post-head .meta a:hover { text-decoration: underline; }
.post-text { padding: 8px 16px 12px; white-space: pre-wrap; word-wrap: break-word; }
.post-text.big { font-size: 24px; }
.post-text.bg { min-height: 320px; display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; font-size: 30px; font-weight: 700; padding: 40px; margin: 0; }
.see-more { color: var(--ink-2); font-weight: 600; cursor: pointer; }
.post-media { display: grid; gap: 2px; background: var(--card); cursor: pointer; }
.post-media.n1 { grid-template-columns: 1fr; }
.post-media.n2 { grid-template-columns: 1fr 1fr; }
.post-media.n3 { grid-template-columns: 1fr 1fr; }
.post-media.n3 > :first-child { grid-column: span 2; }
.post-media.n4 { grid-template-columns: 1fr 1fr; }
.post-media .m { position: relative; background: #000; overflow: hidden; }
.post-media.n1 .m img { width: 100%; max-height: 700px; object-fit: contain; display: block; margin: 0 auto; }
.post-media:not(.n1) .m { aspect-ratio: 1; }
.post-media:not(.n1) .m img, .post-media:not(.n1) .m video { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-media video { width: 100%; max-height: 700px; display: block; background: #000; }
.post-media .more { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 32px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.post-media .file { padding: 12px 16px; background: var(--input); display: flex; gap: 8px; align-items: center; cursor: default; }
.avatar-post { display: flex; justify-content: center; padding: 20px 0; background: linear-gradient(var(--input), var(--card)); }
.avatar-post img { width: 300px; height: 300px; border-radius: 50%; object-fit: cover; border: 4px solid var(--card); }
.shared-box { margin: 0 16px 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.shared-box .post { padding-top: 12px; }
.post-stats { display: flex; justify-content: space-between; padding: 10px 16px; color: var(--ink-2); font-size: 15px; }
.post-stats span.clickable:hover { text-decoration: underline; cursor: pointer; }
.r-icons { display: inline-flex; align-items: center; }
.r-icons span { font-size: 16px; margin-right: -3px; background: var(--card); border-radius: 50%; line-height: 1; }
.post-actions { display: flex; border-top: 1px solid var(--line); margin: 0 16px; padding: 4px 0; }
.post-actions > * { flex: 1; }
.post-actions .ghost-btn { width: 100%; justify-content: center; }
.react-wrap { position: relative; }
.react-pop { position: absolute; bottom: 42px; left: 0; background: var(--card); box-shadow: var(--shadow-lg); border-radius: 30px; padding: 4px 6px; display: flex; gap: 2px; z-index: 50;
  animation: pop .15s ease-out; }
.react-pop button { font-size: 32px; transition: transform .12s; line-height: 1; padding: 2px; }
.react-pop button:hover { transform: scale(1.35) translateY(-6px); }
@keyframes pop { from { transform: scale(.7) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.r-like { color: var(--brand) !important; } .r-love { color: #f33e58 !important; } .r-care, .r-haha, .r-wow, .r-sad { color: #f7b125 !important; } .r-angry { color: #e9710f !important; }
.poll { margin: 0 16px 12px; }
.poll-opt { position: relative; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; overflow: hidden; }
.poll-opt .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand-soft); z-index: 0; transition: width .3s; }
.poll-opt .lbl { position: relative; z-index: 1; display: flex; justify-content: space-between; }
.poll-opt.mine { border-color: var(--brand); font-weight: 600; }
.embed-card { margin: 0 16px 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; }
.embed-card .ec-img { height: 200px; background: var(--brand-soft) center/cover; display: flex; align-items: center; justify-content: center; font-size: 60px; }
.embed-card .ec-body { padding: 10px 12px; background: var(--input); }

/* comments */
.comments { padding: 4px 16px 12px; border-top: 1px solid var(--line); margin: 0 0; }
.comment { display: flex; gap: 6px; margin-top: 8px; }
.comment .bubble-wrap { min-width: 0; max-width: calc(100% - 44px); }
.comment .cbubble { background: var(--input); border-radius: 18px; padding: 8px 12px; display: inline-block; max-width: 100%; position: relative; word-wrap: break-word; }
.comment .cbubble .name { font-weight: 600; font-size: 13px; }
.comment .cbubble .ctext { white-space: pre-wrap; }
.comment .cimg { max-width: 240px; border-radius: 12px; margin-top: 4px; display: block; cursor: pointer; }
.comment .cactions { font-size: 12px; color: var(--ink-2); font-weight: 700; display: flex; gap: 12px; padding: 2px 12px; align-items: center; }
.comment .cactions button:hover { text-decoration: underline; }
.comment .creact { position: absolute; right: -10px; bottom: -10px; background: var(--card); box-shadow: var(--shadow); border-radius: 10px; padding: 0 4px; font-size: 12px; white-space: nowrap; }
.replies { margin-left: 40px; }
.comment-input { display: flex; gap: 6px; margin-top: 8px; align-items: flex-start; }
.comment-input .ci-box { flex: 1; background: var(--input); border-radius: 18px; display: flex; align-items: flex-end; padding: 2px 6px 2px 12px; }
.comment-input textarea { flex: 1; border: 0; background: transparent; outline: none; resize: none; padding: 7px 0; max-height: 120px; min-height: 22px; height: 34px; }
.comment-input .ci-tools button { width: 30px; height: 30px; border-radius: 50%; color: var(--ink-2); font-size: 16px; }
.comment-input .ci-tools button:hover { background: var(--hover); }
.view-more { color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer; margin-top: 8px; display: inline-block; }
.view-more:hover { text-decoration: underline; }

/* menus */
.pop-menu { position: absolute; right: 0; top: 36px; background: var(--card); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px; min-width: 260px; z-index: 60; }
.pop-menu button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px; border-radius: 6px; font-weight: 500; }
.pop-menu button:hover { background: var(--hover); }
.rel { position: relative; }

/* ---------- modals */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); z-index: 400; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto; }
.modal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 500px; max-width: 100%; position: relative; }
.modal.wide { width: 700px; }
.modal-head { padding: 16px; border-bottom: 1px solid var(--line); text-align: center; font-size: 20px; font-weight: 700; position: relative; }
.modal-head .x { position: absolute; right: 12px; top: 10px; }
.modal-body { padding: 16px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 600; display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 92vh; }
.lightbox .x, .lightbox .nav-l, .lightbox .nav-r { position: absolute; color: #fff; background: rgba(255,255,255,.15); width: 44px; height: 44px; border-radius: 50%; font-size: 22px; }
.lightbox .x { top: 16px; left: 16px; } .lightbox .nav-l { left: 16px; top: 50%; } .lightbox .nav-r { right: 16px; top: 50%; }

/* toasts */
#toasts { position: fixed; left: 16px; bottom: 16px; z-index: 700; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 12px 16px; max-width: 360px; display: flex; gap: 10px; align-items: center;
  animation: slidein .2s ease-out; cursor: pointer; }
.toast.error { border-left: 4px solid var(--red); }
@keyframes slidein { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- user list */
.person { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; }
.person:hover { background: var(--hover); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.pcard { background: var(--card); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.pcard .pc-img { aspect-ratio: 1; background: var(--input) center/cover; display: flex; align-items: center; justify-content: center; font-size: 64px; color: #fff; cursor: pointer; }
.pcard .pc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard .pc-body .bold { font-size: 17px; }
.pcard .pc-body .btns { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

/* ---------- profile */
.profile-head { background: var(--card); box-shadow: var(--shadow); }
.profile-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.cover { height: 400px; border-radius: 0 0 8px 8px; background: linear-gradient(135deg, #cfc2f2, #8d6ae8) center/cover; position: relative; }
.cover .edit-cover { position: absolute; right: 16px; bottom: 16px; background: #fff; color: #000; }
.profile-bar { display: flex; align-items: flex-end; gap: 16px; padding: 0 16px 16px; margin-top: -84px; position: relative; flex-wrap: wrap; }
.profile-av { position: relative; }
.profile-av .av { border: 4px solid var(--card); }
.profile-av .cam { position: absolute; bottom: 10px; right: 6px; }
.profile-name { flex: 1; padding-bottom: 8px; min-width: 240px; }
.profile-name h1 { font-size: 32px; margin: 0; }
.profile-actions { display: flex; gap: 8px; padding-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-top: 1px solid var(--line); margin: 0 16px; }
.tab { padding: 16px; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; cursor: pointer; border-radius: 6px 6px 0 0; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.profile-body { max-width: 1100px; margin: 16px auto; padding: 0 16px; display: flex; gap: 16px; align-items: flex-start; }
.profile-body .pleft { width: 40%; position: sticky; top: 72px; }
.profile-body .pright { flex: 1; min-width: 0; }
.intro-item { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 8px; overflow: hidden; }
.photo-grid .ph { aspect-ratio: 1; background: #000 center/cover; cursor: pointer; }
.photo-grid.big { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.friend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.friend-grid .fg img, .friend-grid .fg .av { width: 100%; aspect-ratio: 1; border-radius: 8px; height: auto !important; }
.friend-grid .fg .name { font-weight: 600; font-size: 13px; margin-top: 4px; }

/* ---------- messenger */
.msgr { display: flex; height: calc(100vh - var(--nav-h)); background: var(--card); }
.msgr-list { width: 360px; border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.msgr-list .ml-head { padding: 12px 16px 8px; }
.msgr-list .ml-head h1 { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.msgr-list .ml-items { flex: 1; overflow-y: auto; padding: 0 8px; }
.conv-item { display: flex; gap: 12px; align-items: center; padding: 10px 8px; border-radius: 8px; cursor: pointer; }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--brand-soft); }
.conv-item .ci-last { font-size: 13px; color: var(--ink-2); display: flex; gap: 4px; }
.conv-item.unread .ci-name, .conv-item.unread .ci-last { font-weight: 700; color: var(--ink); }
.conv-item .udot { width: 12px; height: 12px; background: var(--brand); border-radius: 50%; flex-shrink: 0; }
.msgr-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.th-head { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 16px; box-shadow: 0 1px 2px rgba(0,0,0,.1); flex-shrink: 0; z-index: 2; }
.th-head .th-tools button { color: var(--brand); font-size: 20px; width: 36px; height: 36px; border-radius: 50%; }
.th-head .th-tools button:hover { background: var(--hover); }
.th-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.th-intro { text-align: center; padding: 24px 0; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; position: relative; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row .msg-av { width: 28px; flex-shrink: 0; }
.msg-stack { max-width: 65%; display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.me .msg-stack { align-items: flex-end; }
.bubble { background: var(--bubble-other); padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; max-width: 100%; position: relative; }
.msg-row.me .bubble { background: var(--chat-color, var(--brand)); color: #fff; }
.msg-row.me .bubble a { color: #fff; text-decoration: underline; }
.bubble.emoji-only { background: none !important; font-size: 40px; padding: 0 4px; }
.bubble.deleted { background: none !important; border: 1px solid var(--line); color: var(--ink-2) !important; font-style: italic; }
.msg-media img, .msg-media video { max-width: 280px; max-height: 320px; border-radius: 16px; display: block; cursor: pointer; }
.msg-media audio { max-width: 260px; }
.msg-file { display: flex; gap: 8px; align-items: center; background: var(--input); padding: 10px 12px; border-radius: 16px; }
.msg-reply-ref { font-size: 12px; color: var(--ink-2); background: var(--input); border-radius: 14px; padding: 6px 10px; margin-bottom: -8px; padding-bottom: 12px; opacity: .8; max-width: 100%; }
.msg-reacts { background: var(--card); box-shadow: var(--shadow); border-radius: 10px; font-size: 12px; padding: 1px 4px; margin-top: -6px; z-index: 1; cursor: pointer; }
.msg-tools { display: none; gap: 2px; align-self: center; }
.msg-row:hover .msg-tools { display: flex; }
.msg-tools button { width: 28px; height: 28px; border-radius: 50%; color: var(--ink-2); font-size: 14px; }
.msg-tools button:hover { background: var(--hover); }
.msg-time { text-align: center; font-size: 12px; color: var(--ink-2); margin: 12px 0 6px; }
.msg-system { text-align: center; font-size: 12px; color: var(--ink-2); margin: 6px 0; }
.msg-seen { display: flex; justify-content: flex-end; gap: 2px; margin: 2px 0 4px; }
.msg-edited { font-size: 11px; color: var(--ink-2); padding: 0 8px; }
.typing { display: flex; gap: 4px; padding: 10px 14px; background: var(--bubble-other); border-radius: 18px; width: fit-content; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.th-input { display: flex; align-items: flex-end; gap: 4px; padding: 10px 12px; flex-shrink: 0; }
.th-input > button { color: var(--chat-color, var(--brand)); font-size: 20px; width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.th-input > button:hover { background: var(--hover); }
.th-input .ti-box { flex: 1; background: var(--input); border-radius: 20px; display: flex; align-items: flex-end; padding: 0 8px 0 12px; min-width: 0; }
.th-input textarea { flex: 1; border: 0; background: transparent; outline: none; resize: none; padding: 9px 0; max-height: 140px; height: 38px; min-width: 0; }
.replying { padding: 8px 16px 0; font-size: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.msgr-info { width: 320px; border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; flex-shrink: 0; }
.msgr-info .mi-top { text-align: center; margin-bottom: 16px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; }
.emoji-grid button { font-size: 22px; padding: 4px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-pop { position: absolute; bottom: 50px; right: 10px; background: var(--card); box-shadow: var(--shadow-lg); border-radius: 10px; width: 320px; max-height: 260px; overflow-y: auto; z-index: 80; }

/* chat dock popups */
#chatdock { position: fixed; bottom: 0; right: 80px; display: flex; gap: 10px; align-items: flex-end; z-index: 300; }
.chat-pop { width: 330px; height: 455px; background: var(--card); border-radius: 8px 8px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.chat-pop.min { height: auto; }
.chat-pop .th-head { height: 48px; padding: 0 6px 0 8px; }
.chat-pop .th-body { padding: 8px; }
.chat-pop .msg-stack { max-width: 75%; }
.chat-pop .msg-media img, .chat-pop .msg-media video { max-width: 200px; }
.chat-pop .th-input { padding: 6px; }
.chat-pop .th-input > button { width: 30px; height: 30px; font-size: 17px; }
#chatheads { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.chathead { width: 48px; height: 48px; border-radius: 50%; box-shadow: var(--shadow-lg); cursor: pointer; position: relative; }
.newmsg-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow-lg); font-size: 20px; }

/* ---------- auth */
.auth { min-height: 100vh; background: #f0f2f5; display: flex; align-items: center; justify-content: center; padding: 40px 16px; color: #1c1e21; }
.auth-inner { display: flex; gap: 60px; align-items: center; max-width: 980px; width: 100%; flex-wrap: wrap; justify-content: center; }
.auth-brand { flex: 1; min-width: 300px; }
.auth-brand .wordmark { color: var(--brand); font-size: 60px; font-weight: 800; letter-spacing: -2px; margin: 0; font-family: Helvetica, Arial, sans-serif; }
.auth-brand p { font-size: 28px; line-height: 32px; margin: 0; }
.auth-card { background: #fff; width: 396px; max-width: 100%; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,.1), 0 8px 16px rgba(0,0,0,.1); padding: 16px; }
.auth-card .input { margin-bottom: 12px; }
.auth-card hr { border: 0; border-top: 1px solid #dadde1; margin: 20px 0; }
.auth-err { color: var(--red); font-size: 14px; margin-bottom: 10px; }
.auth-modal .input { background: #f5f6f7; font-size: 15px; padding: 11px; }
.auth-modal .row2 { display: flex; gap: 10px; }
.auth-modal label { font-size: 12px; color: #606770; }

/* misc */
.empty { text-align: center; color: var(--ink-2); padding: 40px 16px; }
.empty .big { font-size: 60px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.notif { display: flex; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; align-items: center; position: relative; }
.notif:hover { background: var(--hover); }
.notif .nicon { position: absolute; left: 44px; top: 40px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 14px; }
.notif.unread .ntext { font-weight: 600; }
.notif.unread::after { content: ""; width: 12px; height: 12px; background: var(--brand); border-radius: 50%; flex-shrink: 0; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 6px 12px; border-radius: 18px; background: var(--input); font-weight: 600; cursor: pointer; font-size: 14px; }
.chip.active { background: var(--brand-soft); color: var(--brand); }
.listing-price { font-weight: 700; font-size: 17px; }
.event-date { color: var(--red); font-weight: 700; font-size: 13px; text-transform: uppercase; }
.table { width: 100%; border-collapse: collapse; }
.table td, .table th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.mention-box { position: absolute; background: var(--card); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 4px; z-index: 900; width: 260px; }
.mention-box .person { padding: 6px; }
.mention-box .person.sel { background: var(--hover); }
.hash { color: var(--brand); font-weight: 600; }
.switch { position: relative; width: 44px; height: 24px; background: var(--line); border-radius: 12px; cursor: pointer; transition: .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; }
.switch.on { background: var(--brand); }
.switch.on::after { left: 22px; }
.group-cover { height: 320px; background: linear-gradient(135deg, var(--brand-2), #3b1a8f) center/cover; border-radius: 0 0 8px 8px; }

/* responsive */
@media (max-width: 1260px) { .side-right { display: none; } .msgr-info { display: none; } }
@media (max-width: 1000px) { .side-left { display: none; } .nav-center .nav-tab { width: 70px; } .sub-side { width: 280px; } }
@media (max-width: 760px) {
  .nav-left, .nav-right { width: auto; } .nav-left .search-box { display: none; } .nav-center .nav-tab { width: 48px; font-size: 20px; }
  .nav-tab .badge { right: 2px; } .sub-layout { flex-direction: column; } .sub-side { width: 100%; height: auto; position: static; }
  .sub-main { padding: 16px; } .profile-body { flex-direction: column; } .profile-body .pleft { width: 100%; position: static; }
  .cover { height: 200px; } .profile-bar { margin-top: -60px; }
  .msgr-list { width: 100%; } .msgr.has-thread .msgr-list { display: none; } .msgr:not(.has-thread) .msgr-thread { display: none; }
  #chatdock { right: 0; } .chat-pop { width: 100vw; } .sv-side { display: none; } .feed-col { padding: 12px 8px; }
  .auth-brand { text-align: center; } .auth-brand .wordmark { font-size: 44px; } .auth-brand p { font-size: 20px; }
}

/* ---------- calls */
.call-ui { position: fixed; inset: 0; background: #0b0b10; color: #fff; z-index: 800; display: flex; flex-direction: column; }
.call-ui.min { inset: auto; top: 70px; right: 16px; width: 300px; padding: 10px 12px; border-radius: 12px; box-shadow: var(--shadow-lg); background: #1d1b26; }
.call-top { display: flex; align-items: center; padding: 16px 20px; }
.call-grid { flex: 1; display: grid; gap: 10px; padding: 0 20px; min-height: 0; grid-template-columns: 1fr; }
.call-grid.n2 { grid-template-columns: 1fr 1fr; }
.call-grid.n3, .call-grid.n4 { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; }
.call-grid.n5, .call-grid.n6 { grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: 1fr; }
.call-tile { position: relative; background: #1d1b26; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; }
.call-tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.ct-av { display: flex; align-items: center; justify-content: center; }
.ct-name { position: absolute; left: 12px; bottom: 10px; background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.call-self { position: absolute; right: 24px; bottom: 100px; width: 220px; aspect-ratio: 16/10; background: #2a2735; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; }
.call-self video { width: 100%; height: 100%; object-fit: cover; }
.call-self video.mirror { transform: scaleX(-1); }
.call-bar { display: flex; justify-content: center; gap: 14px; padding: 18px; }
.call-btn { width: 56px; height: 56px; border-radius: 50%; background: #3a3747; color: #fff; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; }
.call-btn:hover { filter: brightness(1.2); }
.call-btn.sm { width: 36px; height: 36px; font-size: 16px; }
.call-btn.red { background: #e41e3f; }
.call-btn.green { background: #31a24c; }
.call-btn.off { background: #fff; color: #000; }
.call-btn.on { background: var(--brand); }
.incoming-call { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 850; background: var(--card); color: var(--ink); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 28px 36px; text-align: center; min-width: 320px; animation: pop .2s ease-out; }
.ic-pulse { display: inline-block; border-radius: 50%; animation: ring 1.4s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(49,162,76,.6); } 70% { box-shadow: 0 0 0 26px rgba(49,162,76,0); } 100% { box-shadow: 0 0 0 0 rgba(49,162,76,0); } }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
.voice-note { display: flex; align-items: center; gap: 6px; background: var(--input); padding: 6px 10px; border-radius: 20px; }
.voice-note audio { height: 36px; }
@media (max-width: 760px) { .call-self { width: 120px; bottom: 96px; right: 12px; } .call-grid.n2 { grid-template-columns: 1fr; } .call-btn { width: 48px; height: 48px; } }
.post-text.bg a { color: #fff !important; text-decoration: underline; }
.profile-bar { margin-top: 0 !important; align-items: flex-end; }
.profile-av { margin-top: -84px; }
.profile-name { padding-top: 12px; }
@media (max-width: 760px) { .profile-av { margin-top: -60px; } }
