/* ==========================================================================
   CozyFX — Home Nexus «Cozy Wheat Edition»
   Toasts, particles, achievements, secrets & the Book of Secrets.
   Scoped: #cozy-fx-root / .cozyfx-* only. No global selectors, no assets.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Root & design tokens (fallbacks keep the module standalone)
   -------------------------------------------------------------------------- */
#cozy-fx-root {
  /* layout per contract §2.2 */
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  color: var(--cozy-ink, #332a1e);
  font-family: var(--cozy-font, "Trebuchet MS", "Segoe UI", Tahoma, sans-serif);
  -webkit-font-smoothing: antialiased;

  /* colour tokens (Lead's base.css tokens win when present) */
  --cozyfx-ink: var(--cozy-ink, #332a1e);
  --cozyfx-muted: var(--cozy-muted, #8b7960);
  --cozyfx-accent: var(--cozy-accent, #d9a441);
  --cozyfx-accent-soft: var(--cozy-accent-soft, #f3d488);
  --cozyfx-accent-deep: var(--cozy-accent-deep, #a87422);
  --cozyfx-wheat: var(--cozy-wheat, #e3b44c);
  --cozyfx-leaf: var(--cozy-leaf, #7d9a62);
  --cozyfx-rose: var(--cozy-rose, #d47b9a);
  --cozyfx-sky: var(--cozy-sky, #86a9bd);
  --cozyfx-outline: #2f261a;
  --cozyfx-soft: rgba(92, 69, 34, .10);
  --cozyfx-line: rgba(92, 69, 34, .16);
  --cozyfx-emoji: "Noto Color Emoji", "Segoe UI Emoji", "Apple Color Emoji",
                  "Segoe UI Symbol", "Trebuchet MS", sans-serif;
  --cozyfx-glow: var(--cozy-glow, rgba(217, 164, 65, .38));
  --cozyfx-shadow: var(--cozy-shadow, 0 18px 50px rgba(88, 62, 24, .16));

  /* cards */
  --cozyfx-toast-wheat-top: color-mix(in srgb, var(--cozy-surface-2, #fffaf0) 92%, #fff 8%);
  --cozyfx-toast-wheat-bottom: var(--cozy-surface, #f6e3b4);
  --cozyfx-toast-info-top: var(--cozy-surface-2, #fffdf8);
  --cozyfx-toast-info-bottom: color-mix(in srgb, var(--cozy-surface-2, #f2ecdd) 82%, var(--cozy-bg, #f2ecdd) 18%);
  --cozyfx-toast-secret-top: color-mix(in srgb, var(--cozy-accent, #d9a441) 16%, var(--cozy-surface-2, #fff8e2));
  --cozyfx-toast-secret-bottom: color-mix(in srgb, var(--cozy-accent, #d9a441) 10%, var(--cozy-surface, #f0d68f));
  --cozyfx-book-top: var(--cozy-paper, #fffaef);
  --cozyfx-book-bottom: color-mix(in srgb, var(--cozy-paper, #f5e6c6) 82%, var(--cozy-bg, #f5e6c6) 18%);
  --cozyfx-ach-bg: color-mix(in srgb, var(--cozy-surface-2, rgba(255, 250, 240, .62)) 68%, transparent);
  --cozyfx-ach-bg-u: linear-gradient(155deg, color-mix(in srgb, var(--cozy-accent, #f3d488) 24%, transparent), color-mix(in srgb, var(--cozy-surface-2, #fffaf0) 82%, transparent));
  --cozyfx-ach-line: var(--cozy-line, rgba(92, 69, 34, .18));
  --cozyfx-bar-track: var(--cozy-line, rgba(92, 69, 34, .14));
}

/* Night palette (attribute set by CozyWorld). */
body[data-cozy-mode="night"][data-cozy-theme="wheat"] #cozy-fx-root {
  --cozyfx-ink: var(--cozy-ink, #f3e7cf);
  --cozyfx-muted: var(--cozy-muted, #b3a084);
  --cozyfx-accent: var(--cozy-accent, #ecc56a);
  --cozyfx-accent-soft: var(--cozy-accent-soft, #8a6a2e);
  --cozyfx-accent-deep: var(--cozy-accent-deep, #f7d98c);
  --cozyfx-outline: #0b0805;
  --cozyfx-soft: rgba(243, 231, 207, .09);
  --cozyfx-line: rgba(243, 231, 207, .15);
  --cozyfx-toast-wheat-top: #4a3d2b;
  --cozyfx-toast-wheat-bottom: #332a1e;
  --cozyfx-toast-info-top: #3f372b;
  --cozyfx-toast-info-bottom: #2c261e;
  --cozyfx-toast-secret-top: #5c4826;
  --cozyfx-toast-secret-bottom: #3b2f1b;
  --cozyfx-book-top: #3b3125;
  --cozyfx-book-bottom: #2a241b;
  --cozyfx-ach-bg: rgba(243, 231, 207, .045);
  --cozyfx-ach-bg-u: linear-gradient(155deg, rgba(236, 197, 106, .20), rgba(243, 231, 207, .05));
  --cozyfx-ach-line: rgba(243, 231, 207, .14);
  --cozyfx-bar-track: rgba(243, 231, 207, .14);
}

/* --------------------------------------------------------------------------
   2. Golden-field veil (Konami / secret reward, 10 s)
   -------------------------------------------------------------------------- */
#cozy-fx-root .cozyfx-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(236, 197, 106, .38), transparent 62%),
    radial-gradient(95% 60% at 50% 112%, rgba(217, 164, 65, .30), transparent 66%);
  transition: opacity .6s ease;
}
#cozy-fx-root.cozyfx-golden .cozyfx-veil,
body.cozy-golden #cozy-fx-root .cozyfx-veil {
  animation: cozyfx-golden-veil 10s ease-in-out both;
}
@keyframes cozyfx-golden-veil {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  78%  { opacity: .62; }
  100% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   3. Particles
   -------------------------------------------------------------------------- */
#cozy-fx-root .cozyfx-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint style;
}
#cozy-fx-root .cozyfx-p {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  will-change: transform, opacity;
  text-shadow: 0 1px 0 rgba(255, 250, 240, .35);
}
body[data-cozy-mode="night"][data-cozy-theme="wheat"] #cozy-fx-root .cozyfx-p {
  text-shadow: 0 0 8px rgba(236, 197, 106, .45);
}

/* falling: wheat rain, stars, leaves, confetti */
#cozy-fx-root .cozyfx-p-fall {
  left: var(--x, 50%);
  font-size: var(--sz, 16px);
  animation-name: cozyfx-fall;
  animation-duration: var(--dur, 3400ms);
  animation-delay: var(--delay, 0ms);
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
#cozy-fx-root .cozyfx-p-stars { animation-name: cozyfx-fall-stars; }
#cozy-fx-root .cozyfx-p-leaves { animation-name: cozyfx-fall-leaves; }
#cozy-fx-root .cozyfx-p-confetti {
  width: var(--w, 9px);
  height: var(--h, 13px);
  border-radius: 2px;
  background: var(--c, #d9a441);
  box-shadow: 0 0 0 1px rgba(47, 38, 26, .35);
  animation-name: cozyfx-fall-confetti;
}

@keyframes cozyfx-fall {
  0%   { transform: translate3d(0, -14vh, 0) rotate(0deg); opacity: 0; }
  9%   { opacity: 1; }
  88%  { opacity: .92; }
  100% { transform: translate3d(var(--dx, 0px), 114vh, 0) rotate(var(--rot, 220deg)); opacity: 0; }
}
@keyframes cozyfx-fall-stars {
  0%   { transform: translate3d(0, -12vh, 0) scale(.5); opacity: 0; }
  12%  { opacity: .95; }
  45%  { opacity: .32; }
  72%  { opacity: .9; }
  100% { transform: translate3d(var(--dx, 0px), 112vh, 0) scale(1); opacity: 0; }
}
@keyframes cozyfx-fall-leaves {
  0%   { transform: translate3d(0, -12vh, 0) rotate(0deg); opacity: 0; }
  12%  { opacity: .9; }
  50%  { transform: translate3d(calc(var(--dx, 0px) * .4), 52vh, 0) rotate(calc(var(--rot, 180deg) * .45)); opacity: .95; }
  100% { transform: translate3d(var(--dx, 0px), 112vh, 0) rotate(var(--rot, 180deg)); opacity: 0; }
}
@keyframes cozyfx-fall-confetti {
  0%   { transform: translate3d(0, -12vh, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: 1; }
  100% { transform: translate3d(var(--dx, 0px), 112vh, 0) rotate(var(--rot, 540deg)); opacity: .85; }
}

/* radial burst (word secret, grain, achievements) */
#cozy-fx-root .cozyfx-p-burst {
  left: var(--x, 50%);
  top: var(--y, 42%);
  font-size: var(--sz, 16px);
  animation-name: cozyfx-burst;
  animation-duration: var(--dur, 900ms);
  animation-delay: var(--delay, 0ms);
  animation-timing-function: cubic-bezier(.17, .86, .38, 1);
  animation-fill-mode: forwards;
}
@keyframes cozyfx-burst {
  0%   { transform: translate(-50%, -50%) scale(.25) rotate(0deg); opacity: 0; }
  14%  { opacity: 1; }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -80px)))
               scale(var(--sc, 1)) rotate(var(--rot, 160deg));
    opacity: 0;
  }
}

/* sparkles around an element */
#cozy-fx-root .cozyfx-p-spark {
  left: var(--x, 50%);
  top: var(--y, 50%);
  font-size: var(--sz, 12px);
  animation-name: cozyfx-spark;
  animation-duration: var(--dur, 800ms);
  animation-delay: var(--delay, 0ms);
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}
@keyframes cozyfx-spark {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  30%  {
    transform: translate(calc(-50% + var(--dx, 0px) * .5), calc(-50% + var(--dy, 0px) * .5))
               scale(1.15) rotate(45deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
               scale(.2) rotate(90deg);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   4. Toasts (sticker cards, bottom-right, max 3, z 1001)
   -------------------------------------------------------------------------- */
#cozy-fx-root .cozyfx-toasts {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 1001;
  width: min(382px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

#cozy-fx-root .cozyfx-toast {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 13px 13px;
  border: 2px solid var(--cozyfx-outline);
  border-radius: 18px;
  background: linear-gradient(165deg, var(--cozyfx-toast-info-top), var(--cozyfx-toast-info-bottom));
  color: var(--cozyfx-ink);
  box-shadow:
    0 3px 0 rgba(47, 38, 26, .55),
    0 16px 34px rgba(88, 62, 24, .22);
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
  transform-origin: 0 100%;
  animation: cozyfx-toast-in 380ms cubic-bezier(.2, 1.3, .35, 1) both;
}
#cozy-fx-root .cozyfx-toast--wheat {
  background: linear-gradient(165deg, var(--cozyfx-toast-wheat-top), var(--cozyfx-toast-wheat-bottom));
}
#cozy-fx-root .cozyfx-toast--secret {
  background: linear-gradient(165deg, var(--cozyfx-toast-secret-top), var(--cozyfx-toast-secret-bottom));
  border-color: var(--cozyfx-accent-deep);
}
body[data-cozy-mode="night"][data-cozy-theme="wheat"] #cozy-fx-root .cozyfx-toast {
  box-shadow:
    0 3px 0 rgba(0, 0, 0, .6),
    0 0 0 1px rgba(236, 197, 106, .16),
    0 18px 40px rgba(0, 0, 0, .5);
}
#cozy-fx-root .cozyfx-toast:hover { translate: 0 -1px; }

#cozy-fx-root .cozyfx-toast-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-family: var(--cozyfx-emoji);
  font-size: 22px;
  line-height: 1;
  border: 2px solid var(--cozyfx-outline);
  border-radius: 14px;
  background: linear-gradient(160deg, var(--cozyfx-accent-soft), var(--cozyfx-accent));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .42);
  transform: rotate(-4deg);
}
#cozy-fx-root .cozyfx-toast--secret .cozyfx-toast-icon {
  background: linear-gradient(160deg, #f7dfa0, #d9a441);
  transform: rotate(4deg);
}
#cozy-fx-root .cozyfx-toast--info .cozyfx-toast-icon {
  background: linear-gradient(160deg, #f3e7cf, #dcc79f);
}

#cozy-fx-root .cozyfx-toast-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}
#cozy-fx-root .cozyfx-toast-top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
}
#cozy-fx-root .cozyfx-toast-eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--cozyfx-accent-deep);
}
#cozy-fx-root .cozyfx-toast-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .01em;
  color: var(--cozyfx-ink);
}
#cozy-fx-root .cozyfx-toast-text {
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--cozyfx-muted);
}

#cozy-fx-root .cozyfx-toast-x {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: -3px -3px 0 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--cozyfx-muted);
  font-size: 12px;
  font-family: var(--cozyfx-emoji);
  cursor: pointer;
  pointer-events: auto;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
#cozy-fx-root .cozyfx-toast-x:hover {
  background: var(--cozyfx-soft);
  border-color: var(--cozyfx-line);
  color: var(--cozyfx-ink);
}
#cozy-fx-root .cozyfx-toast-x:focus-visible {
  outline: 2px solid var(--cozyfx-accent-deep);
  outline-offset: 1px;
}

/* timed wheat line at the bottom of the card */
#cozy-fx-root .cozyfx-toast::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cozyfx-accent-deep), var(--cozyfx-accent-soft));
  transform-origin: left center;
  animation: cozyfx-toast-ttl var(--cozyfx-ttl, 4600ms) linear forwards;
  opacity: .8;
}
#cozy-fx-root .cozyfx-toast.is-out {
  animation: cozyfx-toast-out 240ms ease-in forwards;
  pointer-events: none;
}
#cozy-fx-root .cozyfx-toast.is-out::after { animation: none; }

/* sticker gloss sweep on arrival */
#cozy-fx-root .cozyfx-toast-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, .38) 46%, transparent 60%);
  transform: translateX(-130%);
  animation: cozyfx-shine 950ms ease-out 120ms 1;
}

@keyframes cozyfx-toast-in {
  from { opacity: 0; transform: translateY(18px) scale(.94) rotate(-1.2deg); }
  to   { opacity: 1; transform: none; }
}
@keyframes cozyfx-toast-out {
  to { opacity: 0; transform: translateY(10px) scale(.965); }
}
@keyframes cozyfx-toast-ttl {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
@keyframes cozyfx-shine {
  to { transform: translateX(130%); }
}

/* --------------------------------------------------------------------------
   5. The almost-hidden grain (bottom-left, bobbing, hover reveals)
   -------------------------------------------------------------------------- */
#cozy-fx-root .cozyfx-secret-grain {
  position: absolute;
  right: 16px;
  bottom: 10px;
  z-index: 3;
  width: 30px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  opacity: .15;
  transform-origin: 50% 100%;
  filter: saturate(.65);
  transition: opacity .35s ease, filter .35s ease, transform .35s ease;
  animation: cozyfx-grain-bob 6s ease-in-out infinite;
}
#cozy-fx-root .cozyfx-secret-grain:hover,
#cozy-fx-root .cozyfx-secret-grain:focus-visible {
  opacity: .96;
  filter: none;
  transform: scale(1.12) rotate(-3deg);
  animation-play-state: paused;
  outline: none;
}
#cozy-fx-root .cozyfx-secret-grain:focus-visible {
  box-shadow: 0 0 0 3px var(--cozyfx-accent-soft);
}
#cozy-fx-root .cozyfx-secret-grain.is-found {
  opacity: .28;
  filter: none;
}
#cozy-fx-root .cozyfx-grain-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
#cozy-fx-root .cozyfx-grain-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 197, 106, .6), transparent 66%);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
#cozy-fx-root .cozyfx-secret-grain:hover .cozyfx-grain-glow,
#cozy-fx-root .cozyfx-secret-grain:focus-visible .cozyfx-grain-glow {
  opacity: 1;
}
/* Never let the grain sit over the old login/settings layers. */
#cozy-fx-root.cozyfx-modals-open .cozyfx-secret-grain {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
@media (min-width: 1200px) {
  /* friends rail owns the right 344px — keep the grain just beside it */
  #cozy-fx-root .cozyfx-secret-grain { right: 360px; }
}
@keyframes cozyfx-grain-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-5px) rotate(2.5deg); }
}

/* --------------------------------------------------------------------------
   6. Book of Secrets (z 1002)
   -------------------------------------------------------------------------- */
#cozy-fx-root .cozyfx-book {
  position: fixed;
  inset: 0;
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
}
#cozy-fx-root .cozyfx-book[hidden] { display: none !important; }

