/* ============================================================
   PREMIUM + SETTINGS
   One shared vocabulary for the Premium page, its badge sheet,
   the rebuilt Settings screen and the small sub-pages.
   Every color comes from a theme token.
   ============================================================ */

/* ---------- Premium page ---------- */
/* These screens own their side margins (16/20px), so the shared page
   wrapper must not add another 16px around them. */
body.settings-shell { background: var(--bg); }
body.settings-shell #app { background: var(--bg); }
body.settings-shell .page { padding: 0; }

.pm-page {
  --line: var(--border);
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.pm-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(64px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 12px 0;
  display: flex;
  align-items: center;
  background: var(--bg);
}
.pm-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.pm-back .ic svg { width: 26px; height: 26px; }
.pm-back:active { opacity: .65; }

.pm-scroll { padding-bottom: 170px; }

.pm-hero {
  margin: 6px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.pm-hero-copy { min-width: 0; }
.pm-hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--text);
}
.pm-hero-sub {
  margin: 4px 0 0;
  max-width: 280px;
  font-size: 15px;
  line-height: 1.35;
  color: var(--text-2);
}
.pm-hero-badge {
  flex: 0 0 auto;
  display: inline-flex;
  padding-top: 4px;
}

.pm-label {
  margin: 24px 32px 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.pm-plans-section .pm-label { margin-top: 24px; margin-bottom: 8px; }

.pm-preview-card {
  margin: 0 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
}
.pm-sample {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.pm-sample-avatar { flex: 0 0 auto; line-height: 0; }
.pm-sample-avatar .avatar {
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}
.pm-sample-main { min-width: 0; }
.pm-sample-name-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.pm-sample-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pm-sample-bubble {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 14px;
  border: 1.5px solid var(--surface-2);
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.pm-hint {
  margin: 16px 0 8px;
  font-size: 13px;
  color: var(--text-2);
}
.pm-swatches {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.pm-swatches::-webkit-scrollbar { display: none; }
.pm-swatch {
  position: relative;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  outline-offset: 2px;
}
.pm-swatch::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}
.pm-swatch-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text-muted);
}
.pm-swatch.is-selected {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.pm-swatch:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

.pm-footnote {
  margin: 6px 32px 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}

/* comparison table */
.pm-compare {
  margin: 0 16px;
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.pm-compare-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 84px;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-top: .5px solid var(--line);
  font-size: 15px;
  color: var(--text);
}
.pm-compare-row:first-child { border-top: 0; }
.pm-compare-head {
  min-height: 34px;
  font-size: 12px;
  color: var(--text-2);
}
.pm-compare-label { min-width: 0; padding-right: 8px; }
.pm-compare-value { text-align: right; }
.pm-compare-value.free { color: var(--text-2); }
.pm-check {
  display: inline-flex;
  justify-content: flex-end;
  color: var(--gold-on-surface);
}
.pm-check .ic svg { width: 18px; height: 18px; }

/* plans */
.pm-plans { display: flex; flex-direction: column; }
.pm-plan {
  display: flex;
  align-items: center;
  gap: 12px;
  width: auto;
  min-height: 64px;
  margin: 0 16px 8px;
  padding: 12px 14px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pm-plan.is-selected { border-color: var(--accent); }
.pm-plan:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}
.pm-radio {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--text-3);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.pm-plan.is-selected .pm-radio { border-color: var(--accent); }
.pm-plan.is-selected .pm-radio::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}
.pm-plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pm-plan-name { font-size: 16px; font-weight: 500; }
.pm-plan-sub { font-size: 13px; color: var(--text-2); }
.pm-saving { color: var(--positive); font-weight: 500; }
.pm-plan-price {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.pm-plans-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text-2);
}
.pm-text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
}
.pm-note-card {
  margin: 24px 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

/* sticky purchase bar */
.pm-buybar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 10px 16px calc(22px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: .5px solid var(--line);
}
.pm-buy {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.pm-buy:disabled { opacity: .55; cursor: default; }
.pm-buy-note {
  display: block;
  margin-top: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
}

/* skeleton */
.pm-skel {
  margin: 0 16px 10px;
  border-radius: 14px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.pm-skel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-hi), transparent);
}
.pm-skel-title { height: 40px; width: 46%; margin: 10px 20px 8px; }
.pm-skel-sub { height: 16px; width: 70%; margin: 0 20px 20px; }
.pm-skel-card { height: 170px; }
.pm-skel-line { height: 14px; width: 56%; margin-left: 32px; }
.pm-skel-line.short { width: 38%; margin-bottom: 24px; }
.pm-skel-plan { height: 64px; }

