/* =====================================================================
   FORUM.CSS — Thread Digest Button System & Layout
   Consolidated, de-duplicated, canonical source.
   ===================================================================== */

/* ===================== DESIGN TOKENS ===================== */
:root {
    --td-space-xs:  4px;
    --td-space-sm:  8px;
    --td-space-md:  12px;
    --td-space-lg:  16px;
    --td-space-xl:  24px;
    --td-space-2xl: 32px;
    --td-space-3xl: 48px;

    --td-radius-sm:  4px;
    --td-radius-md:  8px;
    --td-radius-lg:  12px;
    --td-radius-xl:  16px;

    --td-primary:          #3b82f6;
    --td-primary-dark:     #2563eb;

    --td-positive:         #4CAF50;
    --td-positive-dark:    #45a049;

    --td-negative:         #f44336;
    --td-negative-dark:    #e53935;

    --td-destructive:      #dc3545;
    --td-destructive-dark: #c82333;

    --td-secondary:        #6c757d;
    --td-secondary-dark:   #545b62;

    --td-info:             #2196F3;
    --td-info-dark:        #1e88e5;

    --td-hot:              #f59e0b;
    --td-hot-dark:         #d97706;
    --td-hot-border:       #b45309;

    --td-text:             #333;
    --td-text-muted:       #64748b;
    --td-text-light:       #888;

    --td-border:           #e2e8f0;
    --td-bg:               #f8fafc;
    --td-bg-white:         #ffffff;

    --td-shadow-sm:        0 2px 4px rgba(0,0,0,.06);
    --td-shadow-md:        0 4px 12px rgba(30,41,59,.08);
    --td-shadow-lg:        0 8px 25px rgba(0,0,0,.15);

    --td-reply-blue-bg:    #c7e0ff;
    --td-reply-blue-bdr:   #007bff;
    --td-reply-gold-bg:    #fff3b3;
    --td-reply-gold-bdr:   #FFD700;

    --td-offspring-blue:   rgba(0,123,255,.55);
    --td-offspring-gold:   rgba(255,215,0,.55);
}


/* ===================== GLOBAL STYLES ===================== */
body {
    font-family: Arial, sans-serif;
    background: url('/images/misc/pcbg.jpg') no-repeat center center fixed;
    background-size: cover;
    padding: 20px;
    color: var(--td-text);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255,255,255,0.9);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

button {
    font-family: inherit;
    cursor: pointer;
}


/* ===================== BUTTON SYSTEM ===================== */

/* Base class — all intent variants build on this */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--td-space-sm);
    padding: var(--td-space-sm) var(--td-space-lg);
    margin: var(--td-space-xs);
    font-family: inherit;
    font-weight: 600;
    font-size: .9em;
    letter-spacing: .3px;
    line-height: 1.4;
    border: none;
    border-radius: var(--td-radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease, opacity .15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,.15);
}
.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    opacity: .9;
}

/* ── Intent variants ── */
.btn--primary {
    background: var(--td-primary);
    color: #fff;
    padding: var(--td-space-md) var(--td-space-xl);
    font-size: .95em;
    box-shadow: 0 2px 8px rgba(59,130,246,.35);
}
.btn--primary:hover {
    background: var(--td-primary-dark);
    box-shadow: 0 4px 14px rgba(59,130,246,.45);
}

