/* Fixed black/red theme (no light mode) — matches exceptionerror.com's login page. */
:root {
    --bg: #000000;
    --card: #141414;
    --field: #1a1a1a;
    --text: #f2f2f2;
    --muted: #9a7a7a;
    --border: #3a1414;
    --accent: #ff0000;
    --accent-dark: #8b0000;
    --accent-text: #ffffff;
    --pill-text: #ffcccc;
    --error: #ff6b6b;
}

* { box-sizing: border-box; }

html { font-size: 17px; } /* everything sized in rem scales from here */

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    padding-top: 52px; /* space for the fixed .topbar */
}

.wrap {
    max-width: 620px;
    margin: 0 auto;
    padding: 24px 16px 96px;
}

h1 { font-size: 1.5rem; margin: 4px 0 20px; }

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

.card.sponsored { border-color: var(--accent); }
.sponsored-tag { color: var(--accent); font-weight: 600; }

/* ---- forms ---- */
input, textarea {
    width: 100%;
    padding: 9px 11px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

/* Single-line auth fields get the reference site's pill shape. */
.field input {
    border-radius: 24px;
    padding: 11px 18px;
}

input:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: transparent;
}

.btn {
    padding: 9px 22px;
    border: 2px solid var(--accent);
    border-radius: 30px;
    background: var(--field);
    color: var(--pill-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, color .2s, box-shadow .2s, transform .2s;
}
.btn:hover:not(:disabled) {
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 4px 15px rgba(255, 0, 0, .4);
    transform: translateY(-1px);
}

.btn:disabled { opacity: .5; cursor: default; }

.new-post-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.file-label {
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
    font-size: .9rem;
    user-select: none;
}
.file-label:hover { color: var(--accent); }

.image-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.preview-tile {
    position: relative;
    width: 84px;
    height: 84px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.preview-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}
.preview-remove:hover { background: var(--accent); }

/* ---- posts ---- */
.post-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    display: grid;
    place-items: center;
    font-weight: 700;
    flex-shrink: 0;
}

.author { font-weight: 600; }
.time { color: var(--muted); font-size: .85rem; }

.post-body {
    margin: 0 0 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-weight: 500;
}

.post-image {
    display: block;
    width: 100%;
    max-height: 520px;
    object-fit: cover;
    border-radius: 10px;
    margin: 0 0 10px;
    background: var(--bg);
}

/* 2+ images: a cropped grid; each tile links to the full-size original. */
.post-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 4px;
    margin: 0 0 10px;
    border-radius: 10px;
    overflow: hidden;
}
.post-image-tile { display: block; aspect-ratio: 1 / 1; background: var(--bg); }
.post-image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.post-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.link-btn {
    border: none;
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover { color: var(--accent); }
.link-btn.small { font-size: .82rem; }

/* ---- likes / dislikes ---- */
.votes {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.vote-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1;
    padding: 4px 5px;
    border-radius: 6px;
}
.vote-btn:hover { background: var(--border); }
.vote-btn:disabled { cursor: default; opacity: .5; }
.vote-btn.up.active { color: #4ade80; }
.vote-btn.down.active { color: var(--accent); }

.vote-count {
    font-size: .85rem;
    color: var(--muted);
    min-width: 1ch;
    text-align: left;
}

/* ---- comments ---- */
.comments { margin-top: 12px; }

.comment-list { list-style: none; margin: 0 0 12px; padding: 0; }

.comment {
    border-top: 1px solid var(--border);
    padding: 10px 0 6px;
}

.comment-meta { font-size: .85rem; }
.c-author { font-weight: 600; }
.c-body { margin: 3px 0 6px; white-space: pre-wrap; word-wrap: break-word; font-weight: 500; }

.comment-image {
    display: block;
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 8px;
    margin: 4px 0 8px;
    background: var(--bg);
}

/* 2+ images on a comment: a compact grid, smaller than a post's. */
.comment-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 4px;
    max-width: 320px;
    margin: 4px 0 8px;
    border-radius: 8px;
    overflow: hidden;
}
.comment-image-tile { display: block; aspect-ratio: 1 / 1; background: var(--bg); }
.comment-image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* image add/remove row inside a post's edit box */
.image-edit-row { margin-bottom: 8px; }
.image-edit-row .image-previews { margin-bottom: 8px; }
.file-label.small { font-size: .8rem; }

.comment-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}


