/* Every added class is fcs-prefixed. Original component styles stay in charge on desktop. */
.fcs-cap[hidden], .fcs-cap [hidden], .fcs-section[hidden]:not([hidden="until-found"]), .fcs-section [hidden]:not([hidden="until-found"]) { display: none !important; }
.fcs-cap { display: none; }

@media (max-width: 899px) {
  .fcs-cap, .fcs-section[data-fcs-live] {
    --fcs-cream: #fdf8f0;
    --fcs-plum: #4a1942;
    --fcs-gold: #d4a843;
    --fcs-ink: #2d1928;
    --fcs-ease: cubic-bezier(.22, 1, .36, 1);
    box-sizing: border-box;
    color: var(--fcs-ink);
    font-family: 'DM Sans', system-ui, sans-serif;
  }
  .fcs-cap *, .fcs-section .fcs-surface { box-sizing: border-box; }
  .fcs-cap {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: stretch;
    width: calc(100% - 40px);
    max-width: 560px;
    margin: 24px auto 0;
    border: 1px solid var(--fcs-gold);
    border-radius: 20px 20px 8px 20px;
    background: var(--fcs-cream);
    box-shadow: 0 12px 24px -20px var(--fcs-plum);
  }
  .fcs-toggle {
    appearance: none;
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 72px;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 12px;
    border: 0;
    border-radius: inherit;
    color: var(--fcs-plum);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
  }
  .fcs-words { display: flex; flex: 1; flex-direction: column; align-items: flex-start; min-width: 0; gap: 4px; }
  .fcs-title { font: 500 20px/1.1 'Glaze Display', Georgia, serif; overflow-wrap: anywhere; }
  .fcs-hint { font-size: 14px; line-height: 1.3; }
  .fcs-bubble {
    position: relative;
    display: block;
    padding: 4px 8px;
    border-radius: 10px 10px 10px 3px;
    color: var(--fcs-plum);
    background: var(--fcs-cream);
    font: 400 14px/1.3 'DM Sans', system-ui, sans-serif;
    text-align: left;
  }
  .fcs-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -4px;
    width: 8px;
    height: 8px;
    border-radius: 0 0 0 8px;
    background: inherit;
    transform: skewX(-20deg);
  }
  .fcs-mark { display: block; flex: none; transform-origin: 50% 80%; font: 500 20px/1 'Glaze Display', Georgia, serif; }
  .fcs-action { flex: none; font-size: 14px; font-weight: 700; }
  .fcs-order {
    display: flex;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    padding: 8px;
    border-radius: 0 18px 7px 0;
    background: var(--fcs-plum);
    color: var(--fcs-cream);
    font: 700 14px/1.2 'DM Sans', system-ui, sans-serif;
    text-align: center;
    text-decoration: none;
    overflow-wrap: anywhere;
  }
  .fcs-order-word { display: block; max-width: 5ch; }
  .fcs-toggle:active .fcs-mark, .fcs-detail:active, .fcs-close:active { transform: scale(.96); }
  .fcs-toggle .fcs-mark, .fcs-detail, .fcs-close { transition: transform 80ms var(--fcs-ease); }
  .fcs-cap :is(button, a):focus-visible, .fcs-section :is(.fcs-detail, .fcs-close, .fcs-story):focus-visible {
    outline: 3px solid var(--fcs-plum);
    outline-offset: 4px;
    box-shadow: 0 0 0 3px var(--fcs-cream);
  }
  .fcs-cap[data-fcs-stage="1"], .fcs-cap[data-fcs-stage="2"] { border-radius: 20px 20px 0 0; }
  .fcs-section[data-fcs-live] {
    display: block;
    position: relative;
    width: calc(100% - 40px);
    max-width: 560px;
    min-height: 0 !important;
    margin: 0 auto 24px !important;
    padding: 0 !important;
    border: 1px solid var(--fcs-gold);
    border-top: 0;
    border-radius: 0 0 20px 20px;
    background: var(--fcs-cream);
    overflow: visible;
    scroll-margin-block-start: 100px;
  }
  .fcs-section[data-fcs-live][hidden="until-found"] {
    /* Keep the browser's find-in-page mechanism. display:none would disable beforematch. */
    display: block !important;
    content-visibility: hidden;
    contain-intrinsic-size: 0 0;
    margin-block: 0 !important;
    padding: 0 !important;
    border: 0;
  }
  .fcs-surface { min-width: 0; }
  .fcs-pitch { padding: 20px 16px 16px; transform-origin: top center; }
  .fcs-note { max-width: 65ch; margin: 0 0 16px; color: var(--fcs-ink); font-size: 16px; line-height: 1.5; }
  .fcs-detail, .fcs-close {
    appearance: none;
    min-height: 48px;
    min-width: 48px;
    border: 1px solid var(--fcs-plum);
    border-radius: 12px;
    padding: 10px 16px;
    background: var(--fcs-plum);
    color: var(--fcs-cream);
    font: 700 16px/1.3 'DM Sans', system-ui, sans-serif;
    cursor: pointer;
  }
  .fcs-detail { width: 100%; }
  .fcs-story {
    position: relative;
    max-block-size: 65vh;
    max-block-size: 65svh;
    overflow: auto;
    overscroll-behavior: auto;
    border-radius: 0 0 19px 19px;
    scroll-padding-block-start: 72px;
    scrollbar-color: var(--fcs-plum) var(--fcs-cream);
  }
  .fcs-story[hidden="until-found"] {
    content-visibility: hidden;
    contain-intrinsic-size: 0 0;
    border: 0;
  }
  .fcs-readbar {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-block: 1px solid var(--fcs-gold);
    background: var(--fcs-cream);
  }
  .fcs-readtitle { font-size: 14px; font-weight: 700; }
  .fcs-close { padding-inline: 12px; font-size: 14px; }
  .fcs-story-inner { display: flow-root; min-width: 0; transform-origin: top center; }
  .fcs-story-inner :where(button, input:not([type="hidden"]), select) { min-height: 44px; }
  .fcs-story-inner :where([id]) { scroll-margin-block-start: 80px; }

  /* 4: an incoming message, with a plum sender square and a cream reply. */
  .fcs-cap.fcs-option-4 { background: var(--fcs-plum); border-color: var(--fcs-plum); }
  .fcs-option-4 .fcs-toggle { color: var(--fcs-cream); }
  .fcs-option-4 .fcs-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 40px;
    border: 1px solid var(--fcs-gold);
    border-radius: 10px 10px 4px 10px;
    color: var(--fcs-cream);
  }
  .fcs-option-4 .fcs-action { align-self: flex-start; padding-top: 2px; font-size: 14px; }
  .fcs-option-4 .fcs-order { border-inline-start: 1px solid var(--fcs-gold); }

  /* 5: a straight-cut kitchen note with a full-height tear tab. */
  .fcs-cap.fcs-option-5 { border-radius: 3px; box-shadow: 0 4px 0 -1px var(--fcs-cream), 0 5px 0 -1px var(--fcs-gold); }
  .fcs-option-5 .fcs-toggle { gap: 12px; padding-left: 16px; }
  .fcs-option-5 .fcs-mark { display: none; }
  .fcs-option-5 .fcs-action { align-self: stretch; display: grid; align-items: center; border-inline-start: 1px dashed var(--fcs-gold); padding-left: 12px; }
  .fcs-option-5 .fcs-order { border-radius: 0 2px 2px 0; }
  .fcs-option-5 .fcs-bubble { box-shadow: 0 0 0 1px rgba(74, 25, 66, .18); }
  .fcs-section.fcs-option-5 { border-radius: 0 0 3px 3px; }
  .fcs-option-5 .fcs-detail, .fcs-option-5 .fcs-close { border-radius: 3px; }
  .fcs-option-5 .fcs-story { border-radius: 0 0 2px 2px; }

  /* 6: overlapping invitation leaves, never a simulated food illustration. */
  .fcs-cap.fcs-option-6 { margin-top: 32px; border-radius: 16px 4px 16px 4px; }
  .fcs-option-6 .fcs-toggle { background: var(--fcs-cream); }
  .fcs-cap.fcs-option-6::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -7px 5px 7px -5px;
    border: 1px solid var(--fcs-gold);
    border-radius: 16px 4px 16px 4px;
    background: var(--fcs-plum);
    transform: rotate(-1deg);
    pointer-events: none;
  }
  .fcs-option-6 .fcs-mark { writing-mode: vertical-rl; font: 500 14px/1 'Glaze Display', Georgia, serif; }
  .fcs-option-6 .fcs-action { align-self: flex-end; padding-bottom: 2px; }
  .fcs-option-6 .fcs-order { border-radius: 0 3px 15px 0; }
  .fcs-option-6 .fcs-bubble { box-shadow: 0 1px 4px rgba(74, 25, 66, .16); }
  .fcs-section.fcs-option-6 { border-radius: 0 0 16px 4px; }

  @media (max-width: 359px) {
    .fcs-toggle { gap: 6px; padding: 12px 8px; }
    .fcs-option-4 .fcs-mark, .fcs-option-6 .fcs-mark { display: none; }
    .fcs-title { font-size: 20px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .fcs-cap *, .fcs-section .fcs-surface * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .fcs-toggle:active .fcs-mark, .fcs-detail:active, .fcs-close:active { transform: none; }
  }
}
