/* Thread Fanatics Hub mobile-only optimization layer.
   Desktop remains controlled by existing CSS because every rule below is scoped to phone/tablet widths. */
@media (max-width: 800px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    -webkit-text-size-adjust: 100%;
  }

  .app {
    display: block;
    min-height: 100dvh;
  }

  .main {
    width: 100%;
    min-width: 0;
    padding: 12px 12px calc(92px + env(safe-area-inset-bottom)) !important;
  }

  .topbar {
    display: none !important;
  }

  .hero {
    margin: 0 0 14px !important;
    padding: 16px !important;
    display: block !important;
    border: 1px solid rgba(22,117,174,.38);
    border-radius: 18px;
    background: linear-gradient(135deg,rgba(8,32,58,.96),rgba(5,10,18,.96));
    box-shadow: 0 0 26px rgba(22,117,174,.18);
  }

  .hero-left {
    border-left: 0 !important;
    padding-left: 0 !important;
  }

  .hero h1,
  .tfh-calendar-page .tfh-calendar-hero h1,
  .tfh-products-page .tfh-products-hero h1,
  .tfh-marketing-hero h1 {
    font-size: clamp(24px, 7vw, 30px) !important;
    line-height: 1.08 !important;
  }

  .hero p,
  .panel p,
  .tfh-calendar-page .tfh-calendar-hero p,
  .tfh-products-page .tfh-products-hero p,
  .tfh-marketing-hero p {
    font-size: 14px !important;
    line-height: 1.4 !important;
  }

  .dash-grid,
  .single-module,
  .tfh-calendar-page,
  .tfh-products-page,
  .tfh-marketing-page {
    display: grid !important;
    gap: 14px !important;
    width: 100%;
    min-width: 0;
  }

  .panel,
  .settings-card,
  .tfh-calendar-page .tfh-calendar-hero,
  .tfh-calendar-page .tfh-month-panel,
  .tfh-calendar-page .tfh-calendar-main,
  .tfh-calendar-page .tfh-calendar-side,
  .tfh-products-page .tfh-products-hero,
  .tfh-products-page .tfh-product-card,
  .tfh-marketing-hero,
  .tfh-marketing-card {
    border-radius: 18px !important;
    width: 100%;
    min-width: 0;
  }

  .panel {
    padding: 14px !important;
  }

  .panel-head,
  .calendar-panel .panel-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: stretch !important;
    padding-bottom: 14px !important;
  }

  .panel-title {
    gap: 12px !important;
    min-width: 0;
  }

  .roundicon {
    width: 44px !important;
    height: 44px !important;
    font-size: 21px !important;
    flex: 0 0 auto;
  }

  .panel h2 {
    font-size: 18px !important;
  }

  .view,
  .add,
  .calendar-panel .view,
  .task-panel .view,
  .tfh-calendar-page .tfh-calendar-primary,
  .tfh-products-page .tfh-products-btn,
  .tfh-products-page .tfh-products-small-btn,
  .tfh-marketing-page button {
    min-height: 48px !important;
    width: 100%;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
  }

  .listbox,
  .calendar-list {
    padding: 10px !important;
    overflow: visible !important;
  }

  .day,
  .event-day {
    margin-bottom: 10px !important;
  }

  .day-head,
  .event-day-head {
    min-height: 48px !important;
    height: auto !important;
    gap: 8px !important;
    padding: 10px 12px !important;
  }

  .day-label {
    min-width: 0;
    line-height: 1.2;
  }

  .count {
    flex: 0 0 auto;
    min-width: auto !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
  }

  .item {
    grid-template-columns: 28px minmax(0,1fr) auto !important;
    gap: 10px !important;
    padding: 14px 12px !important;
    min-height: 56px;
  }

  .item span:nth-child(2),
  .event-copy,
  .tfh-calendar-copy,
  .tfh-product-title,
  .tfh-marketing-card-title {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .check {
    width: 22px !important;
    height: 22px !important;
  }

  .badge {
    padding: 6px 9px !important;
    font-size: 11px !important;
  }

  .event-item {
    grid-template-columns: 1fr auto !important;
    gap: 8px 10px !important;
    min-height: auto !important;
    padding: 13px 12px !important;
  }

  .event-item .time {
    grid-column: 1 / -1;
    font-size: 13px !important;
  }

  .event-item .dot {
    display: none !important;
  }

  .event-item .badge {
    align-self: start;
    justify-self: end !important;
  }

  .event-copy b {
    font-size: 15px !important;
  }

  .event-copy small {
    font-size: 13px !important;
  }

  .completed-section {
    margin-top: 14px;
  }

  .completed-row {
    display: grid !important;
    grid-template-columns: 28px minmax(0,1fr) !important;
    gap: 10px !important;
    align-items: start !important;
    padding: 12px !important;
  }

  .completed-row button {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .mobile-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -10px 30px rgba(0,0,0,.38);
  }

  .mobile-nav button {
    min-height: 62px !important;
    padding: 9px 2px 8px !important;
    line-height: 1.15 !important;
    overflow: hidden;
  }

  .tfh-modal-backdrop {
    align-items: flex-end !important;
    padding: 10px !important;
  }

  .tfh-modal {
    width: 100% !important;
    max-height: calc(100dvh - 20px) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 20px 20px 14px 14px !important;
  }

  .tfh-modal-top {
    flex: 0 0 auto;
    padding: 14px 16px !important;
  }

  .tfh-form-body,
  .tfh-modal-body {
    overflow: auto !important;
    padding: 18px !important;
  }

  .tfh-modal-actions {
    position: sticky !important;
    bottom: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  }

  .tfh-btn {
    width: 100% !important;
    min-height: 48px !important;
  }

  .tfh-action-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
    min-height: 46px;
  }
}

