:root {
  color-scheme: light;
  --page: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #f7f9f6;
  --text: #18231c;
  --muted: #6d786f;
  --line: #e3e8e2;
  --green: #18864b;
  --green-dark: #0e6537;
  --green-soft: #e5f4e9;
  --danger: #c13d3d;
  --shadow: 0 12px 34px rgba(29, 48, 35, .07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 46px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  place-content: center;
  justify-items: center;
}

.login-button {
  min-width: min(310px, calc(100vw - 40px));
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 0 24px;
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 9px 24px rgba(24, 134, 75, .22);
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

.login-button:active:not(:disabled) {
  transform: translateY(1px);
  background: var(--green-dark);
}

.login-button:disabled {
  cursor: wait;
  opacity: .68;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 3px 18px;
}

.brand,
.account-summary {
  display: flex;
  min-width: 0;
  align-items: center;
}

.brand {
  gap: 12px;
}

.account-summary {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
}

.account-name {
  display: block;
  max-width: min(38vw, 180px);
  overflow: hidden;
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -.04em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  display: flex;
  min-height: 20px;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.logout-button:active:not(:disabled) {
  color: var(--green-dark);
  background: transparent;
}

.logout-button:disabled {
  cursor: wait;
  opacity: .6;
}

.logout-icon {
  font-size: 17px;
  line-height: 1;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 14px 14px 14px 5px;
  color: #ffffff;
  background: var(--green);
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.04em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.04em;
}

h2 {
  margin-bottom: 5px;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

h3 {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .14em;
}

.card {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.subscription-cancel-button {
  margin-top: 9px;
  border: 0;
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.subscription-cancel-button:active:not(:disabled) {
  color: var(--danger);
}

.terms-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.subscription-card {
  overflow: hidden;
}

.subscription-heading {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.subscription-heading:disabled {
  cursor: default;
  opacity: 1;
}

.subscription-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .13em;
}

.subscription-summary {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
}

.subscription-badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.subscription-badge.is-active {
  border-color: #cce7d4;
  color: var(--green-dark);
  background: var(--green-soft);
}

.subscription-heading-aside {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.subscription-chevron {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-right: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s ease;
}

.subscription-heading[aria-expanded="true"] .subscription-chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.subscription-details {
  animation: subscription-expand .16s ease-out;
}

@keyframes subscription-expand {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.subscription-offers {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.subscription-intro {
  margin-bottom: 12px;
}

.plan-list {
  display: grid;
  gap: 8px;
}

.plan-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #d9e7dc;
  border-radius: 14px;
  padding: 10px 13px;
  color: var(--text);
  background: #fbfdfb;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.plan-button:active:not(:disabled) {
  border-color: var(--green);
  background: var(--green-soft);
  transform: translateY(1px);
}

.plan-button:disabled {
  cursor: wait;
  opacity: .58;
}

.plan-copy,
.plan-copy strong,
.plan-copy small {
  display: block;
}

.plan-copy strong {
  font-size: 14px;
  line-height: 1.25;
}

.plan-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.plan-price {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.redeem-block {
  margin-top: 15px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.redeem-block > label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.redeem-row {
  display: flex;
  gap: 8px;
}

.redeem-row input {
  width: 100%;
  min-width: 0;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 11px;
  outline: none;
  color: var(--text);
  background: var(--surface-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.redeem-row input:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(24, 134, 75, .1);
}

.redeem-row button {
  min-width: 105px;
  height: 43px;
  border: 0;
  border-radius: 12px;
  padding: 0 13px;
  color: #ffffff;
  background: var(--green);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.redeem-row button:active:not(:disabled) {
  background: var(--green-dark);
}

.redeem-row button:disabled {
  cursor: wait;
  opacity: .6;
}

.setting-row,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  align-items: flex-start;
  margin-bottom: 16px;
}

.supporting-text {
  max-width: 430px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.batch-threshold-value {
  display: inline-grid;
  min-width: 24px;
  height: 20px;
  margin-left: 3px;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.batch-threshold-control {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.batch-threshold-bound {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

#batch-threshold {
  --range-progress: 11.111%;
  width: 100%;
  height: 30px;
  margin: 0;
  padding: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  accent-color: var(--green);
}

#batch-threshold::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--green) 0 var(--range-progress),
    #d8dfd8 var(--range-progress) 100%
  );
}

#batch-threshold::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  appearance: none;
  background: var(--green);
  box-shadow: 0 1px 5px rgba(24, 35, 28, .22);
}

#batch-threshold::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: #d8dfd8;
}

#batch-threshold::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--green);
}

#batch-threshold::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 1px 5px rgba(24, 35, 28, .22);
}

#batch-threshold:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.keyword-input {
  display: block;
  width: 100%;
  height: 48px;
  min-height: 48px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  overflow-y: hidden;
  outline: none;
  resize: none;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 15px;
  line-height: 20px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.keyword-input::placeholder {
  color: #89928b;
  opacity: 1;
}

.keyword-input:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(24, 134, 75, .1);
}

.keyword-input:disabled {
  cursor: not-allowed;
  opacity: .55;
  box-shadow: none;
}

.count-badge {
  display: grid;
  min-width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 800;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  margin: -7px 0;
  padding: 7px 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #d5dbd5;
  transition: background .18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(24, 35, 28, .2);
  transition: transform .18s ease;
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:disabled + .switch-track {
  opacity: .55;
}

.switch input:focus-visible + .switch-track,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(24, 134, 75, .22);
  outline-offset: 2px;
}

.switch-small .switch-track {
  width: 42px;
  height: 26px;
}

.switch-small {
  margin: -9px 0;
  padding: 9px 0;
}

.switch-small .switch-track::after {
  width: 18px;
  height: 18px;
}

.switch-small input:checked + .switch-track::after {
  transform: translateX(16px);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 44px 0 43px;
  outline: none;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.search-box input::placeholder {
  color: #89928b;
}

.search-box input:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(24, 134, 75, .1);
}

.search-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 17px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-58%);
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--muted);
  transform: rotate(45deg);
}

.search-spinner {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 16px;
  height: 16px;
  border: 2px solid #d8ded8;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.search-status {
  min-height: 18px;
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.product-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-results {
  max-height: min(360px, 45vh);
  margin: 2px 0 16px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  overscroll-behavior: contain;
}

.search-results li:not(:last-child),
.tracked-row:not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.product-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
}

.search-result {
  width: 100%;
  min-height: 70px;
  border: 0;
  padding: 9px 11px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-result:active:not(:disabled) {
  background: var(--surface-soft);
}

.search-result:disabled {
  cursor: default;
  opacity: .62;
}

.product-content {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 11px;
}

.product-image {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #edf0ec;
  border-radius: 12px;
  background: var(--surface-soft);
}

.product-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.image-placeholder {
  color: #a9b2aa;
  font-size: 18px;
  font-weight: 800;
}

.product-image.image-loaded .image-placeholder {
  visibility: hidden;
}

.product-details {
  display: block;
  min-width: 0;
}

.product-name {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-rating {
  display: block;
  margin-top: 5px;
  color: #9b6a08;
  font-size: 11px;
  font-weight: 750;
}

.result-action {
  display: grid;
  min-width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 20px;
  font-weight: 500;
}

.search-result:disabled .result-action {
  width: auto;
  padding: 0 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 700;
}

.tracked-section {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.tracked-row {
  min-height: 70px;
  transition: opacity .15s ease;
}

.tracked-row.is-removing {
  opacity: .45;
}

.product-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.delete-button {
  display: grid;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 11px;
  padding: 0 0 3px;
  place-items: center;
  color: #8c9690;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.delete-button:active:not(:disabled) {
  color: var(--danger);
  background: #fff0ef;
}

.delete-button:disabled {
  cursor: wait;
}

.empty-state {
  margin: 4px 0 0;
  border: 1px dashed #d8ded8;
  border-radius: 14px;
  padding: 20px 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 28px);
  border-radius: 12px;
  padding: 10px 14px;
  color: #ffffff;
  background: #26342b;
  box-shadow: 0 10px 26px rgba(16, 28, 20, .2);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
}

.toast.error {
  background: #963535;
}

@media (max-width: 390px) {
  .shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .card {
    border-radius: 18px;
    padding: 15px;
  }

  .redeem-row {
    display: grid;
  }

  .redeem-row button {
    width: 100%;
  }

  .account-name {
    max-width: 112px;
    font-size: 21px;
  }

  .logout-button {
    font-size: 13px;
  }

  .product-row {
    gap: 7px;
  }

  .product-image {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