/* ---------- Badge upsell sheet ---------- */
.sheet.pm-upsell-sheet {
  background: var(--elevated);
  border-radius: 28px 28px 0 0;
  padding: 10px 22px calc(26px + env(safe-area-inset-bottom, 0px));
}
.sheet.pm-upsell-sheet .grabber { width: 36px; }
.pm-upsell { padding-top: 4px; }
.pm-upsell-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.pm-upsell-star { flex: 0 0 auto; display: inline-flex; }
.pm-upsell-copy { min-width: 0; }
.pm-upsell-title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
}
.pm-upsell-sub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-2);
}
.pm-upsell-primary {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.pm-upsell-secondary {
  width: 100%;
  height: 46px;
  margin-top: 8px;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}
.pm-btn {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.pm-btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.pm-btn-secondary { background: var(--surface-2); color: var(--text); }

/* ---------- Profile: Get Premium row ---------- */
.pr-getpremium-host { margin: 16px 16px 0; }
.pr-getpremium {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.pr-getpremium:active { opacity: .78; }
.pr-getpremium-star { display: inline-flex; flex: 0 0 auto; }
.pr-getpremium-label { flex: 1; min-width: 0; }
.pr-getpremium-chev { display: inline-flex; color: var(--text-3); }
.pr-getpremium-chev .ic svg { width: 20px; height: 20px; }

/* ---------- Edit profile: Customize list ---------- */
.pr-custom-list {
  --line: var(--border);
  margin-top: 0;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
}
.pr-custom-lock {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--text-3);
}
.pr-custom-lock .ic svg { width: 16px; height: 16px; }
.pr-custom-list .st-row-value { margin-left: auto; }

/* ---------- Settings ---------- */
.st-page,
.st-head,
.st-user,
.st-premium-card,
.st-list { --line: var(--border); }

.st-page {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + 28px);
  color: var(--text);
}
.st-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(62px + env(safe-area-inset-top, 0px));
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 0;
  background: var(--bg);
}
.st-back {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.st-back .ic svg { width: 22px; height: 22px; }
.st-head-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}

.st-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 20px 0;
}
.st-user-avatar { flex: 0 0 auto; line-height: 0; }
.st-user-avatar .avatar {
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}
.st-user-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-user-name-line { display: flex; align-items: center; min-width: 0; }
.st-user-name {
  font-size: 17px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-user-id { font-size: 13px; color: var(--text-2); }
.st-user-edit {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 0;
  cursor: pointer;
}

.st-premium-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  margin: 18px 16px 0;
  padding: 14px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.st-premium-card:active { opacity: .86; }
.st-premium-ic {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
}
.st-premium-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-premium-title { font-size: 17px; font-weight: 500; }
.st-premium-sub { font-size: 13px; color: var(--text-2); }
.st-premium-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border-radius: 17px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 500;
}
.st-premium-btn.is-manage { background: var(--surface-2); color: var(--text); }

.st-label {
  margin: 26px 20px 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.st-list {
  margin: 0 20px;
  display: flex;
  flex-direction: column;
}
.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 6px 0;
  border: 0;
  border-top: .5px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: left;
}
.st-row:first-child { border-top: 0; }
button.st-row { cursor: pointer; }
button.st-row:active { background: var(--hover-soft); }
.st-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-row-label { font-size: 16px; color: var(--text); }
.st-row-sub { font-size: 13px; color: var(--text-2); }
.st-row-value {
  flex: 0 0 auto;
  font-size: 15px;
  color: var(--text-2);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-row-chev { flex: 0 0 auto; display: inline-flex; color: var(--text-3); }
.st-row-chev .ic svg { width: 18px; height: 18px; }

.st-switch {
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 3px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background .18s ease;
}
.st-switch::after {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform .18s ease, background .18s ease;
}
.st-switch.is-on { background: var(--btn-bg); }
.st-switch.is-on::after {
  transform: translateX(18px);
  background: var(--btn-text);
}
.st-switch:disabled { opacity: .55; }

.st-lead { margin: 16px 20px 4px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.st-footnote {
  margin: 18px 20px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.st-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-2);
}
.st-error p { margin: 0; }

.st-about-head { margin: 24px 20px 8px; }
.st-about-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
}
.st-about-version { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }
.st-about-credits {
  margin: 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}

.st-sheet { padding: 4px 2px 8px; }
.st-sheet-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
}
.st-sheet-h {
  margin: 16px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-on-surface);
}
.st-sheet-p {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
}

/* 34px touch target around a small badge without changing its layout size. */
.wr-badge.is-tappable { position: relative; }
.wr-badge.is-tappable::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .st-switch, .st-switch::after { transition: none; }
}