/* nested replies: a threading line + a little indent, capped by JS at depth 4 */
.comment-list.replies {
    margin: 0 0 0 14px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}
.comment-list.replies .comment:first-child { border-top: none; padding-top: 4px; }

.comment-form {
    margin-top: 8px;
}
.form-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ---- misc ---- */
.status { text-align: center; color: var(--muted); min-height: 1.2em; }
.muted { color: var(--muted); }
.error { color: var(--error); }
#sentinel { height: 1px; }

/* ---- top bar (fixed, full-width) ---- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    background: #000;
    border-bottom: 1px solid var(--accent-dark);
    z-index: 1000;
}
.brand { font-size: 1.2rem; font-weight: 900; color: var(--accent); text-decoration: none; letter-spacing: .01em; }
.authbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { font-weight: 900; color: var(--accent); text-decoration: none; }
.who:hover { color: #fff; }
.author-link { color: inherit; text-decoration: none; }
.author-link:hover { text-decoration: underline; }

.authbox .link-btn {
    color: var(--pill-text);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 6px 14px;
    font-weight: 600;
}
.authbox .link-btn:hover { background: var(--accent-dark); color: #fff; }

.btn.small { padding: 5px 12px; font-size: .85rem; }
.ok { color: #4ade80; }
.tag { color: var(--muted); font-size: .8rem; text-decoration: none; }
a.tag:hover { color: var(--accent); text-decoration: underline; }

.banner {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: .9rem;
}

/* ---- auth: modal ---- */
#auth-modal {
    position: relative;
    width: min(26rem, calc(100vw - 32px));
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 22px;
    background: #0d0d0d;
    color: var(--text);
    box-shadow: 0 0 30px rgba(255, 0, 0, .3);
}
#auth-modal::backdrop { background: rgba(0, 0, 0, .7); }

#util-modal {
    position: relative;
    width: min(32rem, calc(100vw - 32px));
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 22px;
    background: #0d0d0d;
    color: var(--text);
    box-shadow: 0 0 30px rgba(255, 0, 0, .3);
}
#util-modal::backdrop { background: rgba(0, 0, 0, .7); }
#util-modal-body h2 {
    margin: 0 0 14px;
    padding: 0 34px 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Close button sits in the corner so the title can start at the top-left. */
