/* Chat workspace: shared visual language, desktop panes and touch navigation. */
:root {
  --bg: #101015;
  --bg-elevated: #19171f;
  --surface: #1c1a23;
  --surface-alt: #27232f;
  --surface-hover: #302a3b;
  --border: #3c3449;
  --border-soft: #302a38;
  --primary: #bd9aff;
  --primary-dim: #7950d6;
  --primary-alt: #b74c9a;
  --text-muted: #b2aabd;
  --radius-lg: 18px;
}
:root[data-theme="light"] {
  --bg: #f3f1f7;
  --bg-elevated: #fff;
  --surface: #fff;
  --surface-alt: #f0ebf7;
  --surface-hover: #e9e1f3;
  --border: #d6cce3;
  --border-soft: #e5ddec;
  --primary: #7042ba;
  --primary-dim: #7042ba;
  --primary-alt: #a93984;
  --text-muted: #6d6279;
}
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.btn-primary, .icon-btn-send { background: var(--primary-dim); box-shadow: none; }
.btn-primary:hover { background: var(--primary-alt); }
.text-input { border-radius: 12px; }
.text-input:focus { border-color: var(--primary); }
.muted, .friend-preview { line-height: 1.6; }
.chat-toolbar { background: var(--bg-elevated); border-bottom: 1px solid var(--border-soft); }
.chat-input-wrapper { background: var(--bg-elevated); border-top: 1px solid var(--border-soft); }
.messages { background: var(--bg); overscroll-behavior: contain; }
.messages:empty::before { content: 'כאן מתחילה השיחה. אפשר פשוט להגיד שלום 👋'; display: block; margin: auto; padding: 28px; text-align: center; color: var(--text-muted); font-size: 15px; line-height: 1.7; }
#tab-group-chat .chat-input-wrapper { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
#group-reply-preview { flex-basis: 100%; min-width: 0; margin: 0; }
#group-draft { flex: 1; min-width: 0; padding: 12px 14px; }
#btn-group-send { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--primary-dim); }
#btn-group-send svg { color: white; }
#btn-group-send:disabled { opacity: .4; cursor: not-allowed; }
.list-search { width: 100%; min-width: 0; margin-bottom: 12px; min-height: 44px; flex-shrink: 0; }
.search-empty { padding: 12px; text-align: center; }
.friend-row[hidden], .search-empty[hidden] { display: none !important; }
.is-searching #public-groups-empty, .is-searching #my-groups-empty, .is-searching #friends-empty { display: none !important; }
.friend-row[role="button"]:focus-visible { outline-offset: -3px; }
.connection-status-mobile { display: none; }
.chat-textarea { background: var(--surface-alt); line-height: 1.5; }
.chat-toolbar-actions { gap: 8px; }
.icon-btn, .btn-toolbar-action, .btn-inside-textarea { min-width: 40px; min-height: 40px; }
.friend-row { border-radius: 12px; transition: background .15s; }
.friend-row:hover { background: var(--surface-hover); }
.modal-card { border: 1px solid var(--border); }
.connection-status { font-size: 13px; color: var(--text-muted); white-space: nowrap; margin-inline-end: 16px; }
.connection-status::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); margin-inline-end: 7px; }
.connection-status.is-connected::before { background: var(--success); }
.match-intro { text-align: start; }
.match-intro strong, .match-intro span { display: block; }
.match-intro strong { font-size: 17px; }
.match-intro span { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
#home-idle .idle-actions { gap: 8px; }
#btn-find { min-height: 46px; border-radius: 12px; }
#view-welcome { background: radial-gradient(ellipse at 75% 0%, #7950d622, transparent 60%), var(--bg); }
#view-welcome .container { max-width: 560px; padding: 44px 32px; }
.welcome-eyebrow { color: var(--primary); font-size: 14px; font-weight: 700; }
.welcome-title { font-size: clamp(34px, 5vw, 48px); line-height: 1.15; letter-spacing: -1.2px; margin: 16px 0; }
#view-welcome .card { margin: 28px 0 20px; background: var(--bg-elevated); box-shadow: none; }
#view-welcome .bullet { font-size: 14px; }
.welcome-consent { margin: 4px 0 14px; font-size: 14px; line-height: 1.7; color: var(--text); text-align: start; }
.welcome-consent a { color: var(--primary); text-decoration: underline; }
#view-welcome #btn-start { width: 100%; }
#view-welcome .legal-links { line-height: 1.8; }
#view-profile .container { padding-bottom: 40px; }

@media (min-width: 900px) {
  .side-nav { height: 72px; padding: 0 28px; background: var(--bg-elevated); border-bottom: 1px solid var(--border); justify-content: flex-start; gap: 28px; }
  .side-nav-logo { margin: 0; }
  .side-nav .nav-btn { min-height: 44px; padding: 10px 18px; border-radius: 12px; white-space: nowrap; }
  .side-nav .nav-btn.active { color: var(--primary); background: var(--surface-alt); box-shadow: none; }
  .main-content { max-width: 1680px; grid-template-columns: 230px minmax(300px, 1fr) 250px; grid-template-areas: 'stories stories stories' 'rooms wall friends'; grid-template-rows: auto minmax(0, 1fr); gap: 16px; padding: 20px 24px 100px; align-items: stretch; }
  #online-users-section { border: 1px solid var(--border-soft); border-radius: 16px; background: var(--bg-elevated); padding: 12px 18px; min-width: 0; }
  /* Heading is just the collapse arrow, pinned to the left edge (direction:ltr
     keeps it on the left whatever the page direction is). */
  #tab-home .online-users-heading { display: flex; justify-content: flex-start; direction: ltr; align-items: center; margin: 0; font-size: 14px; }
  #tab-home .online-users-heading .people-toggle { padding: 0; min-height: 0; margin: 0 auto 0 0; }
  #tab-home .online-users-heading { width: 100%; box-sizing: border-box; }
  #tab-home .online-users-grid { padding: 24px 4px 4px; gap: 20px; }
  /* Notes float above the avatars and must show OVER the arrow row, not be cut
     off by it. The row clips whatever sticks out of it, so instead of adding
     height we pull the row up underneath the arrow (negative margin = arrow
     row 26px + section padding 12px) and give it the same amount of extra top
     padding: the layout height is unchanged, but the bubbles now have room and
     are stacked above the arrow. The empty headroom ignores clicks so the arrow
     underneath stays clickable; avatar cards still receive them. */
  /* Heading row sits above the people block but only its arrow takes clicks. */
  #tab-home .online-users-heading { position: relative; z-index: 5; pointer-events: none; }
  #tab-home .online-users-heading .people-toggle { pointer-events: auto; }
  #tab-home .online-users-scroll-wrap { position: relative; z-index: 2; }
  /* Same trick sideways: a wide bubble over the first/last avatar overhangs its
     card and was clipped at the row's edge. The row extends 18px into the
     section's own side padding (negative margin) and gets that back plus the
     old 4px as inner padding, so avatars don't move but bubbles have 22px. */
  #tab-home .online-users-grid { margin: -38px -18px 0; padding: 62px 22px 4px; }
  /* #people-content must not clip the part of the row that sticks up out of it;
     the collapse animation still clips via .is-animating. */
  #tab-home #people-content { overflow: visible; }
  /* Own block formatting context (same as mobile). Without it the row's -38px top
     margin collapses THROUGH #people-content and shifts the whole box up, so while
     its height animates to 0 the section shrinks 38px too far and snaps back once
     the box is display:none. (Before, the clip rule made it a BFC by accident.)
     Layout in the normal state is identical either way. */
  #tab-home #people-content:not([hidden]) { display: flow-root; }
  #online-users-empty { text-align: start; }
  #tab-rooms.hub-col { grid-area: rooms; width: 100%; }
  #tab-wall.hub-col, #home-chat, #tab-group-chat.hub-col, #tab-dm.hub-col { grid-area: wall; width: 100%; min-width: 0; }
  #tab-rooms.hub-col, #tab-wall.hub-col, #tab-friends.hub-col, #home-chat, #tab-group-chat.hub-col, #tab-dm.hub-col { top: 88px; height: max(380px, calc(100dvh - 320px)); border-radius: 16px; box-shadow: none; }
  #tab-rooms.hub-col > .tab-title, #tab-wall.hub-col > .tab-title { display: flex; }
  .hub-col .tab-title { font-size: 18px; padding-bottom: 16px; margin-bottom: 12px; }
  #tab-rooms.hub-col, #tab-friends.hub-col { padding: 18px 14px; }
  #tab-friends .centered-box, #tab-rooms .centered-box { padding: 28px 10px; font-size: 14px; line-height: 1.7; }
  #home-idle { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px; padding: 12px 16px; bottom: 18px; box-shadow: var(--shadow-md); }
  #home-idle .match-intro { display: inline-block; vertical-align: middle; margin-inline-end: 28px; }
  #home-idle .idle-actions { display: inline-flex; vertical-align: middle; }
  #home-idle .btn { margin: 0; }
  #btn-flappy-open-idle { border-radius: 12px; }
  #home-waiting, #home-left { border-radius: 18px; }
  #tab-profile.tab-page { grid-column: 1 / -1; width: min(100%, 640px); margin: auto; }
}
@media (min-width: 900px) and (max-width: 1100px) {
  .main-content { grid-template-columns: 190px minmax(280px, 1fr) 200px; padding-inline: 16px; gap: 12px; }
  .side-nav { padding-inline: 20px; gap: 16px; }
  .connection-status { display: none; }
}
@media (max-width: 899px) {
  .connection-status-mobile { display: block; font-size: 11px; max-width: 150px; margin: 0; white-space: normal; line-height: 1.3; }
  .connection-status-mobile.is-connected { display: none; }
  body.chat-fullscreen .chat-page { top: calc(60px + var(--chat-viewport-top, 0px)); height: calc(var(--chat-viewport-height, 100dvh) - 60px); bottom: auto; }
  .main-content { padding-top: 60px; }
  .app-header { border-bottom: 1px solid var(--border-soft); background: var(--bg-elevated); }
  .bottom-nav { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); gap: 6px; box-shadow: 0 -4px 24px #00000012; }
  .bottom-nav .nav-btn { min-height: 48px; border-radius: 12px; justify-content: center; gap: 4px; }
  .bottom-nav .nav-btn.active { background: var(--surface-alt); color: var(--primary); }
  .bottom-nav .nav-btn small { font-size: 12px; }
  #tab-home .online-users-heading { display: flex; align-items: center; gap: 8px; margin: 16px 16px 0; font-size: 14px; }
  #home-idle { position: relative; inset: auto; transform: none; max-width: none; margin: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: none; z-index: auto; }
  #home-idle .idle-actions { display: flex; margin-top: 14px; }
  #home-idle .btn { margin: 0; }
  #home-idle #btn-find { flex: 1; width: auto; }
  #btn-flappy-open-idle { width: 48px; border-radius: 12px; }
  #tab-wall { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  #home-waiting, #home-left { border-radius: 18px; width: calc(100% - 32px); text-align: center; }
  #home-waiting p, #home-left p { white-space: normal; }
  .text-input { font-size: 16px; }
  .chat-toolbar { padding: 10px 12px; }
  .chat-input-wrapper { padding-inline: 10px; }
  .messages { padding: 16px 12px; }
  #view-welcome .container { padding: 28px 22px; }
  .welcome-title { margin: 12px 0; }
  #view-welcome .card { padding: 18px; margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Compact room directory: a fixed toolbar above one continuous list. */
.people-toggle { display: flex; align-items: center; gap: 12px; border: 0; padding: 6px 0; background: none; color: inherit; font: inherit; cursor: pointer; min-height: 36px; text-align: start; }
.people-chevron { display: inline-block; font-size: 18px; color: var(--primary); }
.people-toggle[aria-expanded="false"] .people-chevron { transform: rotate(180deg); }
#people-content[hidden] { display: none; }
.room-password-hint { margin: 0; font-size: 12px; }
.room-password-dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; width: min(400px, calc(100% - 32px)); box-shadow: var(--shadow-lg); }
.room-password-dialog::backdrop { background: #0009; backdrop-filter: blur(4px); }
.room-password-dialog h3 { margin-top: 0; }
.room-password-dialog .text-input { width: 100%; }
@media (min-width: 900px) {
  .main-content:has(#online-users-section.is-collapsed) :is(#tab-rooms.hub-col, #tab-friends.hub-col, #tab-wall.hub-col, #home-chat, #tab-dm.hub-col, #tab-group-chat.hub-col) { height: max(380px, calc(100dvh - 190px)); }
}

#tab-rooms.hub-col { padding: 0; border-radius: 10px; background: var(--bg-elevated); }
.rooms-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rooms-panel-header .tab-title { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; border: 0; font-size: 18px; }
.rooms-count { color: var(--text-muted); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.rooms-count::before { content: '('; }
.rooms-count::after { content: ')'; }
.room-create-button { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--primary); font-size: 28px; cursor: pointer; }
.room-create-button:hover, .room-create-button[aria-expanded="true"] { background: var(--surface-alt); border-color: var(--border); }
#tab-rooms .list-search { width: calc(100% - 24px); margin: 12px; min-height: 40px; padding: 9px 12px; background: var(--bg); border-color: var(--border-soft); font-size: 14px; border-radius: 8px; }
#tab-rooms #rooms-list-scroll { padding: 0 0 12px; }
#tab-rooms .room-row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; margin: 0; border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; background: transparent; box-shadow: none; cursor: pointer; }
#tab-rooms .room-row:hover { background: var(--surface-hover); }
#tab-rooms .room-row.active { background: var(--surface-alt); box-shadow: inset -3px 0 var(--primary); }
#tab-rooms .room-row.active .friend-name { color: var(--primary); }
.room-symbol { width: 22px; flex-shrink: 0; color: var(--text-muted); text-align: center; font-size: 22px; line-height: 1; }
.room-row-name { flex: 1; min-width: 0; }
#tab-rooms .friend-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-private-label { display: block; color: var(--text-muted); font-size: 11px; }
.room-member-count { min-width: 28px; padding: 3px 7px; background: var(--bg); border-radius: 6px; color: var(--text-muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
#tab-rooms #room-row-wall { margin-bottom: 8px; }
#tab-rooms #public-groups-empty, #tab-rooms #my-groups-empty { padding: 18px 16px; font-size: 13px; line-height: 1.6; }
#tab-rooms .create-group-popover { position: absolute; top: 62px; bottom: auto; left: 10px; width: calc(100% - 20px); max-width: none; border: 1px solid var(--border); border-radius: 10px; }
#tab-rooms .create-group-popover::after { top: auto; bottom: 100%; left: 15px; border-top-color: transparent; border-bottom-color: var(--surface); }
@media (max-width: 899px) {
  #tab-rooms.hub-col { position: relative; margin: 0; min-height: calc(100dvh - 60px); padding-bottom: calc(84px + env(safe-area-inset-bottom)); border-radius: 0; }
  .rooms-panel-header { min-height: 62px; padding-inline: 16px; }
  #tab-rooms .list-search { font-size: 16px; }
  #tab-rooms .room-row { min-height: 56px; padding-inline: 18px; }
  #tab-rooms .create-group-popover { top: 66px; left: 12px; width: min(320px, calc(100% - 24px)); }
}

/* Room directory and create dialog follow the supplied Catch references. */
#tab-rooms.hub-col { background: #08070b; border: 0; border-radius: 34px; padding-bottom: 62px; }
#tab-rooms .rooms-panel-header { justify-content: flex-start; border: 0; min-height: 66px; padding: 16px 22px; }
#tab-rooms .rooms-panel-header .tab-title { color: #fff; font-size: 23px; }
#tab-rooms .rooms-count { color: #fff; font-size: 21px; font-weight: 700; }
#tab-rooms .room-create-button { position: absolute; bottom: 18px; left: 20px; background: #0879ff; color: #08070b; width: 42px; height: 42px; border: 0; border-radius: 16px; font-size: 30px; font-weight: 800; }
#tab-rooms .list-search { background: #140c20; color: #fff; margin-top: 0; border: 0; border-radius: 18px; }
#tab-rooms #rooms-list-scroll { padding: 0 0 8px; }
#tab-rooms .room-row { min-height: 68px; padding: 8px 18px; gap: 12px; border: 0; flex-direction: row; border-radius: 36px; }
#tab-rooms .room-row.active { background: #251039; box-shadow: none; }
#tab-rooms .room-row:hover { background: #1c1028; }
#tab-rooms .room-row .friend-name, #tab-rooms .room-row.active .friend-name { font-size: 18px; color: #faf8ff; font-weight: 600; }
#tab-rooms .room-symbol { display: grid; place-items: center; position: relative; width: 40px; height: 40px; border: 1px solid #dfd6e8; border-radius: 50%; color: #fff; font-size: 26px; }
.room-online-label { display: block; color: #938b9c; font-size: 13px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.room-lock-badge { position: absolute; top: -7px; left: -5px; font-size: 12px; line-height: 18px; border-radius: 50%; background: #251039; }
#tab-rooms .room-private-label { color: #b4a8c0; font-size: 11px; }
#tab-rooms #room-row-wall { border-bottom: 1px solid #20152a; border-radius: 0; margin-bottom: 6px; }
#create-group-form.room-create-dialog { width: min(350px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px; border: 0; border-radius: 36px; color: white; background: #08070b; box-shadow: 0 16px 70px #0008; }
.room-create-dialog::backdrop { background: #0008; backdrop-filter: blur(5px); }
.room-create-name-row, .room-create-password-row { display: flex; gap: 8px; align-items: center; margin-bottom: 20px; }
.room-create-name-row { background: #241033; border-radius: 20px; gap: 0; }
.room-create-dialog .text-input { min-width: 0; width: 100%; flex: 1; background: #241033; border: 0; border-radius: 20px; font-size: 18px; padding: 8px 12px; min-height: 42px; color: white; margin: 0; }
.room-create-dialog .text-input:disabled { opacity: .4; }
.room-icon-picker { width: 42px; height: 42px; flex-shrink: 0; padding: 0; border: 1px solid #e9dff4; border-radius: 50%; color: white; background: #241033; font-size: 26px; cursor: pointer; }
.room-lock-toggle { width: 36px; height: 42px; flex-shrink: 0; border: 0; border-radius: 18px; background: #241033; font-size: 20px; cursor: pointer; }
.room-lock-toggle[aria-pressed="true"] { background: #ed00a8; }
.room-create-actions { display: flex; align-items: center; gap: 10px; }
.room-create-actions .btn { margin: 0; min-height: 42px; padding: 7px 12px; border-radius: 24px; font-size: 18px; }
#btn-create-group-submit { flex: 1; background: #0879ff; color: #fff; }
#btn-create-group-cancel { width: auto; background: #241033; color: #fff; }
.room-icon-options { display: grid; grid-template-columns: repeat(4, 1fr); max-height: 180px; overflow: auto; gap: 6px; margin: -8px 0 20px; }
.room-icon-options[hidden] { display: none; }
.room-icon-options button { min-height: 42px; border: 0; border-radius: 12px; background: none; font-size: 26px; cursor: pointer; }
.room-icon-options button:hover { background: #241033; }
#room-create-error:empty { display: none; }
#room-create-error { margin: 12px 0 0; font-size: 14px; }
@media (max-width: 899px) {
  #tab-rooms.hub-col { border-radius: 0; padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  #tab-rooms .room-create-button { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); left: 20px; }
}
:root[data-theme="light"] #tab-rooms.hub-col { background: var(--surface); }
:root[data-theme="light"] #tab-rooms .rooms-panel-header .tab-title,
:root[data-theme="light"] #tab-rooms .rooms-count,
:root[data-theme="light"] #tab-rooms .room-row .friend-name { color: var(--text); }
:root[data-theme="light"] #tab-rooms .room-symbol { border-color: var(--border); color: var(--text); }
:root[data-theme="light"] #tab-rooms .room-row.active,
:root[data-theme="light"] #tab-rooms .room-row:hover,
:root[data-theme="light"] #tab-rooms .list-search { background: var(--surface-alt); color: var(--text); }

/* Compact room UI, shared modal palette, and mobile-friendly cards. */
#tab-rooms .rooms-panel-header { min-height: 56px; padding: 14px 18px; }
#tab-rooms .rooms-panel-header .tab-title { font-size: 18px; }
#tab-rooms .rooms-count { font-size: 15px; }
#tab-rooms .room-row { min-height: 58px; padding: 8px 16px; margin-left: 18px; border-radius: 28px 0 0 28px; }
#tab-rooms .room-row .friend-name, #tab-rooms .room-row.active .friend-name { font-size: 15px; font-weight: 500; }
#tab-rooms .room-row.active { background: var(--bg); }
:root[data-theme="light"] #tab-rooms .room-row.active { background: var(--bg); }
#tab-rooms .room-row:hover:not(.active) { background: var(--surface-alt); }
#tab-rooms #room-row-wall { border-color: var(--border-soft); margin-left: 0; }
#tab-rooms .room-symbol, .room-symbol, .room-icon-picker { width: 34px; height: 34px; border-radius: 13px 13px 4px 13px; font-size: 21px; }
.room-symbol { display: inline-grid; place-items: center; flex-shrink: 0; border: 1px solid var(--border); }
.room-symbol svg { width: 23px; height: 23px; }
#group-chat-name { display: flex; align-items: center; gap: 10px; font-size: 16px; }
#create-group-form.room-create-dialog, #room-password-dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border-soft); padding: 24px; border-radius: 28px; width: min(350px, calc(100% - 32px)); }
.room-create-name-row, .room-create-dialog .text-input, .room-icon-picker, .room-lock-toggle, #btn-create-group-cancel, .room-icon-options button:hover, #room-password-dialog .text-input { background: var(--surface-alt); color: var(--text); }
.room-icon-picker { border-color: var(--border); }
.room-create-dialog .text-input, .room-create-actions .btn { font-size: 16px; }
.room-create-dialog .text-input::placeholder, #room-password-dialog .text-input::placeholder { color: var(--text-muted); opacity: 1; }
#room-password-dialog::backdrop { background: #0008; backdrop-filter: blur(5px); }
#room-password-dialog h3 { font-size: 17px; margin: 0 0 12px; }
#room-password-dialog .text-input { border: 0; border-radius: 20px; min-height: 42px; font-size: 16px; }
#room-password-dialog .btn { min-height: 42px; border-radius: 24px; font-size: 16px; margin: 0; }
#btn-room-password-join { background: #0879ff; color: white; flex: 1; }
#btn-room-password-cancel { background: var(--surface-alt); color: var(--text); width: auto; }
#people-content { overflow: hidden; }
.room-participants { flex-shrink: 0; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); }
.room-participants-heading { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.room-participants-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 3px; }
.room-participant { display: flex; align-items: center; gap: 6px; flex-shrink: 0; max-width: 150px; border: 1px solid var(--border-soft); background: var(--surface-alt); color: var(--text); border-radius: 16px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.room-participant > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-participant-avatar { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.room-participant-avatar svg { width: 100%; height: 100%; }
#friend-requests-list .friend-request-row { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 10px; padding: 12px; border-radius: 14px; }
.friend-request-row .friend-avatar { width: 36px; height: 36px; }
.friend-request-row > div:nth-child(2) { font-size: 14px; overflow-wrap: anywhere; align-self: center; }
.friend-request-row .inline-banner-actions { grid-column: 1 / -1; display: flex; gap: 8px; width: 100%; }
.friend-request-row .inline-banner-actions button { flex: 1; min-width: 0; min-height: 36px; padding: 6px 10px; font-size: 13px; margin: 0; }
.unread-divider { display: flex; align-items: center; gap: 12px; color: var(--primary); font-size: 12px; padding: 12px 0; margin: 8px 0; flex-shrink: 0; }
.unread-divider::before, .unread-divider::after { content: ''; height: 1px; flex: 1; background: var(--border); }
@media (min-width: 900px) {
  .hub-col, #home-chat { transition: height 280ms cubic-bezier(.2,.7,.2,1); }
}
@media (max-width: 899px) {
  #online-users-section { margin: 10px 12px; padding: 12px 0 4px; border: 1px solid var(--border-soft); border-radius: 16px; background: var(--surface); }
  #tab-home .online-users-heading { margin: 0 12px; font-size: 12px; }
  #tab-home .online-users-grid { display: flex; flex-wrap: nowrap; justify-content: flex-start; gap: 12px; padding: 24px 12px 8px; min-height: 0; }
  /* Mobile: same idea as desktop. The row clips anything above it, so notes
     (especially a text + song note) were cut off with only 24px of headroom.
     Pull the row up 36px under the toolbar (arrow / game button) and add the
     same 36px as top padding: total height is unchanged, notes get 60px and
     are drawn above the toolbar. */
  /* The arrow itself sits above the people block so it stays tappable where the
     row's headroom overlaps the toolbar. */
  .discovery-toolbar .people-toggle { position: relative; z-index: 5; }
  /* Collapse arrow on the left (like desktop), game button / match controls on
     the right: swap the two toolbar items' order. */
  .discovery-toolbar .online-users-heading { order: 2; }
  #view-main .discovery-toolbar .match-controls { order: 1; margin-inline-start: 0; }
  /* The whole people block must stack ABOVE the toolbar (z-index 1), not just the
     inner wrapper: an ancestor with its own stacking context would otherwise keep
     the notes underneath the arrow row. flow-root stops the row's negative margin
     from collapsing out and dragging this block over the toolbar's buttons.
     overflow:visible is the key fix: #people-content is overflow:hidden by
     default (only desktop overrode it), which clipped the notes on mobile. */
  #people-content:not([hidden]) { position: relative; z-index: 3; display: flow-root; overflow: visible; }
  #tab-home .online-users-scroll-wrap { position: relative; z-index: 2; }
  /* No pointer-events:none on the row here: a touch-scroll container with it
     turned off can't be swiped sideways on phones. */
  #tab-home .online-users-grid { margin-top: -34px; padding-top: 58px; padding-bottom: 4px; }
  /* Compact the toolbar to just the arrow so the whole section is no taller than
     on desktop: no bottom padding, no 36px min-height on the toggle. The row
     reaches up 34px (arrow row + the section's top padding), so notes still get
     58px of headroom while the layout only reserves the original 24px. */
  #view-main .discovery-toolbar { padding-bottom: 0; min-height: 0; }
  #view-main .discovery-toolbar .people-toggle { min-height: 0; padding-block: 0; }
  .online-user-card { width: 64px; min-width: 64px; flex: 0 0 64px; }
  .online-user-avatar { width: 48px; height: 48px; margin-inline: auto; }
  .online-user-name { font-size: 12px; }
  .online-user-meta { font-size: 10px; }
  #online-users-empty { padding: 12px; font-size: 12px; }
  #tab-rooms .room-row { min-height: 58px; }
}
@media (prefers-reduced-motion: reduce) { .hub-col, #home-chat, .people-chevron { transition: none !important; } }

#friend-requests-list { overflow-y: auto; overflow-x: hidden; }
@media(max-width:899px) { #tab-home .online-user-card .online-user-avatar { width:48px; height:48px; margin-top:0; } }

/* Room creation belongs to the directory header on every screen size. */
#tab-rooms .rooms-panel-header { justify-content: space-between; gap: 12px; }
#tab-rooms .room-create-button { position: static; width: 36px; height: 36px; border-radius: 12px; font-size: 25px; }
#tab-rooms.hub-col { padding-bottom: 12px; }
#friends-list .friend-row.active { background: var(--surface-alt); border-color: var(--primary); box-shadow: inset -3px 0 var(--primary); }
#friends-list .friend-row.active .friend-name { color: var(--primary); }
.chat-toolbar #chat-partner-strip, .chat-toolbar #dm-partner-strip { flex: 1 1 0; min-width: 0; max-width: none; margin: 0; padding: 8px 4px; border: 0; border-radius: 10px; background: transparent; justify-content: flex-start; gap: 12px; }
.chat-toolbar .chat-partner-strip:hover { background: var(--surface-alt) !important; }
.chat-toolbar .partner-strip-avatar { width: 46px; height: 46px; }
.chat-toolbar .partner-strip-info { flex: 1; min-width: 0; }
.chat-toolbar .partner-strip-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-toolbar .partner-strip-meta { font-size: 12px; line-height: 1.5; }
.chat-toolbar .partner-strip-chevron { margin-inline-start: auto; padding-inline: 10px; }
.people-filters { margin-top: 10px; font-size: 12px; }
.people-filters summary { cursor: pointer; color: var(--text-muted); width: fit-content; padding: 6px 0; }
.people-filter-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 10px 0 4px; }
.people-filter-fields label { display: flex; flex-direction: column; gap: 5px; color: var(--text-muted); }
.people-filter-fields input[type=number], .people-filter-fields select { width: 90px; min-height: 36px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); color: var(--text); font: inherit; }
.people-filter-fields select { width: 110px; }
.people-filter-fields .people-filter-check { flex-direction: row; align-items: center; min-height: 36px; color: var(--text); }
.people-filter-check input { accent-color: var(--primary); }
.people-filter-reset { min-height: 36px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 9px; background: transparent; color: var(--primary); cursor: pointer; }
#people-filter-error { width: 100%; margin: 0; color: var(--danger); }
@media (max-width:899px) {
  #tab-rooms.hub-col { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .people-filters { margin-inline: 12px; }
  .people-filter-fields { gap: 10px; }
  .people-filter-fields input[type=number], .people-filter-fields select { font-size: 16px; width: 75px; }
  .people-filter-fields select { width: 98px; }
  .chat-toolbar { gap: 8px; padding: 8px 12px; }
  .chat-toolbar .partner-strip-avatar { width: 40px; height: 40px; }
  .chat-toolbar .partner-strip-name { font-size: 15px; }
}

#online-users-empty { padding: 10px 0; margin: 0; text-align: start; font-size: 12px; }
@media(min-width:900px) {
  .people-filters { position: relative; }
  .people-filters[open] .people-filter-fields { position: absolute; top: 100%; right: 0; z-index: 30; width: min(660px, 100%); padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 12px 36px #0003; }
  #people-content { overflow: visible; }
}

/* Room participant sorting keeps everyone visible, in the chosen order. */
#tab-rooms .room-create-button { background: var(--surface-alt); color: var(--primary); border: 1px solid var(--border); font-weight: 500; }
#tab-rooms .room-create-button:hover, #tab-rooms .room-create-button[aria-expanded="true"] { background: var(--surface-hover); border-color: var(--primary); }
.room-participants-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.room-sort-label { display: flex; align-items: center; gap: 6px; }
#room-participants-sort { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font: inherit; min-height: 32px; max-width: 210px; }
.room-participants-list { flex-direction: column; max-height: 132px; overflow-y: auto; overflow-x: hidden; gap: 4px; }
.room-participant { width: 100%; max-width: none; min-height: 36px; text-align: right; border-radius: 9px; }
.room-participant-meta { margin-inline-start: auto; color: var(--text-muted); font-size: 11px; }
@media(max-width:899px) { #room-participants-sort { font-size: 16px; } }

/* Room members sit to the left of the conversation, with independent scrolling. */
.room-chat-layout { display: flex; direction: rtl; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.room-conversation { order: 1; display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; position: relative; }
.room-chat-layout > .room-participants { order: 2; width: 180px; flex: 0 0 180px; padding: 14px 10px; border-bottom: 0; border-right: 1px solid var(--border-soft); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.room-participants-heading { align-items: flex-start; gap: 12px; }
.room-sort-label { width: 100%; flex-wrap: wrap; }
#room-participants-sort { width: 100%; max-width: 100%; min-width: 0; }
.room-participants-list { flex: 1; min-height: 0; max-height: none; }
.room-participant { flex-wrap: wrap; }
.room-participant-meta { width: 100%; padding-inline-start: 30px; }
.room-people-toggle, button.room-people-close { display: none; }
#room-people-dialog { padding: 0; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text); margin: 0; height: 100dvh; max-height: 100dvh; width: min(300px, 85vw); max-width: 85vw; }
#room-people-dialog::backdrop { background: #0006; }
#room-people-dialog .room-participants { height: 100%; display: flex; flex-direction: column; padding: 20px 16px; box-sizing: border-box; border: 0; }
#room-people-dialog .room-people-close { display: grid; align-self: flex-end; margin-bottom: 14px; }
@media(max-width:1099px) {
  .room-people-toggle { display: block; align-self: flex-start; flex-shrink: 0; margin: 6px 12px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--primary); background: var(--surface-alt); font: inherit; font-size: 12px; cursor: pointer; }
}

#room-people-dialog { left: 0; right: auto; top: 0; bottom: 0; }

/* Compact room identity: emoji beside the name and count, as in the reference. */
.room-heading-identity { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.room-heading-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid var(--text-muted); border-radius: 50%; background: transparent; font-size: 27px; line-height: 1; }
.room-heading-icon svg { width: 23px; height: 23px; }
.room-heading-copy { min-width: 0; text-align: right; }
#group-chat-name { display: block; font-size: 17px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#group-chat-meta { font-size: 13px; line-height: 1.2; color: var(--text-muted); font-variant-numeric: tabular-nums; margin: 0; }
/* A quieter participant list, with clearer names and larger portraits. */
.room-chat-layout > .room-participants { background: var(--bg-elevated); padding: 18px 12px; width: 190px; flex-basis: 190px; }
.room-participants-heading > span { color: var(--text); font-size: 14px; font-weight: 600; }
#room-participants-count { color: var(--text-muted); font-weight: 400; }
.room-sort-label { color: var(--text-muted); font-size: 11px; gap: 6px; margin-bottom: 8px; }
#room-participants-sort { border-color: var(--border-soft); background: var(--surface); border-radius: 10px; min-height: 36px; }
.room-participant { display: grid; grid-template-columns: 34px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 9px; row-gap: 1px; background: transparent; border: 0; border-radius: 11px; padding: 9px 6px; min-height: 52px; }
.room-participant:hover, .room-participant:focus-visible { background: var(--surface-alt); }
.room-participant-avatar { grid-row: 1 / 3; width: 34px; height: 34px; }
.room-participant > span:nth-child(2) { align-self: end; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-participant-meta { width: auto; padding: 0; margin: 0; grid-column: 2; align-self: start; text-align: right; }
.room-participant-meta:empty { display: none; }
#room-people-dialog { border-radius: 0 22px 22px 0; box-shadow: 10px 0 40px #0003; }
#room-people-dialog[open] { animation: room-panel-enter 180ms ease-out; }
@keyframes room-panel-enter { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@media(prefers-reduced-motion:reduce) { #room-people-dialog[open] { animation: none; } }

/* Keep room identity consistent with the directory's chat-bubble outline. */
.room-heading-icon { border-radius: 13px 13px 4px 13px; }
/* Size the desktop workspace from available space, rather than stacking
   viewport-based panel heights on top of the header and people section. */
@media(min-width:900px) {
  #view-main.active.is-workspace { height: 100dvh; min-height: 0; overflow: hidden; }
  #view-main.is-workspace .side-nav { position: relative; top: auto; }
  #view-main.is-workspace .main-content { flex: 1; min-height: 0; height: 0; grid-template-rows: auto minmax(0, 1fr); padding: 16px 24px 90px; overflow: hidden; }
  #view-main.is-workspace .main-content:has(#tab-group-chat[style*="flex"], #tab-dm[style*="flex"]) { padding-bottom: 16px; }
  #view-main.is-workspace .main-content :is(#tab-rooms.hub-col, #tab-friends.hub-col, #tab-wall.hub-col, #home-chat, #tab-dm.hub-col, #tab-group-chat.hub-col) { position: relative; top: auto; height: 100% !important; min-height: 0; max-height: 100%; align-self: stretch; transition: none; }
  #view-main.is-workspace #online-users-section { min-height: 0; max-height: 28dvh; overflow-y: auto; }
  #view-main.is-workspace #tab-friends { overflow-y: auto; }
}

/* Participant access belongs to the room toolbar on small screens. */
@media(max-width:1099px) {
  #tab-group-chat .chat-toolbar .room-people-toggle { align-self: center; margin: 0; min-height: 38px; max-width: 112px; padding: 6px 10px; border-radius: 12px; font-size: 12px; line-height: 1.3; }
}
.people-toggle { display: inline-flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; transition: background 180ms ease, transform 180ms ease; }
.people-toggle:hover { background: var(--surface-alt); }
.people-toggle:active { transform: scale(.97); }
.people-chevron { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--surface-alt); color: var(--primary); transition: transform 280ms cubic-bezier(.2,.7,.2,1), background 180ms; }
.people-chevron svg { width: 16px; height: 16px; }
.reaction-summary[role=button] { cursor: pointer; border-radius: 10px; padding: 4px; }
.reaction-summary[role=button]:hover { background: var(--surface-alt); }
@media(prefers-reduced-motion:reduce) { .people-toggle { transition: none; } }

#btn-room-people.room-heading-identity { border: 0; background: transparent; color: var(--text); padding: 4px 6px; border-radius: 12px; text-align: right; font: inherit; cursor: pointer; }
#btn-room-people.room-heading-identity:hover { background: var(--surface-alt); }
.room-heading-more { color: var(--text-muted); margin-inline-start: 3px; }
#tab-group-chat .chat-toolbar .room-heading-identity { max-width: none; }
.room-sort-button { width: 100%; border: 1px solid var(--border); background: var(--surface-alt); color: var(--primary); border-radius: 10px; min-height: 36px; cursor: pointer; }
.room-sort-dialog, #idle-session-dialog { width: min(420px, calc(100% - 28px)); max-height: 85dvh; overflow: auto; padding: 24px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 24px; }
.room-sort-dialog::backdrop, #idle-session-dialog::backdrop { background: #0009; backdrop-filter: blur(4px); }
.room-sort-dialog h3, #idle-session-dialog h3 { margin-top: 0; }
.room-sort-dialog fieldset { border: 1px solid var(--border-soft); border-radius: 12px; margin: 16px 0; padding: 12px; }
.room-sort-dialog label { display: flex; align-items: center; gap: 8px; min-height: 38px; font-size: 14px; }
.room-sort-dialog input { accent-color: var(--primary); }
.room-sort-dialog p { font-size: 12px; line-height: 1.6; }
.room-sort-actions { display: flex; gap: 8px; margin-top: 20px; }
.room-sort-actions button, #btn-resume-session { border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); padding: 10px 14px; border-radius: 12px; font: inherit; cursor: pointer; }
.room-sort-actions button[type=submit], #btn-resume-session { flex: 1; background: var(--primary-dim); color: white; }

/* Small sorting tool at the left edge of the participant heading. */
.room-participants-heading { flex-wrap: nowrap; align-items: center; gap: 6px; }
.room-participants-heading > span { flex: 1; min-width: 0; font-size: 13px; }
#btn-room-sort { display: grid; place-items: center; width: 32px; height: 32px; min-height: 32px; flex: 0 0 32px; padding: 6px; margin-inline-start: auto; background: transparent; border: 1px solid transparent; border-radius: 9px; position: relative; }
#btn-room-sort svg { width: 19px; height: 19px; }
#btn-room-sort:hover { background: var(--surface-alt); border-color: var(--border); }
#btn-room-sort.has-active-sort::after { content: ''; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.room-heading-more { display: grid; place-items: center; width: 32px; height: 32px; margin-inline-start: 8px; border-radius: 10px; background: var(--surface-alt); color: var(--primary); }
.room-heading-more svg { width: 19px; height: 19px; }
#btn-room-people:disabled { opacity: 1; cursor: default; }
#btn-room-people:disabled:hover { background: transparent; }
@media(min-width:1100px) { .room-heading-more { display: none; } }

/* Shared gradient makes room icons read consistently across both themes. */
:root { --room-icon-gradient: linear-gradient(145deg, #64468c 0%, #37254f 50%, #1c263f 100%); }
:root[data-theme="light"] { --room-icon-gradient: linear-gradient(145deg, #eee2ff 0%, #d8c7ef 50%, #bfd8f1 100%); }
.room-heading-icon, #tab-rooms .room-symbol, .room-icon-picker { background: var(--room-icon-gradient); }
.room-icon-options { grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); max-height: 240px; gap: 4px; padding: 4px; overscroll-behavior: contain; }
.room-icon-options button { min-width: 40px; min-height: 42px; padding: 4px; }
@media(max-width:1099px) {
  #tab-group-chat .chat-toolbar { padding-left: 58px; }
  #btn-room-people .room-heading-more { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); margin: 0; width: 36px; height: 36px; }
}

/* Creation follows the site's surfaces and purple actions in either theme. */
#create-group-form { width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border-radius: 24px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 24px 80px #0005; }
.room-create-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.room-create-heading h2 { font-size: 21px; margin: 0 0 4px; }
.room-create-heading p, .room-security-heading p { color: var(--text-muted); font-size: 12px; line-height: 1.5; margin: 0; }
.room-field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
#create-group-form .room-create-name-row { background: transparent; gap: 10px; margin-bottom: 18px; }
#create-group-form .text-input { min-width: 0; min-height: 48px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-alt); color: var(--text); font-size: 16px; padding: 12px; }
#create-group-form .text-input:focus { outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: none; }
#create-group-form .room-icon-picker { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 16px 16px 5px 16px; font-size: 25px; border: 1px solid var(--border); }
#create-group-form .room-icon-options { border: 1px solid var(--border-soft); background: var(--surface-alt); border-radius: 14px; margin-bottom: 18px; max-height: min(220px, 30dvh); }
.room-security-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border-soft); }
.room-security-heading .room-field-label { margin-bottom: 3px; }
#create-group-form .room-lock-toggle { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--border); }
#create-group-form .room-lock-toggle[aria-pressed=true] { background: var(--primary-dim); border-color: var(--primary); }
#create-group-form .room-create-password-row { margin: 0 0 16px; }
#create-group-form .room-create-password-row:has(input:disabled) { display: none; }
#create-group-form .room-create-actions { gap: 10px; margin-top: 12px; }
#create-group-form .room-create-actions .btn { min-height: 44px; border-radius: 12px; font-size: 15px; }
#create-group-form #btn-create-group-submit { background: linear-gradient(120deg, var(--primary-dim), var(--primary-alt)); color: #fff; }
#create-group-form #btn-create-group-cancel { background: var(--surface-alt); color: var(--text-muted); }
#room-create-error:empty { display: none; }

/* Random matching is a header action, leaving the workspace to conversations. */
#view-main #home-idle { position: static; inset: auto; transform: none; width: auto; min-width: 0; max-width: none; margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; z-index: auto; flex: 0 0 auto; }
#view-main #home-idle .idle-actions { display: flex; gap: 6px; margin: 0; align-items: center; }
#view-main #home-idle .btn { margin: 0; min-height: 36px; height: 36px; width: auto; padding: 6px 12px; font-size: 13px; border-radius: 11px; }
#view-main #home-idle #btn-find { flex: none; }
#view-main #home-idle #btn-flappy-open-idle { width: 36px; padding: 6px; }
@media(min-width:900px) {
  #view-main.is-workspace .main-content { padding-bottom: 16px; }
}
@media(max-width:899px) {
  #view-main .app-header { gap: 8px; }
  #view-main #home-idle #btn-flappy-open-idle { display: none; }
  #view-main #home-idle .btn { padding-inline: 10px; font-size: 12px; }
}

/* Discovery and matching share one toolbar in all states and screen sizes. */
.discovery-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.discovery-toolbar .online-users-heading { margin: 0; flex: 0 1 auto; }
.match-controls { min-width: 0; margin-inline-start: auto; }
#view-main .match-controls :is(#home-idle, #home-waiting, #home-left) { position: static; inset: auto; transform: none; width: auto; max-width: none; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; z-index: auto; text-align: start; }
#view-main .match-controls :is(#home-waiting, #home-left)[style*="block"] { display: flex !important; align-items: center; flex-wrap: wrap; gap: 8px; }
#view-main .match-controls .btn { width: auto; min-height: 34px; height: 34px; padding: 6px 12px; margin: 0; font-size: 13px; border-radius: 10px; white-space: nowrap; }
#view-main .match-controls #btn-find { background: var(--surface-alt); color: var(--primary); border: 1px solid var(--border); box-shadow: none; }
#view-main .match-controls #btn-find:hover { border-color: var(--primary); background: var(--surface-hover); }
#view-main .match-controls #btn-flappy-open-idle { display: none; }
#view-main .match-controls .x-loader { width: 22px; height: 22px; margin: 0; flex: 0 0 22px; }
#view-main .match-controls .x-loader-svg { width: 22px; height: 22px; }
#view-main .match-controls p { margin: 0; font-size: 12px; line-height: 1.4; color: var(--text-muted); white-space: normal; }
#view-main .match-controls #btn-flappy-open { background: transparent; border: 1px solid var(--border-soft); padding: 6px; width: 34px; }
#view-main .match-controls #btn-cancel-find { background: var(--surface-alt); color: var(--text-muted); }
@media(max-width:899px) {
  .discovery-toolbar { padding: 0 10px 8px; gap: 6px; }
  .discovery-toolbar .people-toggle { font-size: 12px; gap: 5px; padding-inline: 0; }
  .discovery-toolbar .people-chevron { width: 22px; height: 22px; }
  .discovery-toolbar .online-users-dot { display: none; }
  #view-main .match-controls .btn { font-size: 12px; padding-inline: 8px; }
  #view-main .match-controls #btn-flappy-open { display: none; }
  #view-main .match-controls #home-waiting { justify-content: flex-end; }
}

/* New conversation action at the center of mobile navigation. */
.nav-match-btn { flex: 1; min-width: 0; min-height: 48px; border: 0; background: none; color: var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; font: inherit; cursor: pointer; }
.nav-match-btn small { font-size: 11px; }
.nav-match-icon { display: grid; place-items: center; width: 38px; height: 30px; background: var(--room-icon-gradient); border: 1px solid var(--border); border-radius: 12px 12px 5px 12px; transition: transform 160ms ease, border-color 160ms ease; }
.nav-match-icon svg { width: 23px; height: 23px; }
.nav-match-btn:hover .nav-match-icon { border-color: var(--primary); }
.nav-match-btn:active .nav-match-icon { transform: scale(.92); }
.nav-match-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 12px; }
@media(min-width:900px) {
  #view-main .match-controls #btn-flappy-open-idle { display: inline-flex; align-items: center; justify-content: center; }
}
@media(prefers-reduced-motion:reduce) { .nav-match-icon { transition: none; } }

@media(max-width:899px) {
  #view-main .match-controls #btn-find { display: none; }
  #view-main .match-controls #btn-flappy-open-idle,
  #view-main .match-controls #btn-flappy-open { display: inline-flex; align-items: center; justify-content: center; }
}

/* Matching lives with rooms on desktop and stays visible across mobile tabs. */
@media(min-width:900px) {
  #tab-rooms > .match-controls { margin: 0 14px 14px; padding: 10px 0; border-block: 1px solid var(--border-soft); }
  #tab-rooms .match-controls #home-idle .idle-actions { display: flex; }
  #tab-rooms .match-controls #home-idle #btn-find { flex: 1; }
  #tab-rooms .match-controls #home-waiting { gap: 6px; }
  #tab-rooms .match-controls #home-waiting p { flex: 1; }
  #tab-rooms > .match-controls:not(:has(> [style*="block"])) { display: none; }
}
@media(max-width:899px) {
  #view-main > .match-controls { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 21; margin: 0; padding: 8px 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 4px 20px #0002; }
  #view-main > .match-controls:not(:has(#home-waiting[style*="block"], #home-left[style*="block"])) { display: none; }
  #view-main > .match-controls #home-idle { display: none !important; }
  #view-main > .match-controls #home-waiting { justify-content: flex-start; }
  #view-main > .match-controls #home-waiting p { flex: 1; }
  #view-main:has(#home-waiting[style*="block"], #home-left[style*="block"]) .main-content { padding-bottom: 130px; }
}
@media(max-width:899px) {
  #view-main .discovery-toolbar #btn-find { display: none; }
  #view-main .discovery-toolbar #home-idle #btn-flappy-open-idle { display: inline-flex; align-items: center; justify-content: center; }
}

/* Room participants search */
.room-participants-search { width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 7px 10px; min-height: 36px; background: var(--surface); color: var(--text); border: 1px solid var(--border-soft); border-radius: 10px; font: inherit; font-size: 13px; flex-shrink: 0; }
.room-participants-search::placeholder { color: var(--text-muted); }
.room-participants-search:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.room-participants-empty { color: var(--text-muted); font-size: 12px; padding: 8px 4px; }
@media(max-width:899px) { .room-participants-search { font-size: 16px; } }

/* Reaction details - WhatsApp-style sheet */
#reaction-details-dialog { width: min(360px, calc(100% - 28px)); max-height: min(560px, 80dvh); padding: 0; border: 1px solid var(--border-soft); border-radius: 18px; background: var(--surface); color: var(--text); overflow: hidden; box-shadow: 0 20px 70px #0006; }
#reaction-details-dialog[open] { display: flex; flex-direction: column; animation: rd-in 160ms ease-out; }
#reaction-details-dialog::backdrop { background: #0006; }
@keyframes rd-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media(prefers-reduced-motion:reduce) { #reaction-details-dialog[open] { animation: none; } }
.reaction-details-sheet { display: flex; flex-direction: column; min-height: 0; max-height: inherit; overflow: hidden; }
.reaction-details-title { margin: 0; padding: 18px 20px 12px; font-size: 16px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.reaction-details-toprow { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.reaction-details-add { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 18px; background: transparent; color: var(--text-muted); cursor: pointer; }
.reaction-details-add svg { width: 22px; height: 22px; }
.reaction-details-add:hover:not(:disabled), .reaction-details-add[aria-expanded=true] { background: var(--surface-alt); color: var(--text); }
.reaction-details-add:disabled { opacity: .4; cursor: default; }
.reaction-details-tabs { display: flex; gap: 8px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.reaction-details-tabs::-webkit-scrollbar { display: none; }
.reaction-details-tabs button { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--border-soft); border-radius: 18px; background: transparent; color: var(--text-muted); font: inherit; font-size: 14px; cursor: pointer; }
.reaction-details-tabs button .rd-emoji { font-size: 18px; line-height: 1; }
.reaction-details-tabs button[aria-pressed=true] { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.reaction-details-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); background: var(--bg-elevated, var(--surface)); flex-shrink: 0; max-height: 200px; overflow-y: auto; }
.reaction-details-picker[hidden] { display: none; }
.reaction-details-picker button { border: 0; background: transparent; border-radius: 50%; width: 42px; height: 42px; font-size: 26px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; color: var(--text); transition: transform 120ms; }
.reaction-details-picker button:hover { background: var(--surface-alt); transform: scale(1.12); }
.reaction-details-picker button.active { background: var(--surface-alt); box-shadow: inset 0 0 0 1.5px var(--primary); }
.reaction-details-list { overflow-y: auto; min-height: 0; padding: 6px 8px 12px; color: var(--text-muted); }
.reaction-person { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; padding: 8px 10px; color: var(--text); background: transparent; font: inherit; text-align: right; border-radius: 12px; cursor: pointer; }
.reaction-person:hover { background: var(--surface-alt); }
.reaction-person-avatar { width: 42px; height: 42px; overflow: hidden; border-radius: 50%; flex-shrink: 0; }
.reaction-person-avatar svg, .reaction-person-avatar img { width: 100%; height: 100%; object-fit: cover; }
.reaction-person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.reaction-person-name { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reaction-person-sub { font-size: 12px; color: var(--text-muted); }
.reaction-person-emoji { margin-inline-start: auto; font-size: 26px; line-height: 1; }
@media(max-width:600px) {
  #reaction-details-dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 75dvh; }
  #reaction-details-dialog[open] { animation-name: rd-up; }
}
@keyframes rd-up { from { transform: translateY(100%); } to { transform: none; } }

.reaction-details-tabs .rd-emoji svg { width: 20px; height: 20px; display: block; }
.reaction-details-picker button svg { width: 32px; height: 32px; display: block; }
.reaction-person-emoji svg { width: 30px; height: 30px; display: block; }

/* No flashing scrollbar while the "people you should meet" panel opens/closes */
/* Scrollbars stay hidden for the whole animation + settle period, but nothing is
   force-clipped any more except #people-content while its height animation runs.
   (The old rule set overflow:hidden on EVERY descendant for ~0.5s, which cut off
   the notes that stick out above the avatars - so they only popped in afterwards.) */
#view-main #online-users-section.is-animating, #view-main #online-users-section.is-animating * { scrollbar-width: none; }
#view-main #online-users-section.is-animating *::-webkit-scrollbar { display: none; }
/* While the height animation runs, clip only the BOTTOM edge of the panel. The notes
   stick out above the content box (the row is pulled up under the arrow), so the top
   and sides get generous negative insets and stay visible. clip-path instead of
   overflow:hidden is what stops the notes from being cut for the first 280ms. */
#view-main #online-users-section.is-clipping #people-content { clip-path: inset(-90px -40px 0 -40px); }
/* Friend requests: entry button on the Friends tab + its own screen. */
#tab-friends > .tab-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.friend-requests-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px; white-space: nowrap; font: inherit; font-size: 13px; font-weight: 600; flex-shrink: 0; margin: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-alt); color: var(--primary); cursor: pointer; }
.friend-requests-button:hover { background: var(--surface-hover); border-color: var(--primary); }
.friend-requests-button svg { width: 18px; height: 18px; flex-shrink: 0; }
.friend-requests-button-label { line-height: 1; }
.friend-requests-button-count { position: absolute; top: -6px; left: -6px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.friend-requests-dialog { width: min(420px, calc(100vw - 24px)); max-height: min(560px, 80dvh); margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px #0005; overflow: hidden; }
.friend-requests-dialog[open] { display: flex; flex-direction: column; animation: friend-requests-enter 160ms ease-out; }
.friend-requests-dialog::backdrop { background: #0006; }
.friend-requests-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.friend-requests-dialog-header h3 { margin: 0; font-size: 16px; }
.friend-requests-dialog #friend-requests-list { flex: 1; min-height: 0; padding: 8px 12px 12px; }
.friend-requests-dialog #friend-requests-empty { padding: 28px 16px; }
@keyframes friend-requests-enter { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .friend-requests-dialog[open] { animation: none; } }

/* Modals must cover the whole page, including the sticky app header. */
.modal-backdrop { position: fixed; inset: 0; z-index: 2000; }

/* Shared confirm dialog - see showConfirm() in app.js. */
.confirm-dialog { width: min(360px, calc(100vw - 32px)); margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px #0005; }
.confirm-dialog::backdrop { background: #0007; backdrop-filter: blur(4px); }
.confirm-dialog[open] { animation: friend-requests-enter 160ms ease-out; }
.confirm-dialog-body { padding: 20px; }
.confirm-dialog-title { margin: 0 0 8px; font-size: 17px; }
.confirm-dialog-message { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--text-muted); }
.confirm-dialog-actions { display: flex; gap: 8px; }
.confirm-dialog-actions .btn { flex: 1; min-height: 42px; margin: 0; }
@media (prefers-reduced-motion: reduce) { .confirm-dialog[open] { animation: none; } }

/* Friends title: keep the unread dot inline next to the word, not below it. */
#tab-friends > .tab-title > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
#tab-friends > .tab-title .hub-badge-dot { position: static; margin: 0; flex-shrink: 0; }
.friend-request-row-clickable { cursor: pointer; }
.friend-request-row-clickable:hover { background: var(--surface-hover); }
.friend-request-row-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Desktop: modals are centered dialogs, not bottom sheets. */
@media (min-width: 900px) {
  .modal-backdrop { align-items: center; justify-content: center; }
  .modal-backdrop > .modal-card { align-self: center; margin: 0; position: relative; inset: auto; transform: none; max-height: min(90dvh, 760px); overflow-y: auto; border-radius: 22px !important; }
}

/* Flappy top bar: round icon buttons, same look as the profile window's close button. */
.flappy-topbar-actions { display: flex; align-items: center; gap: 8px; }
.flappy-icon-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-alt); color: var(--text); cursor: pointer; }
.flappy-icon-btn svg { width: 19px; height: 19px; }
.flappy-icon-btn:hover { background: var(--surface-hover); border-color: var(--primary); }
.flappy-icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#btn-flappy-leaderboard-toggle, .game-leaderboard-toggle { color: var(--primary); }
/* ============================================================
   Filter modal header (close button)
   ============================================================ */
.filter-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.filter-modal-header h3 { margin: 0; }

/* ============================================================
   ChatX Play
   The game stage is always dark, so overlay text is always light
   (theme text colors were unreadable in light mode). The
   leaderboard is a solid themed panel instead of a see-through one.
   ============================================================ */
.flappy-overlay-text { color: #E9EAF8; font-size: 15px; max-width: 240px; }
.flappy-overlay-label, #flappy-best-note { color: #B9BAD8; }
.flappy-start-btn { min-width: 160px; }
.flappy-icon-btn-sm { width: 34px; height: 34px; border-radius: 10px; }
.flappy-icon-btn-sm svg { width: 16px; height: 16px; }
.flappy-icon-btn { flex-shrink: 0; }

.flappy-leaderboard {
  background: var(--surface);
  backdrop-filter: none;
  padding: 0;
  color: var(--text);
}
.flappy-leaderboard-header {
  padding: 14px;
  margin: 0;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.flappy-lb-title { display: flex; align-items: center; gap: 10px; line-height: 1.25; }
.flappy-lb-title strong { display: block; font-size: 16px; }
.flappy-lb-title small { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); }
.flappy-lb-trophy {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  color: var(--gold);
}
.flappy-lb-trophy svg { width: 20px; height: 20px; }

.flappy-leaderboard-list { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.flappy-lb-row { padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; }
.flappy-lb-rank {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; font-size: 13px; background: var(--surface-alt); color: var(--text-muted);
}
.flappy-lb-row.flappy-lb-top { background: var(--surface-alt); }
.flappy-lb-row.flappy-lb-me { background: color-mix(in srgb, var(--primary) 14%, transparent); border-color: var(--primary); }
.flappy-lb-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.flappy-lb-you { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; background: var(--primary); color: #fff; }
.flappy-lb-score { font-size: 17px; font-variant-numeric: tabular-nums; min-width: 32px; text-align: left; }
.flappy-lb-top-1 .flappy-lb-score { color: var(--gold); }
.flappy-lb-divider { padding: 0; line-height: 1; }

.flappy-lb-empty {
  flex: 1; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px;
}
.flappy-lb-empty strong { color: var(--text); font-size: 16px; }
.flappy-lb-empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-alt); color: var(--primary); margin-bottom: 6px;
}
.flappy-lb-empty-icon svg { width: 26px; height: 26px; }

/* Swipe back out of a room / friend conversation (mobile) */
.chat-page.is-swiping-back { box-shadow: 12px 0 32px rgba(0,0,0,.28); will-change: transform; }

/* Keyboard open in a chat (mobile): keep the header on screen and the input
   flush against the keyboard. Values come from the visual viewport (see
   syncViewport in workspace.js). */
@media (max-width: 899px) {
  body.chat-fullscreen .app-header { transform: translateY(var(--chat-viewport-top, 0px)); }
  body.chat-fullscreen .chat-page {
    top: calc(var(--app-header-height, 60px) + var(--chat-viewport-top, 0px));
    height: calc(var(--chat-viewport-height, 100dvh) - var(--app-header-height, 60px));
    bottom: auto;
  }
  /* The home-indicator padding only belongs when there is no keyboard. */
  html.keyboard-open .chat-input-wrapper { padding-bottom: 8px; }
}

/* Mobile chat: hide the top app header so the conversation gets the whole
   screen. The chat page then starts at the top of the visual viewport (no
   header offset), and its toolbar clears the notch itself. */
@media (max-width: 899px) {
  body.chat-fullscreen .app-header { display: none; }
  body.chat-fullscreen .chat-page {
    top: var(--chat-viewport-top, 0px);
    height: var(--chat-viewport-height, 100dvh);
    bottom: auto;
  }
  body.chat-fullscreen .chat-toolbar { padding-top: max(10px, env(safe-area-inset-top)); }
  /* The chat is fixed to the screen and never scrolls as a page. Without this,
     a drag in a chat with nothing to scroll chains to the document and
     iOS slides/bounces the whole page, leaving the chat out of place. */
  html:has(body.chat-fullscreen) { overflow: hidden; overscroll-behavior: none; }
  body.chat-fullscreen { overflow: hidden; overscroll-behavior: none; }
  body.chat-fullscreen .chat-page { overscroll-behavior: none; }
}

/* Mobile: opening a chat (random chat, DM or room) slides it in. The chat
   page goes from display:none to display:flex when it opens, which restarts
   this animation each time. It slides in from the same side the swipe-back
   gesture takes it out to (see workspace.js), so open and close mirror each
   other. No fill-mode, so the inline transform used while swiping back is
   unaffected once the animation ends. */
@keyframes chat-open-in {
  from { transform: translateX(-28%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@media (max-width: 899px) {
  body.chat-fullscreen .chat-page { animation: chat-open-in 0.26s cubic-bezier(0.22, 0.8, 0.3, 1); }
}
@media (prefers-reduced-motion: reduce) {
  body.chat-fullscreen .chat-page { animation: none; }
}

/* While swiping back out of a chat, show the bottom nav of the screen being
   revealed underneath (it is normally hidden inside a chat). */
@media (max-width: 899px) {
  body.chat-fullscreen.swiping-back .bottom-nav { display: flex; }
}

/* Medals for the top three (drawn in app.js, flappyMedalSvg) */
.flappy-lb-row.flappy-lb-top .flappy-lb-rank { width: 30px; height: 36px; background: none; border-radius: 0; }
.flappy-medal { width: 28px; height: 34px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.flappy-lb-top-1 { --medal-main: #F4C542; --medal-dark: #7A4E00; --medal-light: #FFE9A0; --medal-ribbon: #E5484D; --medal-ribbon-dark: #B83237; }
.flappy-lb-top-2 { --medal-main: #D5D9E8; --medal-dark: #454B63; --medal-light: #FFFFFF; --medal-ribbon: #3E7BFA; --medal-ribbon-dark: #2A58C4; }
.flappy-lb-top-3 { --medal-main: #D9935C; --medal-dark: #5E3210; --medal-light: #F5C49A; --medal-ribbon: #2FA36B; --medal-ribbon-dark: #207A50; }
/* Mobile: the rooms list sits on the same page background as the other tabs
   (Home, Friends, Profile) instead of its own near-black / surface panel.
   :root[data-theme] matches the specificity of the light-theme rule above. */
@media (max-width: 899px) {
  #tab-rooms.hub-col,
  :root[data-theme] #tab-rooms.hub-col { background: var(--bg); }
  /* Rooms search looks like the Friends search (a plain .text-input):
     surface fill, regular border and radius, theme text color. */
  #tab-rooms .list-search,
  :root[data-theme] #tab-rooms .list-search {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
  }
}

/* Opening a <dialog> with showModal() moves focus to the dialog itself or its
   first button (the close "×"). Mobile Safari treats that programmatic focus
   as :focus-visible, so the global purple ring from the top of this file
   flashed on every dialog/side panel. Dialogs never show a ring on
   themselves, and on touch devices (no keyboard focus navigation) the ring is
   skipped inside dialogs. Keyboard users on desktop still get it. */
dialog:focus,
dialog:focus-visible { outline: none; }
@media (hover: none) and (pointer: coarse) {
  dialog :focus-visible { outline: none; }
}

/* Comments window: bottom sheet on phones (slides up, swipe down to close).
   The grabber bar at the top is the visual hint that it can be dragged away;
   it gives a small nudge when the sheet opens. Desktop keeps the centered
   dialog. Swipe handling lives in app.js (enableCommentsSwipeToClose). */
.sheet-grabber { display: none; justify-content: center; padding: 8px 0 12px; flex-shrink: 0; }
.sheet-grabber span { width: 40px; height: 5px; border-radius: 3px; background: var(--text-muted); opacity: .55; animation: sheet-grabber-hint 1.1s ease-in-out .5s 2; }
@keyframes comments-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes comments-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-grabber-hint { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(5px); } 65% { transform: translateY(0); } 80% { transform: translateY(3px); } }
@media (max-width: 899px) {
  #modal-comments { align-items: flex-end; justify-content: center; animation: comments-backdrop-in 220ms ease-out; }
  #modal-comments .modal-card {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 6px 20px calc(20px + env(safe-area-inset-bottom));
    max-height: 88dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    overscroll-behavior: contain;
    animation: comments-sheet-in 280ms cubic-bezier(.2, .8, .2, 1);
  }
  #modal-comments .comments-list { overscroll-behavior: contain; }
  #modal-comments .sheet-grabber { display: flex; }
}
/* Reactions window: already a bottom sheet at <=600px; add the grabber hint and
   make it slide in from the very bottom like the comments sheet. */
@media (max-width: 600px) {
  #reaction-details-dialog .sheet-grabber { display: flex; padding-bottom: 4px; }
  #reaction-details-dialog { overscroll-behavior: contain; }
}
@media (prefers-reduced-motion: reduce) {
  #modal-comments, #modal-comments .modal-card, .sheet-grabber span { animation: none !important; }
}

/* Create-room dialog: the icon list and the password field open and close with
   a short slide/fade instead of popping in. Closed state = zero height, so the
   dialog grows and shrinks smoothly. (JS toggles .is-open on the icon list and
   enables/disables the password input.) */
#create-group-form .room-icon-options {
  max-height: 0;
  margin: 0;
  padding-block: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: max-height 280ms cubic-bezier(.2, .8, .2, 1), margin 280ms cubic-bezier(.2, .8, .2, 1), padding 280ms cubic-bezier(.2, .8, .2, 1), border-width 280ms ease, opacity 200ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1);
}
#create-group-form .room-icon-options.is-open {
  max-height: min(220px, 30dvh);
  margin: -8px 0 18px;
  padding: 4px;
  border-width: 1px;
  opacity: 1;
  overflow-y: auto;
  pointer-events: auto;
  transform: none;
}
#create-group-form .room-create-password-row,
#create-group-form .room-create-password-row:has(input:disabled) {
  display: flex;
  /* 4px of padding (cancelled by the negative side margin) keeps the input's
     focus ring from being clipped by overflow:hidden. */
  box-sizing: border-box;
  max-height: 64px;
  margin: 0 -4px 16px;
  padding: 4px;
  opacity: 1;
  overflow: hidden;
  transform: none;
  transition: max-height 280ms cubic-bezier(.2, .8, .2, 1), margin 280ms cubic-bezier(.2, .8, .2, 1), padding 280ms cubic-bezier(.2, .8, .2, 1), opacity 200ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1);
}
#create-group-form .room-create-password-row:has(input:disabled) {
  max-height: 0;
  margin-bottom: 0;
  padding-block: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}
.room-lock-toggle.is-popping { animation: room-lock-pop 340ms cubic-bezier(.3, 1.5, .5, 1); }
@keyframes room-lock-pop { 0% { transform: scale(1); } 40% { transform: scale(1.22) rotate(-8deg); } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) {
  #create-group-form .room-icon-options,
  #create-group-form .room-create-password-row,
  #create-group-form .room-create-password-row:has(input:disabled) { transition: none; }
  .room-lock-toggle.is-popping { animation: none; }
}

/* One opening animation for every window: the same short fade + rise the
   friend-requests dialog uses (friend-requests-enter). Native <dialog>s get it
   on [open]; the older .modal-backdrop windows get it on their card when they
   switch from display:none to flex. Windows that already have their own entry
   animation keep it (friend requests, confirm, reactions, people panel, and
   the comments bottom sheet on phones - #modal-comments is more specific). */
.modal-backdrop > .modal-card { animation: friend-requests-enter 160ms ease-out; }
#create-group-form[open],
#room-sort-dialog[open],
#room-password-dialog[open],
#idle-session-dialog[open] { animation: friend-requests-enter 160ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop > .modal-card,
  #create-group-form[open],
  #room-sort-dialog[open],
  #room-password-dialog[open],
  #idle-session-dialog[open] { animation: none; }
}

/* Switching to the wall or to a (different) room: the detail pane fades in
   and rises slightly. Class is added by playPaneEnter() in app.js. */
@keyframes pane-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pane-enter { animation: pane-enter 220ms cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: reduce) { .pane-enter { animation: none; } }

/* Note composer (the "add note" window): same fade + rise as the other
   windows. Desktop animates the floating card over a fading backdrop; on
   phones it's a full-screen page, so the page fades and its content rises. */
@keyframes note-composer-fade { from { opacity: 0; } to { opacity: 1; } }
.note-composer { animation: note-composer-fade 160ms ease-out; }
@media (min-width: 900px) {
  .note-composer-window { animation: friend-requests-enter 160ms ease-out; }
}
@media (max-width: 899px) {
  .note-composer-body, .note-composer-save { animation: friend-requests-enter 200ms ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  .note-composer, .note-composer-window, .note-composer-body, .note-composer-save { animation: none; }
}

/* ---------- Song search / replace animations ---------- */
@keyframes nm-panel-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes nm-panel-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes nm-row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes nm-chip-in { 0% { opacity: 0; transform: translateY(6px) scale(.92); } 60% { opacity: 1; transform: scale(1.03); } 100% { opacity: 1; transform: none; } }
@keyframes nm-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes nm-play-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

/* Panel slides/fades in whenever it is shown (display none -> block), and
   fades out while JS has .is-closing on it. */
.note-music-panel { transform-origin: top center; animation: nm-panel-in 200ms cubic-bezier(.2, .7, .2, 1); }
.note-music-panel.is-closing { animation: nm-panel-out 160ms ease-in forwards; pointer-events: none; }

/* Results drop in one after another (--i is set from JS). */
.note-music-result { animation: nm-row-in 260ms cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 35ms); transition: background .15s ease, transform .15s ease; }
.note-music-result:active { transform: scale(.98); }
.note-music-status { animation: nm-row-in 220ms ease-out; }

/* Loading skeleton while searching. */
.note-music-skeleton { display: flex; align-items: center; gap: 10px; padding: 8px; animation: nm-row-in 220ms ease-out backwards; animation-delay: calc(var(--i, 0) * 60ms); }
.nm-sk-art, .nm-sk-lines > span {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: nm-shimmer 1.3s linear infinite;
}
.nm-sk-art { width: 44px; height: 44px; flex-shrink: 0; }
.nm-sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.nm-sk-lines > span { height: 11px; width: 70%; border-radius: 6px; }
.nm-sk-lines > span + span { width: 45%; height: 9px; }

/* Picking / replacing a song: the new chip pops in (the chip's contents are
   rebuilt on every change, so this plays on both add and replace). */
.note-music-chip > * { animation: nm-chip-in 320ms cubic-bezier(.2, .7, .2, 1); }

/* A song that is currently playing gets a soft pulsing ring. */
.note-music-play { transition: transform .15s ease, filter .15s ease; }
.note-music-play:active { transform: scale(.9); }
.note-music-play.is-playing { animation: nm-play-pulse 1.4s ease-out infinite; }
.note-composer-window.is-morphing .note-composer-body { overflow: hidden; }

/* Games button lives in the mobile header next to the notifications bell; the
   copy inside the discovery toolbar is hidden there. (The header button itself
   is already hidden on desktop by .header-icon-btn in styles.css.) */
.header-games-btn { font-size: 17px; line-height: 1; }
@media (max-width: 899px) {
  #view-main .discovery-toolbar #home-idle #btn-flappy-open-idle,
  #view-main .match-controls #btn-flappy-open-idle { display: none !important; }
}

/* iOS Safari zooms the page when a focused text field has a font-size under
   16px. The note bubble is a contenteditable that is auto-focused when the
   composer opens, and on phones it inherited the bubble's 14px - hence the
   zoom-in on "הוסף פתק". Keep every field in the composer at 16px. */
.note-composer-body .note-composer-bubble,
.note-composer-body .note-music-panel .text-input { font-size: 16px; }
/* Mobile: collapsed people bar only - same size as desktop.
   The expanded state is untouched because everything is scoped to .is-collapsed. */
@media (max-width: 899px) {
  #online-users-section { transition: padding 280ms cubic-bezier(.2,.7,.2,1); }

  /* Same arrow size in both states (26px, like desktop). In the open state the extra
     4px are absorbed by a -2px block margin, so the toolbar row - and with it the
     note headroom calculations above - keep their original 22px height. */
  #view-main .discovery-toolbar .people-chevron { width: 26px; height: 26px; margin-block: -2px; }
  #view-main .discovery-toolbar .people-chevron svg { width: 18px; height: 18px; }

  #online-users-section.is-collapsed { padding-block: 12px; }

  #online-users-section.is-collapsed .discovery-toolbar .people-chevron {
    width: 26px;
    height: 26px;
    margin-block: 0; /* collapsed bar has its own padding, no compensation needed */
    border-radius: 9px;
  }
  #online-users-section.is-collapsed .discovery-toolbar .people-chevron svg {
    width: 18px;
    height: 18px;
  }
}

/* Friends list: the "online" dot sits on the avatar (like the stories row) instead of
   as a separate dot at the far side of the row. The wrapper is NOT clipped, so the dot
   can overlap the avatar's edge; the clipping stays on .friend-avatar inside it. */
.friend-avatar-wrap { position: relative; flex-shrink: 0; width: 44px; height: 44px; }
.friend-avatar-wrap.is-online::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--success);
  border: 2.5px solid var(--surface);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  z-index: 3;
}
/* Restore the descriptive title only while the people panel is collapsed. */
.discovery-toolbar { position: relative; }
.people-collapsed-label { display: inline-flex; align-items: center; gap: 8px; position: absolute; right: 0; top: 50%; direction: rtl; text-align: right; color: var(--text-muted); font-size: 13px; font-weight: 500; pointer-events: none; opacity: 0; visibility: hidden; transform: translateY(-50%) translateX(6px); transition: opacity 280ms cubic-bezier(.2,.7,.2,1), transform 280ms cubic-bezier(.2,.7,.2,1), visibility 0s 280ms; }
#online-users-section.is-collapsed .people-collapsed-label { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); transition-delay: 0s; }
.people-collapsed-label::before { content: ''; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--text-muted); }
@media(max-width:899px) { .people-collapsed-label { right: 12px; } }
@media(prefers-reduced-motion:reduce) { .people-collapsed-label { transition: none; } }
/* Conversation requests share the existing responsive DM layout. */
.dm-request-notice{flex-shrink:0;margin:0;padding:12px 16px;background:var(--surface-alt);border-bottom:1px solid var(--border);font-size:13px;color:var(--text-muted);line-height:1.6}
.dm-request-notice p{margin:0}.dm-request-notice [hidden]{display:none!important}.dm-request-notice>div{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.dm-request-notice button{font-size:13px;padding:8px 12px}
#tab-dm:not([data-request-state="accepted"]) #btn-dm-photo,#tab-dm:not([data-request-state="accepted"]) #btn-dm-voice{display:none!important}
#tab-dm[data-request-state="incoming"] .chat-input-wrapper,#tab-dm[data-request-state="declined"] .chat-input-wrapper,#tab-dm[data-request-state="unavailable"] .chat-input-wrapper{display:none}
.request-preview{display:block;color:var(--text-muted);font-size:12px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}
.request-limit-setting{padding:16px 0;border-top:1px solid var(--border);font-size:14px}.request-limit-setting p{font-size:12px;margin:6px 0 12px}.request-limit-setting>div{display:flex;gap:8px}.request-limit-setting input{min-width:0;flex:1}.request-limit-setting [role=status]{font-size:12px;color:var(--primary)}

/* Message requests swap in place of the conversations list (Instagram-style) */
#tab-friends.showing-requests > :not(#friend-requests-view) { display: none !important; }
.friend-requests-view { display: flex; flex-direction: column; min-height: 0; flex: 1; animation: friend-requests-enter 160ms ease-out; }
.friend-requests-view[hidden] { display: none; }
.friend-requests-view-header { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 10px; padding: 4px 0 12px; }
.friend-requests-view-header h3 { margin: 0; font-size: 16px; text-align: center; }
.friend-requests-back { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-alt); color: var(--primary); cursor: pointer; }
.friend-requests-back:hover { background: var(--surface-hover); border-color: var(--primary); }
.friend-requests-back svg { width: 20px; height: 20px; }
.friend-requests-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 18vh 24px 0; }
.friend-requests-empty-icon { display: grid; place-items: center; width: 84px; height: 84px; border: 2px solid var(--text, #fff); border-radius: 50%; color: var(--text, #fff); }
.friend-requests-empty-icon svg { width: 46px; height: 46px; }
.friend-requests-empty h4 { margin: 8px 0 0; font-size: 22px; font-weight: 700; }
.friend-requests-empty p { margin: 0; max-width: 260px; font-size: 14px; color: var(--text-muted, var(--muted, #9aa)); }
@media (prefers-reduced-motion: reduce) { .friend-requests-view { animation: none; } }
/* Request-limit setting: input fills the row, save button keeps its natural width */
.request-limit-setting > div { display: flex; align-items: stretch; gap: 8px; }
.request-limit-setting .text-input { flex: 1 1 auto; width: auto; min-width: 0; margin: 0; min-height: 44px; }
.request-limit-setting .btn { flex: 0 0 auto; width: auto; margin: 0; min-height: 44px; padding: 0 22px; }
/* Room picker shown under the "share to room" button on game-over screens. */
.room-share-picker{display:flex;flex-direction:column;gap:6px;width:100%;max-height:150px;overflow:auto;margin-top:10px;font-size:13px;color:var(--text-muted)}
.room-share-picker .room-share-option{width:100%;text-align:right;padding:8px 12px;font-size:13px}

/* Shared game-score bubbles in rooms: tap to play. */
.bubble.bubble-game{cursor:pointer}
.bubble.bubble-game:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.bubble-game-cta{font-size:12px;font-weight:700;color:var(--primary);margin-bottom:4px}
/* Game-over overlay: keep the room picker inside the panel instead of overflowing it. */
#flappy-gameover-overlay{overflow:auto;justify-content:safe center}
#flappy-gameover-overlay .modal-actions-row{width:100%}
#btn-flappy-again{flex-basis:100%}
#btn-flappy-share,#btn-flappy-share-room{flex:1 1 0;min-width:0;padding-inline:8px}
.room-share-picker{flex-direction:row;flex-wrap:wrap;justify-content:center;max-height:96px;gap:6px}
.room-share-picker .room-share-option{width:auto;flex:0 1 auto;text-align:center;padding:6px 12px;border-radius:999px}

/* Room share picker: choose between last score and personal best. */
.room-share-picker .room-share-mode{display:flex;width:100%;gap:6px}
.room-share-picker .room-share-mode-btn{flex:1 1 0;font:inherit;font-size:13px;padding:6px 8px;cursor:pointer;color:var(--text-muted);background:transparent;border:1px solid var(--border);border-radius:999px}
.room-share-picker .room-share-mode-btn.active{color:var(--text);border-color:var(--primary);background:var(--surface-alt)}
.room-share-picker .room-share-rooms{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;width:100%}

/* Message requests on touch screens: accept and decline sit together on the
   trailing side of the row, instead of accept next to the avatar and decline
   at the far end. (Mouse devices keep the avatar-turns-into-accept behaviour.) */
@media (hover: none) {
  #friend-requests-list .friend-request-row { grid-template-columns: auto minmax(0, 1fr) auto auto !important; }
  #friend-requests-list .friend-request-row .req-slot { display: contents !important; }
  #friend-requests-list .friend-request-row .req-slot .friend-avatar { grid-column: 1; grid-row: 1; }
  #friend-requests-list .friend-request-row > div:nth-child(2) { grid-column: 2; grid-row: 1; }
  #friend-requests-list .friend-request-row .req-slot .friend-req-icon-btn.is-accept { grid-column: 3; grid-row: 1; margin-inline-end: -4px; }
  #friend-requests-list .friend-request-row .inline-banner-actions { grid-column: 4 !important; grid-row: 1; }
}

/* Touch screens: after tapping accept, the list re-renders and the next row
   slides under the finger; the browser then treats it as :hover (sticky hover),
   which fades the avatar out until the next tap. The avatar never hides on touch. */
@media (hover: none) {
  #friend-requests-list .friend-request-row:hover .req-slot .friend-avatar,
  #friend-requests-list .friend-request-row:focus-within .req-slot .friend-avatar {
    opacity: 1 !important; transform: none !important; transition: none !important;
  }
}

/* Touch: no hover highlight on request rows (sticky hover flashed the card that slid under the finger). */
@media (hover: none) {
  #friend-requests-list .friend-request-row:hover { background: var(--surface); transition: none; }
}



/* Desktop: direct profile editing, with secondary settings in a window. */
.header-profile-edit{display:none}
@media(min-width:900px){
.header-profile-edit{display:flex;align-items:center;gap:8px;position:relative;margin-inline-end:12px;min-width:0}
.header-inline-identity{display:flex;align-items:center;gap:8px;width:180px;min-width:120px;padding:3px 6px;border:1px solid var(--border);border-radius:12px;background:var(--surface-alt)}
.header-inline-identity button{border:0;background:none;padding:0;cursor:pointer;flex:none}.header-inline-identity .nav-avatar{display:block;width:30px;height:30px;border-radius:50%;--ring-w:2px}
#header-nickname{width:100%;min-width:0;background:transparent;border:0;color:var(--text);font:inherit;font-size:14px;padding:6px 0;outline:none}.header-inline-identity:focus-within{border-color:var(--primary)}
#header-age,#header-gender,.header-more-settings{height:38px;border:1px solid var(--border);border-radius:10px;background:var(--surface-alt);color:var(--text);font:inherit;font-size:13px;padding:0 10px;box-sizing:border-box}
#header-age{width:58px;text-align:center;appearance:textfield;padding:0 4px}#header-age::-webkit-inner-spin-button,#header-age::-webkit-outer-spin-button{appearance:none}#header-gender{width:94px;cursor:pointer}.header-more-settings{cursor:pointer;white-space:nowrap}.header-more-settings span{color:var(--primary);margin-inline-start:5px}
#header-inline-actions{display:flex;align-items:center;gap:4px}#header-inline-actions[hidden]{display:none}#btn-header-save{font-size:12px;padding:8px 12px;border-radius:10px}#btn-header-cancel{border:0;background:none;color:var(--text-muted);cursor:pointer;font-size:23px;padding:4px}
#header-profile-error{position:absolute;top:100%;inset-inline-start:0;max-width:320px;padding:10px 14px;margin:8px 0;background:var(--surface);color:var(--danger,#ed728a);border:1px solid var(--border);border-radius:10px;font-size:12px;z-index:1500;box-shadow:0 8px 24px #0003}
.header-profile-edit :focus-visible{outline:2px solid var(--primary);outline-offset:2px}
}
@media(min-width:900px) and (max-width:1100px){.header-inline-identity{width:140px}.header-profile-edit{gap:5px}.connection-status{font-size:11px;margin-inline-end:6px}}
.header-settings-modal{z-index:1900}
.header-settings-card{width:min(480px,calc(100vw - 32px));max-height:85dvh;display:flex;flex-direction:column;overflow:hidden;padding:0!important;border-radius:20px}
.header-settings-heading{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--border);flex-shrink:0}.header-settings-heading h3{margin:0;font-size:18px}
.header-settings-content{padding:20px;overflow:auto;min-height:0}.header-settings-content>.tab-title,.header-settings-content>.header-quick-field{display:none}
.header-settings-content .text-input{box-sizing:border-box;width:100%}.header-settings-content .avatar-preview{margin-inline:auto}

/* Stable quick-edit actions; gender color is limited to the avatar ring. */
@media(min-width:900px){
  .header-profile-edit{--profile-accent:var(--primary)}
  .header-inline-identity,#header-age,#header-gender{transition:border-color .2s,background .2s}
  .header-inline-identity:focus-within{border-color:var(--profile-accent)}
  .header-inline-identity .header-more-settings{display:grid;place-items:center;width:30px;height:30px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--text-muted);transition:background .2s,color .2s}
  .header-inline-identity .header-more-settings:hover{background:var(--surface);color:var(--primary)}
  #header-gender{width:42px;padding:0;font-size:23px;display:grid;place-items:center}
  #header-gender:hover{border-color:var(--profile-accent)}
  #header-inline-actions{gap:2px}
  #btn-header-save{width:68px;height:38px;display:grid;place-items:center;padding:0 10px;border:1px solid var(--border);border-radius:10px;background:var(--surface-alt);color:var(--text-muted);font:inherit;font-size:13px;font-weight:600;cursor:pointer;transition:background .2s,color .2s,border-color .2s}
  #btn-header-save:disabled{opacity:.55;cursor:default}
  #header-inline-actions.is-dirty #btn-header-save{background:color-mix(in srgb,var(--profile-accent) 16%,var(--surface));border-color:color-mix(in srgb,var(--profile-accent) 45%,var(--border));color:var(--profile-accent)}
  #btn-header-cancel{width:24px;padding:0;transition:opacity .2s;opacity:0;visibility:hidden}
  #header-inline-actions.is-dirty #btn-header-cancel{opacity:1;visibility:visible}
}
@media(prefers-reduced-motion:reduce){.header-profile-edit *{transition:none!important}}
/* header cancel button now uses the shared X icon instead of a text "×" */
#btn-header-cancel{display:inline-flex;align-items:center;justify-content:center}
#btn-header-cancel svg{width:18px;height:18px}
/* ============================================================
   "הצד השני עזב את השיחה" - אותו עיצוב קומפקטי בדסקטופ ובמובייל,
   באותו סגנון של כפתור "שיחה חדשה" (רקע כהה, מסגרת, טקסט סגול).
   דסקטופ: טקסט מעל הכפתור. מובייל: טקסט והכפתור באותה שורה.
   ============================================================ */
#view-main .match-controls #home-left[style*="block"] {
  display: flex !important; align-items: stretch; gap: 8px; width: 100%;
}
#home-left .left-icon, #home-left .left-sub { display: none; }
#view-main .match-controls #home-left .left-text {
  display: flex; align-items: center; margin: 0; min-width: 0; white-space: normal;
}
#home-left .left-title { font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--text-muted); }
#view-main .match-controls #home-left #btn-find-again {
  height: 40px; min-height: 40px; padding: 0 16px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  background: var(--surface-alt); color: var(--primary);
  border: 1px solid var(--border); box-shadow: none; transform: none;
  transition: border-color .15s ease, background .15s ease;
}
#view-main .match-controls #home-left #btn-find-again:hover { border-color: var(--primary); background: var(--surface-hover); }
#view-main .match-controls #home-left #btn-find-again:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#home-left #btn-find-again svg { display: none; }

@media (min-width: 900px) {
  #tab-rooms > .match-controls:has(#home-left[style*="block"]) { padding: 10px 0; }
  #view-main .match-controls #home-left[style*="block"] { flex-direction: column; }
  #view-main .match-controls #home-left .left-text { justify-content: center; text-align: center; }
  #view-main .match-controls #home-left #btn-find-again { width: 100%; }
}
@media (max-width: 899px) {
  #view-main > .match-controls:has(#home-left[style*="block"]) { padding: 8px 10px; border-radius: 14px; }
  #view-main .match-controls #home-left[style*="block"] { flex-direction: row; align-items: center; justify-content: space-between; }
  #view-main .match-controls #home-left .left-text { flex: 1; }
  #view-main .match-controls #home-left #btn-find-again { width: auto; flex: 0 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  #view-main .match-controls #home-left #btn-find-again { transition: none; }
}