:root {
  color-scheme: light;
  --bg: #edf3f2;
  --panel: #fff;
  --surface: #f2f7f6;
  --line: #d7e4e1;
  --muted: #536c67;
  --green: #086b61;
  --text: #173530;
  --tint: #deefeb;
}

body { background: var(--bg); }
.top {
  height: 64px;
  gap: 18px;
  padding-inline: max(20px, calc((100vw - 1250px) / 2));
  background: #fff;
  backdrop-filter: none;
}
.brand { min-width: 184px; font-size: 24px; letter-spacing: -.035em; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.search { max-width: 410px; padding-inline: 12px; }
.search input { margin: 0; padding: 8px 0; }
.search, .compose .placeholder, input, select, textarea { background: var(--surface); }
input, select, textarea { border-color: var(--line); }
label, .navbtn, .details span { color: var(--muted); }
.account { padding: 5px; border-radius: 10px; }
.account:hover, .ghost:hover, .navbtn:hover, .right .item:hover { background: var(--surface); }
.avatar { background: var(--tint); color: var(--green); }
.layout {
  max-width: 1290px;
  padding: 24px 20px;
  grid-template-columns: 184px minmax(0, 1fr) 258px;
  gap: 18px;
}
.sidebar, .right { top: 88px; max-height: calc(100vh - 100px); }
.navbtn { padding: 8px 10px; border-radius: 8px; }
.navbtn i { color: var(--green); }
.sidefoot { color: var(--muted); }
.navbtn.active, .tab.active { background: var(--tint); color: var(--green); }
.card { border-radius: 12px; box-shadow: 0 2px 8px #14493e08; margin-bottom: 12px; }
.pagehead { margin-bottom: 14px; }
.pagehead .muted:empty { display: none; }
h1 { font-size: 27px; }
.primary { color: #fff; background: var(--green); font-weight: 650; }
.primary:hover { background: #07584f; }
.primary:disabled { cursor: default; opacity: .55; }
.compose { padding: 12px; }
.compose .placeholder { min-width: 0; }
.feed-tabs { background: var(--panel); border: 1px solid var(--line); padding: 5px; border-radius: 12px; }
.tab { background: transparent; color: var(--muted); }
.tab:hover, .stat, .chatbubble, .right .item .bubble { background: var(--tint); }
.pill { background: var(--surface); }
.actions .liked, #autherror { color: #a83544; }
.signed-out .layout { display: block; max-width: 510px; margin-top: 4vh; }
.signed-out .sidebar, .signed-out .right, .signed-out .mobile, .signed-out .search, .signed-out .top > .ghost { display: none; }
.signed-out .hero, .signed-out .hero .eyebrow { color: #edf8f5; }
.signed-out [data-authmode] { font-size: 14px; }
.mobile { background: var(--panel); }

body.messenger-page .layout { grid-template-columns: 184px minmax(0, 1fr); }
.messenger-page .right { display: none; }
.messenger-title { margin: 0 0 14px; }
.messenger-shell {
  display: grid;
  grid-template-columns: minmax(200px, 31%) minmax(0, 1fr);
  min-height: min(600px, 72vh);
  padding: 0;
  overflow: hidden;
}
.conversation-list { min-width: 0; border-right: 1px solid var(--line); }
.conversation-switch { display: flex; padding: 9px; gap: 5px; border-bottom: 1px solid var(--line); }
.conversation-switch .tab { flex: 1; }
.conversation-rows { max-height: min(70vh, 670px); overflow: auto; }
.conversation-row {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}
.conversation-row > span:last-child { min-width: 0; }
.conversation-row b, .conversation-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-row small { color: var(--muted); }
.conversation-row:hover { background: var(--surface); }
.conversation-row.active { background: var(--tint); }
.conversation-hint, .group-create { margin: 12px; color: var(--muted); }
.group-create summary { cursor: pointer; color: var(--green); font-weight: 650; }
.group-create form { margin-top: 10px; }
.group-create form small { display: block; margin-bottom: 10px; }
.conversation-content { display: flex; flex-direction: column; min-width: 0; }
.conversation-empty { margin: auto; }
.conversation-back { display: none; }
.privatehead42, .group-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.privatepeer42 { min-width: 0; overflow-wrap: anywhere; }
.typing42:empty { min-height: 0; }
.presence42.online { color: var(--green); }
.conversation-content .history42 { flex: 1; padding: 14px; background: var(--surface); }
.message42.mine42 { background: var(--tint); }
.message42.theirs42 { background: var(--panel); border: 1px solid var(--line); }
.messageMeta42 { color: var(--muted); }
.reaction42, .voice-message, .attachment-preview { background: var(--panel); border-color: var(--line); }
.reactionQuick42:hover, .attachbtn:hover, .recordbtn:hover { background: var(--tint); }
.attachbtn, .recordbtn { background: var(--surface); }
.conversation-content .privatecomposer { margin: 0; padding: 10px 14px; }
.groupChat42 { display: flex; flex-direction: column; flex: 1; padding: 0; margin: 0; border: 0; }
.group-chat-header h2, .group-chat-header p { margin: 0; overflow-wrap: anywhere; }
.groupAdd42 { padding: 0 14px 12px; }
.callCard42 .ghost:hover { color: var(--text); }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 170px minmax(0, 1fr); }
  .brand { min-width: 170px; }
}
@media (max-width: 760px) {
  .top { height: calc(59px + env(safe-area-inset-top)); gap: 8px; padding: env(safe-area-inset-top) 12px 0; }
  .brand { min-width: 0; font-size: 21px; gap: 6px; }
  .brand img { width: 32px; height: 32px; }
  .search { min-width: 0; padding-inline: 8px; }
  .search input { min-width: 0; font-size: 16px; }
  .account span:last-child { display: none; }
  .layout { display: block; padding: 14px 10px calc(82px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .mobile {
    position: fixed;
    inset: auto 0 0;
    z-index: 5;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--line);
    padding: 5px 2px max(5px, env(safe-area-inset-bottom));
  }
  .mobile button { display: grid; justify-items: center; color: var(--muted); font-size: 10px; min-height: 44px; padding: 4px; }
  .mobile i { font-style: normal; font-size: 19px; }
  .mobile .active { color: var(--green); }
  .messenger-shell { display: block; min-height: 0; }
  .conversation-list { border: 0; }
  .conversation-content { display: none; }
  .conversation-open .conversation-list { display: none; }
  .conversation-open .conversation-content, .conversation-back { display: flex; }
  .conversation-content .history42 { min-height: 36vh; }
  .conversation-content .privatecomposer { flex-direction: row; align-items: flex-end; }
  .conversation-content .sendchat { width: auto; }
  .privatehead42 { flex-wrap: nowrap; }
  .callactions42 { gap: 4px; }
  .callactions42 button, .conversation-back { padding-inline: 7px; min-width: 36px; }
  .compose { gap: 6px; }
  .compose .placeholder { padding-inline: 7px; }
  .compose .primary { padding-inline: 8px; }
}
.callCard42 video[hidden] { display: none !important; }

/* Full-window messenger */
body.messenger-page {
  color-scheme: dark;
  --bg: #101a20;
  --panel: #17262d;
  --surface: #101d24;
  --line: #2d424b;
  --muted: #abc1c8;
  --green: #86e6d4;
  --text: #f0f8fa;
  --tint: #23454b;
  background: var(--bg);
  overflow: hidden;
}
.messenger-page > .top, .messenger-page > .mobile, .messenger-page .sidebar { display: none; }
body.messenger-page .layout {
  display: block;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}
.messenger-page #main, .messenger-page .messenger-shell { height: 100%; min-height: 0; }
.messenger-page .messenger-shell {
  grid-template-columns: clamp(226px, 26vw, 340px) minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  margin: 0;
}
.messenger-page .conversation-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.messenger-sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
}
.messenger-sidebar-head h1 { margin: 0; font-size: 21px; }
.messenger-sidebar-head a { display: inline-flex; border-radius: 10px; }
.messenger-sidebar-head img { width: 36px; height: 36px; border-radius: inherit; }
.messenger-page .conversation-rows { flex: 1; max-height: none; }
.messenger-page .conversation-content, .messenger-page .groupChat42 { min-height: 0; }
.messenger-page .conversation-content { background: var(--bg); }
.messenger-page .privatehead42, .messenger-page .group-chat-header {
  flex: none;
  background: var(--panel);
  padding: max(10px, env(safe-area-inset-top)) clamp(12px, 2vw, 26px) 10px;
}
.messenger-page .conversation-content .history42 {
  min-height: 0;
  max-height: none;
  background-color: #101c23;
  background-image:
    radial-gradient(ellipse 85% 75% at 75% 0%, #163641b0, transparent),
    repeating-radial-gradient(ellipse at 18% 135%, transparent 0 29px, #74c9c713 30px 31px, transparent 32px 49px);
  padding: 16px clamp(12px, 4vw, 64px);
}
.messenger-page .message42 { flex: none; color: var(--text); }
.messenger-page .message42.mine42 {
  background: linear-gradient(135deg, #145f60, #274d79);
  border-radius: 16px 5px 16px 16px;
}
.messenger-page .message42.theirs42 { background: #22343e; border-radius: 5px 16px 16px 16px; }
.messenger-page .message42 .muted, .messenger-page .messageMeta42 { color: #c7dce4; }
.messenger-page .conversation-content .privatecomposer {
  flex: none;
  gap: 8px;
  background: var(--panel);
  padding: 10px clamp(12px, 4vw, 64px) max(10px, env(safe-area-inset-bottom));
  align-items: start;
}
.messenger-page .chatcompose { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; }
.messenger-page .chatcompose > input { min-height: 44px; margin: 0; }
.messenger-page .attachmenttools { flex-wrap: nowrap; }
.messenger-page .attachmenttools #voiceStatus { position: absolute; bottom: 100%; right: 12px; background: var(--panel); }
.messenger-page .attachmenttools #voiceStatus:empty, .messenger-page #privateAttachmentPreview:empty { display: none; }
.messenger-page .privatecomposer { position: relative; }
.messenger-page #privateAttachmentPreview { grid-column: 1 / -1; }
.messenger-page .attachbtn, .messenger-page .recordbtn, .messenger-page .sendchat {
  min-width: 44px;
  min-height: 44px;
  width: auto;
  padding: 0 10px;
  font-size: 18px;
}
.messenger-page .composer-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.messenger-page .primary { background: var(--green); color: #102424; }
.messenger-page .primary:hover { background: #a9f1e3; }
.messenger-page #toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
.messenger-page .callCard42 { bottom: calc(72px + env(safe-area-inset-bottom)); }
.messenger-page .groupAdd42 { flex: none; max-height: 27vh; overflow: auto; }
.messenger-page .attachbtn:focus-within { outline: 2px solid var(--green); outline-offset: 2px; }

@media (max-width: 760px) {
  .messenger-page .messenger-shell { display: flex; }
  .messenger-page .conversation-list, .messenger-page .conversation-content { width: 100%; }
  .messenger-page .conversation-content, .messenger-page .conversation-open .conversation-list { display: none; }
  .messenger-page .conversation-open .conversation-content { display: flex; }
  .messenger-page .message42 { max-width: 88%; }
  .messenger-page .conversation-content .privatecomposer { gap: 5px; }
  .messenger-page .chatcompose, .messenger-page .attachmenttools { gap: 5px; }
}
.messenger-page .conversation-content #privateHistory { max-height: none; }
.recordbtn { touch-action: none; user-select: none; -webkit-touch-callout: none; }
.messenger-page .recordbtn[data-recording] { background: #963b4b; color: white; }
.voice-message audio { width: clamp(145px, 44vw, 245px); max-width: 100%; }
.media-download { display: inline-block; margin-top: 4px; font-size: 13px; }
.messenger-page .attachmenttools #fileStatus { position: absolute; bottom: 100%; right: 12px; background: var(--panel); }
.messenger-page .attachmenttools #fileStatus:empty { display: none; }
.notification-bell { position: relative; min-width: 42px; min-height: 42px; }
.bell-count {
  position: absolute;
  right: -5px;
  top: -6px;
  min-width: 19px;
  padding: 1px 4px;
  border-radius: 12px;
  background: #bd3f4f;
  color: white;
  font: 700 11px/17px system-ui, sans-serif;
  text-align: center;
}
.messenger-sidebar-head .notification-bell { margin-left: auto; padding-inline: 8px; }
@media(max-width:760px) {
  .top > .notification-bell { display: inline-grid; place-items: center; padding: 5px; }
  .signed-out .top > .notification-bell { display: none; }
}
