/* A restrained, familiar messenger interface layered over the original styles. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #252928;
  background: #f2f2ef;
  --green: #17697a;
  --green-dark: #105364;
  --green-pale: #e4eff1;
  --line: #dedfdb;
  --muted: #68716e;
  --danger: #c94747;
}

body { background: #f2f2ef; color: #252928; }
button, input, textarea, select { font-family: inherit; }
.brand { font-family: inherit; font-size: 22px; font-weight: 700; line-height: 1.1; letter-spacing: -.65px; color: #173f45; }
.brand span { display: none; }

.auth-view {
  min-height: 100vh;
  grid-template-columns: minmax(360px, 42%) minmax(420px, 1fr);
  place-items: stretch;
  padding: 0;
  background: #fff;
}
.auth-story {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(48px, 8vw, 112px);
  background: #17444a;
  color: #fff;
}
.story-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 42px;
  border-radius: 11px;
  box-shadow: 0 10px 24px #071e2238;
}
.auth-story h1 {
  max-width: 520px;
  margin: 0 0 22px;
  font-size: clamp(42px, 5vw, 66px);
  line-height: 1.02;
  letter-spacing: -2.4px;
}
.auth-story p { max-width: 500px; margin: 0; color: #d3e1e2; font-size: 17px; line-height: 1.65; }
.auth-story ul {
  display: grid;
  gap: 11px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  color: #eef5f5;
  font-size: 14px;
  font-weight: 600;
}
.auth-story li::before { content: "✓"; display: inline-block; width: 25px; color: #8fc0c7; }
.auth-card {
  align-self: center;
  width: min(440px, calc(100% - 64px));
  margin: auto;
  padding: 44px 20px;
  background: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.mobile-brand { display: none; }
.auth-card h1 { font-family: inherit; font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -.8px; margin: 0 0 10px; }
.auth-card > p { font-size: 15px; line-height: 1.55; margin: 0 0 30px; }
.public-summary { padding: 0; border-radius: 0; background: transparent; color: #68716e; font-size: 14px !important; }
label { font-size: 13px; color: #383e3c; }
input, select { height: 48px; border: 1px solid #cfd2ce; border-radius: 7px; background: #fff; color: #252928; }
input:focus, textarea:focus, select:focus { border-color: #17697a; box-shadow: 0 0 0 3px #dbecef; outline: 0; }
.primary { border-radius: 7px; background: #17697a; font-weight: 650; }
.primary:hover { background: #105364; }
.soft-button { border: 1px solid #cfd4d2; border-radius: 7px; background: #fff; color: #23525b; font-weight: 650; }
.soft-button:hover { background: #f4f6f5; }
.link-button { color: #17697a; }
.fine-print { color: #7b827f !important; }

.app { max-width: none; margin: 0; grid-template-columns: 320px minmax(0, 1fr); background: #fff; box-shadow: none; }
.sidebar { padding: 0; background: #f5f5f2; border-right: 1px solid #d8dad7; }
.side-top { height: 68px; padding: 0 18px; border-bottom: 1px solid #e0e1de; }
.icon-button .avatar { transition: background .15s; }
.icon-button:hover .avatar { background: #cbdfe2; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #d9e7e9; color: #155867; font-size: 13px; font-weight: 700; letter-spacing: .2px; }
.avatar.small { width: 34px; height: 34px; }
.group-avatar { border-radius: 10px; background: #e7e1ee; color: #69547c; }
.main-tabs {
  height: 48px;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0 14px 14px;
  padding: 0;
  background: transparent;
  border-bottom: 1px solid #dfe0dd;
  border-radius: 0;
}
.tab { position: relative; min-height: 48px; border-radius: 0; color: #68716e; font-size: 13px; font-weight: 650; }
.tab.active { background: transparent; color: #173f45; box-shadow: inset 0 -2px #17697a; }
.side-view { padding: 0 10px; }
.section-head { padding: 3px 8px 9px; }
.section-head h2 { font-family: inherit; font-size: 12px; font-weight: 650; line-height: 1; letter-spacing: .15px; color: #717875; }
.conversation, .friend-row, .request-row, .result-row { padding: 9px 10px; border-radius: 7px; color: #2e3432; }
.conversation { min-height: 62px; }
.conversation:hover, .friend-row:hover { background: #e9eae7; }
.conversation.active { background: #e0eaeb; box-shadow: inset 3px 0 #17697a; }
.conversation-copy strong, .row-copy strong { font-size: 14px; font-weight: 650; }
.conversation-copy small, .row-copy small { color: #727a77; }
.presence { background: #2c9c65; box-shadow: 0 0 0 2px #f5f5f2; }
.side-empty { padding: 18px 10px; color: #737a77; }
.account-bar { min-height: 70px; padding: 11px 16px; margin-top: 10px; background: #ededeb; border-top: 1px solid #d8dad7; }
.account-bar strong { font-size: 13px; }
.account-bar > div { flex: 1 1 0; min-width: 0; }
.account-bar #my-name { max-width: none; overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; }
.account-bar #my-name > :is(.display-role-badge, .profile-title-badge) { display: none; }
.account-bar #logout { flex: none; }
.quiet-button { color: #55605c; text-decoration: underline; text-underline-offset: 2px; }

.chat-header { height: 72px; padding: 0 24px; background: #fff; border-bottom: 1px solid #dedfdb; }
.chat-title strong { font-family: inherit; font-size: 16px; font-weight: 650; line-height: 1.2; }
.chat-title small { color: #737b78; }
.call-button { min-height: 38px; padding: 0 15px; border: 1px solid #cfd4d2; border-radius: 7px; background: #fff; color: #155867; font-size: 13px; font-weight: 650; }
.call-button:hover { background: #f1f5f4; }
.chat-panel { min-width: 0; min-height: 0; overflow: hidden; }
.message-feed { min-width: 0; min-height: 0; flex: 1 1 0; overflow-x: hidden; overflow-y: auto; padding: 28px 32px; background: #fbfbfa; }
.empty-state { max-width: 430px; margin: 18vh auto 0; text-align: center; }
.empty-icon { width: 48px; height: 42px; margin: 0 auto 18px; border: 1px solid #cfd4d2; border-radius: 10px; background: #fff; color: #17697a; font-size: 17px; letter-spacing: 2px; }
.empty-state h1 { font-family: inherit; font-size: 20px; font-weight: 650; line-height: 1.2; letter-spacing: -.25px; margin: 0 0 8px; }
.empty-state p { color: #707875; font-size: 14px; }
.message { min-width: 0; gap: 10px; margin-bottom: 18px; }
.message-body { min-width: 0; max-width: min(680px, 78%); }
.message-meta { margin-bottom: 5px; }
.message-meta strong { font-size: 12px; font-weight: 650; }
.message-meta time { color: #7a817f; }
.message p { padding: 10px 13px; border-radius: 4px 13px 13px 13px; background: #eceeeb; font-size: 14px; line-height: 1.5; }
.message.mine p { border-radius: 13px 4px 13px 13px; background: #dcebed; }
.system-avatar { border-radius: 12px; background: #dcebed; color: #155867; }
.system-message .message-meta strong { color: #155867; }
.system-message p { border: 1px solid #c8dcdf; background: #eef6f7; }
.composer-wrap { min-width: 0; flex: none; padding: 12px 24px 18px; background: #fff; border-top: 1px solid #e1e2df; }
.composer-identity { margin: 0 0 7px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.composer-identity strong { color: var(--ink, inherit); font-weight: 700; }
.composer { padding: 7px 8px 7px 13px; border: 1px solid #cfd2ce; border-radius: 10px; background: #fff; }
.composer:focus-within { border-color: #17697a; box-shadow: 0 0 0 3px #dbecef; }
.composer textarea { font-family: inherit; font-size: 14px; line-height: 1.45; color: #252928; }
.send-button { height: 38px; border-radius: 7px; background: #17697a; font-size: 13px; }
.send-button:hover { background: #105364; }

.modal-layer { background: #1e292780; backdrop-filter: none; }
.modal-card { padding: 26px; border: 1px solid #dadbd8; border-radius: 11px; box-shadow: 0 24px 70px #111b1940; }
.modal-head h2 { font-family: inherit; font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -.35px; }
.settings-section h3 { font-family: inherit; }
.incoming-card h2 { font-family: inherit; }
.call-screen header strong { font-family: inherit; }
.close-button { border: 1px solid #d5d8d5; border-radius: 7px; background: #fff; color: #4e5855; }
.address-box { border: 1px solid #dfe1de; border-radius: 7px; background: #f5f6f4; }
.check-list { border-radius: 7px; }
.check-row { border-radius: 5px; }
.role-badge { border-radius: 4px; }
.incoming-card { border-radius: 12px; }
.video-stage { border-radius: 10px; }
.privacy-chip { border-radius: 5px; }
.toast { border-radius: 7px; background: #243a3d; }
button:focus-visible { outline: 3px solid #90bec6; outline-offset: 2px; }

body.theme-dark { --green: #68aab6; --green-dark: #8fc3cb; --green-pale: #223b40; --line: #3a4140; --muted: #a6afac; background: #151918; color: #edf0ef; }
body.theme-dark .auth-view { background: #1a1f1e; }
body.theme-dark .auth-story { background: #12383e; }
body.theme-dark .app, body.theme-dark .chat-panel, body.theme-dark .modal-card, body.theme-dark .incoming-card, body.theme-dark .auth-card { background: #1d2221; color: #edf0ef; }
body.theme-dark .sidebar { background: #181d1c; border-color: #333a38; }
body.theme-dark .side-top, body.theme-dark .main-tabs, body.theme-dark .account-bar, body.theme-dark .chat-header, body.theme-dark .composer-wrap { border-color: #343a38; }
body.theme-dark .chat-header, body.theme-dark .composer-wrap { background: #1d2221; color: #edf0ef; }
body.theme-dark .composer textarea { background: transparent; color: #edf0ef; caret-color: #edf0ef; }
body.theme-dark .composer textarea::placeholder { color: #a6afac; opacity: 1; }
body.theme-dark .account-bar { background: #202625; }
body.theme-dark .brand { color: #dbe9e9; }
body.theme-dark .message-feed { background: #191e1d; }
body.theme-dark .tab.active { background: transparent; color: #e8efee; box-shadow: inset 0 -2px #68aab6; }
body.theme-dark .conversation:hover, body.theme-dark .friend-row:hover { background: #252c2a; }
body.theme-dark .conversation.active { background: #233437; box-shadow: inset 3px 0 #68aab6; }
body.theme-dark input, body.theme-dark select, body.theme-dark .composer, body.theme-dark .soft-button, body.theme-dark .call-button, body.theme-dark .close-button { background: #191e1d; color: #edf0ef; border-color: #414947; }
body.theme-dark label, body.theme-dark .settings-section h3 { color: #dce4e2; }
body.theme-dark .setting-help, body.theme-dark .modal-head p { color: #a6afac; }
body.theme-dark .message p { background: #2a302e; }
body.theme-dark .message.mine p { background: #234046; }
body.theme-dark .public-summary { background: transparent; }
body.theme-dark .address-box { background: #202624; border-color: #3b4240; }
body.theme-dark .empty-icon { background: #202624; border-color: #414947; color: #8ec5cc; }

@media (max-width: 800px) {
  .auth-view { grid-template-columns: 1fr; place-items: center; padding: 24px; background: #fff; }
  .auth-story { display: none; }
  .auth-card { width: min(440px, 100%); padding: 30px 20px; }
  .mobile-brand { display: block; margin-bottom: 45px !important; }
  .app { grid-template-columns: 1fr; }
  .call-button { width: auto; padding: 0 11px; font-size: 12px; }
  .call-button::before { display: none !important; }
}

@media (max-width: 720px) {
  .sidebar { padding: 0; }
  .side-top { height: 64px; }
  .chat-header { height: 66px; padding: 0 12px; }
  .call-button { min-width: 48px; width: auto; padding: 0 10px; font-size: 11px; }
  .message-feed { padding: 20px 14px; }
  .message-body { max-width: 84%; }
  .composer-wrap { padding: 9px 10px 12px; }
  .empty-state { margin-top: 14vh; }
  .video-stage { border-radius: 8px; }
}

/* Motion system */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(.985); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes backdropOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes messageIn {
  from { opacity: 0; transform: translateX(-9px) translateY(5px) scale(.985); }
  to { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}
@keyframes messageInMine {
  from { opacity: 0; transform: translateX(9px) translateY(5px) scale(.985); }
  to { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}
@keyframes presencePulse {
  0%, 70%, 100% { box-shadow: 0 0 0 2px #f5f5f2, 0 0 0 3px #2c9c6500; }
  85% { box-shadow: 0 0 0 2px #f5f5f2, 0 0 0 7px #2c9c6528; }
}
@keyframes callPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 #68aab600; }
  50% { transform: scale(1.035); box-shadow: 0 0 0 12px #68aab61c; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px) scale(.97); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

button, input, textarea, select, .avatar, .conversation, .friend-row, .request-row, .result-row {
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .18s ease, transform .16s ease, opacity .16s ease;
}
button:not(:disabled):hover { transform: translateY(-1px); }
button:not(:disabled):active { transform: translateY(0) scale(.965); transition-duration: .06s; }
button:disabled { cursor: default; opacity: .58; }
.primary, .send-button { box-shadow: 0 3px 9px #1053641c; }
.primary:not(:disabled):hover, .send-button:not(:disabled):hover { box-shadow: 0 5px 14px #1053642c; }
.icon-button:not(:disabled):hover, .quiet-button:not(:disabled):hover, .tab:not(:disabled):hover { transform: none; }
.icon-button:not(:disabled):active .avatar { transform: scale(.91); }

.auth-view:not(.hidden) .auth-story { animation: fadeIn .45s ease both; }
.auth-view:not(.hidden) .story-mark { animation: fadeUp .42s .08s cubic-bezier(.2,.75,.25,1) both; }
.auth-view:not(.hidden) .auth-story h1 { animation: fadeUp .48s .14s cubic-bezier(.2,.75,.25,1) both; }
.auth-view:not(.hidden) .auth-story p { animation: fadeUp .48s .2s cubic-bezier(.2,.75,.25,1) both; }
.auth-view:not(.hidden) .auth-story li { animation: slideFromLeft .35s cubic-bezier(.2,.75,.25,1) both; }
.auth-view:not(.hidden) .auth-story li:nth-child(1) { animation-delay: .27s; }
.auth-view:not(.hidden) .auth-story li:nth-child(2) { animation-delay: .32s; }
.auth-view:not(.hidden) .auth-story li:nth-child(3) { animation-delay: .37s; }
.auth-view:not(.hidden) .auth-card { animation: fadeUp .48s .08s cubic-bezier(.2,.75,.25,1) both; }

.app:not(.hidden) .sidebar { animation: slideFromLeft .32s cubic-bezier(.2,.75,.25,1) both; }
.app:not(.hidden) .chat-panel { animation: fadeIn .38s .06s ease both; }
.side-view:not(.hidden) { animation: fadeUp .24s cubic-bezier(.2,.75,.25,1) both; }
.tab { overflow: hidden; }
.tab::after {
  content: "";
  position: absolute;
  right: 20%;
  bottom: 0;
  left: 20%;
  height: 2px;
  background: #17697a;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .22s cubic-bezier(.2,.75,.25,1), left .22s ease, right .22s ease;
}
.tab.active { box-shadow: none; }
.tab.active::after { right: 0; left: 0; transform: scaleX(1); }
.conversation, .friend-row, .request-row, .result-row { animation: fadeUp .28s cubic-bezier(.2,.75,.25,1) both; }
.conversation:nth-child(2), .friend-row:nth-child(2), .request-row:nth-child(2) { animation-delay: .035s; }
.conversation:nth-child(3), .friend-row:nth-child(3), .request-row:nth-child(3) { animation-delay: .07s; }
.conversation:nth-child(4), .friend-row:nth-child(4), .request-row:nth-child(4) { animation-delay: .105s; }
.conversation:nth-child(n+5), .friend-row:nth-child(n+5), .request-row:nth-child(n+5) { animation-delay: .14s; }
.conversation:hover, .friend-row:hover { transform: translateX(2px); }
.conversation:active, .friend-row:active { transform: translateX(1px) scale(.985); }
.presence:not(.offline) { animation: presencePulse 2.6s ease-in-out infinite; }
.count { animation: modalIn .25s cubic-bezier(.2,.8,.25,1) both; }

.chat-title, .call-actions { animation: fadeUp .25s cubic-bezier(.2,.75,.25,1) both; }
.empty-state { animation: fadeUp .4s .08s cubic-bezier(.2,.75,.25,1) both; }
.message { animation: messageIn .26s cubic-bezier(.2,.75,.25,1) both; transform-origin: left bottom; }
.message.mine { animation-name: messageInMine; transform-origin: right bottom; }
.message:nth-last-child(2) { animation-delay: .025s; }
.message:last-child { animation-delay: .05s; }
.composer-wrap:not(.hidden) { animation: fadeUp .25s cubic-bezier(.2,.75,.25,1) both; }
.composer textarea { transition: height .14s ease, color .16s ease; }
.send-button:not(:disabled):active { transform: scale(.94); }

.modal-layer { animation: backdropIn .18s ease both; }
.modal-card, .incoming-card { animation: modalIn .24s cubic-bezier(.2,.8,.25,1) both; }
.modal-card .settings-section, .modal-card form { animation: fadeUp .3s cubic-bezier(.2,.75,.25,1) both; }
.modal-card .settings-section:nth-child(2) { animation-delay: .035s; }
.modal-card .settings-section:nth-child(3), .modal-card form:nth-child(3) { animation-delay: .07s; }
.modal-layer.is-closing { animation: backdropOut .18s ease both; pointer-events: none; }
.modal-layer.is-closing .modal-card, .modal-layer.is-closing .incoming-card { animation: modalOut .18s ease both; }
.incoming-card .avatar { animation: callPulse 1.35s ease-in-out infinite; }
.call-screen:not(.hidden) { animation: fadeIn .25s ease both; }
.call-screen:not(.hidden) .video-stage { animation: modalIn .34s .04s cubic-bezier(.2,.8,.25,1) both; }
.call-screen:not(.hidden) .call-controls { animation: fadeUp .32s .1s cubic-bezier(.2,.75,.25,1) both; }
.remote-placeholder .avatar { animation: callPulse 2.1s ease-in-out infinite; }
.local-video { transition: width .25s ease, height .25s ease, transform .2s ease, opacity .2s ease; }
.local-video:hover { transform: scale(1.025); }
.toast.show { animation: toastIn .24s cubic-bezier(.2,.8,.25,1) both; }

body.theme-dark .tab::after { background: #68aab6; }
body.theme-dark .presence:not(.offline) { animation-name: presencePulse; }

/* Rich messaging */
.chat-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chat-actions .call-actions { margin-left: 0; }
.composer-wrap { position: relative; }
.composer-wrap.dragging { background: #edf6f7; box-shadow: inset 0 0 0 2px #4f9aa7; }
.composer-toolbar { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; overflow-x: auto; scrollbar-width: thin; }
.composer-tool {
  min-height: 32px;
  flex: none;
  padding: 0 10px;
  border: 1px solid #d4d8d5;
  border-radius: 7px;
  background: #f7f8f6;
  color: #3f5659;
  font-size: 11px;
  font-weight: 650;
}
.composer-tool:hover { background: #edf3f3; border-color: #bfcac9; }
.chat-background-tool { border-color: #b9cbd0; background: #eaf3f4; color: #155867; }
.chat-background-tool:hover { background: #dcecef; }
.visually-hidden { position: fixed !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
.emoji-picker {
  position: absolute;
  left: 24px;
  bottom: calc(100% - 5px);
  z-index: 4;
  width: min(330px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  padding: 10px;
  border: 1px solid #d7dad7;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 40px #18211e2b;
  animation: modalIn .2s cubic-bezier(.2,.8,.25,1) both;
}
.emoji-picker button { width: 43px; height: 39px; padding: 0; border: 0; border-radius: 6px; background: transparent; font-size: 21px; }
.emoji-picker button:hover { background: #edf2f1; }
.attachment-preview { display: flex; gap: 8px; margin: 0 0 9px; overflow-x: auto; }
.attachment-chip { min-width: 150px; max-width: 230px; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px; border: 1px solid #d5d9d6; border-radius: 8px; background: #f7f8f6; animation: fadeUp .22s ease both; }
.attachment-chip > span { min-width: 0; flex: 1; }
.attachment-chip strong, .attachment-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip strong { font-size: 11px; }
.attachment-chip small { margin-top: 2px; color: #77807d; font-size: 10px; }
.attachment-chip button { width: 27px; height: 27px; flex: none; border: 0; border-radius: 6px; background: #e9ece9; color: #56605d; font-size: 18px; }
.upload-status { margin: 0 0 8px; color: #496a70; font-size: 11px; font-weight: 650; animation: fadeIn .18s ease both; }
.composer-wrap .upload-status, .draft-help { font-size: 13px; line-height: 1.5; }
.composer-wrap .upload-status { color: var(--muted); }
.draft-help { display: block; margin-top: 6px; color: var(--muted, #496a70); }
#retry-chat-upload { min-height: 44px; margin-bottom: 8px; }
.message-text a { color: #0f6577; text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.message-attachments { min-width: 0; max-width: 100%; display: grid; gap: 7px; margin-top: 7px; overflow: hidden; }
.media-attachment { display: block; width: min(440px, 100%); max-width: 100%; max-height: min(330px, 48vh); overflow: hidden; border: 1px solid #dfe2df; border-radius: 10px; background: #e9ece9; }
.media-attachment img, img.media-attachment { display: block; width: 100%; max-width: 100%; height: auto; max-height: min(330px, 48vh); object-fit: contain; }
video.media-attachment { width: min(440px, 100%); height: auto; max-height: min(330px, 48vh); object-fit: contain; background: #111; }
.message-attachments audio { width: min(360px, 100%); }
.message-meta { min-height: 28px; }
.message { position: relative; -webkit-touch-callout: none; user-select: none; touch-action: pan-y; }
.message-more {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin: -6px 0 -4px 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #66716e;
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}
.message:hover .message-more, .message:focus-within .message-more { opacity: 1; }
.message-more:hover { background: #e9edeb; }
.message-receipt { display: block; margin-top: 6px; color: #76807d; font-size: 10px; text-align: right; }
.message-reply {
  width: 100%;
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
  padding: 8px 10px;
  border: 0;
  border-left: 3px solid #4f8f9a;
  border-radius: 6px;
  background: #eef3f3;
  color: #35403e;
  text-align: left;
}
.message-reply strong { color: #17697a; font-size: 11px; }
.message-reply span { overflow: hidden; color: #68716e; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.announcement-badge { padding: 3px 6px; border-radius: 4px; background: #fff0c7; color: #745817; font-size: 9px; font-weight: 750; }
.announced-message .message-body { padding: 7px; border: 1px solid #e7cf8a; border-radius: 10px; background: #fffdf6; }
.message-highlight .message-body { animation: messageHighlight 1.5s ease; }
@keyframes messageHighlight { 0%, 100% { box-shadow: 0 0 0 0 #dfb74200; } 25%, 70% { box-shadow: 0 0 0 5px #dfb74255; } }
.group-announcement {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-bottom: 1px solid #ead89f;
  background: #fff9e8;
  color: #4e4732;
}
.announcement-mark { flex: none; font-size: 20px; }
.group-announcement > span:nth-child(2) { min-width: 0; flex: 1; }
.group-announcement strong, .group-announcement small { display: block; }
.group-announcement strong { font-size: 11px; }
.group-announcement small { margin-top: 2px; overflow: hidden; color: #73694d; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.group-announcement button { min-height: 34px; padding: 0 11px; border: 1px solid #dfc875; border-radius: 7px; background: #fff; color: #66501d; font-size: 11px; font-weight: 700; }
.reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 8px 9px 8px 12px;
  border-left: 3px solid #4f8f9a;
  border-radius: 6px;
  background: #eef4f4;
}
.reply-preview > span { min-width: 0; flex: 1; }
.reply-preview strong, .reply-preview small { display: block; }
.reply-preview strong { color: #17697a; font-size: 11px; }
.reply-preview small { margin-top: 2px; overflow: hidden; color: #697370; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview button { width: 32px; height: 32px; flex: none; border: 0; border-radius: 50%; background: transparent; color: #66716e; font-size: 20px; }
.reply-preview button:hover { background: #dfe9e8; }
.message-actions-card { width: min(430px, 100%); }
.message-action-list { display: grid; gap: 8px; }
.message-action-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px solid #dfe2df;
  border-radius: 9px;
  background: #fff;
  color: #303735;
  text-align: left;
}
.message-action-button > span:first-child { width: 38px; height: 38px; display: grid; place-items: center; flex: none; border-radius: 50%; background: #edf1ef; font-size: 20px; }
.message-action-button strong, .message-action-button small { display: block; }
.message-action-button strong { font-size: 13px; }
.message-action-button small { margin-top: 3px; color: #727b78; font-size: 11px; line-height: 1.4; }
.message-action-button:hover { background: #f6f8f7; }
.message-action-button.danger-action { border-color: #ead4d4; color: #a13e3e; }
.message-action-button.danger-action > span:first-child { background: #f8e9e9; }
.file-attachment { min-width: min(310px, 70vw); display: flex; align-items: center; gap: 11px; padding: 11px; border: 1px solid #d6dad7; border-radius: 9px; background: #f4f6f4; color: #26322f; text-decoration: none; }
.file-attachment > span:first-child { width: 40px; height: 38px; display: grid; place-items: center; flex: none; border-radius: 7px; background: #dcebed; color: #155867; font-size: 9px; font-weight: 800; letter-spacing: .6px; }
.file-attachment > span:last-child { min-width: 0; }
.file-attachment strong, .file-attachment small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-attachment strong { font-size: 12px; }
.file-attachment small { margin-top: 3px; color: #737b78; font-size: 10px; }
.contact-card { min-width: min(330px, 72vw); display: flex; align-items: center; gap: 10px; margin-top: 7px; padding: 11px; border: 1px solid #d6dad7; border-radius: 9px; background: #f4f6f4; }
.contact-card > span:nth-child(2) { min-width: 0; flex: 1; }
.contact-card strong, .contact-card small { display: block; }
.contact-card strong { font-size: 13px; }
.contact-card small { margin-top: 3px; color: #6d7673; font: 10px ui-monospace,SFMono-Regular,Consolas,monospace; }
.contact-card button { min-height: 32px; padding: 0 9px; border: 1px solid #ccd2cf; border-radius: 6px; background: #fff; color: #23525b; font-size: 10px; font-weight: 700; }
.contact-list { display: grid; gap: 6px; }
.contact-choice { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px; border: 0; border-radius: 7px; background: transparent; color: inherit; text-align: left; }
.contact-choice:hover { background: #eef1ef; transform: translateX(2px); }
.contact-choice > span:last-child { min-width: 0; }
.contact-choice strong, .contact-choice small { display: block; }
.contact-choice strong { font-size: 13px; }
.contact-choice small { margin-top: 3px; color: #6d7673; font: 10px ui-monospace,SFMono-Regular,Consolas,monospace; }
.conversation-notice { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 13px 20px; border-top: 1px solid #e0d0d0; background: #faf1f1; color: #7d3535; font-size: 12px; animation: fadeUp .25s ease both; }
.conversation-notice span { color: #855d5d; }
.danger-toggle strong { color: #a53f3f; }

/* Administrator center */
.admin-settings { padding-bottom: 0; }
.admin-card { width: min(1120px, 96vw); height: min(820px, 92vh); display: flex; flex-direction: column; overflow: hidden; }
.admin-head { flex: none; margin-bottom: 16px; }
.admin-head .role-badge { margin-bottom: 8px; }
.admin-summary { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; flex: none; }
.admin-metric { min-width: 0; padding: 13px 14px; border: 1px solid #dfe1de; border-radius: 8px; background: #f6f7f5; }
.admin-metric strong, .admin-metric span { display: block; }
.admin-metric strong { color: #173f45; font-size: 22px; line-height: 1; }
.admin-metric span { margin-top: 6px; color: #707875; font-size: 11px; }
.admin-tabs { display: flex; gap: 18px; margin-top: 17px; border-bottom: 1px solid #dedfdb; overflow-x: auto; flex: none; }
.admin-tab { min-height: 42px; padding: 0 2px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #68716e; font-size: 13px; font-weight: 700; white-space: nowrap; flex: none; }
.admin-tab.active { border-bottom-color: #17697a; color: #173f45; }
.admin-view { min-height: 0; flex: 1; padding-top: 15px; }
.admin-profile-shortcuts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.admin-usage-section { margin: 16px 0 19px; padding: 15px; border: 1px solid #d6e3e0; border-radius: 9px; background: #f7faf9; }
.admin-usage-section h4 { margin: 0 0 11px; font-size: 14px; }
.admin-usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.admin-usage-grid .admin-metric { background: #fff; }
.admin-usage-grid .admin-metric strong { font-size: 18px; }
.admin-usage-section .admin-activity-note { margin-bottom: 0; }
body.theme-dark .admin-usage-section { background: #202d29; border-color: #3d5149; }
body.theme-dark .admin-usage-grid .admin-metric { background: #26352f; }
.admin-broadcast-form { max-width: 600px; padding: 16px; }
.admin-broadcast-form h3 { margin-top: 0; }
.admin-broadcast-form p { line-height: 1.5; }
.admin-broadcast-form textarea { width: 100%; margin-top: 8px; }
.admin-remove-message { margin-top: 12px; }
.admin-group-members { display: grid; gap: 7px; margin-top: 12px; }
.admin-group-member { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid #e5e8e5; }
.admin-group-member .soft-button { min-height: 36px; }
.admin-toolbar { display: flex; align-items: end; gap: 10px; margin-bottom: 12px; }
.admin-search { min-width: 0; flex: 1; margin: 0; }
.admin-search input { margin-top: 6px; }
.admin-toolbar > .soft-button { min-height: 48px; padding: 0 15px; }
.admin-account-layout { height: calc(100% - 100px); min-height: 310px; display: grid; grid-template-columns: minmax(250px, 34%) minmax(0, 1fr); border: 1px solid #dedfdb; border-radius: 9px; overflow: hidden; }
.admin-list { min-height: 0; overflow: auto; padding: 7px; border-right: 1px solid #dedfdb; background: #f7f8f6; }
.admin-user-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 7px; background: transparent; color: inherit; text-align: left; }
.admin-user-row:hover { background: #eaedeb; transform: none; }
.admin-user-row.active { background: #dfecee; box-shadow: inset 3px 0 #17697a; }
.admin-user-copy { min-width: 0; flex: 1; }
.admin-user-copy strong, .admin-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-copy strong { font-size: 13px; }
.admin-user-copy small { margin-top: 3px; color: #737b78; font: 9px ui-monospace,SFMono-Regular,Consolas,monospace; }
.admin-user-status { flex: none; font-size: 10px; font-weight: 700; }
.admin-user-status.online { color: #197449; }
.admin-user-status.offline { color: #7c8581; }
.admin-user-status.suspended { color: #a33c3c; }
.admin-detail { min-height: 0; overflow: auto; padding: 20px; background: #fff; }
.admin-detail-heading { display: flex; align-items: center; gap: 11px; padding-bottom: 16px; border-bottom: 1px solid #e4e5e2; }
.admin-detail-heading h3 { margin: 0 0 4px; font-size: 18px; }
.admin-detail-heading .avatar { width: 54px; height: 54px; font-size: 19px; }
.admin-profile-bio { margin: 12px 0 4px; color: #58635e; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-role-label { display: inline-block; color: #6d7572; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.admin-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin: 4px 0 20px; }
.admin-facts > div { min-width: 0; padding: 11px 0; border-bottom: 1px solid #ededeb; }
.admin-facts dt { margin-bottom: 4px; color: #767e7b; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .35px; }
.admin-facts dd { margin: 0; overflow-wrap: anywhere; color: #29322f; font-size: 13px; }
.admin-activity-section { margin: 0 0 18px; padding-top: 17px; border-top: 1px solid #e7e9e6; }
.admin-activity-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; font-size: 14px; }
.admin-section-count { min-width: 22px; padding: 3px 7px; border-radius: 99px; background: #e8eff0; color: #315f66; font-size: 11px; text-align: center; }
.admin-activity-note { margin: 0 0 12px; color: #697571; font-size: 12px; line-height: 1.5; }
.admin-friend-list { display: grid; gap: 7px; }
.admin-friend { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; border: 1px solid #e5e8e5; border-radius: 8px; background: #f8faf8; }
.admin-friend > span:last-child { min-width: 0; }
.admin-friend strong, .admin-friend small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-friend strong { font-size: 12px; }
.admin-friend small { margin-top: 3px; color: #77817d; font: 10px ui-monospace,SFMono-Regular,Consolas,monospace; }
.admin-history-list { display: grid; gap: 8px; }
.admin-history-list .admin-message { margin: 0; }
.admin-history-jump { min-height: 38px; margin: 0 0 16px; }
.admin-load-more { width: 100%; min-height: 42px; margin-top: 10px; }
.admin-reset-form, .admin-access-form, .admin-notice-form, .admin-role-form { padding: 15px; border: 1px solid #e2ddd3; border-radius: 8px; background: #fbf8f1; }
.admin-role-form { margin-bottom: 11px; border-color: #d7d9eb; background: #f7f7fd; }
.admin-role-form h4 { margin: 0 0 5px; font-size: 13px; }
.admin-role-form p { margin: 0 0 12px; color: #737873; font-size: 11px; line-height: 1.5; }
.admin-role-form label { display: block; margin-bottom: 10px; }
.admin-role-form select { display: block; width: 100%; margin-top: 6px; }
.display-role-badge { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 5px; vertical-align: middle; font-size: 10px; font-weight: 800; line-height: 1.3; letter-spacing: .02em; white-space: nowrap; }
.display-role-pro { color: #215d78; background: #dceef6; }
.display-role-ultra { color: #713bab; background: #f0e5fc; }
body.theme-dark .display-role-pro { color: #bce9fa; background: #254658; }
body.theme-dark .display-role-ultra { color: #ebd4ff; background: #49345f; }
body.theme-dark .admin-role-form { background: #282737; border-color: #46435b; }
.admin-notice-form { margin-bottom: 11px; border-color: #c8dde1; background: #f3f9fa; }
.admin-access-form { margin-bottom: 11px; border-color: #e5caca; background: #fff7f7; }
.admin-access-form.is-suspended { border-color: #c9dfd1; background: #f3faf5; }
.admin-reset-form h4, .admin-access-form h4, .admin-notice-form h4 { margin: 0 0 5px; font-size: 13px; }
.admin-reset-form > p:not(.form-notice), .admin-access-form > p:not(.form-notice), .admin-notice-form > p:not(.form-notice) { margin: 0 0 13px; color: #737873; font-size: 11px; line-height: 1.5; }
.admin-reset-form label, .admin-access-form label, .admin-notice-form label { margin-bottom: 9px; }
.admin-reset-form .form-notice, .admin-access-form .form-notice, .admin-notice-form .form-notice { margin: 5px 0 9px; }
.admin-notice-form textarea { display: block; width: 100%; min-height: 82px; margin-top: 7px; padding: 11px 12px; resize: vertical; border: 1px solid #d6dedc; border-radius: 8px; background: #fff; color: #29322f; font: inherit; line-height: 1.45; outline: 0; }
.admin-notice-form textarea:focus { border-color: #17697a; box-shadow: 0 0 0 3px #dbecef; }
.system-button { min-height: 40px; padding: 0 14px; border: 1px solid #17697a; border-radius: 7px; background: #17697a; color: #fff; font-size: 12px; font-weight: 750; }
.system-button:hover { background: #105364; }
.danger-button, .restore-button { min-height: 40px; padding: 0 14px; border-radius: 7px; font-size: 12px; font-weight: 750; }
.danger-button { border: 1px solid #a94747; background: #a94747; color: #fff; }
.danger-button:hover { background: #913838; }
.restore-button { border: 1px solid #34724d; background: #34724d; color: #fff; }
.restore-button:hover { background: #285f3d; }
.admin-protected-note { margin: 0; padding: 13px 15px; border: 1px solid #d9dedb; border-radius: 8px; background: #f5f7f5; color: #68716e; font-size: 11px; line-height: 1.55; }
.admin-result-note { margin: 0 0 10px; color: #737b78; font-size: 11px; }
.admin-message-list { height: calc(100% - 90px); min-height: 300px; overflow: auto; padding-right: 5px; }
.admin-message { padding: 14px 15px; margin-bottom: 8px; border: 1px solid #dedfdb; border-radius: 8px; background: #fafbf9; }
.admin-message header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.admin-message header strong { font-size: 12px; }
.admin-message header span { flex: none; color: #78807d; font-size: 10px; }
.admin-message > p { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #303735; font-size: 13px; line-height: 1.55; }
.admin-attachments { display: grid; gap: 7px; margin-top: 10px; }
.admin-shared-contact { display: block; margin-top: 9px; color: #68716e; }
.admin-privacy-note { flex: none; margin: 13px 0 0; padding: 10px 12px; border-radius: 7px; background: #f2f0e9; color: #646660; font-size: 11px; line-height: 1.45; }

body.theme-dark .composer-tool, body.theme-dark .attachment-chip, body.theme-dark .file-attachment, body.theme-dark .contact-card { background: #202624; color: #e4e9e7; border-color: #3d4643; }
body.theme-dark .composer-wrap.dragging { background: #1d3033; box-shadow: inset 0 0 0 2px #68aab6; }
body.theme-dark .composer-tool:hover, body.theme-dark .contact-choice:hover { background: #28312f; }
body.theme-dark .emoji-picker { background: #202624; border-color: #414947; box-shadow: 0 14px 40px #0007; }
body.theme-dark .emoji-picker button:hover, body.theme-dark .attachment-chip button { background: #303936; }
body.theme-dark .message-text a { color: #80c4d0; }
body.theme-dark .message-more { color: #b7c0bd; }
body.theme-dark .message-more:hover { background: #313936; }
body.theme-dark .message-receipt { color: #aab3b0; }
body.theme-dark .message-reply, body.theme-dark .reply-preview { background: #253332; color: #e2e8e6; }
body.theme-dark .message-reply strong, body.theme-dark .reply-preview strong { color: #8fc8d1; }
body.theme-dark .message-reply span, body.theme-dark .reply-preview small { color: #b4bdb9; }
body.theme-dark .announced-message .message-body { border-color: #6a5b31; background: #2b2921; }
body.theme-dark .announcement-badge { background: #4b4022; color: #efd68a; }
body.theme-dark .group-announcement { border-color: #5f522e; background: #2c2920; color: #eee6ce; }
body.theme-dark .group-announcement small { color: #c4b99b; }
body.theme-dark .group-announcement button { border-color: #6b5d35; background: #23251f; color: #ead99f; }
body.theme-dark .message-action-button { background: #202624; border-color: #3b4240; color: #e4e9e7; }
body.theme-dark .message-action-button:hover { background: #28302d; }
body.theme-dark .message-action-button > span:first-child { background: #303936; }
body.theme-dark .message-action-button small { color: #adb5b2; }
body.theme-dark .message-action-button.danger-action { border-color: #5b3939; color: #f1a1a1; }
body.theme-dark .message-action-button.danger-action > span:first-child { background: #402a2a; }
body.theme-dark .media-attachment { border-color: #3c4441; background: #111; }
body.theme-dark .file-attachment > span:first-child { background: #28454a; color: #9dd1d8; }
body.theme-dark .contact-card button { background: #181d1c; color: #a9d5db; border-color: #46504d; }
body.theme-dark .conversation-notice { border-color: #573b3b; background: #2e2020; color: #f0adad; }
body.theme-dark .conversation-notice span { color: #d59b9b; }
body.theme-dark .danger-toggle strong { color: #ef9a9a; }
body.theme-dark .admin-metric, body.theme-dark .admin-list, body.theme-dark .admin-message { background: #202624; border-color: #3b4240; }
body.theme-dark .admin-metric strong, body.theme-dark .admin-tab.active { color: #d9ecee; }
body.theme-dark .admin-tabs, body.theme-dark .admin-account-layout, body.theme-dark .admin-list, body.theme-dark .admin-detail-heading { border-color: #3b4240; }
body.theme-dark .admin-user-row:hover { background: #29312e; }
body.theme-dark .admin-user-row.active { background: #243a3e; }
body.theme-dark .admin-detail { background: #1d2221; }
body.theme-dark .admin-facts > div { border-color: #343a38; }
body.theme-dark .admin-activity-section { border-color: #343a38; }
body.theme-dark .admin-profile-bio, body.theme-dark .admin-activity-note { color: #b5c2bd; }
body.theme-dark .admin-friend { border-color: #3b4440; background: #242b28; }
body.theme-dark .admin-section-count { background: #263d42; color: #b4dbe1; }
body.theme-dark .admin-facts dd, body.theme-dark .admin-message > p { color: #e1e7e5; }
body.theme-dark .admin-reset-form { background: #2a281f; border-color: #4d4939; }
body.theme-dark .admin-access-form { background: #2d2222; border-color: #5a3939; }
body.theme-dark .admin-access-form.is-suspended { background: #202d25; border-color: #365340; }
body.theme-dark .admin-notice-form { background: #1e2c2f; border-color: #355057; }
body.theme-dark .admin-notice-form textarea { background: #182322; border-color: #3d4d4a; color: #e1e7e5; }
body.theme-dark .admin-protected-note { background: #232927; border-color: #3c4542; color: #b9c1be; }
body.theme-dark .system-message p { border-color: #35545a; background: #213437; }
body.theme-dark .admin-privacy-note { background: #2b2a24; color: #bdbbb3; }

@media (max-width: 720px) {
  .app.chat-open .chat-panel { animation: slideFromRight .27s cubic-bezier(.2,.75,.25,1) both; }
  .conversation:hover, .friend-row:hover { transform: none; }
  .chat-header { gap: 8px; }
  .chat-actions { gap: 4px; }
  .chat-actions .call-button { min-width: 43px; padding: 0 7px; }
  .composer-toolbar { margin-right: -2px; }
  .composer-tool { min-height: 34px; }
  .emoji-picker { left: 10px; }
  .conversation-notice { align-items: flex-start; flex-direction: column; gap: 3px; }
  .admin-card { width: 100%; height: 96vh; padding: 18px 14px; }
  .admin-summary { grid-template-columns: repeat(2, 1fr); }
  .admin-metric:last-child { grid-column: 1 / -1; }
  .admin-account-layout { grid-template-columns: 1fr; height: auto; max-height: calc(96vh - 330px); overflow: auto; }
  .admin-list { max-height: 220px; border-right: 0; border-bottom: 1px solid #dedfdb; }
  .admin-detail { overflow: visible; }
  .admin-facts { grid-template-columns: 1fr; }
  .admin-message-list { height: calc(96vh - 355px); }
  .admin-message header { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
  button:not(:disabled):hover, button:not(:disabled):active, .conversation:hover, .friend-row:hover { transform: none; }
}

/* Phone and tablet ergonomics */
html, body { width: 100%; min-height: 100%; overscroll-behavior: none; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, .conversation, .friend-row, .request-row, .result-row { touch-action: manipulation; }
.app, .call-screen { height: var(--app-height, 100vh); }
.auth-view { min-height: 100vh; min-height: 100dvh; }
.sidebar, .chat-panel, .side-view, .conversation-list, .message-feed { min-height: 0; }
.message-feed, .side-view, .modal-card, .admin-list, .admin-detail, .admin-message-list { -webkit-overflow-scrolling: touch; }

@media (pointer: coarse) {
  .icon-button, .quiet-button, .soft-button, .close-button, .back-button, .call-button, .composer-tool, .admin-tab, .row-action, .mini-actions button { min-width: 44px; min-height: 44px; }
  .message-more { width: 38px; height: 38px; margin-block: -10px -8px; opacity: 1; }
  .tab { min-height: 48px; }
  .conversation, .friend-row, .request-row, .result-row { min-height: 58px; }
  .toggle-row { min-height: 58px; }
  .toggle-row input { width: 24px; height: 24px; flex: none; }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .app { grid-template-columns: clamp(270px, 34vw, 320px) minmax(0, 1fr); }
  .side-top { padding-inline: 15px; }
  .chat-header { padding-inline: 16px; }
  .message-feed { padding: 24px 20px; }
  .composer-wrap { padding-inline: 16px; }
  .chat-actions, .call-actions { gap: 5px; }
  .call-button { padding-inline: 11px; }
  .message-body { max-width: 84%; }
  .modal-card { max-height: min(780px, 92dvh); }
  .admin-card { width: min(960px, 96vw); }
  .admin-summary { grid-template-columns: repeat(3, 1fr); }
  .admin-metric:nth-child(4), .admin-metric:nth-child(5) { grid-column: auto; }
}

@media (max-width: 720px) {
  html, body { height: var(--app-height, 100vh); overflow: hidden; }
  body { position: relative; }
  input, textarea, select { font-size: 16px; }

  .app, .chat-panel { height: var(--app-height, 100vh); max-height: var(--app-height, 100vh); }

  .auth-view {
    display: block;
    overflow-y: auto;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  }
  .auth-card { width: min(460px, 100%); min-height: 100%; padding: 28px 4px; }
  .mobile-brand { margin-bottom: clamp(30px, 8vh, 58px) !important; }
  .auth-card h1 { font-size: 28px; }
  .auth-card > p { margin-bottom: 24px; }
  .auth-card input, .auth-card .wide { min-height: 52px; }
  .fine-print { max-width: 390px; margin-inline: auto !important; line-height: 1.55; }

  .app { width: 100%; max-width: none; }
  .sidebar, .chat-panel { width: 100%; min-width: 0; }
  .side-top {
    height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 15px 0;
  }
  .side-top .icon-button { display: grid; place-items: center; }
  .main-tabs { height: 52px; margin: 0 12px 12px; }
  .tab { min-height: 52px; font-size: 14px; }
  .side-view { padding: 0 8px; }
  .section-head { padding: 5px 8px 10px; }
  .section-head h2 { font-size: 13px; }
  .conversation, .friend-row, .request-row { padding: 11px 10px; border-radius: 10px; }
  .conversation { min-height: 68px; }
  .conversation-copy strong, .row-copy strong { font-size: 15px; }
  .conversation-copy small, .row-copy small { font-size: 12px; }
  .account-bar {
    min-height: calc(72px + env(safe-area-inset-bottom));
    margin-top: 8px;
    padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  }
  .account-bar strong { max-width: 42vw; font-size: 14px; }
  .account-bar #my-address-short { font-size: 10px; }
  .quiet-button { padding-inline: 8px; }

  .chat-header {
    height: calc(66px + env(safe-area-inset-top));
    flex: none;
    padding: env(safe-area-inset-top) 8px 0;
    gap: 7px;
  }
  .back-button { width: 44px; height: 44px; flex: none; padding: 0; font-size: 32px; }
  .chat-header > .avatar { width: 36px; height: 36px; }
  .chat-title { flex: 1; }
  .chat-title strong { font-size: 15px; }
  .chat-title small { max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-actions { flex: none; gap: 3px; }
  .call-actions { gap: 3px; }
  .chat-actions .call-button { min-width: 42px; width: 42px; height: 42px; padding: 0; font-size: 0; }
  #audio-call::before { content: "☎"; font-size: 18px; }
  #video-call::before { content: "▣"; font-size: 17px; }
  #conversation-options::before { content: "•••"; font-size: 15px; letter-spacing: 1px; }

  .message-feed { min-height: 0; flex: 1 1 0; padding: 18px 12px; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; }
  .group-announcement { padding-inline: 12px; }
  .empty-state { margin-top: 11vh; padding-inline: 18px; }
  .empty-state h1 { font-size: 19px; }
  .message { gap: 8px; margin-bottom: 16px; }
  .message > .avatar { width: 34px; height: 34px; font-size: 11px; }
  .message-body { max-width: 84%; }
  .message p { padding: 10px 12px; font-size: 15px; }
  .message-meta strong { font-size: 12px; }
  .media-attachment, .media-attachment img, img.media-attachment { max-height: 260px; }
  .file-attachment, .contact-card { min-width: 0; width: min(100%, 310px); }

  .composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 5;
    max-height: min(46vh, 360px);
    max-height: min(46dvh, 360px);
    flex: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 8px calc(9px + env(safe-area-inset-bottom));
    background: #fff;
  }
  .composer-toolbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    margin: 0 0 7px;
    overflow: visible;
  }
  .composer-tool { min-width: 0; min-height: 38px; padding: 0 4px; font-size: 11px; white-space: nowrap; }
  .composer { gap: 7px; padding: 5px 5px 5px 11px; border-radius: 10px; }
  .composer textarea { min-height: 42px; max-height: 104px; padding: 10px 0 5px; resize: none; font-size: 16px; }
  .send-button { min-width: 66px; height: 42px; }
  .emoji-picker { right: 8px; bottom: calc(116px + env(safe-area-inset-bottom)); left: 8px; width: auto; grid-template-columns: repeat(7, 1fr); }
  .emoji-picker button { width: 100%; }
  .attachment-preview { margin-bottom: 7px; }
  .attachment-chip { min-width: 142px; }

  .modal-layer { align-items: end; padding: 0; }
  .modal-card {
    width: 100%;
    max-height: min(90vh, 90dvh);
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 18px 18px 0 0;
  }
  .modal-head { position: sticky; top: -20px; z-index: 3; margin: -20px -16px 18px; padding: 20px 16px 12px; background: inherit; border-bottom: 1px solid #eceeeb; }
  .modal-head h2 { font-size: 21px; }
  .close-button { width: 44px; height: 44px; flex: none; }
  .settings-card, .admin-card {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .address-box { align-items: stretch; flex-direction: column; }
  .address-box code { padding: 5px 2px; font-size: 14px; overflow-wrap: anywhere; }
  .address-box .soft-button { width: 100%; }
  .toggle-row, .setting-action { padding-block: 12px; }
  .setting-action .soft-button { flex: none; }
  .search-row { grid-template-columns: 1fr; }
  .search-row .primary { min-height: 48px; }
  .check-list { max-height: 36dvh; }

  .admin-card { display: block; overflow-y: auto; padding: 20px 14px calc(18px + env(safe-area-inset-bottom)); }
  .admin-head { margin: -20px -14px 14px; padding-inline: 14px; }
  .admin-summary { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
  .admin-metric { min-width: 118px; scroll-snap-align: start; }
  .admin-metric:last-child { grid-column: auto; }
  .admin-tabs { position: sticky; top: 72px; z-index: 2; margin-top: 12px; background: inherit; }
  .admin-tab { flex: none; padding-inline: 7px; }
  .admin-view { min-height: auto; padding-top: 13px; }
  .admin-toolbar { align-items: stretch; }
  .admin-toolbar > .soft-button { min-height: 48px; }
  .admin-account-layout { height: auto; min-height: 0; max-height: none; grid-template-columns: 1fr; overflow: visible; }
  .admin-list { max-height: 250px; border-right: 0; border-bottom: 1px solid #dedfdb; }
  .admin-detail { overflow: visible; padding: 17px 14px; }
  .admin-facts { grid-template-columns: 1fr; }
  .admin-message-list { height: auto; min-height: 180px; overflow: visible; }
  .admin-message header { align-items: flex-start; flex-direction: column; gap: 4px; }
  .admin-privacy-note { margin-bottom: 5px; }

  .incoming-card { width: calc(100% - 28px); padding: 28px 20px calc(26px + env(safe-area-inset-bottom)); }
  .call-screen > header { height: calc(66px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; }
  .video-stage { margin: 0 8px; }
  .local-video { right: 10px; bottom: 10px; width: 104px !important; height: 138px !important; }
  .call-controls { height: calc(82px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .call-controls button { width: 56px; height: 56px; }
  .toast { bottom: calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .chat-header > .avatar { display: none; }
  .chat-title small { max-width: 30vw; }
  .composer-tool { font-size: 10px; }
  .admin-toolbar { flex-direction: column; }
  .admin-toolbar > .soft-button { width: 100%; }
}

@media (max-width: 350px) {
  .brand { font-size: 20px; }
  .account-bar { gap: 7px; padding-inline: 10px; }
  .account-bar > .avatar { width: 36px; height: 36px; }
  .chat-title small { display: none; }
  .composer-toolbar { grid-template-columns: repeat(3, 1fr); }
  .composer-tool { min-height: 36px; }
  .send-button { min-width: 58px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .auth-card { padding-block: 18px; }
  .mobile-brand { margin-bottom: 18px !important; }
  .call-screen > header { height: 52px; }
  .call-controls { height: 64px; }
  .local-video { width: 120px !important; height: 82px !important; }
  .modal-card { max-height: 96dvh; }
}

/* Public release number */
.auth-language-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.auth-language-picker select {
  width: auto;
  min-width: 94px;
  height: 35px;
  margin: 0;
  padding: 0 7px;
  font-size: 13px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-icon { display: block; flex: 0 0 auto; border-radius: 8px; }

/* A visible message menu button for phones and tablets */
@media (max-width: 1100px) {
  .message-meta {
    align-items: center;
  }

  .message-more {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    margin: -8px -5px -8px 1px;
    border: 1px solid #d8ddda;
    background: #f0f3f1;
    color: #505b56;
    font-size: 14px;
    opacity: 1;
  }

  .message-more:active {
    background: #dfe8e3;
    transform: scale(.94);
  }

  body.theme-dark .message-more {
    border-color: #444e49;
    background: #2c3430;
    color: #d0d8d4;
  }

  body.theme-dark .message-more:active {
    background: #39443e;
  }
}

/* Familiar call controls */
.header-action-icon,
.control-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.call-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.call-button::before { display: none !important; content: none !important; }
.header-action-icon { width: 18px; height: 18px; }

.incoming-help {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.incoming-actions { gap: 38px; }
.incoming-action {
  width: 82px;
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #3c4542;
  font-size: 12px;
  font-weight: 700;
}
.incoming-action-circle {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 7px 20px #16201c24;
  transition: transform .16s ease, filter .16s ease;
}
.incoming-action:hover .incoming-action-circle { transform: translateY(-2px); filter: brightness(1.05); }
.incoming-action:active .incoming-action-circle { transform: scale(.94); }
.incoming-action.decline { background: transparent; color: #834444; }
.incoming-action.decline .incoming-action-circle { background: #d84e4e; }
.incoming-action.accept { background: transparent; color: #2e6847; }
.incoming-action.accept .incoming-action-circle { background: #2f9b62; }
.incoming-action.decline .control-icon { transform: rotate(135deg); }

.call-controls {
  height: 112px;
  align-items: flex-start;
  gap: clamp(5px, 2vw, 18px);
  padding-top: 13px;
}
.call-controls .call-control {
  width: 76px;
  height: auto;
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  color: #fff;
  font-size: 11px;
  font-weight: 650;
}
.control-circle {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff24;
  color: #fff;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}
.call-control:hover .control-circle { background: #ffffff35; transform: translateY(-1px); }
.call-control:active .control-circle { transform: scale(.93); }
.call-control.off .control-circle { background: #fff; color: #283631; }
.call-control.hangup .control-circle { background: #d84e4e; color: #fff; }
.call-control.hangup .control-icon { transform: rotate(135deg); }
.call-control.hangup:hover .control-circle { background: #e25959; }
.control-label { white-space: nowrap; color: #e4eae7; }
.icon-off { display: none; }
.call-control.off .icon-on { display: none; }
.call-control.off .icon-off { display: block; }

body.theme-dark .incoming-action { color: #e7ecea; }
body.theme-dark .incoming-action.decline { color: #f2abab; }
body.theme-dark .incoming-action.accept { color: #9fd7b7; }

@media (max-width: 720px) {
  .chat-actions .call-button {
    min-width: 42px;
    width: 42px;
    height: 42px;
    padding: 0;
  }
  .chat-actions .call-button > span { display: none; }
  .chat-actions .header-action-icon { width: 20px; height: 20px; }
  #conversation-options { font-size: 0; }
  #conversation-options::after { content: '•••'; font-size: 15px; letter-spacing: 1px; }
  .call-controls {
    height: calc(105px + env(safe-area-inset-bottom));
    padding: 12px 4px env(safe-area-inset-bottom);
  }
  .call-controls .call-control { width: 70px; height: auto; }
  .control-circle { width: 54px; height: 54px; }
}

@media (max-width: 350px) {
  .call-controls .call-control { width: 64px; }
  .control-circle { width: 50px; height: 50px; }
  .control-label { font-size: 10px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .call-controls { height: 70px; flex-direction: row; align-items: center; padding: 4px 0; }
  .call-controls .call-control { width: 64px; display: flex; justify-content: center; }
  .control-circle { width: 46px; height: 46px; }
  .control-label { display: none; }
}

/* V1.05 chess board */
.game-screen {
  background:
    radial-gradient(circle at 50% -20%, #fff 0, transparent 42%),
    linear-gradient(155deg, #f5f1e9 0%, #e8eee9 100%);
}
.game-screen-header,
.game-footer {
  border-color: #d9d6ce;
  background: rgba(255, 255, 255, .88);
}
.game-player-strip { width: min(590px, 100%); }
.game-player {
  position: relative;
  min-height: 58px;
  padding: 10px 13px;
  border: 1px solid #deddd7;
  border-radius: 16px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 8px 24px rgba(48, 53, 48, .07);
}
.game-player.active {
  border-color: #2f6f55;
  box-shadow: 0 0 0 2px rgba(47, 111, 85, .13), 0 9px 26px rgba(48, 53, 48, .1);
}
.game-player.active::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #35a36c;
  box-shadow: 0 0 0 3px rgba(53, 163, 108, .13);
}
.game-player:nth-child(2).active::before { right: auto; left: 8px; }
.game-player.white-side::after,
.game-player.black-side::after {
  content: '';
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #8b8479;
}
.game-player.white-side::after { background: #f7f3e9; }
.game-player.black-side::after { background: #303534; box-shadow: 0 0 0 1px #111; }
.game-status {
  width: fit-content;
  min-height: 34px;
  margin: 0 auto 12px;
  padding: 7px 15px;
  border-radius: 999px;
  background: #fff;
  color: #293c33;
  box-shadow: 0 5px 18px rgba(52, 54, 49, .08);
  font-size: 15px;
}
.game-board.chess-board {
  width: min(570px, 100%);
  aspect-ratio: 1;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  flex: none;
  overflow: hidden;
  border: 6px solid #5f4633;
  border-radius: 14px;
  background: #5f4633;
  box-shadow: 0 22px 50px rgba(51, 38, 28, .28), 0 3px 9px rgba(51, 38, 28, .25);
}
.chess-square {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  text-shadow: none;
  transition: filter .14s ease, transform .12s ease, box-shadow .14s ease;
}
.chess-square.light { background: #f0d9b5; }
.chess-square.dark { background: #b58863; }
.chess-piece {
  position: absolute;
  inset: 7%;
  z-index: 2;
  width: 86%;
  height: 86%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 3px 1px rgba(35, 25, 18, .24));
  transition: transform .16s cubic-bezier(.2, .8, .2, 1);
}
.chess-piece-shape {
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chess-piece-shape line { fill: none; }
.white-piece .chess-piece-shape { fill: #faf7ed; stroke: #343331; }
.black-piece .chess-piece-shape { fill: #303331; stroke: #101211; }
.black-piece .knight-eye { fill: #d8c49e; stroke: none; }
.white-piece .knight-eye { fill: #343331; stroke: none; }
.chess-square:enabled:hover .chess-piece { transform: translateY(-2px); }
.chess-square.last-move::after {
  inset: 0;
  z-index: 0;
  border-radius: 0;
  background: rgba(232, 202, 62, .42);
}
.chess-square.selected::before {
  inset: 4px;
  z-index: 3;
  border: 4px solid #fff077;
  border-radius: 7px;
  box-shadow: inset 0 0 0 2px rgba(72, 60, 17, .5), 0 0 0 1px rgba(72, 60, 17, .4);
}
.square-coordinate {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  font: 800 clamp(8px, 1.4vw, 11px)/1 Manrope, sans-serif;
  text-transform: uppercase;
  text-shadow: none;
}
.rank-coordinate { top: 4px; left: 4px; }
.file-coordinate { right: 4px; bottom: 4px; }
.chess-square.light .square-coordinate { color: #946c4c; }
.chess-square.dark .square-coordinate { color: #f0d9b5; }

body.theme-dark .game-screen {
  background: radial-gradient(circle at 50% -20%, #35443c 0, transparent 42%), linear-gradient(155deg, #202b26, #17201c);
}
body.theme-dark .game-player,
body.theme-dark .game-status { background: #26342d; color: #edf3ef; border-color: #46544d; }
body.theme-dark .game-screen-header,
body.theme-dark .game-footer { background: rgba(27, 37, 32, .9); border-color: #465049; }

/* V1.05 stable mobile chat scrolling */
@media (max-width: 720px) {
  .app.chat-open .chat-panel {
    height: var(--app-height, 100vh);
    min-height: 0;
    overflow: hidden;
  }
  .message-feed {
    height: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .composer-wrap {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
    padding: 8px 8px calc(9px + env(safe-area-inset-bottom));
  }
  .composer-toolbar {
    display: flex;
    grid-template-columns: none;
    gap: 6px;
    margin: 0 0 7px;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .composer-toolbar::-webkit-scrollbar { display: none; }
  .composer-tool {
    min-width: 64px;
    min-height: 38px;
    flex: 0 0 auto;
    padding: 0 9px;
    font-size: 11px;
  }
  .composer-toolbar .game-tool { margin-left: 0; }
  .attachment-preview {
    max-height: 48px;
    margin-bottom: 7px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .attachment-chip { min-width: 142px; height: 42px; }
  .media-attachment,
  .media-attachment img,
  img.media-attachment,
  video.media-attachment {
    max-width: 100%;
    max-height: min(42vh, 280px);
    max-height: min(42dvh, 280px);
    object-fit: contain;
  }
  .game-board.chess-board {
    width: min(570px, 100%);
    border-width: 4px;
    border-radius: 10px;
  }
  .game-player { min-height: 50px; }
}

@media (max-width: 350px) {
  .composer-toolbar { display: flex; grid-template-columns: none; }
}

/* V1.06 chat navigation */
.chat-search-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  font-size: 27px;
  line-height: 1;
}
.chat-search {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 9px 20px;
  border-bottom: 1px solid #dfe4e0;
  background: #fff;
}
.chat-search label { margin: 0; white-space: nowrap; font-size: 12px; }
.chat-search input {
  min-width: 0;
  height: 38px;
  flex: 1;
  margin: 0;
  border-radius: 7px;
}
.chat-search > span { min-width: 72px; color: #68736e; font-size: 11px; text-align: center; }
.chat-search button {
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid #d4dad6;
  border-radius: 7px;
  background: #f8faf8;
  color: #31584e;
  font-size: 20px;
}
.chat-search button:hover { background: #eaf2ee; }
.message.search-match .message-body {
  border-radius: 10px;
  box-shadow: 0 0 0 2px #e4bd54;
}
.message.search-current .message-body {
  box-shadow: 0 0 0 3px #b67324, 0 7px 20px #754d2430;
}
body.theme-dark .chat-search { background: #1f2c25; border-color: #34483e; }
body.theme-dark .chat-search button { background: #293b31; color: #dce9e2; border-color: #435a4d; }
@media (max-width: 720px) {
  .chat-search-toggle { width: 38px; min-width: 38px; height: 38px; font-size: 25px; }
  .chat-search { gap: 5px; padding: 7px 8px; }
  .chat-search label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .chat-search > span { min-width: 59px; font-size: 10px; }
  .chat-search button { width: 31px; height: 34px; font-size: 18px; }
  .chat-search input { height: 36px; padding: 0 8px; }
}

/* V1.07 reporting */
.report-person-button { width: 100%; margin-top: 14px; color: #943c3c; background: #faf0f0; }
#report-details {
  display: block;
  width: 100%;
  min-height: 110px;
  margin-top: 7px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid #d6dedc;
  border-radius: 8px;
  background: #fff;
  color: #29322f;
  font: inherit;
}
#admin-reports-list .admin-message { margin-bottom: 10px; }
#admin-reports-list .soft-button { margin-top: 10px; }
body.theme-dark #report-details { background: #182322; border-color: #3d4d4a; color: #e1e7e5; }

.connection-banner {
  flex: none;
  padding: 9px 15px;
  border-bottom: 1px solid #dfc989;
  background: #fff5d8;
  color: #645018;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}
body.theme-dark .connection-banner { border-color: #695929; background: #39321f; color: #f0daa2; }

/* V1.08 profile and appearance controls */
.avatar { position: relative; overflow: hidden; }
.avatar.has-icon { font-size: 22px; }
.avatar.small.has-icon { font-size: 19px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profile-editor, .friend-profile-card { display: flex; align-items: center; gap: 13px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf9; }
.profile-editor { margin: 10px 0 16px; }
.profile-preview { width: 72px; height: 72px; font-size: 22px; }
.profile-editor > div, .friend-profile-card > span:last-child { min-width: 0; flex: 1; }
.profile-editor strong, .friend-profile-card strong { display: block; font-size: 14px; }
.profile-editor #settings-username .developer-title-badge { display: table; width: fit-content; max-width: 100%; margin: 8px 0 0; font-size: 11px; line-height: 1.3; white-space: normal; overflow-wrap: break-word; }
.profile-editor small, .friend-profile-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.profile-photo-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.profile-photo-actions button { min-height: 34px; }
.profile-bio-form { margin-bottom: 17px; }
.profile-bio-form label { margin: 0; }
.profile-bio-form textarea { width: 100%; min-height: 76px; margin-top: 7px; padding: 10px 12px; resize: vertical; border: 1px solid #cfd2ce; border-radius: 7px; background: #fff; color: #252928; font: inherit; }
.profile-bio-form > small { display: block; margin: 3px 0 8px; color: var(--muted); text-align: right; }
.friend-profile-card { margin-bottom: 12px; }
body.theme-dark .profile-editor, body.theme-dark .friend-profile-card { background: #26382f; border-color: #3d5448; }
body.theme-dark .profile-bio-form textarea { background: #1a2821; border-color: #3c5146; color: #edf3ef; }

body[data-accent="teal"] { --ui-accent: #17697a; --ui-accent-hover: #105364; --ui-accent-soft: #e2eff1; --ui-accent-ink: #155867; }
body[data-accent="blue"] { --ui-accent: #315fa3; --ui-accent-hover: #264d86; --ui-accent-soft: #e6edf8; --ui-accent-ink: #274e85; }
body[data-accent="purple"] { --ui-accent: #6a55a3; --ui-accent-hover: #554488; --ui-accent-soft: #eeeaf8; --ui-accent-ink: #57438d; }
body[data-accent="rose"] { --ui-accent: #ad4c6b; --ui-accent-hover: #8e3d58; --ui-accent-soft: #f8eaf0; --ui-accent-ink: #913e5a; }
body[data-accent="orange"] { --ui-accent: #ac5725; --ui-accent-hover: #8e441b; --ui-accent-soft: #fbede3; --ui-accent-ink: #87451f; }
body[data-accent="green"] { --ui-accent: #286d54; --ui-accent-hover: #1e5742; --ui-accent-soft: #e4f1e9; --ui-accent-ink: #225e48; }
body[data-accent] { --green: var(--ui-accent); --green-dark: var(--ui-accent-hover); --green-pale: var(--ui-accent-soft); }
body[data-accent] .auth-story, body[data-accent] .primary, body[data-accent] .send-button, body[data-accent] .system-button { background: var(--ui-accent); }
body[data-accent] .primary:hover, body[data-accent] .send-button:hover { background: var(--ui-accent-hover); }
body[data-accent] .brand, body[data-accent] .link-button, body[data-accent] .call-button, body[data-accent] .empty-icon, body[data-accent] .message-reply strong, body[data-accent] .reply-preview strong { color: var(--ui-accent-ink); }
body[data-accent] .avatar, body[data-accent] .system-avatar, body[data-accent] .file-attachment > span:first-child { background: var(--ui-accent-soft); color: var(--ui-accent-ink); }
body[data-accent] .tab.active, body[data-accent] .admin-tab.active { color: var(--ui-accent-ink); border-color: var(--ui-accent); }
body[data-accent] .tab.active { box-shadow: inset 0 -2px var(--ui-accent); }
body[data-accent] .conversation.active, body[data-accent] .admin-user-row.active { background: var(--ui-accent-soft); box-shadow: inset 3px 0 var(--ui-accent); }
body[data-accent] .message.mine p { background: var(--ui-accent-soft); }
body[data-accent] .composer:focus-within, body[data-accent] input:focus, body[data-accent] select:focus, body[data-accent] textarea:focus { border-color: var(--ui-accent); outline-color: var(--ui-accent); }
body[data-accent] .admin-metric strong, body[data-accent] .address-box code { color: var(--ui-accent-ink); }
body.theme-dark[data-accent] { --ui-accent-soft: #304039; --ui-accent-ink: #b7d7cc; }
body.theme-dark[data-accent="blue"] { --ui-accent-soft: #28394f; --ui-accent-ink: #aac8f2; }
body.theme-dark[data-accent="purple"] { --ui-accent-soft: #3b334b; --ui-accent-ink: #cdbcf1; }
body.theme-dark[data-accent="rose"] { --ui-accent-soft: #4a303a; --ui-accent-ink: #efb5c7; }
body.theme-dark[data-accent="orange"] { --ui-accent-soft: #49382c; --ui-accent-ink: #f4c19c; }
body.theme-dark[data-accent="green"] { --ui-accent-soft: #293e32; --ui-accent-ink: #afd9bc; }

body[data-density="compact"] .conversation, body[data-density="compact"] .friend-row { min-height: 51px; padding-block: 5px; }
body[data-density="compact"] .message { margin-bottom: 10px; }
body[data-density="compact"] .message-feed { padding-block: 16px; }
@media (max-width: 720px) { body[data-density="compact"] .conversation, body[data-density="compact"] .friend-row { min-height: 55px; } }

/* iPad portrait, landscape, and a keyboard-reduced visual viewport. */
.drive-shortcut { display: flex; align-items: center; gap: 11px; flex: none; min-height: 62px; margin: 8px 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: inherit; text-align: left; }
.drive-shortcut > span:first-child { font-size: 30px; color: var(--ui-accent, #17697a); }
.drive-shortcut > span:nth-child(2) { flex: 1; font-size: 14px; font-weight: 700; }
.drive-shortcut small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; color: var(--muted); }
.drive-shortcut > span:last-child { font-size: 24px; color: var(--muted); }
.modal-card.drive-card { width: min(940px, 100%); height: min(800px, calc(var(--app-height, 100dvh) - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.drive-card > .modal-head { flex: none; }
.drive-storage { flex: none; padding: 15px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--ui-accent-soft, #e4eff1); }
.drive-storage > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.drive-storage strong { font-size: 15px; }
.drive-storage span { font-size: 13px; color: var(--muted); }
.drive-storage p { margin: 8px 0 0; font-size: 12px; line-height: 1.45; }
.drive-storage progress, .drive-transfer progress { display: block; width: 100%; height: 8px; margin-top: 12px; border: 0; border-radius: 6px; overflow: hidden; appearance: none; background: var(--line); accent-color: var(--ui-accent, #17697a); }
.drive-card progress::-webkit-progress-bar { background: var(--line); border-radius: 6px; }
.drive-card progress::-webkit-progress-value { background: var(--ui-accent, #17697a); border-radius: 6px; }
.drive-card progress::-moz-progress-bar { background: var(--ui-accent, #17697a); border-radius: 6px; }
.drive-toolbar { display: flex; align-items: end; flex: none; gap: 9px; margin-top: 18px; }
.drive-search { flex: 1; min-width: 0; margin: 0; font-size: 12px; }
.drive-search input { margin-top: 6px; height: 44px; }
.drive-toolbar button { min-height: 44px; flex: none; }
.drive-transfer { flex: none; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; padding: 12px 0 0; }
.drive-transfer > span { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.drive-transfer progress { grid-column: 1; margin: 0; }
.drive-transfer button { grid-column: 2; grid-row: 1 / 3; }
.drive-file-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
.drive-file { display: flex; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.drive-file-kind { display: grid; place-items: center; flex: none; width: 46px; height: 50px; border-radius: 8px; background: var(--ui-accent-soft, #e4eff1); color: var(--ui-accent-ink, #155867); font-size: 10px; font-weight: 750; }
.drive-file-copy { flex: 1; min-width: 0; }
.drive-file-name { display: block; overflow-wrap: anywhere; font-size: 14px; }
.drive-file-copy small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.drive-file-actions { display: flex; flex: none; gap: 6px; }
.drive-file-actions .soft-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding-inline: 10px; font-size: 12px; text-decoration: none; }
.drive-file-actions .drive-delete { color: var(--danger); }
.drive-footnote { flex: none; margin: 12px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.drive-confirm-actions { display: flex; justify-content: end; gap: 10px; margin-top: 18px; }
#drive-delete-name { overflow-wrap: anywhere; font-weight: 700; }
#drive-rename-modal, #drive-delete-modal { z-index: 22; }
body.theme-dark .drive-storage { border-color: var(--line); }
#drive-open-plans, #drive-clear-pending { margin-top: 10px; margin-right: 8px; min-height: 44px; }
#subscription-modal { z-index: 23; }
.modal-card.subscription-card { width: min(760px, 100%); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.subscription-current { padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--ui-accent-soft, #e4eff1); }
.subscription-status { display: inline-block; font-size: 12px; font-weight: 700; color: var(--ui-accent-ink, #155867); }
.subscription-current h3 { margin: 8px 0 12px; font-size: 25px; }
.subscription-current p { margin: 8px 0 0; font-size: 13px; line-height: 1.6; }
.subscription-plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.subscription-plans article { position: relative; min-width: 0; padding: 40px 16px 20px; border: 1px solid var(--line); border-radius: 10px; }
.subscription-plans article.is-current { border: 2px solid var(--ui-accent, #17697a); padding: 39px 15px 19px; }
.plan-current-label { position: absolute; top: 14px; left: 16px; font-size: 11px; font-weight: 700; color: var(--ui-accent-ink, #155867); }
.subscription-plans h3 { margin: 0 0 16px; font-size: 16px; }
.subscription-plans strong { font-size: 30px; line-height: 1.2; }
.subscription-plans p { margin: 8px 0; font-size: 12px; color: var(--muted); }
.subscription-plans small { font-size: 12px; }
.subscription-billing-note { font-size: 13px; line-height: 1.7; color: var(--muted); margin: 20px 0; }
.subscription-card button { min-height: 44px; }
.subscription-confirm { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 16px; }
.subscription-confirm p { margin: 0; line-height: 1.6; font-size: 13px; }
.subscription-admin-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subscription-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.subscription-admin-actions button, .subscription-admin-fields select { min-height: 44px; }
.admin-role-form .admin-subscription-period { font-weight: 700; color: var(--ui-accent-ink, #155867); }
@media (max-width: 720px) {
  .subscription-plans { grid-template-columns: 1fr; gap: 10px; }
  .subscription-plans article { padding: 36px 16px 16px; }
  .subscription-plans article.is-current { padding: 35px 15px 15px; }
  .subscription-plans h3 { margin-bottom: 8px; }
  .subscription-admin-fields { grid-template-columns: 1fr; gap: 0; }
  .subscription-confirm .drive-confirm-actions { flex-wrap: wrap; }
  .subscription-confirm .drive-confirm-actions button { flex: 1; }
  .modal-card.drive-card { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .drive-toolbar { flex-wrap: wrap; }
  .drive-search { flex-basis: 100%; }
  .drive-toolbar button { flex: 1; }
  .drive-file { flex-wrap: wrap; }
  .drive-file-copy { flex-basis: calc(100% - 62px); }
  .drive-file-actions { width: 100%; justify-content: end; }
  .drive-storage > div { flex-wrap: wrap; gap: 5px; }
}
@media (max-height: 600px) {
  .modal-card.drive-card { display: block; overflow-y: auto; }
  .drive-file-list { max-height: 320px; min-height: 100px; }
}

@media (max-width: 1366px) {
  .modal-layer {
    top: var(--viewport-top, 0px);
    bottom: auto;
    height: var(--app-height, 100dvh);
    overflow: hidden;
  }
  .modal-card { max-height: 100%; }
  .composer textarea { min-width: 0; }
}

@media (min-width: 721px) and (max-width: 1366px) {
  html, body { height: var(--app-height, 100dvh); overflow: hidden; }
  .auth-view { height: var(--app-height, 100dvh); min-height: 0; overflow-y: auto; }
  .app {
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    grid-template-columns: clamp(248px, 29vw, 300px) minmax(0, 1fr);
  }
  .sidebar, .chat-panel { min-width: 0; }
  .sidebar { padding-left: env(safe-area-inset-left); }
  .side-top { min-height: calc(68px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .main-tabs { flex: 0 0 52px; }
  .tab { min-height: 52px; font-size: 15px; }
  .conversation, .friend-row, .request-row, .result-row { min-height: 68px; padding-block: 12px; }
  body[data-density="compact"] .conversation, body[data-density="compact"] .friend-row { min-height: 58px; }
  .conversation-copy strong, .row-copy strong { font-size: 15px; }
  .account-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat-header {
    min-height: calc(72px + env(safe-area-inset-top));
    height: auto;
    flex: 0 0 auto;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 16px;
    gap: 10px;
  }
  .chat-header > .avatar { width: 36px; height: 36px; flex: none; }
  .chat-title { flex: 1; min-width: 0; }
  .chat-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-actions, .call-actions { gap: 6px; flex: none; }
  .message-feed { flex: 1 1 0; min-height: 0; padding: 24px clamp(16px, 2.5vw, 32px); }
  .message-body { max-width: min(680px, 84%); }
  .message p { font-size: 16px; }
  .message-meta strong { font-size: 13px; }
  .message-meta time { font-size: 11px; }
  .composer-wrap { padding: 10px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) 16px; }
  .composer-toolbar { gap: 7px; padding-bottom: 3px; margin-bottom: 8px; overscroll-behavior-x: contain; }
  .composer-tool { flex: 0 0 auto; padding-inline: 12px; font-size: 13px; }
  .composer { gap: 10px; padding: 7px; }
  .composer textarea { font-size: 16px; min-height: 44px; max-height: 112px; padding: 11px 5px 7px; resize: none; }
  .send-button { min-width: 76px; height: 44px; font-size: 15px; }
  input, textarea, select { font-size: 16px; }
  .icon-button, .quiet-button, .soft-button, .close-button, .call-button,
  .composer-tool, .row-action, .mini-actions button, .admin-tab,
  .message-more, .chat-search button, .group-announcement button,
  .attachment-chip button, .reply-preview button, .contact-card button {
    min-width: 44px;
    min-height: 44px;
  }
  .message-more { width: 44px; height: 44px; opacity: 1; }
  .emoji-picker { width: min(390px, calc(100% - 32px)); right: 16px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .emoji-picker button { width: 100%; min-height: 44px; }
  .media-attachment, .media-attachment img, img.media-attachment, video.media-attachment {
    max-width: 100%;
    max-height: min(48dvh, 440px);
    object-fit: contain;
  }
  .modal-layer {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .modal-card { width: min(640px, 100%); padding: 24px; overscroll-behavior-y: contain; }
  .modal-head {
    position: sticky;
    top: -24px;
    z-index: 4;
    margin: -24px -24px 20px;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--line);
    background: inherit;
  }
  .settings-card { width: min(680px, 100%); }
  .admin-card { width: min(1120px, 100%); height: min(900px, calc(var(--app-height, 100dvh) - 32px)); }
  .admin-account-layout { grid-template-columns: minmax(210px, .9fr) minmax(0, 1.5fr); }
  .admin-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-summary .admin-metric { grid-column: auto; }
  .toggle-row, .setting-action { min-height: 60px; }
  .toggle-row input { width: 24px; height: 24px; flex: none; }
  .call-screen > header { padding-top: env(safe-area-inset-top); }
  .call-controls { padding-bottom: env(safe-area-inset-bottom); }
}

@media (min-width: 721px) and (max-width: 960px) {
  .chat-actions .call-button { width: 44px; padding: 0; }
  .call-button .header-action-icon { width: 21px; height: 21px; }
  .chat-actions .call-button > span { display: none; }
  #conversation-options { font-size: 0; }
  #conversation-options::after { content: '•••'; font-size: 19px; }
  .chat-search { flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
  .chat-search label { flex-basis: 100%; }
  .chat-search input { flex: 1 1 140px; width: 0; }
}

@media (min-width: 721px) and (max-width: 1366px) and (max-height: 600px) {
  .admin-card { display: block; overflow-y: auto; }
  .admin-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-account-layout { height: auto; max-height: none; }
  .admin-list, .admin-detail { max-height: 320px; }
  .admin-message-list { height: auto; min-height: 0; max-height: 320px; }
}

/* Narrow iPad Split View uses the same single-panel navigation as phones. */
@media (max-width: 720px) {
  .settings-card, .admin-card { height: 100%; max-height: 100%; }
}

@media (pointer: coarse) {
  input, textarea, select { font-size: 16px; }
  .message-more, .chat-search button, .emoji-picker button, .send-button { min-width: 44px; min-height: 44px; }
  .message-more { width: 44px; height: 44px; }
  button:not(:disabled):hover, .conversation:hover, .friend-row:hover { transform: none; }
}

/* Stamp messages keep a fixed footprint while images load. */
.message-stamp { display: block; width: 192px; height: 192px; max-width: 100%; object-fit: contain; border-radius: 16px; }
.modal-card.stamp-card { width: min(780px, 100%); height: min(820px, calc(var(--app-height, 100dvh) - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.stamp-card > .modal-head, .stamp-toolbar, .stamp-selection, .stamp-footer { flex: none; }
.stamp-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp-toolbar label { min-width: 0; font-size: 12px; }
.stamp-toolbar input, .stamp-toolbar select { width: 100%; min-height: 44px; margin-top: 6px; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); align-content: start; gap: 10px; flex: 1; min-height: 110px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px; }
.stamp-choice { display: flex; flex-direction: column; align-items: center; width: 100%; min-height: 130px; border: 2px solid transparent; border-radius: 12px; background: transparent; color: inherit; padding: 4px; }
.stamp-choice:hover, .stamp-choice[aria-pressed="true"] { border-color: var(--ui-accent, #17697a); background: var(--ui-accent-soft, #e4eff1); }
.stamp-choice img { width: 96px; height: 96px; }
.stamp-choice span { font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.stamp-remove { display: block; margin: 0 auto; background: transparent; border: 0; min-height: 44px; color: var(--danger); font-size: 12px; }
.stamp-selection { display: flex; align-items: center; gap: 12px; padding: 12px 0; margin-top: 8px; border-top: 1px solid var(--line); }
.stamp-selection img { width: 76px; height: 76px; object-fit: contain; flex: none; }
.stamp-selection > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stamp-selection strong, .stamp-selection small { display: block; }
.stamp-selection small { margin-top: 5px; font-size: 11px; line-height: 1.5; color: var(--muted); }
.stamp-selection button, .stamp-footer button { min-height: 44px; }
.stamp-footer { display: flex; flex-wrap: wrap; gap: 8px; }
.stamp-footer button { flex: 1; font-size: 12px; }
.stamp-create { flex: none; max-height: 35vh; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }
.stamp-create summary { padding: 12px; min-height: 44px; cursor: pointer; font-size: 13px; font-weight: 700; }
.stamp-create form { padding: 0 12px 12px; }
.stamp-create label { display: block; margin-bottom: 10px; font-size: 12px; }
.stamp-create input { display: block; width: 100%; margin-top: 5px; }
.stamp-create p { font-size: 12px; color: var(--muted); }
#chat-background-modal { z-index: 24; }
.wallpaper-preview { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; min-height: 130px; }
.wallpaper-upload-help { margin: 6px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.wallpaper-preview[data-wallpaper^="custom:"] { background-repeat: no-repeat; background-size: cover; background-position: center; }
.message-feed[data-wallpaper^="custom:"] { background-repeat: no-repeat; background-size: cover; background-position: center; background-attachment: local; }
.wallpaper-preview span { align-self: start; padding: 9px 13px; border-radius: 12px; background: #fff; color: #283c39; font-size: 14px; box-shadow: 0 1px 4px #0001; }
.wallpaper-preview span:last-child { align-self: end; background: #dceee8; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="warm"] { background: #faf3e9; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="cool"] { background: #eef5f7; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="dots"] { background: radial-gradient(#c5d1cc 1px, transparent 1px) 0 0 / 20px 20px #f6f7f5; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="lavender"] { background: #eee8f6; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="mint"] { background: #e6f2e9; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="sunset"] { background: linear-gradient(155deg, #fbe6d8, #f5e6ef); }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="grid"] { background: linear-gradient(#b8c8cc33 1px, transparent 1px), linear-gradient(90deg, #b8c8cc33 1px, transparent 1px), #f6f7f5; background-size: 24px 24px; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="night"] { background: radial-gradient(#b5c4e199 1px, transparent 1px) 0 0 / 37px 43px, radial-gradient(#edf4ff77 1px, transparent 1px) 17px 23px / 71px 79px, #25334a; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="ocean"] { background: linear-gradient(155deg, #d8edf3, #e8f7f4 65%, #fff9ec); }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="peach"] { background: linear-gradient(145deg, #ffe7dd, #fff4e8 60%, #fae8f0); }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="forest"] { background: radial-gradient(#80a78a33 1.5px, transparent 2px) 0 0 / 32px 32px, #e6f0e4; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="aurora"] { background: linear-gradient(135deg, #dce7f9, #e4f7ed 35%, #f8e3f5 72%, #f8e9d7); }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="confetti"] { background: radial-gradient(#e5a6bc 2px, transparent 3px) 5px 7px / 49px 43px, radial-gradient(#9ec6ce 2px, transparent 3px) 22px 18px / 59px 53px, #faf4ed; }
:is(.message-feed,.wallpaper-preview)[data-wallpaper="midnight"] { background: radial-gradient(#d7dcff99 1px, transparent 2px) 0 0 / 41px 39px, linear-gradient(150deg, #18253d, #322448); }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="warm"] { background: #29251f; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="cool"] { background: #1c2b31; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="dots"] { background: radial-gradient(#35453d 1px, transparent 1px) 0 0 / 20px 20px #1b2420; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="lavender"] { background: #292438; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="mint"] { background: #1d3029; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="sunset"] { background: linear-gradient(155deg, #3b2a24, #322438); }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="grid"] { background: linear-gradient(#778f8b22 1px, transparent 1px), linear-gradient(90deg, #778f8b22 1px, transparent 1px), #1b2420; background-size: 24px 24px; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="ocean"] { background: linear-gradient(145deg, #183443, #1c3b35); }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="peach"] { background: linear-gradient(145deg, #46312f, #43362b); }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="forest"] { background: radial-gradient(#80a78a33 1.5px, transparent 2px) 0 0 / 32px 32px, #1e3428; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="aurora"] { background: linear-gradient(135deg, #1d304b, #194037 40%, #42304a); }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="confetti"] { background: radial-gradient(#aa658066 2px, transparent 3px) 5px 7px / 49px 43px, radial-gradient(#548d9966 2px, transparent 3px) 22px 18px / 59px 53px, #332c31; }
body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="midnight"] { background: radial-gradient(#d7dcff99 1px, transparent 2px) 0 0 / 41px 39px, linear-gradient(150deg, #18253d, #322448); }
.message-feed[data-wallpaper="midnight"] .message-meta, .message-feed[data-wallpaper="midnight"] .message-meta strong, .message-feed[data-wallpaper="midnight"] .message-receipt { color: #dbe6f6; }
.saved-messages-card { max-height: calc(100dvh - 24px); overflow-y: auto; }
.saved-messages-list { display: grid; gap: 8px; margin: 14px 0; }
.saved-message-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line, #d9ddda); border-radius: 12px; }
.saved-message-row div { min-width: 0; }
.saved-message-row p { margin: 5px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.saved-message-row strong { overflow-wrap: anywhere; }
.saved-message-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 560px) { .saved-message-row { align-items: stretch; flex-direction: column; } .saved-message-actions { flex-wrap: wrap; } }
@media (max-width: 720px) {
  .modal-card.stamp-card { height: 100%; max-height: 100%; width: 100%; }
  .stamp-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; }
  .stamp-choice img { width: 84px; height: 84px; }
  .stamp-selection { gap: 6px; }
  .stamp-selection img { width: 60px; height: 60px; }
  .stamp-selection button { padding-inline: 12px; }
}
@media (max-height: 600px) {
  .modal-card.stamp-card { display: block; overflow-y: auto; }
  .stamp-grid { max-height: 40vh; }
}

body.theme-dark :is(.message-feed,.wallpaper-preview)[data-wallpaper="night"] { background: radial-gradient(#b5c4e199 1px, transparent 1px) 0 0 / 37px 43px, radial-gradient(#edf4ff77 1px, transparent 1px) 17px 23px / 71px 79px, #192539; }
.message-feed[data-wallpaper="night"] .message-meta, .message-feed[data-wallpaper="night"] .message-meta strong, .message-feed[data-wallpaper="night"] .message-receipt { color: #dbe6f6; }

/* Permanent account removal stays separate from reversible account controls. */
.admin-delete-section { margin-top: 20px; padding: 16px; border: 1px solid #c94d4d; border-radius: 10px; background: #fff5f5; }
.admin-delete-section h4 { margin: 0 0 7px; font-size: 14px; }
.admin-delete-section p { line-height: 1.5; font-size: 12px; }
#admin-delete-account-modal { z-index: 30; }
#mfa-modal, #security-data-modal { z-index: 32; }
#mfa-modal code, #mfa-modal pre { display: block; max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; }
#admin-delete-account-modal .modal-card { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
#admin-delete-account-modal p { line-height: 1.6; overflow-wrap: anywhere; }
.delete-account-target { padding: 12px; border-radius: 8px; background: #f8e9e9; color: #8f2525; font-size: 18px; font-weight: 700; }
.delete-account-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.delete-account-actions button, .admin-delete-section button { min-height: 44px; }
body.theme-dark .admin-delete-section { background: #2d2222; border-color: #965050; }
body.theme-dark .delete-account-target { background: #3d2525; color: #ffbcbc; }

/* Mobile pages scroll normally; open conversations keep a bounded chat layout. */
@media (max-width: 1366px) {
  html, body {
    width: 100%;
    height: auto;
    min-height: var(--app-height, 100dvh);
    overflow-x: hidden;
    overflow-y: auto;
  }
  .app {
    position: fixed;
    top: var(--viewport-top, 0px);
    left: 0;
    width: 100%;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    min-height: 0;
  }
  .auth-view {
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    min-height: var(--app-height, 100dvh);
    overflow: visible;
  }
  .auth-card { min-height: 0; }
  .sidebar, .chat-panel { min-height: 0; max-height: 100%; }
  .side-view, .message-feed {
    min-height: 0;
    flex: 1 1 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .composer-wrap {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
    max-height: min(50%, 280px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .modal-layer { min-height: 0; }
  .modal-card { min-height: 0; }
  .settings-card, .admin-card {
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 1366px) {
  .composer-wrap .composer {
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
  .composer textarea { max-height: min(104px, calc(var(--app-height, 100dvh) * .2)); }
  .composer-wrap .emoji-picker {
    position: static;
    width: 100%;
    max-height: 140px;
    margin-bottom: 8px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
}

/* Keep the phone inbox inside the viewport so its active list can scroll. */
@media (max-width: 720px) {
  .app:not(.chat-open):not(.social-mode) {
    position: fixed;
    top: var(--viewport-top, 0px);
    left: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }
  .app:not(.chat-open):not(.social-mode) .sidebar {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .app:not(.chat-open):not(.social-mode) .side-view {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  .app:not(.chat-open):not(.social-mode) #conversation-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  /* Keep file shortcuts available in Chats, but give Friends the extra height. */
  .app:not(.chat-open):not(.social-mode):has(#friends-view:not(.hidden)) .drive-shortcut {
    display: none;
  }
}

/* Sign-in uses the document scrollbar, without a second body scroll container. */
html.auth-screen {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
html.auth-screen body {
  position: static;
  height: auto;
  min-height: 100%;
  overflow: visible;
}
html.auth-screen .auth-view {
  position: static;
  height: auto;
  max-height: none;
  min-height: 100svh;
  overflow: visible;
}
.auth-card .switch-copy { margin: 0 0 18px !important; }
.auth-card #switch-mode { min-height: 44px; padding: 8px 10px; }
@media (max-width: 800px) {
  html.auth-screen .auth-view {
    display: block;
    padding: max(16px, env(safe-area-inset-top)) 18px max(32px, env(safe-area-inset-bottom));
  }
  html.auth-screen .auth-card {
    width: min(460px, 100%);
    min-height: 0;
    margin: 0 auto;
    padding: 12px 4px;
  }
  .auth-card .mobile-brand { margin-bottom: 16px !important; }
  .auth-card .auth-language-picker { margin-bottom: 16px; }
  .auth-card .public-summary { display: none; }
  .auth-card #auth-intro { margin-bottom: 12px; }
}

/* Profile identity is separate from the viewer's own interface theme. */
.profile-style-fields { min-width: 0; margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.plan-profile-choices { margin: 18px 0; }
.plan-profile-choices summary { cursor: pointer; font-weight: 700; }
.plan-profile-table-wrap { max-width: 100%; overflow-x: auto; margin-top: 10px; }
.plan-profile-choices table { width: 100%; min-width: 440px; border-collapse: collapse; font-size: 14px; }
.plan-profile-choices th, .plan-profile-choices td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: center; }
.plan-profile-choices th:first-child { text-align: left; }
.profile-style-fields legend { padding: 0 6px; font-weight: 700; }
.profile-style-fields > p { font-size: 13px; line-height: 1.5; color: var(--muted); }
.profile-style-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-style-controls label { min-width: 0; margin: 0; }
.profile-style-controls select, .profile-style-controls input { width: 100%; min-height: 44px; }
.profile-style-controls :disabled { opacity: .6; }
.public-style-details { margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.public-style-details summary { cursor: pointer; font-weight: 700; }
.public-style-details > .setting-help { margin: 12px 0; }
.public-style-details .profile-style-controls { margin-bottom: 4px; }
.profile-style-surface { display: flex; align-items: center; gap: 16px; min-height: 112px; margin: 12px 0 18px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; overflow-wrap: anywhere; }
.profile-style-surface > div { min-width: 0; }
.profile-style-surface strong { font-size: 19px; }
.profile-style-surface small { display: block; margin-top: 8px; color: var(--muted); white-space: pre-wrap; }
.profile-style-surface, .friend-profile-card { transition: background .25s ease, border-color .25s ease, box-shadow .25s ease; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="ocean"] { background: linear-gradient(120deg,#e0f0f8,#e0f5ec); }
:is(.profile-style-surface,.friend-profile-card)[data-banner="sunset"] { background: linear-gradient(120deg,#ffe8d5,#f7e0ef); }
:is(.profile-style-surface,.friend-profile-card)[data-banner="lavender"] { background: linear-gradient(120deg,#e9e2fb,#e5edfb); }
:is(.profile-style-surface,.friend-profile-card)[data-banner="paper"] { background: repeating-linear-gradient(0deg,transparent 0 23px,#b49c7530 24px 25px),#fff8eb; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="meadow"] { background: radial-gradient(circle at 78% 18%,#fff8c9 0 12%,transparent 40%),linear-gradient(120deg,#daf1d9,#e8f3e2); }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] { background: radial-gradient(circle at 75% 20%,#a2a3ff55,transparent 42%),linear-gradient(120deg,#1f3451,#2b2447); color: #f4f5ff; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="waves"] { background: repeating-radial-gradient(ellipse at 4% 110%,#77b8e23d 0 3px,transparent 4px 27px),linear-gradient(120deg,#e2f3fa,#d9e8f7); }
:is(.profile-style-surface,.friend-profile-card)[data-border="accent"] { border: 2px solid #8b73b9; }
:is(.profile-style-surface,.friend-profile-card)[data-border="shadow"] { box-shadow: 0 10px 28px #293b5740; }
:is(.profile-style-surface,.friend-profile-card)[data-border="glow"] { border-color: #9a7bd1; box-shadow: 0 0 0 3px #9a7bd13b, 0 8px 30px #946ed53d; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="constellation"] { background: radial-gradient(circle at 18px 18px,#8668ce66 1px,transparent 2px) 0 0 / 29px 29px,linear-gradient(125deg,#e7e1ff,#dcf3fa); border-color: #9372c6; }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="ocean"] { background: linear-gradient(120deg,#203847,#203b34); }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="sunset"] { background: linear-gradient(120deg,#433020,#44273e); }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="lavender"] { background: linear-gradient(120deg,#332944,#263148); }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="paper"] { background: repeating-linear-gradient(0deg,transparent 0 23px,#b49c7530 24px 25px),#3c3029; }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="meadow"] { background: radial-gradient(circle at 78% 18%,#b5a65533 0 12%,transparent 40%),linear-gradient(120deg,#20392e,#334436); }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="waves"] { background: repeating-radial-gradient(ellipse at 4% 110%,#77b8e22e 0 3px,transparent 4px 27px),linear-gradient(120deg,#1d3a4c,#26324c); }
body.theme-dark :is(.profile-style-surface,.friend-profile-card)[data-banner="constellation"] { background: radial-gradient(circle at 18px 18px,#af9aeb77 1px,transparent 2px) 0 0 / 29px 29px,linear-gradient(125deg,#302440,#183943); }
.profile-style-surface[data-banner="midnight"] small, .friend-profile-card[data-banner="midnight"] small { color: #d6ddf2; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="violet"] { color: #d7c2ff; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="blue"] { color: #add1ff; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="teal"] { color: #9be8dd; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="rose"] { color: #ffc1d5; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="gold"] { color: #ffe4a0; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="mint"] { color: #a6f2cb; }
:is(.profile-style-surface,.friend-profile-card)[data-banner="midnight"] .styled-name[data-ink="coral"] { color: #ffbfaa; }
.styled-name[data-font="rounded"] { font-family: ui-rounded, 'Trebuchet MS', sans-serif; }
.styled-name[data-font="serif"] { font-family: Georgia, 'Times New Roman', serif; }
.styled-name[data-font="mono"] { font-family: ui-monospace, 'Courier New', monospace; }
.styled-name[data-font="condensed"] { font-family: 'Arial Narrow', 'Roboto Condensed', sans-serif; font-stretch: condensed; letter-spacing: -.04em; }
.styled-name[data-font="handwritten"] { font-family: 'Comic Sans MS', 'Bradley Hand', cursive; letter-spacing: .01em; }
.styled-name[data-ink="violet"] { color: #7141b0; }
.styled-name[data-ink="blue"] { color: #185bb7; }
.styled-name[data-ink="teal"] { color: #08736b; }
.styled-name[data-ink="rose"] { color: #ad3864; }
.styled-name[data-ink="gold"] { color: #855b06; }
.styled-name[data-ink="mint"] { color: #087a63; }
.styled-name[data-ink="coral"] { color: #ad4938; }
body.theme-dark .styled-name[data-ink="violet"] { color: #c5a5ff; }
body.theme-dark .styled-name[data-ink="blue"] { color: #8bbcff; }
body.theme-dark .styled-name[data-ink="teal"] { color: #80d9c6; }
body.theme-dark .styled-name[data-ink="rose"] { color: #f6a1be; }
body.theme-dark .styled-name[data-ink="gold"] { color: #f3d276; }
body.theme-dark .styled-name[data-ink="mint"] { color: #86e4bf; }
body.theme-dark .styled-name[data-ink="coral"] { color: #ffad97; }
.styled-name[data-effect="glow"] { text-shadow: 0 0 12px color-mix(in srgb, currentColor 35%, transparent); }
.styled-name[data-effect="underline"] { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: currentColor; text-underline-offset: 5px; }
.styled-name[data-effect="shimmer"] { animation: profileNameShimmer 3.2s ease-in-out infinite; }
@keyframes profileNameShimmer { 0%,100% { text-shadow: none; } 50% { text-shadow: 0 0 9px currentColor, 0 0 20px color-mix(in srgb, currentColor 45%, transparent); } }
.styled-name[data-effect="aurora"] { text-shadow: -1px 0 #40bcbe66, 1px 0 #ba70da66, 0 0 14px #9970d966; }
.styled-name[data-effect="prism"] { text-decoration: underline; text-decoration-color: #a482dc; text-underline-offset: 5px; text-decoration-thickness: 2px; text-shadow: 1px 1px #43b6bf44; }
.avatar[data-frame="ring"] { outline: 2px solid #8c70b8; outline-offset: 2px; }
.avatar[data-frame="double"] { outline: 4px double #8c70b8; outline-offset: 2px; }
.avatar[data-frame="petal"] { outline: 3px solid #cf81a4; outline-offset: 2px; box-shadow: 0 0 0 6px #cf81a42c; }
.avatar[data-frame="neon"] { outline: 2px solid #55bdb4; outline-offset: 3px; box-shadow: 0 0 0 5px #55bdb42f, 0 0 15px #55bdb488; }
.avatar[data-frame="orbit"] { outline: 2px solid #9370dd; outline-offset: 3px; box-shadow: 0 0 0 6px #61bbb933, 0 0 17px #9270da55; }
.avatar[data-shape="rounded"] { border-radius: 24%; }
.avatar[data-shape="squircle"] { border-radius: 36%; }
.profile-style-surface small[data-title-style="pill"], .friend-profile-card small[data-title-style="pill"] { display: inline-block; padding: 3px 9px; border-radius: 999px; background: #8b73b93d; color: inherit; }
.profile-style-surface small[data-title-style="outlined"], .friend-profile-card small[data-title-style="outlined"] { display: inline-block; padding: 3px 9px; border: 1px solid currentColor; border-radius: 6px; color: inherit; }
.profile-style-surface small[data-title-style="handwritten"], .friend-profile-card small[data-title-style="handwritten"] { font-family: 'Comic Sans MS', 'Bradley Hand', cursive; font-size: 15px; color: inherit; }
.profile-detail-card { margin-top: 10px; padding: 20px; min-height: 100px; }
.profile-detail-card .profile-large { flex: none; }
.community-person-identity.profile-style-surface h3 { margin: 0; }
.community-person-identity.profile-style-surface > div { min-width: 0; }
.display-role-badge { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; text-shadow: none; letter-spacing: normal; }
.display-role-developer { display: inline-flex; align-items: center; color: #56328a; background: linear-gradient(110deg,#eee2ff,#d9f6f4); border: 1px solid #b29bcc; font-size: 10px; font-weight: 800; white-space: nowrap; }
body.theme-dark .display-role-developer { color: #dfccff; background: linear-gradient(110deg,#352346,#173f43); border-color: #9579bc; }
.admin-developer-section { margin: 16px 0; padding: 16px; border: 1px solid #9c7bbe; border-radius: 12px; }
.admin-developer-section h4 { margin: 0 0 8px; }
.admin-developer-section p { font-size: 13px; line-height: 1.6; }
@media (max-width: 380px) { .profile-style-controls { grid-template-columns: 1fr; } }
@keyframes developerBadgeGlow { 0%,100% { box-shadow: 0 0 0 transparent; } 50% { box-shadow: 0 0 10px #a588cc55; } }
.display-role-developer { animation: developerBadgeGlow 5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .display-role-developer, .styled-name[data-effect="shimmer"] { animation: none; } }

/* Chess keeps one board size while browser chrome and status text change. */
.game-board-wrap:has(.chess-board) { min-width: 0; width: 100%; }
.game-board.chess-board { align-self: start; gap: 0; padding: 0; }
.game-board.chess-board .chess-square { margin: 0; padding: 0; border: 0; border-radius: 0; line-height: 1; }
.game-board.chess-board .chess-square:active { transform: none; }
.game-board.chess-board .chess-square:focus-visible { outline: 3px solid #fff077; outline-offset: -3px; z-index: 5; }
.game-board.chess-board .chess-piece { display: block; max-width: 86%; max-height: 86%; }
.game-player > span:last-of-type { min-width: 0; }
.game-player strong { overflow-wrap: anywhere; }
.game-screen-header > div { min-width: 0; }
.game-screen-header small { overflow-wrap: anywhere; }
.game-status { max-width: 100%; overflow-wrap: anywhere; }
@media (pointer: coarse) {
  .chess-square:enabled:hover .chess-piece { transform: none; }
}

/* First-use welcome follows the existing Home interface. */
.beginner-welcome{width:min(460px,calc(100vw - 32px));max-height:calc(100dvh - 40px);overflow-y:auto;margin:auto;padding:28px;border-radius:11px;color:inherit}
.beginner-welcome::backdrop{background:rgb(0 0 0 / .52)}
.beginner-welcome h2{margin:0 0 15px;font-size:24px;line-height:1.25;letter-spacing:-.5px}
.beginner-welcome p{font-size:15px;line-height:1.65;margin:0 0 14px}
.beginner-welcome .setting-help{font-size:13px;margin-bottom:24px}
.beginner-welcome-actions{display:flex;gap:10px;flex-wrap:wrap}
.beginner-welcome-actions button{min-height:44px;padding:11px 18px}
@media(max-width:480px){.beginner-welcome{padding:24px}.beginner-welcome-actions{display:grid;grid-template-columns:minmax(0,1fr) auto}}

.chat-mode-picker{padding:12px 16px}.chat-mode-picker label{display:block;font-weight:650;margin-bottom:6px}.chat-mode-picker select{width:100%;padding:9px 12px;border-radius:10px;border:1px solid var(--border,#87939f);background:var(--surface,#fff);color:var(--text,#202e43)}.chat-mode-picker p{margin:8px 0 0;line-height:1.45}

.call-audio-panel{flex-shrink:0;display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px 12px;padding:10px 16px;background:#202c29;color:#fff}.call-audio-panel label{font-size:14px;font-weight:600}.call-audio-panel select{max-width:100%;padding:8px;border-radius:8px;border:1px solid #ffffff60;background:#253b31;color:#fff}.call-audio-panel p{flex-basis:100%;margin:0;text-align:center;font-size:13px;line-height:1.4;color:#e0eee6}#call-talk{touch-action:none;user-select:none;-webkit-user-select:none;min-width:125px}#call-talk[aria-pressed=true]{background:#d5f5dc;color:#163c25}#call-talk[hidden]{display:none}

/* Both ends of a call use the same tap-to-speak and level-filter controls. */
#call-talk{min-height:48px;font-size:16px;touch-action:manipulation}#call-noise-status{font-size:14px;line-height:1.5}.call-audio-panel select{min-height:44px}@media(max-width:600px){#call-talk{width:100%;max-width:320px}.call-audio-panel{padding:12px;gap:10px}}
.call-screen .call-audio-panel label{display:inline-block;width:auto;flex:0 0 auto;color:#fff;margin:0;font-weight:650}.call-screen .call-audio-panel select{width:auto;flex:0 1 auto;min-width:210px;margin:0}.call-screen .call-audio-panel p{color:#e0eee6}@media(max-width:600px){.call-screen .call-audio-panel select{min-width:0;width:100%;flex-basis:100%}}

.group-call-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px;padding:16px;flex:1;min-height:0;overflow:auto;background:#152821}.group-call-tile{position:relative;min-height:170px;display:flex;flex-direction:column;justify-content:flex-end;border:1px solid #ffffff28;border-radius:18px;overflow:hidden;background:#203b33;color:white}.group-call-tile video{display:block;width:100%;height:180px;object-fit:cover;background:#12231c}.group-call-tile strong{padding:10px 12px 0;font-size:16px}.group-call-tile>span{padding:3px 12px 12px;color:#d4e7dd;font-size:13px}.group-call-grid.hidden{display:none}@media(max-width:600px){.group-call-grid{grid-template-columns:repeat(2,minmax(0,1fr));padding:8px;gap:8px}.group-call-tile{min-height:135px;border-radius:12px}.group-call-tile video{height:110px}.group-call-tile strong{font-size:14px}}

.file-preview-dialog { width: min(900px, 94vw); max-height: 90dvh; overflow: auto; }
.file-preview-media { display: block; max-width: 100%; max-height: 65dvh; margin: 16px auto; object-fit: contain; }
.file-preview-text { max-height: 65dvh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px; background: var(--ui-accent-soft, #edf4f4); border-radius: 8px; }

/* Developer artwork: calm center, detailed celestial edges, static for comfort. */
body:is(.theme-dark, :not(.theme-dark)) :is(.message-feed,.wallpaper-preview)[data-wallpaper="celestial-sanctum"] {
  background: linear-gradient(90deg, #070d2480, #10112930 48%, #090c2260), url('/developer-chat-background.webp') center center / cover no-repeat, #0c1026;
}
.message-feed[data-wallpaper="celestial-sanctum"] :is(.message-meta,.message-meta strong,.message-receipt,.message-day) { color: #f3e4be; text-shadow: 0 1px 3px #000; }
.message-feed[data-wallpaper="celestial-sanctum"] .message p { box-shadow: 0 2px 14px #03061740; }
.wallpaper-preview[data-wallpaper="celestial-sanctum"] { min-height: 230px; border-color: #bba16b; }
.subscription-one-time { padding: 16px 0; margin-top: 12px; border-top: 1px solid var(--g-divider, #dfe7e2); }
.subscription-one-time h3 { margin: 0 0 8px; }
.subscription-one-time p { margin: 6px 0; line-height: 1.5; }

/* Two clear picture choices stay side by side, including on small phones. */
.signup-human-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.signup-human-choice { min-width: 0; padding: 8px; border: 2px solid #c6d6d2; border-radius: 12px; background: #f7faf9; color: #273f37; cursor: pointer; }
.signup-human-choice img { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 8px; }
.signup-human-choice span { display: block; margin-top: 7px; font-size: 14px; font-weight: 650; }
.signup-human-choice[aria-pressed="true"] { border-color: #17697a; background: #dbedf0; box-shadow: 0 0 0 2px #17697a; }
body.theme-dark .signup-human-choice { background: #263c35; border-color: #77988b; color: #f2faf5; }
body.theme-dark .signup-human-choice[aria-pressed="true"] { background: #34574b; border-color: #9bd3ba; }

/* Prepaid checkout stays in the existing Plans sheet. */
#subscription-prepaid label { display: block; margin-top: 12px; margin-bottom: 6px; font-weight: 600; }
#subscription-prepaid select { display: block; width: 100%; max-width: 100%; min-height: 44px; }
#subscription-prepaid #prepaid-total { font-weight: 700; }

/* One familiar file browser for account storage and shared spaces. */
.file-library-controls { flex: none; margin: 16px 0 8px; }
.file-library-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.file-library-nav button { min-height: 44px; margin: 0; border-radius: 14px; }
.file-library-nav button[aria-pressed=true] { background: var(--ui-accent, #17697a); color: #fff; border-color: transparent; }
.file-library-tools { display: flex; align-items: end; gap: 12px; margin-top: 12px; }
.file-library-tools > input { flex: 1; min-width: 0; }
.file-library-tools label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.file-library-tools select { width: auto; min-height: 44px; margin: 0; }
.file-library-count { color: var(--muted, #657780); font-size: 13px; margin: 8px 0; }
.file-library-dialog { width: min(940px, calc(100vw - 32px)); }
.file-library-thumbnail { position: relative; isolation: isolate; display: grid; place-items: center; flex: none; width: 64px; height: 64px; min-height: 0; padding: 0; margin: 0; overflow: hidden; border: 1px solid var(--line, #899aa333); border-radius: 12px; background: var(--ui-accent-soft, #e4eff1); color: var(--ui-accent-ink, #155867); }
.file-library-thumbnail img, .file-library-thumbnail video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--g-well, #eef0f5); pointer-events: none; }
.file-library-fallback { font-size: 16px; font-weight: 700; }
.file-library-play { z-index: 1; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: white; background: #142632b8; }
.file-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; gap: 14px; padding: 4px 4px 14px; }
.file-library-grid > .modal-empty { grid-column: 1 / -1; }
.file-library-grid .drive-file, .file-library-grid .library-shared-file { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 10px; margin: 0; min-width: 0; border: 1px solid var(--line, #899aa333); border-radius: 16px; }
.file-library-grid .file-library-thumbnail { width: 100%; height: 150px; margin: 0; }
.file-library-grid .drive-file-copy { flex: 1; flex-basis: auto; }
.file-library-grid .drive-file-actions { flex-wrap: wrap; width: 100%; justify-content: start; gap: 4px; }
.library-shared-file { flex-wrap: wrap; }
.library-shared-file > a { overflow-wrap: anywhere; min-width: 0; flex: 1; }
.file-library-grid .library-shared-file > a { flex: auto; }
.file-library-grid .library-shared-file button:not(.file-library-thumbnail) { margin: 0; }
#received-shared-spaces { flex: none; max-height: 120px; overflow: auto; }
@media (max-width: 560px) {
  .file-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .file-library-grid .file-library-thumbnail { height: 120px; }
  .file-library-grid .drive-file { padding: 8px; }
  .file-library-tools { flex-wrap: wrap; }
  .file-library-nav { gap: 5px; }
  .file-library-nav button { padding-inline: 10px; font-size: 13px; }
  .drive-toolbar { flex-wrap: wrap; }
  .drive-search { flex-basis: 100%; }
}