.btn--secondary {
    background: var(--td-secondary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(108,117,125,.3);
}
.btn--secondary:hover {
    background: var(--td-secondary-dark);
    box-shadow: 0 4px 10px rgba(108,117,125,.4);
}

.btn--subtle {
    background: #fff;
    color: var(--td-text-muted);
    border: 1.5px solid var(--td-border);
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.btn--subtle:hover {
    background: var(--td-bg);
    color: var(--td-text);
    border-color: #94a3b8;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

.btn--positive {
    background: var(--td-positive);
    color: #fff;
    box-shadow: 0 2px 6px rgba(76,175,80,.35);
}
.btn--positive:hover {
    background: var(--td-positive-dark);
    box-shadow: 0 4px 10px rgba(76,175,80,.45);
}

.btn--negative {
    background: var(--td-negative);
    color: #fff;
    box-shadow: 0 2px 6px rgba(244,67,54,.3);
}
.btn--negative:hover {
    background: var(--td-negative-dark);
    box-shadow: 0 4px 10px rgba(244,67,54,.4);
}

.btn--destructive {
    background: var(--td-destructive);
    color: #fff;
    box-shadow: 0 2px 6px rgba(220,53,69,.3);
}
.btn--destructive:hover {
    background: var(--td-destructive-dark);
    box-shadow: 0 4px 10px rgba(220,53,69,.4);
}

.btn--info {
    background: var(--td-info);
    color: #fff;
    box-shadow: 0 2px 6px rgba(33,150,243,.3);
}
.btn--info:hover {
    background: var(--td-info-dark);
    box-shadow: 0 4px 10px rgba(33,150,243,.4);
}

/* ── Size modifiers ── */
.btn--sm {
    padding: 4px 12px;
    font-size: .8em;
    border-radius: var(--td-radius-sm);
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.btn--sm:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.btn--lg {
    padding: var(--td-space-md) var(--td-space-2xl);
    font-size: 1.05em;
}

/* ── Shape modifier ── */
.btn--pill {
    border-radius: 999px;
}


/* ===================== SPECIALTY BUTTONS =====================
   These live outside the .btn class but follow the same token system.
   ============================================================= */

/* Show / Toggle Replies — outlined primary style */
.show-replies-btn,
.toggle-replies-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--td-space-sm);
    padding: 5px 14px;
    margin: var(--td-space-xs);
    font-family: inherit;
    font-weight: 600;
    font-size: .85em;
    letter-spacing: .3px;
    line-height: 1.4;
    background: #fff;
    color: var(--td-primary);
    border: 1.5px solid var(--td-primary);
    border-radius: var(--td-radius-md);
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(59,130,246,.12);
    transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.show-replies-btn:hover,
.toggle-replies-btn:hover {
    background: var(--td-primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(59,130,246,.3);
    transform: translateY(-1px);
}
.show-replies-btn:active,
.toggle-replies-btn:active {
    transform: translateY(0);
    opacity: .9;
}

/* Reply submit button (inside .reply-input, outside .btn system) */
.reply-submit-btn:not(.btn) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    margin-top: 10px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .3px;
    background: var(--td-primary);
    color: #fff;
    border: none;
    border-radius: var(--td-radius-md);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59,130,246,.3);
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.reply-submit-btn:not(.btn):hover {
    background: var(--td-primary-dark);
    box-shadow: 0 4px 14px rgba(59,130,246,.4);
    transform: translateY(-1px);
}
.reply-submit-btn:not(.btn):active {
    transform: translateY(0);
    opacity: .9;
}


/* ===================== FULL-THREAD BUTTON ROW =====================
   renderSingleReply emits buttons inside a bare <div> with no class.
   We target the wrapper that holds reply/delete/moderate actions, and
   also style the raw .reaction-btn classes used in the full thread view
   (distinct from .btn--positive / .btn--negative used in digest cards).
   ================================================================== */

/* Button action row — wraps Reply, Delete, Moderate inside each reply */
.reply-container > div:has(.reply-btn),
.reply-wrapper > div:has(.reply-btn) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

/* Fallback for browsers without :has() — explicit class hook */
.reply-btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

/* ── Raw reaction buttons (full thread / renderSingleReply path) ──
   These do NOT have .btn on them. Style them to match .btn base + intent. */
.reaction-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    margin: 2px;
    font-family: inherit;
    font-weight: 600;
    font-size: .85em;
    letter-spacing: .3px;
    line-height: 1.4;
    border: none;
    border-radius: var(--td-radius-md);
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.reaction-btn:hover  { transform: translateY(-1px); }
.reaction-btn:active { transform: translateY(0); opacity: .9; }

/* Positive reaction button */
.reaction-btn.positive-btn {
    background: var(--td-positive);
    color: #fff;
    box-shadow: 0 2px 6px rgba(76,175,80,.35);
}
.reaction-btn.positive-btn:hover {
    background: var(--td-positive-dark);
    box-shadow: 0 4px 10px rgba(76,175,80,.45);
}

/* Negative reaction button */
.reaction-btn.negative-btn {
    background: var(--td-negative);
    color: #fff;
    box-shadow: 0 2px 6px rgba(244,67,54,.3);
}
.reaction-btn.negative-btn:hover {
    background: var(--td-negative-dark);
    box-shadow: 0 4px 10px rgba(244,67,54,.4);
}

/* Show Reactions button */
.reaction-btn.show-reactions-btn {
    background: var(--td-info);
    color: #fff;
    box-shadow: 0 2px 6px rgba(33,150,243,.3);
}
.reaction-btn.show-reactions-btn:hover {
    background: var(--td-info-dark);
    box-shadow: 0 4px 10px rgba(33,150,243,.4);
}

/* Reaction dropdown items inside full-thread dropdowns */
.reaction-options .reaction-btn,
.reaction-dropdown .reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: .82em;
    font-weight: 600;
    margin: 3px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .12s;
    line-height: 1.4;
}
.reaction-dropdown--positive .reaction-btn,
.reaction-options.reaction-dropdown--positive .reaction-btn {
    background: #e8f5e9;
    color: #2e7d32;
    box-shadow: 0 1px 3px rgba(76,175,80,.18);
}
.reaction-dropdown--positive .reaction-btn:hover,
.reaction-options.reaction-dropdown--positive .reaction-btn:hover {
    background: #c8e6c9;
    box-shadow: 0 3px 8px rgba(76,175,80,.28);
    transform: translateY(-1px);
}
.reaction-dropdown--negative .reaction-btn,
.reaction-options.reaction-dropdown--negative .reaction-btn {
    background: #fdecea;
    color: #c62828;
    box-shadow: 0 1px 3px rgba(244,67,54,.18);
}
.reaction-dropdown--negative .reaction-btn:hover,
.reaction-options.reaction-dropdown--negative .reaction-btn:hover {
    background: #ffcdd2;
    box-shadow: 0 3px 8px rgba(244,67,54,.28);
    transform: translateY(-1px);
}

/* Total reactions container */
.total-reactions {
    margin-top: 6px;
    font-size: .85em;
    color: var(--td-text-muted);
    line-height: 1.5;
}
.total-reactions--hidden { display: none; }

/* OP reaction buttons use .btn classes — make sure they sit in a flex row */
.op-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
}

/* Reaction options containers (full thread + OP) — hidden by default */
.reaction-options {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-lg);
    box-shadow: 0 6px 20px rgba(0,0,0,.10);
}
.reaction-options.is-open,
.reaction-options[style*="display: flex"],
.reaction-options[style*="display:flex"] {
    display: flex !important;
}

/* Elevate the host container above sibling offspring containers when a
   reaction dropdown is open.  Each .reply-container temporarily forms a
   CSS stacking context during its fade-in transition (transform != none);
   without an explicit z-index the container sits at z-index:auto and
   later siblings in DOM order paint on top of it — hiding the dropdown.
   Giving the container z-index:10 makes its whole stacking context rise
   above the z-index:auto siblings.  The :has() selector automatically
   resets once the dropdown's inline display:none is restored. */
.reply-container:has(> .reaction-dropdown[style*="display: block"]),
.op-container:has(> .reaction-dropdown[style*="display: block"]),
.post-container:has(> .reaction-dropdown[style*="display: block"]) {
    z-index: 10;
}

/* Focus mode button — sits inline with action buttons */
.focus-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 9px;
    font-size: .82em;
    background: none;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-sm);
    color: var(--td-text-muted);
    cursor: pointer;
    margin: 2px;
    transition: background .15s, color .15s;
    line-height: 1.4;
}
.focus-mode-btn:hover {
    background: var(--td-bg);
    color: var(--td-text);
}


/* ── Digest-card reaction dropdown items (.reaction-dropdown__item path) ── */
.reaction-dropdown {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.reaction-dropdown.is-open {
    display: flex;
}
.reaction-dropdown__item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: .82em;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .12s;
    line-height: 1.4;
}
.reaction-dropdown--positive .reaction-dropdown__item {
    background: #e8f5e9;
    color: #2e7d32;
    box-shadow: 0 1px 3px rgba(76,175,80,.18);
}
.reaction-dropdown--positive .reaction-dropdown__item:hover {
    background: #c8e6c9;
    box-shadow: 0 3px 8px rgba(76,175,80,.28);
    transform: translateY(-1px);
}
.reaction-dropdown--negative .reaction-dropdown__item {
    background: #fdecea;
    color: #c62828;
    box-shadow: 0 1px 3px rgba(244,67,54,.18);
}
.reaction-dropdown--negative .reaction-dropdown__item:hover {
    background: #ffcdd2;
    box-shadow: 0 3px 8px rgba(244,67,54,.28);
    transform: translateY(-1px);
}


