:root {
  --color-bg: #faf8f4;
  --color-surface: #ffffff;
  --color-ink: #14201b;
  --color-ink-soft: #5b6b64;
  --color-primary: #0b5a44;
  --color-primary-deep: #07402f;
  --color-accent: #e8f4ee;
  --color-live: #d92d20;
  --color-ok: #12805c;
  --color-line: #e4e0d8;

  /* Listener backdrop artwork, supplied per deployment by brand.js. */
  --listener-bg: none;

  --radius: 16px;
  --space: 1rem;
  --shadow: 0 1px 2px rgba(20, 32, 27, 0.06), 0 8px 24px rgba(20, 32, 27, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang HK", "PingFang TC", "Microsoft JhengHei",
    system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Listener backdrop: brand artwork around a readable center. */
body.listener-page {
  background-color: var(--color-bg);
  background-image: var(--listener-bg);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

.listener-page .card {
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px) saturate(110%);
  backdrop-filter: blur(12px) saturate(110%);
}

@media (max-width: 42rem) {
  /* Textural artwork: keep both edge clusters visible around the narrow UI. */
  body.listener-page[data-bg-mode="cluster"] {
    background-image: var(--listener-bg), var(--listener-bg);
    background-position: left -5rem top -2rem, right -4rem bottom -3rem;
    background-size: auto 34rem, auto 34rem;
    background-attachment: scroll;
  }

  /* A composed scene stays whole. Anchored right so the focal detail survives
     the heavy crop a portrait phone applies to a landscape image, instead of
     leaving only empty ground. Fixed attachment janks on mobile Safari. */
  body.listener-page[data-bg-mode="cover"] {
    background-position: right center;
    background-attachment: scroll;
  }
}

.wrap {
  max-width: 26rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

/* Header */
.brand { padding: 0.75rem 0 1.25rem; }
.brand-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
}
.brand h1 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--color-primary-deep);
}
.brand p {
  color: var(--color-ink-soft);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}
.internal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.25rem 0.55rem;
  /* Tinted from the brand palette. The plain values are a fallback for
     browsers without color-mix; the mix reproduces them exactly for USANA. */
  border: 1px solid rgba(11, 90, 68, 0.22);
  border: 1px solid color-mix(in srgb, var(--color-primary) 22%, transparent);
  border-radius: 999px;
  background: rgba(232, 244, 238, 0.88);
  background: color-mix(in srgb, var(--color-accent) 88%, transparent);
  color: var(--color-primary-deep);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.7rem;
}

/* Option buttons (language / mode) */
.options { display: grid; gap: 0.55rem; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.options.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.opt {
  border: 1.5px solid var(--color-line);
  background: var(--color-surface);
  border-radius: 12px;
  padding: 0.8rem 0.6rem;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 120ms ease, background 120ms ease;
}
.opt .zh { display: block; font-size: 1.05rem; font-weight: 600; }
.opt .en { display: block; font-size: 0.72rem; color: var(--color-ink-soft); margin-top: 0.1rem; }
.opt .desc { display: block; font-size: 0.7rem; color: var(--color-ink-soft); margin-top: 0.3rem; }
.opt[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-accent);
}
.opt:disabled { opacity: 0.35; cursor: not-allowed; }

/* Primary actions */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 1.05rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 80ms ease, opacity 120ms ease;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-danger { background: #fff; color: var(--color-live); border: 1.5px solid var(--color-live); }
.btn-ghost { background: #fff; color: var(--color-primary); border: 1.5px solid var(--color-line); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn .en-sub { display: block; font-size: 0.72rem; font-weight: 500; opacity: 0.85; margin-top: 0.1rem; }

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  width: fit-content;
  margin: 0 auto 0.9rem;
  background: var(--color-accent);
  color: var(--color-primary-deep);
}
.status .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-ink-soft);
}
.status.live { background: #feeceb; color: var(--color-live); }
.status.live .dot { background: var(--color-live); animation: pulse 1.4s infinite; }
.status.ok .dot { background: var(--color-ok); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* QR block */
.qr-box { text-align: center; }
.qr-box img { width: min(62vw, 240px); height: auto; image-rendering: pixelated; }
.share-link {
  font-size: 0.72rem;
  color: var(--color-ink-soft);
  word-break: break-all;
  background: var(--color-bg);
  border-radius: 10px;
  padding: 0.6rem;
  margin: 0.7rem 0;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }

.meta { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--color-ink-soft); padding: 0 0.2rem; }
.meta b { color: var(--color-ink); }

.hint { font-size: 0.78rem; color: var(--color-ink-soft); line-height: 1.5; margin-top: 0.7rem; }
.error-box {
  background: #feeceb; border: 1px solid #f6c9c5; color: #8a1a12;
  border-radius: 12px; padding: 0.8rem; font-size: 0.85rem; margin-bottom: 0.9rem;
  white-space: pre-wrap; word-break: break-word;
}
.hidden { display: none !important; }

/* Listener big state headline */
.state-line { text-align: center; padding: 1.4rem 0 0.6rem; }
.state-line .zh { display: block; font-size: 1.3rem; font-weight: 700; }
.state-line .en { display: block; font-size: 0.85rem; color: var(--color-ink-soft); margin-top: 0.25rem; }

.compliance-note {
  margin-top: 1.25rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(11, 90, 68, 0.16);
  border: 1px solid color-mix(in srgb, var(--color-primary) 16%, transparent);
  border-left: 3px solid var(--color-primary);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--color-ink-soft);
  font-size: 0.72rem;
  line-height: 1.55;
  -webkit-backdrop-filter: blur(10px) saturate(105%);
  backdrop-filter: blur(10px) saturate(105%);
}
.compliance-note strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--color-primary-deep);
  font-size: 0.75rem;
}

footer { text-align: center; font-size: 0.7rem; color: var(--color-ink-soft); margin-top: 2rem; }
