/* ==========================================================================
   Nafa3na app design system
   Header + three columns + footer. Logical properties only (RTL + LTR).
   Spacing on a 4px grid. Radii: 8 / 12 / pill.
   ========================================================================== */

:root {
    --ink: #13233F;
    --teal: #0D7A6B;
    --teal-hover: #0A6A5D;
    --teal-tint: rgba(13, 122, 107, .10);
    --teal-soft: #E6F3F0;
    --saffron: #E8A317;
    --saffron-ink: #8A5B00;
    --saffron-tint: rgba(232, 163, 23, .14);
    --saffron-soft: #FDF4DF;

    --text-1: #13233F;
    --text-2: #4E5C70;
    --text-3: #8391A4;
    --page: #F2F4F7;
    --bg: #FFFFFF;
    --bg-2: #F6F8FB;
    --bg-hover: #F1F4F8;
    --line: #E5EAF0;
    --line-2: #D3DBE5;
    --danger: #D92D20;

    --paper: var(--bg-2);
    --surface: var(--bg);
    --muted: var(--text-3);
    --ink-2: var(--text-2);

    --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    --display: "El Messiri", "IBM Plex Sans Arabic", serif;
    --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 24px;

    --r-sm: 8px; --r-md: 12px; --r-pill: 999px;
    --shadow-card: 0 1px 2px rgba(19, 35, 63, .04);
    --shadow-pop: 0 10px 32px rgba(19, 35, 63, .16), 0 1px 3px rgba(19, 35, 63, .08);
    --ease: cubic-bezier(.2, .8, .2, 1);

    --head-h: 64px;
    --left-w: 280px;
    --feed-w: 620px;
    --right-w: 320px;
    --gap: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--page); color: var(--text-1);
    font-family: var(--font); font-size: var(--fs-md); line-height: 1.5;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.lp, body.auth { background: var(--bg); }
[dir="rtl"] body { line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
img, svg, video { display: block; }
h1, h2, h3, p, dl, dd { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--teal-tint); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }
.icon { flex: none; }
.muted { color: var(--text-3); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 18px; border-radius: var(--r-pill);
    font-size: var(--fs-md); font-weight: 600; white-space: nowrap;
    border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1E3357; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-hover); }
.btn-ghost { background: var(--bg); border-color: var(--line-2); color: var(--text-1); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: var(--fs-lg); }
.btn-sm { min-height: 32px; padding: 0 14px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn-compact { min-height: 34px; padding: 0 14px; font-size: var(--fs-sm); }
.btn-follow { min-width: 92px; }
.btn-follow[aria-pressed="true"] { background: var(--bg); color: var(--text-1); border-color: var(--line-2); }
.btn-follow[aria-pressed="true"] .when-off, .btn-follow[aria-pressed="false"] .when-on { display: none; }
.btn-follow[aria-pressed="true"]:hover { border-color: var(--danger); color: var(--danger); background: rgba(217, 45, 32, .05); }
.icon-btn {
    position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.icon-btn.small { width: 34px; height: 34px; }

.mark { width: 34px; height: 28px; flex: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--display); font-size: 25px; font-weight: 700; line-height: 1; }

/* ---------- Avatars ---------- */
.avatar {
    position: relative; width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
    display: inline-grid; place-items: center;
    background: var(--c, var(--teal)); color: #fff; font-weight: 600; font-size: 16px; line-height: 1; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { width: 28px; height: 28px; font-size: 12px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.xl { width: 128px; height: 128px; font-size: 48px; }

/* ==========================================================================
   Header
   ========================================================================== */
.app-head {
    position: sticky; top: 0; z-index: 50; height: var(--head-h);
    background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
}
.app-head-in {
    display: grid; grid-template-columns: var(--left-w) minmax(0, var(--feed-w)) var(--right-w); gap: var(--gap);
    align-items: center; height: 100%; max-width: calc(var(--left-w) + var(--feed-w) + var(--right-w) + 2 * var(--gap) + 32px);
    margin-inline: auto; padding-inline: 16px;
}
.head-search { position: relative; }
.search {
    display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 16px; border-radius: var(--r-pill);
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text-3); transition: background .15s, border-color .15s;
}
.search:focus-within { background: var(--bg); border-color: var(--teal); color: var(--teal); box-shadow: 0 0 0 4px var(--teal-tint); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text-1); font-size: var(--fs-md); }
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; }
.head-end { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.head-nav { display: flex; align-items: center; gap: 2px; margin-inline-end: 4px; }
.head-nav a { position: relative; display: grid; place-items: center; width: 52px; height: 44px; border-radius: var(--r-md); color: var(--text-2); transition: background .15s, color .15s; }
.head-nav a:hover { background: var(--bg-hover); color: var(--text-1); }
.head-nav a.is-active { color: var(--teal); }
.head-nav a.is-active::after { content: ""; position: absolute; bottom: -11px; inset-inline: 10px; height: 3px; border-radius: 3px 3px 0 0; background: var(--teal); }
.dot-badge {
    position: absolute; top: 4px; inset-inline-end: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: grid; place-items: center; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
    box-shadow: 0 0 0 2px var(--bg);
}
.me-menu { position: relative; }
.me-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: var(--r-pill); }
.me-menu summary::-webkit-details-marker { display: none; }
.me-menu summary:hover { background: var(--bg-hover); }
.menu {
    position: absolute; z-index: 60; inset-inline-end: 0; top: calc(100% + 8px); min-width: 260px; padding: 8px;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.menu-me { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-sm); }
