:root {
    --brand: #b3201b;
    --brand-dark: #8f1713;
    --brand-soft: #fbe9e8;
    --bg: #eef0f3;
    --card: #ffffff;
    --ink: #1c1e21;
    --ink-2: #65676b;
    --ink-3: #8a8d91;
    --line: #e4e6eb;
    --radius: 12px;
    --top-pad: 0px;
    --bottom-pad: 0px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body.phone {
    --top-pad: 3.85rem;
    --bottom-pad: 1.2rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body.phone { height: 100vh; overflow: hidden; }
body.phone .main { height: 100vh; overflow-y: auto; padding-top: calc(var(--top-pad) + 52px); padding-bottom: var(--bottom-pad); }
body.phone .main::-webkit-scrollbar { display: none; }

button, input, textarea { font: inherit; color: inherit; }
img { display: block; }

.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

/* ---------- top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
body.phone .topbar { position: fixed; left: 0; right: 0; padding-top: var(--top-pad); }
.topbar__inner {
    max-width: 680px;
    margin: 0 auto;
    height: 52px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.logo {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 23px;
    letter-spacing: -0.04em;
    font-style: italic;
}
.logo span { font-weight: 500; opacity: .92; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar .btn--light { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar .btn--light:hover { background: rgba(255, 255, 255, .26); }

.icon-btn {
    border: 0;
    background: transparent;
    color: inherit;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.icon-btn:hover { background: rgba(0, 0, 0, .08); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .16); }

.me-btn {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
}

/* ---------- layout */
.main {
    max-width: 680px;
    margin: 0 auto;
    padding: 14px 12px 40px;
}
body.phone .main { padding-left: 10px; padding-right: 10px; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
    margin-bottom: 12px;
}

/* ---------- avatar */
.avatar {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--brand-soft) center/cover no-repeat;
    color: var(--brand);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 16px;
    text-transform: uppercase;
    overflow: hidden;
}
.avatar--sm { width: 32px; height: 32px; font-size: 13px; }
.avatar--lg { width: 84px; height: 84px; font-size: 32px; }
.avatar--xl { width: 96px; height: 96px; font-size: 36px; border: 4px solid #fff; }
.topbar .avatar { width: 34px; height: 34px; font-size: 14px; background-color: rgba(255, 255, 255, .92); }

/* ---------- buttons */
.btn {
    border: 0;
    border-radius: 8px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn--ghost { background: #f0f2f5; color: var(--ink); }
.btn--ghost:hover:not(:disabled) { background: #e4e6eb; }
.btn--block { width: 100%; }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f5f6f7;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 400;
    color: var(--ink);
    outline: none;
    resize: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }
.field__row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #f5f6f7; }
.field__row:focus-within { border-color: var(--brand); background: #fff; }
.field__row i { font-style: normal; color: var(--ink-3); padding-left: 12px; }
.field__row input { border: 0; background: transparent; padding-left: 4px; }

/* ---------- register */
.register { padding: 24px 20px; text-align: center; }
.register h1 { margin: 12px 0 6px; font-size: 22px; }
.register p { margin: 0 0 18px; line-height: 1.45; font-size: 14px; }
.register .field { text-align: left; margin-bottom: 12px; }
.register__mark {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 16px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    font-size: 34px;
    font-style: italic;
    display: grid;
    place-items: center;
}

/* ---------- guest */
.guest { padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.guest .muted { flex: 1 1 260px; font-size: 13.5px; }

/* ---------- composer */
.composer { padding: 12px; }
.composer__row { display: flex; gap: 10px; }
.composer textarea {
    flex: 1;
    border: 0;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 15px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 160px;
}
.composer__preview { position: relative; margin: 10px 0 0 50px; }
.composer__preview img { max-height: 220px; max-width: 100%; border-radius: 10px; }
.chip-x {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}
.composer__bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.composer__bar .counter { margin-left: auto; font-size: 12px; color: var(--ink-3); }

/* ---------- post */
.post { padding: 12px 14px 4px; }
.post__head { display: flex; align-items: center; gap: 10px; }
.post__who { min-width: 0; flex: 1; line-height: 1.25; }
.post__name {
    font-weight: 700;
    cursor: pointer;
    border: 0;
    background: none;
    padding: 0;
    text-align: left;
    font-size: 15px;
}
.post__name:hover { text-decoration: underline; }
.post__meta { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    vertical-align: 2px;
}
.post__text { margin: 10px 0 0; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.45; }
.post__img {
    margin: 10px -14px 0;
    background: #000;
    cursor: zoom-in;
}
.post__img img { width: 100%; max-height: 520px; object-fit: contain; }
.post__stats { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 13px; padding: 8px 0 6px; }
.post__stats button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 13px; }
.post__stats button:hover { text-decoration: underline; }
.post__actions { display: flex; border-top: 1px solid var(--line); padding: 2px 0; }
.act {
    flex: 1;
    border: 0;
    background: none;
    padding: 8px 4px;
    border-radius: 6px;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.act:hover { background: #f0f2f5; }
.act--on { color: var(--brand); }
.act svg { width: 18px; height: 18px; }

.menu-btn { color: var(--ink-3); font-size: 20px; width: 32px; height: 32px; }

/* ---------- profile header */
.profile { overflow: hidden; }
.profile__cover { height: 96px; background: linear-gradient(120deg, var(--brand) 0%, #e2552c 100%); }
.profile__body { padding: 0 16px 16px; margin-top: -48px; }
.profile__name { margin: 8px 0 0; font-size: 21px; font-weight: 800; }
.profile__user { color: var(--ink-3); font-size: 14px; }
.profile__bio { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.profile__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.profile__stats { margin-top: 10px; color: var(--ink-2); font-size: 13.5px; }

/* ---------- sheets */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .15s ease; }
.sheet__panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 86vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    animation: up .2s ease;
    padding-bottom: var(--bottom-pad);
}
@media (min-width: 700px) {
    body:not(.phone) .sheet { align-items: center; }
    body:not(.phone) .sheet__panel { border-radius: 16px; max-height: 80vh; }
}
.sheet__panel--narrow { max-width: 400px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); font-size: 16px; }
.sheet__body { padding: 14px 16px; overflow-y: auto; }
.sheet__foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.sheet__foot input {
    flex: 1;
    border: 0;
    border-radius: 20px;
    background: #f0f2f5;
    padding: 10px 14px;
    font-size: 15px;
    outline: none;
    min-width: 0;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- comments */
.comment { display: flex; gap: 8px; margin-bottom: 12px; }
.comment__bubble { background: #f0f2f5; border-radius: 14px; padding: 7px 12px; max-width: calc(100% - 40px); }
.comment__bubble b { font-size: 13.5px; cursor: pointer; }
.comment__bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.4; }
.comment__meta { font-size: 12px; color: var(--ink-3); margin: 3px 0 0 12px; display: flex; gap: 12px; }
.comment__meta button { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; font-size: 12px; cursor: pointer; }
.empty { text-align: center; color: var(--ink-3); padding: 22px 0; font-size: 14px; }

/* ---------- edit profile */
.edit-avatar { display: flex; align-items: center; gap: 14px; }
.edit-avatar__btns { display: flex; flex-direction: column; gap: 6px; }
.pw-box { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.pw-box p { margin: 0; }

/* ---------- misc */
.list-end { text-align: center; padding: 6px 0 18px; color: var(--ink-3); font-size: 13px; }
.list-end .btn { margin-top: 2px; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .92); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--bottom-pad));
    transform: translateX(-50%);
    z-index: 70;
    background: #1c1e21;
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    max-width: 90vw;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    animation: up .2s ease;
}
.toast--err { background: var(--brand); }

.new-pill {
    position: sticky;
    top: 62px;
    z-index: 10;
    display: block;
    margin: 0 auto 10px;
    border: 0;
    border-radius: 18px;
    padding: 7px 16px;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(179, 32, 27, .35);
}
