/* UI rules and responsive acceptance criteria: ../../UI_RULES.md */
:root {
  color-scheme: light;
  --blue: #9cd4f6;
  --blue-dark: #236e98;
  --ink: #233f52;
  --muted: #5c7180;
  --line: #e6edf2;
  --pale: #edf7fc;
  --surface: #fff;
  --canvas: #eef6fb;
  --focus: #236e98;
  --font: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --app-width: 480px;
  --gutter: 20px;
  --thumb: 104px;
  --rail-width: 76px;
  --category-thumb: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-ui-height: calc(72px + var(--safe-bottom));
  --search-ui-height: 72px;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; border: 0; background: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
.icon { width: 24px; height: 24px; flex: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* One page width and one measured bottom inset, shared across routes. */
.app-shell {
  width: 100%; max-width: var(--app-width); min-height: 100vh; min-height: 100dvh;
  margin-inline: auto; padding-bottom: calc(var(--bottom-ui-height) + 20px);
  display: flex; flex-direction: column; background: var(--surface);
  box-shadow: 0 0 64px #183f5708;
}
.app-shell > * { flex-shrink: 0; }
.page-header { position: relative; display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 16px var(--gutter); }
.page-header h1 { font-size: 20px; font-weight: 600; line-height: 1.4; letter-spacing: .04em; }
.back-button { position: absolute; left: 8px; width: 44px; height: 44px; display: grid; place-items: center; }
.hero { height: 180px; margin: 0 var(--gutter) 8px; border-radius: 12px; overflow: hidden; position: relative; background: #c6e8f7; }
.hero-image { position: absolute; width: 100%; height: 100%; object-fit: cover; inset: 0; }
.hero-copy { position: relative; padding: 24px; max-width: 80%; }
.eyebrow { font-size: 12px; letter-spacing: .1em; color: #486f84; }
.hero-copy h2 { font-size: 24px; line-height: 1.6; font-weight: 500; letter-spacing: .04em; margin-top: 8px; }
.hero-copy p { font-size: 12px; letter-spacing: .06em; margin-top: 8px; color: #486f84; }
.search-sticky { position: sticky; top: 0; z-index: 20; background: #fffffff5; padding: 12px var(--gutter); }
.search-form { min-height: 48px; border-radius: 12px; background: #f2f6f8; display: flex; align-items: center; padding: 0 12px; gap: 8px; }
.search-form:focus-within { box-shadow: 0 0 0 2px var(--focus); }
.search-form input { border: 0; background: none; outline: 0; min-width: 0; width: 100%; font-size: 16px; color: var(--ink); padding: 12px 0; }
.search-form > .icon { width: 20px; height: 20px; color: var(--muted); }
.search-form input::placeholder { color: var(--muted); }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; place-items: center; flex: none; width: 44px; height: 44px; color: var(--muted); padding: 12px; margin-right: -8px; }
.search-clear .icon { width: 18px; height: 18px; }
.home-content { padding: 0 var(--gutter); }
.filter-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); padding: 0 0 12px; margin-bottom: 8px; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tabs button { position: relative; min-height: 44px; padding: 10px 16px; white-space: nowrap; border-radius: 24px; font-size: 14px; flex: 1 0 auto; color: var(--muted); }
.filter-tabs button.active { color: var(--blue-dark); background: var(--pale); font-weight: 600; }
.filter-tabs button.active::after { content: ''; height: 2px; width: 16px; border-radius: 2px; background: currentColor; position: absolute; bottom: 4px; left: calc(50% - 8px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 8px 0 0; }
.section-heading h2 { font-size: 17px; font-weight: 600; line-height: 1.5; }
.section-heading a, .section-heading > span { color: var(--muted); font-size: 13px; font-weight: 400; white-space: nowrap; }
.section-heading a { display: inline-flex; align-items: center; min-height: 44px; padding-left: 12px; }

/* The action lives in the price row. Never float it or offset it upwards. */
.product-row { display: grid; grid-template-columns: var(--thumb) minmax(0,1fr); align-items: start; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.product-image-link { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #f3f7fa; }
.product-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.product-copy { min-width: 0; min-height: var(--thumb); display: flex; flex-direction: column; }
.product-details { display: block; min-width: 0; }
.product-copy h3 { font-size: 16px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.product-category { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-bottom { display: grid; grid-template-columns: minmax(0,1fr) 44px; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; }
.product-price-link { min-width: 0; display: flex; align-items: center; min-height: 44px; }
.price { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; max-width: 100%; font-size: 20px; font-weight: 500; color: var(--blue-dark); font-variant-numeric: tabular-nums; line-height: 1.4; }
.price-amount { white-space: nowrap; }
.price small { font-size: 13px; font-weight: 400; }
.price .unit { font-size: 12px; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.price-long { font-size: 14px; }
.price-pending { font-size: 14px; color: var(--muted); }
.heart-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--pale); color: var(--blue-dark); padding: 10px; transition: background .15s; }
.heart-button .icon { width: 22px; height: 22px; }
.heart-button.is-selected { color: var(--blue-dark); background: #dcedf8; }
.heart-button.is-selected .icon { fill: currentColor; stroke-width: 1.3; }
.remove-button { color: var(--muted); background: #f2f6f8; }
.page-note { font-size: 12px; line-height: 1.7; text-align: center; color: var(--muted); padding: 24px var(--gutter) 4px; }
.studio-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 4px; color: var(--blue-dark); font-size: 13px; text-underline-offset: 4px; }
.studio-link:hover { text-decoration: underline; }

/* The 480px shell is a mobile preview on desktops, never an enlarged phone. */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--app-width); padding: 8px 12px calc(8px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line); z-index: 30; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.nav-item { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; font-size: 12px; line-height: 18px; color: var(--muted); min-height: 56px; }
.nav-item.active { color: var(--blue-dark); font-weight: 500; }
.nav-icon { position: relative; height: 24px; }
.nav-item .icon { width: 24px; height: 24px; }
.nav-item.active .icon { fill: #d4edfc; stroke: var(--blue-dark); }
.nav-count { position: absolute; top: -4px; right: -12px; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; font-size: 10px; padding: 0 4px; line-height: 1; background: var(--blue-dark); color: white; border: 1px solid white; }

/* Category rows reuse the same price/action structure at every width. */
.category-layout { display: grid; grid-template-columns: var(--rail-width) minmax(0,1fr); align-items: start; }
.category-rail { position: sticky; top: var(--search-ui-height); max-height: calc(100dvh - var(--search-ui-height) - var(--bottom-ui-height)); overflow-y: auto; overscroll-behavior: contain; background: #f5f9fc; padding: 8px 0; border-radius: 0 12px 12px 0; }
.category-rail button { display: block; width: 100%; min-height: 56px; padding: 12px 8px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; position: relative; color: var(--muted); }
.category-rail button.active { background: #e8f4fc; color: var(--blue-dark); font-weight: 600; }
.category-rail button.active::before { content: ''; position: absolute; left: 0; top: calc(50% - 12px); width: 3px; height: 24px; background: var(--blue-dark); border-radius: 0 4px 4px 0; }
.category-layout .browse-content { min-width: 0; padding: 0 16px 0 12px; }
.subcategory-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.subcategory-tabs button { min-height: 44px; font-size: 13px; line-height: 1.5; padding: 8px 12px; border-radius: 8px; background: #f3f7fa; color: var(--muted); }
.subcategory-tabs .active { background: #e8f4fc; color: var(--blue-dark); font-weight: 500; }
.category-layout .product-row { --thumb: var(--category-thumb); gap: 12px; }
.category-layout .product-copy h3 { font-size: 15px; }
.category-layout .product-category { font-size: 12px; }
.category-layout .price { font-size: 18px; }
.category-layout .price-long, .category-layout .price-pending { font-size: 13px; }
.category-layout .section-heading h2 { font-size: 16px; }
.category-layout + .page-note { margin-top: auto; }

.selection-content { padding: 0 var(--gutter); }
.selection-banner { position: relative; height: 164px; border-radius: 12px; overflow: hidden; background: #d8effb; margin-bottom: 24px; }
.selection-banner .hero-image { opacity: .78; object-position: center; }
.selection-banner-copy { position: relative; padding: 24px 20px; }
.selection-banner-copy > p:last-child { font-size: 13px; color: #486f84; margin-top: 4px; }
.selection-counter { font-size: 16px; display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.selection-counter strong { font-size: 32px; font-weight: 500; line-height: 1.5; font-variant-numeric: tabular-nums; }
.selection-group { margin-bottom: 24px; }
.selection-group .section-heading { justify-content: flex-start; gap: 12px; }
.selection-group .product-row:last-child { border-bottom: 0; }
.continue-button { margin-top: 8px; width: 100%; }
.button { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; padding: 12px 20px; border-radius: 10px; font-size: 16px; font-weight: 500; transition: background .15s; }
.primary { background: var(--blue); color: #254e65; }
.primary:hover { background: #87c9ee; }
.secondary { background: var(--pale); color: var(--blue-dark); }
.selection-hint { font-size: 12px; line-height: 1.7; color: var(--muted); text-align: center; margin-top: 12px; }
.selection-submit-error { padding: 12px var(--gutter) 0; color: #a44343; font-size: 13px; line-height: 1.7; }
.selection-dock { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--app-width); z-index: 30; background: var(--surface); box-shadow: 0 -4px 20px #294b6008; }
.selection-dock .bottom-nav { position: static; transform: none; width: 100%; max-width: none; }
.selection-submit-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--gutter); border-top: 1px solid var(--line); }
.selection-submit-bar p { font-size: 15px; }
.selection-submit-bar strong { font-weight: 600; color: var(--blue-dark); }
.selection-submit-bar span { display: block; font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 4px; }
.selection-submit-bar .button { flex: none; min-width: 120px; }

.detail-content { padding-bottom: 12px; }
.detail-image { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f7fa; }
.detail-body { padding: 24px var(--gutter) 0; }
.detail-category { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.detail-body > h2 { font-size: 24px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.detail-summary { font-size: 15px; line-height: 1.8; color: var(--muted); margin: 8px 0 16px; }
.detail-body > .price { font-size: 28px; }
.detail-body > .price small { font-size: 16px; }
.detail-body > .price .unit { font-size: 14px; }
.detail-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.detail-section h3 { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.detail-section dl { margin: 0; display: grid; gap: 16px; font-size: 14px; }
.detail-section dl > div { display: grid; grid-template-columns: 80px minmax(0,1fr); gap: 12px; line-height: 1.6; }
.detail-section dt { color: var(--muted); }
.detail-section dd { margin: 0; overflow-wrap: anywhere; }
.description { font-size: 16px; line-height: 1.9; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-action { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: var(--app-width); padding: 12px var(--gutter) calc(12px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line); z-index: 30; }
.detail-action .button { width: 100%; }
.detail-action .saved .icon { fill: currentColor; }
.empty-state { padding: 40px 12px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.empty-state > .icon { width: 44px; height: 44px; color: var(--blue-dark); margin-bottom: 16px; }
.empty-state h1, .empty-state h2 { font-size: 18px; font-weight: 500; }
.empty-state p { font-size: 14px; color: var(--muted); line-height: 1.8; margin-top: 12px; max-width: 260px; }
.empty-state .button { margin-top: 24px; }
.loading { text-align: center; color: var(--muted); padding: 120px 20px; }
.toast { position: fixed; bottom: calc(96px + var(--safe-bottom)); left: 50%; transform: translate(-50%,8px); z-index: 100; color: white; background: #294b60f5; border-radius: 8px; padding: 12px 20px; font-size: 14px; line-height: 1.5; opacity: 0; pointer-events: none; transition: opacity .18s,transform .18s; text-align: center; max-width: 90vw; }
.toast.visible { opacity: 1; transform: translate(-50%,0); }
.submission-content { padding: 24px var(--gutter); }
.submission-content h2, .submission-success h2 { font-size: 20px; font-weight: 500; }
.submission-success { padding: 64px var(--gutter); text-align: center; }
.submission-success > .icon { width: 56px; height: 56px; color: var(--blue-dark); background: var(--pale); padding: 12px; border-radius: 50%; margin-bottom: 24px; }
.submission-success > p { color: var(--muted); font-size: 14px; margin: 16px 0; }
.receipt { background: #f2f8fc; padding: 20px; border-radius: 12px; line-height: 2; font-size: 13px !important; overflow-wrap: anywhere; }
.receipt strong { font-weight: 500; color: var(--blue-dark); }
.privacy-body { white-space: pre-wrap; font-size: 16px; line-height: 1.9; color: var(--muted); margin-top: 24px; }
.product-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #f3f8fb; color: #648c9e; font-size: 36px; }
.detail-image.product-placeholder { height: 240px; aspect-ratio: auto; font-size: 72px; }

@media (max-width: 359px) {
  :root { --gutter: 16px; --thumb: 88px; --rail-width: 64px; --category-thumb: 64px; }
  .hero { height: 164px; }
  .hero-copy { padding: 20px; max-width: 88%; }
  .hero-copy h2 { font-size: 22px; }
  .product-row { gap: 12px; }
  .product-copy h3 { font-size: 15px; }
  .category-layout .browse-content { padding-inline: 8px 12px; }
  .category-layout .product-row { gap: 8px; }
  .category-layout .product-bottom { gap: 4px; }
  .category-layout .price { font-size: 16px; }
  .category-layout .price-long, .category-layout .price-pending { font-size: 12px; }
  .subcategory-tabs { gap: 4px; }
  .subcategory-tabs button { padding-inline: 8px; }
  .selection-banner-copy { padding-inline: 16px; }
  .selection-submit-bar .button { min-width: 108px; padding-inline: 16px; }
}
@media (min-width: 414px) {
  :root { --gutter: 24px; --thumb: 112px; --rail-width: 80px; --category-thumb: 88px; }
  .category-layout .browse-content { padding-inline: 16px 20px; }
  .hero { height: 192px; }
  .product-row { padding-block: 20px; }
  .category-layout .product-row { padding-block: 16px; }
}
@media (hover: hover) and (pointer: fine) {
  .product-image-link:hover .product-thumb { transform: scale(1.03); }
  .heart-button:hover { background: #dceef8; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