#cozy-fx-root .cozyfx-book-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: radial-gradient(120% 100% at 50% 0%, rgba(58, 43, 24, .34), rgba(34, 25, 14, .62));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .28s ease;
}
body[data-cozy-mode="night"][data-cozy-theme="wheat"] #cozy-fx-root .cozyfx-book-backdrop {
  background: radial-gradient(120% 100% at 50% 0%, rgba(8, 6, 4, .55), rgba(0, 0, 0, .74));
}
#cozy-fx-root .cozyfx-book.is-open .cozyfx-book-backdrop { opacity: 1; }

#cozy-fx-root .cozyfx-book-card {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: min(740px, 100%);
  max-height: min(84dvh, 760px);
  display: flex;
  flex-direction: column;
  padding: 20px 22px 16px;
  border: 2.5px solid var(--cozyfx-outline);
  border-radius: 26px;
  background: linear-gradient(170deg, var(--cozyfx-book-top), var(--cozyfx-book-bottom));
  color: var(--cozyfx-ink);
  box-shadow:
    0 4px 0 rgba(47, 38, 26, .5),
    var(--cozyfx-shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(22px) scale(.965) rotate(-.35deg);
  transition:
    opacity .3s ease,
    transform .4s cubic-bezier(.2, 1.2, .35, 1);
}
#cozy-fx-root .cozyfx-book.is-open .cozyfx-book-card {
  opacity: 1;
  transform: none;
}
body[data-cozy-mode="night"][data-cozy-theme="wheat"] #cozy-fx-root .cozyfx-book-card {
  box-shadow:
    0 4px 0 rgba(0, 0, 0, .6),
    0 0 0 1px rgba(236, 197, 106, .16),
    var(--cozyfx-shadow);
}

