/* ════════════════════════════════════════════════════════════════
   fractured Ego — design system (rebuild)
   Warm, soft, quietly luxurious. Rose is the light in the room.
   Every value is a token so it can change later without a rebuild.
   Moods: <html data-mood="day|dusk|auto">
   ════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Cormorant Garamond'; font-weight: 300; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 300; font-style: italic; font-display: swap; src: url(../fonts/cormorant-garamond-latin-300-italic.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 400; font-style: italic; font-display: swap; src: url(../fonts/cormorant-garamond-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: italic; font-display: swap; src: url(../fonts/cormorant-garamond-latin-500-italic.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format('woff2'); }

/* ── Tokens: Daylight (default) ── */
:root {
  --rose: #ffb6c1;          /* the brand */
  --rose-soft: #ffe3e8;
  --rose-wash: #fff3f5;
  --rose-ink: #a8475c;      /* rose dark enough for text */
  --bg: #fbf7f6;            /* warm white */
  --surface: #ffffff;
  --surface-2: #f7f1f0;
  --grey: #efedee;          /* light grey: notes, quiet fills */
  --ink: #1f1719;           /* warm black */
  --ink-2: #5d5154;
  --ink-3: #8c8184;
  --line: #ece3e2;
  --line-2: #dccfce;
  --danger: #b3261e; --danger-wash: #fdecea;
  --ok: #2e7d5b; --ok-wash: #e8f5ee;
  --shadow-1: 0 1px 2px rgba(60, 30, 36, .06), 0 2px 8px rgba(60, 30, 36, .05);
  --shadow-2: 0 2px 6px rgba(60, 30, 36, .06), 0 18px 48px rgba(60, 30, 36, .10);
  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --r-sm: 12px; --r-md: 18px; --r-lg: 26px; --r-xl: 34px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --spring: linear(0, .009, .035 2.1%, .141, .281 6.7%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .974 53.8%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}
/* ── Tokens: Dusk ── */
:root[data-mood="dusk"] {
  --rose-soft: #4a2c33; --rose-wash: #2b1d21; --rose-ink: #ffc2cc;
  --bg: #171113; --surface: #211819; --surface-2: #2a1f21; --grey: #2f2628;
  --ink: #f7eeee; --ink-2: #cbbcbe; --ink-3: #9a8b8e; --line: #33282a; --line-2: #45383a;
  --danger: #ffb4ab; --danger-wash: #3d1d1a; --ok: #8fd6b3; --ok-wash: #1d3329;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 18px 48px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-mood="auto"] {
    --rose-soft: #4a2c33; --rose-wash: #2b1d21; --rose-ink: #ffc2cc;
    --bg: #171113; --surface: #211819; --surface-2: #2a1f21; --grey: #2f2628;
    --ink: #f7eeee; --ink-2: #cbbcbe; --ink-3: #9a8b8e; --line: #33282a; --line-2: #45383a;
    --danger: #ffb4ab; --danger-wash: #3d1d1a; --ok: #8fd6b3; --ok-wash: #1d3329;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 18px 48px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; scroll-behavior: smooth; }
body { min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--rose); color: #1f1719; }
:focus-visible { outline: 2px solid var(--rose-ink); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── Type ── */
.fe-display { font: 300 clamp(2.6rem, 7vw, 4.6rem)/1.02 var(--serif); letter-spacing: -.02em; text-wrap: balance; }
.fe-title { font: 400 clamp(2rem, 5vw, 2.9rem)/1.08 var(--serif); letter-spacing: -.015em; text-wrap: balance; }
.fe-h2 { font: 400 clamp(1.6rem, 3.6vw, 2.1rem)/1.15 var(--serif); letter-spacing: -.01em; }
.fe-h3 { font: 600 17px/1.35 var(--sans); }
.fe-display em, .fe-title em, .fe-h2 em { font-style: italic; }
.fe-lead { font-size: 17px; line-height: 1.65; color: var(--ink-2); max-width: 46ch; text-wrap: pretty; }
.fe-small { font-size: 13.5px; color: var(--ink-3); line-height: 1.6; }
.fe-eyebrow { font: 500 13px var(--sans); color: var(--rose-ink); letter-spacing: .01em; }

/* ── Light & grain ── */
.fe-light { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--bg); }
.fe-light::before, .fe-light::after { content: ''; position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.fe-light::before { width: 70vmax; height: 70vmax; left: -20vmax; top: -30vmax; background: radial-gradient(circle, var(--rose) 0%, transparent 62%); animation: drift 26s ease-in-out infinite alternate; }
.fe-light::after { width: 60vmax; height: 60vmax; right: -25vmax; bottom: -30vmax; background: radial-gradient(circle, var(--rose-soft) 0%, transparent 65%); animation: drift 32s ease-in-out infinite alternate-reverse; }
.fe-light i { position: absolute; inset: 0; background-image: var(--grain); opacity: .07; mix-blend-mode: multiply; }
:root[data-mood="dusk"] .fe-light::before { opacity: .22; } :root[data-mood="dusk"] .fe-light i { mix-blend-mode: screen; opacity: .05; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.08); } }

/* ── Layout ── */
.fe-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 clamp(18px, 5vw, 40px); }
.fe-narrow { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 20px; }
.fe-header { position: sticky; top: 0; z-index: 50; padding: calc(10px + env(safe-area-inset-top)) clamp(18px, 5vw, 40px) 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); }
.fe-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font: 400 22px var(--serif); color: var(--ink); white-space: pre; }
.fe-brand img { width: 22px; height: 22px; }
.fe-brand .e { color: var(--rose-ink); font-style: italic; }
.fe-nav { display: flex; gap: 4px; align-items: center; }
.fe-nav a { text-decoration: none; font: 500 14px var(--sans); padding: 9px 14px; border-radius: 999px; color: var(--ink-2); transition: background-color .2s, color .2s; }
.fe-nav a:hover { background: var(--grey); color: var(--ink); }
@media (max-width: 560px) { .fe-nav .hide-sm { display: none; } }

