/* AION — Dark theme, zero-gap grid, overlay postcards */

:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1c1c1f;
    --text: #f5f5f7;
    --dim: #a0a0a8;
    --border: rgba(255,255,255,0.08);
    --accent: #4a7cff;
    --accent-hover: #5c8aff;
    --like: #ff3b5c;
    --cols: 5;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { overflow-x: clip; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10,10,11,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
}
.topbar-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 16px;
    max-width: 100%;
}
.topbar-inner .logo { grid-column: 1; justify-self: start; }
.topbar-inner .topnav-center { grid-column: 2; justify-self: center; }
.topbar-inner .topnav-right { grid-column: 3; justify-self: end; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .5px; }
.logo-mark { color: var(--accent); font-size: 22px; }
.logo-text { font-size: 16px; }
.logo-sub { color: var(--dim); font-weight: 400; margin-left: 4px; font-size: 11px; letter-spacing: 2px; }
.logo-img { height: 28px; width: auto; display: block; }

.topnav { display: flex; align-items: center; gap: 2px; }
.nav-btn {
    position: relative;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--text);
    border: none; border-radius: 50%;
    transition: background .15s ease;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.nav-btn .icon { width: 20px; height: 20px; }
.nav-btn .badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--like); color: #fff;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    padding: 0 4px;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
}
.nav-link { padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.nav-link-primary { background: var(--accent); color: #fff; }
.nav-link-primary:hover { background: var(--accent-hover); color: #fff; }

/* ---------- Dropdowns ---------- */
.dropdown {
    display: none;
    position: absolute; top: var(--topbar-h); right: 0;
    width: 320px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    z-index: 99;
}
.dropdown.open { display: block; }
.dropdown-inner { display: flex; flex-direction: column; gap: 16px; }

/* Compact menu-style dropdown (e.g. account menu) */
.dropdown-menu { width: 180px; padding: 6px; }
.dropdown-menu .dropdown-inner { gap: 2px; }
.dropdown-item {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    transition: background .12s ease;
}
.dropdown-item:hover { background: rgba(255,255,255,0.08); }
.dropdown-item-primary { background: var(--accent); color: #fff; }
.dropdown-item-primary:hover { background: var(--accent-hover); color: #fff; }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-group > label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 6px 12px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    transition: all .15s ease;
}
.chip:hover { border-color: rgba(255,255,255,0.2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.slider { width: 100%; accent-color: var(--accent); }

.search-form { display: flex; gap: 8px; }
.search-input {
    flex: 1; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-submit {
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px; padding: 10px 16px;
    font-size: 14px; font-weight: 600;
}

/* Mobile dropdowns: full width */
@media (max-width: 640px) {
    .dropdown { width: 100%; right: 0; left: 0; border-radius: 0; }
    .topbar-inner { padding: 0 8px; }
    .nav-btn { width: 34px; height: 34px; }
    .nav-btn .icon { width: 18px; height: 18px; }
}

/* ---------- Main ---------- */
.main-content { min-height: calc(100vh - var(--topbar-h)); }

/* ---------- Grid (row-span masonry, preserves DOM order) ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 1px;
    width: 100%;
    margin: 0 auto;
}
.grid[data-columns="1"] { max-width: 640px; }
.grid[data-columns="2"] { max-width: 1040px; }

@media (max-width: 600px) {
    .grid { grid-template-columns: repeat(min(var(--cols), 3), 1fr) !important; max-width: 100% !important; }
}

/* Profile-only: constrain grid container to header width */
.profile-feed {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
}
@media (max-width: 600px) {
    .profile-feed { padding: 0; }
}

/* ---------- Postcard ---------- */
.postcard {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
    isolation: isolate;
    aspect-ratio: 2 / 3;
}
.postcard-media {
    position: absolute;
    inset: 0;
    display: block;
}
.postcard-media img,
.postcard-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.media-indicator {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    z-index: 3;
}

/* Audio tile */
.audio-tile {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #2a1a5e 0%, #4a2a8e 100%);
    display: flex; align-items: center; justify-content: center;
}
.postcard .audio-tile {
    position: absolute;
    inset: 0;
    aspect-ratio: auto;
    height: 100%;
}
.audio-wave {
    display: flex; align-items: center; gap: 3px;
    height: 60%;
}
.audio-wave span {
    display: block;
    width: 4px;
    background: rgba(255,255,255,0.6);
    border-radius: 2px;
    animation: wave 1.2s ease-in-out infinite;
}
.audio-wave span:nth-child(1) { height: 20%; animation-delay: 0s; }
.audio-wave span:nth-child(2) { height: 50%; animation-delay: .1s; }
.audio-wave span:nth-child(3) { height: 80%; animation-delay: .2s; }
.audio-wave span:nth-child(4) { height: 40%; animation-delay: .3s; }
.audio-wave span:nth-child(5) { height: 70%; animation-delay: .4s; }
.audio-wave span:nth-child(6) { height: 30%; animation-delay: .5s; }
.audio-wave span:nth-child(7) { height: 90%; animation-delay: .6s; }
.audio-wave span:nth-child(8) { height: 50%; animation-delay: .7s; }
.audio-wave span:nth-child(9) { height: 60%; animation-delay: .8s; }
.audio-wave span:nth-child(10) { height: 30%; animation-delay: .9s; }
.audio-wave span:nth-child(11) { height: 70%; animation-delay: 1s; }
.audio-wave span:nth-child(12) { height: 40%; animation-delay: 1.1s; }
.audio-wave span:nth-child(13) { height: 80%; animation-delay: 1.2s; }
.audio-wave span:nth-child(14) { height: 20%; animation-delay: 1.3s; }
.audio-wave span:nth-child(15) { height: 55%; animation-delay: 1.4s; }
.audio-wave span:nth-child(16) { height: 75%; animation-delay: 1.5s; }
.audio-wave span:nth-child(17) { height: 35%; animation-delay: 1.6s; }
.audio-wave span:nth-child(18) { height: 65%; animation-delay: 1.7s; }
.audio-wave span:nth-child(19) { height: 45%; animation-delay: 1.8s; }
.audio-wave span:nth-child(20) { height: 60%; animation-delay: 1.9s; }
@keyframes wave { 0%,100% { transform: scaleY(.5); } 50% { transform: scaleY(1); } }

/* Text tile — container for short/long typography modes */
.text-tile {
    width: 100%;
    padding: 10% 8%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    color: #fff;
    overflow: hidden;
}
/* Inside a postcard, fill the 2:3 tile exactly */
.postcard .text-tile {
    position: absolute;
    inset: 0;
    height: 100%;
}
.text-tile-title {
    font-weight: 700;
    margin: 0 0 .4em;
    line-height: 1.2;
    font-size: clamp(16px, 2.2vw, 26px);
}
.text-tile-body {
    line-height: 1.35;
    margin: 0;
    overflow: hidden;
    word-wrap: break-word;
    /* Soft gradient fade-out for overflowing text, regardless of tile bg color */
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
            mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}
.text-tile-body a { color: inherit; text-decoration: underline; }

/* Short text: scales big to fill the tile */
.text-tile.text-short .text-tile-body {
    font-size: clamp(20px, 4.5cqw, 56px);
    font-weight: 600;
    line-height: 1.15;
}
.text-tile.text-short .text-tile-title {
    font-size: clamp(18px, 3.5cqw, 40px);
}
/* When title is present with short body, give a bit less size to body */
.text-tile.text-short .text-tile-title + .text-tile-body {
    font-size: clamp(16px, 3cqw, 36px);
}

/* Long text: normal reading size, wraps, clamps with ellipsis */
.text-tile.text-long {
    justify-content: flex-start;
    text-align: left;
    padding: 14% 10%;
}
.text-tile.text-long .text-tile-title {
    font-size: clamp(15px, 1.6cqw, 20px);
    text-align: left;
    width: 100%;
}
.text-tile.text-long .text-tile-body {
    font-size: clamp(12px, 1.3cqw, 15px);
    line-height: 1.45;
    text-align: left;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Postcard becomes a container for cqw/cqh units */
.postcard { container-type: inline-size; }

/* Gradients */
.gradient-1 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.gradient-2 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.gradient-3 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.gradient-4 { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.gradient-5 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.gradient-6 { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.gradient-7 { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); color: #222; }
.gradient-8 { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); color: #222; }
.gradient-7 .text-tile-body a, .gradient-8 .text-tile-body a { color: #222; }

/* Link preview tile (native to AION — not an embedded widget) */
.link-tile {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    color: #fff;
    overflow: hidden;
    text-decoration: none;
}
.postcard .link-tile { position: absolute; inset: 0; }
.link-tile-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    justify-content: flex-end;
}
.link-tile-image::before {
    content: '';
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.55) 45%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}
.link-tile-caption {
    position: relative;
    padding: 14% 8% 14%;
    display: flex; flex-direction: column; gap: 4px;
}
.link-tile-text {
    padding: 12% 8%;
    justify-content: center;
    text-align: center;
    align-items: center;
}
.link-tile-title {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.link-tile-text .link-tile-title {
    font-size: 1.15em;
    -webkit-line-clamp: 4;
    margin-bottom: 8px;
}
.link-tile-desc {
    margin: 0 0 10px;
    font-size: 0.85em;
    line-height: 1.35;
    color: rgba(255,255,255,0.88);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
            mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}
.link-tile-host {
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
    color: rgba(255,255,255,0.72);
}
.link-tile-image .link-tile-host { margin-bottom: 4px; }
.postcard-link .postcard-hover-overlay .hover-host {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.72);
}

/* Overlays */
.postcard-user {
    position: absolute;
    top: 8px; left: 8px;
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 4px;
    background: rgba(0,0,0,0.5);
    border-radius: 999px;
    z-index: 4;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(6px);
}
.postcard-user:hover { background: rgba(0,0,0,0.75); color: #fff; }
.avatar-sm {
    width: 24px; height: 24px; border-radius: 50%;
    object-fit: cover;
}

.postcard-title-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 48px;
    padding: 24px 12px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
    z-index: 3;
    pointer-events: none;
}
.postcard-title-overlay h4 {
    margin: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.postcard-menu-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 30px; height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 5;
    padding: 0;
    transition: background .15s ease;
}
.postcard-menu-btn:hover { background: rgba(0,0,0,0.8); }

.profile-actions { display: flex; gap: 8px; align-items: center; }
.profile-menu-btn { padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; }

.post-menu-popover {
    position: absolute;
    z-index: 9999;
    min-width: 140px;
    background: rgba(24,24,27,0.98);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: reaction-pop .12s ease-out;
}
.post-menu-popover button {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.post-menu-popover button:hover { background: rgba(255,255,255,0.06); }
.post-menu-popover button.danger { color: #ff6b6b; }

/* Desktop hover overlay — full post text fades in over media tiles */
.postcard-hover-overlay {
    position: absolute;
    inset: 0;
    padding: 36px 18px 48px;
    background: rgba(0,0,0,0.72);
    color: #fff;
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
    gap: 10px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.postcard-hover-overlay::-webkit-scrollbar { width: 4px; }
.postcard-hover-overlay::-webkit-scrollbar-track { background: transparent; }
.postcard-hover-overlay::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
}
.postcard-hover-overlay::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
.postcard-hover-overlay .hover-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}
.postcard-hover-overlay .hover-body {
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: rgba(255,255,255,0.92);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.postcard-hover-overlay .hover-host {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.65);
    margin-top: 2px;
}

/* Link-tile hover: fade the link caption so the overlay reads cleanly. */
@media (hover: hover) {
    .postcard-link .link-tile-caption { transition: opacity .18s ease; }
    .postcard-link:hover .link-tile-caption { opacity: 0; }
    .postcard-link:hover .link-tile-image::before { opacity: 0.25; transition: opacity .18s ease; }
}
@media (hover: hover) {
    .postcard:hover .postcard-hover-overlay { opacity: 1; }
    .postcard:hover .postcard-title-overlay { opacity: 0; }

    /* Desktop grid tile zoom — ~1.4x on hover so content is readable
       without clicking. transform-origin is set per-tile by JS so the
       tile grows toward whichever corner keeps it on-screen. */
    .grid:not([data-columns="1"]) .postcard {
        transition: transform .18s ease, box-shadow .18s ease;
    }
    .grid:not([data-columns="1"]) .postcard:hover {
        transform: scale(1.2);
        z-index: 50;
        box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    }
}
.postcard-title-overlay { transition: opacity .18s ease; }

.postcard-actions {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 8px 4%;
    display: flex; gap: 0; align-items: center; justify-content: space-evenly;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    z-index: 4;
    opacity: 1;
    transition: opacity .2s ease;
    pointer-events: auto;
}
@media (max-width: 640px) {
    .postcard-actions { padding: 6px 2%; }
    .action-btn { padding: 2px; }
}

/* Social-proof stats pill (bottom-left, shown in discovery mode) */
.postcard-stats {
    position: absolute;
    left: 8px; bottom: 8px;
    z-index: 3;
    display: none;
    gap: 8px; align-items: center;
    padding: 4px 10px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    transition: opacity .18s ease;
}
.postcard-stats .stat { display: inline-flex; align-items: center; gap: 4px; }
.postcard-stats .emoji-img { width: 14px; height: 14px; vertical-align: -2px; }
.postcard-stats .num { font-variant-numeric: tabular-nums; }

/* Discovery mode: columns 3 and up */
.grid:not([data-columns="1"]):not([data-columns="2"]) .postcard-stats { display: inline-flex; }
.grid:not([data-columns="1"]):not([data-columns="2"]) .postcard-actions { opacity: 0; pointer-events: none; }

/* Desktop hover in discovery mode: reveal actions, hide stats */
@media (hover: hover) {
    .grid:not([data-columns="1"]):not([data-columns="2"]) .postcard:hover .postcard-actions { opacity: 1; pointer-events: auto; }
    .grid:not([data-columns="1"]):not([data-columns="2"]) .postcard:hover .postcard-stats { opacity: 0; }
}

.react-glyph { display: inline-flex; align-items: center; justify-content: center; }
.react-glyph .emoji { font-size: 20px; line-height: 1; }
.emoji-img {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    display: inline-block;
    user-select: none;
}

/* Reaction picker popover */
.reaction-picker {
    position: fixed;
    z-index: 9999;
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(24,24,27,0.96);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: reaction-pop .22s cubic-bezier(.2,.9,.3,1.2);
    max-width: calc(100vw - 16px);
    transform-origin: bottom center;
}
.reaction-opt {
    background: transparent;
    border: none;
    padding: 4px 6px;
    font-size: 40px;
    line-height: 1;
    cursor: pointer;
    transition: transform .22s cubic-bezier(.2,.9,.3,1.2);
    will-change: transform;
}
@media (max-width: 640px) {
    .reaction-picker { gap: 4px; padding: 8px 10px; }
    .reaction-opt { padding: 3px 4px; font-size: 34px; }
}
.reaction-opt:hover,
.reaction-opt:focus-visible {
    transform: translateY(-6px) scale(1.18);
    outline: none;
}
@keyframes reaction-pop {
    0% { opacity: 0; transform: translateY(10px) scale(.88); }
    60% { opacity: 1; transform: translateY(-2px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.action-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: transparent; border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px;
    transition: transform .1s ease;
}
.action-btn:hover { transform: scale(1.1); }
.action-btn.liked { color: var(--like); }
.action-btn .count { min-width: 14px; text-align: left; color: #fff; }

/* Text-only postcards — hide the media wrap's gradient class; already on postcard */
.postcard-text .postcard-media { background: transparent; }

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed; inset: 0;
    z-index: 1000;
    align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* Fades as the dialog is swiped down. --drag-progress is 0..1, set by modal.js. */
    opacity: calc(1 - var(--drag-progress, 0) * 0.75);
}
.modal-dialog {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 1000px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 100px rgba(0,0,0,0.7);
}
.modal-close {
    position: absolute; top: 12px; right: 12px;
    background: rgba(0,0,0,0.6); color: #fff;
    border: none; border-radius: 50%;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
}
.modal-close:hover { background: rgba(0,0,0,0.85); }
.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.modal-loading { padding: 40px; text-align: center; color: var(--dim); }

/* Compose / share / report modals: let the padded inner div scroll when content is tall */
#compose-modal .modal-dialog > div,
#share-modal .modal-dialog > div,
#report-modal .modal-dialog > div {
    overflow-y: auto;
    max-height: 90vh;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
@media (max-width: 768px) {
    .modal { align-items: stretch; justify-content: stretch; }
    .modal-dialog {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
    }
    /* Sticky comment bar uses safe-area padding so it sits flush on iPhones with a home indicator */
    .modal-post-compose {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* Modal post layout — vertical single-column (Instagram-style) on all breakpoints */
.modal-post { display: flex; flex-direction: column; width: 100%; }
.modal-post-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-post-header .avatar-sm { width: 36px; height: 36px; }
.modal-post-header .meta { flex: 1; min-width: 0; }
.modal-post-header .meta .name { font-weight: 600; }
.modal-post-header .meta .handle { font-size: 12px; color: var(--dim); }
.modal-post-body { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-post-body h2 { margin: 0 0 8px; font-size: 18px; }
.modal-post-body p { margin: 0; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.modal-post-media {
    background: #000;
    display: flex; align-items: flex-start; justify-content: center;
}
.modal-post-media img,
.modal-post-media video {
    width: 100%;
    height: auto;
    display: block;
}
.modal-post-media .text-tile {
    width: 100%; min-height: 320px;
    padding: 40px;
}
.modal-post-actions { display: flex; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); }
.modal-post-actions .action-btn { color: var(--text); font-size: 14px; }
.modal-post-actions .action-btn.liked { color: var(--like); }
.modal-post-comments { padding: 12px 16px; }
.modal-post-compose { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--surface); }
.modal-post-compose input {
    flex: 1; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 999px;
    padding: 8px 14px; font-size: 14px;
}
.modal-post-compose input:focus { outline: none; border-color: var(--accent); }
.modal-post-compose button { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600; }

/* Narrower dialog for the post modal specifically (desktop only — mobile
 * always uses the full screen via the @media rule above). */
@media (min-width: 769px) {
    #post-modal .modal-dialog { max-width: 680px; }
}

/* Link preview tile inside the modal — give it real height, dark gradient
 * anchor at the bottom so the title is readable over any image. */
#post-modal .modal-post-media .link-tile {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 340px;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
#post-modal .modal-post-media .link-tile-image::before {
    height: 70%;
    background: linear-gradient(to top,
        rgba(0,0,0,0.92) 0%,
        rgba(0,0,0,0.75) 35%,
        rgba(0,0,0,0.25) 75%,
        rgba(0,0,0,0) 100%);
}
#post-modal .modal-post-media .link-tile-caption {
    padding: 20px 22px 22px;
    gap: 6px;
}
#post-modal .modal-post-media .link-tile-title {
    font-size: 1.25em;
    -webkit-line-clamp: 3;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
#post-modal .modal-post-media .link-tile-host {
    text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}
/* Text-only link tile in modal — give it breathing room */
#post-modal .modal-post-media .link-tile-text {
    min-height: 300px;
    padding: 36px 28px;
}

/* ---------- Comments ---------- */
.comment {
    display: flex; gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.comment .avatar-sm { width: 30px; height: 30px; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.comment-head .name { font-weight: 600; }
.comment-head .time { color: var(--dim); font-size: 11px; }
.comment-head { position: relative; }
.comment-head { padding-right: 24px; }
.comment-menu-btn {
    position: absolute; right: 0; top: -2px;
    background: none; border: none; color: var(--dim);
    padding: 2px 4px; cursor: pointer; line-height: 0;
    border-radius: 4px;
}
.comment-menu-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.comment-text { font-size: 13px; line-height: 1.4; margin: 2px 0 6px; word-wrap: break-word; }
.comment-actions { display: flex; gap: 10px; font-size: 11px; color: var(--dim); }
.comment-actions button { background: none; border: none; color: var(--dim); padding: 0; font-size: 11px; }
.comment-actions button:hover { color: var(--text); }
.comment-actions .action-btn-sm { display: inline-flex; align-items: center; gap: 3px; padding: 2px 4px; color: var(--dim); }
.comment-actions .action-btn-sm.liked { color: var(--accent); }
.comment-actions .action-btn-sm .emoji { font-size: 14px; line-height: 1; }
.comment-actions .action-btn-sm .count { font-size: 11px; }
.comment-edit-form textarea {
    width: 100%; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font-family: inherit; font-size: 13px; line-height: 1.4; resize: vertical;
    box-sizing: border-box;
}
.comment-edit-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.comment-edit-actions .btn { padding: 4px 10px; font-size: 12px; }
.comment-replies { margin-left: 40px; }
.comment[data-depth="3"] + .comment-replies, .comment-replies .comment-replies .comment-replies { margin-left: 0; }

/* ---------- Forms / Auth ---------- */
.auth-container { max-width: 400px; margin: 48px auto; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.auth-container h1 { margin: 0 0 8px; font-size: 24px; }
.auth-container .subtitle { color: var(--dim); margin: 0 0 24px; font-size: 14px; }
.auth-form, .compose-form, .settings-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label, .compose-form label, .settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.auth-form label > span, .compose-form label > span, .settings-form label > span { color: var(--text); font-size: 13px; font-weight: 500; }
.auth-form input, .compose-form input, .compose-form textarea, .settings-form input, .settings-form textarea, .settings-form select {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.auth-form input:focus, .compose-form input:focus, .compose-form textarea:focus, .settings-form input:focus, .settings-form textarea:focus {
    outline: none; border-color: var(--accent);
}
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border-radius: 10px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: rgba(255,255,255,0.2); }
.btn-danger { background: var(--like); color: #fff; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.auth-footer { text-align: center; margin-top: 18px; color: var(--dim); font-size: 13px; }

/* Password strength meter */
.pw-meter {
    height: 4px; border-radius: 2px; background: rgba(255,255,255,0.08);
    overflow: hidden; margin-top: 6px;
}
.pw-meter > span {
    display: block; height: 100%; width: 0%;
    background: #ff4e6b; transition: width 0.2s, background 0.2s;
}
.pw-meter[data-strength="1"] > span { width: 25%; background: #ff4e6b; }
.pw-meter[data-strength="2"] > span { width: 50%; background: #ffa54a; }
.pw-meter[data-strength="3"] > span { width: 75%; background: #f5d543; }
.pw-meter[data-strength="4"] > span { width: 100%; background: #4aff8c; }
.pw-match-ok { color: #4aff8c; }
.pw-match-bad { color: #ff8098; }

/* ---------- Compose link preview card ---------- */
.compose-link-preview {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel, rgba(255,255,255,0.04));
}
.compose-link-preview .clp-image {
    width: 100%;
    aspect-ratio: 1.91 / 1;
    background-size: cover;
    background-position: center;
    background-color: rgba(255,255,255,0.05);
}
.compose-link-preview .clp-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.compose-link-preview .clp-host {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--dim);
}
.compose-link-preview .clp-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.compose-link-preview .clp-desc {
    margin: 0;
    font-size: 13px;
    color: var(--dim);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.compose-link-preview .clp-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.compose-link-preview .clp-close:hover { background: rgba(0,0,0,0.85); }

/* ---------- Compose upload preview (background image upload) ---------- */
.compose-upload-preview {
    position: relative;
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2);
    max-height: 320px;
}
.compose-upload-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    transition: opacity 0.25s ease;
}
.compose-upload-preview.uploading img { opacity: 0.55; }
.compose-upload-progress {
    position: absolute;
    left: 0; bottom: 0;
    height: 2px;
    width: 0%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(74, 124, 255, 0.55);
    transition: width 0.18s ease-out;
    pointer-events: none;
}
.compose-upload-preview:not(.uploading) .compose-upload-progress {
    opacity: 0;
    transition: opacity 0.4s 0.15s;
}
.compose-upload-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.compose-upload-remove:hover { background: rgba(0, 0, 0, 0.85); }

/* ---------- Follows list ---------- */
.follows-container { max-width: 720px; margin: 0 auto; padding: 20px; }
.profile-stat-link { color: inherit; text-decoration: none; cursor: pointer; }
.profile-stat-link:hover strong { text-decoration: underline; }
.follows-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.follows-tab {
    padding: 10px 18px; color: var(--dim); text-decoration: none;
    border-bottom: 2px solid transparent; font-weight: 500; font-size: 14px;
}
.follows-tab:hover { color: var(--text); }
.follows-tab.is-active { color: var(--text); border-bottom-color: var(--accent, #4a9eff); }
.follows-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.follows-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    border-radius: 10px; transition: background 0.15s;
}
.follows-item:hover { background: rgba(255,255,255,0.03); }
.follows-user { display: flex; align-items: center; gap: 12px; flex: 1; text-decoration: none; color: inherit; min-width: 0; }
.follows-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.follows-meta { display: flex; flex-direction: column; min-width: 0; }
.follows-name { font-weight: 600; color: var(--text); font-size: 15px; }
.follows-handle { color: var(--dim); font-size: 13px; }
.follows-bio { color: var(--dim); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follows-item .follow-btn { flex-shrink: 0; }
.follows-empty { color: var(--dim); text-align: center; padding: 40px 20px; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 13px; }
.alert-error { background: rgba(255,59,92,0.15); color: #ff8098; border: 1px solid rgba(255,59,92,0.3); }
.alert-success { background: rgba(74,255,145,0.1); color: #6eff9e; border: 1px solid rgba(74,255,145,0.3); }

small { color: var(--dim); font-weight: 400; }

/* ---------- Pages ---------- */
.page-title { font-size: 22px; margin: 24px 20px 16px; }
.compose-container, .settings-container { max-width: 720px; margin: 0 auto; padding: 24px 20px; }

/* Profile */
.profile-head-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
}
.profile-cover {
    width: 100%;
    height: 400px;
    overflow: hidden;
    background: var(--surface-2);
    border-radius: 0 0 12px 12px;
}
.profile-cover img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    display: block;
}
.avatar-lg {
    width: 160px; height: 160px;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 50%;
    background: var(--surface-2);
    flex-shrink: 0;
}
.profile-header {
    display: flex; align-items: center; gap: 24px;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}
.profile-header.has-cover {
    margin-top: -60px;
    padding-top: 0;
    align-items: flex-end;
    position: relative;
}
.profile-header.has-cover .avatar-lg {
    border: 4px solid var(--bg);
    background: var(--bg);
}

/* Settings — profile image pickers */
.settings-media-row { display: flex; gap: 16px; flex-wrap: wrap; }
.settings-media-item { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.settings-media-item .settings-label { font-size: 13px; font-weight: 500; color: var(--text); }
.settings-media-cover { flex: 1; min-width: 220px; }
.settings-avatar-preview {
    width: 140px; height: 140px; border-radius: 50%; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
}
.settings-avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.settings-cover-preview {
    width: 100%; max-width: 540px; aspect-ratio: 2.7 / 1;
    border-radius: 10px; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}
.settings-cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.settings-cover-empty { color: var(--dim); font-size: 13px; }
.profile-avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.profile-info { flex: 1; }
.profile-info h1 { margin: 0 0 4px; font-size: 26px; }
.profile-handle { color: var(--dim); font-size: 14px; margin: 0 0 12px; }
.profile-bio { margin: 0 0 16px; color: var(--text); line-height: 1.4; max-width: 600px; }
.profile-stats { display: flex; gap: 24px; margin-bottom: 12px; }
.profile-stats .stat { font-size: 14px; }
.profile-stats .stat strong { font-size: 18px; display: block; }
.profile-stats .stat span { color: var(--dim); font-size: 12px; }
.profile-actions { display: flex; gap: 8px; }

@media (max-width: 640px) {
    .profile-head-wrap { padding: 0 12px; }
    .profile-cover { height: 200px; }
    .profile-header { flex-direction: column; align-items: flex-start; text-align: left; padding: 16px 0; gap: 16px; }
    .profile-header.has-cover { margin-top: -48px; }
    .avatar-lg { width: 110px; height: 110px; }
    .profile-avatar { width: 80px; height: 80px; }
}

/* Reposition widget (settings photo previews) */
.photo-reposition {
    position: relative;
    cursor: grab;
    user-select: none;
    touch-action: none;
}
.photo-reposition.dragging { cursor: grabbing; }
.photo-reposition img { pointer-events: none; }
.photo-reposition-hint {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}
.photo-reposition:hover .photo-reposition-hint,
.photo-reposition.show-hint .photo-reposition-hint { opacity: 1; }
.photo-reposition.dragging .photo-reposition-hint { opacity: 0; }

/* Notifications dropdown (topbar) */
.notif-dropdown-inner { padding: 0; min-width: 340px; max-width: 380px; }
.notif-dropdown-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.notif-dropdown-list { max-height: 420px; overflow-y: auto; }
.notif-loading, .notif-empty { padding: 20px; text-align: center; color: var(--dim); font-size: 13px; }
.notif-dropdown-list .notif-item {
    display: flex; gap: 10px; align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px; color: var(--text); text-decoration: none;
}
.notif-dropdown-list .notif-item:hover { background: rgba(255,255,255,0.04); }
.notif-dropdown-list .notif-item.unread { background: rgba(94,106,210,0.08); }
.notif-dropdown-list .notif-item.unread::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.notif-dropdown-list .avatar-sm { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; object-fit: cover; }
.notif-text { flex: 1; min-width: 0; line-height: 1.35; }
.notif-name { font-weight: 600; }
.notif-time { color: var(--dim); font-size: 11px; }
.notif-dropdown-foot { padding: 10px 14px; text-align: center; border-top: 1px solid var(--border); }
.notif-dropdown-foot a { color: var(--accent); font-size: 13px; text-decoration: none; }
.notif-dropdown-foot a:hover { text-decoration: underline; }

/* Notifications modal — dropdown style, larger scale */
.notifications-modal-dialog { max-width: 560px; width: 90%; max-height: 80vh; }
.notifications-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    flex: 0 0 auto;
}
.notifications-modal-head strong { font-size: 17px; }
.notifications-modal-body {
    padding: 4px 0;
    /* inherits flex:1 + overflow-y:auto from .modal-body */
}
.notif-modal-item {
    display: flex; gap: 14px; align-items: center;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    color: var(--text); text-decoration: none;
    transition: background .12s ease;
    position: relative;
}
.notif-modal-item:hover { background: rgba(255,255,255,0.03); }
.notif-modal-item:last-child { border-bottom: 0; }
.notif-modal-item.unread { background: rgba(94,106,210,0.07); }
.notif-modal-item.unread::before {
    content: '';
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.notif-modal-item .avatar-md {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 50%; object-fit: cover;
}
.notif-modal-text { flex: 1; min-width: 0; line-height: 1.35; }
.notif-modal-line { font-size: 14.5px; color: var(--text); word-wrap: break-word; }
.notif-modal-line .notif-name { font-weight: 600; }
.notif-modal-time {
    margin-top: 2px;
    font-size: 12px;
    color: var(--dim);
}
@media (max-width: 768px) {
    .notifications-modal-dialog { max-width: 100%; }
    .notifications-modal-head { padding: 16px 18px; }
    .notif-modal-item { padding: 14px 18px; gap: 12px; }
    .notif-modal-item .avatar-md { width: 40px; height: 40px; }
    .notif-modal-line { font-size: 14px; }
}

/* Search / user list */
.user-list { display: flex; flex-direction: column; gap: 4px; padding: 0 20px; max-width: 720px; margin: 16px auto; }
.user-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.user-list-item .avatar-sm { width: 40px; height: 40px; }
.user-list-item .meta { flex: 1; }
.user-list-item .meta .name { font-weight: 600; }
.user-list-item .meta .handle { font-size: 12px; color: var(--dim); }

.section-title { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; margin: 24px 20px 8px; }

/* Empty states */
.empty-state { text-align: center; padding: 60px 20px; color: var(--dim); }
.empty-state h2 { color: var(--text); margin: 0 0 8px; }
.empty-state p { margin: 0 0 16px; }
.empty-state .empty-icon { font-size: 40px; line-height: 1; margin-bottom: 12px; opacity: 0.6; }

.char-counter {
    display: block;
    text-align: right;
    font-size: 12px;
    color: var(--dim);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.char-counter.near { color: #d89b2d; }
.char-counter.over { color: #e34c4c; font-weight: 600; }

#feed-sentinel {
    padding: 24px 0 48px;
    text-align: center;
}
.feed-more-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 28px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.feed-more-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.feed-more-btn:disabled { opacity: 0.5; cursor: default; }
#feed-sentinel.done .feed-more-btn { background: transparent; border-color: transparent; color: var(--dim); }

/* ---------- Admin ---------- */
.admin-layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.admin-sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    flex-shrink: 0;
}
.admin-sidebar h2 { margin: 0 20px 16px; font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.admin-sidebar a {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text);
    border-left: 3px solid transparent;
}
.admin-sidebar a:hover { background: rgba(255,255,255,0.04); }
.admin-sidebar a.active { border-left-color: var(--accent); background: rgba(74,124,255,0.08); color: var(--accent); }
.admin-content { flex: 1; padding: 24px; overflow-x: auto; }
.admin-content h1 { margin: 0 0 20px; font-size: 22px; }

.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.admin-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.admin-stat-card .label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.admin-stat-card .value { font-size: 28px; font-weight: 700; margin-top: 8px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.admin-table th { background: var(--surface-2); color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.admin-table tr:last-child td { border-bottom: none; }

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; padding: 8px; }
    .admin-sidebar h2 { display: none; }
    .admin-sidebar a { padding: 8px 12px; border-left: none; border-bottom: 2px solid transparent; }
    .admin-sidebar a.active { border-left: none; border-bottom-color: var(--accent); }
}

/* ---------- Inline links in content ---------- */
.hashtag, .mention { color: var(--accent); }
.hashtag:hover, .mention:hover { text-decoration: underline; }

/* ---------- Scroll lock ---------- */
body.modal-open { overflow: hidden; }

/* ---------- Groups ---------- */
.groups-page { max-width: 1200px; margin: 0 auto; padding: 24px; }
.groups-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.groups-search { display: flex; gap: 8px; margin-bottom: 24px; }
.groups-search .search-input { flex: 1; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); }
.groups-section { margin-bottom: 32px; }
.groups-feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.group-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--fg); transition: transform .12s ease, border-color .12s ease; }
.group-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.group-card-cover { height: 100px; background-size: cover; background-position: center; background-color: #222; }
.group-card-cover-empty { background-image: linear-gradient(135deg, #7c3aed, #06b6d4); }
.group-card-body { padding: 14px; }
.group-card-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.group-card-desc { color: var(--dim); font-size: 13px; line-height: 1.4; margin-bottom: 10px; max-height: 3.2em; overflow: hidden; }
.group-card-meta { color: var(--dim); font-size: 12px; }
.group-badge { font-size: 12px; color: var(--dim); font-weight: 400; }

.group-view { max-width: 1200px; margin: 0 auto; }
.group-header { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin: 16px; }
.group-cover { height: 180px; background-size: cover; background-position: center; background-color: #222; }
.group-cover-empty { background-image: linear-gradient(135deg, #7c3aed, #06b6d4); }
.group-header-body { padding: 20px; }
.group-name { margin: 0 0 8px; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.group-desc { color: var(--dim); margin: 0 0 12px; line-height: 1.5; }
.group-meta { color: var(--dim); font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; }
.group-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- In-context thread view (post rendered inside group shell) ---------- */
.group-thread-view { max-width: 1200px; margin: 0 auto; }
.group-header-compact { margin: 16px 16px 0; border-radius: 14px 14px 0 0; border-bottom: none; }
.group-cover-compact { height: 90px; }
.group-header-body-compact { padding: 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.group-thread-breadcrumb { font-size: 13px; color: var(--dim); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.group-thread-breadcrumb a { color: var(--accent); text-decoration: none; }
.group-thread-breadcrumb a:hover { text-decoration: underline; }
.group-thread-breadcrumb .sep { color: var(--dim); }
.compose-container.in-group {
    max-width: none;
    margin: 0 16px; padding: 20px 24px;
    border-top-left-radius: 0; border-top-right-radius: 0;
    border-top: 1px solid var(--border);
}
.group-thread-footer { margin: 14px 16px 24px; display: flex; justify-content: flex-start; }

/* ---------- Post page media: constrained size, text wraps around image/video ---------- */
.post-media-image, .post-media-video { max-width: 450px; width: 100%; border-radius: 12px; display: block; margin: 0 0 16px; }
.post-media-float { float: left; margin: 4px 20px 12px 0; }
.post-body-text { line-height: 1.6; margin-bottom: 16px; word-wrap: break-word; }
@media (max-width: 640px) {
    .post-media-float { float: none; margin: 0 0 16px; max-width: 100%; }
}

/* ---------- Post page (full) comments — same look & feel as modal, sized for full width ---------- */
.post-comments-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; flex-wrap: wrap; }
.post-comments-head-left { display: flex; align-items: center; gap: 12px; }
.post-compose-cancel { background: none; border: 0; color: var(--dim); font-size: 20px; line-height: 1; padding: 0 6px; cursor: pointer; }
.post-compose-cancel:hover { color: var(--text); }
/* Inline reply form sits neatly beneath the comment it replies to */
.comment-body > .post-page-compose { margin-top: 8px; border-top: 0; padding: 0; }
.post-page-comments { padding: 0; overflow: visible; }
.post-page-comments .comment { padding: 12px 0; gap: 12px; }
.post-page-comments .comment .avatar-sm { width: 36px; height: 36px; }
.post-page-comments .comment-head { font-size: 14px; }
.post-page-comments .comment-head .time { font-size: 12px; }
.post-page-comments .comment-text { font-size: 14px; line-height: 1.5; margin: 4px 0 8px; }
.post-page-comments .comment-actions { font-size: 12px; gap: 14px; }
.post-page-comments .comment-replies { margin-left: 48px; }
/* Depth-3 cap for group posts: keep deeper nests flat at level 2 */
.post-page-comments .comment[data-depth="2"] + .comment-replies,
.post-page-comments .comment-replies .comment-replies .comment-replies { margin-left: 0; }

.post-page-compose { padding: 12px 0; border-top: 1px solid var(--border); margin-top: 8px; }
.post-page-compose input { padding: 10px 16px; font-size: 14px; }
.post-page-compose button { padding: 10px 20px; font-size: 14px; }

.post-reply-to {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(124, 58, 237, 0.12); color: var(--accent);
    padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
    margin: 12px 0 -4px;
}
.post-reply-to .post-reply-cancel {
    background: none; border: 0; color: inherit; font-size: 16px; line-height: 1;
    cursor: pointer; padding: 0 2px;
}
@media (max-width: 640px) {
    .group-cover-compact { height: 70px; }
    .group-header-body-compact { padding: 10px 14px; }
    .compose-container.in-group { margin: 0 8px; }
    .group-header-compact { margin: 8px 8px 0; }
    .group-thread-footer { margin: 12px 8px 20px; }
}

.postcard-group {
    position: absolute; top: 8px; right: 44px;
    background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
    color: #fff; text-decoration: none;
    font-size: 11px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
    max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    z-index: 3;
}
.postcard-group:hover { background: rgba(0,0,0,.75); }

.compose-group-chip {
    display: inline-block; background: var(--accent); color: #fff;
    padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
    margin-bottom: 8px;
    align-self: flex-start;
}
.compose-group-chip[hidden] { display: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.muted-badge { font-size: 11px; color: var(--dim); padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.05); margin-right: 4px; }

/* ---------- Legal stub pages (Terms / Privacy) ---------- */
.legal-page { max-width: 760px; line-height: 1.6; }
.legal-page h1 { margin: 0 0 4px; }
.legal-page h2 { margin-top: 28px; margin-bottom: 8px; font-size: 18px; }
.legal-page p, .legal-page ul { margin: 8px 0; }
.legal-page ul { padding-left: 22px; }
.legal-page .legal-meta { color: var(--dim); font-size: 13px; margin-bottom: 24px; }
.legal-page a { color: var(--accent); }

/* ---------- Site footer ---------- */
.site-footer {
    max-width: 1200px; margin: 32px auto 24px; padding: 16px 20px;
    color: var(--dim); font-size: 12px;
    display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
    border-top: 1px solid var(--border);
}
.site-footer a { color: var(--dim); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer .sep { opacity: .5; }

.auth-legal { margin-top: 14px; font-size: 12px; color: var(--dim); text-align: center; }
.auth-legal a { color: var(--accent); }

/* ---------- Error page ---------- */
.error-page {
    max-width: 520px;
    margin: 64px auto;
    padding: 48px 24px;
    text-align: center;
}
.error-code {
    font-size: 96px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    color: var(--accent);
    margin-bottom: 8px;
}
.error-title {
    font-size: 24px;
    margin: 0 0 12px;
}
.error-message {
    color: var(--dim);
    line-height: 1.6;
    margin: 0 0 28px;
}
.error-actions {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
@media (max-width: 640px) {
    .error-page { margin: 32px auto; padding: 32px 16px; }
    .error-code { font-size: 72px; }
}

/* ---------- View toggle (grid / thread) ---------- */
.view-toggle { display: inline-flex; gap: 4px; margin: 0 16px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.view-toggle-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px;
    color: var(--dim); text-decoration: none;
    font-size: 13px; font-weight: 600;
    transition: all .12s ease;
}
.view-toggle-btn:hover { color: var(--fg); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }

/* ---------- Thread list (forum-style) ---------- */
.thread-list { display: flex; flex-direction: column; gap: 1px; margin: 0 16px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.thread-row {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 14px 16px;
    background: var(--surface);
    transition: background-color .12s ease;
    cursor: pointer;
}
.thread-row:hover { background: rgba(124, 58, 237, 0.06); }
.thread-row-avatar { flex-shrink: 0; }
.thread-row-avatar img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; display: block; }
.thread-row-body { flex: 1; min-width: 0; }
.thread-row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; font-size: 13px; }
.thread-row-user { color: var(--fg); text-decoration: none; font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.thread-row-user:hover { color: var(--accent); }
.thread-row-handle { color: var(--dim); font-weight: 400; font-size: 12px; }
.thread-row-time { color: var(--dim); font-size: 12px; margin-left: auto; }
.thread-row-title {
    display: block; color: var(--fg); text-decoration: none;
    font-size: 16px; font-weight: 600; line-height: 1.3;
    margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.thread-row-title:hover { color: var(--accent); }
.thread-row-excerpt { color: var(--dim); font-size: 13px; line-height: 1.45; margin-bottom: 6px;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread-row-meta { display: flex; gap: 14px; color: var(--dim); font-size: 12px; }
.thread-row-thumb {
    flex-shrink: 0; width: 100px; height: 70px;
    border-radius: 8px; background-size: cover; background-position: center;
    background-color: #222;
}

@media (max-width: 640px) {
    .thread-row-thumb { width: 64px; height: 48px; }
    .thread-row { padding: 12px; }
    .thread-row-avatar img { width: 34px; height: 34px; }
    .thread-row-time { margin-left: 0; font-size: 11px; }
}