/* decorative wheat doodles */
#cozy-fx-root .cozyfx-book-doodles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: 26px;
}
#cozy-fx-root .cozyfx-book-doodle {
  position: absolute;
  font-family: var(--cozyfx-emoji);
  font-size: 34px;
  opacity: .17;
  filter: saturate(.7);
  animation: cozyfx-doodle-float 9s ease-in-out infinite;
}
#cozy-fx-root .cozyfx-book-doodle:nth-child(1) {
  top: 12px; right: 96px; transform: rotate(16deg);
}
#cozy-fx-root .cozyfx-book-doodle:nth-child(2) {
  bottom: 74px; left: 22px; font-size: 22px; animation-delay: -3s; transform: rotate(-12deg);
}
#cozy-fx-root .cozyfx-book-doodle:nth-child(3) {
  top: 46px; left: 42%; font-size: 20px; animation-delay: -5s;
}
#cozy-fx-root .cozyfx-book-doodle:nth-child(4) {
  bottom: 22px; right: 40px; font-size: 26px; animation-delay: -7s; transform: rotate(24deg);
}
@keyframes cozyfx-doodle-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -7px; }
}

#cozy-fx-root .cozyfx-book-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 12px;
}
#cozy-fx-root .cozyfx-book-heading {
  flex: 1 1 auto;
  min-width: 0;
}
#cozy-fx-root .cozyfx-book-kicker {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid rgba(168, 116, 34, .36);
  border-radius: 999px;
  background: rgba(217, 164, 65, .16);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--cozyfx-accent-deep);
}
#cozy-fx-root .cozyfx-book-title {
  margin: 7px 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 3.1vw, 31px);
  line-height: 1.06;
  letter-spacing: .01em;
  color: var(--cozyfx-ink);
}
#cozy-fx-root .cozyfx-book-sub {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--cozyfx-muted);
}
#cozy-fx-root .cozyfx-book-progress {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--cozyfx-accent-deep);
}
#cozy-fx-root .cozyfx-book-count {
  font-size: 30px;
  line-height: 1;
}
#cozy-fx-root .cozyfx-book-total {
  font-size: 13px;
  color: var(--cozyfx-muted);
}
#cozy-fx-root .cozyfx-book-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--cozyfx-outline);
  border-radius: 13px;
  background: linear-gradient(160deg, var(--cozyfx-accent-soft), var(--cozyfx-accent));
  color: #2f261a;
  font-family: var(--cozyfx-emoji);
  font-size: 15px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 0 rgba(47, 38, 26, .45);
  transition: transform .18s ease, filter .18s ease;
}
#cozy-fx-root .cozyfx-book-close:hover {
  transform: rotate(6deg) scale(1.05);
  filter: brightness(1.05);
}
#cozy-fx-root .cozyfx-book-close:focus-visible {
  outline: 3px solid var(--cozyfx-accent-deep);
  outline-offset: 2px;
}

