:root {
  --soft-teal: #7fd8d6;
  --pearlescent-purple: #c7b1f7;
  --oatmeal: #f3ebdd;
  --coral: #ff4f6d;
  --ink: #1e2a3b;
  --muted: #435a72;
  --card: #f5f9ff;
  --stroke: #cfe0f8;
  --shadow: 0 10px 24px rgba(16, 27, 43, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--oatmeal);
  color: var(--ink);
}

.topbar {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--soft-teal), var(--pearlescent-purple));
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  box-shadow: var(--shadow);
}
.topbar__title { font-weight: 900; letter-spacing: 0.2px; font-size: 21px; line-height: 1.1; }
.topbar__subtitle { font-size: 13px; opacity: 0.92; margin-top: 4px; }
.topbar__actions { display: flex; gap: 8px; }

.iconbtn {
  width: 42px;
  height: 42px;
  border-radius: 21px;
  border: 0;
  background: rgba(0,0,0,0.2);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}
.installbtn {
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: rgba(0,0,0,0.22);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.2px;
  cursor: pointer;
  touch-action: manipulation;
}
.installbtn:active,
.iconbtn:active { transform: translateY(1px); }

.main { padding: 14px 16px 92px; }
.view { display: none; }
.view--active { display: block; }
.hidden { display: none !important; }

.search-row { margin: 10px 0 14px; }
.search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.8);
  outline: none;
}

.empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
}
.empty__title { font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.empty__hint { font-size: 13px; opacity: 0.85; }

.cards { display: grid; gap: 12px; }
.carditem {
  border: 1px solid var(--stroke);
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(16, 27, 43, 0.08);
}
.carditem__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 104px;
}
.carditem__media {
  width: 100%;
  height: 100%;
  background: #fff;
}
.carditem__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
}
.carditem__ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: rgba(30, 42, 59, 0.92);
  text-align: center;
  gap: 10px;
}
.carditem__phInit {
  font-weight: 950;
  font-size: 24px;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.36);
  border: 1px solid rgba(255,255,255,0.35);
  padding: 4px 8px;
  border-radius: 12px;
}
.carditem__phName {
  width: 92%;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.2px;
  background: rgba(255,255,255,0.34);
  border: 1px solid rgba(255,255,255,0.30);
  padding: 4px 8px;
  border-radius: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.carditem__name {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 12px;
  font-weight: 750;
  font-size: 20px;
  line-height: 1.1;
  color: var(--ink);
  background:
    radial-gradient(120px 80px at 30% 30%, rgba(127,216,214,0.18), rgba(255,255,255,0) 60%),
    radial-gradient(140px 90px at 70% 70%, rgba(199,177,247,0.18), rgba(255,255,255,0) 60%),
    #fff;
}
.carditem__nameText {
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
  text-align: center;
  font-family: "Playfair Display", ui-serif, Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: 86px;
  width: 60px;
  height: 60px;
  border-radius: 30px;
  border: none;
  background: var(--coral);
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  box-shadow: 0 14px 26px rgba(255, 79, 109, 0.35);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  background: rgba(243, 235, 221, 0.92);
  border-top: 1px solid rgba(30, 42, 59, 0.10);
  display: grid;
  grid-template-columns: 1fr 1fr;
  backdrop-filter: blur(10px);
}

/* iOS PWAs can heat up with heavy blur effects (GPU). Prefer a solid bar. */
@supports (-webkit-touch-callout: none) {
  .tabbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(243, 235, 221, 0.98);
  }
}

.tab {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: rgba(30, 42, 59, 0.62);
}
.tab--active { color: var(--soft-teal); }
.tab__icon { font-size: 20px; }
.tab__label { font-size: 13px; font-weight: 900; color: rgba(30, 42, 59, 0.78); }
.tab--active .tab__label { color: rgba(15, 127, 123, 0.95); }

.backlink {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 0;
}

.cardhero {
  margin-top: 8px;
  padding: 14px 12px 12px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--soft-teal), var(--pearlescent-purple));
  box-shadow: var(--shadow);
  text-align: center;
}
.cardhero__logo {
  max-height: 70px;
  max-width: 220px;
  margin: 0 auto 8px;
  object-fit: contain;
  display: block;
}
.cardhero__name { font-size: 30px; font-weight: 900; }

.barcodebox {
  margin-top: 14px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 10px;
}
.barcodebox__svg { width: 100%; height: 256px; }
.barcodebox__code { text-align: center; margin-top: 8px; font-size: 16px; color: var(--muted); }