/* ===================== MODERATION DROPDOWN ===================== */
.moderation-dropdown {
    display: inline-block;
    position: relative;
    margin: var(--td-space-xs);
}
.moderation-dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1000;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-md);
    box-shadow: var(--td-shadow-lg);
    padding: 4px 0;
}
.moderation-dropdown-content.is-open {
    display: block;
}
.dropdown-item {
    display: block;
    width: 100%;
    padding: 9px 14px;
    font-family: inherit;
    font-size: .88em;
    font-weight: 500;
    color: var(--td-text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
}
.dropdown-item:hover {
    background: var(--td-bg);
}
.dropdown-item--delete {
    color: var(--td-destructive);
}
.dropdown-item--delete:hover {
    background: #fff5f5;
}
.dropdown-item--mute {
    color: var(--td-secondary);
}
.dropdown-item--view {
    color: var(--td-info);
}
.dropdown-item--panel {
    color: var(--td-text-muted);
    border-top: 1px solid var(--td-border);
    margin-top: 4px;
    padding-top: 10px;
}


/* ===================== SHOW/HIDDEN REPLIES GROUP ===================== */
.show-replies-group {
    margin: 12px 0 0 0;
    padding: 10px 0 0 0;
    border-top: 1px dashed #b3c6e0;
    background: rgba(240,247,255,0.7);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0,123,255,.04);
    transition: background .2s;
}
.show-replies-group .show-replies-btn {
    display: block;
    margin: 0 auto 8px auto;
    width: fit-content;
}

.hidden-replies {
    margin-top: 8px;
    padding-left: 12px;
    border-left: 2px solid #e0e7ef;
    background: rgba(255,255,255,0.6);
    border-radius: 0 0 8px 8px;
}
.hidden-replies[style*="display: none"],
.hidden-replies[hidden] {
    display: none;
}


/* ===================== REPLY CARD GROUPS ===================== */
.reply-card-blue.reply-card-group {
    background: var(--td-reply-blue-bg);
    border: 2px solid var(--td-reply-blue-bdr);
    border-radius: 14px;
    margin-bottom: 28px;
    padding: 18px 18px 8px 18px;
    box-shadow: 0 2px 8px rgba(0,123,255,.07);
}
.reply-card-gold.reply-card-group {
    background: var(--td-reply-gold-bg);
    border: 2px solid var(--td-reply-gold-bdr);
    border-radius: 14px;
    margin-bottom: 28px;
    padding: 18px 18px 8px 18px;
    box-shadow: 0 2px 8px rgba(255,215,0,.07);
}
.reply-card-group .reply-container {
    margin-left: 0 !important;
    border-left: none !important;
    background: transparent;
    border-radius: 10px;
    border: none;
    box-shadow: none;
    position: relative;
}
.reply-card-group .reply-container + .reply-container {
    border-top: 1px solid #e0e0e0;
    margin-top: 10px;
    padding-top: 10px;
}

/* Blank placeholder for visual rhythm */
.blank-thread-placeholder {
    min-height: 32px;
    opacity: 0;
    pointer-events: none;
}


/* ===================== REPLY CONTAINER ===================== */
.reply-container {
    margin-bottom: 20px;
    padding: 15px;
    background-color: rgba(255,255,255,0.4);
    border: 1px solid #ccc;
    border-radius: 10px;
    position: relative;
    margin-left: 0 !important;
    border-left: none !important;
}
.reply-blue {
    border-left: 3px solid var(--td-reply-blue-bdr) !important;
}
.reply-gold {
    border-left: 3px solid var(--td-reply-gold-bdr) !important;
}

/* Offspring color layers */
.reply-container.offspring-blue {
    background: linear-gradient(135deg, rgba(0,123,255,.55) 0%, rgba(255,255,255,.4) 100%) !important;
}
.reply-container.offspring-gold {
    background: linear-gradient(135deg, rgba(255,215,0,.55) 0%, rgba(255,255,255,.4) 100%) !important;
}

/* Gap between a direct reply and its offspring */
.reply-container + .offspring {
    margin-top: 36px !important;
}
.reply-container.offspring {
    margin-top: 10px !important;
}
.reply-container.offspring.offspring-branch-start {
    margin-top: 28px !important;
}

/* Offspring flat group */
.offspring-flat-group {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: static !important;
}
.offspring-flat-group-last {
    margin-bottom: 28px !important;
}
.offspring-flat-group .reply-container {
    margin-left: 0 !important;
    border-left: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Droffspring legacy reset */
.droffspring,
.droffspring .reply-container {
    margin-left: 0 !important;
    padding-left: 0 !important;
    border-left: none !important;
}

/* Reply spine */
.reply-spine {
    display: none;
}

/* End-of-string divider */
hr.reply-string-end {
    border: none;
    border-top: 1px dashed #c0d0e0;
    margin: 12px 0 0 0;
    opacity: 0.6;
}


/* ===================== REPLY CARD TOGGLE (collapsible) ===================== */
.reply-card-group .reply-card-body {
    display: none;
}
.reply-card-group.is-expanded .reply-card-body {
    display: block;
}
.reply-card-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-family: inherit;
    font-size: .9em;
    font-weight: 600;
    color: inherit;
    text-align: left;
}
.reply-card-toggle__arrow {
    transition: transform .2s ease;
    font-size: .85em;
    opacity: .6;
}
.reply-card-group.is-expanded .reply-card-toggle__arrow {
    transform: rotate(180deg);
}