#cozy-fx-root .cozyfx-book-bar {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  height: 10px;
  margin-bottom: 14px;
  border: 1.5px solid var(--cozyfx-line);
  border-radius: 999px;
  background: var(--cozyfx-bar-track);
  overflow: hidden;
}
#cozy-fx-root .cozyfx-book-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cozyfx-accent-deep), var(--cozyfx-accent), var(--cozyfx-accent-soft));
  transition: width .55s cubic-bezier(.2, .9, .3, 1);
}

#cozy-fx-root .cozyfx-book-grid {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
  padding: 2px 6px 8px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cozyfx-accent) transparent;
}
#cozy-fx-root .cozyfx-book-grid::-webkit-scrollbar { width: 8px; }
#cozy-fx-root .cozyfx-book-grid::-webkit-scrollbar-track { background: transparent; }
#cozy-fx-root .cozyfx-book-grid::-webkit-scrollbar-thumb {
  background: var(--cozyfx-accent);
  border-radius: 999px;
}

#cozy-fx-root .cozyfx-ach {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 11px 12px;
  border: 1.5px solid var(--cozyfx-ach-line);
  border-radius: 16px;
  background: var(--cozyfx-ach-bg);
  overflow: hidden;
}
#cozy-fx-root .cozyfx-ach.is-unlocked {
  border-color: var(--cozyfx-accent-deep);
  background: var(--cozyfx-ach-bg-u);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}
