/* Settings, the tip jar and the Welcome / What's New sheet (spec/settings.md, shell.md §14).
   The Settings page is the Mac's grouped form: one column at most 640 px, sections as rounded cards,
   13 px rows with the control at the trailing edge, 11 px footers. Logical properties throughout,
   so Arabic reads right to left. */

/* ---------------------------------------------------------------- the platinum icon's colours */

.settings-plat {
  --plat-top: #DBE0E8; --plat-bottom: #8C94A1;
  --plat-glyph-top: #2A2F35; --plat-glyph-bottom: #2A2F35;
  --plat-shine: 0.5;
  display: inline-block; line-height: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .settings-plat {
    --plat-top: #2B2E33; --plat-bottom: #0F1113;
    --plat-glyph-top: #E0E6ED; --plat-glyph-bottom: #A3ABB8;
    --plat-shine: 0.12;
  }
}
:root[data-theme="dark"] .settings-plat, :root.stage .settings-plat {
  --plat-top: #2B2E33; --plat-bottom: #0F1113;
  --plat-glyph-top: #E0E6ED; --plat-glyph-bottom: #A3ABB8;
  --plat-shine: 0.12;
}

/* ---------------------------------------------------------------- spinner */

.settings-spinner {
  display: inline-block; flex: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--label-2) 30%, transparent);
  border-top-color: var(--label-2);
  animation: settings-spin 0.8s linear infinite;
}
.settings-spinner.ink { border-color: rgba(30, 18, 3, 0.25); border-top-color: var(--on-accent); width: 16px; height: 16px; }
@keyframes settings-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- the Settings page */

.settings-page { padding-block: 4px 24px; }
.settings-section { margin-block-start: 20px; }
.settings-section:first-child { margin-block-start: 6px; }
.settings-header {
  margin: 0; padding: 0 10px 6px;
  font-size: calc(13px * var(--text-scale)); font-weight: 700; color: var(--label);
}
.settings-card {
  container-type: inline-size;
  background: var(--row);
  border-radius: 10px;
  overflow: hidden;
}
.settings-footer { padding: 6px 10px 0; font-size: calc(11px * var(--text-scale)); color: var(--label-2); line-height: 1.35; }
.settings-footer p { margin: 0; }
.settings-footer p + p { margin-block-start: 4px; }

.settings-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 36px;
  padding: 6px 12px;
  color: var(--label);
  font-size: calc(13px * var(--text-scale));
  text-align: start;
  text-decoration: none;
}
.settings-row + .settings-row::before {
  content: ""; position: absolute; top: 0; inset-inline: 12px 0;
  border-top: 0.5px solid var(--hairline);
}
button.settings-row:hover:not(:disabled), a.settings-row:hover { background: var(--hover); }
button.settings-row:active:not(:disabled), a.settings-row:active { background: var(--pressed); }
button.settings-row:disabled { cursor: default; }
.settings-row-icon {
  flex: none; display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  color: var(--label);
}
.settings-row-icon .icon { width: 16px; height: 16px; }
.settings-row-icon.accent { color: var(--accent-text); }
.settings-row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.settings-row-label { overflow-wrap: anywhere; }
.settings-row-sub { font-size: calc(11px * var(--text-scale)); color: var(--label-2); }
.settings-chev { flex: none; width: 11px; height: 11px; color: var(--label-3); stroke-width: 2.2; }
[dir="rtl"] .settings-chev { transform: scaleX(-1); }

/* The long label, or the short one where the long does not fit (Rate Us, Tell a Friend). */
.settings-fit .short { display: none; }
@container (max-width: 300px) {
  .settings-fit .long { display: none; }
  .settings-fit .short { display: inline; }
}

/* The Mac's pop-up button: the chosen value and the up-down chevrons. */
.settings-popup {
  flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 60%;
  min-height: 24px; padding: 2px 6px 2px 8px;
  border-radius: 6px;
  color: var(--label-2);
  font-size: calc(13px * var(--text-scale));
}
.settings-popup:hover { background: var(--hover); color: var(--label); }
.settings-popup[aria-expanded="true"] { background: var(--pressed); color: var(--label); }
.settings-popup-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-popup .icon { width: 12px; height: 12px; stroke-width: 2; }

/* The tiers (TipRows): amber icon and title, a 10 px note, the price trailing. */
.settings-tip-title { color: var(--accent-text); font-size: calc(13px * var(--text-scale)); }
.settings-tip-note { color: var(--label-2); font-size: calc(10px * var(--text-scale)); }
.settings-price { flex: none; color: var(--label-2); font-variant-numeric: tabular-nums; }
.settings-unavailable { flex: none; color: var(--label-3); }
.settings-thanks { color: var(--accent-text); }
.settings-done-row .settings-row-icon { color: var(--green); }