/* ── Buttons ── */
.fe-btn { --h: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: var(--h); padding: 0 26px;
  border: none; border-radius: 999px; cursor: pointer; text-decoration: none; font: 600 15.5px var(--sans); letter-spacing: .005em;
  background: var(--ink); color: var(--bg); transition: transform .35s var(--spring), background-color .2s, box-shadow .25s, opacity .2s; -webkit-tap-highlight-color: transparent; }
.fe-btn svg { width: 19px; height: 19px; }
.fe-btn:hover:not(:disabled) { box-shadow: var(--shadow-2); }
.fe-btn:active:not(:disabled) { transform: scale(.97); }
.fe-btn:disabled { opacity: .38; cursor: not-allowed; }
.fe-btn-rose { background: var(--rose); color: #1f1719; }
.fe-btn-soft { background: var(--grey); color: var(--ink); }
.fe-btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.fe-btn-quiet { background: transparent; color: var(--ink-2); padding: 0 12px; height: 44px; }
.fe-btn-quiet:hover:not(:disabled) { box-shadow: none; color: var(--ink); }
.fe-btn-full { width: 100%; }
.fe-btn-sm { --h: 40px; padding: 0 18px; font-size: 14px; }
.fe-btn.armed { background: var(--rose); color: #1f1719; animation: armed 1.6s ease-in-out infinite; }
@keyframes armed { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--rose) 35%, transparent); } }
.fe-spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards & notes ── */
.fe-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: clamp(20px, 4vw, 30px); }
.fe-note { background: var(--grey); border-radius: var(--r-md); padding: 14px 16px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.fe-note strong { color: var(--ink); }
.fe-warn { background: var(--danger-wash); color: var(--danger); border-radius: var(--r-md); padding: 14px 16px; font-size: 14px; line-height: 1.6; display: flex; gap: 12px; }
.fe-warn svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.fe-alert { border-radius: var(--r-md); padding: 12px 16px; font-size: 14.5px; line-height: 1.55; background: var(--danger-wash); color: var(--danger); animation: rise .4s var(--ease) both; }
.fe-alert.ok { background: var(--ok-wash); color: var(--ok); }

/* ── Fields ── */
.fe-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.fe-field label, .fe-label { font: 500 14px var(--sans); color: var(--ink); }
.fe-field label .opt { font-weight: 400; color: var(--ink-3); }
.fe-input { width: 100%; min-height: 54px; padding: 14px 16px; border-radius: var(--r-sm); border: 1.5px solid var(--line-2); background: var(--surface);
  font-size: 16px; color: var(--ink); transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none; }
textarea.fe-input { min-height: 140px; resize: vertical; line-height: 1.55; }
select.fe-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238c8184' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
.fe-input::placeholder { color: var(--ink-3); }
.fe-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rose) 45%, transparent); }
.fe-input.bad { border-color: var(--danger); }
.fe-hint { font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.fe-hint.bad { color: var(--danger); }
.fe-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .fe-row { grid-template-columns: 1fr; } }
.fe-check { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: var(--grey); cursor: pointer; font-size: 14.5px; line-height: 1.5; }
.fe-check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--ink); flex: none; }

