/* Connecta design tokens. Dark is the brand default; light follows the device setting. */
:root {
    --bg: #0b0b0d;
    --surface: #141417;
    --surface-2: #1b1b1f;
    --surface-3: #24242a;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #f4f1ea;
    --text-2: #a9a49a;
    --text-3: #77736b;
    --accent: #e0b15a;
    --accent-hover: #ebbf6c;
    --accent-ink: #1a1408;
    --accent-soft: rgba(224, 177, 90, .14);
    --like: #f4506b;
    --repost: #34c38f;
    --danger: #f06a5a;
    --danger-soft: rgba(240, 106, 90, .12);
    --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 12px 40px rgba(0, 0, 0, .45);
    --sk: rgba(255, 255, 255, .06);
    --sk-shine: rgba(255, 255, 255, .1);
    --bar-bg: rgba(11, 11, 13, .82);
    --radius-s: 10px;
    --radius: 14px;
    --radius-l: 20px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Inter, Arial, sans-serif;
    --serif: Palatino, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --tabs-h: 60px;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f5f2;
        --surface: #ffffff;
        --surface-2: #f2f0ec;
        --surface-3: #e8e5df;
        --border: rgba(20, 16, 8, .09);
        --border-strong: rgba(20, 16, 8, .18);
        --text: #16140f;
        --text-2: #5f5a50;
        --text-3: #8d877b;
        --accent: #b9852a;
        --accent-hover: #a57524;
        --accent-ink: #ffffff;
        --accent-soft: rgba(185, 133, 42, .12);
        --like: #e0244a;
        --repost: #149a68;
        --danger: #d1402f;
        --danger-soft: rgba(209, 64, 47, .08);
        --scrim: rgba(20, 16, 8, .45);
        --shadow: 0 12px 40px rgba(20, 16, 8, .16);
        --sk: rgba(20, 16, 8, .06);
        --sk-shine: rgba(20, 16, 8, .1);
        --bar-bg: rgba(255, 255, 255, .86);
        color-scheme: light;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; overflow-x: clip; }
