/* =====================================================================
   feed.css — Community Feed (rebuilt). Load AFTER main.css, mobile.css,
   notifications.css and study-plus.css (it must be the last feed styling).
   Pairs with feed.js. Delete both <link>/<script> tags to go back to the old feed.
   Cards are <article class="fx-card">, so the old "#feed-stream > div" rules
   in main.css / mobile.css no longer touch them.
   ===================================================================== */

#feed-stream { display: flex; flex-direction: column; gap: 18px; width: 100%; }
#feed-stream > .space-y-6 > * { margin: 0 !important; }

/* ---------- Card ---------- */
.fx-card {
    --fx-line: rgba(255, 255, 255, .08);
    --fx-soft: rgba(255, 255, 255, .045);
    --fx-ink: #e8ecf6;
    --fx-mute: #98a4bb;
    --fx-accent: #8b7bff;
    position: relative; box-sizing: border-box; width: 100%;
    padding: 22px 24px 20px;
    border-radius: 22px;
    color: var(--fx-ink);
    background: linear-gradient(180deg, rgba(28, 34, 66, .78), rgba(13, 17, 36, .86));
    border: 1px solid var(--fx-line);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 22px 44px -26px rgba(0, 0, 0, .8);
    overflow: hidden;
    overflow-wrap: anywhere;
}
.light-theme .fx-card {
    --fx-line: rgba(109, 94, 252, .16);
    --fx-soft: rgba(109, 94, 252, .06);
    --fx-ink: #1e1b4b;
    --fx-mute: #5b5f87;
    --fx-accent: #6d5efc;
    background: #fff;
    box-shadow: 0 1px 0 #fff inset, 0 16px 34px -20px rgba(109, 94, 252, .35);
}

/* ---------- Header: avatar | name + titles | date | remove ---------- */
.fx-head {
    display: grid; align-items: start; column-gap: 14px; row-gap: 2px;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "av who date del";
}
.fx-actions { display: contents; }
.fx-head > .fx-av { grid-area: av; }
.fx-who { grid-area: who; min-width: 0; }
.fx-date { grid-area: date; padding-top: 4px; font: 500 11.5px/1.3 'JetBrains Mono', ui-monospace, monospace; color: var(--fx-mute); white-space: nowrap; }
.fx-del { grid-area: del; }

/* The picture the person chose. Beats the old "#feed-stream img { 38px }" rule. */
#feed-stream .fx-av {
    display: block; flex: none; width: 48px !important; height: 48px !important; max-width: none !important;
    border-radius: 15px; object-fit: cover !important;
    border: 1px solid var(--fx-line); background: var(--fx-soft);
}
#feed-stream .fx-av.fx-av-sm { width: 34px !important; height: 34px !important; border-radius: 11px; }
#feed-stream .fx-av.fx-av-xs { width: 26px !important; height: 26px !important; border-radius: 9px; }

