/* ============================================================
   九零管乐 · 手机 / 平板专用布局层
   在页面原有样式之后加载，只覆盖断点内的布局与触控尺寸。
   手机：≤767px    平板：768–1023px    桌面：≥1024px
   ============================================================ */

/* ---------- 导航：手机/平板统一抽屉 ---------- */
.nav-toggle {
  display: none;
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: .45rem;
  padding: 0;
  border: 1px solid rgba(201, 162, 94, .32);
  border-radius: 10px;
  background: rgba(15, 14, 13, .62);
  color: #E4C68A;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
  transition: transform .25s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.rmenu {
  position: fixed;
  inset: 0;
  z-index: 10060;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
}
.rmenu.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.rmenu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 4, .68);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.rmenu-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(86vw, 360px);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  background: #121214;
  border-left: 1px solid rgba(201, 162, 94, .28);
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.22, .61, .36, 1);
  overflow-y: auto;
}
.rmenu.open .rmenu-panel { transform: translateX(0); }
.rmenu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: .9rem;
  border-bottom: 1px solid rgba(201, 162, 94, .18);
}
.rmenu-brand {
  color: #C9A25E;
  font-family: 'Noto Serif SC', serif;
  font-size: 1rem;
  letter-spacing: .18em;
}
.rmenu-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(201, 162, 94, .25);
  border-radius: 50%;
  background: transparent;
  color: #BDB3A3;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.rmenu-links {
  display: flex;
  flex-direction: column;
  margin-top: .7rem;
}
.rmenu-links a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 .15rem;
  color: #E9DECB;
  font-family: 'Noto Serif SC', serif;
  font-size: 1rem;
  letter-spacing: .07em;
  border-bottom: 1px solid rgba(201, 162, 94, .10);
  text-decoration: none;
}
.rmenu-links a:active { color: #E4C68A; }
.rmenu-cta {
  display: grid;
  gap: .5rem;
  margin-top: auto;
  padding-top: 1rem;
}
.rmenu-cta a,
.rmenu-cta button {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 162, 94, .35);
  border-radius: 10px;
  background: transparent;
  color: #E4C68A;
  font-family: 'Noto Serif SC', serif;
  font-size: .86rem;
  letter-spacing: .08em;
  text-decoration: none;
  cursor: pointer;
}
.rmenu-cta a.primary {
  background: #C9A25E;
  border-color: #C9A25E;
  color: #121214;
}

/* ---------- 手机 / 平板：隐藏桌面导航，保留抽屉 ---------- */
@media (max-width: 1023px) {
  .nav-links { display: none !important; }
  .nav-back { display: none !important; }
  .nav-toggle { display: inline-flex; }
  .chat-toggle-top { display: none !important; }
  .chat-toggle.scroll-hide { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }
  .nav { padding-left: 1rem; padding-right: 1rem; }

  .nav-services {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-left: 1rem;
    padding-right: 1rem;
    gap: 1.25rem;
  }
  .nav-services::-webkit-scrollbar { display: none; }
  .nav-services a { flex: none; white-space: nowrap; }
  .card-spot { display: none !important; }
  #condNewSide, #condUsedSide,
  *:has(> #condNewSide), *:has(> #condUsedSide) { display: none !important; }
}

/* ---------- 平板：两列布局 ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  .services-grid,
  .inventory-grid,
  .custom-grid,
  .content-grid,
  .contact-grid { grid-template-columns: repeat(2, 1fr) !important; }

  .plan-grid,
  .highlight-grid,
  .gallery-strip { grid-template-columns: repeat(2, 1fr) !important; }

  .instrument-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.2rem !important;
    padding: 1.2rem 1.4rem 2.4rem !important;
  }
  .instrument-body { padding: 1.35rem; }
  .instrument-img { height: 210px; }

  .section-desc,
  .phil-text { max-width: 44em; }
  .content-grid { gap: 2.4rem; }
}

/* ---------- 手机：单列布局 ---------- */
@media (max-width: 767px) {
  .services-grid,
  .inventory-grid,
  .custom-grid,
  .content-grid,
  .contact-grid,
  .plan-grid,
  .highlight-grid,
  .craft-grid,
  .gallery-strip,
  .phil-grid { grid-template-columns: 1fr !important; }

  .instrument-grid {
    grid-template-columns: 1fr !important;
    gap: 1.1rem !important;
    padding: .8rem 1rem 2.2rem !important;
  }
  .instrument-card .instrument-img { height: 220px; }
  .instrument-body { padding: 1.25rem; }
  .instrument-name { font-size: 1.08rem; }
  .instrument-desc { font-size: .82rem; line-height: 1.78; }

  .content-grid { gap: 1.8rem; }
  .contact-grid { gap: 2rem; }
  .section-desc { max-width: 100%; }

  /* 商品详情弹层：双列改单列 */
  .detail-body,
  .detail-panel,
  .instrument-detail { grid-template-columns: 1fr !important; }

  /* 服务记录弹层 */
  .rec-panel { width: min(94vw, 620px); }
  .rec-panel-actions .hbtn { min-height: 44px; }
}

/* ---------- 触控尺寸 ---------- */
@media (pointer: coarse) {
  .nav-toggle,
  .rmenu-close,
  .chat-toggle { min-width: 44px; min-height: 44px; }

  .filter-btn,
  .chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-top: .55rem;
    padding-bottom: .55rem;
  }
  .btn,
  .jl-btn { min-height: 44px; }
  .service-link,
  .instrument-cta { padding-top: .5rem; padding-bottom: .5rem; }
}

/* ---------- 安全区 ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
  .nav { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  .chat-toggle { bottom: max(1rem, env(safe-area-inset-bottom)); }
  .rmenu-panel { padding-bottom: max(1.1rem, env(safe-area-inset-bottom)); }
}

/* ---------- 小屏兜底 ---------- */
@media (max-width: 360px) {
  .nav-brand { font-size: .95rem; }
  .instrument-card .instrument-img { height: 190px; }
  .rmenu-panel { width: 92vw; }
}

/* 125% Windows / 浏览器缩放：大屏多用一点宽度，避免内容显得偏窄 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (min-width: 1181px) and (min-resolution: 1.25dppx) {
  .container { max-width: 1240px; }
  .nav { padding-left: 2.6rem; padding-right: 2.6rem; }
  .nav.scrolled { padding-left: 2.6rem; padding-right: 2.6rem; }
}
@media (min-width: 1600px) {
  .container { max-width: 1280px; }
}

/* 地图缩略图：避免 min-height + aspect-ratio 把宽度撑出屏幕 */
.contact-grid > * { min-width: 0; }
.contact-map { min-height: 0; max-width: 100%; }