body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: clip;
    overflow-wrap: break-word;
}
body.locked { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ico { display: block; flex: none; }
.muted { color: var(--text-2); }
.fine { color: var(--text-3); font-size: 12px; line-height: 1.5; }
.center { text-align: center; }
.mobile-only { display: initial; }
.desktop-only { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 650;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; min-height: 48px; }
.btn.icon-only { padding: 0; width: 40px; }
.icon-btn {
    width: 40px;
    height: 40px;
    flex: none;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: background .15s;
}
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.glass { background: rgba(0, 0, 0, .4); border: 0; color: #fff; backdrop-filter: blur(8px); }
.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.row-actions.tight { margin: 0; gap: 8px; }
.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    display: inline-block;
    animation: spin .7s linear infinite;
    opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Brand ---------- */
.wordmark {
    font-family: var(--serif);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.03em;
    color: var(--text);
    text-decoration: none;
}
.wordmark.light { color: #fff; font-size: 44px; }

/* ---------- App layout ---------- */
.layout { min-height: 100dvh; }
.rail, .side { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 56px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    background: var(--bar-bg);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); }
.topbar .wordmark { flex: 1; }
.topbar > span:empty { width: 40px; flex: none; }
.content { min-height: 50vh; }
.layout.no-tabs .main { padding-bottom: 16px; }
body.typing .tabs { display: none; }
body.typing .main { padding-bottom: 16px; }

.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    background: var(--bar-bg);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
}
.tabs a {
    display: grid;
    justify-items: center;
    gap: 2px;
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
}
.tabs a.on { color: var(--text); }
.tabs a.on .ico { stroke-width: 2.4; }
.tabs .tab-create {
    width: 48px;
    height: 36px;
    margin: 0 auto;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
}

.guest-shell .main { padding-bottom: 40px; }
.guest-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--bar-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.main.solo { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }

@media (min-width: 700px) {
    .mobile-only { display: none !important; }
    .desktop-only { display: initial !important; }
    .tabs { display: none; }
    .layout { display: grid; grid-template-columns: 76px minmax(0, 620px); justify-content: center; }
    .main { padding-bottom: 40px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 100dvh; }
    .rail {
        position: sticky;
        top: 0;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 16px 10px;
    }
    .rail .wordmark { display: none; }
    .rail-mark img { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 12px; }
    .rail-nav { display: grid; gap: 4px; }
    .rail-link {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 12px;
        border-radius: 999px;
        color: var(--text-2);
        text-decoration: none;
        font-size: 17px;
        transition: background .15s, color .15s;
    }
    .rail-link:hover { background: var(--surface-2); color: var(--text); }
    .rail-link.on { color: var(--text); font-weight: 700; }
    .rail-link.on .ico { stroke-width: 2.4; }
    .rail-link span, .rail-create span, .rail-me span { display: none; }
    .rail-create { width: 52px; height: 52px; padding: 0; margin-top: 12px; }
    .rail-me { margin-top: auto; padding: 6px; border-radius: 999px; text-decoration: none; }
    .rail-me:hover { background: var(--surface-2); }
    .topbar { padding: 8px 16px; }
}

@media (min-width: 1100px) {
    .layout { grid-template-columns: 250px minmax(0, 620px) 330px; }
    .layout.wide { grid-template-columns: 250px minmax(0, 620px) 330px; }
    .rail { align-items: stretch; padding: 16px 20px; }
    .rail .wordmark { display: block; padding: 4px 12px 16px; }
    .rail-mark { display: none; }
    .rail-link span, .rail-create span { display: inline; }
    .rail-create { width: auto; height: 50px; padding: 0 18px; }
    .rail-me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
    .rail-me span { display: grid; min-width: 0; }
    .rail-me strong, .rail-me small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .rail-me small { color: var(--text-2); }
    .side { display: block; position: sticky; top: 0; align-self: start; padding: 16px 20px; max-height: 100dvh; overflow: auto; }
    #stories { display: none; }
}

/* ---------- Panels & lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 16px 16px 8px; margin-bottom: 16px; }
.panel h2 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.panel .person { padding: 10px 0; border: 0; }
.panel-more { display: block; padding: 10px 0 8px; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; }
.section-title { font-size: 17px; font-weight: 800; padding: 18px 16px 8px; }
.block + .block { border-top: 1px solid var(--border); }
.list { display: grid; }
.person, .chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
}
.chat-row:hover { background: var(--surface); }
.person.compact { padding: 8px 0; border: 0; }
.who { flex: 1; min-width: 0; display: grid; gap: 1px; }
.who .name-link, .who .name { min-width: 0; }
.name { font-weight: 700; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.name-link { text-decoration: none; color: inherit; overflow: hidden; }
.name-link:hover .name { text-decoration: underline; }
.meta { color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta a { text-decoration: none; }
.meta a:hover { text-decoration: underline; }
.clip { display: block; }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.verified { color: var(--accent); display: inline-grid; flex: none; }
.verified .ico { fill: var(--accent); stroke: var(--bg); }

.avatar {
    position: relative;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #3a2c14, #6b4e1f);
    color: #f6e2b8;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .02em;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }

.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty .ico { color: var(--text-3); margin-bottom: 4px; }
.empty h3 { color: var(--text); font-size: 18px; }
.empty p { max-width: 320px; }
.empty .btn { margin-top: 8px; }

/* ---------- Skeletons ---------- */
.sk {
    display: block;
    background: linear-gradient(90deg, var(--sk) 0%, var(--sk-shine) 50%, var(--sk) 100%);
    background-size: 200% 100%;
    animation: shine 1.2s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-circle { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk-circle.sm { width: 34px; height: 34px; }
.sk-circle.xl { width: 96px; height: 96px; margin: -48px 0 12px 16px; border: 4px solid var(--bg); box-sizing: content-box; }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk-line { height: 12px; margin: 6px 0; }
.w25 { width: 25%; } .w40 { width: 40%; } .w70 { width: 70%; } .w90 { width: 90%; }
.sk-media { height: 260px; border-radius: var(--radius); margin-top: 10px; }
.sk-cover { height: 150px; border-radius: 0; }
.skeleton-post .sk-line { margin-left: 0; }
.profile-skeleton { display: grid; }
.profile-skeleton .sk-line { margin: 8px 16px; }

/* ---------- Feed ---------- */
.prompt { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.prompt-input {
    flex: 1;
    text-align: left;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-3);
}
.prompt-input:hover { border-color: var(--border-strong); }
.prompt-input { min-width: 0; }
.prompt-input span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stories { display: flex; gap: 14px; overflow-x: auto; padding: 14px 16px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.stories::-webkit-scrollbar { display: none; }
.story { width: 68px; flex: none; display: grid; justify-items: center; gap: 6px; text-decoration: none; }
.story .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.story small { font-size: 12px; color: var(--text-2); max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.post { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.post-note { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; margin: 0 0 8px 54px; }
.post-note.promoted { color: var(--accent); }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-head .who { line-height: 1.3; }
.post-head > .icon-btn { margin-right: -8px; color: var(--text-2); }
.post-body { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.5; }
.post-body a, .bio a, .c-bubble p a, .reel-info a, .bubble a { color: var(--accent); text-decoration: none; }
.post-body a:hover, .bio a:hover { text-decoration: underline; }
.post-body.clamped { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn.more { margin-top: 4px; font-size: 14px; }
.frame { touch-action: manipulation; position: relative; margin-top: 12px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); user-select: none; }
.frame.single img.media { width: 100%; max-height: 640px; object-fit: cover; }
.frame video.media { width: 100%; max-height: 640px; background: #000; }
.frame audio.media { width: 100%; margin: 12px 0; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { position: relative; flex: 0 0 100%; aspect-ratio: 4 / 5; scroll-snap-align: start; background: #000; }
.slide .media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pager { position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; font-weight: 700; }
.dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .5); transition: background .2s, transform .2s; }
.dots span.on { background: #fff; transform: scale(1.2); }
.heart-pop { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; pointer-events: none; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .4)); animation: pop .8s ease forwards; }
.heart-pop .ico { fill: #fff; }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 25% { transform: scale(1.1); opacity: 1; } 45% { transform: scale(.95); } 100% { transform: scale(1); opacity: 0; } }

.post-actions { display: flex; align-items: center; gap: 4px; margin: 8px -8px 0; }
.act {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 40px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--text-2);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    transition: color .15s, background .15s;
}
.act:hover { background: var(--surface-2); color: var(--text); }
.act.like:hover, .act.like.on { color: var(--like); }
.act.like.on .ico { fill: currentColor; animation: beat .3s ease; }
.act.repost:hover, .act.repost.on { color: var(--repost); }
@keyframes beat { 50% { transform: scale(1.25); } }
.views { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); font-size: 13px; padding-right: 8px; }
.boost-line { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 6px 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; }
.sentinel { display: grid; place-items: center; padding: 24px; color: var(--text-2); }

/* ---------- Upload banner ---------- */
.upload {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 16px 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    animation: drop-in .25s ease;
}
.upload.done { border-color: color-mix(in srgb, var(--repost) 50%, transparent); }
.upload.failed { border-color: color-mix(in srgb, var(--danger) 60%, transparent); background: var(--danger-soft); }
.up-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.up-text { flex: 1; min-width: 0; display: grid; gap: 6px; font-size: 14px; }
.up-text strong { font-weight: 600; }
.bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s; }
.up-actions { display: flex; align-items: center; gap: 12px; }
@keyframes drop-in { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- Composer ---------- */
.composer-card { padding: 16px; display: grid; gap: 12px; }
.composer-card.dragging { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: var(--radius); }
.composer-head { display: flex; align-items: center; gap: 12px; }
.composer-head > div { display: grid; gap: 3px; justify-items: start; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--accent); }
.composer-card textarea {
    width: 100%;
    min-height: 120px;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    font-size: 18px;
    line-height: 1.45;
}
.composer-card textarea::placeholder { color: var(--text-3); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; display: grid; place-items: center; padding: 0; }
.thumb.add { display: grid; place-items: center; border: 1.5px dashed var(--border-strong); background: transparent; color: var(--text-2); cursor: pointer; }
.thumb.add:hover { border-color: var(--accent); color: var(--accent); }
.composer-tools { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }
.tool { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; margin-left: -12px; border-radius: 999px; color: var(--accent); font-weight: 600; cursor: pointer; }
.tool:hover { background: var(--accent-soft); }
.counter { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--danger); }
.hint { color: var(--text-3); font-size: 12.5px; }

/* ---------- Explore ---------- */
.search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 6px 0 14px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid transparent;
    color: var(--text-2);
}
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.tile { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--surface-2); display: block; text-decoration: none; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.tile:hover img, .tile:hover video { transform: scale(1.04); }
.tile-text { position: absolute; inset: 0; padding: 10px; font-size: 13px; line-height: 1.35; color: var(--text-2); overflow: hidden; }
.tile-mark { position: absolute; top: 6px; right: 6px; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6)); }
.tile-stats { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.tile-stats .ico { fill: #fff; }
.tile.sk { border-radius: 0; }

/* ---------- Profile ---------- */
.cover { height: 150px; background: linear-gradient(120deg, #2a1f0d 0%, #6b4e1f 45%, #e0b15a 100%); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 16px; margin-top: -48px; }
.profile-head > .avatar, .avatar-pick .avatar { box-shadow: 0 0 0 4px var(--bg); }
.avatar-pick { position: relative; display: inline-grid; cursor: pointer; border-radius: 50%; }
.avatar-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cam { position: absolute; right: 2px; bottom: 2px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--bg); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-bottom: 4px; }
.profile-actions .btn { min-height: 36px; padding: 0 14px; font-size: 14px; }
.profile-actions .btn.icon-only { width: 36px; padding: 0; }
.profile-id { padding: 12px 16px 4px; display: grid; gap: 8px; }
.profile-id h1 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.handle { color: var(--text-2); margin-top: -6px; }
.bio { white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 14px; }
.facts li { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; }
.facts a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts a { color: var(--accent); text-decoration: none; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--text-2); }
.stats a, .stats span { text-decoration: none; }
.stats a:hover { text-decoration: underline; }
.stats strong { color: var(--text); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.profile .chip { font-size: 13px; padding: 4px 12px; }
.verify-card { display: flex; align-items: center; gap: 12px; margin: 12px 16px 4px; padding: 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }
.verify-card > div { flex: 1; color: var(--text); }
.verify-card p { color: var(--text-2); font-size: 13.5px; }
.profile-tabs { display: flex; margin-top: 12px; border-bottom: 1px solid var(--border); }
.profile-tabs span { flex: 1; display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 12px; font-weight: 700; font-size: 14px; color: var(--text-2); }
.profile-tabs .on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.cover-pick { position: relative; display: grid; place-items: center; height: 120px; border-radius: var(--radius); overflow: hidden; background: linear-gradient(120deg, #2a1f0d 0%, #6b4e1f 45%, #e0b15a 100%); cursor: pointer; }
.cover-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-pick span { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; font-weight: 600; }
.center-pick { justify-self: start; margin: -52px 0 0 16px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; }
.input {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input input, .input select, .input textarea { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 12px 0; }
.input select { appearance: none; cursor: pointer; }
.input.area { align-items: stretch; }
.input textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.prefix { color: var(--text-2); font-weight: 600; }
.eye { width: 32px; height: 32px; border: 0; padding: 0; background: none; color: var(--text-3); display: grid; place-items: center; border-radius: 8px; }
.eye.on, .eye:hover { color: var(--accent); }
.input.code input { text-align: center; font-size: 26px; letter-spacing: .5em; font-variant-numeric: tabular-nums; padding-left: .5em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr; } }
.form-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 14px; line-height: 1.4; }
.form-error[hidden] { display: none; }
.form-error .ico { margin-top: 1px; }
.error-text { color: var(--danger); }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; }
.auth-hero {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: flex-end;
    padding: 24px;
    background: linear-gradient(180deg, rgba(7, 7, 8, .1) 0%, rgba(7, 7, 8, .85) 100%), url('/images/connecta-portrait.jpg') center 20% / cover no-repeat;
    color: #fff;
}
.auth-hero-copy { display: grid; gap: 6px; max-width: 420px; }
.auth-hero-copy p { color: rgba(255, 255, 255, .78); }
.tagline { color: #f0c56e !important; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 700; }
.auth-panel { display: flex; justify-content: center; padding: 28px 20px 96px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 14px; align-content: start; }
.auth-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.auth-card > .muted { margin-top: -6px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; }
.auth-switch { text-align: center; color: var(--text-2); font-size: 14px; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.link-btn.inline { font-size: 14px; }
@media (min-width: 900px) {
    .auth { grid-template-columns: 1.1fr 1fr; }
    .auth-hero { min-height: 100dvh; padding: 56px; position: sticky; top: 0; }
    .auth-hero-copy p:last-child { font-size: 18px; }
    .auth-panel { align-items: center; padding: 48px; }
}

/* ---------- Sheets & toasts ---------- */
.scrim {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--vv-top, 0px);
    height: var(--vvh, 100dvh);
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: var(--scrim);
    animation: fade .18s ease;
}
.scrim.out { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
    width: 100%;
    max-height: 88dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
    animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet { max-height: calc(var(--vvh, 100dvh) * .92); }
.sheet.tall { height: calc(var(--vvh, 100dvh) * .85); }
body.typing .sheet.tall { height: calc(var(--vvh, 100dvh) - 12px); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 20px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { font-size: 16px; font-weight: 700; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 20px; }
.sheet.tall .sheet-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 700px) {
    .scrim { align-items: center; padding: 24px; }
    .sheet { max-width: 440px; border-radius: var(--radius-l); max-height: 86dvh; }
    .sheet.wide { max-width: 560px; }
    .sheet.tall { height: min(720px, 86dvh); }
}
.menu { display: grid; margin: -8px -12px; }
.menu button { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border: 0; border-radius: 12px; background: none; text-align: left; font-weight: 500; }
.menu button:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger); }
.copy-line { word-break: break-all; padding: 12px; border-radius: 12px; background: var(--surface-2); user-select: all; }

.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
    transform: translateX(-50%);
    z-index: 80;
    display: grid;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}
@media (min-width: 700px) { .toasts { bottom: 24px; } }
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: drop-in .2s ease;
    transition: opacity .3s, transform .3s;
}
.toast .ico { color: var(--repost); }
.toast.error .ico { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Comments ---------- */
.comments-sheet { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.comments-sheet .thread { flex: 1; overflow: auto; padding: 12px 16px; overscroll-behavior: contain; }
.thread { display: grid; gap: 14px; align-content: start; }
.comment { display: flex; gap: 10px; align-items: flex-start; transition: opacity .2s; }
.comment.pending { opacity: .6; }
.comment.failed .c-bubble { border: 1px solid var(--danger); }
.c-main { flex: 1; min-width: 0; }
.c-bubble { display: inline-grid; gap: 2px; max-width: 100%; padding: 8px 12px; border-radius: 4px 16px 16px 16px; background: var(--surface-2); }
.c-bubble .name { font-size: 13.5px; }
.c-bubble p { white-space: pre-wrap; overflow-wrap: anywhere; }
.c-actions { display: flex; align-items: center; gap: 14px; padding: 4px 0 0 12px; font-size: 12.5px; color: var(--text-3); }
.c-actions button { border: 0; background: none; padding: 6px 2px; margin: -6px 0; color: var(--text-2); font-weight: 700; font-size: 12.5px; }
.c-actions button:hover { color: var(--text); }
.c-time { display: inline-flex; align-items: center; gap: 4px; }
.replies { display: grid; gap: 12px; }
.replies:not(:empty) { margin-top: 12px; }
.load-more { justify-self: start; font-size: 14px; }
.thread-empty { display: grid; justify-items: center; gap: 10px; padding: 40px 16px; color: var(--text-2); text-align: center; }
.reply-box { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 12px; }
.reply-row { display: flex; align-items: flex-end; gap: 10px; }
.reply-row textarea, .chat-composer textarea {
    flex: 1;
    min-height: 40px;
    max-height: 140px;
    padding: 9px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    outline: none;
    resize: none;
    line-height: 1.4;
}
.reply-row textarea:focus, .chat-composer textarea:focus { border-color: var(--accent); }
.send {
    width: 40px;
    height: 40px;
    flex: none;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    transition: opacity .15s, transform .1s;
}
.send:disabled { opacity: .35; }
.send:active:not(:disabled) { transform: scale(.94); }
.replying { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 44px; font-size: 13px; color: var(--text-2); }
.replying[hidden] { display: none; }
.post-comments { padding-bottom: 80px; }
.inline-thread .thread { padding: 4px 16px 16px; }
.inline-thread .reply-box { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .inline-thread .reply-box { bottom: 0; } }

/* ---------- Reels ---------- */
.reels { height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom)); overflow-y: auto; scroll-snap-type: y mandatory; background: #000; position: relative; scrollbar-width: none; }
.reels::-webkit-scrollbar { display: none; }
.reels .empty { color: rgba(255, 255, 255, .7); }
.reels .empty h3 { color: #fff; }
.reels-top { position: sticky; top: 0; z-index: 2; height: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 0 16px; }
.reels-top h1 { margin-top: calc(14px + env(safe-area-inset-top)); color: #fff; font-size: 20px; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.reels-top .icon-btn { margin-top: calc(10px + env(safe-area-inset-top)); }
.reel { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; overflow: hidden; color: #fff; }
.reel.loading { color: rgba(255, 255, 255, .7); }
.reel .media { width: 100%; height: 100%; object-fit: cover; }
.reel::after { content: ""; position: absolute; inset: 50% 0 0; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .65)); pointer-events: none; }
.reel-info { position: absolute; left: 16px; right: 80px; bottom: 20px; z-index: 1; display: grid; gap: 8px; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.reel-info p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.reel-info .reel-author { display: inline-flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; color: #fff; }
.reel-author strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-actions { position: absolute; right: 8px; bottom: 20px; z-index: 1; display: grid; gap: 6px; }
.reel-actions .act { flex-direction: column; height: auto; padding: 8px; color: #fff; font-size: 12px; gap: 2px; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .5)); }
.reel-actions .act:hover { background: transparent; }
.reel-actions .act.like.on { color: var(--like); }
@media (min-width: 700px) {
    .reels { height: 100dvh; }
    .reel .media { object-fit: contain; }
}

/* ---------- Messages ---------- */
.chat { display: flex; flex-direction: column; height: calc(var(--vvh, 100dvh) - 57px - env(safe-area-inset-top) - 16px); }
.chat-composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
body.typing .chat-composer { padding-bottom: 10px; }
@media (min-width: 700px) { .chat { height: calc(100dvh - 57px - 40px); } }
.thread-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.thread-msgs .thread-empty { margin: auto; }
.bubble { max-width: 78%; padding: 9px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.bubble.mine a { color: inherit; text-decoration: underline; }
.bubble.theirs { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.bubble.pending { opacity: .6; }
.bubble + .bubble.mine:not(.theirs + .mine), .bubble + .bubble.theirs:not(.mine + .theirs) { margin-top: -1px; }
.mine + .theirs, .theirs + .mine { margin-top: 10px; }
.chat-composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--bg); }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.chat-title span { display: grid; min-width: 0; line-height: 1.25; }
.chat-title strong { display: inline-flex; align-items: center; gap: 4px; }
.chat-title small { color: var(--text-2); font-size: 12px; }
.center-spin { margin: auto; }

/* ---------- Install ---------- */
.install-widget {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
}
@media (min-width: 700px) { .install-widget { bottom: 20px; } }
.install-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 14px 5px 5px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow);
}
.install-btn img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.install-x { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-2); display: grid; place-items: center; padding: 0; box-shadow: var(--shadow); }
.install-card { display: grid; justify-items: center; gap: 12px; text-align: center; }
.install-logo { width: 64px; height: 64px; border-radius: 16px; }
.install-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; text-align: left; width: 100%; }
.install-steps li { display: flex; align-items: center; gap: 12px; font-size: 14px; line-height: 1.4; }
.install-steps b { color: var(--accent); }
.install-step-ico { width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; }
@media (display-mode: standalone) { .install-widget { display: none; } }

/* ---------- Phones ---------- */
@media (max-width: 699px) {
    /* iOS zooms into any field under 16px when it gets focus, which throws the whole layout off. */
    .input input, .input select, .input textarea, .search input, .reply-row textarea, .chat-composer textarea { font-size: 16px; }
    body.typing .toasts, body.no-tabs .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
    body.no-tabs .install-widget { bottom: calc(16px + env(safe-area-inset-bottom)); }
    body.typing .install-widget { display: none; }
    .install-widget { right: 12px; }
}
@media (max-width: 420px) {
    /* Avatar on its own row, buttons share the full width below it. */
    .profile-head { flex-wrap: wrap; margin-top: -40px; }
    .profile-head > .avatar, .profile-head .avatar-pick .avatar { width: 80px; height: 80px; font-size: 28px; }
    .profile-actions { flex: 1 1 100%; justify-content: stretch; flex-wrap: nowrap; padding: 4px 0 0; }
    .profile-actions .btn { flex: 1; min-width: 0; padding: 0 10px; }
    .profile-actions .btn.icon-only { flex: none; }
    .verify-card { flex-wrap: wrap; }
    .verify-card > div { flex: 1 1 160px; }
    .cover { height: 120px; }
    .post { padding-left: 12px; padding-right: 12px; }
    .post-note { margin-left: 0; }
    .act { padding: 0 8px; min-width: 36px; }
    .composer-card { padding: 12px; }
    .auth-panel { padding-left: 16px; padding-right: 16px; }
    .wordmark.light { font-size: 38px; }
}

/* Touch screens keep :hover after a tap; drop those highlights so buttons don't look stuck. */
@media (hover: none) {
    .btn.secondary:hover:not(:disabled), .icon-btn:hover, .act:hover, .chip:hover, .menu button:hover, .chat-row:hover, .rail-link:hover, .tool:hover { background: transparent; }
    .icon-btn:not(.plain):hover { background: var(--surface); }
    .icon-btn.glass:hover { background: rgba(0, 0, 0, .4); }
    .act:hover { color: var(--text-2); }
    .act.like.on:hover { color: var(--like); }
    .act.repost.on:hover { color: var(--repost); }
    .tile:hover img, .tile:hover video { transform: none; }
}

/* ---------- Server-rendered fallback before the script loads ---------- */
.boot { max-width: 560px; margin: 0 auto; padding: 48px 24px; display: grid; gap: 12px; }
.boot h1 { font-size: 28px; }
.boot a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
