/*
    Settings > Email Preferences (emp-*): one column of big switch rows grouped by what they watch, a strip with the
    recipient and the count, the AI Money Story card and the save bar. Phone-first: 16px gutters, rows at least 56px
    tall, the switch always on the right, the save bar in reach. Group hues follow the design system's area colors
    (cash aqua, cards rose, investments green, partner violet); the rest is the Settings grey family. Dark follows
    data-bs-theme="dark" on <html>.
*/

:root {
    --emp-text: var(--set-text);
    --emp-muted: var(--set-muted);
    --emp-light: var(--set-light);
    --emp-card: var(--set-card);
    --emp-border: var(--set-card-border);
    --emp-surface: var(--set-surface);
    --emp-violet: var(--set-ink);
    --emp-violet-soft: var(--set-icon-bg);
    --emp-positive: #16A34A;
    --emp-critical: #DC2626;
    --emp-strip-bg: var(--set-hero-bg);
    --emp-strip-border: var(--set-hero-border);
    --emp-story-bg: var(--set-section-bg);
    --emp-story-border: var(--set-section-border);
    --emp-glass: var(--set-glass);
    --emp-glass-border: var(--set-glass-border);
    --emp-focus: var(--set-focus);
}

[data-bs-theme="dark"] {
    --emp-positive: #22C55E;
    --emp-critical: #F87171;
}

.emp-page { color: var(--emp-text); max-width: 880px; }
.emp-page * { box-sizing: border-box; }
.emp-head { margin-bottom: 1rem; }
.emp-head-titles { max-width: 46rem; }
.emp-form { display: grid; gap: .9rem; }

/* The strip */
.emp-strip {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .8rem 1rem;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--emp-strip-border);
    background: var(--emp-strip-bg);
}

