/* Final mobile polish loaded after theme files. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body.silk {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body.silk :where(img, video, canvas, svg) {
  max-width: 100%;
  height: auto;
}

body.silk :where(input, select, textarea, button) {
  font-size: max(16px, 1rem);
}

body.silk :where(.btn, button, input, select, textarea, .tablist li) {
  touch-action: manipulation;
}

body.silk :where(.btn, button, .tablist li, .qty-btn, .activity-chip-delete) {
  min-height: 44px;
}

body.silk :where(.btn, button) {
  max-width: 100%;
  white-space: normal;
}

body.silk :where(.card, .summary-card, .auth-card, .profile-card, .ritual-card, .ritual-box, .ai-card, .admin-table-wrapper) {
  max-width: 100%;
}

body.silk :where(.grid-2, .grid-2-compact, .quick-grid, .ai-grid, .msg-grid, .glow-grid, .profile-hero-grid) {
  min-width: 0;
}

body.silk :where(.admin-table-wrapper, .table-wrap, .targets, .msg-list) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.silk.is-visual-zoomed :where(.floating-hearts, #snow-container, #kcalSticky, .kcal-status-art) {
  display: none !important;
}

body.silk.is-visual-zoomed :where(.topbar) {
  position: static !important;
  top: auto !important;
  transform: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.silk.index-bg :where(.tabs, main.tabs) {
  overflow: visible !important;
}

@media (max-width: 900px) {
  body.silk :where(.grid-2, .grid-2-compact, .quick-grid, .ai-grid, .msg-grid, .glow-grid, .profile-hero-grid) {
    grid-template-columns: 1fr !important;
  }

  body.silk :where(.topbar, .summary-hero, .glow-hero, .ritual-hero, .profile-hero, .silk-hero, .monique-banner, .start-hero.card) {
    max-width: calc(100vw - 20px) !important;
  }
}

@media (max-width: 760px) {
  body.silk {
    --mobile-safe-top: max(env(safe-area-inset-top), 8px);
    --mobile-safe-right: max(env(safe-area-inset-right), 10px);
    --mobile-safe-bottom: max(env(safe-area-inset-bottom), 14px);
    --mobile-safe-left: max(env(safe-area-inset-left), 10px);
    padding-bottom: calc(var(--mobile-safe-bottom) + 18px);
  }

  body.silk .floating-hearts,
  body.silk #snow-container {
    display: none !important;
  }

  body.silk .topbar {
    position: relative !important;
    top: auto !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    margin: 10px auto 12px !important;
    padding: 14px var(--mobile-safe-right) 14px var(--mobile-safe-left) !important;
    border-radius: 18px !important;
  }

  body.silk .topbar h1 {
    margin: 0 !important;
    font-size: clamp(1.08rem, 5.4vw, 1.45rem) !important;
    line-height: 1.08 !important;
    max-width: 100% !important;
    text-wrap: balance;
  }

  body.silk .topbar .user-info {
    display: block !important;
    justify-self: start !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-wrap: anywhere;
    white-space: normal !important;
    text-align: left !important;
    font-size: .86rem !important;
    line-height: 1.3 !important;
  }

  body.silk .topbar .nav-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.silk .topbar .nav-buttons > *,
  body.silk .topbar .nav-buttons form,
  body.silk .topbar .nav-buttons .inline,
  body.silk .topbar .nav-buttons .btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.silk .topbar .nav-buttons .btn,
  body.silk .topbar .nav-buttons button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 46px !important;
    padding: 10px 12px !important;
    text-align: center !important;
    line-height: 1.16 !important;
  }

  body.silk :where(main, .page-content, .tabs, .summary-wrap, .user-admin-wrap, .ritual-wrap, .profile-wrap) {
    width: 100% !important;
    max-width: 100vw !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: var(--mobile-safe-left) !important;
    padding-right: var(--mobile-safe-right) !important;
  }

  body.silk :where(.monique-banner, .ritual-hero, .summary-hero, .glow-hero, .profile-hero, .silk-hero, .start-hero.card) {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 12px 0 16px !important;
    padding: 18px !important;
    border-radius: 18px !important;
  }

  body.silk :where(.monique-banner h1, .monique-banner h2, .ritual-hero h1, .summary-hero h1, .glow-hero h1, .landing h1) {
    max-width: 100% !important;
    font-size: clamp(1.8rem, 9vw, 2.45rem) !important;
    line-height: 1.02 !important;
    overflow-wrap: anywhere;
  }

  body.silk :where(.monique-points, .modern-stat-grid, .quick-actions, .landing, .landing-gallery-column) {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  body.silk :where(.modern-hero-actions, .ritual-actions, .quick-actions) {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  body.silk.index-bg {
    padding-bottom: calc(var(--mobile-safe-bottom) + 102px) !important;
  }

  body.silk.index-bg .tabs {
    overflow: visible !important;
  }

  body.silk.index-bg .tabs-search-sticky {
    position: sticky !important;
    top: var(--mobile-safe-top) !important;
    z-index: 1080 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 8px 0 14px !important;
    padding: 8px !important;
    overflow: visible !important;
    border-radius: 16px !important;
  }

  body.silk.index-bg .tabs-search-sticky .tablist.sticky-tabs,
  body.silk.index-bg .tabs-search-sticky .search-wrap {
    position: static !important;
    top: auto !important;
  }

  body.silk.index-bg .tablist.sticky-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    padding: 6px 2px 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  body.silk.index-bg .tablist.sticky-tabs::-webkit-scrollbar {
    display: none;
  }

  body.silk.index-bg .tablist.sticky-tabs li {
    flex: 0 0 auto !important;
    min-width: 48px !important;
    min-height: 42px !important;
    padding: 9px 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    scroll-snap-align: start;
    white-space: nowrap !important;
  }

  body.silk.index-bg .tablist.sticky-tabs li.summary-tab {
    min-width: max-content !important;
  }

  body.silk.index-bg .tablist.sticky-tabs li.clear-tab-wrap {
    padding: 0 !important;
  }

  body.silk.index-bg .clear-tab-btn {
    min-height: 42px !important;
    height: 42px !important;
    margin: 0 !important;
    padding: 0 13px !important;
    white-space: nowrap !important;
  }

  body.silk.index-bg .search-wrap {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    padding: 10px !important;
  }

  body.silk.index-bg .search-wrap input {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
  }

  body.silk.index-bg .search-scope-btn,
  body.silk.index-bg .activity-mini-btn {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    justify-content: center !important;
    text-align: center !important;
  }

  body.silk.index-bg .bmr-widget {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
  }

  body.silk.index-bg .bmr-right {
    min-width: 0 !important;
  }

  body.silk.index-bg #kcalSticky.sticky-counter.heart-counter {
    position: fixed !important;
    top: auto !important;
    right: var(--mobile-safe-right) !important;
    bottom: var(--mobile-safe-bottom) !important;
    left: auto !important;
    z-index: 1090 !important;
    opacity: .78 !important;
    transform: scale(.72) !important;
    transform-origin: bottom right !important;
    pointer-events: none !important;
  }

  body.silk.index-bg .kcal-status-art {
    display: none !important;
  }

  body.silk.index-bg .card {
    padding: 10px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
  }

  body.silk.index-bg .silk-table,
  body.silk.index-bg .silk-table tbody,
  body.silk.index-bg .silk-table tr,
  body.silk.index-bg .silk-table td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.silk.index-bg .silk-table {
    border-spacing: 0 !important;
    table-layout: fixed !important;
    touch-action: pan-y !important;
  }

  body.silk.index-bg .silk-table thead {
    display: none !important;
  }

  body.silk.index-bg .silk-table tbody {
    display: grid !important;
    gap: 10px !important;
    touch-action: pan-y !important;
  }

  body.silk.index-bg .silk-table tr.meal-row {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    gap: 8px 10px !important;
    align-items: center !important;
    padding: 12px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    transform: none !important;
    transition: none !important;
    will-change: auto !important;
    touch-action: pan-y !important;
  }

  body.silk.index-bg .silk-table tr.meal-row:hover {
    transform: none !important;
  }

  body.silk.index-bg .silk-table tr.meal-row td {
    padding: 0 !important;
    border-radius: 0 !important;
    min-width: 0 !important;
    background: transparent !important;
  }

  body.silk.index-bg .silk-table tr.meal-row td:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding-top: 2px !important;
  }

  body.silk.index-bg .silk-table tr.meal-row td.meal-title {
    grid-column: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.28 !important;
  }

  body.silk.index-bg .silk-table tr.meal-row td.meal-kcal {
    grid-column: 2;
    justify-self: stretch;
    text-align: left !important;
  }

  body.silk.index-bg .silk-table input[type="checkbox"] {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    touch-action: manipulation !important;
  }

  body.silk.index-bg .kcal-wrap {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    min-width: 0 !important;
  }

  body.silk.index-bg .kcal-number {
    min-width: 0 !important;
    font-size: .98rem !important;
    font-weight: 800 !important;
  }

  body.silk.index-bg .qty-controls {
    flex: 0 0 auto !important;
    gap: 8px !important;
  }

  body.silk.index-bg .qty-controls button {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    touch-action: manipulation !important;
  }

  body.silk.index-bg .activity-list-head {
    align-items: flex-start !important;
  }

  body.silk.index-bg .activity-chip {
    max-width: 100% !important;
    white-space: normal !important;
    border-radius: 14px !important;
  }

  body.silk.index-bg .activity-chip-text {
    min-width: 0 !important;
    overflow-wrap: anywhere;
  }

  body.silk.index-bg .activity-chip-delete {
    opacity: 1 !important;
    transform: none !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    line-height: 28px !important;
  }

  body.silk.index-bg .activity-panel {
    align-items: flex-end !important;
    padding: 16px var(--mobile-safe-right) var(--mobile-safe-bottom) var(--mobile-safe-left) !important;
    overflow-y: auto !important;
  }

  body.silk.index-bg .activity-panel-card {
    width: 100% !important;
    max-height: calc(100dvh - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 24px) !important;
    overflow-y: auto !important;
    border-radius: 20px 20px 16px 16px !important;
  }

  body.silk.index-bg .activity-grid {
    grid-template-columns: 1fr !important;
  }

  @media (pointer: coarse) {
    body.silk.index-bg .silk-table,
    body.silk.index-bg .silk-table tbody,
    body.silk.index-bg .silk-table tr.meal-row,
    body.silk.index-bg .silk-table tr.meal-row td {
      filter: none !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      box-shadow: none !important;
      animation: none !important;
    }
  }
}

@media (max-width: 430px) {
  body.silk .topbar .nav-buttons {
    grid-template-columns: 1fr !important;
  }

  body.silk.index-bg .search-wrap {
    grid-template-columns: 1fr !important;
  }

  body.silk.index-bg .tablist.sticky-tabs li {
    min-width: 46px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.silk.index-bg #kcalSticky.sticky-counter.heart-counter {
    transform: scale(.66) !important;
  }
}

/* Keep the day tabs and search tools pinned as the app's mobile command bar. */
body.silk.index-bg .tabs-search-sticky,
body.silk.is-visual-zoomed.index-bg .tabs-search-sticky {
  position: sticky !important;
  position: -webkit-sticky !important;
  top: max(env(safe-area-inset-top), 0px) !important;
  z-index: 1200 !important;
  transform: none !important;
  align-self: start !important;
  will-change: transform !important;
}

body.silk.index-bg .mobile-tools-placeholder {
  display: none;
}

@media (max-width: 760px) {
  body.silk.index-bg.mobile-tools-fixed .mobile-tools-placeholder {
    display: block;
    height: var(--mobile-tools-h, 132px);
  }

  body.silk.index-bg.mobile-tools-fixed .tabs-search-sticky,
  body.silk.index-bg.mobile-tools-fixed.is-visual-zoomed .tabs-search-sticky {
    position: fixed !important;
    top: max(env(safe-area-inset-top), 0px) !important;
    left: max(env(safe-area-inset-left), 8px) !important;
    right: max(env(safe-area-inset-right), 8px) !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    z-index: 2000 !important;
  }
}

body.silk.index-bg .tabs-search-sticky .tablist.sticky-tabs,
body.silk.index-bg .tabs-search-sticky .search-wrap,
body.silk.is-visual-zoomed.index-bg .tabs-search-sticky .tablist.sticky-tabs,
body.silk.is-visual-zoomed.index-bg .tabs-search-sticky .search-wrap {
  position: static !important;
  top: auto !important;
}