/* ===================== REPLY HEADER & AVATAR ===================== */
.reply-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
}
.reply-header img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-right: 10px;
}
.offspring .reply-header {
    display: flex;
    align-items: flex-start;
    padding-top: 10px;
}
.offspring .reply-header .avatar {
    margin-right: 10px;
    width: 60px;
    height: 60px;
}
.offspring .reply-header .reply-meta {
    font-style: italic;
    padding-bottom: 10px;
}
.offspring .reply-container {
    padding: 0 !important;
    margin-left: 0 !important;
    margin-bottom: 0 !important;
    border: none !important;
    background: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.offspring .reply-container .reply-text {
    margin-top: 10px;
}


/* ===================== REPLY META & TEXT ===================== */
.reply-meta small {
    display: block;
    margin-top: 4px;
    color: var(--td-text-muted);
    font-size: .85em;
}
.reply-text,
.op-content-text {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.6;
}
.reply-text.long-content,
.op-content-text.long-content {
    max-height: 200px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    transition: max-height .3s ease, mask-image .3s ease;
}
.reply-text.long-content.expanded,
.op-content-text.long-content.expanded {
    max-height: none;
    -webkit-mask-image: none;
    mask-image: none;
}
.content-expand-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    font-size: .82em;
    font-weight: 600;
    color: var(--td-primary);
    background: none;
    border: 1px solid var(--td-primary);
    border-radius: var(--td-radius-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.content-expand-btn:hover {
    background: var(--td-primary);
    color: #fff;
}


/* ===================== REPLYING-TO BANNER ===================== */
.replying-to-banner {
    font-size: .88em;
    color: var(--td-text-muted);
    padding: 7px 12px;
    margin-bottom: 8px;
    border-radius: 10px 10px 0 0;
    line-height: 1.5;
}
.replying-to-banner.offspring-blue {
    background: linear-gradient(90deg, rgba(0,123,255,.32) 0%, rgba(255,255,255,.7) 60%, rgba(0,123,255,.10) 100%);
    border-top: 4px solid #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,.10);
}
.replying-to-banner.offspring-gold {
    background: linear-gradient(90deg, rgba(180,140,0,.44) 0%, rgba(255,255,255,.7) 60%, rgba(180,140,0,.10) 100%);
    border-top: 4px solid #B48C00;
    box-shadow: 0 2px 8px rgba(180,140,0,.10);
}


/* ===================== REPLY INPUT / FORM ===================== */
/*
 * Two code paths toggle visibility:
 *   forums.js toggleReplyInput       -> element.style.display = 'block'/'none'  (inline style)
 *   threads.php attachReplyListeners -> classList.add/remove('open')
 * No !important — inline styles from forums.js must be able to override the base rule.
 */
.reply-input {
    width: 100%;
    display: none;
    background: #fffbe6;
    border: 2px solid #e0c200;
    padding: 10px;
    margin: 10px 0;
    box-sizing: border-box;
    z-index: 10;
    border-radius: var(--td-radius-md);
}
.reply-input.open {
    display: block;
}
.reply-input textarea,
.reply-textarea {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-top: 15px;
    box-sizing: border-box;
    min-height: 100px;
    resize: vertical;
    transition: border-color .15s;
}
.reply-input textarea:focus,
.reply-textarea:focus {
    outline: none;
    border-color: var(--td-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.char-counter {
    font-size: .82em;
    color: var(--td-text-light);
    margin-top: 4px;
    text-align: right;
}
.reply-submit-row {
    margin-top: 8px;
}


/* ── OP reply input — lives inside .op-container flex column ── */
.reply-input--op {
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    border-radius: var(--td-radius-md);
}
/* OP delete button — sits in .op-buttons flex row, needs consistent sizing */
.op-container .delete-btn {
    margin-left: 0;
}
/* OP reaction options — full width below the button row */
.op-reaction-options {
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
}


/* ===================== OP CONTAINER ===================== */
.op-container {
    padding: 20px;
    background-color: rgba(248,249,250,0.9);
    margin-bottom: 20px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    width: 100%;
    position: relative;
}
.op-badge {
    display: inline-block;
    font-size: .78em;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--td-primary-dark);
    background: #dbeafe;
    border-radius: var(--td-radius-sm);
    padding: 2px 8px;
    margin-bottom: 10px;
}
.topic-header {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    margin-bottom: 20px;
    width: 100%;
}
.topic-header img,
.op-avatar {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin-right: 20px;
    flex-shrink: 0;
}
.op-meta-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}
.op-meta small {
    display: block;
    margin-top: 5px;
    color: var(--td-text-muted);
}
.op-title {
    font-size: 1.5em;
    margin: 0 0 10px 0;
}
.topic-header p {
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1.5;
    color: var(--td-text);
    margin-top: 30px;
}


/* ===================== REACTIONS SUMMARY ===================== */
.reactions-summary {
    padding: 15px;
    margin-top: 20px;
    background-color: rgba(255,255,255,0.9);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.reactions-summary .reaction-totals {
    font-weight: bold;
    font-size: 1.2em;
}

/* ===================== REPLY MICRO-SUMMARY ===================== */
.reply-micro-summary {
    font-size: .8em;
    color: var(--td-text-muted);
    margin: 4px 0 6px 0;
}
.micro-summary__item {
    display: inline-block;
    background: #f1f5f9;
    border-radius: var(--td-radius-sm);
    padding: 2px 8px;
}


/* ===================== REPLY TAG ===================== */
.reply-to-op-tag {
    display: inline-block;
    font-size: .75em;
    font-weight: 600;
    color: var(--td-primary);
    background: #dbeafe;
    border-radius: var(--td-radius-sm);
    padding: 1px 7px;
    margin-left: 8px;
    vertical-align: middle;
}


/* ===================== CONTRIBUTOR PIP ===================== */
.contributor-pip {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
}
.contributor-pip--common    { background: #94a3b8; }
.contributor-pip--uncommon  { background: #22c55e; }
.contributor-pip--rare      { background: #3b82f6; }
.contributor-pip--epic      { background: #a855f7; }
.contributor-pip--legendary { background: #f59e0b; }


/* ===================== SORT TOGGLE BAR ===================== */
.sort-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--td-border);
}
.section-heading {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--td-text);
    margin: 0;
}
.section-heading--flush {
    margin-bottom: 0;
}
.sort-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.sort-label {
    font-size: .82em;
    color: var(--td-text-muted);
    font-weight: 600;
    margin-right: 4px;
}
.sort-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 13px;
    font-family: inherit;
    font-size: .82em;
    font-weight: 600;
    border: 1.5px solid var(--td-border);
    border-radius: var(--td-radius-md);
    background: #fff;
    color: var(--td-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.sort-btn:hover {
    background: var(--td-bg);
    color: var(--td-text);
    border-color: #94a3b8;
}
.sort-btn.active {
    background: var(--td-primary);
    color: #fff;
    border-color: var(--td-primary);
    box-shadow: 0 2px 8px rgba(59,130,246,.25);
}
.sub-toggle-bar {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.sub-toggle-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-family: inherit;
    font-size: .8em;
    font-weight: 600;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-sm);
    background: #fff;
    color: var(--td-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.sub-toggle-btn:hover {
    background: var(--td-bg);
    color: var(--td-text);
}
.sub-toggle-btn.active {
    background: var(--td-primary);
    color: #fff;
    border-color: var(--td-primary);
}


/* ===================== VIEWS ===================== */
.replies-view {
    display: none;
}
.replies-view.active-view {
    display: block;
}
.sub-view {
    display: none;
}
.sub-view.active-sub-view {
    display: block;
}

.section-micro-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 6px 10px;
    background: var(--td-bg);
    border-radius: var(--td-radius-md);
    border: 1px solid var(--td-border);
}
.section-micro-header__icon {
    font-size: 1em;
}
.section-micro-header__title {
    font-weight: 700;
    font-size: .9em;
    color: var(--td-text);
}
.section-micro-header__count {
    font-size: .8em;
    color: var(--td-text-muted);
    margin-left: auto;
}


/* ===================== DIGEST / HEAT / QUALITY CARDS ===================== */
.recent-reply-card,
.heat-card,
.quality-card,
.my-interaction-card {
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-lg);
    padding: 14px 16px;
    margin-bottom: 14px;
    transition: box-shadow .2s;
}
.recent-reply-card:hover,
.heat-card:hover,
.quality-card:hover {
    box-shadow: var(--td-shadow-md);
}
.heat-count-badge,
.quality-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 3px 10px;
    border-radius: var(--td-radius-sm);
    font-size: .82em;
    font-weight: 600;
}
.heat-count-badge {
    background: #fef3c7;
    color: #92400e;
}
.heat-count-value { font-size: 1em; }
.heat-count-label { font-weight: 400; }
.quality-score-badge {
    background: #f3f4f6;
    color: var(--td-text-muted);
}
.quality-score-value { font-size: 1.1em; font-weight: 700; }
.quality-score--positive { color: #166534; }
.quality-score--negative { color: #991b1b; }
.quality-score-label { font-weight: 400; }

.digest-card-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.jump-to-context {
    display: inline-block;
    margin-top: 8px;
    font-size: .82em;
    color: var(--td-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color .15s;
}
.jump-to-context:hover {
    color: var(--td-primary-dark);
    text-decoration: underline;
}

.empty-state {
    color: var(--td-text-muted);
    font-size: .92em;
    text-align: center;
    padding: 24px 0;
}


/* ===================== CONVERSATION BEAT DIVIDER ===================== */
.conversation-beat {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: var(--td-text-muted);
    font-size: .78em;
    font-weight: 600;
    letter-spacing: .5px;
}
.conversation-beat__line {
    flex: 1;
    height: 1px;
    background: var(--td-border);
}
.conversation-beat__label {
    white-space: nowrap;
}


/* ===================== FOCUS MODE ===================== */
.focus-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.focus-overlay.is-open {
    display: flex;
}
.focus-overlay__content {
    background: #fff;
    border-radius: var(--td-radius-lg);
    padding: 24px;
    max-width: 680px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
.focus-overlay__close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    color: var(--td-text-muted);
    line-height: 1;
}
.focus-overlay__close:hover { color: var(--td-text); }
.focus-overlay__breadcrumb {
    font-size: .8em;
    color: var(--td-text-muted);
    margin-bottom: 12px;
}


/* ===================== HEADLINER BAR ===================== */
.headliner {
    background: var(--td-primary);
    color: #fff;
    text-align: center;
    padding: 6px 12px;
    font-size: .82em;
    font-weight: 600;
    letter-spacing: .3px;
    min-height: 0;
    transition: min-height .3s;
    overflow: hidden;
}
.headliner:empty {
    display: none;
}


/* ===================== RETURN TO TOP / NEXT NEW ===================== */
.return-to-thread {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background: var(--td-primary);
    color: #fff;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: .85em;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--td-shadow-md);
    opacity: 0.9;
    z-index: 999;
    transition: opacity .2s, transform .2s;
}
.return-to-thread:hover {
    opacity: 1;
    transform: translateY(-2px);
}
.next-new-btn {
    position: fixed;
     bottom: 220px;
     right: 40px;
    background: var(--td-hot);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: .85em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--td-shadow-md);
    z-index: 999;
    transition: background .15s, transform .2s;
}
.next-new-btn:hover {
    background: var(--td-hot-dark);
    transform: translateY(-2px);
}


/* ===================== ENERGY TRACKER ===================== */
.energy-tracker {
    position: fixed;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--td-border);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: .82em;
    font-weight: 600;
    z-index: 999;
    box-shadow: var(--td-shadow-sm);
}
.energy-tracker.energy-tracker--under-balance {
    top: 56px;
    right: 8px;
}
.energy-tracker__label { color: var(--td-text); }
.energy-tracker__bar {
    width: 80px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}
.energy-tracker__fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 999px;
    transition: width .4s ease;
}
@media (max-width: 768px) {
    .energy-tracker.energy-tracker--under-balance {
        top: 58px;
        right: 8px;
    }
}


/* ===================== FADE-IN ANIMATION ===================== */
.fade-in {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .3s ease, transform .3s ease;
}
.fade-in.is-visible {
    opacity: 1;
    /* Use transform:none so settled containers do NOT form a CSS stacking
       context.  translateY(0) is visually identical but still creates a
       stacking context that traps the reaction dropdown's z-index inside
       the container, letting sibling offspring containers (later in DOM)
       paint over it. */
    transform: none;
}


/* ===================== TOAST NOTIFICATIONS ===================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-md);
    box-shadow: var(--td-shadow-lg);
    font-size: .88em;
    max-width: 320px;
    pointer-events: all;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    position: relative;
    overflow: hidden;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--exit    { opacity: 0; transform: translateY(8px); }
.toast--success { border-left: 3px solid var(--td-positive); }
.toast--error   { border-left: 3px solid var(--td-destructive); }
.toast--info    { border-left: 3px solid var(--td-info); }
.toast-icon { font-size: 1em; font-weight: 700; flex-shrink: 0; }
.toast--success .toast-icon { color: var(--td-positive); }
.toast--error   .toast-icon { color: var(--td-destructive); }
.toast--info    .toast-icon { color: var(--td-info); }
.toast-message { flex: 1; color: var(--td-text); }
.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    color: var(--td-text-muted);
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: currentColor;
    opacity: .25;
    transform-origin: left;
    animation: toast-progress linear forwards;
}
@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}


/* ===================== MODAL SYSTEM ===================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 50000;
    align-items: center;
    justify-content: center;
}
.modal[style*="display: block"],
.modal[style*="display: flex"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #fff;
    border-radius: var(--td-radius-lg);
    padding: 28px;
    max-width: 520px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--td-shadow-lg);
}
.modal--wide .modal-content  { max-width: 760px; }
.modal--narrow .modal-content { max-width: 380px; }
.modal-content .close {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 1.4em;
    cursor: pointer;
    color: var(--td-text-muted);
    background: none;
    border: none;
    line-height: 1;
}
.modal-content .close:hover { color: var(--td-text); }
.modal-scrollable {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-md);
    padding: 10px;
    margin-top: 10px;
}
.modal-form-group {
    margin-bottom: 14px;
}
.modal-form-group label {
    display: block;
    font-size: .88em;
    font-weight: 600;
    color: var(--td-text-muted);
    margin-bottom: 5px;
}
.modal-form-group textarea,
.modal-form-group select {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: .9em;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-md);
    box-sizing: border-box;
    transition: border-color .15s;
}
.modal-form-group textarea:focus,
.modal-form-group select:focus {
    outline: none;
    border-color: var(--td-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.modal-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}


/* ===================== MODERATION PANEL ===================== */
.mod-panel-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.mod-tab-btn {
    padding: 6px 14px;
    font-family: inherit;
    font-size: .85em;
    font-weight: 600;
    border: 1.5px solid var(--td-border);
    border-radius: var(--td-radius-md);
    background: #fff;
    color: var(--td-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.mod-tab-btn.active {
    background: var(--td-secondary);
    color: #fff;
    border-color: var(--td-secondary);
}
.mod-tab-content { display: block; }
.muted-user-item,
.mod-log-item,
.deleted-post-item {
    padding: 10px;
    border-bottom: 1px solid var(--td-border);
    font-size: .88em;
}
.muted-user-item:last-child,
.mod-log-item:last-child,
.deleted-post-item:last-child { border-bottom: none; }
.deleted-post-type {
    display: inline-block;
    font-size: .75em;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--td-info);
    background: #dbeafe;
    border-radius: var(--td-radius-sm);
    padding: 1px 7px;
    margin-bottom: 5px;
}
.unmute-btn,
.restore-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    margin-top: 6px;
    font-family: inherit;
    font-size: .82em;
    font-weight: 600;
    background: var(--td-positive);
    color: #fff;
    border: none;
    border-radius: var(--td-radius-sm);
    cursor: pointer;
    transition: background .15s;
}
.unmute-btn:hover,
.restore-btn:hover { background: var(--td-positive-dark); }
.error-message { color: var(--td-destructive); }

/* Inline confirm bars (for unmute/restore) */
.inline-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: .85em;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .2s, transform .2s;
}
.inline-confirm--visible { opacity: 1; transform: translateY(0); }
.btn-confirm {
    padding: 3px 12px;
    font-family: inherit;
    font-size: .85em;
    font-weight: 600;
    border: none;
    border-radius: var(--td-radius-sm);
    cursor: pointer;
    transition: background .15s;
}
/* forums.js uses --yes, moderation panel uses --restore — both are confirm actions */
.btn-confirm--yes,
.btn-confirm--restore { background: var(--td-positive); color: #fff; }
.btn-confirm--yes:hover,
.btn-confirm--restore:hover { background: var(--td-positive-dark); }
.btn-confirm--cancel  { background: var(--td-secondary); color: #fff; }
.btn-confirm--cancel:hover { background: var(--td-secondary-dark); }

/* Deleting animation */
.post-deleting {
    opacity: 0;
    transform: scaleY(0.8);
    transition: opacity .4s, transform .4s;
    pointer-events: none;
}


/* ===================== BADGE POPUP ===================== */
.badge-popup {
    position: absolute;
    z-index: 10001;
    background: #fff;
    border: 1px solid var(--td-border);
    border-radius: var(--td-radius-lg);
    box-shadow: 0 12px 36px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
    width: 300px;
    opacity: 0;
    transform: scale(0.9) translateY(-6px);
    transition: opacity .18s ease, transform .18s ease;
}
.badge-popup[style*="display: block"] {
    display: block;
}
.badge-popup-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--td-border);
    background: var(--td-bg);
    border-radius: var(--td-radius-lg) var(--td-radius-lg) 0 0;
}
.badge-popup-header h4 {
    margin: 0;
    font-size: .92em;
    font-weight: 700;
    color: var(--td-text);
    letter-spacing: .2px;
}
.badge-popup-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}
.badge-popup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
}
.badge-popup-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: default;
    padding: 6px 4px;
    border-radius: var(--td-radius-md);
    transition: background .15s;
}
.badge-popup-item:hover {
    background: var(--td-bg);
}
.badge-popup-item img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}
.badge-popup-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.badge-popup-category {
    font-size: .66em;
    color: var(--td-text-muted);
    text-align: center;
    line-height: 1.3;
}
.badge-popup-milestone {
    font-size: .72em;
    font-weight: 700;
    color: var(--td-primary);
    text-align: center;
}
.badge-popup-empty,
.badge-popup-loading,
.badge-popup-error {
    font-size: .85em;
    color: var(--td-text-muted);
    text-align: center;
    padding: 16px 0;
}
.badge-popup-error { color: var(--td-destructive); }
.badge-popup-stats {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, var(--td-bg) 0%, #fff 100%);
    border-radius: var(--td-radius-md);
    border: 1px solid var(--td-border);
}
.badge-popup-stats-title {
    font-size: .72em;
    font-weight: 700;
    color: var(--td-text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 8px;
}
.badge-popup-stats-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.stat-item {
    font-size: .80em;
    color: var(--td-text-muted);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.stat-item strong {
    font-size: 1.15em;
    color: var(--td-text);
    font-weight: 700;
}
.badge-popup.mobile-centered {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) scale(0.9) !important;
}


/* ===================== BADGE EARNED MODAL ===================== */
.badge-earned-modal .modal-content {
    text-align: center;
}
.badge-earned-modal__title {
    font-size: 1.2em;
    font-weight: 700;
    margin: 0 0 16px 0;
}
.badge-earned-modal__content {
    margin-bottom: 16px;
}
.badge-earned-modal__ok-btn {
    background: var(--td-primary);
    color: #fff;
    border: none;
    border-radius: var(--td-radius-md);
    padding: 10px 28px;
    font-family: inherit;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.badge-earned-modal__ok-btn:hover { background: var(--td-primary-dark); }


/* ===================== REACTION BADGE OVERLAY ===================== */
#reaction-badge-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
#reaction-badge-overlay[style*="display: flex"] {
    display: flex !important;
}
#reaction-badges-container {
    background: #fff;
    border-radius: var(--td-radius-lg);
    padding: 28px;
    max-width: 460px;
    width: 92%;
    text-align: center;
    box-shadow: var(--td-shadow-lg);
}
#reaction-badges-container h3 {
    margin: 0 0 16px;
    font-size: 1.1em;
    font-weight: 700;
}
#reaction-badges-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}
.reaction-badge-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: var(--td-bg);
    border-radius: var(--td-radius-md);
    border: 1px solid var(--td-border);
    position: relative;
    overflow: hidden;
    text-align: left;
    animation: badge-item-in .35s ease both;
}
@keyframes badge-item-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.reaction-badge-item img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}
.reaction-badge-desc h4 {
    margin: 0 0 2px;
    font-size: .9em;
    font-weight: 700;
}
.reaction-badge-desc p {
    margin: 0;
    font-size: .82em;
    color: var(--td-text-muted);
}
.reaction-badge-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
    animation: shine .7s ease .2s both;
    pointer-events: none;
}
@keyframes shine {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}
#reaction-badge-close-btn {
    background: var(--td-primary);
    color: #fff;
    border: none;
    border-radius: var(--td-radius-md);
    padding: 10px 28px;
    font-family: inherit;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
