*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ──────────────────────────────────────────────── */
:root {
    color-scheme: dark;
    --bg: #1A1816;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-alt: rgba(255, 255, 255, 0.10);
    --border: rgba(255, 255, 255, 0.10);
    --accent: #E07A5F;
    --accent-soft: rgba(224, 122, 95, 0.15);
    --accent-light: #F09070;
    --text: rgba(245, 240, 235, 0.92);
    --text-muted: rgba(245, 240, 235, 0.50);
    --bg-hover: rgba(224, 122, 95, 0.12);
    --input-bg: rgba(255, 255, 255, 0.08);
    --shadow: 0 2px 12px rgba(0,0,0,0.30);
    --shadow-hover: 0 8px 28px rgba(0,0,0,0.40);
}

/* ── Base ───────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', system-ui, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 15% 85%, rgba(224,122,95,0.15) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 10%, rgba(0,0,0,0.65) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(224,122,95,0.06) 0%, transparent 45%),
        #1A1816;
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.gradient-noise {
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath fill='%23ffffff0d' d='M0 0h20v20H0z'/%3E%3C/svg%3E");
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

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

/* ── Site header ───────────────────────────────────────────────── */
.site-header {
    background: rgba(26,24,22,0.94);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 1rem;
}

.site-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.site-logo:hover { color: var(--accent-light); }

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }
.nav-link i { font-size: 1.2rem; }

/* ── User menu ─────────────────────────────────────────────────── */
.user-menu { position: relative; }

.user-menu-trigger {
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    padding: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.user-menu-trigger:hover { background: var(--bg-hover); }

.user-avatar-img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s;
    z-index: 200;
}

.user-menu.open .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: var(--text);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.15s;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--text); }

/* ── Main content ──────────────────────────────────────────────── */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 1rem;
}

/* ── Compose area ──────────────────────────────────────────────── */
.compose-area {
    display: flex;
    gap: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.compose-avatar .user-avatar-img,
.compose-avatar .user-avatar-circle {
    width: 40px;
    height: 40px;
}

.compose-body { flex: 1; min-width: 0; }

.compose-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 2.5rem;
    overflow: hidden;
}
.compose-input::placeholder { color: var(--text-muted); }

.compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.compose-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 1.3rem;
}
.compose-btn:hover { background: var(--accent-soft); }

.compose-submit {
    font-size: 0.85rem;
    padding: 0.45rem 1.2rem;
}

/* ── Image preview ─────────────────────────────────────────────── */
.image-preview {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    line-height: 1;
}

/* ── Feed ──────────────────────────────────────────────────────── */
.feed-container { display: flex; flex-direction: column; gap: 1rem; }

.post-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    transition: box-shadow 0.2s;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.post-author-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.post-author-info { flex: 1; min-width: 0; }
.post-author-name { font-weight: 600; font-size: 0.9rem; }
.post-time { font-size: 0.75rem; color: var(--text-muted); }

.post-actions-menu {
    position: relative;
}

.post-actions-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.post-actions-btn:hover { background: var(--bg-hover); color: var(--text); }

.post-actions-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 120px;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    overflow: hidden;
    display: none;
    z-index: 50;
}
.post-actions-dropdown.open { display: block; }

.post-action-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.8rem;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.post-action-item:hover { background: var(--bg-hover); }
.post-action-item.danger { color: #E05555; }

.post-text {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.6rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.post-text a { color: var(--accent); }

.post-edit-area {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.6rem;
    resize: vertical;
    min-height: 3rem;
    outline: none;
}
.post-edit-area:focus { border-color: var(--accent); }

.post-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    justify-content: flex-end;
}

/* ── Image gallery ─────────────────────────────────────────────── */
.post-images {
    display: grid;
    gap: 4px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}
.post-images.count-1 { grid-template-columns: 1fr; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 { grid-template-columns: 1fr 1fr; }
.post-images.count-4 { grid-template-columns: 1fr 1fr; }
.post-images.count-5 { grid-template-columns: 1fr 1fr 1fr; }

.post-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.15s;
    max-height: 400px;
}
.post-images.count-1 img { max-height: 500px; }
.post-images img:hover { opacity: 0.9; }

/* ── Reactions ─────────────────────────────────────────────────── */
.reaction-bar {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    border-radius: 20px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    min-height: 36px;
}
.reaction-btn:hover { background: var(--bg-hover); color: var(--text); }
.reaction-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(224,122,95,0.3);
}
.reaction-btn .reaction-emoji { font-size: 1.1rem; }
.reaction-btn .reaction-count { font-weight: 600; }

