.friends-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vw, 13px);
}

.friends-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.friends-tabs button, .friend-card-action, #friends-gift-all { position: relative; white-space: nowrap; }
.friends-tabs button[data-ready="true"]::after,
#friends-gift-all[data-ready="true"]::after,
.friend-card-action[data-ready="true"]::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border: 1px solid #fff5e2;
  border-radius: 50%;
  background: #c9513c;
  box-shadow: 0 1px 2px #6d211940;
  pointer-events: none;
}

.friends-book {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--collection-line);
  border-top-color: #fffaf1;
  border-radius: 8px 19px;
  background: var(--collection-surface);
  box-shadow: inset 0 0 0 1px #fff9ed, 0 3px 8px #895c381e;
}
.friends-pane { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.friends-loading { margin: 1.15rem var(--gap) .65rem; text-align: center; color: var(--collection-muted); font-size: var(--text-body); }
#friends-retry { align-self: center; }
.friends-toolbar, .friends-own-uid {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px clamp(8px, 2.5vw, 15px);
  border-bottom: 1px solid var(--collection-line);
  background: linear-gradient(110deg, #f1dfc9, #fff6e7);
  color: #674733;
  font-size: var(--text-label);
}
.friends-toolbar strong { font-variant-numeric: tabular-nums; }
.friends-text-action {
  flex: none;
  min-height: 36px;
  padding: 2px .6rem;
  border: 1px solid #b78b65a1;
  border-top-color: #c6a17f;
  border-radius: 5px 10px;
  background: #fff8eb;
  color: #6d482f;
  font-size: var(--text-small);
  font-weight: 750;
  white-space: nowrap;
}
.friends-text-action:disabled { opacity: .6; cursor: default; }

.friends-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.friends-list { display: grid; gap: 6px; margin: 0; padding: 8px; list-style: none; }
.friends-list:empty { padding: 0; }
.friend-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 62px;
  padding: 5px 6px;
  border: 1px solid #bb906756;
  border-top-color: #fffaf1;
  border-radius: 6px 14px;
  background: linear-gradient(145deg, #fff8eb, #f4e5d1);
}
.friend-card[data-gift="true"] {
  border-color: #bd8a52;
  border-top-color: #fff7e0;
  background: linear-gradient(135deg, #fff2d5, #efddbb);
}
.friend-person {
  display: flex;
  align-items: center;
  gap: clamp(5px, 2vw, 9px);
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--collection-ink);
  text-align: start;
}
.friend-person:active { transform: translateY(1px); }
.friend-person .friend-avatar { flex: none; width: clamp(37px, 10.8vw, 51px); }
.friend-person-text { display: grid; min-width: 0; gap: 2px; }
.friend-person-text > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-label); }
.friend-person-text > small { color: var(--collection-muted); font-size: var(--text-micro); }
.friend-person-text > small[data-online="true"] { color: #436643; }

.friend-card-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; }
.friend-card-action { min-height: 37px; padding: 4px 7px; font-size: var(--text-small); }
.friend-card-label {
  display: inline-grid;
  place-items: center;
  min-height: 37px;
  padding-inline: 3px;
  color: #785d46;
  font-size: var(--text-micro);
  font-weight: 750;
  white-space: nowrap;
}