@media (max-width: 800px) {
  .tfh-calendar-page .tfh-calendar-hero,
  .tfh-products-page .tfh-products-hero,
  .tfh-marketing-hero {
    display: grid !important;
    gap: 14px !important;
    padding: 16px !important;
  }

  .tfh-calendar-page .tfh-calendar-stats,
  .tfh-products-page .tfh-products-stats,
  .tfh-marketing-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .tfh-calendar-page .tfh-calendar-stats > div,
  .tfh-products-page .tfh-products-stats > div,
  .tfh-marketing-stats > div {
    padding: 12px !important;
  }

  .tfh-calendar-page .tfh-calendar-stats strong,
  .tfh-products-page .tfh-products-stats strong,
  .tfh-marketing-stats strong {
    font-size: 21px !important;
  }

  .tfh-calendar-page .tfh-month-panel {
    overflow: visible !important;
  }

  .tfh-calendar-page .tfh-month-head,
  .tfh-calendar-page .tfh-calendar-section-head,
  .tfh-marketing-mockup-head {
    display: grid !important;
    gap: 12px !important;
  }

  .tfh-calendar-page .tfh-month-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .tfh-calendar-page .tfh-month-actions button {
    width: 100%;
    min-height: 44px;
  }

  .tfh-calendar-page .tfh-month-weekdays {
    display: none !important;
  }

  .tfh-calendar-page .tfh-month-grid {
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .tfh-calendar-page .tfh-month-cell.is-empty {
    display: none !important;
  }

  .tfh-calendar-page .tfh-month-cell {
    min-height: auto !important;
    display: grid;
    grid-template-columns: 44px minmax(0,1fr);
    gap: 10px;
    align-items: start;
    padding: 10px !important;
  }

  .tfh-calendar-page .tfh-month-day-num {
    margin: 0 !important;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #0d2b4c;
    border: 1px solid #1c5d9b;
  }

  .tfh-calendar-page .tfh-month-events button {
    min-height: 38px;
    white-space: normal !important;
    font-size: 12px !important;
  }

  .tfh-calendar-page .tfh-calendar-card {
    grid-template-columns: 54px minmax(0,1fr) !important;
    padding: 10px !important;
  }

  .tfh-calendar-page .tfh-calendar-card h3 {
    font-size: 16px !important;
  }

  .tfh-calendar-page .tfh-calendar-card p {
    font-size: 13px !important;
  }

  .tfh-products-page .tfh-product-card-head,
  .tfh-marketing-card-head {
    grid-template-columns: 58px minmax(0,1fr) 44px !important;
    gap: 10px !important;
    padding: 12px !important;
  }

  .tfh-products-page .tfh-product-thumb,
  .tfh-marketing-icon {
    height: 52px !important;
  }

  .tfh-products-page .tfh-products-small-btn,
  .tfh-marketing-edit {
    grid-column: 1 / -1 !important;
    justify-self: stretch !important;
    width: 100% !important;
  }

  .tfh-products-page .tfh-product-chevron,
  .tfh-marketing-expand {
    grid-column: 3 / 4 !important;
    grid-row: 1 / 2 !important;
  }

  .tfh-products-page .tfh-product-detail-grid,
  .tfh-marketing-info-grid,
  .tfh-marketing-mockup-strip {
    grid-template-columns: 1fr !important;
  }

  .tfh-products-page .tfh-product-section {
    padding: 14px !important;
  }

  .tfh-products-page .tfh-photo-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .tfh-products-page .tfh-photo-tile {
    min-height: 78px !important;
  }
}

@media (max-width: 420px) {
  .main {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .tfh-calendar-page .tfh-calendar-stats,
  .tfh-products-page .tfh-products-stats,
  .tfh-marketing-stats {
    grid-template-columns: 1fr !important;
  }

  .tfh-products-page .tfh-photo-grid {
    grid-template-columns: 1fr !important;
  }

  .mobile-nav button {
    font-size: 10px !important;
  }
}