:root {
  --bg: #e8f0ec;
  --bg-deep: #d5e4dc;
  --surface: rgba(247, 251, 248, 0.72);
  --surface-solid: #f7fbf8;
  --ink: #14241f;
  --muted: #5a7368;
  --line: rgba(20, 36, 31, 0.1);
  --glass-line: rgba(255, 255, 255, 0.55);
  --glass-line-dark: rgba(20, 36, 31, 0.08);
  --accent: #1a3a32;
  --accent-soft: #2d5a4e;
  --cheap: #0f7a4f;
  --cheap-bg: rgba(216, 243, 230, 0.78);
  --exp: #b53a2a;
  --exp-bg: rgba(252, 232, 228, 0.82);
  --same: #6b5a2e;
  --same-bg: rgba(245, 237, 212, 0.82);
  --wait: #5a7368;
  --wait-bg: rgba(228, 235, 231, 0.75);
  --bought: #1f5c72;
  --bought-bg: rgba(215, 235, 241, 0.8);
  --radius: 22px;
  --pad-x: clamp(14px, 4.2vw, 24px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "Noto Sans SC", "PingFang SC", sans-serif;
  --num: "Outfit", "Noto Sans SC", sans-serif;
  --blur: blur(22px) saturate(160%);
  --blur-soft: blur(12px) saturate(140%);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);

  --c-sage: #cfe3d8;
  --c-sage-ink: #1f4a3c;
  --c-mist: #c9dde4;
  --c-mist-ink: #1f4d5c;
  --c-olive: #dce4c8;
  --c-olive-ink: #45522a;
  --c-sand: #e6dfcf;
  --c-sand-ink: #5a4f38;
  --c-clay: #e6d5d0;
  --c-clay-ink: #6a4038;
  --c-lilac: #ddd6e4;
  --c-lilac-ink: #4a3d58;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 55% at 8% -8%, #c5ddd2 0%, transparent 58%),
    radial-gradient(ellipse 70% 45% at 100% 5%, #b9d2cb 0%, transparent 52%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  overflow-x: clip;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0 0 calc(108px + var(--safe-b));
  min-height: 100dvh;
}

/* —— Shared glass material —— */
.glass-chip,
.glass-panel {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* —— Sticky liquid-glass header (full viewport bleed) —— */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  /* keep header on its own compositor layer */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.header-glass {
  position: relative;
  padding-top: max(12px, calc(var(--safe-t) + 8px));
  padding-bottom: 12px;
  background:
    linear-gradient(
      180deg,
      rgba(247, 251, 248, 0.88) 0%,
      rgba(236, 244, 240, 0.78) 100%
    );
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition:
    background 0.28s var(--ease-out),
    padding-bottom 0.28s var(--ease-out);
}

.header-glass::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 4%,
    rgba(255, 255, 255, 0.85) 30%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0.85) 70%,
    transparent 96%
  );
  pointer-events: none;
  opacity: 0.9;
}

.header.is-scrolled .header-glass {
  background:
    linear-gradient(
      180deg,
      rgba(247, 251, 248, 0.94) 0%,
      rgba(232, 240, 236, 0.9) 100%
    );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  padding-bottom: 10px;
}

.header-inner {
  width: min(720px, 100%);
  margin: 0 auto;
  padding-left: max(var(--pad-x), var(--safe-l));
  padding-right: max(var(--pad-x), var(--safe-r));
}

/* Soft edge under sticky bar — pure paint, no mask/blur (was causing scroll jank) */
.header-fade {
  height: 18px;
  margin-top: -1px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(232, 240, 236, 0.85) 0%,
    rgba(232, 240, 236, 0) 100%
  );
}

.header.is-scrolled .header-fade {
  height: 14px;
  background: linear-gradient(
    180deg,
    rgba(232, 240, 236, 0.92) 0%,
    rgba(232, 240, 236, 0) 100%
  );
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(10px, 3vw, 16px);
}