/* Name and titles sit beside each other and wrap together */
.fx-nameline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.fx-name { margin: 0; font-weight: 800; font-size: 16px; line-height: 1.3; font-family: inherit; color: var(--fx-ink); letter-spacing: 0; word-break: break-word; }
.fx-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; }
.fx-chip {
    display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
    padding: 2px 9px; border-radius: 8px; border: 1px solid;
    font-weight: 700; font-size: 11px; line-height: 1.5; font-family: inherit; white-space: nowrap;
}
.fx-chip.is-title { color: #c7d2fe; background: rgba(99, 102, 241, .2); border-color: rgba(129, 140, 248, .4); }
.fx-chip.is-level { color: #67e8f9; background: rgba(6, 182, 212, .12); border-color: rgba(34, 211, 238, .28); }
.fx-chip.is-staff { color: #fca5a5; background: rgba(239, 68, 68, .16); border-color: rgba(248, 113, 113, .4); }
.fx-chip.is-dev   { color: #ddd6fe; background: rgba(139, 92, 246, .2);  border-color: rgba(167, 139, 250, .4); }
.light-theme .fx-chip.is-title { color: #4338ca; background: #eef2ff; border-color: #c7d2fe; }
.light-theme .fx-chip.is-level { color: #0e7490; background: #ecfeff; border-color: #a5f3fc; }
.light-theme .fx-chip.is-staff { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.light-theme .fx-chip.is-dev   { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.fx-chips.is-mini .fx-chip { padding: 1px 7px; font-size: 10px; border-radius: 7px; }

.fx-del {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
    border-radius: 12px; border: 0; background: transparent; cursor: pointer;
    font-weight: 700; font-size: 12px; line-height: 1; font-family: inherit; color: var(--fx-mute);
    transition: background-color .15s ease, color .15s ease;
}
.fx-del:hover { color: #f87171; background: rgba(239, 68, 68, .12); }

/* ---------- Post text — the size you pick in the composer is what you get ---------- */
.fx-text {
    margin: 16px 0 0; text-align: start; white-space: pre-wrap;
    font-size: var(--fx-size, 14px) !important;
    line-height: 1.7 !important;
    color: var(--fx-color, var(--fx-ink)) !important;
}

.fx-attach { margin-top: 14px; border-radius: 14px; overflow: hidden; border: 1px solid var(--fx-line); background: var(--fx-soft); }
#feed-stream .fx-attach img { width: 100% !important; height: auto !important; max-height: 320px; object-fit: cover !important; border-radius: 0; border: 0; }
.fx-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.fx-file b { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.fx-file button { flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: #a5b4fc; font-weight: 700; font-size: 12px; line-height: 1; font-family: inherit; cursor: pointer; }
.fx-file button:hover { background: rgba(129, 140, 248, .15); }

/* ---------- Like bar ---------- */
.fx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--fx-line); }
.fx-btn {
    display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px;
    border-radius: 12px; border: 1px solid var(--fx-line); background: var(--fx-soft); color: var(--fx-mute);
    font-weight: 700; font-size: 13px; line-height: 1; font-family: inherit; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.fx-btn:hover { color: #f87171; border-color: rgba(248, 113, 113, .4); }
.fx-btn.is-on { color: #f87171; border-color: rgba(248, 113, 113, .45); background: rgba(239, 68, 68, .1); }
.fx-btn svg { width: 17px; height: 17px; }
.fx-link { min-height: 40px; padding: 0 6px; border: 0; background: transparent; color: #a5b4fc; font-weight: 700; font-size: 12.5px; line-height: 1; font-family: inherit; cursor: pointer; }
.fx-link:hover { text-decoration: underline; }
.light-theme .fx-link { color: #5b4bd6; }

/* ---------- Comments ---------- */
.fx-comments { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--fx-line); }
.fx-ctitle { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 800; font-size: 13px; line-height: 1; font-family: inherit; color: var(--fx-mute); letter-spacing: .02em; }
.fx-ctitle span { padding: 2px 8px; border-radius: 999px; background: var(--fx-soft); border: 1px solid var(--fx-line); font-size: 11px; }

.fx-composer { display: flex; align-items: stretch; gap: 10px; }
.fx-input {
    flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; box-sizing: border-box;
    border-radius: 14px; border: 1px solid var(--fx-line); background: rgba(2, 6, 23, .55); color: var(--fx-ink);
    font-weight: 500; font-size: 14px; line-height: 1.4; font-family: inherit;
}
.light-theme .fx-input { background: #f8f7ff !important; }
.fx-input::placeholder { color: var(--fx-mute); }
.fx-send {
    flex: none; min-height: 44px; padding: 0 20px; border: 0; border-radius: 14px; cursor: pointer;
    font-weight: 800; font-size: 13px; line-height: 1; font-family: inherit; color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 10px 22px -12px rgba(99, 102, 241, .9);
}
.fx-send:hover { filter: brightness(1.1); }
.fx-send.is-small { min-height: 38px; padding: 0 16px; border-radius: 12px; font-size: 12px; }

.fx-clist { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.fx-none { margin: 4px 0 0; font-size: 13px; color: var(--fx-mute); }

.fx-comment { display: flex; align-items: flex-start; gap: 10px; }
.fx-cbody { flex: 1; min-width: 0; }
.fx-bubble { padding: 10px 14px 12px; border-radius: 6px 18px 18px 18px; background: var(--fx-soft); border: 1px solid var(--fx-line); }
.fx-cline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.fx-cname { font-weight: 800; font-size: 13.5px; color: var(--fx-ink); }
.fx-ctime { margin-inline-start: auto; font: 500 10.5px/1.2 'JetBrains Mono', ui-monospace, monospace; color: var(--fx-mute); }
.fx-ctext { margin: 6px 0 0; text-align: start; white-space: pre-wrap; font-size: 14px; line-height: 1.6; color: var(--fx-ink); opacity: .92; }
.fx-cacts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 2px 0 0 6px; }
.fx-cacts button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--fx-mute); font-weight: 700; font-size: 12px; line-height: 1; font-family: inherit; }
.fx-cacts button:hover { color: var(--fx-ink); background: var(--fx-soft); }
.fx-cacts button.is-on { color: #f87171; }
.fx-cacts button.is-reply, .fx-cacts button.is-who { color: #a5b4fc; }
.fx-cacts button.is-del:hover { color: #f87171; }
.fx-cacts svg { width: 14px; height: 14px; }
.light-theme .fx-cacts button.is-reply, .light-theme .fx-cacts button.is-who { color: #5b4bd6; }

.fx-replybox { display: flex; align-items: stretch; gap: 8px; margin: 6px 0 4px 6px; }
.fx-replybox.hidden { display: none !important; }
.fx-replybox .fx-input { min-height: 38px; font-size: 13px; }

.fx-replies { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 0 6px; padding-left: 12px; border-left: 2px solid var(--fx-line); }
.fx-replies:empty { display: none; }
.fx-replies .fx-bubble { padding: 8px 12px 10px; }
.fx-replies .fx-cname { font-size: 12.5px; }
.fx-replies .fx-ctext { font-size: 13px; }

/* ---------- Tablets ---------- */
@media (max-width: 1023px) {
    .fx-card { padding: 18px 18px 16px; }
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
    #feed-stream { gap: 14px; }
    .fx-card { padding: 14px 14px 12px; border-radius: 20px; }

    /* Date moves under the name, Remove shrinks to a tappable icon */
    .fx-head { column-gap: 11px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "av who del" "av date date"; }
    #feed-stream .fx-av { width: 44px !important; height: 44px !important; border-radius: 14px; }
    .fx-date { padding-top: 2px; font-size: 11px; }
    .fx-name { font-size: 15px; }
    .fx-del { width: 40px; height: 40px; min-height: 40px; padding: 0; justify-content: center; }
    .fx-del span { display: none; }

    .fx-text { margin-top: 12px; }

    .fx-bar .fx-btn { flex: 1 1 auto; justify-content: center; }

    /* Comment box: the Comment button goes UNDER the typing field */
    .fx-composer { flex-direction: column; gap: 8px; }
    .fx-input { min-height: 46px; font-size: 16px; }              /* 16px stops iOS zooming in on focus */
    .fx-send { width: 100%; min-height: 46px; font-size: 14px; }

    .fx-comment { gap: 8px; }
    #feed-stream .fx-av.fx-av-sm { width: 30px !important; height: 30px !important; border-radius: 10px; }
    .fx-bubble { padding: 9px 12px 11px; }
    .fx-ctime { flex-basis: 100%; margin: 0; }                       /* date drops to its own line */
    .fx-cacts { margin-left: 2px; }

    .fx-replybox { flex-direction: column; margin-left: 2px; }
    .fx-replybox .fx-input { min-height: 44px; font-size: 16px; }
    .fx-replybox .fx-send { width: 100%; min-height: 42px; }
    .fx-replies { margin-left: 2px; padding-left: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .fx-card *, .fx-btn, .fx-del { transition: none !important; }
}