/* Suggest a Feature: the mail link, and the address to select or copy. */
.settings-suggest { flex-wrap: wrap; row-gap: 2px; }
.settings-row-link {
  flex: 1 1 auto; min-width: 0; min-height: 24px;
  display: flex; align-items: center; gap: 10px;
  color: var(--label);
}
.settings-row-link:hover .settings-row-label { text-decoration: underline; text-underline-offset: 2px; }
.settings-address-box { flex: none; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.settings-address {
  color: var(--label-2); font-size: calc(12px * var(--text-scale));
  user-select: text; -webkit-user-select: text; cursor: text;
  overflow-wrap: anywhere;
}
.settings-copy {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: var(--label-2);
}
.settings-copy:hover { background: var(--hover); color: var(--label); }
.settings-copy .icon { width: 14px; height: 14px; }
@container (max-width: 400px) {
  .settings-address-box { margin-inline-start: 30px; }
}

/* The consent row comes from core/consent.js, in a .form box of its own inside the card. */
.settings-card > .settings-consent { border-radius: 0; background: transparent; }
.settings-card > .settings-consent + .settings-row::before {
  content: ""; position: absolute; top: 0; inset-inline: 12px 0;
  border-top: 0.5px solid var(--hairline);
}

/* ⑦ Credits: centred, no card, 10 px secondary, +3 px leading. */
.settings-credits {
  margin: 4px 24px 16px; padding-block-start: 22px;
  text-align: center; font-size: calc(10px * var(--text-scale)); line-height: calc(1em + 3px + 0.2em); color: var(--label-2);
}
.settings-credits p { margin: 0; }
.settings-credits-made { white-space: pre-line; margin-block-start: 0; }
.settings-credits .settings-credits-version { margin-block-start: 18px; font-variant-numeric: tabular-nums; }
.settings-credits .settings-credits-year { margin-block-start: 6px; }

/* ---------------------------------------------------------------- the tip jar sheet (460 wide) */

.settings-tipjar .sheet-body { background: var(--page); padding: 4px 16px 18px; }
.settings-jar { display: flex; flex-direction: column; gap: 16px; padding-block-start: 12px; }

.settings-tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.settings-tiers.one { grid-template-columns: minmax(0, 1fr); max-width: calc(50% - 6px); width: 100%; margin-inline: auto; }
@media (max-width: 359px) {
  .settings-tiers { grid-template-columns: minmax(0, 1fr); }
  .settings-tiers.one { max-width: none; }
}

button.settings-tier, .settings-tier.owned {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%;
  padding: 18px 12px 12px;
  border-radius: 24px;
  background: var(--row);
  text-align: center;
  transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.15s;
}
button.settings-tier:active:not(:disabled) { transform: scale(0.97); opacity: 0.85; }
button.settings-tier:disabled { cursor: default; }
.settings-sign { display: grid; place-items: center; height: 64px; margin-block-end: 4px; }
.settings-cup {
  display: grid; place-items: center;
  width: 60px; height: 60px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-text);
}
.settings-cup .icon { width: 26px; height: 26px; stroke-width: 1.9; }
.settings-tier-title { font-size: calc(13px * var(--text-scale)); font-weight: 700; color: var(--label); }
.settings-tier-note { font-size: calc(10px * var(--text-scale)); color: var(--label-2); line-height: 1.3; }
.settings-tier-space { flex: 1 1 4px; min-height: 4px; }
.settings-capsule {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; padding: 0 12px;
  border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: calc(13px * var(--text-scale)); font-weight: 700; font-variant-numeric: tabular-nums;
}
.settings-capsule.off { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.settings-pill {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 44px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-text);
  font-size: calc(13px * var(--text-scale)); font-weight: 700;
}
.settings-pill .icon { width: 13px; height: 13px; stroke-width: 2.4; }

.settings-promise { margin: 0; padding: 0 8px; font-size: calc(10px * var(--text-scale)); color: var(--label-2); text-align: center; line-height: 1.35; }
.settings-promise.small { margin-block-start: -10px; }

.settings-extras { display: flex; flex-direction: column; gap: 2px; }
.settings-hair { height: 1px; background: var(--hairline); }
.settings-extras-line { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.settings-extras-line.single { grid-template-columns: minmax(0, 1fr); }
.settings-extra {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 0; min-height: 44px; padding: 0 6px;
  font-size: calc(11px * var(--text-scale)); font-weight: 600; color: var(--accent-text);
  white-space: nowrap; overflow: hidden;
}
.settings-extra:hover span { text-decoration: underline; text-underline-offset: 2px; }
.settings-extra .icon { width: 13px; height: 13px; stroke-width: 2; }
.settings-extra .short { display: none; }
.settings-extras-line.short-words .settings-extra .long { display: none; }
.settings-extras-line.short-words .settings-extra .short { display: inline; }
.settings-extras-sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--label-2) 40%, transparent); }
.settings-quiet-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px;
  min-height: 32px;
  font-size: calc(10px * var(--text-scale)); color: var(--label-2);
}
.settings-quiet { color: var(--label-2); font-size: calc(10px * var(--text-scale)); display: inline-flex; align-items: center; gap: 4px; }
.settings-quiet:hover { color: var(--label); text-decoration: underline; text-underline-offset: 2px; }
.settings-dot { color: var(--label-3); }

