/* H5 shell: real browser viewport, safe areas and touch targets. */
:root { --h5-width: 480px; --h5-bar-height: 72px; color-scheme: light dark; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 72px; }
body { min-width: 280px; margin: 0; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
*, *::before, *::after { box-sizing: border-box; }
#haojia-connected { padding: 0; width: 100%; max-width: var(--h5-width); margin: 0 auto; }
#haojia-connected [data-page] > div { width: 100%; padding: 0; }
#haojia-connected :is(.hd-phone,.pd-phone,.wl-phone,.ac-phone) {
  max-width: none; width: 100%; min-height: 100vh; min-height: 100dvh;
  border: 0; border-radius: 0; box-shadow: none; overflow: visible;
  padding-bottom: calc(var(--h5-bar-height) + env(safe-area-inset-bottom, 0px) + 16px);
}
#haojia-connected :is(.hd-status,.pd-status,.wl-status,.ac-status) { display: none; }
#haojia-connected :is(button,summary,select) { touch-action: manipulation; }
#haojia-connected button { min-height: 44px; }
#haojia-connected :is(input:not([type=checkbox]),select,textarea) { font-size: 16px !important; }
#haojia-connected :is(.hd-body,.pd-content,.wl-body,.ac-body,.pd-info,.hd-header,.wl-head,.ac-header) {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#haojia-connected :is(.hd-header,.wl-head,.ac-header) { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
#haojia-connected :is(.hd-nav,.wl-footer,.ac-nav,footer.pd-footer) {
  position: fixed; z-index: 40; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: var(--h5-width); margin: 0;
  padding: 8px max(12px,env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(12px,env(safe-area-inset-left, 0px));
  box-shadow: 0 -3px 18px light-dark(#302c2908,#00000018);
}
#haojia-connected :is(.hd-nav,.wl-footer,.ac-nav) button {
  flex: 1; min-width: 0; min-height: 52px; padding: 3px 0; gap: 3px; font-size: 12px;
}
#haojia-connected .hd-form { min-width: 0; }
#haojia-connected .hd-form input { width: 0; flex: 1; }
#haojia-connected .hd-categories { gap: 16px 4px; }
#haojia-connected .hd-category { min-height: 72px; font-size: 12px; }
#haojia-connected .hd-category-icon { width: 46px; height: 46px; }
#haojia-connected .hd-platforms { gap: 8px; grid-template-columns: 1fr 1.4fr 1fr .85fr; }
#haojia-connected .hd-product-visual { height: clamp(130px,39vw,186px); }
#haojia-connected .hd-product-info h4 { font-size: 14px; }
#haojia-connected .hd-price { font-size: 24px; }
#haojia-connected .hd-small,#haojia-connected .hd-spec { font-size: 12px; }
#haojia-connected .hd-save { width: 44px; height: 44px; right: 2px; top: 2px; }
#haojia-connected .pd-top {
  position: sticky; top: 0; z-index: 30; min-height: 60px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-left: max(12px,env(safe-area-inset-left, 0px));
  padding-right: max(12px,env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--pd-line);
}
#haojia-connected .pd-icon { width: 44px; height: 44px; }
#haojia-connected .pd-hero { height: clamp(180px,52vw,250px); }
#haojia-connected .pd-offer-top > div:first-child { flex: 1; min-width: 0; }
#haojia-connected .pd-offer-purchase { max-width: 47%; }
#haojia-connected .pd-offer-price { white-space: nowrap; font-size: clamp(20px,5.8vw,26px); }
#haojia-connected .pd-target-row { flex-wrap: wrap; }
#haojia-connected .pd-target-row input { flex: 1 1 140px; width: 0; }
#haojia-connected .pd-target-row button { flex: 0 0 auto; }
#haojia-connected footer.pd-footer { gap: 10px; }
#haojia-connected footer.pd-footer button { min-width: 0; min-height: 48px; }
#haojia-connected footer.pd-footer .pd-main { flex: 1.6; }
#haojia-connected div.pd-footer { border: 0; background: none; padding-top: 0; }
#haojia-connected .pd-small,#haojia-connected .pd-notice { font-size: 12px; }
#haojia-connected .pd-offer summary { min-height: 40px; }
#haojia-connected .wl-actions { flex-wrap: wrap; }
#haojia-connected .wl-actions button { min-width: 0; }
#haojia-connected .wl-primary { white-space: normal; }
#haojia-connected .wl-small,#haojia-connected .wl-rule { font-size: 12px; }
#haojia-connected .ac-row span:first-of-type { min-width: 0; }
#haojia-connected .ac-value { flex-shrink: 0; }
#haojia-connected .ac-small { font-size: 12px; }
#haojia-connected .ac-panel label { min-height: 44px; }
#haojia-connected .ac-header h2 { font-size: clamp(18px,5vw,21px); }
#haojia-connected.keyboard-open :is(.hd-nav,.wl-footer,.ac-nav,footer.pd-footer) { display: none; }
@media(max-width:340px) {
  #haojia-connected .hd-grid { gap: 10px; }
  #haojia-connected .hd-product-info { padding: 10px; }
  #haojia-connected .hd-compare { font-size: 11px; }
  #haojia-connected .pd-target-row { display: grid; grid-template-columns: minmax(0,1fr); }
  #haojia-connected .pd-target-row input { width: 100%; }
  #haojia-connected .wl-tabs { gap: 15px; }
}
@media(orientation:landscape) and (max-height:500px) {
  #haojia-connected .pd-hero { height: 140px; }
  #haojia-connected .hd-product-visual { height: 125px; }
}

