/* Homer phone grid. Desktop rules stay in index.html. Breakpoint matches 719px. */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  overscroll-behavior-y: contain;
}

button,
a,
.cat-tab,
.auth-btn,
.auth-link,
.phone-tab,
.phone-app-card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: none) {
  .card-hover:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.55);
  }
  .card-hover:hover .card-img-zoom { transform: none; }
  .card-hover:hover .card-title { color: inherit; }
  .auth-btn:hover {
    transform: none;
    box-shadow: none;
  }
}

.portal-more-btn,
.portal-more-menu,
.phone-tabbar,
.phone-page,
.phone-inner,
.phone-inner-head,
.phone-brand-sub { display: none; }

@media (max-width: 719px) {
  html.is-narrow,
  html.is-narrow body {
    background: #f4f6fb;
    /* Root-page swipes must not also traverse the browser's history. */
    overscroll-behavior-x: none;
  }

  .orb,
  .auth-orb { display: none !important; }

  html.is-narrow #app {
    min-height: 100dvh;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  header.portal-header {
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 0;
    box-shadow: none;
  }

  header.portal-header .portal-nav-row {
    height: 56px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    gap: 10px;
  }

  header.portal-header .portal-logo {
    width: 36px !important;
    height: 36px !important;
    border-radius: 999px !important;
  }

  header.portal-header .portal-logo svg {
    width: 18px;
    height: 18px;
  }

  header.portal-header h1 {
    font-size: 18px !important;
    line-height: 1.15;
    color: #111827;
  }

  header.portal-header h1 span:first-child { display: none; }

  .phone-brand-sub {
    display: block;
    margin-top: 2px;
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
  }

  header.portal-header .portal-nav-actions { display: none !important; }
  #navUserName,
  #navUserType,
  .portal-icon-btn { display: none !important; }

  html.is-narrow.phone-inner-open .phone-inner-head {
    flex: 1;
  }

  .portal-more-btn {
    display: none !important;
  }

  .portal-more-menu {
    display: block;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 70;
    min-width: 168px;
    padding: 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
  }

  .portal-more-menu[hidden] { display: none !important; }
  .portal-more-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px;
    border: 0;
    background: transparent;
    border-radius: 10px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
  }
  .portal-more-menu button:active { background: #f1f5f9; }
  .portal-more-menu .portal-more-logout { color: #dc2626; }

  .portal-search-mobile {
    padding: 0 16px 12px !important;
  }

  .portal-search-mobile input,
  #searchInputMobile {
    font-size: 16px !important;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: #fff !important;
    border-color: #eef2f7 !important;
  }

  #app > main.flex-grow {
    padding: 8px 16px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html.is-narrow.phone-tab-feedback #appsWorkspace,
  html.is-narrow.phone-tab-messages #appsWorkspace,
  html.is-narrow.phone-tab-me #appsWorkspace,
  html.is-narrow.phone-inner-open #appsWorkspace,
  html.is-narrow.phone-tab-feedback #newUserBanner,
  html.is-narrow.phone-tab-messages #newUserBanner,
  html.is-narrow.phone-tab-me #newUserBanner,
  html.is-narrow.phone-inner-open #newUserBanner,
  html.is-narrow.phone-tab-home #appSidebarDefault,
  html.is-narrow.phone-tab-messages #appSidebarDefault,
  html.is-narrow.phone-tab-me #appSidebarDefault,
  html.is-narrow.phone-inner-open #appSidebarDefault,
  html.is-narrow #app footer,
  html.is-narrow.phone-tab-feedback .portal-search-mobile,
  html.is-narrow.phone-tab-messages .portal-search-mobile,
  html.is-narrow.phone-tab-me .portal-search-mobile,
  html.is-narrow.phone-inner-open .portal-search-mobile,
  html.is-narrow.phone-inner-open .portal-more-btn,
  html.is-narrow #tagFilters {
    display: none !important;
  }

  html.is-narrow.phone-tab-feedback #appSidebarDefault {
    display: grid !important;
    margin-top: 0 !important;
    gap: 12px !important;
  }

  .cat-tab-bar {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    margin: 0 0 14px !important;
    padding: 2px 0 4px;
    gap: 6px !important;
  }

  .cat-tab {
    min-width: 0;
    width: 100%;
    min-height: 40px;
    justify-content: center;
    padding: 8px 4px !important;
    white-space: nowrap;
    font-size: 13px !important;
    border-radius: 999px !important;
  }

  .cat-tab svg { display: none; }

  #newUserBanner:not(.hidden) {
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 14px;
  }

  #appGrid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px !important;
  }

  #appGrid .phone-app-card {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    background: #111;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
  }

  #appGrid .phone-app-cover {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #1f2937;
  }

  #appGrid .phone-app-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  #appGrid .phone-app-cover-fallback {
    position: absolute;
    inset: 0;
  }

  #appGrid .phone-app-cover::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58%;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.78));
  }

  #appGrid .phone-app-cover-name {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 1;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  html.is-narrow.phone-tab-messages,
  html.is-narrow.phone-tab-messages body {
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html.is-narrow.phone-tab-messages body {
    min-height: 0 !important;
  }

  html.is-narrow.phone-tab-messages #app {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
  }

  html.is-narrow.phone-tab-messages header.portal-header {
    flex: none;
    position: sticky;
    top: 0;
    z-index: 60;
  }

  html.is-narrow.phone-tab-messages #app > main.flex-grow {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 0 calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html.is-narrow.phone-tab-messages .phone-page-messages {
    display: flex !important;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    padding: 0 !important;
    overflow: hidden;
  }

  .phone-chat-host,
  .phone-chat-frame {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    background: transparent;
    overflow: hidden;
  }

  html.is-narrow.phone-chat-open .phone-tabbar { display: none !important; }

  html.is-narrow.phone-tab-messages.phone-chat-open #app > main.flex-grow {
    padding-bottom: 0 !important;
  }

  html.is-narrow.phone-tab-messages.phone-kbd-open,
  html.is-narrow.phone-tab-messages.phone-kbd-open body,
  html.is-narrow.phone-tab-messages.phone-kbd-open #app {
    height: var(--phone-vvh, 100dvh);
    max-height: var(--phone-vvh, 100dvh);
  }

  html.is-narrow.phone-tab-messages.phone-kbd-open #app > main.flex-grow {
    padding-bottom: 0 !important;
  }

  html.is-narrow.phone-chat-open.phone-kbd-open header.portal-header { display: none !important; }

  #emptyState { padding: 36px 16px !important; }

  #appSidebarDefault .p-6 { padding: 16px !important; }
  #appSidebarDefault h3 { font-size: 16px !important; }
  #appSidebarDefault textarea,
  #appSidebarDefault select,
  #appSidebarDefault button[type="submit"] {
    font-size: 16px !important;
    min-height: 44px;
  }

  .phone-tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    background: #fff;
    border-top: 1px solid #eef2f7;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .phone-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 11px;
    font-weight: 600;
    min-height: 48px;
    justify-content: center;
  }

  .phone-tab.is-on { color: #111827; }
  .phone-tab svg { width: 22px; height: 22px; }
  .phone-tab .dot {
    position: absolute;
    top: 4px;
    left: calc(50% + 7px);
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #f43f5e;
    box-shadow: 0 0 0 2px #fff;
  }
  .phone-tab .dot.num {
    top: 1px;
    left: calc(50% + 4px);
    width: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }
  .phone-tab .dot[hidden] { display: none; }

  .phone-page,
  .phone-inner {
    display: none;
    padding: 8px 16px 16px;
  }

  html.is-narrow.phone-tab-me .phone-page-me,
  html.is-narrow.phone-inner-open .phone-inner {
    display: block;
  }

  html.is-narrow.phone-inner-open header.portal-header .portal-nav-row {
    justify-content: flex-start;
  }

  .phone-inner-head {
    display: none;
  }

  html.is-narrow.phone-inner-open .phone-inner-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  html.is-narrow.phone-inner-open .phone-home-brand { display: none !important; }

  .phone-back {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .phone-inner-title {
    min-width: 0;
    flex: 1;
  }

  .phone-inner-title strong {
    display: block;
    font-size: 18px;
    color: #111827;
  }

  .phone-inner-title span {
    display: block;
    font-size: 11px;
    color: #6b7280;
  }

  .phone-chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 4px 0 14px;
  }

  .phone-chip-row::-webkit-scrollbar { display: none; }

  .phone-chip {
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: #fff;
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
  }

  .phone-chip.is-on {
    background: #4f46e5;
    color: #fff;
  }

  .phone-meet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .phone-meet-card {
    min-height: 132px;
    padding: 14px;
    border: 0;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    text-align: left;
    color: inherit;
  }

  .phone-meet-card.is-record {
    background: #111827;
    color: #fff;
  }

  .phone-meet-card .meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 10px;
  }

  .phone-meet-card.is-record .meta { color: #d1d5db; }

  .phone-meet-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.3;
  }

  .phone-meet-card p {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
  }

  .phone-meet-card.is-record p { color: #d1d5db; }

  .phone-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    font-size: 10px;
    font-weight: 700;
  }

  .phone-badge.warn { background: #fff7ed; color: #c2410c; }
  .phone-badge.mute { background: #f3f4f6; color: #6b7280; }

  .phone-frame {
    width: 100%;
    height: calc(100dvh - 140px - env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 16px;
    background: #fff;
  }

  .phone-account {
    background: #fff;
    border-radius: 20px;
    padding: 20px 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  }

  .phone-account .name {
    font-size: 22px;
    font-weight: 800;
    color: #111827;
  }

  .phone-account .role {
    margin-top: 4px;
    color: #6b7280;
    font-size: 13px;
  }

  .phone-account button {
    width: 100%;
    margin-top: 16px;
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: #111827;
    color: #fff;
    font-weight: 700;
  }

  .phone-account button.ghost {
    margin-top: 10px;
    background: #f3f4f6;
    color: #111827;
  }

  .phone-msg {
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 10px;
  }

  .phone-msg b { display: block; color: #111827; font-size: 14px; }
  .phone-msg span { display: block; color: #6b7280; font-size: 12px; margin: 4px 0 6px; }
  .phone-msg p { margin: 0; color: #334155; font-size: 13px; line-height: 1.55; }

  .phone-empty {
    grid-column: 1 / -1;
    padding: 20px 8px;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
  }
  .phone-empty a { color: #4f46e5; }

  #changelogPanel {
    top: auto !important;
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: min(75vh, 640px);
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -16px 40px rgba(15, 23, 42, 0.18);
  }

  #toast {
    top: auto !important;
    right: 12px !important;
    left: 12px !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  #authOverlay {
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  }

  #authOverlay .relative.z-10 {
    padding-top: 24px;
    padding-bottom: 24px;
    align-items: flex-start;
  }

  #authOverlay .auth-glass {
    padding: 20px !important;
    border-radius: 20px !important;
  }

  #authOverlay .auth-input,
  #authOverlay .auth-btn {
    font-size: 16px !important;
    min-height: 46px;
  }

  #authToast {
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    transform: translateY(-120px);
    text-align: center;
  }

  #authToast.show { transform: translateY(0); }

  #growthMap .gm-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  #growthMap .gm-footer {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  #growthMap .gm-foot-cta {
    width: 100%;
    justify-content: center;
    min-height: 46px;
  }
}

@media (max-width: 359px) {
  header.portal-header h1 { font-size: 16px !important; }
}

/* Swiping between the four root pages slides the new page in from the side it came from. */
@media (max-width: 719px) {
  html.is-narrow #app > main.phone-swipe-from-r { animation: phone-swipe-from-r .26s cubic-bezier(.2, .8, .2, 1); }
  html.is-narrow #app > main.phone-swipe-from-l { animation: phone-swipe-from-l .26s cubic-bezier(.2, .8, .2, 1); }
  html.is-narrow.phone-dragging #app { overflow-x: clip; }
  html.is-narrow #app > main.phone-swipe-stage { will-change: transform; }
  html.is-narrow #app > main.phone-swipe-settling { transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes phone-swipe-from-r { from { transform: translateX(36px); opacity: .4; } }
@keyframes phone-swipe-from-l { from { transform: translateX(-36px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  html.is-narrow #app > main.phone-swipe-from-r,
  html.is-narrow #app > main.phone-swipe-from-l { animation: none; }
}
