* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #0b0b0b;
    color: #f2f2f2;
    font-family: Arial, Helvetica, sans-serif;
}

/* TOP BAR */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #222;
    background: #111;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    margin: 0;
    font-size: 32px;
    color: #ffffff;
}

.tagline {
    margin-top: 5px;
    color: #888;
    font-size: 13px;
}

.identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.identity img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #222;
}

/* POST FORM */

.post-form {
    padding: 20px;
    border-bottom: 1px solid #222;
}

textarea {
    width: 100%;
    height: 120px;
    background: #161616;
    border: 1px solid #333;
    color: white;
    padding: 15px;
    resize: vertical;
    border-radius: 10px;
    font-size: 15px;
}

input[type="text"] {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: #161616;
    border: 1px solid #333;
    border-radius: 10px;
    color: white;
}

button {
    margin-top: 12px;
    padding: 12px 20px;
    background: #ffffff;
    color: black;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    opacity: 0.9;
}

/* POSTS CONTAINER */

.posts {
    max-width: 900px;
    margin: auto;
    padding: 20px;
}

/* THREAD STRUCTURE */

.replies {
    margin-left: 28px;
    padding-left: 16px;
    border-left: 2px solid #333;
}

/* REPLY CARDS */

.reply-post {
    background: #141414;
    border: 1px solid #222;
    border-radius: 14px;
    padding: 16px;
    margin-top: 14px;
    position: relative;
}

/* VISUAL DEPTH */

.depth-2 .reply-post {
    border-left: 3px solid #2f2f2f;
}

.depth-3 .reply-post,
.depth-4 .reply-post {
    border-left: 3px solid #1f1f1f;
}

/* POST HEADER */

.post-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.post-header img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #222;
}

.username {
    font-weight: bold;
    font-size: 16px;
}

.time {
    color: #888;
    font-size: 12px;
    margin-top: 3px;
}

/* MESSAGE TEXT */

.message {
    line-height: 1.6;
    word-wrap: break-word;
    padding-right: 6px;
}

/* GIF */

.gif {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 12px;
}

/* REPLY BUTTON */

.reply-btn {
    margin-top: 8px;
    background: #222;
    color: white;
    border: 1px solid #333;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
}

.reply-btn:hover {
    background: #333;
}

/* REPLY LABEL */

.replying-label {
    color: #7aa2ff;
    font-size: 12px;
    margin-bottom: 10px;
    opacity: 0.9;
}

/* OP BADGE */

.op-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #000;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 7px;
    border-radius: 999px;
    margin-right: 6px;
}

/* COLLAPSED THREADS */

.collapsed-thread {
    margin-top: 12px;
}

.collapsed-thread summary {
    cursor: pointer;
    color: #8ab4ff;
    font-size: 13px;
    margin-bottom: 10px;
    user-select: none;
}

/* MOBILE */

@media (max-width: 700px) {

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .posts {
        padding: 10px;
    }

    .replies {
        margin-left: 0 !important;
        padding-left: 10px;
        border-left: 1px solid #2f2f2f;
    }

    .reply-post {
        padding: 12px;
    }

    .post-header img {
        width: 42px;
        height: 42px;
    }

    .username {
        font-size: 14px;
    }

    .replying-label {
        font-size: 11px;
    }
}

/* GIF PICKER (ONLY ONE CLEAN VERSION) */

#gif-picker {
    display: none;
    position: fixed;
    left: 10px;
    right: 10px;
    top: 80px;
    bottom: 80px;
    background: #111;
    border: 1px solid #222;
    border-radius: 12px;
    padding: 12px;
    z-index: 999;
    overflow: hidden;
}

#gif-search {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    background: #1a1a1a;
    border: 1px solid #333;
    color: white;
    border-radius: 10px;
}

#gif-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: calc(100% - 60px);
    overflow-y: auto;
}

.gif-option {
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
}

.gif-option:hover {
    border-color: #7aa2ff;
}

.gif-selected {
    border-color: #7aa2ff;
}

#gif-preview img {
    max-width: 180px;
    border-radius: 10px;
    border: 1px solid #333;
    margin-top: 10px;
}

#remove-gif {
    margin-top: 6px;
    background: #222;
    color: white;
    border: 1px solid #333;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
}

/* =========================
   FIX: THREAD INDENT VISUALS
   (restores clean nesting look)
========================= */

.depth-1,
.depth-2,
.depth-3,
.depth-4 {
    position: relative;
}

/* vertical thread line */
.depth-1::before,
.depth-2::before,
.depth-3::before,
.depth-4::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.08);
}

/* extra spacing so text doesn’t touch edges */
.reply-post {
    padding: 18px;
}

/* make nested replies breathe more */
.depth-2 .reply-post { margin-left: 10px; }
.depth-3 .reply-post { margin-left: 20px; }
.depth-4 .reply-post { margin-left: 30px; }

/* =========================
   FIX: GIF PICKER STABILITY
========================= */

#gif-picker {
    max-height: 70vh;
    overflow: hidden;
}

#gif-results {
    max-height: calc(70vh - 60px);
    overflow-y: auto;
}

/* =========================
   FIX: MOBILE SAFETY (DO NOT BREAK LAYOUT)
========================= */

@media (max-width: 700px) {

    .depth-2 .reply-post,
    .depth-3 .reply-post,
    .depth-4 .reply-post {
        margin-left: 0;
    }

    .depth-1::before,
    .depth-2::before,
    .depth-3::before,
    .depth-4::before {
        display: none;
    }
}