.brand {
  margin: 0;
  font-family: var(--num);
  font-size: clamp(0.68rem, 1.9vw, 0.74rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.title {
  margin: 6px 0 0;
  font-size: clamp(1.7rem, 6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.tagline {
  margin: 8px 0 0;
  font-size: clamp(0.78rem, 2.3vw, 0.88rem);
  color: var(--muted);
  letter-spacing: 0.01em;
  line-height: 1.35;
  max-width: 16em;
  transition: opacity 0.25s ease, max-height 0.25s ease, margin 0.25s ease;
  max-height: 3em;
  overflow: hidden;
}

.header.is-scrolled .tagline {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
}

.rate-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 11px 13px;
  border-radius: 16px;
  transition: transform 0.15s ease, background 0.2s ease;
}

.rate-btn:active {
  transform: scale(0.97);
}

.rate-label {
  font-size: 0.7rem;
  color: var(--muted);
}

.rate-value {
  font-family: var(--num);
  font-weight: 600;
  font-size: clamp(0.88rem, 2.4vw, 0.95rem);
}

.rate-panel {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius);
  animation: slideDown 0.22s ease;
}

.rate-panel[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* —— Fields —— */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field > span {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--muted);
}

.field em {
  font-style: normal;
  opacity: 0.7;
  font-weight: 400;
}

.field input,
.krw-input,
.select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-size: 16px; /* iOS zoom prevention */
  appearance: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%235a7368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-color: rgba(255, 255, 255, 0.72);
  padding-right: 40px;
}

.field input:focus,
.krw-input:focus,
.select:focus {
  border-color: rgba(45, 90, 78, 0.45);
  box-shadow:
    0 0 0 3px rgba(45, 90, 78, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.rate-row,
.input-with-unit,
.krw-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.rate-row .unit,
.input-with-unit .unit,
.krw-input-wrap .unit {
  position: absolute;
  right: 14px;
  color: var(--muted);
  font-family: var(--num);
  font-weight: 600;
  pointer-events: none;
}

.rate-row input,
.input-with-unit input,
.krw-input {
  padding-right: 36px;
}

.hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

/* —— Summary —— */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, 1.8vw, 10px);
  margin-top: clamp(14px, 3vw, 18px);
}

.summary-item {
  padding: clamp(12px, 2.8vw, 14px) 8px 12px;
  border-radius: 18px;
  text-align: center;
}

.summary-item.bought {
  background: var(--bought-bg);
  border-color: rgba(255, 255, 255, 0.5);
}

.summary-item.saved {
  background: var(--cheap-bg);
  border-color: rgba(255, 255, 255, 0.5);
}

.summary-num {
  display: block;
  font-family: var(--num);
  font-size: clamp(1.1rem, 3.6vw, 1.28rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.summary-label {
  display: block;
  margin-top: 4px;
  font-size: clamp(0.65rem, 1.9vw, 0.72rem);
  color: var(--muted);
}

/* —— Main —— */
.main {
  position: relative;
  z-index: 1;
  margin-top: -10px;
  padding-left: max(var(--pad-x), var(--safe-l));
  padding-right: max(var(--pad-x), var(--safe-r));
  padding-top: 4px;
}

.lists-bar {
  margin-bottom: 14px;
}

.lists-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.lists-head h2 {
  margin: 0;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lists-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.text-btn {
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.text-btn[aria-pressed="true"] {
  background: var(--exp-bg);
  color: var(--exp);
  border-color: rgba(255, 255, 255, 0.45);
}

.add-list-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(26, 58, 50, 0.92);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.add-list-btn span {
  font-family: var(--num);
  font-size: 1rem;
  line-height: 1;
}

.list-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 -2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.list-tabs::-webkit-scrollbar {
  display: none;
}

.list-tab {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-size: clamp(0.82rem, 2.4vw, 0.88rem);
  font-weight: 600;
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.list-tab .count {
  font-family: var(--num);
  font-size: 0.75rem;
  opacity: 0.65;
  font-weight: 600;
}

.list-tab.active {
  border-color: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

.list-tab .del-list {
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  background: rgba(20, 36, 31, 0.1);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
  margin-left: 2px;
}

.managing .list-tab.custom .del-list {
  display: inline-flex;
}

.list-tab.tone-all {
  background: rgba(247, 251, 248, 0.62);
}

.list-tab.tone-sage { background: rgba(207, 227, 216, 0.78); color: var(--c-sage-ink); }
.list-tab.tone-mist { background: rgba(201, 221, 228, 0.78); color: var(--c-mist-ink); }
.list-tab.tone-olive { background: rgba(220, 228, 200, 0.78); color: var(--c-olive-ink); }
.list-tab.tone-sand { background: rgba(230, 223, 207, 0.8); color: var(--c-sand-ink); }
.list-tab.tone-clay { background: rgba(230, 213, 208, 0.8); color: var(--c-clay-ink); }
.list-tab.tone-lilac { background: rgba(221, 214, 228, 0.8); color: var(--c-lilac-ink); }

/* —— Filters —— */
.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -2px 14px;
  padding: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-size: clamp(0.74rem, 2.2vw, 0.8rem);
  color: var(--muted);
  transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.filter.active {
  background: rgba(26, 58, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: scale(1.03);
}

/* —— Stage + slide transitions —— */
.stage {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  will-change: transform, opacity;
}

.stage.is-leaving.to-left {
  animation: stageOutLeft 0.26s var(--ease-out) forwards;
}

.stage.is-leaving.to-right {
  animation: stageOutRight 0.26s var(--ease-out) forwards;
}

.stage.is-entering.from-right {
  animation: stageInFromRight 0.38s var(--ease-spring) both;
}

.stage.is-entering.from-left {
  animation: stageInFromLeft 0.38s var(--ease-spring) both;
}

@keyframes stageOutLeft {
  from { transform: translate3d(0, 0, 0); opacity: 1; }
  to { transform: translate3d(-18%, 0, 0); opacity: 0; }
}

@keyframes stageOutRight {
  from { transform: translate3d(0, 0, 0); opacity: 1; }
  to { transform: translate3d(18%, 0, 0); opacity: 0; }
}

@keyframes stageInFromRight {
  from { transform: translate3d(22%, 0, 0); opacity: 0; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}

@keyframes stageInFromLeft {
  from { transform: translate3d(-22%, 0, 0); opacity: 0; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}

/* —— Products —— */
.product-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.8vw, 16px);
}

.product {
  position: relative;
  display: flex;
  border-radius: var(--radius);
  background: rgba(247, 251, 248, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
  animation: cardIn 0.45s var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.product.is-bought {
  background: rgba(238, 247, 242, 0.96);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

.product-accent {
  width: 4px;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(74, 143, 116, 0.95), rgba(45, 90, 78, 0.75));
}

.product.tone-sage .product-accent { background: linear-gradient(180deg, #5aa088, #3d7460); }
.product.tone-mist .product-accent { background: linear-gradient(180deg, #5a9cb0, #3d7084); }
.product.tone-olive .product-accent { background: linear-gradient(180deg, #8aa05a, #62703d); }
.product.tone-sand .product-accent { background: linear-gradient(180deg, #b0a078, #84785a); }
.product.tone-clay .product-accent { background: linear-gradient(180deg, #c08a7a, #8e5e52); }
.product.tone-lilac .product-accent { background: linear-gradient(180deg, #9a8aac, #6e6280); }

.product-body {
  flex: 1;
  padding: clamp(14px, 3.2vw, 18px) clamp(14px, 3.2vw, 18px) 14px;
  min-width: 0;
}

.product-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.list-chip,
.bought-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.list-chip {
  background: var(--wait-bg);
  color: var(--muted);
}

.list-chip.tone-sage { background: rgba(207, 227, 216, 0.85); color: var(--c-sage-ink); }
.list-chip.tone-mist { background: rgba(201, 221, 228, 0.85); color: var(--c-mist-ink); }
.list-chip.tone-olive { background: rgba(220, 228, 200, 0.85); color: var(--c-olive-ink); }
.list-chip.tone-sand { background: rgba(230, 223, 207, 0.88); color: var(--c-sand-ink); }
.list-chip.tone-clay { background: rgba(230, 213, 208, 0.88); color: var(--c-clay-ink); }
.list-chip.tone-lilac { background: rgba(221, 214, 228, 0.88); color: var(--c-lilac-ink); }

.bought-tag {
  background: var(--bought-bg);
  color: var(--bought);
}

.bought-tag[hidden] {
  display: none;
}

.product-name {
  margin: 0;
  font-size: clamp(1rem, 3.2vw, 1.08rem);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.product-note {
  margin: 5px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.product-note:empty {
  display: none;
}

.product-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: var(--muted);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: background 0.15s ease, transform 0.15s var(--ease-out);
}

.icon-btn:active {
  background: rgba(213, 228, 220, 0.8);
}

.price-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 10px;
  margin-bottom: 12px;
}

.price-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.price-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.price-china {
  font-family: var(--num);
  font-size: clamp(1.1rem, 3.5vw, 1.22rem);
  font-weight: 700;
  padding: 10px 0 2px;
  letter-spacing: -0.02em;
}

.krw-input {
  padding: 12px 36px 12px 12px;
  font-family: var(--num);
  font-weight: 600;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  border: 1.5px solid rgba(45, 90, 78, 0.35);
}

.compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px dashed rgba(20, 36, 31, 0.12);
}

.converted-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.converted-value {
  font-family: var(--num);
  font-weight: 700;
  font-size: clamp(0.98rem, 3vw, 1.05rem);
  letter-spacing: -0.02em;
}

.badge {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: clamp(0.74rem, 2.2vw, 0.8rem);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.badge.wait { background: var(--wait-bg); color: var(--wait); }
.badge.cheap { background: var(--cheap-bg); color: var(--cheap); }
.badge.exp { background: var(--exp-bg); color: var(--exp); }
.badge.same { background: var(--same-bg); color: var(--same); }

.purchase-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  flex-wrap: wrap;
}

.buy-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(26, 58, 50, 0.92);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.15s ease, background 0.15s ease;
}

.buy-btn:active {
  transform: scale(0.97);
}

.buy-btn.is-bought {
  color: var(--bought);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: var(--bought-bg);
}

.purchase-result {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.purchase-result[hidden] {
  display: none;
}

.purchase-qty {
  font-size: 0.72rem;
  color: var(--muted);
}

.purchase-save {
  font-family: var(--num);
  font-size: clamp(0.88rem, 2.8vw, 0.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.purchase-save.gain { color: var(--cheap); }
.purchase-save.loss { color: var(--exp); }
.purchase-save.flat { color: var(--same); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 52px 16px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.empty[hidden] {
  display: none;
}

/* —— FAB —— */
.fab {
  position: fixed;
  right: max(16px, var(--safe-r), calc(50% - 360px + 16px));
  bottom: calc(22px + var(--safe-b));
  width: clamp(54px, 14vw, 64px);
  height: clamp(54px, 14vw, 64px);
  border-radius: 20px;
  background: rgba(26, 58, 50, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  z-index: 30;
  transition: transform 0.2s var(--ease-out);
}

.fab:active {
  transform: scale(0.94);
}

/* —— Sheets —— */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 31, 0.36);
  z-index: 40;
  animation: fade 0.22s var(--ease-out);
}

.sheet-backdrop[hidden] {
  display: none;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  width: min(720px, 100%);
  max-height: min(90dvh, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px max(20px, var(--safe-l)) calc(24px + var(--safe-b)) max(20px, var(--safe-r));
  border-radius: 28px 28px 0 0;
  background: rgba(247, 251, 248, 0.94);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-bottom: none;
  z-index: 50;
  transition: transform 0.36s var(--ease-spring);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.sheet.open {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: rgba(20, 36, 31, 0.14);
  margin: 4px auto 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: clamp(1.12rem, 3.4vw, 1.22rem);
  letter-spacing: -0.02em;
}

.sheet-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  padding: 14px 18px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 1rem;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn.primary {
  background: rgba(26, 58, 50, 0.94);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn:active {
  opacity: 0.92;
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(6px, 1.8vw, 8px);
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 0 0 1px rgba(20, 36, 31, 0.06);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch.tone-sage { background: var(--c-sage); }
.color-swatch.tone-mist { background: var(--c-mist); }
.color-swatch.tone-olive { background: var(--c-olive); }
.color-swatch.tone-sand { background: var(--c-sand); }
.color-swatch.tone-clay { background: var(--c-clay); }
.color-swatch.tone-lilac { background: var(--c-lilac); }

.color-swatch.selected {
  border-color: var(--accent);
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(26, 58, 50, 0.15);
}

.qty-row {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.qty-btn {
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-family: var(--num);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.qty-row input {
  text-align: center;
  font-family: var(--num);
  font-weight: 700;
  font-size: 1.25rem;
  padding: 12px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.72);
}

.buy-preview {
  margin: 4px 0 16px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.buy-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.buy-preview-row + .buy-preview-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(20, 36, 31, 0.12);
}

.buy-preview-row.highlight strong {
  font-family: var(--num);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.buy-preview-row strong.gain { color: var(--cheap); }
.buy-preview-row strong.loss { color: var(--exp); }
.buy-preview-row strong.flat { color: var(--same); }

/* Fallback when blur unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .header-glass {
    background: rgba(236, 244, 240, 0.96);
  }

  .glass-chip,
  .glass-panel,
  .product,
  .sheet,
  .filter,
  .list-tab,
  .fab {
    background-color: rgba(247, 251, 248, 0.96);
  }

  .sheet-backdrop {
    background: rgba(20, 36, 31, 0.5);
  }
}

/* Small phones */
@media (max-width: 380px) {
  .summary-num {
    font-size: 1.05rem;
  }

  .purchase-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .buy-btn {
    width: 100%;
    text-align: center;
  }

  .purchase-result {
    align-items: flex-start;
    width: 100%;
  }

  .sheet-actions {
    grid-template-columns: 1fr;
  }
}

/* Tablet / desktop */
@media (min-width: 768px) {
  .header-glass {
    padding-top: max(20px, calc(var(--safe-t) + 16px));
    padding-bottom: 16px;
  }

  .price-grid {
    grid-template-columns: 150px 1fr;
    align-items: end;
  }

  .fab {
    right: max(24px, calc(50% - 360px + 24px));
  }

  .sheet {
    border-radius: 28px;
    bottom: max(24px, var(--safe-b));
    max-width: 440px;
    left: auto;
    right: max(24px, calc(50% - 360px + 24px));
    transform: translateY(110%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    padding-bottom: 24px;
  }

  .sheet.open {
    transform: translateY(0);
  }

  .sheet-handle {
    display: none;
  }
}

/* Large desktop: softer full-bleed glass */
@media (min-width: 1100px) {
  .header-glass {
    background:
      linear-gradient(
        180deg,
        rgba(247, 251, 248, 0.7) 0%,
        rgba(236, 244, 240, 0.5) 100%
      );
  }

  .header.is-scrolled .header-glass {
    background:
      linear-gradient(
        180deg,
        rgba(247, 251, 248, 0.82) 0%,
        rgba(232, 240, 236, 0.68) 100%
      );
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }

  .stage,
  .product {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