.menu-me:hover { background: var(--bg-hover); }
.menu-me b { display: block; }
.menu-me span { font-size: var(--fs-sm); color: var(--text-3); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 8px; border-radius: var(--r-sm); font-weight: 500; text-align: start; }
.menu a:hover, .menu button:hover { background: var(--bg-hover); }
.menu .lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 0 4px; }
.menu .lang-list a { padding: 6px 8px; font-size: var(--fs-sm); }
.menu .lang-list a[aria-current] { color: var(--teal); font-weight: 700; }
.menu-label { padding: 6px 8px 2px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }

/* ==========================================================================
   Layout
   ========================================================================== */
.layout {
    display: grid; grid-template-columns: var(--left-w) minmax(0, var(--feed-w)) var(--right-w); gap: var(--gap);
    align-items: start; max-width: calc(var(--left-w) + var(--feed-w) + var(--right-w) + 2 * var(--gap) + 32px);
    margin-inline: auto; padding: 20px 16px 48px;
}
.rail { position: sticky; top: calc(var(--head-h) + 20px); display: grid; gap: 16px; max-height: calc(100vh - var(--head-h) - 40px); overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { min-width: 0; }
.main { display: grid; gap: 12px; min-width: 0; }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-card); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px; }
.card-h h2 { font-size: var(--fs-lg); font-weight: 700; }
.card-h a { font-size: var(--fs-sm); color: var(--teal); font-weight: 600; }