#cozy-fx-root .cozyfx-ach.is-locked {
  border-style: dashed;
  opacity: .82;
}
#cozy-fx-root .cozyfx-ach.is-unlocked::after {
  content: "";
  position: absolute;
  top: -20px;
  right: -26px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 197, 106, .34), transparent 70%);
  pointer-events: none;
}
#cozy-fx-root .cozyfx-ach-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-family: var(--cozyfx-emoji);
  font-size: 20px;
  line-height: 1;
  border: 2px solid var(--cozyfx-outline);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--cozyfx-accent-soft), var(--cozyfx-accent));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4);
  transform: rotate(-3deg);
}
#cozy-fx-root .cozyfx-ach.is-locked .cozyfx-ach-icon {
  background: var(--cozyfx-soft);
  border-color: var(--cozyfx-ach-line);
  color: var(--cozyfx-muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  box-shadow: none;
}
#cozy-fx-root .cozyfx-ach-text { min-width: 0; }
#cozy-fx-root .cozyfx-ach-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .01em;
}
#cozy-fx-root .cozyfx-ach.is-locked .cozyfx-ach-title {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: .12em;
  color: var(--cozyfx-muted);
}
#cozy-fx-root .cozyfx-ach-desc {
  margin: 2px 0 0;
  font-size: 10.8px;
  line-height: 1.38;
  color: var(--cozyfx-muted);
}
#cozy-fx-root .cozyfx-ach.is-locked .cozyfx-ach-desc { font-style: italic; }
#cozy-fx-root .cozyfx-ach-stamp {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  border: 1px solid rgba(168, 116, 34, .42);
  border-radius: 999px;
  background: rgba(217, 164, 65, .2);
  color: var(--cozyfx-accent-deep);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  transform: rotate(3deg);
}

