/* Settings (page-settings.ts, #profile): the app's Settings tab.
 *
 * Phone (< 768px) is the app: one column, 16px margins, 18px between
 * sections (14 after the profile card), the app's type and measurements
 * (docs/web-parity/audit/04-collection-settings.md §A4; settings.tsx and
 * components/settings/*). Wide: the same sections in a centred settings
 * column, max 720px, with a page title and six themes to a row.
 * Colours are tokens only (tokens.css), including the fixed ones the app
 * hard-codes: --tb-gold*, --tb-discord*, --tb-theme-lock-*.
 */

/* (.main-content > .st-page outranks the shell's 1200px column rule.) */
.st-page, .main-content > .st-page { max-width: 720px; position: relative; isolation: isolate; }

/* settings.tsx background: primary @0x38 from the top left, primaryLight @0x1A
   from the right, behind the whole screen (fixed, so it never widens the page). */
.st-glow {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(60vw 60vh at 0% 0%, rgba(var(--tb-primary-rgb), 0.2), transparent 70%),
        radial-gradient(50vw 70vh at 100% 25%, rgba(var(--tb-primary-light-rgb), 0.1), transparent 70%);
}

.st-title { margin-bottom: 20px; }

/* ── Section scaffolding ───────────────────────────────────────────────── */
.st-section { margin-bottom: 18px; }
.st-eyebrow {
    margin: 0 0 8px 4px; font-size: 10px; font-weight: 800; letter-spacing: 1.4px;
    color: var(--tb-primary-light); line-height: 1.3;
}
.st-eyebrow--locked { color: var(--tb-accent); }

