/* Contained overlays and touch controls, using the existing theme tokens. */
.popover { overflow-y: auto; overscroll-behavior: contain; }
.popover:has(.profile-card) { display: flex; overflow: hidden; }
.profile-card, .profile-card:not(.mini) { max-width: 100%; max-height: inherit; min-height: 0; display: flex; flex-direction: column; }
.profile-card .pc-hero, .profile-card .pc-banner { flex-shrink: 0; }
.profile-card .pc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
.full-profile { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.full-profile .fp-banner, .full-profile .fp-top, .full-profile .fp-tabs { flex-shrink: 0; }
.full-profile .fp-top { flex-wrap: wrap; gap: 8px 12px; }
.full-profile .fp-names { min-width: 120px; overflow-wrap: anywhere; }
.fp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fp-body { flex: 1 1 auto; min-height: 0; max-height: none; overscroll-behavior: contain; overflow-wrap: anywhere; }
.fp-modal { max-height: min(860px, calc(100dvh - 24px)); }
.settings-search { display: block; position: sticky; top: -14px; background: var(--bg); padding: 8px 2px; z-index: 2; }
.settings-search input { width: 100%; min-width: 0; font-size: 12px; }
.settings-nav [hidden] { display: none !important; }
.settings-jump { display: none; }
.settings-main { scroll-behavior: smooth; overscroll-behavior: contain; scrollbar-gutter: stable; }
.settings-main .field { max-width: 100%; }
.settings-main .select, .settings-main .input { min-width: 0; }
.settings-main h2 { padding-right: 28px; }
.community-form { display: grid; gap: 14px; max-width: 560px; }
.community-form [hidden] { display: none !important; }
.community-form .row { display: flex; gap: 12px; }
.community-form .row .field:first-child { flex: 1; min-width: 0; }
.community-form .row .field:last-child { width: 112px; }
.community-link { display: block; margin: 10px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3); color: var(--text); overflow-wrap: anywhere; }
.community-link b { display: flex; align-items: center; gap: 8px; }
.community-link small { display: block; color: var(--text-2); margin-top: 6px; }
.invite-embed { margin: 10px 0 4px; width: min(380px,100%); border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); overflow: hidden; }
.invite-cover { height: 72px; background: linear-gradient(135deg,var(--gold-soft),var(--bg-3)); }
.invite-content { padding: 0 16px 16px; }
.invite-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--bg-3); border: 3px solid var(--bg-2); margin-top: -28px; position: relative; overflow: hidden; font-size: 24px; }
.invite-icon img { width: 100%; height: 100%; object-fit: cover; }
.invite-content h4 { margin: 10px 0 6px; font-size: 17px; overflow-wrap: anywhere; }
.invite-content p { margin: 6px 0; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.invite-content .btn { width: 100%; justify-content: center; margin-top: 12px; }
.invite-online { color: var(--green); }
.restriction-list { display: grid; gap: 8px; margin: 12px 0 24px; }
.restriction-list .mem-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px; flex-wrap: wrap; gap: 8px; }
.restriction-list .mr-name { min-width: 120px; flex: 1; overflow-wrap: anywhere; }
.settings-hint { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.message-enter { animation: message-arrive .2s cubic-bezier(.2,.7,.3,1); animation-delay: var(--message-enter-delay,0ms); }
@keyframes message-arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.reduce-motion .message-enter { animation: none; }
@media(prefers-reduced-motion:reduce) { .message-enter { animation: none; } .settings-main { scroll-behavior: auto; } }
@media(pointer:coarse) {
  .icon-btn, .menu button, .settings-nav button, .btn { min-height: 44px; }
  .icon-btn { min-width: 44px; }
  .chan { min-height: 44px; }
  .topbar .t-actions { gap: 2px; }
  .deck-servers { touch-action: pan-x; overscroll-behavior-x: contain; }
}
@media(max-width:760px) {
  .app { height: var(--mobile-viewport-height,100dvh); }
  .app .nav { height: var(--mobile-viewport-height,100dvh); bottom: auto; }
  .modal-back { height: var(--mobile-viewport-height,100dvh); bottom: auto; }
  .modal-back .modal.wide { height: var(--mobile-viewport-height,100dvh); max-height: var(--mobile-viewport-height,100dvh); }
  .modal-back .modal:not(.wide) { max-height: calc(var(--mobile-viewport-height,100dvh) - 12px); }
  .settings > .settings-nav { display: none; }
  .settings-jump { display: block; position: sticky; top: -14px; background: var(--bg-2); padding: 8px 40px 12px 0; z-index: 3; margin-bottom: 14px; }
  .settings-jump select { font-size: 16px; width: 100%; min-height: 44px; }
  .settings-main > .x { position: fixed; top: max(16px,env(safe-area-inset-top)); right: 10px; z-index: 5; background: var(--bg-3); }
  .settings-main { padding-bottom: max(24px,env(safe-area-inset-bottom)); }
  .fp-modal { max-height: min(94dvh,calc(var(--mobile-viewport-height,100dvh) - 12px)) !important; }
  .full-profile .fp-banner { height: 92px; }
  .full-profile .fp-top { padding: 0 14px; margin-top: -28px; }
  .full-profile .fp-top .av.lg { width: 72px; height: 72px; }
  .full-profile .fp-actions { flex-basis: 100%; }
  .full-profile .fp-actions .btn { flex: 1; justify-content: center; }
  .full-profile .fp-tabs { padding-left: 10px; padding-right: 10px; overflow-x: auto; }
  .full-profile .fp-tabs button { white-space: nowrap; flex-shrink: 0; }
  .profile-card:not(.mini) { width: min(340px,calc(100vw - 16px)); }
  .gl-src { grid-template-columns: 1fr; }
  .gl-opt { padding: 10px; }
  .gl-row { flex-wrap: wrap; }
  .settings-main .mem-row > .btn { flex-shrink: 0; }
  .community-form .row { flex-wrap: wrap; }
}