/* delightful stagger when the book opens */
#cozy-fx-root .cozyfx-book.is-open .cozyfx-ach {
  animation: cozyfx-ach-in 440ms cubic-bezier(.2, 1.1, .35, 1) both;
  animation-delay: calc(var(--i, 0) * 34ms + 90ms);
}
@keyframes cozyfx-ach-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
#cozy-fx-root .cozyfx-ach.is-locked { animation-name: cozyfx-ach-in; }

#cozy-fx-root .cozyfx-book-foot {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--cozyfx-ach-line);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--cozyfx-muted);
}
#cozy-fx-root .cozyfx-book-hint { flex: 1 1 auto; }
#cozy-fx-root .cozyfx-book-hint::before {
  content: "🌾";
  margin-right: 6px;
  opacity: .85;
  font-family: var(--cozyfx-emoji);
}

/* --------------------------------------------------------------------------
   7. Reduced motion: skip particles & floating, keep toasts readable
   -------------------------------------------------------------------------- */
#cozy-fx-root.cozyfx-reduced .cozyfx-p { display: none !important; }
#cozy-fx-root.cozyfx-reduced .cozyfx-toast,
#cozy-fx-root.cozyfx-reduced .cozyfx-toast.is-out,
#cozy-fx-root.cozyfx-reduced .cozyfx-toast-shine,
#cozy-fx-root.cozyfx-reduced .cozyfx-book-card,
#cozy-fx-root.cozyfx-reduced .cozyfx-secret-grain,
#cozy-fx-root.cozyfx-reduced .cozyfx-book-doodle,
#cozy-fx-root.cozyfx-reduced .cozyfx-veil,
#cozy-fx-root.cozyfx-reduced .cozyfx-book.is-open .cozyfx-ach {
  animation: none !important;
  transition: none !important;
}
#cozy-fx-root.cozyfx-reduced .cozyfx-toast::after,
#cozy-fx-root.cozyfx-reduced .cozyfx-toast-shine { display: none; }
#cozy-fx-root.cozyfx-reduced .cozyfx-toast.is-out { opacity: 0; }
#cozy-fx-root.cozyfx-reduced .cozyfx-book.is-open .cozyfx-ach { opacity: 1; transform: none; }
#cozy-fx-root.cozyfx-reduced .cozyfx-veil { display: none; }