/* ── Choices (selectable cards) ── */
.fe-choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; border-radius: var(--r-md); border: 1.5px solid var(--line);
  background: var(--surface); text-align: left; cursor: pointer; transition: border-color .2s, background-color .2s, transform .35s var(--spring), box-shadow .2s; }
.fe-choice:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.fe-choice:active { transform: scale(.985); }
.fe-choice.on { border-color: var(--ink); background: var(--rose-wash); }
.fe-choice .ic { width: 42px; height: 42px; border-radius: 14px; background: var(--grey); display: grid; place-items: center; flex: none; color: var(--rose-ink); }
.fe-choice .ic svg { width: 21px; height: 21px; }
.fe-choice.on .ic { background: var(--rose); color: #1f1719; }
.fe-choice .t { font: 600 15.5px var(--sans); display: block; }
.fe-choice .d { font-size: 13.5px; color: var(--ink-3); display: block; margin-top: 2px; }
.fe-choice .flag { margin-left: auto; font: 600 11px var(--sans); color: var(--danger); background: var(--danger-wash); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.fe-choices { display: grid; gap: 10px; }
.fe-choices.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .fe-choices.two { grid-template-columns: 1fr; } }

/* ── Screens (the gift flow) ── */
.fe-screen { animation: rise .7s var(--ease) both; }
.fe-screen.leaving { animation: sink .28s var(--ease-soft) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes sink { to { opacity: 0; transform: translateY(-10px); } }
.fe-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--rose); z-index: 60; transition: width .8s var(--ease); border-radius: 0 3px 3px 0; }

/* ── The reveal: light through a seam ── */
.fe-reveal { position: relative; text-align: center; padding: 30px 0 10px; }
.fe-seam { position: relative; height: 2px; margin: 0 auto 34px; width: 0; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--rose) 20%, #fff 50%, var(--rose) 80%, transparent);
  box-shadow: 0 0 24px 6px color-mix(in srgb, var(--rose) 70%, transparent); animation: seam 1.4s var(--ease) .2s forwards; }
@keyframes seam { to { width: min(420px, 80%); } }
.fe-amount { font: 300 clamp(4rem, 17vw, 7.5rem)/1 var(--serif); letter-spacing: -.03em; opacity: 0; filter: blur(14px); transform: translateY(8px) scale(.98);
  animation: bloom 1.6s var(--ease) 1.1s forwards; }
@keyframes bloom { to { opacity: 1; filter: blur(0); transform: none; } }
.fe-after { opacity: 0; animation: rise .9s var(--ease) forwards; }
.fe-glow { position: absolute; left: 50%; top: 40%; width: 520px; height: 260px; transform: translate(-50%, -50%); z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--rose) 60%, transparent), transparent 70%); filter: blur(30px); opacity: 0; animation: glow 2.4s var(--ease) 1s forwards; }
@keyframes glow { to { opacity: .85; } }