#reaction-badge-close-btn:hover { background: var(--td-primary-dark); }


/* ===================== MUTE WARNING ===================== */
.mute-warning__title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--td-destructive);
    margin: 0 0 10px;
}
.mute-warning__text {
    font-size: .9em;
    color: var(--td-text);
    margin-bottom: 8px;
}
.mute-warning__detail {
    font-size: .88em;
    color: var(--td-text-muted);
    margin-bottom: 8px;
}
.mute-warning__countdown {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--td-destructive);
    margin: 10px 0 18px;
    font-variant-numeric: tabular-nums;
}


/* ===================== RESOURCE BOX ===================== */
.resource-box-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    width: 300px !important;
    background: rgba(255,255,255,.32) !important;
    backdrop-filter: blur(10px) !important;
    transform: translateX(-100%);
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    border-right: 2px solid rgba(44,62,80,.12) !important;
    box-shadow: 8px 0 32px rgba(44,62,80,.13), 0 2px 8px rgba(44,62,80,.08) !important;
    transition: transform .3s cubic-bezier(.4,0,.2,1) !important;
    overflow: visible !important;
}
.resource-box-tab {
    position: absolute !important;
    top: 50% !important;
    left: 100% !important;
    width: 40px !important;
    height: 80px !important;
    background: linear-gradient(135deg, #2ecc71, #27ae60) !important;
    color: #fff !important;
    text-align: center !important;
    line-height: 80px !important;
    font-size: 24px !important;
    transform: translateY(-50%) !important;
    border-radius: 0 12px 12px 0 !important;
    cursor: pointer !important;
    box-shadow: 4px 0 15px rgba(0,0,0,.2) !important;
    z-index: 1 !important;
    border: 1px solid rgba(255,255,255,.1) !important;
}
.resource-box-content {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 16px 10px 0 10px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    margin-top: -20px !important;
    max-height: 100vh;
    position: relative !important;
}
.resource-box-content h3 {
    font-size: 28px !important;
    color: #1a2633 !important;
    margin-bottom: 25px !important;
    font-weight: 700 !important;
    letter-spacing: -.5px !important;
}
.resource-items {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 4px !important;
}
.resource-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 4px !important;
    padding: 8px 8px !important;
    background: rgba(255,255,255,.92) !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 14px rgba(44,62,80,.07) !important;
    border: 1.2px solid rgba(44,62,80,.09) !important;
    width: 92% !important;
    transition: transform .18s, box-shadow .18s !important;
}
.resource-item:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,.08) !important;
}
.resource-item img {
    width: 72px !important;
    height: 72px !important;
    object-fit: contain !important;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,.1)) !important;
    transition: transform .2s ease !important;
}
.resource-item:hover img { transform: scale(1.05) !important; }
.resource-item .resource-value {
    font-size: 20.58px !important;
    font-weight: 800 !important;
    color: #111 !important;
}
.resource-item span:last-child {
    font-size: 12.01px !important;
    color: #111 !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 1.2px !important;
    opacity: .92 !important;
}


