:root {
    --bg: #000;
    --bg-2: #16181c;
    --card: transparent;
    --card-solid: #000;
    --border: #2f3336;
    --input-border: #333639;
    --text: #e7e9ea;
    --muted: #71767b;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --accent-2: #1d9bf0;
    --accent-soft: rgba(29, 155, 240, .1);
    --pink: #f91880;
    --danger: #f4212e;
    --ok: #00ba7c;
    --hover: rgba(231, 233, 234, .1);
    --row-hover: rgba(255, 255, 255, .03);
    --radius: 16px;
    --shadow: rgba(255, 255, 255, .2) 0 0 15px, rgba(255, 255, 255, .15) 0 0 3px 1px;
    --sticky-top: 0px;
    --blur-bg: rgba(0, 0, 0, .65);
}

* { box-sizing: border-box; }

html {
    color-scheme: dark;
    scrollbar-width: thin;
    scrollbar-color: #3e4144 transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: #3e4144;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #5b5f63; background-clip: padding-box; }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
*::-webkit-scrollbar-corner { background: transparent; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 15px/1.3333 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }

.muted { color: var(--muted); }
.small { font-size: .87rem; }
.center { text-align: center; }
.accent { color: var(--accent); }

/* ---------- Каркас ---------- */

.layout { flex: 1; width: 100%; }
.chrome { display: contents; }
.dock[hidden] { display: none !important; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 53px;
    padding: 0 16px;
    background: var(--blur-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
body.is-guest[data-page="home"] .topbar { display: none; }

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: var(--text);
    transition: background-color .2s;
}
.logo:hover { text-decoration: none; background: var(--hover); }
.logo-mark { width: 32px; height: 32px; display: block; }
.logo-accent { fill: var(--accent); }

.nav { display: flex; }
.nav-guest { margin-left: auto; align-items: center; gap: 12px; }
.nav-guest a:not(.btn) { padding: 6px 14px; border-radius: 9999px; color: var(--text); font-weight: 700; }
.nav-guest a:not(.btn):hover { background: var(--hover); text-decoration: none; }
.nav-icon { display: block; width: 26px; height: 26px; flex: none; }
.btn-post .nav-icon { display: none; }
.account { display: none; }

.badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 18px;
    border: 1px solid var(--bg);
}

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 20px 40px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px 24px 24px; }
body.is-app .footer { display: none; }

.grid-2 { display: block; }
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

body.is-app .container .card {
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin: 0;
    padding: 12px 16px;
}
body.is-app .container .card.empty { padding: 40px 32px; }

