.friends-page {max-width:1120px;padding-block:clamp(24px,4vw,48px)}
.friends-page [hidden] {display:none!important}
.friends-page h1,.friends-page h2,.friends-page h3,.friends-page p {margin:0}
.friends-heading,.friends-section-heading,.friends-chat-heading,.friends-actions,.friends-identity {display:flex;align-items:center}
.friends-heading {gap:14px;margin-bottom:24px}
.friends-heading-icon {display:grid;place-items:center;width:44px;height:44px;border-radius:14px;background:var(--accent);color:#18210e}
.friends-heading-icon .icon {width:26px;height:26px}
.friends-heading h1 {font-size:clamp(1.7rem,4vw,2.4rem);line-height:1.12;letter-spacing:-.035em}
.friends-grid,.friends-sidebar {display:grid;align-items:start;gap:14px}
.friends-sidebar,.friends-grid>* {min-width:0}
.friends-card {min-width:0;padding:18px;border:1px solid var(--line);border-radius:16px;background:var(--surface)}
.friends-card h2 {font-size:1.1rem;line-height:1.4;letter-spacing:-.015em}
.friends-card h3 {font-size:.875rem}
.friends-section-heading {justify-content:space-between;gap:10px}
.friends-count,.friends-unread {display:inline-grid;place-items:center;min-width:26px;min-height:24px;padding:2px 7px;border-radius:8px;font-size:.81rem;font-weight:700;font-variant-numeric:tabular-nums}
.friends-count {background:var(--raised);color:var(--muted)}
.friends-unread {margin-inline-start:auto;background:var(--accent);color:#18210e}
.friends-search [data-search-form],.friends-compose {display:flex;align-items:stretch;gap:8px;margin-top:12px}
.friends-input-wrap {position:relative;display:flex;align-items:center;min-width:0;flex:1}
.friends-input-wrap .icon {position:absolute;inset-inline-start:11px;width:18px;height:18px;color:var(--muted);pointer-events:none}
.friends-page input[type=search],.friends-compose textarea {box-sizing:border-box;width:100%;min-width:0;border:1px solid var(--line);border-radius:10px;background:var(--bg);color:var(--text);font:inherit;line-height:1.45}
.friends-page input[type=search] {height:44px;padding:9px 10px;padding-inline-start:36px}
.friends-compose textarea {resize:vertical;min-height:46px;max-height:160px;padding:10px 12px}
.friends-page :is(input,textarea)::placeholder {color:var(--muted)}
.friends-page :is(input,textarea,a,button,[tabindex]):focus-visible {outline:2px solid var(--accent);outline-offset:2px}
.friends-primary,.friends-action,.friends-text {display:inline-flex;align-items:center;justify-content:center;margin:0;border-radius:9px;line-height:1.25;font:inherit;font-weight:650;cursor:pointer}
.friends-primary {min-height:44px;padding:10px 18px;border:0;background:var(--accent);color:#17210c}
.friends-action {min-height:40px;padding:8px 10px;border:1px solid var(--line);background:var(--raised);color:var(--text);font-size:.875rem}
.friends-action[data-action="request"],.friends-action[data-action="accept"] {color:var(--accent)}
.friends-text {min-height:40px;padding:5px 2px;background:transparent;color:var(--accent);border:0;font-size:.875rem}
.friends-primary:hover {filter:brightness(1.07)}
.friends-action:hover {border-color:var(--muted)}
.friends-text:hover {text-decoration:underline}
.friends-page button:disabled,.friends-page textarea:disabled {opacity:.65;cursor:default}
.friends-page .friends-hint,.friends-placeholder {color:var(--muted);font-size:.94rem;line-height:1.55}
.friends-page .friends-hint {margin-top:12px}
.friends-page .friends-notice:not(:empty) {margin:0 0 14px;padding:12px 16px;border:1px solid var(--line);border-radius:10px;background:var(--surface)}
.friends-notice[data-error] {color:#ffd2d4}
.friends-notice:empty,.friends-hint:empty {display:none}
.friends-search [data-search-panel] {margin-top:14px;border-top:1px solid var(--line);padding-top:8px}
.friends-person,.friends-profile,.friends-roster-row {display:flex;align-items:center;gap:10px;overflow-wrap:anywhere}
.friends-people,.friends-roster,.friends-messages {list-style:none;padding:0;margin:0}
.friends-people:not(:empty),.friends-roster:not(:empty) {margin-top:10px}
.friends-person {padding:8px 0;flex-wrap:wrap}
.friends-person strong {min-width:0;flex:1;font-size:.95rem}
.friends-actions {gap:5px;flex-wrap:wrap}
.friends-roster li+li,.friends-people li+li {border-top:1px solid var(--line)}
.friends-roster-row {padding:6px 0}
.friends-profile {min-width:0;min-height:44px;flex:1 1 9rem;border-radius:6px}
.friends-profile,.friends-profile-name {color:var(--text);text-decoration:none}
.friends-profile strong,.friends-profile-name {text-decoration:underline;text-decoration-color:var(--muted);text-underline-offset:.18em}
.friends-profile:hover strong,.friends-profile-name:hover {color:var(--accent);text-decoration-color:currentColor}
.friends-roster-row .friends-action {gap:5px}
.friends-roster-row .friends-action[aria-current="true"] {border-color:var(--accent)}
.friends-initial {display:grid;place-items:center;position:relative;overflow:hidden;flex:none;width:36px;height:36px;border:1px solid var(--line);border-radius:12px;background:var(--raised);color:var(--text);font-size:1rem;font-weight:750;text-transform:uppercase}
.friends-initial img {position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.friends-identity {min-width:0;align-items:flex-start;flex-direction:column;gap:2px}
.friends-presence {display:flex;align-items:baseline;gap:6px;color:var(--muted);font-size:.875rem;line-height:1.4;overflow-wrap:anywhere}
.friends-presence::before {content:"";flex:none;width:7px;height:7px;align-self:baseline;border-radius:50%;background:#88919f}
.friends-presence.is-online::before {background:var(--accent)}
.friends-page[data-presence-stale] .friends-presence {visibility:hidden}
.friends-conversation {padding:0;overflow:hidden}
.friends-chat-heading {min-height:68px;gap:12px;padding:14px 18px;border-bottom:1px solid var(--line);overflow-wrap:anywhere}
.friends-chat-heading>div {min-width:0}
.friends-placeholder {display:grid;place-items:center;min-height:260px;padding:24px;text-align:center}
.friends-page .friends-thread {display:flex;flex-direction:column}
.friends-scroll {height:clamp(220px,48vh,540px);overflow-y:auto;overscroll-behavior:contain;padding:12px 16px;scrollbar-gutter:stable}
.friends-older {display:flex;margin-inline:auto}
.friends-messages {display:flex;flex-direction:column;gap:10px}
.friends-message {align-self:flex-start;max-width:min(86%,65ch);min-width:0;background:var(--raised);border:1px solid var(--line);border-radius:13px 13px 13px 3px;padding:9px 13px}
.friends-message.is-own {align-self:flex-end;background:#29361f;border-color:#485c37;border-radius:13px 13px 3px 13px}
.friends-message p {overflow-wrap:anywhere;white-space:pre-wrap;line-height:1.55}
.friends-message time {display:block;margin-top:4px;color:var(--muted);font-size:.78rem}
.friends-compose {align-items:center;margin:0;padding:12px 16px;border-top:1px solid var(--line);background:var(--surface)}
@media (min-width:761px) {
    .friends-grid {grid-template-columns:minmax(290px, .85fr) minmax(0,1.5fr);gap:20px}
    .friends-card {padding:20px}
    .friends-conversation {position:sticky;top:82px;padding:0}
    .friends-placeholder {min-height:340px}
    .friends-back {display:none}
}
@media (max-width:760px) {
    .friends-page:not([data-open]) .friends-conversation,.friends-page[data-open] .friends-sidebar {display:none}
    .friends-chat-heading {flex-wrap:wrap}
    .friends-back {width:100%;justify-content:flex-start;min-height:32px}
    .friends-scroll {height:clamp(160px,42dvh,500px)}
}
.friends-window {
    position:fixed;inset:0;margin:auto;padding:0;width:min(1040px,calc(100% - 32px));max-width:100%;
    max-height:calc(100dvh - 40px);overflow:hidden;border:1px solid var(--line);border-radius:20px;
    background:var(--bg);color:var(--text);box-shadow:0 20px 90px #0008;text-align:start
}
.friends-window[open] {display:flex;flex-direction:column}
.friends-window::backdrop {background:#080b13aa;backdrop-filter:blur(4px)}
.friends-window-bar {display:flex;align-items:center;gap:12px;padding:12px 20px;border-bottom:1px solid var(--line);background:var(--surface)}
.friends-window-bar h2 {flex:1;margin:0;font-size:1.3rem;line-height:1.3}
.friends-window .friends-window-close {display:grid;place-items:center;flex:none;width:44px;height:44px;margin:0;border:1px solid var(--line);border-radius:50%;background:var(--raised);color:var(--text);font:inherit;font-size:1.6rem;line-height:1;cursor:pointer}
.friends-window-body {min-height:0;overflow:auto;overscroll-behavior:contain}
.friends-window [data-window-status]:not(:empty),.friends-window-errors {margin:16px 20px}
.friends-window [data-window-status]:empty,.friends-window-errors[hidden] {display:none}
.friends-window-errors {display:flex;align-items:center;gap:16px}
.friends-window .friends-page {width:100%;margin:0;padding:16px}
.friends-window .friends-conversation {top:0}
@media (max-width:760px) {
    .friends-window {width:100%;inset:auto 0 0;max-height:calc(100dvh - max(14px,env(safe-area-inset-top)));margin:0 auto;border-inline:0;border-bottom:0;border-radius:20px 20px 0 0}
    .friends-window-bar {padding:8px 14px}
    .friends-window .friends-page {padding:12px 10px max(16px,env(safe-area-inset-bottom))}
    .friends-window .friends-scroll {height:clamp(150px,40dvh,460px)}
}