/* Me card (left) */
.me-card { overflow: hidden; }
.me-card .cover { height: 64px; background: linear-gradient(135deg, var(--teal), #10917F 50%, var(--saffron) 140%); }
.me-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.me-card .who { padding: 0 16px 16px; text-align: center; }
.me-card .who .avatar { margin: -32px auto 8px; box-shadow: 0 0 0 3px var(--bg); }
.me-card .who b { display: block; font-size: var(--fs-lg); }
.me-card .who span { font-size: var(--fs-sm); color: var(--text-3); }
.me-card .bio { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.me-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.me-stats a { padding: 10px 4px; text-align: center; transition: background .15s; }
.me-stats a + a { border-inline-start: 1px solid var(--line); }
.me-stats a:hover { background: var(--bg-hover); }
.me-stats b { display: block; font-size: var(--fs-lg); line-height: 1.2; }
.me-stats span { font-size: var(--fs-xs); color: var(--text-3); }

.side-links { padding: 8px; }
.side-links a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 500; transition: background .15s; }
.side-links a:hover { background: var(--bg-hover); }
.side-links a.is-active { background: var(--teal-tint); color: var(--teal); font-weight: 700; }
.side-links .count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.topics-list { padding: 4px 8px 8px; }
.topics-list a { display: block; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2); }
.topics-list a:hover { background: var(--bg-hover); color: var(--text-1); }
.topics-list a.is-active { color: var(--teal); font-weight: 700; }

.guest-card { padding: 20px; }
.guest-card h2 { font-family: var(--display); font-size: var(--fs-xl); line-height: 1.35; }
.guest-card p { margin: 8px 0 16px; color: var(--text-2); font-size: var(--fs-md); }
.guest-card .btn + .btn { margin-top: 8px; }

/* Right rail */
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; transition: background .15s; }
a.list-row:hover, .list-row.is-link:hover { background: var(--bg-hover); }
.list-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.list-row .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .who span { font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .who p { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.need-row { display: block; padding: 10px 16px; transition: background .15s; }
.need-row:hover { background: var(--bg-hover); }
.need-row .k { display: block; font-size: var(--fs-sm); color: var(--text-3); }
.need-row .v { display: block; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.need-row .s { display: block; font-size: var(--fs-sm); color: var(--saffron-ink); margin-top: 2px; }
.card-more { display: block; padding: 12px 16px; color: var(--teal); font-weight: 600; font-size: var(--fs-md); border-top: 1px solid var(--line); }
.card-more:hover { background: var(--bg-hover); }
.badge-helped { font-size: var(--fs-sm); font-weight: 700; color: var(--teal); white-space: nowrap; }
.mini-footer { padding: 0 8px; font-size: var(--fs-sm); color: var(--text-3); }
.mini-footer .footer-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.mini-footer a:hover { text-decoration: underline; }

/* ==========================================================================
   Page header inside the main column (tabs, titles)
   ========================================================================== */
.page-head { overflow: hidden; }
.page-title { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.page-title h1, .page-title h2 { font-size: var(--fs-xl); font-weight: 700; line-height: 1.25; }
.page-title p { font-size: var(--fs-sm); color: var(--text-3); }
.back-btn { margin-inline-start: -8px; }
[dir="rtl"] .back-btn .icon { transform: scaleX(-1); }
.tabs { display: flex; border-top: 1px solid var(--line); }
.page-head > .tabs:first-child { border-top: 0; }
.tabs a {
    position: relative; flex: 1; display: grid; place-items: center; height: 50px; color: var(--text-3); font-weight: 600;
    transition: background .15s, color .15s;
}
.tabs a:hover { background: var(--bg-hover); color: var(--text-1); }
.tabs a.is-active { color: var(--text-1); }
.tabs a.is-active::after { content: ""; position: absolute; bottom: 0; left: 50%; translate: -50% 0; width: 56px; height: 3px; border-radius: 3px 3px 0 0; background: var(--teal); }

.flash { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: var(--r-md); background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.field-error { margin-top: 6px; font-size: var(--fs-sm); color: var(--danger); font-weight: 500; }

/* ==========================================================================
   Composer
   ========================================================================== */
.composer { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 16px; }
.composer-body { min-width: 0; }
.composer textarea {
    display: block; width: 100%; min-height: 44px; max-height: 50vh; padding: 8px 0; resize: none;
    border: 0; background: transparent; font-size: var(--fs-lg); line-height: 1.55; color: var(--text-1);
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:focus { outline: none; }
.composer-fake { width: 100%; height: 44px; padding: 0 16px; border-radius: var(--r-pill); background: var(--bg-2); border: 1px solid var(--line); color: var(--text-3); text-align: start; font-size: var(--fs-md); transition: background .15s; }
.composer-fake:hover { background: var(--bg-hover); }
.composer-quick { display: flex; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.composer-quick button, .composer-quick label { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; transition: background .15s; }
.composer-quick button:hover, .composer-quick label:hover { background: var(--bg-hover); }
.q-photo .icon { color: #2E9E5B; } .q-tip .icon { color: var(--teal); } .q-help .icon { color: var(--saffron); }
.composer .composer-extra, .composer .composer-textarea-wrap { display: none; }
.composer.is-open .composer-extra, .composer.is-open .composer-textarea-wrap, .composer.has-errors .composer-extra, .composer.has-errors .composer-textarea-wrap { display: block; }
.composer.is-open .composer-fake, .composer.is-open .composer-quick, .composer.has-errors .composer-fake, .composer.has-errors .composer-quick { display: none; }
.composer-kind { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
.kind-chip { position: relative; cursor: pointer; }
.kind-chip input { position: absolute; opacity: 0; pointer-events: none; }
.kind-chip span {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--r-pill);
    border: 1px solid var(--line-2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; transition: all .15s;
}
.kind-chip span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.kind-chip input:checked + span { border-color: var(--teal); background: var(--teal-tint); color: var(--teal); }
.kind-chip.k-help input:checked + span { border-color: var(--saffron); background: var(--saffron-tint); color: var(--saffron-ink); }
.kind-chip input:checked + span::before { opacity: 1; }
.kind-chip input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }
.media-previews { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.media-previews:empty { display: none; }
.media-previews .pv { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.media-previews .pv img, .media-previews .pv video { width: 100%; height: 100%; object-fit: cover; }
.media-previews .pv button { position: absolute; top: 4px; inset-inline-end: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(19, 35, 63, .75); color: #fff; display: grid; place-items: center; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.composer-bar select {
    appearance: none; -webkit-appearance: none; height: 36px; max-width: 46%; padding: 0 30px 0 14px; border-radius: var(--r-pill);
    border: 1px solid var(--line-2); background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%234E5C70' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--text-1); font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
[dir="rtl"] .composer-bar select { padding: 0 14px 0 30px; background-position: left 12px center; }
.composer-bar select:invalid { color: var(--text-3); }
.composer-bar .attach { color: #2E9E5B; cursor: pointer; }
.composer-bar .spacer { flex: 1; }
.counter { width: 24px; height: 24px; }
.counter circle { fill: none; stroke-width: 2.5; }
.counter .track { stroke: var(--line); }
.counter .fill { stroke: var(--teal); stroke-linecap: round; transition: stroke-dashoffset .15s, stroke .15s; transform: rotate(-90deg); transform-origin: center; }
.counter.is-warn .fill { stroke: var(--saffron); }
.counter.is-over .fill { stroke: var(--danger); }
.composer .btn-teal[data-mode="help"] { background: var(--saffron); color: var(--ink); }
.sheet-close { display: none; }

/* ==========================================================================
   Post
   ========================================================================== */
.post { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 16px 16px 8px; }
.post .avatar:not(.xs):not(.sm) { width: 44px; height: 44px; }
.post.is-link { cursor: pointer; }
.post-avatar { align-self: start; }
.post-main { min-width: 0; }
.post-head { display: flex; align-items: flex-start; gap: 4px; }
.post-who { flex: 1; min-width: 0; line-height: 1.35; }
.post-who .line1 { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.post-who .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.post-who .name:hover { text-decoration: underline; }
.post-who .handle { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); }
.post-who .line2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); }
.post-who .line2 a:hover { text-decoration: underline; color: var(--text-1); }
.post-menu { position: relative; margin-inline-start: auto; margin-top: -4px; }
.post-menu summary { list-style: none; cursor: pointer; }
.post-menu summary::-webkit-details-marker { display: none; }
.post-menu .menu { min-width: 210px; }
.post-menu .menu .danger { color: var(--danger); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; line-height: 1; }
.tag-benefit { background: var(--teal-tint); color: var(--teal); }
.tag-help { background: var(--saffron-tint); color: var(--saffron-ink); }
.tag-solved { background: var(--teal-tint); color: var(--teal); }
.tag .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--saffron); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 163, 23, .55); } 70% { box-shadow: 0 0 0 6px rgba(232, 163, 23, 0); } 100% { box-shadow: 0 0 0 0 rgba(232, 163, 23, 0); } }

.post-body { margin-top: 10px; font-size: var(--fs-md); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-line; }
[dir="rtl"] .post-body, .post-body:lang(ar), .post-body:lang(ur) { line-height: 1.8; }
.post-body:lang(ur) { font-size: 16px; }
.read-more { color: var(--teal); font-weight: 600; }
.read-more:hover { text-decoration: underline; }
.post-full .post-body { font-size: 18px; }

/* Media grid */
.media { display: grid; gap: 4px; margin-top: 12px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); }
.media a, .media .vid { position: relative; display: block; min-height: 0; overflow: hidden; background: #0B1220; }
.media img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.media a:hover img { opacity: .92; }
.media video { width: 100%; max-height: 70vh; background: #000; }
.media.n1 a { aspect-ratio: var(--ar, 16 / 10); max-height: 560px; }
.media.n1 img { object-fit: cover; }
.media.n2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.media.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 10; }
.media.n3 a:first-child { grid-row: 1 / 3; }
.media.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 10; }

/* Stats line + actions */
.post-stats { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: var(--fs-sm); color: var(--text-3); }
.post-stats .glyph { width: 18px; height: 15px; }
.post-stats .impact { display: inline-flex; align-items: center; gap: 6px; }
.post-stats .impact b { color: var(--text-1); }
.post-stats a:hover { text-decoration: underline; }
.actions { display: flex; align-items: stretch; gap: 4px; margin-top: 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.actions form { display: contents; }
.act {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: var(--r-sm);
    color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; transition: background .15s, color .15s;
}
.act:hover { background: var(--bg-hover); color: var(--text-1); }
.act .glyph { width: 20px; height: 17px; filter: grayscale(1) opacity(.6); transition: filter .15s; }
.act-benefit[aria-pressed="true"] { color: var(--teal); }
.act-benefit[aria-pressed="true"] .glyph, .act-benefit:hover .glyph { filter: none; }
.act-help[aria-pressed="true"] { color: var(--saffron-ink); }
.act[aria-pressed="true"] .glyph, .act[aria-pressed="true"] .icon { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.3); } }
.act.is-static { cursor: default; opacity: .55; }
.act.is-static:hover { background: none; color: var(--text-2); }

/* Comments */
.comment-form { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.comment-form .box { display: flex; align-items: flex-end; gap: 8px; padding: 4px 4px 4px 14px; border-radius: 20px; background: var(--bg-2); border: 1px solid var(--line); }
[dir="rtl"] .comment-form .box { padding: 4px 14px 4px 4px; }
.comment-form .box:focus-within { border-color: var(--teal); background: var(--bg); }
.comment-form textarea { flex: 1; min-width: 0; min-height: 34px; padding: 6px 0; resize: none; border: 0; background: transparent; font-size: var(--fs-md); }
.comment-form textarea:focus { outline: none; }
.comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; padding: 8px 16px; }
.comment .bubble { display: inline-block; max-width: 100%; padding: 8px 12px; border-radius: 16px; background: var(--bg-2); }
.comment .bubble .name { font-weight: 700; font-size: var(--fs-sm); }
.comment .bubble .name:hover { text-decoration: underline; }
.comment .post-body { margin-top: 2px; }
.comment-meta { display: flex; gap: 12px; padding: 4px 12px 0; font-size: var(--fs-xs); color: var(--text-3); }
.link-danger { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.link-danger:hover { color: var(--danger); text-decoration: underline; }
.join-cta { padding: 16px; border-top: 1px solid var(--line); }
.join-cta p { font-weight: 600; margin-bottom: 12px; }
.join-cta .row { display: flex; gap: 8px; flex-wrap: wrap; }
.comments-list { padding-bottom: 8px; }
.note { padding: 14px 16px; color: var(--text-3); font-size: var(--fs-md); }
.section-label { padding: 4px 4px 0; font-size: var(--fs-lg); font-weight: 700; }

/* Profile */
.profile { overflow: hidden; }
.profile-cover { position: relative; aspect-ratio: 3 / 1; background: linear-gradient(135deg, var(--teal) 0%, #10917F 45%, var(--saffron) 130%); }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 20px; }
.profile-top .avatar { margin-top: -64px; box-shadow: 0 0 0 4px var(--bg); }
.profile-top .actions-row { display: flex; gap: 8px; padding-bottom: 4px; }
.profile-info { padding: 12px 20px 16px; }
.profile-info h1 { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.25; }
.profile-info .handle { color: var(--text-3); }
.profile-info .bio { margin-top: 10px; white-space: pre-line; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; color: var(--text-3); font-size: var(--fs-md); }
.profile-meta span, .profile-meta a { display: inline-flex; align-items: center; gap: 6px; }
.profile-meta a { color: var(--teal); }
.profile-meta a:hover { text-decoration: underline; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; }
.profile-stats a, .profile-stats span { color: var(--text-3); }
.profile-stats a:hover { text-decoration: underline; }
.profile-stats b { color: var(--text-1); font-weight: 700; }
.profile-stats .main b { color: var(--teal); }

/* Settings */
.form-card { padding: 20px; display: grid; gap: 18px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-row input[type=text], .form-row input[type=url], .form-row textarea {
    width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--r-md); border: 1.5px solid var(--line-2); background: var(--bg-2); font-size: var(--fs-md);
}
.form-row textarea { min-height: 96px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus { outline: none; border-color: var(--teal); background: var(--bg); box-shadow: 0 0 0 4px var(--teal-tint); }
.form-row .hint { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.edit-visual { position: relative; }
.edit-visual .profile-cover { border-radius: var(--r-md); overflow: hidden; }
.edit-visual .avatar { position: absolute; inset-inline-start: 20px; bottom: -40px; box-shadow: 0 0 0 4px var(--bg); }
.edit-visual .pick { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(19, 35, 63, .65); color: #fff; cursor: pointer; }
.edit-visual .pick:hover { background: rgba(19, 35, 63, .85); }
.edit-visual .pick-cover { top: 50%; left: 50%; translate: -50% -50%; }
.edit-visual .pick-avatar { inset-inline-start: 62px; bottom: -2px; translate: 0 0; width: 40px; height: 40px; }
.edit-visual input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.edit-spacer { height: 40px; }
.check-row { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Explore */
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 16px 16px; }
.topic { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg); transition: border-color .15s, background .15s; }
.topic:hover { border-color: var(--teal); background: var(--bg-2); }
.topic b { font-size: var(--fs-lg); }
.topic span { font-size: var(--fs-sm); color: var(--text-3); }
.search-page { padding: 16px 16px 12px; }

/* Notifications */
.notif { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); transition: background .15s; }
.notif:first-child { border-top: 0; }
.notif:hover { background: var(--bg-hover); }
.notif.is-new { background: var(--teal-soft); }
.notif .who-av { position: relative; }
.notif .kind { position: absolute; bottom: -4px; inset-inline-end: -4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; box-shadow: 0 0 0 2px var(--bg); }
.notif .k-follow { background: #3B6FD4; } .notif .k-benefit { background: var(--teal); } .notif .k-offer { background: var(--saffron); } .notif .k-comment { background: #7A4FC9; }
.notif p { line-height: 1.5; }
.notif .q { margin-top: 4px; color: var(--text-3); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.notif time { font-size: var(--fs-sm); color: var(--text-3); }

.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 32px; text-align: center; }
.empty .mark { width: 64px; height: 54px; margin-bottom: 8px; }
.empty h2 { font-size: var(--fs-xl); font-weight: 700; }
.empty p { color: var(--text-2); max-width: 40ch; margin-bottom: 8px; }
.pager { display: flex; justify-content: center; gap: 8px; padding: 8px 0; }
.ad-slot { padding: 12px; min-height: 100px; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 95; display: none; place-items: center; background: rgba(6, 10, 20, .92); padding: 24px; }
.lightbox.is-on { display: grid; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.lightbox button { position: absolute; top: 16px; inset-inline-end: 16px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; display: grid; place-items: center; }

/* Toast */
.toast {
    position: fixed; z-index: 99; left: 50%; bottom: 28px; translate: -50% 20px; opacity: 0; pointer-events: none;
    padding: 12px 20px; border-radius: var(--r-pill); background: var(--ink); color: #fff; font-weight: 600;
    box-shadow: var(--shadow-pop); transition: opacity .2s, translate .25s var(--ease);
}
.toast.is-on { opacity: 1; translate: -50% 0; }

/* ==========================================================================
   Site footer
   ========================================================================== */
.site-foot { background: var(--bg); border-top: 1px solid var(--line); margin-top: 24px; }
.site-foot-in { max-width: 1200px; margin-inline: auto; padding: 40px 16px 24px; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.site-foot .about p { margin-top: 12px; color: var(--text-2); max-width: 34ch; }
.site-foot h3 { font-size: var(--fs-md); font-weight: 700; margin-bottom: 12px; }
.site-foot ul { display: grid; gap: 8px; }
.site-foot ul a { color: var(--text-2); }
.site-foot ul a:hover { color: var(--teal); text-decoration: underline; }
.site-foot ul a[aria-current] { color: var(--teal); font-weight: 700; }
.site-foot .langs { grid-template-columns: 1fr 1fr; }
.site-foot-bar { max-width: 1200px; margin-inline: auto; padding: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); color: var(--text-3); }
.credit a, .site-foot-bar a { color: var(--text-1); font-weight: 700; border-bottom: 2px solid var(--saffron); }
.credit a:hover, .site-foot-bar a:hover { color: var(--teal); }

/* Shared by landing/auth pages */
.site-footer { font-size: var(--fs-sm); color: var(--text-3); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.footer-links a:hover { text-decoration: underline; color: var(--text-2); }
.rights { margin-top: 6px; }
.credit { margin-top: 8px; }
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: var(--r-pill); color: var(--text-2); }
.lang summary::-webkit-details-marker { display: none; }
.lang summary:hover { background: var(--bg-hover); color: var(--text-1); }
.lang-menu { position: absolute; z-index: 60; min-width: 200px; padding: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.lang-side .lang-menu { bottom: calc(100% + 6px); inset-inline-start: 0; }
.lang-top .lang-menu { top: calc(100% + 6px); inset-inline-end: 0; }
.lang-menu a { display: block; padding: 10px 12px; border-radius: var(--r-sm); }
.lang-menu a:hover { background: var(--bg-hover); }
.lang-menu a[aria-current] { font-weight: 700; color: var(--teal); }

/* ==========================================================================
   Responsive
   ========================================================================== */
.bottom-nav, .fab, .m-only { display: none; }

@media (max-width: 1240px) {
    :root { --left-w: 240px; --right-w: 300px; --gap: 16px; }
}
@media (max-width: 1080px) {
    .layout, .app-head-in { grid-template-columns: minmax(0, var(--feed-w)) var(--right-w); max-width: calc(var(--feed-w) + var(--right-w) + var(--gap) + 32px); }
    .rail-left { display: none; }
    .app-head-in .brand { grid-column: auto; }
    .app-head-in { grid-template-columns: auto minmax(0, 1fr) auto; }
}
@media (max-width: 860px) {
    .layout { grid-template-columns: minmax(0, var(--feed-w)); justify-content: center; }
    .rail-right { display: none; }
    .site-foot-in { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
    :root { --head-h: 56px; }
    body { background: var(--bg); }
    .app-head-in { grid-template-columns: auto 1fr auto; gap: 8px; padding-inline: 12px; }
    .app-head .brand-name, .head-nav, .head-search, .head-post, .me-menu .chev { display: none; }
    .m-only { display: inline-grid; }
    .layout { padding: 0 0 calc(80px + env(safe-area-inset-bottom)); gap: 0; }
    .main { gap: 0; }
    .main > .card { border-radius: 0; border-inline: 0; border-top: 0; box-shadow: none; }
    .main > .card + .card { border-top: 8px solid var(--page); }
    .main > .flash { border-radius: 0; }
    .section-label { padding: 16px 16px 4px; }
    .composer.card { display: none; }
    .composer.card.is-sheet, .composer.card.has-errors { display: grid; }
    .composer.is-sheet {
        position: fixed; inset: 0; z-index: 80; align-content: start; background: var(--bg);
        padding-top: calc(12px + env(safe-area-inset-top)); border: 0 !important;
    }
    .composer.is-sheet .sheet-close { display: inline-grid; }
    .bottom-nav {
        position: fixed; inset-inline: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around; align-items: center;
        height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .95); border-top: 1px solid var(--line);
        backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px);
    }
    .bottom-nav a { position: relative; display: grid; place-items: center; width: 56px; height: 48px; color: var(--text-2); border-radius: var(--r-md); }
    .bottom-nav a.is-active { color: var(--teal); }
    .bottom-nav .dot-badge { top: 6px; inset-inline-end: 8px; }
    .fab {
        display: grid; place-items: center; position: fixed; z-index: 41; inset-inline-end: 16px;
        bottom: calc(72px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%;
        background: var(--teal); color: #fff; box-shadow: 0 8px 20px rgba(13, 122, 107, .35);
    }
    .profile-top .avatar.xl { width: 96px; height: 96px; margin-top: -48px; font-size: 36px; }
    .post-full .post-body { font-size: 17px; }
    .site-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

.site-foot-bar a.plain { border: 0; font-weight: 500; color: inherit; }
.site-foot-bar a.plain:hover { text-decoration: underline; }
.row-checks { display: flex; flex-wrap: wrap; gap: 16px; }
.row-checks:empty { display: none; }
.tabs a { display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.profile-stats > * { white-space: nowrap; }

/* ==========================================================================
   v4: fixed rails (no inner scrollbars), motto, friends, messages, safety
   ========================================================================== */
.rail { overflow: visible; max-height: none; transition: top .15s; }
.plain-bar { border: 0 !important; padding: 0 !important; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.icon-btn.bordered { border: 1px solid var(--line-2); width: 40px; height: 40px; }
.icon-btn.bordered:hover { border-color: var(--text-3); }
.pill-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.row-actions form { display: contents; }
.friend-btn { display: flex; gap: 6px; }
.friend-btn form { display: contents; }
.friend-menu summary { list-style: none; }
.friend-menu summary::-webkit-details-marker { display: none; }
.blocked-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 14px; border-radius: var(--r-md); background: var(--bg-2); color: var(--text-2); font-weight: 600; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
[hidden] { display: none !important; }

/* Categories as compact chips */
.topics-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 14px; }
.topics-chips a { padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--line); font-size: var(--fs-sm); color: var(--text-2); transition: border-color .15s, color .15s; }
.topics-chips a:hover { border-color: var(--teal); color: var(--teal); }
.topics-chips a.is-active { border-color: var(--teal); background: var(--teal-tint); color: var(--teal); font-weight: 700; }

/* The site's message */
.motto { margin: 0; text-align: center; color: var(--ink); }
.motto blockquote { margin: 0; font-family: "Aref Ruqaa", "Amiri", var(--display); font-weight: 700; line-height: 1.5; }
.motto figcaption { color: var(--text-3); font-size: var(--fs-sm); }
.motto-orn { width: 120px; height: 12px; margin: 0 auto 4px; color: var(--saffron); }
.motto-card { padding: 18px 16px 14px; border-radius: var(--r-md); background:
    radial-gradient(120% 140% at 100% 0%, rgba(232, 163, 23, .16), transparent 55%),
    radial-gradient(120% 140% at 0% 100%, rgba(13, 122, 107, .14), transparent 55%), var(--bg);
    border: 1px solid var(--line); }
.motto-card blockquote { font-size: 27px; background: linear-gradient(90deg, var(--teal), #0E8F7D 45%, var(--saffron-ink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.motto-foot { text-align: start; margin: 14px 0 0; }
.motto-foot .motto-orn { margin-inline: 0; }
.motto-foot blockquote { font-size: 24px; color: var(--teal); }
.motto-hero { margin-bottom: 18px; }
.motto-hero blockquote { font-size: clamp(26px, 3.4vw, 38px); color: var(--teal); }
.motto-hero figcaption { font-size: var(--fs-md); }

/* Report dialog */
.dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 16px; box-shadow: var(--shadow-pop); color: var(--text-1); }
.dialog::backdrop { background: rgba(10, 16, 30, .55); }
.dialog form { display: grid; gap: 12px; padding: 16px 20px 20px; }
.dialog-h { display: flex; align-items: center; justify-content: space-between; }
.dialog-h h2 { font-size: var(--fs-xl); }
.dialog-sub { color: var(--text-2); }
.reasons { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; }
.reason { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); cursor: pointer; transition: border-color .15s, background .15s; }
.reason:hover { background: var(--bg-hover); }
.reason:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.reason input { margin-top: 4px; accent-color: var(--teal); }
.reason b { display: block; }
.reason small { color: var(--text-3); }
.dialog textarea { width: 100%; padding: 10px 12px; border-radius: var(--r-md); border: 1.5px solid var(--line-2); background: var(--bg-2); resize: vertical; }
.dialog-f { display: flex; justify-content: flex-end; gap: 8px; }

/* Messages */
.layout-wide { grid-template-columns: minmax(0, 1100px) !important; justify-content: center; max-width: 1132px !important; }
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--head-h) - 40px); min-height: 480px; overflow: hidden; }
.chat-list { border-inline-end: 1px solid var(--line); overflow-y: auto; }
.chat-list-h { position: sticky; top: 0; z-index: 2; padding: 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.chat-list-h h1 { font-size: var(--fs-xl); }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; transition: background .15s; }
.chat-row:hover { background: var(--bg-hover); }
.chat-row.is-active { background: var(--teal-soft); }
.chat-row .who { flex: 1; min-width: 0; }
.chat-row .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-row .top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row time { flex: none; font-size: var(--fs-xs); color: var(--text-3); }
.chat-row .last { display: block; font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.is-unread .last { color: var(--text-1); font-weight: 600; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); flex: none; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-h { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chat-peer { display: flex; align-items: center; gap: 10px; }
.chat-peer span { display: flex; flex-direction: column; line-height: 1.3; }
.chat-peer span span { font-size: var(--fs-sm); color: var(--text-3); }
.m-back { display: none; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--bg-2); }
.chat-hello { display: grid; justify-items: center; gap: 6px; padding: 24px; text-align: center; color: var(--text-2); }
.chat-day { align-self: center; margin: 10px 0; padding: 3px 12px; border-radius: var(--r-pill); background: var(--bg); border: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-3); }
.msg { max-width: min(75%, 520px); align-self: flex-start; padding: 8px 12px 6px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.msg p { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.55; }
.msg time { display: block; margin-top: 2px; font-size: 11px; color: var(--text-3); text-align: end; }
.msg.mine { align-self: flex-end; background: var(--teal); border-color: var(--teal); color: #fff; }
.msg.mine time { color: rgba(255, 255, 255, .75); }
.msg.is-pending { opacity: .6; }
.msg-seen { align-self: flex-end; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg); }
.chat-form textarea { flex: 1; min-height: 42px; max-height: 160px; padding: 10px 14px; border-radius: 22px; border: 1px solid var(--line-2); background: var(--bg-2); resize: none; }
.chat-form textarea:focus { outline: none; border-color: var(--teal); background: var(--bg); }
.send-btn { background: var(--teal); color: #fff; width: 42px; height: 42px; }
.send-btn:hover { background: var(--teal-hover); color: #fff; }
.chat-blocked { padding: 16px; text-align: center; color: var(--text-3); border-top: 1px solid var(--line); }
.chat-placeholder { margin: auto; display: grid; justify-items: center; gap: 8px; padding: 32px; text-align: center; color: var(--text-2); }
.chat-placeholder .icon { color: var(--teal); }

@media (max-width: 860px) {
    .chat { grid-template-columns: 1fr; }
    .chat.has-thread .chat-list { display: none; }
    .chat:not(.has-thread) .chat-thread { display: none; }
    .m-back { display: inline-grid; }
}
@media (max-width: 680px) {
    .chat { height: calc(100vh - var(--head-h) - 56px - env(safe-area-inset-bottom)); border-radius: 0; border: 0; }
    .layout-wide { padding-bottom: 0; }
    .motto-card blockquote { font-size: 24px; }
}
.notif .k-friend_request, .notif .k-friend_accept { background: #2E9E5B; }
.notif .k-best_answer { background: var(--saffron); } .notif .k-help_needed { background: var(--teal); }

/* ==========================================================================
   v5: impact levels, solutions, library, weekly summary, transparency
   ========================================================================== */
.lvl { --lc: var(--text-3); display: inline-flex; align-items: center; gap: 4px; color: var(--lc); }
.lvl-seed { --lc: #8391A4; } .lvl-sprout { --lc: #3E9E5B; } .lvl-tree { --lc: #0D7A6B; }
.lvl-orchard { --lc: #2F7FB5; } .lvl-spring { --lc: #7A4FC9; } .lvl-river { --lc: #C9821A; }
.lvl-icon { flex: none; }
.lvl-chip { height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; background: color-mix(in srgb, var(--lc) 12%, transparent); }
.me-card .lvl-chip { margin: 6px auto 0; }
.lvl-full { padding: 12px 14px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); }
.lvl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lvl-score { font-weight: 700; color: var(--text-1); }
.lvl-bar { height: 8px; margin-top: 10px; border-radius: 4px; background: var(--line); overflow: hidden; }
.lvl-bar span { display: block; height: 100%; border-radius: 4px; background: var(--lc); }
.lvl-next { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.profile-impact { display: grid; gap: 10px; margin-top: 14px; justify-items: start; }
.profile-impact .lvl-full { width: 100%; }
.expertise-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-sm); }
.tag-cat-chip { height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--teal-tint); color: var(--teal); font-size: var(--fs-xs); font-weight: 700; display: inline-flex; align-items: center; }

.tag-paid { background: var(--saffron-soft); color: var(--saffron-ink); border: 1px solid var(--saffron); }
.post-note { display: flex; align-items: flex-start; gap: 6px; margin-top: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-2); color: var(--text-2); font-size: var(--fs-sm); }
.post-note .icon { margin-top: 2px; color: var(--text-3); }
.act-save[aria-pressed="true"] { color: var(--teal); }
.act-save[aria-pressed="true"] .icon path { fill: currentColor; }
@media (max-width: 460px) { .actions .act:not(.act-benefit):not(.act-help) span { display: none; } }

.comment.is-best .bubble { background: var(--teal-soft); box-shadow: inset 0 0 0 1.5px var(--teal); }
.best-badge { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; color: var(--teal); font-size: var(--fs-xs); font-weight: 700; }
.best-badge + .name { display: block; }
.link-accept { font-size: var(--fs-xs); font-weight: 700; color: var(--teal); }
.link-accept:hover { text-decoration: underline; }
.link-accept.is-on { color: var(--text-3); }
.comment-meta form { display: inline; }
.solution-card { padding: 16px 20px; border: 1.5px solid var(--teal); background: linear-gradient(180deg, var(--teal-soft), var(--bg) 70%); }
.solution-card h2 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); color: var(--teal); }
.solution-body { margin-top: 10px; font-size: 17px; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; }
.solution-by { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-sm); }
.solution-by:hover b { text-decoration: underline; }
.hint-card { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: var(--r-md); background: var(--saffron-soft); color: var(--saffron-ink); font-weight: 600; }
.title-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--teal-tint); color: var(--teal); flex: none; }

.week-card { padding: 16px; background: linear-gradient(135deg, var(--teal-soft), var(--bg) 55%), var(--bg); }
.week-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.week-head h2 { font-size: var(--fs-lg); }
.week-head p { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; }
.week-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.week-stats div { padding: 10px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); text-align: center; }
.week-stats dt { font-size: var(--fs-xs); color: var(--text-3); }
.week-stats dd { margin: 2px 0 0; font-size: var(--fs-xl); font-weight: 700; color: var(--teal); }
.week-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--teal); font-weight: 600; font-size: var(--fs-sm); }
.week-cta:hover { text-decoration: underline; }
@media (max-width: 520px) { .week-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.disclosure-row { margin: 4px 0 8px; }
.expertise-pick { border: 0; padding: 0; margin: 0; }
.expertise-pick legend { font-weight: 600; margin-bottom: 2px; }
.topics-chips.pick { padding: 8px 0 0; }
.topics-chips.pick label { cursor: pointer; }
.topics-chips.pick input { position: absolute; opacity: 0; pointer-events: none; }
.topics-chips.pick span { display: inline-block; padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); font-size: var(--fs-sm); color: var(--text-2); transition: all .15s; }
.topics-chips.pick input:checked + span { border-color: var(--teal); background: var(--teal-tint); color: var(--teal); font-weight: 700; }
.topics-chips.pick input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Impact card dialog */
.impact-dialog canvas { width: 100%; height: auto; border-radius: 12px; display: block; }
.impact-dialog .dialog-f { flex-wrap: wrap; }

/* v6: impact tree (tree rings) */
.tree-card { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 20px; align-items: center; padding: 20px; background: radial-gradient(circle at 0% 50%, var(--teal-soft), var(--bg) 62%), var(--bg); scroll-margin-top: 80px; }
[dir="rtl"] .tree-card { background: radial-gradient(circle at 100% 50%, var(--teal-soft), var(--bg) 62%), var(--bg); }
.tree-rings { position: relative; width: 188px; aspect-ratio: 1; }
.tree-rings svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tree-rings .ring-line { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 4; }
.tree-rings .ring-dot { transform-box: fill-box; transform-origin: center; animation: ring-in .5s cubic-bezier(.2, .8, .2, 1.2) both; animation-delay: var(--d); }
@keyframes ring-in { from { opacity: 0; transform: scale(0); } }
.tree-core { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); padding: 3px; border-radius: 50%; background: var(--bg); box-shadow: 0 0 0 2px var(--teal); }
[dir="rtl"] .tree-core { inset: 50% 50% auto auto; transform: translate(50%, -50%); }
.tree-core .avatar { width: 44px; height: 44px; font-size: 18px; }
.tree-body h2 { font-family: var(--display); font-size: var(--fs-xl); color: var(--text-1); }
.tree-lead { margin-top: 4px; color: var(--text-2); }
.tree-lead b { color: var(--teal); font-size: var(--fs-2xl); font-weight: 700; }
.tree-gens { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.tree-gens li { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: var(--fs-sm); color: var(--text-2); }
.tree-gens .gen-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tree-gens b { color: var(--text-1); font-size: var(--fs-md); }
.tree-gens .faces { display: inline-flex; margin-inline-start: auto; }
.tree-gens .faces a { margin-inline-start: -8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); }
.tree-gens .faces a:first-child { margin-inline-start: 0; }
.tree-note { margin-top: 12px; font-size: var(--fs-xs); color: var(--text-3); }
.tree-body .btn { margin-top: 12px; }
@media (max-width: 560px) {
    .tree-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .tree-gens li { text-align: start; }
}
@media (prefers-reduced-motion: reduce) { .tree-rings .ring-dot { animation: none; } }
.tree-core { display: grid; line-height: 0; }
@media (max-width: 440px) {
    .app-head .lang-top .lang-current { display: none; }
    .app-head .head-end .btn-compact { padding: 0 10px; }
}
@media (max-width: 360px) {
    .app-head .head-end .btn-ghost.btn-compact { display: none; }
}
/* v7: legal pages (privacy, terms) - a readable document, not a feed */
.legal { max-width: 760px; margin-inline: auto; padding: 32px 40px 28px; }
.legal-head { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.legal-head h1 { font-family: var(--display); font-size: 30px; line-height: 1.3; color: var(--text-1); }
.legal-date { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.legal-intro { margin-top: 14px; font-size: var(--fs-lg); line-height: 1.85; color: var(--text-2); }
.legal-toc { margin: 20px 0 4px; padding: 16px 20px; border-radius: var(--r-md); background: var(--bg-2); }
.legal-toc h2 { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.legal-toc ol { margin: 8px 0 0; padding-inline-start: 22px; columns: 2; column-gap: 32px; font-size: var(--fs-sm); line-height: 2; }
.legal-toc a { color: var(--teal); }
.legal-toc a:hover { text-decoration: underline; }
.legal-sec { padding-top: 24px; scroll-margin-top: 84px; }
.legal-sec h2 { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: var(--fs-xl); color: var(--text-1); }
.legal-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--teal-tint); color: var(--teal); font-family: var(--font); font-size: var(--fs-sm); font-weight: 700; flex: none; }
.legal-sec p, .legal-sec li { font-size: var(--fs-md); line-height: 1.95; color: var(--text-2); }
.legal-sec p { margin-top: 8px; padding-inline-start: 38px; }
.legal-sec ul { margin: 8px 0 0; padding-inline-start: 56px; }
.legal-sec li + li { margin-top: 6px; }
.legal-sec li::marker { color: var(--saffron); }
.legal-sec a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; word-break: break-all; }
.legal-sec:target h2 { color: var(--teal); }
.legal-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--text-3); }
.legal-foot a { color: var(--teal); font-weight: 600; }
@media (max-width: 640px) {
    .legal { padding: 22px 18px; border-radius: 0; }
    .legal-head h1 { font-size: 24px; }
    .legal-toc ol { columns: 1; }
    .legal-sec p { padding-inline-start: 0; }
    .legal-sec ul { padding-inline-start: 20px; }
}
@media print {
    .app-head, .site-foot, .legal-toc { display: none !important; }
    .legal { box-shadow: none; border: 0; max-width: none; }
}