@media (prefers-reduced-motion: reduce) {
  #cozy-fx-root .cozyfx-p { display: none !important; }
  #cozy-fx-root .cozyfx-toast,
  #cozy-fx-root .cozyfx-toast.is-out,
  #cozy-fx-root .cozyfx-toast-shine,
  #cozy-fx-root .cozyfx-book-card,
  #cozy-fx-root .cozyfx-secret-grain,
  #cozy-fx-root .cozyfx-book-doodle,
  #cozy-fx-root .cozyfx-veil,
  #cozy-fx-root .cozyfx-book.is-open .cozyfx-ach {
    animation: none !important;
    transition: none !important;
  }
  #cozy-fx-root .cozyfx-toast::after,
  #cozy-fx-root .cozyfx-toast-shine { display: none; }
  #cozy-fx-root .cozyfx-toast.is-out { opacity: 0; }
  #cozy-fx-root .cozyfx-book.is-open .cozyfx-ach { opacity: 1; transform: none; }
  #cozy-fx-root .cozyfx-veil { display: none; }
}

/* --------------------------------------------------------------------------
   8. Responsive (390 px phone / 1440 px desktop)
   -------------------------------------------------------------------------- */
@media (max-width: 620px) {
  #cozy-fx-root .cozyfx-toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    align-items: stretch;
  }
  #cozy-fx-root .cozyfx-toast { padding: 11px 12px 12px; border-radius: 16px; }
  #cozy-fx-root .cozyfx-toast-icon { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  #cozy-fx-root .cozyfx-toast-title { font-size: 15.5px; }

  #cozy-fx-root .cozyfx-secret-grain { right: 8px; bottom: 6px; width: 24px; height: 32px; }

  #cozy-fx-root .cozyfx-book { padding: 10px; }
  #cozy-fx-root .cozyfx-book-card {
    max-height: 92dvh;
    padding: 15px 13px 12px;
    border-radius: 21px;
  }
  #cozy-fx-root .cozyfx-book-title { font-size: 23px; }
  #cozy-fx-root .cozyfx-book-sub { font-size: 11.5px; }
  #cozy-fx-root .cozyfx-book-count { font-size: 25px; }
  #cozy-fx-root .cozyfx-book-doodle:nth-child(1),
  #cozy-fx-root .cozyfx-book-doodle:nth-child(4) { display: none; }
  #cozy-fx-root .cozyfx-book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding-right: 4px;
  }
  #cozy-fx-root .cozyfx-ach { padding: 9px 9px 10px; border-radius: 13px; }
  #cozy-fx-root .cozyfx-ach-icon { width: 32px; height: 32px; font-size: 17px; border-radius: 10px; }
  #cozy-fx-root .cozyfx-ach-title { font-size: 11.5px; }
  #cozy-fx-root .cozyfx-ach-desc { font-size: 10px; }
  #cozy-fx-root .cozyfx-book-close { width: 34px; height: 34px; border-radius: 11px; }
  #cozy-fx-root .cozyfx-book-foot { font-size: 10.5px; }
}

/* После получения секрета «Зерно» росток убираем из дома: мягко гаснет и сходит. */
#cozy-fx-root .cozyfx-secret-grain.is-gone {
  opacity: 0 !important;
  transform: translateY(10px) scale(.72) rotate(-7deg);
  filter: saturate(.4) blur(1.5px);
  transition: opacity .3s ease, transform .3s ease, filter .3s ease;
  animation: none !important;
  pointer-events: none !important;
}