/* ===================== FLOATING AVATAR & NAMEPLATE ===================== */
.floating-avatar-group {
    position: fixed !important;
    bottom: 20px !important;
    right: 40px !important;
    display: block !important;
    z-index: 99999 !important;
    overflow: visible !important;
}
.floating-avatar {
    position: relative !important;
    display: block !important;
    width: 180px !important;
    height: 180px !important;
    z-index: 1 !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0,0,0,.2) !important;
}
.floating-avatar .avatar-container,
.floating-avatar img {
    width: 180px !important;
    height: 180px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

/* Nameplate animations */
@keyframes plate-shimmer-slow {
    0%   { transform: skewX(-18deg) translateX(-300%); opacity: 0; }
    3%   { opacity: 1; }
    11%  { transform: skewX(-18deg) translateX(400%); opacity: 0; }
    100% { transform: skewX(-18deg) translateX(400%); opacity: 0; }
}
@keyframes plate-glow {
    0%, 100% { box-shadow: 0 0 0 1px rgba(200,168,80,.18), 0 2px 12px rgba(0,0,0,.9), 0 0 8px rgba(200,168,80,.05); }
    50%       { box-shadow: 0 0 0 1px rgba(255,215,0,.7), 0 2px 20px rgba(0,0,0,.95), 0 0 28px rgba(255,200,60,.28); }
}
@keyframes top-rule-shimmer {
    from { background-position: -200% center; }
    to   { background-position:  200% center; }
}
@keyframes corner-pulse {
    0%, 100% { opacity: .35; }
    50%       { opacity: .9; }
}
.username-float {
    position: absolute !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    min-width: 220px !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background: linear-gradient(170deg, #12100a 0%, #0c0a06 55%, #0f0d09 100%) !important;
    border: 1px solid rgba(200,168,80,.22) !important;
    border-radius: 3px !important;
    padding: 5px 28px 4px !important;
    overflow: hidden !important;
    pointer-events: none !important;
    z-index: 2 !important;
    box-sizing: border-box !important;
    animation: plate-glow 4s ease-in-out infinite !important;
}
.username-float::after {
    content: '' !important;
    position: absolute !important;
    top: -20% !important;
    left: 0 !important;
    width: 28% !important;
    height: 140% !important;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.06) 25%, rgba(255,252,210,.62) 50%, rgba(255,255,255,.06) 75%, transparent 100%) !important;
    transform: skewX(-18deg) translateX(-300%) !important;
    animation: plate-shimmer-slow 8s ease-in-out infinite !important;
    pointer-events: none !important;
}
.username-float .plate-rule-top {
    width: 100% !important;
    height: 1.5px !important;
    background: linear-gradient(90deg, transparent 0%, rgba(200,168,80,.5) 15%, rgba(255,215,0,1) 50%, rgba(200,168,80,.5) 85%, transparent 100%) !important;
    background-size: 200% 100% !important;
    animation: top-rule-shimmer 3s linear infinite !important;
    margin-bottom: 3px !important;
    border-radius: 2px !important;
    display: block !important;
}
.username-float .plate-name {
    font-family: 'Cinzel', 'Exo 2', serif !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #f0c040 !important;
    letter-spacing: 2.5px !important;
    text-transform: uppercase !important;
    text-shadow: 0 0 8px rgba(255,200,60,.5), 0 1px 3px rgba(0,0,0,.95) !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    max-width: 100% !important;
    text-overflow: ellipsis !important;
    position: relative !important;
    z-index: 1 !important;
}
.username-float .plate-rule-bottom {
    width: 80% !important;
    height: 1px !important;
    background: linear-gradient(90deg, transparent, rgba(200,168,80,.35) 30%, rgba(200,168,80,.35) 70%, transparent) !important;
    margin-top: 2px !important;
    display: block !important;
}
.username-float .plate-corners span {
    position: absolute !important;
    width: 6px !important;
    height: 6px !important;
    border-color: rgba(200,168,80,.7) !important;
    border-style: solid !important;
    animation: corner-pulse 4s ease-in-out infinite !important;
}
.username-float .plate-corners span:nth-child(1) { top:3px !important; left:3px !important; border-width:1.5px 0 0 1.5px !important; }
.username-float .plate-corners span:nth-child(2) { top:3px !important; right:3px !important; border-width:1.5px 1.5px 0 0 !important; animation-delay:-.5s !important; }
.username-float .plate-corners span:nth-child(3) { bottom:3px !important; left:3px !important; border-width:0 0 1.5px 1.5px !important; animation-delay:-1s !important; }
.username-float .plate-corners span:nth-child(4) { bottom:3px !important; right:3px !important; border-width:0 1.5px 1.5px 0 !important; animation-delay:-1.5s !important; }