.frontback {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.frontback__col { background: rgba(255,255,255,0.88); border: 1px solid var(--stroke); border-radius: 14px; padding: 8px; }
.frontback__label { font-size: 12px; opacity: 0.75; text-align: center; margin-bottom: 6px; }
.frontback__img { width: 100%; height: 120px; object-fit: contain; display: block; }

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 12px;
  font-weight: 800;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--stroke);
}
.btn--outlineRed {
  border: 2px solid var(--coral);
}
.btn--danger { background: #d9534f; color: #fff; border: 0; }
.btn--cta { background: var(--coral); color: #fff; border: 0; }

.info { text-align: center; }
.info__notice {
  margin-top: 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(0, 0, 0, 0.78);
}
.info__logo { width: 220px; height: 220px; object-fit: contain; border-radius: 24px; box-shadow: var(--shadow); }
.info__cta { margin-top: 12px; padding: 14px; background: rgba(255,255,255,0.85); border: 1px solid var(--stroke); border-radius: 18px; }
.info__ctaText { font-weight: 900; margin-bottom: 10px; }
.info__link { margin-top: 10px; font-size: 13px; color: var(--muted); word-break: break-all; }
.info__box { margin-top: 12px; padding: 14px; background: rgba(255,255,255,0.85); border: 1px solid var(--stroke); border-radius: 18px; text-align: left; }
.info__boxTitle { font-weight: 900; margin-bottom: 8px; }
.info__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info__small { font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 8px; }
.info__title { margin-top: 14px; font-size: 26px; font-weight: 900; }
.info__text { margin-top: 10px; line-height: 1.5; color: var(--muted); }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.sheet {
  width: 100%;
  max-width: 520px;
  background: rgba(255,255,255,0.96);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sheet__title { padding: 12px 14px; font-weight: 900; }
.sheet__btn {
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 0;
  background: transparent;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-weight: 800;
}
.sheet__btn--cta {
  color: var(--coral);
}
.sheet__btn:hover { background: rgba(127, 216, 214, 0.10); }

.pickrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pickcard {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  padding: 10px;
  text-align: center;
  box-shadow: 0 8px 18px rgba(16, 27, 43, 0.06);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}
.pickcard--accent {
  border: 2px solid var(--coral);
}
.pickcard:active {
  transform: scale(0.99);
  filter: brightness(0.98);
}
@media (hover: hover) {
  .pickcard:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(16, 27, 43, 0.10);
  }
}
.pickcard__label {
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 8px;
  text-align: center;
}
.pickcard__pv {
  border-radius: 12px;
}
.pickcard__pv--square {
  /* keep for future overrides */
}
.pv {
  width: 100%;
  height: 90px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  position: relative;
  overflow: hidden;
}
.pv.pickcard__pv { height: 104px; }
.pv__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: none;
}
.pv--hasimg .pv__img { display: block; }
.pv__ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
  color: rgba(30, 42, 59, 0.92);
}
.pv--hasimg .pv__ph { display: none; }
.pv__init {
  font-weight: 950;
  font-size: 26px;
  background: rgba(255,255,255,0.36);
  border: 1px solid rgba(255,255,255,0.35);
  padding: 4px 10px;
  border-radius: 14px;
}
.pv__name {
  width: 100%;
  font-weight: 900;
  font-size: 12px;
  background: rgba(255,255,255,0.34);
  border: 1px solid rgba(255,255,255,0.30);
  padding: 4px 8px;
  border-radius: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cropper-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 70;
}
.cropper {
  width: 100%;
  max-width: 520px;
  background: rgba(255,255,255,0.98);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cropper__header { padding: 12px 14px 10px; font-weight: 900; }
.cropper__body { padding: 0 14px 12px; }
.cropper__viewport {
  width: 100%;
  height: clamp(220px, 44vh, 420px);
  background: #111;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  position: relative;
  touch-action: none;
}
.cropper__img {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.cropper__crop {
  position: absolute;
  border: 2px solid rgba(255,255,255,0.95);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.42);
  border-radius: 14px;
  touch-action: none;
}
.cropper__handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(0,0,0,0.10);
}
.cropper__handle--tl { left: -11px; top: -11px; }
.cropper__handle--tr { right: -11px; top: -11px; }
.cropper__handle--bl { left: -11px; bottom: -11px; }
.cropper__handle--br { right: -11px; bottom: -11px; }
.cropper__tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 14px 10px;
}
.cropper__toolbtn {
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 800;
}
.cropper__select {
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 800;
}
.cropper__hint { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.cropper__zoom { width: 100%; margin-top: 10px; }
.cropper__footer {
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cropjs-backdrop {
  position: fixed;
  inset: 0;
  background: #0b0f16;
  z-index: 80;
}
.cropjs {
  height: 100%;
  display: grid;
  grid-template-rows: 56px 1fr 56px 74px;
}
.cropjs__top {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  color: #fff;
  padding: 0 6px;
}
.cropjs__title { font-weight: 900; text-align: center; }
.cropjs__icon {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 0;
  background: rgba(255,255,255,0.10);
  color: #fff;
  font-size: 18px;
}
.cropjs__stage {
  position: relative;
  background: #0b0f16;
  overflow: hidden;
}
.cropjs__stage img { display: block; }
.cropjs__bar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}
.cropjs__select {
  border: 0;
  border-radius: 14px;
  padding: 10px 10px;
  font-weight: 900;
  background: rgba(255,255,255,0.10);
  color: #fff;
}
.cropjs__zoom {
  flex: 1;
  max-width: 220px;
  accent-color: var(--coral);
}
.cropjs__btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  background: rgba(255,255,255,0.10);
  color: #fff;
}
.cropjs__footer {
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: linear-gradient(180deg, rgba(11,15,22,0), rgba(11,15,22,0.98) 42%);
}

.scanner {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.scanner__top {
  padding: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.scanner__video {
  flex: 1;
  width: 100%;
  object-fit: cover;
}
.scanner__hint {
  padding: 10px 12px;
  color: #fff;
  opacity: 0.9;
  text-align: center;
}