.emp-strip-bg { position: absolute; inset: 0; z-index: -1; background: var(--set-glow-user), var(--set-glow-partner); }
.emp-who { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.emp-who-avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: var(--set-icon-bg); color: var(--set-ink); font-weight: 800; font-size: 1.1rem; border: 1px solid var(--set-card-border); }
.emp-who-text { display: grid; min-width: 0; }
.emp-who-text strong { font-size: .95rem; }
.emp-who-text span { color: var(--emp-muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp-strip-stats { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.emp-ring { position: relative; width: 46px; height: 46px; flex: 0 0 auto; }
.emp-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.emp-ring-track { fill: none; stroke: var(--emp-glass-border); stroke-width: 4; }
.emp-ring-fill { fill: none; stroke: var(--set-accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: calc(var(--emp-ratio, 0) * 100) 100; transition: stroke-dasharray .5s cubic-bezier(.2, .8, .2, 1); }
.emp-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.emp-strip-text { display: grid; gap: .05rem; }
.emp-strip-text strong { font-size: .9rem; }
.emp-strip-text span { color: var(--emp-muted); font-size: .76rem; }
.emp-strip-actions { display: flex; gap: .35rem; }
.emp-mini { padding: .3rem .6rem; border-radius: 999px; border: 1px solid var(--emp-glass-border); background: var(--emp-glass); color: var(--emp-muted); font-size: .72rem; font-weight: 700; cursor: pointer; backdrop-filter: blur(8px); }
.emp-mini:hover { color: var(--emp-violet); }
.emp-mini:focus-visible { outline: none; box-shadow: var(--emp-focus); }

/* Groups and rows */
.emp-group { --emp-hue: var(--set-accent); padding: .9rem 1rem 1rem; border-radius: 18px; border: 1px solid var(--set-section-border); background: var(--set-section-bg); animation: emp-rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.emp-group:nth-of-type(2) { animation-delay: .05s; }
.emp-group:nth-of-type(3) { animation-delay: .1s; }
.emp-group:nth-of-type(4) { animation-delay: .15s; }
@keyframes emp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.emp-group-title { display: flex; align-items: center; gap: .55rem; margin: 0 0 .35rem; font-size: .92rem; font-weight: 700; }
.emp-group-glyph { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 10px; background: var(--set-icon-bg); color: var(--set-icon); font-size: .8rem; }

.emp-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 60px;
    margin: 0;
    padding: .65rem .25rem;
    border-top: 1px solid var(--emp-border);
    cursor: pointer;
    transition: background-color .15s ease;
}

.emp-group-title + .emp-row { border-top: 0; }
.emp-row:hover { background: var(--set-surface); border-radius: 12px; }
.emp-row-glyph { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; background: var(--set-card); border: 1px solid var(--set-card-border); color: var(--set-icon); font-size: .9rem; }
.emp-row-text { display: grid; gap: .1rem; min-width: 0; flex: 1 1 auto; }
.emp-row-text strong { font-size: .92rem; }
.emp-row-text > span { color: var(--emp-muted); font-size: .78rem; line-height: 1.35; }
.emp-row-note { margin-top: .2rem; color: var(--emp-light) !important; font-size: .74rem !important; }
.emp-row-note.is-on { color: var(--emp-positive) !important; font-weight: 600; }
.emp-row-note i { margin-right: .25rem; }

/* The switch */
.emp-switch { position: relative; display: inline-flex; flex: 0 0 auto; width: 50px; height: 30px; }
.emp-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.emp-switch input:disabled { cursor: not-allowed; }
.emp-switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--emp-surface); border: 1px solid var(--emp-border); transition: background-color .2s ease, border-color .2s ease; }
.emp-switch-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.emp-switch input:checked + .emp-switch-track { background: var(--set-accent); border-color: var(--set-accent); }
.emp-switch input:checked + .emp-switch-track .emp-switch-thumb { transform: translateX(20px); }
.emp-switch input:focus-visible + .emp-switch-track { box-shadow: var(--emp-focus); }
.emp-switch input:disabled + .emp-switch-track { opacity: .5; }

/* The money story card */
.emp-story { position: relative; isolation: isolate; overflow: hidden; padding: .6rem 1rem .8rem; border-radius: 18px; border: 1px solid var(--emp-story-border); background: var(--emp-story-bg); animation: emp-rise .4s cubic-bezier(.2, .8, .2, 1) .2s both; }
.emp-story-bg { position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 100% 100%, rgba(246, 196, 83, .14), transparent 55%); }
.emp-story .emp-row { border-top: 0; cursor: default; }
.emp-story .emp-row:hover { background: transparent; }
.emp-story.is-on .emp-row-glyph { background: var(--set-ink); border-color: var(--set-ink); color: var(--set-card); }
/* The All Access tag follows the accent preference (settings-theme.css --set-plan*), as on mobile. */
.emp-badge { display: inline-flex; align-items: center; gap: .3rem; margin-left: .4rem; padding: .12rem .5rem; border-radius: 999px; background: var(--set-plan-soft); color: var(--set-plan); font-size: .64rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.emp-unlock { display: inline-flex; align-items: center; gap: .4rem; margin: 0 0 .2rem 3.3rem; padding: .4rem .8rem; border: 0; border-radius: 999px; background: #F6C453; color: #3E3121; font-size: .78rem; font-weight: 800; cursor: pointer; }

/* The daily cap stepper */
.emp-row.is-cap { cursor: default; }
.emp-row.is-cap:hover { background: transparent; }
.emp-stepper { display: inline-flex; align-items: center; flex: 0 0 auto; border-radius: 999px; border: 1px solid var(--emp-border); background: var(--emp-surface); overflow: hidden; }
.emp-step { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; background: transparent; color: var(--set-ink); font-size: .85rem; cursor: pointer; }
.emp-step:hover:not(:disabled) { background: var(--set-icon-bg); }
.emp-step:disabled { opacity: .35; cursor: not-allowed; }
.emp-step:focus-visible { outline: none; box-shadow: inset var(--emp-focus); }
.emp-step-value { width: 3.2rem; height: 40px; border: 0; border-left: 1px solid var(--emp-border); border-right: 1px solid var(--emp-border); background: var(--emp-card); color: var(--emp-text); font-weight: 800; font-size: 1rem; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.emp-step-value::-webkit-outer-spin-button, .emp-step-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.emp-step-value:focus { outline: none; box-shadow: inset var(--emp-focus); }

/* Alerts and the save bar */
.emp-alert { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .95rem; border-radius: 14px; border: 1px solid var(--emp-border); font-size: .86rem; }
.emp-alert.is-success { border-left: 4px solid var(--emp-positive); background: color-mix(in srgb, var(--emp-positive) 10%, var(--emp-card)); }
.emp-alert.is-success i { color: var(--emp-positive); }
.emp-alert.is-error { border-left: 4px solid var(--emp-critical); background: color-mix(in srgb, var(--emp-critical) 10%, var(--emp-card)); }
.emp-alert.is-error i { color: var(--emp-critical); }

.emp-save { position: sticky; bottom: .5rem; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .6rem .6rem .6rem 1rem; border: 1px solid var(--emp-glass-border); border-radius: 16px; background: var(--emp-glass); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
.emp-save-note { color: var(--emp-light); font-size: .76rem; }
.emp-save-note i { margin-right: .25rem; color: var(--set-icon); }
.emp-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.2rem;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: var(--set-accent);
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px -14px hsl(calc(247.83deg + var(--ci-accent-shift, 0deg)) 76.3% 58.63% / .7);
    transition: transform .15s ease, filter .2s ease;
}

.emp-btn-primary:not(:disabled):hover { transform: translateY(-1px); filter: saturate(1.1) brightness(1.04); }
.emp-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.emp-btn-primary:focus-visible { outline: none; box-shadow: var(--emp-focus); }
.emp-spin { animation: emp-spin 1s linear infinite; }
@keyframes emp-spin { to { transform: rotate(360deg); } }

@media (max-width: 767.98px) {
    .emp-page { max-width: none; }
    .emp-strip-text strong { font-size: .86rem; }
}

@media (max-width: 575.98px) {
    .emp-strip { padding: .9rem; }
    .emp-strip-stats { width: 100%; }
    .emp-strip-actions { margin-left: auto; }
    .emp-group { padding: .8rem .75rem .6rem; border-radius: 16px; }
    .emp-row { gap: .65rem; padding: .6rem .1rem; }
    .emp-row-glyph { width: 32px; height: 32px; }
    .emp-unlock { margin-left: 0; }
    .emp-save { padding: .5rem; }
    .emp-btn-primary { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .emp-group, .emp-story, .emp-spin { animation: none !important; }
    .emp-switch-thumb, .emp-ring-fill, .emp-btn-primary, .emp-row { transition: none !important; }
}

[data-a11y-reduce-motion="on"] .emp-group, [data-a11y-reduce-motion="on"] .emp-story { animation: none !important; }

/* Budgets 2.0: the digest group (fuchsia glyph) and its schedule pickers. */
.emp-group.is-budgets .emp-group-glyph { background: #FAE8FF; color: #C026D3; }
[data-bs-theme="dark"] .emp-group.is-budgets .emp-group-glyph { background: #3B1F44; color: #E879F9; }
.emp-digest-picks { display: inline-flex; flex-wrap: wrap; gap: .4rem; flex: 0 0 auto; justify-content: flex-end; }
.emp-select { min-height: 34px; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--emp-border); background: var(--emp-surface); color: inherit; font: inherit; font-size: .82rem; }
.emp-select:focus { outline: 2px solid color-mix(in srgb, var(--set-accent) 45%, transparent); outline-offset: 1px; }
.emp-digest-picks .cs-select.emp-pick { min-width: 132px; border-radius: 999px; }
@media (max-width: 640px) { .emp-digest-picks { width: 100%; justify-content: flex-start; } }
