/* MD Marketplace — phone & tablet layout */

@media (max-width: 768px) {
  .tv-wrap { width: min(var(--tv-container), 100% - 24px); }

  body.tv-body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
  }

  /* ── Header compact ── */
  .tv-header__inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
  }

  .tv-logo__brand {
    font-size: 0.88rem;
    padding: 8px 11px;
    letter-spacing: 0.2em;
  }

  .tv-search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .tv-search select {
    max-width: 108px;
    min-width: 88px;
    font-size: 0.72rem;
    padding: 10px 24px 10px 8px;
    color-scheme: light;
  }

  .tv-search input {
    padding: 10px 8px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .tv-search__btn {
    width: 38px;
    height: 38px;
    background: var(--tv-btn-bg, linear-gradient(135deg, var(--tv-gold), var(--tv-gold-deep)));
    color: var(--tv-btn-text, #1a1200);
  }

  .tv-nav {
    display: none;
  }

  .tv-nav.tv-nav--drawer-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: 56px;
    left: 12px;
    right: 12px;
    z-index: 120;
    padding: 14px;
    gap: 8px;
    border-radius: 16px;
    background: var(--tv-surface-solid);
    border: 1px solid var(--tv-line-soft);
    box-shadow: var(--tv-shadow);
    backdrop-filter: var(--tv-blur);
    animation: tv-drawer-in 0.28s var(--tv-ease);
  }

  .tv-nav.tv-nav--drawer-open .tv-nav__link,
  .tv-nav.tv-nav--drawer-open .tv-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
  }

  .tv-nav.tv-nav--drawer-open .tv-nav__link {
    background: var(--tv-bg-2);
    border: 1px solid var(--tv-line-soft);
  }

  @keyframes tv-drawer-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
  }

  .tv-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }

  .tv-mobile-menu-btn,
  .tv-mobile-search-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--tv-line-soft);
    background: var(--tv-surface-solid);
    color: var(--tv-text);
    font-size: 1.1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }

  .tv-search.tv-search--collapsed {
    display: none;
  }

  .tv-search.tv-search--mobile-open {
    display: flex;
    animation: tv-drawer-in 0.25s var(--tv-ease);
  }

  /* ── Category nav ── */
  .tv-catnav__inner {
    padding: 6px 0 8px;
    gap: 0;
  }

  .tv-catnav__item {
    min-width: 72px;
    padding: 8px 12px;
    font-size: 0.65rem;
  }

  .tv-catnav__icon { font-size: 1.05rem; }

  /* ── Hero ── */
  .tv-hero {
    min-height: 320px;
    border-radius: 16px;
    background-position: 65% center;
  }

  .tv-hero__content {
    padding: 28px 22px 32px;
    max-width: none;
  }

  .tv-hero__content h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  .tv-hero__content h1 br { display: none; }

  .tv-hero__content p {
    font-size: 0.92rem;
    margin-bottom: 20px;
  }

  .tv-hero__actions {
    flex-direction: column;
    margin-bottom: 22px;
  }

  .tv-hero__actions .tv-btn {
    width: 100%;
  }

  .tv-trust {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .tv-trust__item {
    font-size: 0.68rem;
    padding: 8px 10px;
    justify-content: center;
  }

  .md-section-tools {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    top: 8px;
    right: 8px;
    padding: 4px 6px;
  }

  .md-section-tools span { display: none; }

  /* ── Stats & sections ── */
  .tv-stats { gap: 8px; margin-top: 14px; }

  .tv-stat { padding: 14px 8px; }

  .tv-stat strong { font-size: 1.15rem; }

  .tv-section { margin-top: 28px; }

  .tv-section__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .tv-section__head h2 { font-size: 1.15rem; }

  .tv-cats { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .tv-cat { padding: 18px 12px; border-radius: 14px; }

  .tv-cards { gap: 12px; }

  html[data-md-cards="3"] .tv-cards,
  html[data-md-cards="4"] .tv-cards {
    grid-template-columns: 1fr;
  }

  html[data-md-cards="2"] .tv-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .tv-card__body { padding: 12px 14px 14px; }

  .tv-card__title { font-size: 0.82rem; }

  .tv-how {
    gap: 10px;
    margin-top: 28px;
  }

  .tv-how__step {
    padding: 20px 16px;
    border-radius: 14px;
  }

  /* ── Sidebar widgets on home ── */
  .tv-side { gap: 12px; }

  .tv-widget {
    border-radius: 14px;
    padding: 18px;
  }

  .tv-page { padding: 16px 0 32px; }

  /* ── Inner pages ── */
  .tv-page-head { padding: 20px 0 10px; }

  .tv-page-head h1 { font-size: 1.45rem; }

  .tv-filters {
    flex-direction: column;
    padding: 14px;
  }

  .tv-filters > div { width: 100%; }

  .tv-filters select { width: 100%; }

  .tv-type-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tv-type-tabs::-webkit-scrollbar { display: none; }

  .tv-type-tabs a {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.78rem;
  }

  .tv-detail__price { font-size: 1.65rem; }

  .tv-detail__actions .tv-btn { flex: 1; min-width: calc(50% - 5px); }

  .tv-detail__gallery-hint {
    font-size: 0.72rem;
    padding: 8px 10px;
  }

  .tv-contact-form textarea {
    font-size: 16px;
    min-height: 120px;
  }

  .tv-detail__seller-card {
    margin-top: 12px;
  }

  .tv-auth-box {
    margin: 24px auto;
    padding: 24px 20px;
    border-radius: 16px;
  }

  .tv-pricing { grid-template-columns: 1fr; }

  .tv-premium-hero { padding: 32px 18px; border-radius: 16px; }

  /* ── Footer ── */
  .tv-footer { padding: 28px 0 16px; }

  .tv-footer__grid {
    grid-template-columns: 1fr;
    gap: 20px;
    text-align: center;
  }

  .tv-footer__brand { font-size: 1.4rem; }

  .tv-footer__bottom {
    font-size: 0.72rem;
    padding-top: 16px;
    text-align: center;
  }

  /* ── Announce bar ── */
  .tv-announce {
    font-size: 0.72rem;
    padding: 8px 16px;
    text-align: center;
  }

  /* ── Style Lab above bottom nav ── */
  .md-style-lab {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 12px;
  }

  .md-style-lab__toggle {
    padding: 10px 16px;
    font-size: 0.78rem;
  }

  .md-style-lab__panel {
    max-height: min(58vh, 420px);
  }

  .md-style-lab__body {
    max-height: none;
  }

  .tv-toast {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 32px);
    text-align: center;
  }
}