/* ===================== MOBILE (≤768px) ===================== */
@media (max-width: 768px) {
    html, body {
        max-width: 100vw;
        overflow-x: hidden !important;
    }
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box;
        font-size: .97em;
    }
    table {
        width: 100% !important;
        max-width: 100vw;
        display: block;
        overflow-x: auto;
        box-sizing: border-box;
    }
    pre, code {
        white-space: pre-wrap !important;
        word-break: break-word !important;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .reply-container {
        font-size: .97em;
        padding: 6px;
        max-width: 100vw;
        overflow-wrap: break-word;
        word-break: break-word;
        box-sizing: border-box;
    }
    .reply-text {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: break-word;
        max-width: 100vw;
    }
    .op-container {
        position: sticky;
        top: 0;
        z-index: 2;
        max-width: 100vw;
        padding: 10px;
        box-sizing: border-box;
    }
    .topic-header img,
    .op-avatar {
        width: 80px;
        height: 80px;
        margin-right: 12px;
    }
    .sort-toggle-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .sort-toggle {
        width: 100%;
    }
    .sort-btn {
        flex: 1;
        min-width: 0;
        text-align: center;
        justify-content: center;
    }
    /* Mobile touch targets — action buttons only */
    .show-replies-btn,
    .toggle-replies-btn,
    .reply-submit-btn,
    .reply-input .reply-submit-btn {
        min-height: 44px !important;
        padding: 10px 18px !important;
        font-size: 1em !important;
        border-radius: var(--td-radius-xl) !important;
    }
    .reactions-summary {
        flex-direction: row;
        padding: 10px;
    }
    .resource-box-container {
        width: 280px !important;
    }
    .resource-box-tab {
        width: 35px !important;
        height: 70px !important;
        font-size: 20px !important;
        line-height: 70px !important;
    }
    .floating-avatar-group {
        bottom: 10px !important;
        right: 10px !important;
        display: inline-flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    .floating-avatar {
        width: 135px !important;
        height: 135px !important;
    }
    .floating-avatar .avatar-container,
    .floating-avatar img {
        width: 135px !important;
        height: 135px !important;
    }
    .username-float {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        margin-top: -36px !important;
        min-width: 180px !important;
        max-width: calc(100vw - 20px) !important;
        padding: 6px 24px 5px !important;
    }
    .username-float .plate-name {
        font-size: 17px !important;
        letter-spacing: 2px !important;
    }
    .next-new-btn {
        right: 10px;
        bottom: 160px;
    }
    .return-to-thread {
        left: 14px;
        bottom: 14px;
    }
    .toast-container {
        right: 12px;
        bottom: 12px;
        max-width: calc(100vw - 24px);
    }
}


/* ===================== SMALL PHONES (≤480px) ===================== */
@media (max-width: 480px) {
    .floating-avatar-group { bottom: 8px !important; right: 8px !important; }
    .floating-avatar { width: 105px !important; height: 105px !important; }
    .floating-avatar .avatar-container,
    .floating-avatar img { width: 105px !important; height: 105px !important; }
    .next-new-btn {
        right: 8px;
        bottom: 126px;
    }
    .username-float {
        min-width: 150px !important;
        max-width: calc(100vw - 16px) !important;
        margin-top: -30px !important;
        padding: 5px 18px !important;
    }
    .username-float .plate-name {
        font-size: 15px !important;
        letter-spacing: 1.5px !important;
    }
}