:root {
  --canvas: var(--wm-color-canvas);
  --panel: var(--wm-color-surface);
  --ink: var(--wm-color-ink);
  --muted: var(--wm-color-muted);
  --muted-soft: var(--wm-color-muted-soft);
  --teal: var(--wm-color-primary);
  --teal-deep: var(--wm-color-action);
  --teal-soft: var(--wm-color-primary-soft);
  --orange: var(--wm-color-accent);
  --line: var(--wm-color-line);
  --line-strong: var(--wm-color-line-strong);
  --page-width: var(--mobile-shell-content-width, 346.56px);
  --device-height: 760px;
  --bottom-nav-height: 62px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--wm-color-app-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--wm-color-app-bg);
  font-family: var(--wm-font-ui);
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

button { border: 0; cursor: pointer; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.ranking-page {
  position: relative;
  width: min(100%, var(--page-width));
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: var(--canvas);
}

.ranking-topbar {
  position: absolute;
  top: 25px;
  right: 0;
  left: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  height: 51px;
  padding: 0 4px;
}

.ranking-topbar h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-back {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
}

.ranking-back-icon {
  display: block;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  transform: translateX(3px) rotate(45deg);
}

.ranking-more {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.ranking-more span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink);
}

.ranking-main {
  position: relative;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding-bottom: calc(var(--bottom-nav-height) + 22px + env(safe-area-inset-bottom));
}

.device-screen[data-shell-bottom-nav="hidden"] .ranking-main {
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.ranking-main::-webkit-scrollbar { display: none; }

.ranking-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 236px;
  background: var(--wm-color-primary-wash);
  border-bottom: 0;
}

.ranking-hero-image {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  aspect-ratio: 390 / 246;
  height: 246px;
  object-fit: cover;
  object-position: center bottom;
  transform: scale(1.01);
}

.ranking-hero-copy {
  position: absolute;
  top: 92px;
  left: 20px;
  z-index: 3;
  width: 48%;
  color: var(--ink);
}

.ranking-hero-copy span,
.ranking-hero-copy strong,
.ranking-hero-copy p { display: block; }

.ranking-hero-copy span {
  color: var(--teal-deep);
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}

.ranking-hero-copy strong {
  margin-top: 2px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 34px;
}

.ranking-hero-copy p {
  max-width: 150px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 16px;
}

.ranking-hero::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  z-index: 1;
  height: 48%;
  content: "";
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .88) 68%, var(--panel) 100%);
  pointer-events: none;
}

.ranking-feed {
  position: relative;
  z-index: 2;
  margin: -32px 7px 0;
  padding: 22px 10px 24px;
  background: var(--panel);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 26px rgba(var(--wm-action-rgb), .075);
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.ranking-product {
  position: relative;
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  grid-template-rows: auto auto;
  overflow: visible;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 3px 10px rgba(var(--wm-ink-rgb), .035);
  transition: border-color .2s ease, transform .2s ease;
}

.ranking-product-image {
  grid-column: 1;
  grid-row: 1;
  width: 100px;
  height: auto;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--wm-color-primary-wash);
  border-radius: 11px;
}

.ranking-product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.ranking-medal {
  position: absolute;
  top: -6px;
  right: -4px;
  z-index: 2;
  display: block;
  width: 48px;
  height: 56px;
  pointer-events: none;
}

.ranking-medal img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ranking-product-body {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  min-width: 0;
  min-height: 108px;
  flex-direction: column;
  justify-content: space-between;
}

.ranking-product.has-medal .ranking-product-name { padding-right: 37px; }

.ranking-product-name {
  display: -webkit-box;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 18px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ranking-product-subtitle {
  min-width: 0;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-product-price-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  min-width: 0;
  column-gap: 5px;
  row-gap: 2px;
  margin-top: 5px;
}

.ranking-product-price {
  grid-column: 1;
  grid-row: 1;
  color: var(--orange);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.ranking-product-reference {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--muted-soft);
  font-size: 9px;
  line-height: 13px;
  text-decoration: line-through;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-product-action {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: relative;
  z-index: 8;
  align-self: center;
  min-height: 24px;
  padding: 5px 8px 5px 9px;
  color: #fff;
  background: var(--teal-deep);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  white-space: nowrap;
}

.ranking-product-metrics.metric-list {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  margin-top: 0;
  padding-top: 6px;
  border-top: 1px solid var(--wm-color-primary-soft);
  color: var(--wm-color-muted-strong);
  font-size: 8px;
  line-height: 12px;
}

.ranking-product-metrics .metric-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  column-gap: 4px;
  align-items: center;
  min-width: 0;
  min-height: 19px;
  padding: 1px 3px 1px 1px;
  border-radius: 8px;
  white-space: nowrap;
}

.ranking-product-metrics .metric-item img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 50%;
}

.ranking-product-metrics .metric-item > span {
  min-width: 0;
  overflow: hidden;
  padding-left: 1px;
  color: var(--wm-color-muted-strong);
  font-size: 8px;
  font-weight: 400;
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-product-metrics .metric-item--flow { background: var(--wm-color-primary-soft); }
.ranking-product-metrics .metric-item--fresh { background: var(--wm-color-primary-wash); }
.ranking-product-metrics .metric-item--cost { background: var(--wm-color-primary-wash); }

.ranking-toast {
  position: fixed;
  right: 50%;
  bottom: calc(var(--bottom-nav-height) + 18px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(var(--page-width) - 28px);
  padding: 9px 13px;
  color: #fff;
  background: var(--teal-deep);
  border-radius: 10px;
  box-shadow: 0 9px 22px rgba(var(--wm-action-rgb), .22);
  font-size: 11px;
  line-height: 15px;
  transform: translateX(50%);
}

.device-screen[data-shell-bottom-nav="hidden"] .ranking-toast {
  bottom: calc(18px + env(safe-area-inset-bottom));
}

@media (max-width: 350px) {
  .ranking-product {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  .ranking-product-image {
    width: 92px;
    height: auto;
    aspect-ratio: 3 / 2;
  }

  .ranking-product-body { min-height: 104px; }
  .ranking-product-price { font-size: 16px; }
  .ranking-product-action { padding-right: 7px; padding-left: 7px; font-size: 9px; }
}

