/* YOYO Messenger — mobile / tablet tweaks (desktop layout unchanged) */

/* PWA install banner — mobile only */
.yoyo-pwa-banner {
  display: none;
}

@media (max-width: 1024px) {
  /* Classic program toolbar — phones + tablets / PWA (desktop >1024 unchanged) */
  body.messenger-page .messenger-toolbar {
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(180deg, #f0e8f8, #d8c8ec);
  }

  body.messenger-page .messenger-toolbar button {
    flex: 0 0 auto;
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  body.messenger-page .messenger-toolbar .ym-btn-sound {
    margin-left: 4px;
    font-size: 16px;
    padding: 8px 10px;
  }

  /* IM window action strip — same touch-friendly strip as messenger toolbar */
  body.chat-page .chat-toolbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  body.chat-page .chat-toolbar button {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 18px;
  }

  body.chat-page .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    min-width: 64px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .yoyo-pwa-banner {
    display: flex;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 2000;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #f8f4fc 0%, #e0d4f0 100%);
    border: 1px solid var(--ym-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(61, 29, 99, 0.35);
    font-family: var(--font-ui);
    color: var(--ym-text);
  }

  .yoyo-pwa-banner-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    line-height: 1.35;
  }

  .yoyo-pwa-banner-text strong {
    color: var(--ym-purple-dark);
    font-size: 12px;
  }

  .yoyo-pwa-banner-text span {
    color: #555;
  }

  .yoyo-pwa-banner-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .yoyo-pwa-install-btn {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 12px;
  }

  .yoyo-pwa-dismiss-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
  }
}

@media (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    font-size: 13px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .ym-btn {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
  }

  .ym-field input,
  .ym-field select {
    min-height: 40px;
    font-size: 16px; /* avoid iOS zoom */
    padding: 8px 10px;
  }

  .ym-dialog {
    min-width: 0;
    width: calc(100vw - 24px);
    max-width: 400px;
    margin: 0 12px;
  }

  /* Login */
  body.login-page {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .login-header {
    padding: 20px 16px 12px;
  }

  .login-logo {
    font-size: 24px;
  }

  .login-box {
    margin: 0 12px 16px;
    padding: 16px;
  }

  .login-tab {
    padding: 10px 6px;
    font-size: 13px;
    min-height: 40px;
  }

  .login-actions {
    flex-wrap: wrap;
    gap: 10px;
  }

  .login-actions .ym-btn-primary {
    min-width: 100%;
    min-height: 44px;
    font-size: 15px;
  }

  /* Messenger / buddy list */
  body.messenger-page {
    height: 100dvh;
    height: 100vh;
  }

  .buddy-item {
    padding: 10px 12px 10px 16px;
    min-height: 48px;
    gap: 10px;
  }

  .buddy-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .buddy-name {
    font-size: 14px;
  }

  .buddy-status-msg {
    font-size: 11px;
  }

  .buddy-group-header {
    padding: 10px 12px;
    font-size: 13px;
    min-height: 40px;
  }

  .search-box input {
    min-height: 40px;
    font-size: 16px;
    padding: 8px 10px;
  }

  .my-status-msg,
  .my-status-row select {
    min-height: 36px;
    font-size: 14px;
  }

  /* Chat IM */
  body.chat-page {
    height: 100dvh;
    height: 100vh;
  }

  .chat-header {
    padding: 10px 12px;
  }

  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    min-width: 64px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .chat-header-info h3 {
    font-size: 15px;
  }

  .chat-messages {
    font-size: 14px;
    padding: 10px 12px;
  }

  .chat-msg-image {
    max-width: min(220px, 70vw);
  }

  .chat-msg-file {
    max-width: min(280px, 85vw);
  }

  .chat-input-area textarea {
    height: 72px;
    font-size: 16px;
    padding: 10px;
  }

  .chat-send-row .ym-btn-primary {
    min-height: 40px;
    min-width: 88px;
    font-size: 14px;
  }

  .emoticon-picker {
    left: 4px;
    right: 4px;
    bottom: 140px;
    max-width: calc(100vw - 8px);
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    padding: 10px;
  }

  .emoticon-picker button {
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  /* Call */
  body.call-page {
    height: 100dvh;
    height: 100vh;
  }

  .call-header {
    padding: 12px 14px;
  }

  .call-header-info h2 {
    font-size: 16px;
  }

  #local-video {
    width: 96px;
    height: 72px;
    bottom: 10px;
    right: 10px;
  }

  .call-btn {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }

  .call-controls,
  .call-incoming-actions {
    padding: 16px;
    gap: 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .call-btn-close {
    min-width: 160px;
    min-height: 48px;
    font-size: 14px;
  }

  /* Rooms list */
  body.rooms-page {
    height: 100dvh;
    height: 100vh;
  }

  .rooms-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .rooms-header h2 {
    font-size: 15px;
  }

  .room-item {
    padding: 10px 12px;
    flex-wrap: wrap;
    min-height: 48px;
  }

  .room-item .ym-btn {
    min-height: 36px;
    font-size: 12px;
  }

  /* Room chat — stack members below messages on narrow screens */
  body.room-chat-page {
    height: 100dvh;
    height: 100vh;
  }

  .room-chat-body {
    flex-direction: column;
  }

  .room-members-panel {
    width: 100%;
    max-height: 28vh;
    border-left: none;
    border-top: 1px solid var(--ym-border);
  }

  .room-input-area textarea {
    font-size: 16px;
    min-height: 56px;
  }

  .room-send-row .ym-btn-primary {
    min-height: 40px;
    min-width: 88px;
  }

  .room-chat-header {
    padding: 10px 12px;
  }

  .room-chat-header-info h3 {
    font-size: 15px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .ym-btn {
    min-height: 32px;
    padding: 5px 12px;
  }

  .buddy-item {
    padding: 8px 10px 8px 18px;
    min-height: 40px;
  }

  .room-chat-body {
    flex-direction: row;
  }

  .room-members-panel {
    width: 140px;
    max-height: none;
  }
}