/* ── Comments ──────────────────────────────────────────────────── */
.comments-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.3rem 0;
    font-family: inherit;
}
.comments-toggle:hover { color: var(--text); }

.comments-section { margin-top: 0.5rem; }

.comment-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 0;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--panel-alt);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.comment-body {
    background: var(--input-bg);
    border-radius: 10px;
    padding: 0.4rem 0.7rem;
    flex: 1;
    min-width: 0;
}

.comment-author { font-weight: 600; font-size: 0.8rem; }
.comment-text { font-size: 0.8rem; line-height: 1.4; }
.comment-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }

.comment-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0 0.3rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.comment-item:hover .comment-delete { opacity: 1; }
.comment-delete:hover { color: #E05555; }

.add-comment-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: flex-start;
}

.add-comment-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.45rem 0.8rem;
    outline: none;
    min-height: 36px;
}
.add-comment-input:focus { border-color: var(--accent); }
.add-comment-input::placeholder { color: var(--text-muted); }

.add-comment-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
.add-comment-btn:hover { background: var(--accent-light); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.2rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent-light); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* ── Friends page ──────────────────────────────────────────────── */
.friends-page { max-width: 100%; }

.friends-search-section { margin-bottom: 1.5rem; }
.friends-search-section h2,
.friends-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.8rem;
    transition: border-color 0.15s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar i { color: var(--text-muted); font-size: 1.1rem; }
.search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-results { margin-top: 0.75rem; }

.friends-section { margin-bottom: 1.5rem; }
.friends-list { display: flex; flex-direction: column; gap: 0.5rem; }

.friend-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 600; font-size: 0.9rem; }
.friend-email { font-size: 0.75rem; color: var(--text-muted); }
.friend-status { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

.friend-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Auth ──────────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-mark-letter {
    color: #fff;
    font-weight: 700;
    font-size: 1.3rem;
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.auth-card h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.form-group input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); }

.auth-card .btn-primary {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.5rem;
}

.error-message {
    background: rgba(224,85,85,0.15);
    border: 1px solid rgba(224,85,85,0.3);
    color: #F08080;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* ── Loading ───────────────────────────────────────────────────── */
.feed-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.dot-pulse {
    display: inline-flex;
    gap: 6px;
}
.dot-pulse::before,
.dot-pulse::after,
.dot-pulse {
    content: '';
}
.dot-pulse, .dot-pulse::before, .dot-pulse::after {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s infinite ease-in-out both;
}
.dot-pulse::before { animation-delay: -0.32s; }
.dot-pulse::after { animation-delay: 0.16s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.feed-sentinel { height: 1px; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Image lightbox ────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}
.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
}

/* ── Push notification banner ──────────────────────────────────── */
.push-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--accent-soft);
    border: 1px solid rgba(224,122,95,0.25);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text);
}
.push-banner i { font-size: 1.3rem; color: var(--accent); flex-shrink: 0; }
.push-banner span { flex: 1; }
.push-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.3rem;
    line-height: 1;
}
.push-dismiss:hover { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .header-content { padding: 0 0.75rem; }
    .main-content { padding: 0.75rem; }
    .nav-label { display: none; }
    .compose-area { padding: 0.75rem; }
    .post-card { padding: 0.75rem; }
    .post-images.count-1 img { max-height: 350px; }
}