/* ── Bottom navigation (phone app feel) ── */
.tv-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .tv-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 140;
    align-items: stretch;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(var(--tv-header-bg, 5, 5, 5), 0.94);
    backdrop-filter: var(--tv-blur);
    -webkit-backdrop-filter: var(--tv-blur);
    border-top: 1px solid var(--tv-line-soft);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  }

  .tv-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    min-height: 52px;
    border-radius: 12px;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--tv-muted);
    transition: color 0.2s, background 0.2s;
    -webkit-user-select: none;
    user-select: none;
  }

  .tv-bottom-nav__item:hover,
  .tv-bottom-nav__item.is-active {
    color: var(--tv-accent);
  }

  .tv-bottom-nav__item.is-active {
    background: rgba(var(--tv-hero-overlay), 0.06);
  }

  .tv-bottom-nav__ico {
    font-size: 1.25rem;
    line-height: 1;
  }

  .tv-bottom-nav__post {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    margin-top: -18px;
    border-radius: 50%;
    background: var(--tv-btn-bg, linear-gradient(135deg, var(--tv-gold), var(--tv-gold-deep)));
    color: var(--tv-btn-text, #1a1200);
    box-shadow: var(--tv-btn-shadow, var(--tv-shadow-sm));
    font-size: 1.5rem;
    font-weight: 800;
    border: 3px solid var(--tv-bg);
  }

  .tv-bottom-nav__post.is-active {
    transform: scale(1.05);
  }
}

@media (min-width: 769px) {
  .tv-mobile-bar { display: none !important; }
}

@media (max-width: 768px) {
  .tv-page-banner {
    padding: 24px 0 28px;
    border-radius: 0 0 16px 16px;
    margin-bottom: 4px;
  }

  .tv-page-banner h1 { font-size: 1.35rem; }

  .tv-promo-strip {
    margin-top: 24px;
    padding: 22px 18px;
    border-radius: 14px;
  }

  .tv-promo-strip .tv-btn { width: 100%; }
}

@media (max-width: 380px) {
  .tv-trust { grid-template-columns: 1fr; }
  html[data-md-cards="2"] .tv-cards { grid-template-columns: 1fr; }
}