/* ── Mend (status) ── */
.fe-mend { width: 100%; height: 56px; overflow: visible; }
.fe-mend .crack { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-linejoin: round; }
.fe-mend .heal { fill: none; stroke: var(--rose-ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; transition: stroke-dashoffset 1.6s var(--ease); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rose) 80%, transparent)); }
.fe-stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.fe-stages span { font: 500 12.5px var(--sans); color: var(--ink-3); text-align: center; }
.fe-stages span.on { color: var(--ink); }

/* ── Toast ── */
.fe-toasts { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.fe-toast { background: var(--ink); color: var(--bg); padding: 13px 18px; border-radius: 14px; font-size: 14.5px; box-shadow: var(--shadow-2); animation: rise .45s var(--spring) both; }

/* ── Prose (policy and help pages) ── */
.fe-prose { font-size: 16.5px; line-height: 1.75; color: var(--ink-2); }
.fe-prose h2 { font: 400 1.75rem/1.2 var(--serif); color: var(--ink); margin: 2.2em 0 .5em; }
.fe-prose h3 { font: 600 16.5px var(--sans); color: var(--ink); margin: 1.6em 0 .4em; }
.fe-prose p, .fe-prose ul, .fe-prose ol { margin: 0 0 1em; }
.fe-prose ul, .fe-prose ol { padding-left: 1.3em; }
.fe-prose li { margin: .35em 0; }
.fe-prose strong { color: var(--ink); }
.fe-prose a { color: var(--rose-ink); text-underline-offset: 3px; }
.fe-prose .fe-note { margin: 1.4em 0; }

/* ── Footer ── */
.fe-footer { padding: 56px 0 calc(40px + env(safe-area-inset-bottom)); color: var(--ink-3); font-size: 13.5px; }
.fe-footer .cols { display: flex; flex-wrap: wrap; gap: 28px 56px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 28px; }
.fe-footer nav { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.fe-footer a { text-decoration: none; color: var(--ink-2); }
.fe-footer a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ── Quick exit (from safety.js) ── */
.quick-exit { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 900; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 999px; border: none; background: var(--ink); color: var(--bg); font: 600 13px var(--sans); cursor: pointer; box-shadow: var(--shadow-2); }

/* app.js compatibility (ripples, offline notice) */
:where(.md-ripple-host) { position: relative; overflow: hidden; }
.md-ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .12; pointer-events: none; transform: scale(0); animation: ripple .6s var(--ease) forwards; }
.md-ripple.out { opacity: 0; transition: opacity .35s; }
@keyframes ripple { to { transform: scale(1); } }
.md-offline { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font: 600 13px var(--sans); display: flex; align-items: center; gap: 8px; }
.md-offline .ms { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .fe-light::before, .fe-light::after { animation: none; }
}

/* ── Fixes after first visual review ── */
.fe-brand { gap: 0; }
.fe-brand img { margin-right: 9px; }
.fe-after { opacity: 0; animation: appear .9s var(--ease) forwards; }
@keyframes appear { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fe-note svg, .fe-hint svg { display: inline-block; width: 17px; height: 17px; vertical-align: -3px; margin-right: 6px; color: var(--rose-ink); }
.fe-choices.two { grid-template-columns: 1fr 1fr; }
.fe-choices.two .fe-choice { position: relative; padding: 13px 14px; gap: 11px; }
.fe-choices.two .fe-choice .ic { width: 36px; height: 36px; border-radius: 12px; }
.fe-choices.two .fe-choice .ic svg { width: 19px; height: 19px; }
.fe-choices.two .fe-choice .t { font-size: 14.5px; }
.fe-choices.two .fe-choice .flag { position: absolute; top: -8px; right: 10px; margin: 0; font-size: 10.5px; }