.modal-x { position: absolute; top: 14px; right: 14px; margin: 0; z-index: 1; }
.modal-x button {
    border: none; background: none; color: var(--muted);
    font-size: 2rem; line-height: 1; cursor: pointer;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { margin: 0; padding-right: 34px; font-size: 1.2rem; }

.btn-google {
    text-align: center;
    text-decoration: none;
    border-color: var(--border);
    background: var(--field);
    color: var(--pill-text);
}
.btn.btn-google:hover {
    background: var(--field);
    color: var(--accent);
    box-shadow: none;
    border-color: var(--accent);
}
.auth-divider {
    margin: -4px 0;
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
}
.google-btn-wrap { display: flex; flex-direction: column; gap: 6px; }
.google-btn-wrap .muted { text-align: center; margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.field input { margin: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; margin: 0; }

.acct-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 14px;
}
.acct-section h3 { margin: 0; font-size: .95rem; }
.acct-section .btn { align-self: flex-start; }
.acct-section.danger h3 { color: var(--error); }

/* ---- owner edit / delete ---- */
.post-head { position: relative; }
.owner-menu { display: flex; gap: 10px; margin-left: auto; }
.link-btn.danger { color: var(--error); }
.link-btn.danger:hover { color: #b91c1c; }

.edit-box { margin: 4px 0 10px; }
.edit-area { width: 100%; margin-bottom: 8px; }

.comment.is-deleted > .c-body { font-style: italic; }

/* ---- following sidebar ---- */
.layout {
    display: flex;
    gap: 28px;
    justify-content: center;
    align-items: flex-start;
}
.sidebar {
    width: 220px;
    flex-shrink: 0;
    order: -1; /* left rail, ahead of .wrap in the flex row — conventional placement */
    position: sticky;
    top: 68px; /* clears the fixed 52px topbar + a gap */
    margin-left: 5px;
    padding: 24px 4px 24px 0;
}
.sidebar-title { font-size: 1rem; margin: 0 0 10px; }

.follow-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 7px;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
}
.follow-row:hover { background: var(--card); }

.follow-badge {
    background: var(--accent);
    color: var(--accent-text);
    font-size: .72rem;
    font-weight: 700;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 .35em;
    border-radius: 1em;
    display: grid;
    place-items: center;
}

.profile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.profile-head h2 { margin: 0; font-size: 1.2rem; }
.btn.small.is-following {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

@media (max-width: 900px) {
    .layout { flex-direction: column; align-items: stretch; }
    .sidebar {
        width: auto;
        position: static;
        padding: 8px 16px 0;
    }
    .sidebar-title { margin-bottom: 6px; }
    #following-list { display: flex; flex-wrap: wrap; gap: 6px; }
    .follow-row { border: 1px solid var(--border); }
}

/* ---- sidebar: friends / following ---- */
.sidebar-section {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.sidebar-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.sidebar-head .sidebar-title { margin: 0; }

.add-btn {
    margin-left: auto;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid var(--accent);
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.add-btn span { transform: translateY(-1px); }
.add-btn:hover { background: var(--accent); color: #fff; }

.inline-add {
    display: flex;
    gap: 6px;
    flex: 1 1 100%; /* own row under the title whenever it doesn't fit beside it */
}
.inline-add input {
    flex: 1;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 6px 10px;
    font-size: .82rem;
}
.inline-add button { flex-shrink: 0; }
.tiny-check { flex-shrink: 0; font-size: .72rem; color: var(--muted); gap: 4px; }
.group-add-form { flex-wrap: wrap; }
.group-add-actions { display: flex; gap: 8px; flex: 1 1 100%; }

.modal-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.group-discovery { display: flex; flex-direction: column; gap: 8px; }
.group-discovery > input { margin: 0; }

.group-results {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.group-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.group-result-row:last-child { border-bottom: none; }
.group-result-info p { margin: 2px 0 0; }
.group-result-name { color: var(--pill-text); font-weight: 700; text-decoration: none; }
.group-result-name:hover { color: var(--accent); }

.person-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: .88rem;
}
.person-row > a, .person-row > span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.person-actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn.tiny {
    padding: 4px 10px;
    font-size: .72rem;
    border-width: 1px;
}
.btn.tiny.is-following { background: transparent; color: var(--muted); border-color: var(--border); }

/* ---- feed tabs + search ---- */
.feed-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.feed-tab {
    background: none;
    border: none;
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    padding: 8px 6px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.feed-tab:hover { color: var(--text); }
.feed-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- admin ---- */
.admin-main { max-width: 800px; margin: 0 auto; padding: 20px 16px; }
.admin-main h1 { font-size: 1.1rem; margin: 0 0 12px; }
.admin-main h2 { font-size: .85rem; color: var(--muted); margin: 0 0 6px; }

.admin-totals { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.admin-stat {
    flex: 1 1 90px;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}
.admin-stat-value { font-size: 1.3rem; font-weight: 900; color: var(--accent); }
.admin-stat-label { font-size: .75rem; color: var(--muted); }

.admin-chart { margin-bottom: 16px; }
.admin-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}
.admin-bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }

.admin-users { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 10px; }
.admin-users th, .admin-users td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.admin-users th { color: var(--muted); font-weight: 600; font-size: .75rem; }

.admin-pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

/* ---- group invites ---- */
.desc-row { display: flex; align-items: baseline; gap: 8px; }
.desc-row p { margin: 0; }

.invite-manager { display: flex; flex-direction: column; gap: 4px; }
.invite-manager h2 { margin: 0; font-size: 1.1rem; }
.invite-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.invite-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    flex-wrap: wrap;
}
.invite-url { flex: 1 1 auto; min-width: 0; color: var(--pill-text); font-size: .8rem; overflow-wrap: anywhere; }