body.is-app .container > .page-title,
body.is-app .page-title {
    position: sticky;
    top: var(--sticky-top);
    z-index: 5;
    display: flex;
    align-items: center;
    height: 53px;
    margin: 0;
    padding: 0 16px;
    font-size: 20px;
    font-weight: 700;
    background: var(--blur-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.eyebrow { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.empty { text-align: center; padding: 40px 24px; }
.empty h2 { font-size: 1.85rem; font-weight: 800; margin-bottom: 8px; }
.big-number { font-size: 2rem; font-weight: 800; margin: 0; line-height: 1; }

/* ---------- Правая колонка ---------- */

.rail { display: block; }
.rail .sidebar { gap: 16px; }
.rail .card {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    margin: 0;
}
.rail .card h2, .rail .eyebrow {
    display: block;
    margin: 0 0 12px;
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
    line-height: 24px;
}
.rail .n-card .eyebrow { text-align: left; }
.rail-search {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 6px 0;
    margin-bottom: 10px;
    background: var(--bg);
}
.rail-search-box { position: relative; display: block; }
.rail-search-box svg {
    position: absolute;
    left: 16px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.rail-search-box input[type=search] {
    padding: 11px 16px 11px 46px;
    border-radius: 9999px;
    background: #202327;
    border-color: transparent;
}
.rail-search-box input[type=search]:focus { background: var(--bg); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rail-search-box:focus-within svg { color: var(--accent); }
.rail .trends { padding: 12px 0 4px; overflow: hidden; }
.rail .trends h2 { padding: 0 16px; }
.trends-empty { margin: 0 16px 12px; }
.trend {
    display: flex;
    flex-direction: column;
    padding: 10px 16px;
    line-height: 20px;
    color: var(--text);
    transition: background-color .2s;
}
.trend:hover { background: var(--row-hover); text-decoration: none; }
.trend strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .sidebar { margin-top: 16px; }
.rail-foot { margin: 16px 16px 0; color: var(--muted); font-size: 13px; }

/* ---------- Кнопки и формы ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 9999px;
    background: #eff3f4;
    color: #0f1419;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, color .2s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #d7dbdc; }
.btn-blue, .btn-post, .compose .btn:not(.btn-ghost) { background: var(--accent); color: #fff; }
.btn-blue:hover, .btn-post:hover, .compose .btn:not(.btn-ghost):hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: #536471; }
.btn-ghost:hover { background: var(--hover); }
.btn-outline-blue { color: var(--accent); }
.btn-outline-blue:hover { background: var(--accent-soft); }
.btn-small { min-height: 32px; padding: 0 14px; font-size: 14px; }
.btn-large { min-height: 44px; padding: 0 24px; font-size: 15px; }
.nav a.btn { color: #fff; }

.link-button { background: none; border: 0; padding: 4px 6px; color: var(--muted); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--text); }

.inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.logout { margin: 0; }

input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
    width: 100%;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 48px; }
select { width: auto; padding: 6px 10px; font-size: 14px; cursor: pointer; background: var(--bg); }

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.form .btn { align-self: flex-start; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-ok { background: rgba(0,186,124,.1); border-color: rgba(0,186,124,.4); color: #7ee2bf; }
.flash-info { background: var(--accent-soft); border-color: rgba(29,155,240,.4); color: #9fd4f8; }
.flash-error { background: rgba(244,33,46,.1); border-color: rgba(244,33,46,.4); color: #ff9aa2; }

/* ---------- Аватары и строки ---------- */

.avatar {
    --h: 220;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: hsl(var(--h) 42% 40%);
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
}
.avatar.has-photo { overflow: visible; background: #333639; }
.avatar.has-photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar-xs { width: 22px; height: 22px; font-size: .62rem; box-shadow: 0 0 0 2px var(--bg); }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.8rem; }

.user-link { color: var(--text); font-weight: 700; }

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 -16px;
    padding: 12px 16px;
    flex-wrap: wrap;
    transition: background-color .2s;
}
.row:hover { background: var(--row-hover); }
.row-main { flex: 1; min-width: 160px; }

.search { display: flex; gap: 10px; }
.search input { flex: 1; min-width: 0; width: auto; border-radius: 9999px; background: #202327; border-color: transparent; padding: 10px 18px; }
.search input:focus { background: var(--bg); }

/* ---------- Лендинг ---------- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 40px;
    min-height: calc(100vh - 120px);
    padding: 16px 0;
}
.hero-mark { display: flex; justify-content: center; }
.hero-n { width: min(380px, 80%); height: auto; display: block; overflow: visible; }
.hero-copy h1 { font-size: clamp(2.6rem, 5.4vw, 4rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 0 0 24px; }
.lead { font-size: 17px; line-height: 1.4; color: var(--muted); max-width: 480px; margin: 0 0 36px; }
.hero-join { font-size: 31px; font-weight: 800; margin: 0 0 20px; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; width: 300px; max-width: 100%; }
.hero-actions .btn { width: 100%; }
.hero-actions .small { margin: 0; font-size: 11px; }
.hero-signin { margin: 32px 0 12px; font-size: 17px; font-weight: 700; }
.hero-stats { margin: 28px 0 0; }
.hero-n .draw {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: hero-draw .12s linear var(--t, 0s) both;
}
.hero-letter { stroke: var(--text); }
.hero-heart { stroke: var(--accent); }

@keyframes hero-draw { to { stroke-dashoffset: 100; } }

@media (prefers-reduced-motion: reduce) {
    .hero-n .draw { animation: none; stroke-dashoffset: 100; }
}

.auth { max-width: 440px; margin: 20px auto; text-align: center; padding: 32px; }
.auth h1 { font-size: 31px; }
.auth .form { text-align: left; margin-bottom: 16px; }
.auth .form .btn { align-self: stretch; }
.auth-logo { width: 48px; height: 48px; color: var(--text); margin-bottom: 12px; }

/* ---------- Посты ---------- */

.compose textarea {
    display: block;
    min-height: 52px;
    margin-bottom: 8px;
    padding: 10px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 20px;
    line-height: 24px;
    resize: none;
}
.compose textarea:focus { box-shadow: none; }
body.is-app .container .compose.has-avatar { position: relative; padding-left: 72px; }
.compose-avatar { position: absolute; left: 16px; top: 12px; }
.compose-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.compose-foot .small { flex: 1; font-size: 12px; line-height: 16px; }

.distance-line { color: var(--accent); font-size: 13px; margin-top: 4px; }
.story { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 4px; }
.story span {
    padding: 4px 12px;
    border-radius: 9999px;
    border: 1px solid var(--border);
    font-size: 13px;
}
.digest p { margin: 0 0 8px; }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.note .note-main { flex: 1; }

.post { --life: 1; opacity: calc(.5 + .5 * var(--life)); transition: opacity .3s, background-color .2s; }
.post:hover { opacity: 1; background: var(--row-hover); }
body.is-app .container .post.card { position: relative; padding: 12px 16px 4px 72px; }
.post-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 2px; }
body.is-app .post-head > .avatar { position: absolute; left: 16px; top: 12px; }
.post-tools { display: flex; gap: 2px; margin-left: auto; }
.post-tools .link-button { padding: 0 6px; font-size: 13px; border-radius: 9999px; }
.post-tools .link-button:hover { color: var(--accent); }
.post-edit textarea { width: 100%; margin-bottom: 10px; }
.post-edit-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.post-meta { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; min-width: 0; line-height: 20px; }
.post-meta .handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.post-delete { margin: 0; }
.hashtag, a.hashtag:hover, .bubble.is-mine .bubble-body a.hashtag { color: var(--accent); text-decoration: none; }
.bubble.is-mine .bubble-body a.hashtag { color: #fff; font-weight: 700; }
a.mention, a.mention:hover { color: var(--accent); text-decoration: none; }
.bubble.is-mine .bubble-body a.mention { color: #fff; font-weight: 700; }

.mention-box {
    position: fixed;
    z-index: 200;
    display: flex;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 0;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(255,255,255,.2), 0 0 3px 1px rgba(255,255,255,.15);
}
.mention-box[hidden] { display: none; }
.mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.mention-item:hover, .mention-item.is-active { background: var(--hover); }
.mention-who { display: flex; flex-direction: column; min-width: 0; font-size: 15px; line-height: 20px; }
.mention-who strong, .mention-who .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.link { color: var(--accent); text-decoration: none; word-break: break-all; }
a.link:hover { text-decoration: underline; }
.bubble.is-mine .bubble-body a.link { color: #fff; text-decoration: underline; }

.link-card {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
    transition: background-color .2s;
}
.link-card:hover { background: rgba(255,255,255,.03); text-decoration: none; }
.link-card[hidden], .link-card.is-editing { display: none; }
.link-card-media { display: block; aspect-ratio: 1.91 / 1; background: #16181c; border-bottom: 1px solid var(--border); }
.link-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.link-card-body { display: flex; flex-direction: column; gap: 2px; padding: 12px; font-size: 15px; line-height: 20px; }
.link-card-host { color: var(--muted); font-size: 13px; }
.link-card-title { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-card-desc { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tag-head h2 { margin: 0 0 4px; font-size: 20px; }
.tag-head p, .search-hint { margin: 0; }
.post-body { font-size: 15px; line-height: 20px; margin-bottom: 12px; word-wrap: break-word; overflow-wrap: anywhere; }

.life { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.life-track { flex: 0 0 120px; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.life-bar { height: 100%; width: calc(var(--life) * 100%); background: var(--accent); }

.reactions, .private-reactions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.chip {
    padding: 4px 12px;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
}
.chip:hover { color: var(--pink); background: rgba(249,24,128,.1); border-color: transparent; }
.chip.active { color: var(--pink); background: rgba(249,24,128,.1); border-color: rgba(249,24,128,.4); font-weight: 700; }
.chip-static { cursor: default; color: var(--text); }
.chip-static:hover { color: var(--text); background: transparent; border-color: var(--border); }
.react-group { display: inline-flex; align-items: center; gap: 8px; padding-left: 6px; }
.react-faces { display: inline-flex; align-items: center; }
.react-face { display: inline-flex; line-height: 0; border-radius: 50%; margin-left: -6px; }
.react-face:first-child { margin-left: 0; }
.react-face:hover { text-decoration: none; z-index: 1; position: relative; }

.replies { padding-left: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.comments-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px -8px;
    padding: 6px 10px 6px 8px;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: color .2s, background-color .2s;
}
.comments-bar:hover { color: var(--accent); background: var(--accent-soft); }
.comments-icon { width: 18px; height: 18px; flex: none; }
.comments-faces { display: inline-flex; align-items: center; }
.comments-faces .avatar { margin-left: -8px; }
.comments-faces .avatar:first-child { margin-left: 0; }
.comments-label { min-width: 0; }
.comments-sheet[hidden] { display: none !important; }
.comments-sheet {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.comments-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(91, 112, 131, .4);
    cursor: pointer;
}
.comments-panel {
    position: relative;
    z-index: 1;
    width: min(600px, 100%);
    height: min(78vh, 720px);
    max-height: calc(100dvh - 12px);
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
}
.comments-head { display: flex; align-items: center; gap: 16px; height: 45px; margin-bottom: 4px; font-size: 17px; }
.comments-head strong { order: 1; }
.comments-x {
    order: 0;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.comments-x:hover { background: var(--hover); }
.comments-scroll { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.comments-source { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 10px; }
.comments-source[hidden] { display: none !important; }
.comments-source .replies { overflow: auto; flex: 1; padding: 8px 4px; }
.comments-empty { margin: 8px 0 0; }
.comments-source .reply-form { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.reply { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.reply.is-noted, .post.is-noted { background: var(--accent-soft); border-radius: 12px; }
body.is-app .container .post.is-noted { border-radius: 0; }
.notice-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.notice-head h2, .notice-head strong { margin: 0; font-size: 20px; font-weight: 800; }
.note-list { display: flex; flex-direction: column; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; color: inherit; }
.note:hover { background: var(--row-hover); text-decoration: none; }
.note-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.note-body { color: var(--muted); }
.note-wrap { position: relative; }
.note-bell { position: relative; display: inline-flex; align-items: center; }
.note-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(380px, 80vw);
    max-height: 70vh;
    overflow: auto;
    padding: 12px;
    background: var(--card-solid);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 30;
    font-size: 15px;
    font-weight: 400;
}
.reply-main { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.reply-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.reply-to { color: var(--muted); }
.reply-actions { display: flex; gap: 2px; margin-left: -4px; }
.reply-actions .link-button { padding: 0 4px; font-size: 13px; }
.reply-actions .link-button:hover { color: var(--accent); }
.reply-edit { display: flex; gap: 8px; width: 100%; align-items: center; }
.reply-edit input, .reply-form input[name=body] {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 9px 16px;
    border-radius: 9999px;
    background: #202327;
    border-color: transparent;
}
.reply-edit input:focus, .reply-form input[name=body]:focus { background: var(--bg); }
.reply-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.reply-target { flex: 1 0 100%; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* ---------- Нить ---------- */

.thread-head { text-align: center; }
.thread-head h1 { font-size: 20px; }
.thread-pair { --thick: 3px; display: flex; align-items: center; justify-content: center; gap: 0; margin: 8px 0 14px; }
.thread-line {
    width: 160px;
    height: var(--thick);
    border-radius: var(--thick);
    background: var(--accent);
}
.thread { display: flex; flex-direction: column; gap: 10px; }
.feed-more,
.thread-more { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px; color: var(--muted); font-size: 14px; }
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thread-compose { position: sticky; bottom: 0; z-index: 4; background: var(--bg); }
body.is-app .thread-compose { border-top: 1px solid var(--border); }
body.is-app .thread-entries { padding: 16px; }
.bubble { max-width: 75%; align-self: flex-start; }
.bubble.is-mine { align-self: flex-end; text-align: right; }
.bubble-body {
    display: inline-block;
    text-align: left;
    padding: 12px 16px;
    border-radius: 24px 24px 24px 4px;
    background: var(--border);
    overflow-wrap: anywhere;
}
.bubble.is-mine .bubble-body { border-radius: 24px 24px 4px 24px; background: var(--accent); color: #fff; }
.bubble.is-mine .bubble-body a { color: #fff; text-decoration: underline; }
.bubble-meta { margin-top: 4px; font-size: 13px; }
.pinned { margin: 8px -16px; }
.pinned .eyebrow { padding: 0 16px 0 72px; margin: 0; }
.pinned .card { margin-bottom: 0; }

.thread-meter { --thick: 2px; height: var(--thick); max-width: 220px; margin: 6px 0; border-radius: 4px; background: var(--accent); opacity: .8; }

/* ---------- Профиль и созвездие ---------- */

.profile-head { display: flex; align-items: flex-start; gap: 0 12px; flex-wrap: wrap; }
.profile-cover {
    display: block;
    flex: 0 0 calc(100% + 32px);
    height: 200px;
    margin: -12px -16px 12px;
    padding: 0;
    border: 0;
    background: #333639;
    overflow: hidden;
}
.profile-head .profile-cover { max-width: none; margin-bottom: 12px; }
.profile-head button.profile-cover { cursor: zoom-in; }
.profile-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }

.cover-form { display: flex; flex-direction: column; gap: 10px; }
.cover-form p { margin: 0; }
.cover-form .avatar-actions { justify-content: flex-start; }
.cover-current, .cover-form .photo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 3 / 1;
    margin: 0;
    border-radius: 12px;
    background: #333639;
    overflow: hidden;
}
.cover-form .photo-preview[hidden] { display: none !important; }
.cover-current img, .cover-form .photo-preview img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    object-fit: cover;
}
.cover-form .photo-preview .photo-remove { position: absolute; }
.profile-head .avatar-xl {
    order: 1;
    width: 134px;
    height: 134px;
    margin-top: -79px;
    font-size: 2.6rem;
    border: 4px solid var(--bg);
}
.profile-actions { order: 2; margin-left: auto; }
.profile-info { order: 3; flex: 1 0 100%; min-width: 0; margin-top: 12px; }
.profile-info h1 { margin-bottom: 2px; font-size: 20px; font-weight: 800; }
.profile-info p { margin-bottom: 12px; }
.profile-info p:last-child { margin-bottom: 0; }

.constellation { width: 100%; height: auto; display: block; border-radius: 16px; background: radial-gradient(circle at 50% 50%, rgba(29,155,240,.08), transparent 70%); }
.c-dust { fill: #fff; opacity: .35; animation: twinkle 5s ease-in-out infinite; }
.c-line { stroke-linecap: round; }
.c-glow, .c-flow { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .c-flow { display: none; } }
.c-star text { fill: var(--text); font-size: 13px; font-weight: 500; }
.c-star:hover text { fill: var(--accent); }
.c-core { fill: #fff; }
.c-group { fill: var(--muted); font-size: 11px; letter-spacing: .18em; font-weight: 700; }
.c-center-text { fill: #fff; font-size: 15px; font-weight: 800; }
.c-empty { fill: var(--muted); font-size: 15px; }

.c-wrap { position: relative; }
.c-wrap .constellation { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; }
.constellation.is-dragging { cursor: grabbing; }
.constellation.is-dragging .c-star { pointer-events: none; }
.c-tools {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.c-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--text);
    cursor: pointer;
    transition: background-color .15s;
}
.c-tool:hover { background: var(--hover); }
.c-tool:disabled { opacity: .5; cursor: progress; }
.c-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.c-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.c-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: 16px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.c-wrap.show-hint .c-hint { opacity: 1; }

.c-modal { position: fixed; inset: 0; z-index: 90; background: #000; }
.c-modal-stage { position: absolute; inset: 0; }
.c-modal .constellation { width: 100%; height: 100%; border-radius: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.c-modal .c-tools {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    bottom: auto;
}
.c-modal .c-tool { width: 40px; height: 40px; }

@keyframes twinkle { 0%, 100% { opacity: .15; } 50% { opacity: .6; } }

.n-card { text-align: center; }
.n-number {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    margin: 0 0 12px;
    color: var(--text);
}
.layers { list-style: none; padding: 0; margin: 0; text-align: left; }
.layers li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); font-size: 15px; }

/* ---------- Диагональ ---------- */

.chain { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0; margin: 18px 0; }
.chain-node { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); font-size: 13px; font-weight: 700; padding: 0 4px; }
.chain-node:hover { text-decoration: none; }
.chain-node.is-me .avatar { box-shadow: 0 0 0 2px var(--text); }
.chain-node.is-target .avatar { box-shadow: 0 0 0 2px var(--accent); }
.chain-link {
    width: 48px;
    height: 2px;
    margin-bottom: 26px;
    background: var(--accent);
}

.diagonal { text-align: center; }
.diagonal .lead { margin: 0 auto; color: var(--text); }
.diagonal-target { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 26px auto; max-width: 520px; text-align: left; }
.diagonal-target h2 { margin-bottom: 2px; font-size: 20px; }
.diagonal-target p { margin-bottom: 4px; }
.diagonal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
body.is-app .container > .muted.center { padding: 16px; margin: 0; }

.teaser-user { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

/* ---------- Фото ---------- */

[hidden] { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.file-btn { position: relative; cursor: pointer; flex: none; }
.compose .file-btn, .post-edit .file-btn { color: var(--accent); border-color: transparent; }
.compose .file-btn:hover, .post-edit .file-btn:hover { background: var(--accent-soft); }
.file-btn:focus-within { box-shadow: 0 0 0 2px var(--accent); }

.photo-preview { position: relative; display: inline-block; margin-bottom: 10px; }
.photo-preview img { display: block; max-width: 220px; max-height: 160px; border-radius: 16px; border: 1px solid var(--border); object-fit: cover; }
.photo-remove {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 0;
    background: rgba(15, 20, 25, .75);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.photo-remove:hover { background: rgba(39, 44, 48, .75); }

.post-photo, .bubble-photo, .photo-open {
    display: block;
    margin-bottom: 12px;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    text-align: inherit;
    max-width: 100%;
}
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .9);
}
.lightbox[hidden] { display: none !important; }

.confirm {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(91, 112, 131, .4);
    animation: confirm-fade .15s ease-out;
}
.confirm[hidden] { display: none !important; }
.confirm-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    padding: 32px;
    border-radius: 16px;
    background: var(--bg);
    animation: confirm-pop .15s ease-out;
}
.confirm-box h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 24px; overflow-wrap: anywhere; }
.confirm-box p { margin: 0 0 12px; font-size: 15px; line-height: 20px; }
.confirm-box p[hidden] { display: none; }
.confirm-box .btn { width: 100%; min-height: 44px; }
.btn-danger { background: #f4212e; color: #fff; }
.btn-danger:hover { background: #dc1e29; }
body.has-modal { overflow: hidden; }
@keyframes confirm-fade { from { opacity: 0; } }
@keyframes confirm-pop { from { transform: scale(.96); opacity: 0; } }
.lightbox img {
    max-width: min(1100px, 100%);
    max-height: calc(100vh - 48px);
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 20, 25, .75);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-close:hover { background: rgba(39, 44, 48, .75); }
body.lightbox-open { overflow: hidden; }
.post-photo img, .bubble-photo img {
    display: block;
    max-width: 100%;
    max-height: 510px;
    border-radius: 16px;
    border: 1px solid var(--border);
    object-fit: contain;
    background: #000;
}
.post-photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    aspect-ratio: 16 / 9;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}
.post-photos.count-2 { grid-template-rows: 1fr; }
.post-photos.count-3, .post-photos.count-4 { grid-template-rows: 1fr 1fr; }
.post-photos.count-3 .photo-cell:first-child { grid-row: span 2; }
.photo-cell {
    position: relative;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: #16181c;
    cursor: zoom-in;
}
.photo-cell img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-cell:hover img { filter: brightness(.92); }
.post-photos.count-1 { display: block; aspect-ratio: auto; border: 0; border-radius: 0; overflow: visible; }
.post-photos.count-1 .photo-cell { background: none; max-width: 100%; }
.post-photos.count-1 .photo-cell img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 510px;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #000;
}
.photo-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 28px;
    font-weight: 800;
}

.photo-tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.photo-tile { position: relative; width: 96px; height: 96px; flex: none; }
.photo-tile img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.photo-tile-remove {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 20, 25, .75);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.photo-tile-remove:hover { background: rgba(39, 44, 48, .75); }
.file-btn.is-full { opacity: .5; pointer-events: none; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 20, 25, .75);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-nav:hover { background: rgba(39, 44, 48, .9); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-count {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 9999px;
    background: rgba(15, 20, 25, .75);
    color: #fff;
    font-size: 14px;
}

.bubble-photo { margin-bottom: 4px; }
.bubble-photo img { max-height: 320px; margin-left: 0; }
.bubble.is-mine .bubble-photo img { margin-left: auto; }

/* ---------- Аватар в настройках ---------- */

.avatar-form { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.avatar-form .avatar-xl { width: 120px; height: 120px; font-size: 2.4rem; }
.avatar-form .photo-preview { margin: 0; }
.avatar-form .photo-preview img { width: 120px; height: 120px; max-width: none; border-radius: 50%; object-fit: cover; }
.avatar-form p { margin: 0; }
.avatar-actions { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* ---------- Вкладки ленты ---------- */

.tabs {
    display: flex;
    margin: 0 0 16px;
    border-bottom: 1px solid var(--border);
}
.tabs a {
    flex: 1;
    display: flex;
    justify-content: center;
    color: var(--muted);
    font-weight: 500;
    font-size: 15px;
    transition: background-color .2s;
}
.tabs a span { position: relative; padding: 16px 0; }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a.active { color: var(--text); font-weight: 700; }
.tabs a.active span::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    border-radius: 9999px;
    background: var(--accent);
}
body.is-app .tabs {
    position: sticky;
    top: var(--sticky-top);
    z-index: 5;
    margin: 0;
    background: var(--blur-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.distance { color: var(--accent); }

/* ---------- Админ-панель ---------- */

.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 16px; }
.admin-stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.admin-stat strong { font-size: 28px; font-weight: 800; line-height: 1.1; }
.admin-heading { margin: 8px 16px 0; padding-bottom: 12px; font-size: 20px; font-weight: 800; border-bottom: 1px solid var(--border); }
.admin-search { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.admin-search input { flex: 1; min-width: 0; }
.admin-filter, .admin-empty { margin: 16px; }
.admin-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.admin-row.is-banned { background: rgba(244, 33, 46, .06); }
.admin-main { flex: 1; min-width: 0; }
.admin-main p { margin: 2px 0; overflow-wrap: anywhere; }
.admin-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.admin-who .user-link { font-weight: 700; color: var(--text); }
.admin-badge { padding: 1px 8px; border-radius: 9999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.admin-badge[hidden] { display: none; }
.admin-body { margin: 6px 0 !important; max-height: 9.6em; overflow: hidden; }
.admin-quote { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.admin-photos { display: flex; gap: 6px; margin: 6px 0; }
.admin-photos button { width: 72px; height: 72px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--bg-2); }
.admin-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; }
.admin-actions .link-button:hover { color: var(--text); }
.admin-row .admin-danger { color: var(--danger); }
.admin-row .admin-danger:hover { color: var(--danger); text-decoration: underline; }
.admin-entry { margin: 24px 0; }
.admin-actions .admin-premium { color: var(--accent); }
.admin-tag { align-items: center; flex-wrap: wrap; }
.admin-tag input[type=text] { flex: 1 1 160px; min-width: 0; }
.admin-tag input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 8px; cursor: pointer; }
.admin-tag-preview { min-width: 72px; }
.admin-tag-count { flex: 1 0 100%; }

/* ---------- Премиум и теги ---------- */

.premium-letter { color: var(--accent); }
.user-tag { color: var(--tag, var(--accent)); font-weight: 700; font-size: .92em; white-space: nowrap; }
.premium-pill { display: inline-block; padding: 1px 8px; border-radius: 9999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; vertical-align: middle; }
.premium-pill[hidden] { display: none; }
.admin-pill { display: inline-block; padding: 1px 8px; border-radius: 9999px; background: var(--ok); color: #fff; font-size: 12px; font-weight: 700; vertical-align: middle; }
.admin-pill[hidden] { display: none; }
.tag-options { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-option { flex-direction: row !important; align-items: center; gap: 8px !important; padding: 8px 12px; border: 1px solid var(--border); border-radius: 9999px; cursor: pointer; color: var(--text) !important; }
.tag-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tag-option input { margin: 0; accent-color: var(--accent); }

/* ---------- Живые обновления ---------- */

.is-new { animation: arrive .6s ease-out; }
@keyframes arrive {
    from { opacity: 0; transform: translateY(8px); background: var(--accent-soft); }
    to { opacity: 1; transform: none; }
}

form.is-busy { opacity: .6; pointer-events: none; }

#toasts {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: min(420px, calc(100vw - 32px));
    transform: translateX(-50%);
}
.toast {
    padding: 12px 16px;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    box-shadow: rgba(101, 119, 134, .2) 0 0 15px, rgba(101, 119, 134, .15) 0 0 3px 1px;
    font-size: 15px;
    transition: opacity .4s, transform .4s;
}
.toast-error { background: var(--danger); }
.toast.is-hiding { opacity: 0; transform: translateY(8px); }

.thread-entries { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Десктоп: три колонки как в X ---------- */

@media (min-width: 1001px) {
    body.is-app .layout { display: flex; justify-content: center; align-items: flex-start; }
    body.is-app .chrome {
        position: sticky;
        top: 0;
        z-index: 20;
        flex: none;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        width: 275px;
        height: 100vh;
        height: 100dvh;
        padding: 2px 12px 12px;
    }
    body.is-app .topbar { display: contents; }
    body.is-app .logo { order: 0; margin-bottom: 2px; }
    body.is-app .dock { order: 1; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
    body.is-app .note-wrap { order: 2; }
    body.is-app .logout-btn { order: 3; }
    body.is-app .btn-post { order: 4; }
    body.is-app .account { order: 5; }
    body.is-app .topbar > .live-dot { display: none; }

    body.is-app .dock a,
    body.is-app .note-bell,
    body.is-app .logout-btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 20px;
        padding: 12px;
        border-radius: 9999px;
        color: var(--text);
        font-size: 20px;
        line-height: 24px;
        transition: background-color .2s;
    }
    body.is-app .dock a:hover,
    body.is-app .note-bell:hover,
    body.is-app .logout-btn:hover { background: var(--hover); text-decoration: none; }
    body.is-app .dock a.active { font-weight: 700; }
    body.is-app .dock a.active .nav-icon { filter: drop-shadow(0 0 .5px currentColor); }
    body.is-app .nav-label { padding-right: 16px; }
    body.is-app .dock .badge,
    body.is-app .note-bell .badge { position: absolute; top: 4px; left: 26px; }

    body.is-app .note-panel { left: 0; right: auto; top: calc(100% + 4px); }

    body.is-app .btn-post {
        width: 90%;
        min-height: 52px;
        margin-top: 16px;
        font-size: 17px;
        box-shadow: none;
    }

    body.is-app .account {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        margin-top: auto;
        padding: 12px;
        border-radius: 9999px;
        color: var(--text);
        transition: background-color .2s;
    }
    body.is-app .account:hover { background: var(--hover); text-decoration: none; }
    .account-avatar { position: relative; display: inline-flex; flex: none; }
    .account-avatar .live-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid var(--bg); }
    .account-text { display: flex; flex-direction: column; min-width: 0; line-height: 20px; }
    .account-text strong, .account-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    body.is-app .container {
        flex: none;
        width: 600px;
        max-width: 600px;
        min-height: 100vh;
        margin: 0;
        padding: 0;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    body.is-app .rail {
        position: sticky;
        top: 0;
        flex: none;
        width: 350px;
        max-height: 100vh;
        margin-left: 30px;
        padding: 0 0 24px;
        overflow-y: auto;
        scrollbar-width: none;
    }
    body.is-app .rail::-webkit-scrollbar { display: none; }

    .comments-sheet { align-items: center; }
    .comments-panel { border-radius: 16px; height: min(80vh, 720px); padding-bottom: 12px; }

    .comments-sheet.is-docked { right: auto; padding: 6px 0 12px; align-items: stretch; background: var(--bg); }
    .comments-sheet.is-docked .comments-backdrop { display: none; }
    .comments-sheet.is-docked .comments-panel {
        width: 100%;
        height: auto;
        max-height: none;
        border: 1px solid var(--border);
    }
    body.is-app .post.is-commenting { background: var(--row-hover); box-shadow: inset 3px 0 0 var(--accent); }
}

/* Узкий десктоп: меню сворачивается в иконки */
@media (min-width: 1001px) and (max-width: 1279px) {
    body.is-app .chrome { width: 88px; align-items: center; }
    body.is-app .dock { align-items: center; }
    body.is-app .nav-label,
    body.is-app .btn-post-label,
    body.is-app .account-text { display: none; }
    body.is-app .btn-post { width: 52px; padding: 0; }
    body.is-app .btn-post .nav-icon { display: block; width: 24px; height: 24px; }
    body.is-app .account { width: auto; }
    body.is-app .rail { width: 290px; margin-left: 20px; }
}

/* ---------- Планшет и телефон ---------- */

@media (max-width: 1000px) {
    body.is-app { --sticky-top: calc(53px + env(safe-area-inset-top)); }

    body.is-app .topbar {
        gap: 4px;
        height: calc(53px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 12px 0;
        background: rgba(0, 0, 0, .92);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    body.is-app .logo { width: 40px; height: 40px; }
    body.is-app .logo-mark { width: 28px; height: 28px; }
    body.is-app .note-wrap { margin-left: auto; }
    body.is-app .topbar > .live-dot { margin: 0 6px; }
    body.is-app .topbar .nav-label { display: none; }
    body.is-app .note-bell,
    body.is-app .logout-btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        color: var(--text);
    }
    body.is-app .note-bell:hover,
    body.is-app .logout-btn:hover { background: var(--hover); }
    body.is-app .note-bell .nav-icon,
    body.is-app .logout-btn .nav-icon { width: 22px; height: 22px; }
    body.is-app .note-bell .badge { position: absolute; top: 2px; right: 0; }

    body.is-app .dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        justify-content: space-around;
        height: calc(53px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(0, 0, 0, .85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--border);
    }
    body.is-app .dock a {
        position: relative;
        flex: 1 1 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--muted);
    }
    body.is-app .dock a:hover { text-decoration: none; color: var(--text); }
    body.is-app .dock a.active { color: var(--text); }
    body.is-app .dock .nav-label { display: none; }
    body.is-app .dock .nav-admin { display: none; }
    body.is-app .dock .badge { position: absolute; top: 6px; left: calc(50% + 4px); }
    body.is-app .thread-compose { bottom: calc(53px + env(safe-area-inset-bottom)); }
    body.is-app[data-page=thread] .btn-post { display: none; }

    body.is-app .btn-post {
        position: fixed;
        right: 16px;
        bottom: calc(53px + 16px + env(safe-area-inset-bottom));
        z-index: 41;
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
        box-shadow: rgba(255, 255, 255, .2) 0 0 10px, rgba(255, 255, 255, .15) 0 0 3px 1px;
    }
    body.is-app .btn-post-label { display: none; }
    body.is-app .btn-post .nav-icon { display: block; width: 24px; height: 24px; }
    body.is-app[data-page="thread"] .btn-post { display: none; }

    body.is-app .container {
        max-width: 600px;
        margin: 0 auto;
        padding: 0;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    body.is-app .rail {
        max-width: 600px;
        margin: 0 auto;
        padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    body.is-app .rail-search { position: static; }

    body.is-app #toasts { bottom: calc(72px + env(safe-area-inset-bottom)); }
    body.is-app .note-panel {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top));
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100dvh - 130px - env(safe-area-inset-bottom));
    }
    body.is-app .comments-panel {
        margin-bottom: calc(53px + env(safe-area-inset-bottom));
        height: min(68vh, 640px);
        padding-bottom: 12px;
    }

    .hero { grid-template-columns: 1fr; gap: 24px; min-height: 0; padding: 24px 0 32px; }
    .hero-mark { justify-content: flex-start; }
    .hero-n { width: 96px; }
}

@media (max-width: 640px) {
    body.is-app .container,
    body.is-app .rail { border-left: 0; border-right: 0; }
    body.is-app .rail { border-top: 1px solid var(--border); }
    .topbar { gap: 8px; }
    .container { padding: 16px 16px 28px; }
    .card { padding: 16px; }
    .compose-foot { flex-wrap: wrap; }
    .compose-foot .small { order: -1; flex: 1 0 100%; }
    .row { gap: 8px 12px; }
    .row-main { min-width: 0; flex: 1 1 120px; }
    .row select { max-width: 100%; }
    .bubble { max-width: 88%; }
    .thread-line { width: 56px; }
    .chain-link { width: 18px; }
    .chain-node { font-size: 12px; }
    .diagonal-target { flex-direction: column; text-align: center; }
    .life { flex-wrap: wrap; }
    .life-track { flex-basis: 72px; }
    .profile-cover { height: 130px; }
    .profile-head .avatar-xl { width: 88px; height: 88px; margin-top: -56px; font-size: 1.8rem; }
    .hero-copy h1 { font-size: 2.4rem; }
    .hero-join { font-size: 23px; }
    .hero-actions { width: 100%; }
    .auth { padding: 24px 20px; }
    .n-number { font-size: 3.2rem; }
}

/* iOS Safari zooms into any field with font-size below 16px on focus. */
@media (pointer: coarse), (max-width: 1000px) {
    input, textarea, select { font-size: 16px !important; }
    .compose textarea { font-size: 20px !important; }
}