.st-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 14px; border-radius: var(--tb-r-row); border: 1px solid var(--tb-border); background: var(--tb-bg2);
    color: var(--tb-text); text-align: left; font: inherit; text-decoration: none;
}
.st-row + .st-row { margin-top: 10px; }
.st-section--tight .st-row + .st-row,
.st-section--tight .st-disclosure + .st-row { margin-top: 8px; }
.st-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-row__title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--tb-text); line-height: 1.35; }
.st-row__sub { margin: 2px 0 0; font-size: 11px; line-height: 1.45; color: var(--tb-muted); }
.st-row__sub--strong { color: var(--tb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-row--link { cursor: pointer; transition: border-color var(--tb-dur) var(--tb-ease), background var(--tb-dur) var(--tb-ease); }
.st-row--link:hover { border-color: var(--tb-border-strong); }
.st-row__chev { color: var(--tb-muted); transition: transform var(--tb-dur) var(--tb-ease); }
.st-disclosure.is-open .st-row__chev--down { transform: rotate(180deg); }
.st-skel-sub { display: inline-block; width: 120px; height: 10px; margin-top: 3px; vertical-align: middle; }

.st-disclosure__panel {
    margin-top: 8px; padding: 12px 14px 6px; border-radius: var(--tb-r-row);
    border: 1px solid var(--tb-border); background: var(--tb-bg2);
}
.st-disclosure__intro { margin: 0 0 4px; }

/* ── Profile card (ProfileCard.tsx) ────────────────────────────────────── */
.st-profile {
    position: relative; overflow: hidden; margin-bottom: 14px;
    display: flex; align-items: center; gap: 14px; padding: 16px;
    border-radius: var(--tb-r-card); border: 1px solid var(--tb-border);
    background: linear-gradient(135deg, rgba(var(--tb-primary-rgb), 0.1), transparent 70%), var(--tb-bg2);
}
.st-profile__avatar {
    width: 72px; height: 72px; border-radius: 18px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--tb-bg); border: 1px solid rgba(var(--tb-primary-rgb), 0.45);
    color: var(--tb-text); font-size: 24px; font-weight: 800;
}
.st-profile__text { flex: 1; min-width: 0; }
.st-profile__name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.st-profile__name {
    margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.3px; color: var(--tb-text); line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.st-profile__tick {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tb-primary); color: var(--tb-on-primary); font-size: 10px;
}
.st-profile__tick .tb-icon { width: 10px; height: 10px; }
.st-profile__handle { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--tb-primary-light); }
.st-profile__email {
    margin: 6px 0 0; font-size: 12px; color: var(--tb-text2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Currency pill (PreferencesCard.tsx) ───────────────────────────────── */
.st-cur {
    display: inline-flex; flex-shrink: 0; padding: 3px; border-radius: var(--tb-r-pill);
    border: 1px solid var(--tb-border); background: rgba(var(--tb-primary-rgb), 0.1);
}
.st-cur__btn {
    display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border: 0; border-radius: var(--tb-r-pill);
    background: transparent; color: var(--tb-text2); font: inherit; cursor: pointer;
    transition: background var(--tb-dur) var(--tb-ease), color var(--tb-dur) var(--tb-ease), box-shadow var(--tb-dur) var(--tb-ease);
}
.st-cur__btn.is-active {
    background: var(--tb-primary); color: var(--tb-on-primary);
    box-shadow: 0 2px 8px rgba(var(--tb-primary-rgb), 0.4);
}
.st-cur__sym { font-size: 13px; font-weight: 800; line-height: 1; }
.st-cur__code { font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; opacity: 0.92; line-height: 1; }

/* ── Pro chip, shared by both subscription states ──────────────────────── */
.st-chip {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
    padding: 4px 9px; border-radius: 6px; background: var(--tb-gold); color: var(--tb-gold-ink);
    font-size: 10px; font-weight: 900; letter-spacing: 1.5px; line-height: 1.2;
}

/* ── Pro active (SubscriptionCard.tsx, isPro) ──────────────────────────── */
.st-active {
    margin-bottom: 18px; padding: 14px; border-radius: var(--tb-r-row);
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px;
    border: 1px solid rgba(var(--tb-primary-rgb), 0.45); background: var(--tb-bg2);
}
.st-active__row { grid-column: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.st-active__row .st-chip { align-self: center; }
.st-active__title { white-space: nowrap; }
/* Web only: where Pro comes from and when it renews or ends. */
.st-active__detail { grid-column: 1; margin: 6px 0 0; font-size: 11px; line-height: 1.45; color: var(--tb-muted); }
.st-active .st-manage { grid-column: 2; grid-row: 1 / span 2; }
.st-manage { margin-left: auto; }
/* Web only: where Pro comes from and when it renews or ends. */
.st-active__detail { margin: 8px 0 0; font-size: 11px; line-height: 1.45; color: var(--tb-muted); }
.st-manage {
    flex-shrink: 0; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--tb-border);
    color: var(--tb-text2); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.st-manage:hover { border-color: var(--tb-border-strong); color: var(--tb-text); }

/* ── Upgrade card (SubscriptionCard.tsx, not Pro) ──────────────────────── */
.st-upgrade {
    position: relative; overflow: hidden; margin-bottom: 18px; padding: 16px;
    display: flex; flex-direction: column;
    border-radius: var(--tb-r-card); border: 1px solid rgba(var(--tb-primary-rgb), 0.45);
    background:
        radial-gradient(70% 60% at 100% 0%, rgba(var(--tb-gold-rgb), 0.18), transparent 70%),
        linear-gradient(135deg, rgba(var(--tb-primary-rgb), 0.32), rgba(var(--tb-primary-rgb), 0.1) 50%, rgba(var(--tb-gold-rgb), 0.1)),
        var(--tb-bg2);
}
.st-upgrade__title { margin: 12px 0 0; font-size: 19px; font-weight: 800; letter-spacing: -0.3px; color: var(--tb-text); line-height: 1.25; }
.st-upgrade__sub { margin: 4px 0 0; font-size: 12px; line-height: 18px; color: var(--tb-text2); }
.st-upgrade__ended { margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--tb-warning); }
.st-upgrade__benefits { list-style: none; margin: 14px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.st-upgrade__benefits li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--tb-text); }
.st-upgrade__check {
    width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(var(--tb-gold-rgb), 0.18); border: 1px solid rgba(var(--tb-gold-rgb), 0.5); color: var(--tb-gold-text);
}
.st-upgrade__check .tb-icon { width: 10px; height: 10px; }
.st-upgrade__how { margin: 0 0 10px; text-align: center; font-size: 12px; font-weight: 600; color: var(--tb-text2); }
.st-upgrade .tb-store-badges { margin-top: 0; }
.st-check {
    align-self: center; margin-top: 10px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent;
    color: var(--tb-primary-light); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.st-check:hover:not(:disabled) { background: var(--tb-primary-tint-weak); }
.st-check:disabled { opacity: 0.6; cursor: default; }
.st-upgrade__legal { margin-top: 6px; }
.st-upgrade__legal a, .st-upgrade__legal span { color: var(--tb-text2); }

/* ── Themes (ThemesGrid.tsx) ───────────────────────────────────────────── */
.st-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.st-themes + .st-eyebrow { margin-top: 4px; }
.st-themes:last-child { margin-bottom: 0; }
.st-theme {
    display: flex; flex-direction: column; min-width: 0; padding: 7px; border-radius: 13px;
    border: 1px solid var(--tb-border); background: var(--tb-bg2); color: var(--tb-text);
    font: inherit; text-align: left; cursor: pointer;
    transition: border-color var(--tb-dur) var(--tb-ease), transform var(--tb-dur) var(--tb-ease);
}
.st-theme:hover { border-color: var(--tb-border-strong); }
/* 1.5px selected ring without moving the layout: the extra half pixel is a shadow. */
.st-theme.is-selected { border-color: var(--tb-primary); box-shadow: 0 0 0 0.5px var(--tb-primary); }
.st-theme.is-locked.is-selected { border-color: var(--tb-border); box-shadow: none; }
.st-theme__preview {
    position: relative; display: block; height: 46px; border-radius: 8px; overflow: hidden;
    background: linear-gradient(135deg, var(--tb-bg2) 20%, var(--tb-bg));
}
.st-theme__grad { position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: linear-gradient(90deg, var(--tb-grad-from), var(--tb-grad-to)); }
.st-theme__dots { position: absolute; top: 6px; left: 6px; display: flex; gap: 3px; }
.st-theme__dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--tb-bg); }
.st-theme__dots i:nth-child(1) { background: var(--tb-primary); }
.st-theme__dots i:nth-child(2) { background: var(--tb-accent); }
.st-theme__dots i:nth-child(3) { background: var(--tb-success); }
.st-theme__veil { position: absolute; inset: 0; background: var(--tb-theme-lock-veil); }
.st-theme__lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--tb-theme-lock-fg); font-size: 13px; }
/* The tick is the ACTIVE theme's, drawn over the previewed one. */
.st-theme__tick {
    position: absolute; top: 5px; right: 5px; width: 17px; height: 17px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.st-theme .st-theme__tick { background: var(--st-active-primary); color: var(--st-active-on-primary); }
.st-page { --st-active-primary: var(--tb-primary); --st-active-on-primary: var(--tb-on-primary); }
/* Names wrap rather than clip ("Cherry Blossom", "Porcelain PRO" in a third of a phone). */
.st-theme__label { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-top: 6px; min-width: 0; }
.st-theme__name { font-size: 11.5px; font-weight: 800; line-height: 1.3; color: var(--tb-text); min-width: 0; overflow-wrap: anywhere; }
.st-theme.is-locked .st-theme__name { color: var(--tb-text2); }
.st-theme__pro {
    display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; padding: 1.5px 4px; border-radius: var(--tb-r-pill);
    background: var(--tb-accent); color: var(--tb-bg); font-size: 7.5px; font-weight: 900; letter-spacing: 0.3px; line-height: 1.2;
}

/* ── Footer (SignOutBlock.tsx) ─────────────────────────────────────────── */
.st-footer { display: flex; flex-direction: column; padding-top: 4px; }
.st-btn {
    height: 46px; border-radius: 12px; border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-size: 13.5px; font-weight: 700; text-decoration: none; cursor: pointer;
    transition: filter var(--tb-dur) var(--tb-ease), border-color var(--tb-dur) var(--tb-ease);
}
.st-btn + .st-btn { margin-top: 10px; }
.st-btn--discord { background: var(--tb-discord); border-color: var(--tb-discord); color: var(--tb-discord-fg); }
.st-btn--discord:hover { filter: brightness(1.08); }
.st-btn--support { background: var(--tb-surface); border-color: var(--tb-border); color: var(--tb-text2); }
.st-btn--support:hover { border-color: var(--tb-border-strong); color: var(--tb-text); }
.st-btn--signout { background: rgba(var(--tb-error-rgb), 0.08); border-color: rgba(var(--tb-error-rgb), 0.28); color: var(--tb-error); }
.st-btn--signout:hover { border-color: rgba(var(--tb-error-rgb), 0.5); }
.st-delete {
    align-self: center; margin-top: 12px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--tb-muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.st-delete:hover { color: var(--tb-error); }
.st-legal { margin: 14px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 11.5px; font-weight: 700; }
.st-legal a, .st-legal span { color: var(--tb-muted); text-decoration: none; }
.st-legal a:hover { color: var(--tb-text); text-decoration: underline; }
.st-disclaimer { margin: 12px 0 0; padding: 0 8px; text-align: center; font-size: 9.5px; line-height: 13px; color: var(--tb-muted); }
.st-build { margin: 16px 0 0; text-align: center; font-size: 10px; font-weight: 600; letter-spacing: 0.6px; color: var(--tb-muted); }

/* ── Dialogs (sign out, delete account, Pro themes) ────────────────────── */
.st-modal-text { margin: 0; font-size: 14px; line-height: 1.55; color: var(--tb-text2); }
.st-modal-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--tb-muted); }
.st-modal-error { margin: 12px 0 0; font-size: 12.5px; font-weight: 600; line-height: 1.45; color: var(--tb-error); }
.st-delete-field { margin-top: 14px; }
.tb-modal .tb-store-badges { margin-top: 14px; }
.tb-modal .st-check { display: block; margin: 8px auto 0; }

/* ── Layout ────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    /* The app has no title here: the top bar carries the wordmark. */
    .st-page { padding-top: 12px; padding-bottom: 120px; }
    .st-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
}

@media (min-width: 600px) {
    .st-themes { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
    .st-profile { padding: 20px; }
    .st-upgrade { padding: 20px; }
    .st-section { margin-bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    .st-row__chev, .st-theme, .st-cur__btn, .st-btn { transition: none; }
}
