@layer components {
  .icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.2em; }

  /* --- Botones ------------------------------------------------------------- */
  .btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink);
    --btn-border: var(--line-strong);
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 44px; padding: 0.55rem 1.15rem;
    border-radius: var(--r-pill);
    border: 2px solid var(--btn-border);
    background: var(--btn-bg); color: var(--btn-fg);
    font-weight: 800; line-height: 1.1; text-decoration: none; text-align: center;
    transition: transform 0.12s var(--ease), background 0.15s, box-shadow 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:hover { color: var(--btn-fg); transform: translateY(-1px); }
  .btn:active { transform: translateY(1px); }
  .btn--primary { --btn-bg: var(--cta); --btn-border: var(--cta); --btn-fg: var(--ink); box-shadow: 0 4px 0 -1px var(--cta-600); }
  .btn--primary:hover { --btn-bg: #f9a35d; }
  .btn--ink { --btn-bg: var(--ink); --btn-border: var(--ink); --btn-fg: #fff; }
  .btn--ink:hover { --btn-bg: var(--ink-2); color: #fff; }
  .btn--ghost { --btn-bg: transparent; }
  .btn--ghost:hover { --btn-bg: var(--paper); --btn-border: var(--slime); }
  .btn--danger { --btn-bg: var(--danger-100); --btn-border: var(--danger-100); --btn-fg: var(--danger); }
  .btn--sm { min-height: 36px; padding: 0.35rem 0.9rem; font-size: var(--fs-sm); }
  .btn--lg { min-height: 52px; padding: 0.75rem 1.5rem; font-size: 1.08rem; }
  .btn--block { width: 100%; }

  .btn--toggle { --btn-bg: var(--surface); }
  .btn--toggle[aria-pressed="true"] { --btn-bg: var(--slime-100); --btn-border: var(--slime); --btn-fg: var(--slime-600); }
  .btn--toggle[aria-pressed="true"] .icon { fill: currentColor; }
  .btn--toggle.btn--primary[aria-pressed="true"] { --btn-bg: var(--slime-100); box-shadow: none; }

  .icon-btn {
    display: inline-grid; place-items: center; gap: 2px;
    min-width: 44px; height: 44px; padding-inline: 0.5rem;
    border-radius: var(--r-pill); color: var(--ink-2); text-decoration: none;
    transition: background 0.15s;
  }
  .icon-btn:hover { background: var(--cream); color: var(--ink); }
  .icon-btn .icon { width: 22px; height: 22px; }

  /* --- Insignias, chips y etiquetas --------------------------------------- */
  .badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.18rem 0.55rem; border-radius: var(--r-pill);
    font-size: var(--fs-xs); font-weight: 800; line-height: 1.3; white-space: nowrap;
    background: var(--cream-2); color: var(--ink);
  }
  .badge .icon { width: 0.95em; height: 0.95em; }
  .badge--age { color: #fff; background: var(--age-all); }
  .badge--age-10 { background: var(--age-10); }
  .badge--age-13 { background: var(--age-13); }
  .badge--age-16 { background: var(--age-16); }
  .badge--age-18 { background: var(--age-18); }
  .badge--ongoing { background: var(--slime-100); color: var(--slime-600); }
  .badge--completed { background: #e3efe6; color: #24693c; }
  .badge--coming_soon { background: var(--cta-100); color: #9a4b0d; }
  .badge--early_access { background: #ece6fb; color: #5a3fb0; }
  .badge--hiatus { background: #eef0f3; color: #4f5b69; }
  .badge--cancelled { background: #f1e8e8; color: #7a3b3b; }
  .badge--lang { background: transparent; border: 1.5px solid var(--line-strong); color: var(--ink-2); }
  .badge--access { background: var(--slime); color: var(--ink); }
  .badge--members { background: var(--cream-2); color: var(--ink); }
  .badge--vip { background: var(--ink); color: #fff; }
  .badge--scheduled { background: #eef0f3; color: #4f5b69; }

  .chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1rem; border-radius: var(--r-pill);
    background: var(--surface); border: 2px solid var(--line); font-weight: 700; text-decoration: none;
  }
  .chip:hover { border-color: var(--slime); color: var(--ink); }
  .chip--muted { color: var(--muted); border-style: dashed; }

  .tags { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .tag {
    display: inline-block; padding: 0.25rem 0.75rem; border-radius: var(--r-pill);
    background: var(--cream); border: 1.5px solid var(--line-strong); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
  }
  .tag--genre { background: var(--slime-100); border-color: transparent; color: var(--slime-600); font-weight: 800; }

  .pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.85rem; border-radius: var(--r-pill); background: var(--cream-2); font-weight: 700; text-decoration: none; font-size: var(--fs-sm); }
  .pill[aria-current="true"] { background: var(--ink); color: #fff; }
  .pill--lg { font-size: var(--fs-lg); padding: 0.6rem 1.4rem; }

  /* --- Portadas -------------------------------------------------------------- */
  .cover {
    position: relative; overflow: hidden;
    aspect-ratio: 2 / 3;
    border-radius: var(--r);
    background:
      radial-gradient(120% 60% at 50% 115%, rgb(255 255 255 / 0.35), transparent 60%),
      radial-gradient(80% 40% at 15% 100%, rgb(0 0 0 / 0.12), transparent 70%),
      linear-gradient(170deg, var(--c1), var(--c2));
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25), var(--shadow-sm);
    container-type: inline-size;
  }
  .cover img { width: 100%; height: 100%; object-fit: cover; }
  .cover__title {
    position: absolute; inset: max(16%, 30px) 8% auto;
    font-weight: 900; text-align: center; line-height: 1.05;
    font-size: clamp(0.8rem, 13cqi, 2.6rem);
    color: #fff; text-shadow: 0 2px 0 rgb(22 50 79 / 0.55), 0 0 18px rgb(22 50 79 / 0.35);
    text-wrap: balance;
  }
  .cover__slime { position: absolute; width: 62%; left: 19%; bottom: 7%; filter: drop-shadow(0 6px 8px rgb(22 50 79 / 0.25)); }
  .cover--xs { width: 52px; border-radius: 10px; flex: none; }
  .cover--xs .cover__slime { width: 80%; left: 10%; }
  .cover--blur > :not(.cover__gate) { filter: blur(14px) saturate(0.6); }
  .cover__gate {
    position: absolute; inset: auto 8% 8%; display: flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.35rem 0.5rem; border-radius: var(--r-pill);
    background: rgb(22 50 79 / 0.82); color: #fff; font-weight: 800; font-size: clamp(0.65rem, 8cqi, 0.9rem);
  }

  /* --- Mascota y burbujas --------------------------------------------------- */
  .slime { width: 80px; height: auto; }
  .bubble {
    position: absolute; z-index: -1; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgb(255 255 255 / 0.95), rgb(169 222 226 / 0.45) 45%, rgb(63 184 175 / 0.18) 70%);
    box-shadow: inset 0 0 0 1.5px rgb(63 184 175 / 0.35);
    pointer-events: none;
  }
  .bubble--a { width: 46px; height: 46px; top: 22px; right: 26px; }
  .bubble--b { width: 22px; height: 22px; top: 82px; right: 70px; }

  /* --- Tarjetas de historia ------------------------------------------------- */
  .story-card { position: relative; min-width: 0; }
  .story-card__link { display: block; text-decoration: none; }
  .story-card__media { position: relative; transition: transform 0.2s var(--ease); }
  .story-card__link:hover .story-card__media { transform: translateY(-4px) rotate(-0.6deg); }
  .story-card__link:hover { color: inherit; }
  .story-card__badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
  .story-card__title { font-size: var(--fs-md); font-weight: 800; margin-top: var(--s-2); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .story-card__meta { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 0.3rem; margin-top: 2px; }
  .story-card__meta .icon { color: var(--cta); }

  .rail {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 42%);
    gap: var(--s-4); overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: var(--s-3); margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter);
    scrollbar-width: thin;
  }
  .rail > * { scroll-snap-align: start; }
  @media (min-width: 640px) { .rail { grid-auto-columns: minmax(160px, 28%); } }
  @media (min-width: 1024px) {
    .rail { grid-auto-flow: row; grid-template-columns: repeat(6, 1fr); overflow: visible; margin: 0; padding: 0; }
  }

  /* Fila con sinopsis: horizontal cuando hay espacio (container query). */
  .story-list { display: grid; gap: var(--s-4); }
  @media (min-width: 1100px) { .story-list { grid-template-columns: 1fr 1fr; } }
  .story-row {
    container-type: inline-size;
    display: grid; grid-template-columns: 96px 1fr; gap: var(--s-4);
    background: var(--surface); border-radius: var(--r); padding: var(--s-3); box-shadow: var(--shadow-sm);
  }
  .story-row__body { min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
  .story-row__badges { display: flex; flex-wrap: wrap; gap: 4px; }
  .story-row__title { font-size: var(--fs-lg); }
  .story-row__title a { text-decoration: none; }
  .story-row__author { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
  .story-row__synopsis { font-size: var(--fs-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .story-row__stats { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; font-size: var(--fs-sm); color: var(--muted); font-weight: 700; }
  .story-row__stats .icon { color: var(--cta); }
  .story-row__cta { margin-top: auto; align-self: flex-start; }
  @container (min-width: 460px) {
    .story-row { grid-template-columns: 128px 1fr; }
    .story-row__synopsis { -webkit-line-clamp: 3; }
  }

  .section-head { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-4); }
  .section-head h2 { display: flex; align-items: center; gap: 0.4rem; }
  .section-head__link { margin-left: auto; font-weight: 800; color: var(--slime-600); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.2rem; }

  /* --- Paginación ------------------------------------------------------------- */
  .pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-6); }
  .pagination ol { display: flex; gap: var(--s-1); align-items: center; list-style: none; padding: 0; }
  .pagination ol a { display: grid; place-items: center; min-width: 40px; height: 40px; border-radius: var(--r-sm); text-decoration: none; font-weight: 800; }
  .pagination ol a:hover { background: var(--paper); }
  .pagination ol a[aria-current="page"] { background: var(--slime-600); color: #fff; }
  .pagination__step { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 800; text-decoration: none; padding: 0.5rem; }

  /* --- Menú desplegable (details) --------------------------------------------- */
  .menu { position: relative; }
  .menu > summary { list-style: none; cursor: pointer; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu__panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    min-width: 210px; padding: 0.4rem;
    background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  }
  .menu__item {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.6rem 0.75rem; border-radius: var(--r-sm); text-decoration: none; font-weight: 700; text-align: left;
  }
  .menu__item:hover { background: var(--cream); color: var(--ink); }
  .menu__item--danger { color: var(--danger); }
  .menu__item[aria-current="true"] { color: var(--slime-600); }
  .lang-switch__code { font-size: var(--fs-xs); font-weight: 900; margin-top: -4px; }
  .lang-switch > summary { grid-template-rows: auto auto; height: 48px; }

  /* --- Diálogo, toast y avisos ------------------------------------------------ */
  .dialog {
    width: min(520px, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100dvh - 2rem);
    padding: 0; border: 0; border-radius: var(--r-lg); background: var(--paper); color: var(--text);
    box-shadow: var(--shadow-lg);
  }
  .dialog::backdrop { background: rgb(22 50 79 / 0.45); backdrop-filter: blur(2px); }
  .dialog__body { padding: var(--s-5); }
  .dialog__head { display: flex; align-items: center; justify-content: space-between; }
  .dialog__head h2 { font-size: var(--fs-lg); display: flex; gap: 0.4rem; align-items: center; }
  .dialog__actions { display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; }

  .toast {
    position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 0.75rem 1.2rem; border-radius: var(--r-pill);
    background: var(--ink); color: #fff; font-weight: 700; box-shadow: var(--shadow-lg);
    animation: toast-in 0.25s var(--ease);
  }
  @media (min-width: 860px) { .toast { bottom: 24px; } }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

  .flash { margin-bottom: var(--s-4); padding: 0.8rem 1.1rem; border-radius: var(--r); background: var(--slime-100); color: var(--slime-600); font-weight: 700; }
  .flash--error { background: var(--danger-100); color: var(--danger); }
  .flash[data-flash] { display: flex; align-items: center; gap: 0.5rem; transition: opacity 0.3s ease, transform 0.3s ease; }
  .flash[data-flash] .flash__text { flex: 1; }
  .flash.is-leaving { opacity: 0; transform: translateY(-6px); }
  .flash__close { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
  .flash__close:hover { background: rgb(0 0 0 / 0.06); }
  .flash__close[hidden] { display: none; }
  @media (prefers-reduced-motion: reduce) { .flash[data-flash] { transition: none; } }

  .banner { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1rem; border-radius: var(--r); font-weight: 700; margin-bottom: var(--s-3); }
  .banner--soon { background: var(--cta-100); color: #8a430c; }
  .banner--early { background: #ece6fb; color: #4a3196; }
  .banner--hiatus { background: #eef0f3; color: #4f5b69; }

  /* --- Tarjetas y paneles ----------------------------------------------------- */
  .card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: var(--s-4); }
  .panel {
    position: relative;
    background: var(--cream); border: 2px solid var(--ink); border-radius: var(--r-lg);
    padding: var(--s-5);
  }
  .panel h2 { font-size: var(--fs-lg); display: flex; align-items: center; gap: 0.45rem; }

  /* --- Formularios ------------------------------------------------------------ */
  .field { display: grid; gap: 0.35rem; }
  .field__label { font-weight: 800; font-size: var(--fs-sm); }
  .field__help { color: var(--muted); font-size: var(--fs-xs); }
  .choice { display: flex; align-items: center; gap: 0.55rem; cursor: pointer; padding-block: 0.2rem; }
  .choice-list { display: grid; gap: 0.1rem; }
  .choice-list legend { font-weight: 800; margin-bottom: 0.35rem; }
  .choice-list--inline { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
  .choice-list--chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .choice-list--chips legend { width: 100%; }
  .chip-input input { position: absolute; opacity: 0; pointer-events: none; }
  .chip-input span { display: inline-block; padding: 0.4rem 0.9rem; border-radius: var(--r-pill); border: 2px solid var(--line-strong); font-weight: 700; cursor: pointer; background: var(--surface); }
  .chip-input input:checked + span { background: var(--slime-100); border-color: var(--slime); color: var(--slime-600); }
  .chip-input input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

  .switch { display: flex; align-items: center; gap: 0.7rem; cursor: pointer; }
  .switch input { position: absolute; opacity: 0; }
  .switch__track { position: relative; width: 44px; height: 26px; flex: none; border-radius: var(--r-pill); background: var(--line-strong); transition: background 0.2s; }
  .switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s var(--ease); }
  .switch input:checked + .switch__track { background: var(--slime-600); }
  .switch input:checked + .switch__track::after { transform: translateX(18px); }
  .switch input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }

  /* Control segmentado */
  .seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--cream-2); gap: 2px; }
  .seg button, .seg label span {
    min-height: 34px; padding: 0.25rem 0.8rem; border-radius: var(--r-pill);
    font-weight: 800; font-size: var(--fs-sm); color: var(--ink-2); display: inline-flex; align-items: center; cursor: pointer;
  }
  .seg button[aria-pressed="true"], .seg input:checked + span { background: var(--ink); color: #fff; }
  .seg label input { position: absolute; opacity: 0; }
  .seg label input:focus-visible + span { outline: 3px solid var(--focus); }
  .seg--block { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); border-radius: var(--r); }
  .seg--block label span { justify-content: center; text-align: center; width: 100%; height: 100%; min-height: 40px; border-radius: var(--r-sm); line-height: 1.2; }

  /* --- Estrellas, avatar y vacíos --------------------------------------------- */
  .stars { display: inline-flex; gap: 1px; color: var(--line-strong); vertical-align: middle; }
  .stars .icon { width: 1.1em; height: 1.1em; }
  .stars .is-on { color: var(--cta); }
  .stars--sm .icon { width: 0.9em; height: 0.9em; }

  .avatar {
    --size: 40px;
    display: inline-grid; place-items: center; flex: none;
    width: var(--size); height: var(--size); border-radius: 50%;
    background: hsl(var(--hue, 170) 45% 85%); color: hsl(var(--hue, 170) 50% 25%);
    font-weight: 900; border: 2px solid var(--paper); box-shadow: 0 0 0 2px var(--slime);
  }
  .avatar--xl { --size: clamp(84px, 16vw, 150px); font-size: calc(var(--size) * 0.42); border-width: 4px; box-shadow: 0 0 0 6px var(--slime); }

  .empty { text-align: center; display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); }
  .empty__slime { width: 110px; }
  .empty--page { padding-block: var(--s-7); }
  .empty__code { font-size: 4rem; font-weight: 900; color: var(--slime); line-height: 1; }
  .empty-inline { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); padding: var(--s-4); background: var(--cream); border-radius: var(--r); }

  .spoiler summary { cursor: pointer; display: inline-block; padding: 0.3rem 0.7rem; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-weight: 700; font-size: var(--fs-sm); list-style: none; }
  .spoiler[open] summary { display: none; }

  .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: var(--r-pill); background: var(--cta); font-size: var(--fs-xs); font-weight: 900; }

  /* --- Gotas ----------------------------------------------------------------- */
  .drop-mark {
    display: inline-block; flex: none; width: 0.78em; height: 0.78em; margin-right: 0.25em;
    border-radius: 50% 50% 50% 0; transform: rotate(-45deg) translate(-0.05em, 0.05em);
    background: radial-gradient(circle at 35% 35%, #bff0ea 0 18%, var(--slime) 45%, var(--slime-600));
    box-shadow: inset 0 0 0 1.5px rgb(22 50 79 / 0.55);
  }
  .drops-chip { display: inline-flex; align-items: center; gap: 0.1rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }

  .vip-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.5rem; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; vertical-align: middle; white-space: nowrap; }
  .vip-badge .icon { width: 0.9em; height: 0.9em; }
  .vip-badge--gem { background: linear-gradient(135deg, #DCF2EF, #BDE9E3); color: var(--slime-600); }
  .vip-badge--crystal { background: linear-gradient(135deg, #ECE6FB, #D9CFF7); color: #5A3FB0; }
  h1 .vip-badge { font-size: var(--fs-sm); padding: 0.2rem 0.7rem; }
  .search {
    display: flex; align-items: center; gap: var(--s-2);
    margin-top: var(--s-4); padding: 0.35rem 0.35rem 0.35rem 1rem;
    background: var(--surface); border-radius: var(--r-pill); box-shadow: var(--shadow-sm); border: 2px solid var(--line);
  }
  .search:focus-within { border-color: var(--slime); }
  .search > .icon { color: var(--muted); }
  .search input { border: 0 !important; box-shadow: none !important; padding-inline: 0 !important; background: transparent !important; min-width: 0; }
}