.friends-screen .game-button {
  border: 1px solid #a87651;
  border-top-color: #ebc693;
  border-radius: 5px 11px;
  background: linear-gradient(150deg, #8c6247, #634031);
  box-shadow: inset 0 0 0 1px #ffe5b82e, 0 2px 3px #57362633;
  color: #fff6e6;
  text-shadow: none;
  font-weight: 750;
}
.friends-screen .game-button-alt {
  border-color: #b78b65a1;
  border-top-color: #c6a17f;
  background: #fff7e7;
  color: #674733;
  box-shadow: none;
}
.friends-screen .game-button:disabled { filter: none; opacity: .56; }
.friends-screen .game-button:active { box-shadow: none; transform: translateY(1px); }

.friends-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: clamp(18px, 8dvh, 56px) 8px;
}
.friends-empty img { width: clamp(72px, 24vw, 97px); height: auto; object-fit: contain; opacity: .76; }
.friends-empty p, .friends-empty-text { margin: .4em 0; color: var(--collection-muted); text-align: center; font-size: var(--text-body); }
.friends-empty-text { padding: 1rem .6rem; }
.friends-gift-footer, .friends-actions {
  flex: none;
  padding: 8px 9px;
  border-top: 1px solid var(--collection-line);
  background: #f6e6d0;
}
.friends-gift-footer {
  display: grid;
  grid-template-columns: clamp(24px, 8vw, 36px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.friends-gift-footer > img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.friends-gift-footer :is(strong, small) { display: block; }
.friends-gift-footer strong { font-size: var(--text-label); }
.friends-gift-footer small { color: var(--collection-muted); font-size: var(--text-micro); }
#friends-gift-all { font-size: var(--text-small); }
.friends-actions { display: flex; justify-content: flex-end; gap: 6px; }
.friends-actions .game-button { min-height: 37px; font-size: var(--text-label); }

.friends-search {
  display: grid;
  flex: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
}
.friends-search input {
  width: 100%;
  min-width: 0;
  min-height: var(--touch);
  padding: 3px .65rem;
  border: 1px solid #b78b65a1;
  border-radius: 6px 11px;
  background: #fffaf0;
  box-shadow: inset 0 1px 3px #90674417;
  color: var(--collection-ink);
  font-size: max(16px, var(--text-body));
}
.friends-search input:focus { outline: 2px solid #a26c3f; outline-offset: -2px; }
.friends-search button { font-size: var(--text-label); }
.friends-own-uid { border-block: 1px solid var(--collection-line); background: #fff6e5; }
.friends-own-uid span { min-width: 0; font-size: var(--text-small); }
.friends-own-uid b { font: 750 clamp(.65rem, 2.5vw, .83rem)/1.3 ui-monospace, monospace; overflow-wrap: anywhere; user-select: all; }
.friends-preference { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-small); white-space: nowrap; }
.friends-preference input { width: 16px; height: 16px; accent-color: #8d6243; }
.friends-outgoing { margin: 6px 8px; border: 1px solid var(--collection-line); border-radius: 6px 12px; background: #fff5e4; }
.friends-outgoing summary { padding: 8px; cursor: pointer; font-size: var(--text-label); font-weight: 750; }

.friend-public-card {
  position: relative;
  container-type: inline-size;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(74px, 38%);
  gap: clamp(4px, 1.8vw, 10px);
  padding: clamp(12px, 3.9vw, 17px);
  border: 1px solid #ad80539c;
  border-top-color: #fffbeb;
  border-radius: 10px 21px 10px 21px;
  background:
    linear-gradient(90deg, #fcf1dd 4%, #f8e8ce 35%, #f5e2c8e8 49%, #f0ddbd68 65%, transparent 84%),
    linear-gradient(0deg, #69452f80 0%, transparent 51%),
    url("assets/garden-ui/conservatory.webp?v=wide-lobby") right 35% / 60% auto no-repeat,
    #efddbe;
  box-shadow: inset 0 0 0 1px #fff5dbd4, 0 3px 8px #734b2824;
}
.friend-public-card::before {
  position: absolute;
  inset: 5px;
  z-index: 1;
  border: 1px solid #fff8eaa8;
  border-radius: 5px 17px 6px 16px;
  pointer-events: none;
  content: "";
}
.friend-public-identity {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: clamp(3px, 1.8cqi, 8px);
  min-width: 0;
}
.friend-public-identity .friend-avatar {
  width: clamp(51px, 23cqi, 75px);
  margin-inline-start: 2px;
  filter: drop-shadow(0 2px 2px #62462829);
}
.friend-public-details { display: grid; gap: 3px; min-width: 0; width: 100%; }
.friend-public-details > strong {
  color: #503124;
  font: 800 clamp(18px, 7.2cqi, 28px)/1.13 var(--font-title);
  overflow-wrap: anywhere;
}
.friend-public-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding-top: 3px; }
.friend-public-stats small { color: #725137; font-size: var(--text-small); line-height: 1.25; }
.friend-public-stats small:first-child {
  padding: 2px 7px;
  border: 1px solid #c69b647a;
  border-radius: 5px 8px;
  background: #fff7e6b5;
  color: #70452d;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.friend-public-achievement .achievement-plate { width: min(100%, 159px); margin-inline: 0; }
.friend-companion-spotlight {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding-top: 6px;
  text-align: center;
}
.friend-companion-spotlight .lobby-character {
  width: 100%;
  height: clamp(104px, 47cqi, 158px);
  filter: drop-shadow(0 4px 4px #56381855);
}
.friend-companion-spotlight figcaption {
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #fff1d24f;
  border-radius: 6px 9px;
  background: #664630dc;
  color: #fff4dd;
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.collection-dialog-actions #friend-card-action {
  min-height: 44px;
  border-radius: 8px 14px;
  font-weight: 750;
}
.collection-dialog-actions #friend-card-action[data-intent="add"]:enabled {
  border-color: #96633d;
  border-top-color: #e4bb8f;
  background: linear-gradient(145deg, #a57955, #694433 82%);
  color: #fff7e7;
  box-shadow: inset 0 1px #fee3bebf, 0 2px 4px #784d2e38;
  text-shadow: 0 1px #53331e;
}
.collection-dialog-actions #friend-card-action[data-intent="block"]:enabled,
.collection-dialog-actions #friend-card-action[data-intent="neutral"]:enabled {
  border-color: #bd987b;
  border-top-color: #e6c6a4;
  background: linear-gradient(135deg, #fff7e8, #f0ddc7);
  color: #67432f;
  box-shadow: inset 0 1px #fff9efd9;
  text-shadow: none;
}

@media (min-width: 680px) {
  .friends-workspace { display: grid; grid-template-columns: minmax(104px, 18%) minmax(0, 1fr); }
  .friends-tabs { align-self: start; grid-template-columns: 1fr; }
}
@media (max-width: 325px) {
  .friend-card-action { padding-inline: 4px; }
}
@media (max-height: 440px) {
  .friends-scroll { flex: 1 0 64px; }
}