/* Category browsing has an independent sidebar and product list. */
#hj-category { color: #302d29; background: #faf9f6; font-family: -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif; }
#hj-category button { font: inherit; cursor: pointer; border: 0; }
#hj-category .cg-phone { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(88px + env(safe-area-inset-bottom,0px)); }
.cg-header { padding: calc(18px + env(safe-area-inset-top,0px)) 20px 18px; background: #fffdfa; border-bottom: 1px solid #eee9e2; }
.cg-header h2 { margin: 0; font-size: 22px; }
.cg-layout { display: grid; grid-template-columns: 78px minmax(0,1fr); align-items: start; }
#cg-categories { position: sticky; top: 0; display: grid; background: #f1eee8; padding: 8px 0; }
#cg-categories button { position: relative; background: transparent; padding: 18px 2px; color: #7d756d; font-size: 12px; }
#cg-categories button[aria-pressed=true] { background: #faf9f6; color: #b84c36; font-weight: 600; }
#cg-categories button[aria-pressed=true]::before { content: ''; position: absolute; left: 0; top: 20px; bottom: 20px; width: 3px; background: #b84c36; border-radius: 3px; }
.cg-main { padding: 16px 12px; min-width: 0; }
.cg-main h3 { font-size: 17px; margin: 0 0 8px; }
#cg-subcategories { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
#cg-subcategories::-webkit-scrollbar { display: none; }
#cg-subcategories button { flex: 0 0 auto; background: transparent; border-radius: 16px; padding: 8px 10px; font-size: 12px; color: #81796f; white-space: nowrap; }
#cg-subcategories button[aria-pressed=true] { color: #a54431; background: #faeee7; }
#cg-count { color: #92877d; font-size: 11px; margin: 8px 0 0; }
.cg-product { display: flex; align-items: flex-start; gap: 12px; padding: 16px 0; border-bottom: 1px solid #eae5dc; }
#hj-category .cg-art { display: grid; place-items: center; flex: 0 0 clamp(80px,22vw,104px); height: clamp(100px,27vw,128px); background: #eee9df; color: #8f8375; border-radius: 10px; }
.cg-art svg { width: 48px; height: 48px; }
.cg-art .hj-icon { font-size: 42px; }
.cg-product-info { min-width: 0; flex: 1; }
#hj-category .cg-name { display: block; text-align: left; padding: 0; background: transparent; min-height: 28px; font-size: 15px; font-weight: 600; color: #302d29; }
.cg-product-info p { font-size: 11px; line-height: 1.6; color: #8b8176; margin: 4px 0; }
.cg-product-info strong { display: block; color: #b84c36; font-size: 23px; margin-top: 6px; }
.cg-product-info small { font-size: 11px; font-weight: 400; margin-left: 4px; }
#hj-category .cg-compare { background: transparent; color: #9f4b39; padding: 6px 0; font-size: 12px; text-align: left; }
.cg-notice { font-size: 11px; color: #93897e; line-height: 1.8; margin: 20px 0 0; }
#hj-category .cg-nav { display: flex; position: fixed; z-index: 40; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: #fffdfa; border-top: 1px solid #eae5dc; padding: 8px 12px calc(8px + env(safe-area-inset-bottom,0px)); }
#hj-category .cg-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 52px; font-size: 12px; background: transparent; color: #8b8176; }
#hj-category .cg-nav button[aria-pressed=true] { color: #b84c36; font-weight: 600; }
@media(max-width:340px) { .cg-layout { grid-template-columns: 76px minmax(0,1fr); } .cg-main { padding: 18px 10px; } .cg-product { gap: 8px; } #hj-category .cg-art { flex-basis: 64px; height: 88px; } }
#hj-category .cg-art i { font-size: 42px !important; }

/* Discovery leads with cross-platform prices; filters stay collapsed. */
#hj-discovery-v2 .hd-feed-heading { display: flex; align-items: baseline; justify-content: space-between; position: relative; gap: 12px; margin: 20px 0 4px; }
#hj-discovery-v2 .hd-feed-heading h3 { font-size: 22px; font-weight: 600; }
#hj-discovery-v2 #hd-filters { position: static; }
#hj-discovery-v2 #hd-filter-toggle { cursor: pointer; display: flex; align-items: center; min-height: 44px; list-style: none; font-size: 12px; color: var(--hd-muted); }
#hd-filter-toggle::-webkit-details-marker { display: none; }
#hj-discovery-v2 .hd-filter-panel { position: absolute; z-index: 35; top: 48px; left: 0; right: 0; background: var(--hd-panel); border: 1px solid var(--hd-line); box-shadow: 0 12px 24px #302c291c; border-radius: 12px; padding: 16px; }
#hj-discovery-v2 .hd-filter-panel p { margin: 0 0 8px; font-size: 13px; }
#hd-category-area,.hd-sort-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
#hj-discovery-v2 .hd-filter-panel button { border: 0; border-radius: 8px; background: var(--hd-bg); color: var(--hd-muted); padding: 8px 10px; font-size: 12px; }
#hj-discovery-v2 .hd-filter-panel button[aria-pressed=true] { background: var(--hd-soft); color: var(--hd-accent); }
#hj-discovery-v2 #hd-reset-filters { background: transparent; color: var(--hd-accent); }
#hj-discovery-v2 .hd-source { margin-bottom: 14px; font-size: 11px; }
#hj-discovery-v2 .hd-art { border: 0; padding: 0; background: transparent; display: grid; place-items: center; width: 100%; height: 100%; color: inherit; cursor: pointer; }
#hj-discovery-v2 .hd-art i { font-size: 48px !important; }
#hj-discovery-v2 .hd-product-name { display: block; background: transparent; border: 0; padding: 0; min-height: 28px; text-align: left; color: var(--hd-text); font-size: 15px; font-weight: 600; }
#hj-discovery-v2 .hd-spec { min-height: 36px; font-size: 11px; }
#hj-discovery-v2 .hd-low-label { font-size: 10px; color: var(--hd-muted); margin-top: 8px; }
#hj-discovery-v2 .hd-price { margin-top: 2px; font-size: 28px; font-weight: 600; }
#hj-discovery-v2 .hd-low-platform { color: var(--hd-text); font-size: 12px; margin-top: 2px; }
#hj-discovery-v2 .hd-gap { font-size: 11px; color: var(--hd-accent); margin-top: 6px; }
#hj-discovery-v2 .hd-compare { margin-top: 10px; color: var(--hd-accent); }

/* Settings open in the viewport and remain above the mobile navigation. */
#hj-account dialog.ac-panel {
  position: fixed; inset: auto auto 0 50%; transform: translateX(-50%);
  width: min(100%,480px); max-width: 480px; max-height: 85vh; max-height: 85dvh;
  margin: 0; padding: 20px max(20px,env(safe-area-inset-right,0px)) calc(24px + env(safe-area-inset-bottom,0px)) max(20px,env(safe-area-inset-left,0px));
  border: 1px solid var(--ac-line); border-bottom: 0; border-radius: 20px 20px 0 0;
  background: var(--ac-panel); color: var(--ac-text); overflow-y: auto;
  overscroll-behavior: contain; box-shadow: 0 -8px 32px #302c291c;
}
#hj-account dialog.ac-panel::backdrop { background: #211e1b66; }
#hj-account dialog .ac-close { min-width: 52px; min-height: 44px; }
#hj-account dialog select { min-height: 48px; }
#hj-account dialog .ac-main { width: 100%; min-height: 48px; }
#hj-account dialog label { min-height: 48px; }
body:has(#ac-panel[open]) { overflow: hidden; }

#hj-product-detail dialog.pd-follow-panel {
  position: fixed; inset: auto auto 0 50%; transform: translateX(-50%);
  width: min(100%,480px); max-width: 480px; max-height: 85vh; max-height: 85dvh;
  margin: 0; padding: 20px max(20px,env(safe-area-inset-right,0px)) calc(24px + env(safe-area-inset-bottom,0px)) max(20px,env(safe-area-inset-left,0px));
  border: 1px solid var(--pd-line); border-bottom: 0; border-radius: 20px 20px 0 0;
  background: var(--pd-panel); color: var(--pd-text); overflow-y: auto;
  overscroll-behavior: contain; box-shadow: 0 -8px 32px #302c291c;
}
#hj-product-detail dialog.pd-follow-panel::backdrop { background: #211e1b66; }
#hj-product-detail .pd-follow-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#hj-product-detail #pd-follow-close { min-width: 52px; min-height: 44px; }
#hj-product-detail dialog .pd-target-row { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
#hj-product-detail dialog .pd-target-row input { flex: auto; width: 100%; min-height: 48px; }
#hj-product-detail dialog .pd-target-row button { min-height: 48px; width: 100%; }
#hj-product-detail #pd-follow-error { color: var(--pd-accent); font-size: 12px; margin-top: 8px; }
#hj-product-detail #pd-follow-error:empty { display: none; }
#hj-product-detail #pd-target[aria-invalid=true] { border-color: var(--pd-accent); }
body:has(#pd-follow-panel[open]) { overflow: hidden; }

#hj-discovery-v2 .hd-birthday-entry { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; border: 0; border-radius: 8px; margin: 10px 0 0; padding: 10px 12px; background: var(--hd-soft); color: var(--hd-accent); font-size: 13px; }
#hj-discovery-v2 .hd-birthday-entry span { color: var(--hd-muted); font-size: 11px; }
#hj-account .ac-birthday-group { margin-top: 12px; }
#hj-birthday { background: #f8f7f4; color: #302c29; font-family: -apple-system,BlinkMacSystemFont,'PingFang SC','Microsoft YaHei',sans-serif; min-height: 100vh; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom,0px); line-height: 1.65; }
#hj-birthday button,#hj-birthday select { font: inherit; }
#hj-birthday button { cursor: pointer; }
#hj-birthday h2,#hj-birthday h3,#hj-birthday h4,#hj-birthday p { margin: 0; }
#hj-birthday h3 { font-size: 17px; }
#hj-birthday .bd-header { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top,0px)) 16px 10px; background: #fff; border-bottom: 1px solid #eae6e1; }
#hj-birthday .bd-header h2 { font-size: 18px; font-weight: 500; }
#hj-birthday #bd-back { background: transparent; border: 0; min-width: 44px; font-size: 22px; color: #302c29; }
.bd-body { padding: 16px; }
.bd-intro { padding: 8px 2px 20px; }
.bd-eyebrow { color: #b84c36; font-size: 12px; }
#hj-birthday .bd-intro h3 { font-size: 24px; margin: 6px 0; }
#hj-birthday .bd-intro p { font-size: 13px; color: #7c756e; }
#bd-form,.bd-live,.bd-card { background: #fff; border: 1px solid #eae6e1; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
#hj-birthday .bd-muted { color: #7c756e; font-size: 12px; margin-top: 8px; }
.bd-date { display: flex; gap: 12px; margin-top: 16px; }
.bd-date label { flex: 1; font-size: 13px; }
.bd-date select { display: block; width: 100%; min-height: 48px; margin-top: 4px; border: 1px solid #eae6e1; border-radius: 8px; background: #f8f7f4; color: #302c29; padding: 8px; }
.bd-actions { display: flex; gap: 12px; margin-top: 14px; }
#hj-birthday .bd-actions button { border: 0; border-radius: 8px; padding: 10px 16px; background: #f1eeea; color: #7c756e; font-size: 13px; }
#hj-birthday .bd-actions .bd-primary { flex: 1; background: #b84c36; color: #fff; }
#bd-feedback { color: #b84c36; font-size: 12px; margin-top: 8px !important; }
#hj-birthday .bd-live > p { font-size: 13px; margin-top: 10px; }
.bd-examples > h3 { margin-top: 24px !important; }
.bd-examples > p { margin-bottom: 12px !important; }
.bd-badge { font-size: 11px; color: #a34732; }
#hj-birthday h4 { font-size: 18px; margin: 8px 0; }
.bd-card > p { font-size: 13px; color: #7c756e; }
.bd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.bd-tags span { background: #f1eeea; border-radius: 4px; padding: 3px 6px; font-size: 11px; color: #7c756e; }
.bd-card details { border-top: 1px solid #eae6e1; padding-top: 10px; font-size: 12px; }
.bd-card summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.bd-card ol { padding-left: 20px; }
#hj-birthday .bd-card button:disabled { width: 100%; margin-top: 14px; min-height: 44px; border: 0; border-radius: 8px; background: #f1eeea; color: #827970; font-size: 12px; cursor: default; }