/* The provider's donation panel in a sheet. */
.settings-provider .sheet-body { display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--page); }
.settings-provider-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.settings-provider-hint { margin: 0; padding: 10px 16px; font-size: calc(11px * var(--text-scale)); color: var(--label-2); text-align: center; border-bottom: 0.5px solid var(--hairline); }
.settings-provider-frame { position: relative; flex: 1; min-height: 0; background: #fff; }
.settings-provider-iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.settings-provider-wait { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.settings-provider .sheet-foot { justify-content: space-between; }
.settings-provider-tab { font-size: calc(13px * var(--text-scale)); }
.settings-provider-tab .icon { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- Welcome / What's New (480 × 620) */

.settings-whatsnew { --settings-continue: #C8770A; }
.settings-whatsnew .sheet-body { display: flex; padding: 0; overflow: hidden; }
.settings-wn { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.settings-wn-list { display: flex; flex-direction: column; gap: 34px; padding: 64px 32px 24px; }
.settings-wn-list.compact { gap: 22px; padding: 44px 28px 24px; }
.settings-wn-title { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.15; color: var(--label); }
.settings-wn-list.compact .settings-wn-title { margin-block-end: 6px; }
.settings-wn-item { display: flex; align-items: flex-start; gap: 18px; }
.settings-wn-list.compact .settings-wn-item { gap: 16px; }
.settings-wn-icon { flex: none; width: 44px; display: flex; justify-content: center; color: var(--accent); }
.settings-wn-icon .icon { stroke-width: 1.6; }
.settings-wn-tool { padding-block-start: 2px; color: var(--accent); }
.settings-wn-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.settings-wn-list.compact .settings-wn-text { gap: 2px; }
.settings-wn-name { font-size: calc(15px * var(--text-scale)); font-weight: 600; color: var(--label); }
.settings-wn-line { margin: 0; font-size: calc(15px * var(--text-scale)); line-height: 1.3; color: var(--label-2); }
.settings-wn-list.compact .settings-wn-name { font-size: calc(13px * var(--text-scale)); font-weight: 700; }
.settings-wn-list.compact .settings-wn-line { font-size: calc(11px * var(--text-scale)); }
.settings-whatsnew .sheet-foot { border-top: 0; padding: 0 24px 16px; min-height: 0; justify-content: stretch; }
.settings-continue {
  flex: 1;
  padding: 17px 16px;
  border-radius: 999px;
  background: var(--settings-continue); color: #fff;
  font-size: calc(13px * var(--text-scale)); font-weight: 700; text-align: center;
  transition: filter 0.12s, transform 0.12s;
}
.settings-continue:hover { filter: brightness(1.06); }
.settings-continue:active { transform: scale(0.99); }
@media (max-width: 639px) {
  .settings-whatsnew .sheet-foot { padding-block-end: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .settings-wn-list { padding-block-start: calc(64px + env(safe-area-inset-top, 0px)); }
  .settings-wn-list.compact { padding-block-start: calc(44px + env(safe-area-inset-top, 0px)); }
}

/* The App Store badge, on phones only (the sidebar carries it on wider windows). */
.settings-badge { display: none; justify-content: center; padding-block: 8px 0; }
@media (max-width: 639px) { .settings-badge { display: flex; } }
.settings-credits-legal { font-size: calc(10px * var(--text-scale)); color: var(--label-3); max-width: 420px; margin: 6px auto 0; text-align: center; line-height: 1.4; }

/* The account sheet's rows: "Change" or "Add" at the trailing edge. */
.settings-signin { flex: none; color: var(--accent-text); font-size: calc(13px * var(--text-scale)); font-weight: 600; }

/* ---------------------------------------------------------------- ENYO Sync's sign-in sheet */

.ensync-signin { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 8px; }
.ensync-pane, .ensync-form, .ensync-step-body { display: flex; flex-direction: column; gap: 12px; }
.ensync-pane > .ensync-social:not(:empty) { margin-block-end: 0; }
.ensync-step-body[hidden], .ensync-step[hidden] { display: none; }
.ensync-step { margin: 0; font-size: calc(11px * var(--text-scale)); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.06em; }
/* "for anna@example.com · Change" over the password. */
.ensync-for { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: calc(13px * var(--text-scale)); color: var(--label-2); min-width: 0; }
.ensync-for > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label); font-weight: 600; }
/* A password field with Show / Hide at its trailing edge. */
.ensync-pass { position: relative; }
.ensync-pass .ensync-field { padding-inline-end: 40px; }
.ensync-reveal {
  position: absolute; inset-block: 0; inset-inline-end: 2px;
  width: 36px; display: grid; place-items: center;
  color: var(--label-2); border-radius: 8px;
}
.ensync-reveal:hover { color: var(--label); }
.ensync-reveal .icon { width: 18px; height: 18px; }
/* What the new password needs, ticked as it is met. */
.ensync-rules { list-style: none; margin: -2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ensync-rule { display: flex; align-items: center; gap: 6px; font-size: calc(12px * var(--text-scale)); color: var(--label-2); }
.ensync-rule-mark { display: inline-flex; color: var(--label-3); }
.ensync-rule-mark .icon { width: 14px; height: 14px; }
.ensync-rule.met { color: var(--label); }
.ensync-rule.met .ensync-rule-mark { color: var(--green); }
/* First and last name side by side, stacked on a narrow sheet. */
.ensync-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 380px) { .ensync-names { grid-template-columns: 1fr; } }
.ensync-sent { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding-block: 8px 0; }
.ensync-sent .ensync-lead { max-width: 34ch; }
.ensync-sent .ensync-links { justify-content: center; }
.ensync-sent-mark { width: 36px; height: 36px; color: var(--accent-text); }
.ensync-lead { margin: 0; font-size: calc(13px * var(--text-scale)); color: var(--label-2); line-height: 1.45; }
.ensync-field { width: 100%; box-sizing: border-box; }
.ensync-code { font-variant-numeric: tabular-nums; letter-spacing: 0.3em; text-align: center; font-size: calc(17px * var(--text-scale)); }
.ensync-go { width: 100%; }
.ensync-note { margin: 0; min-height: 1em; font-size: calc(12px * var(--text-scale)); color: var(--red, #c4322b); }
.ensync-note:empty { display: none; }
.ensync-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ensync-link { font-size: calc(12px * var(--text-scale)); }
.ensync-social { display: flex; flex-direction: column; gap: 8px; }
.ensync-social:empty { display: none; }
.ensync-provider { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 40px; border-radius: 10px; font-weight: 600; }
.ensync-provider.apple { background: #000; color: #fff; }
.ensync-provider.google { background: #fff; color: #1f1f1f; border: 1px solid #747775; }
/* On a dark sheet: Apple's white button, Google's dark theme (their guidelines). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ensync-provider.apple { background: #fff; color: #000; }
  :root:not([data-theme="light"]) .ensync-provider.google { background: #131314; color: #e3e3e3; border-color: #8e918f; }
}
:root[data-theme="dark"] .ensync-provider.apple { background: #fff; color: #000; }
:root[data-theme="dark"] .ensync-provider.google { background: #131314; color: #e3e3e3; border-color: #8e918f; }
.ensync-provider-mark { display: inline-flex; }
.ensync-or { display: flex; align-items: center; gap: 10px; color: var(--label-3, var(--label-2)); font-size: calc(11px * var(--text-scale)); }
.ensync-or::before, .ensync-or::after { content: ""; flex: 1; height: 0.5px; background: var(--hairline); }

/* ---------------------------------------------------------------- the account sheet (views/account.js) */

.account-sheet { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 8px; }
.account-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.account-who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.account-name { margin: 0; font-size: calc(17px * var(--text-scale)); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-email { margin: 0; font-size: calc(13px * var(--text-scale)); color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sheet .settings-footer { padding-block-start: 0; margin-block-start: -6px; }
.account-sign-out { align-self: center; color: var(--red); font-weight: 600; }
/* Delete Account's Danger Zone: set apart at the foot, outlined in red. */
.account-danger {
  margin-block-start: 18px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
  border-radius: 12px;
}
.account-danger-title {
  margin: 0; font-size: calc(11px * var(--text-scale)); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--red);
}
.account-danger-text { margin: 0; font-size: calc(12px * var(--text-scale)); color: var(--label-2); line-height: 1.4; }
.account-delete {
  color: var(--red); font-weight: 600;
  background: color-mix(in srgb, var(--red) 10%, transparent);
}
.account-delete:hover { background: color-mix(in srgb, var(--red) 18%, transparent); }
/* "Signed in with Apple / Google": the provider's own mark in the icon's place. */
.account-way-mark svg { width: 15px; height: 15px; }
/* ENYO Sync's row: "Live" while the account's channel is open (core/live.js). */
.account-live { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: calc(11px * var(--text-scale)); font-weight: 600; color: var(--green); }
.account-live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
