/* What every theme shares: the page reset and the theme switcher. A theme's own look is themes/<id>.css,
   loaded alone, so themes never fight each other. Switcher classes are rt- so no theme's classes touch them */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: clip; }
body { margin: 0; }
#root { padding-top: env(safe-area-inset-top); }
:where(#root) a, .rt button { touch-action: manipulation; }
/* no hover on a phone: a press answers instead */
@media (hover: none) { :where(#root) a:active { scale: .97; opacity: .88; } }
/* :where() keeps these at zero weight, so a theme's own link colours always win */
:where(#root) a { color: inherit; text-decoration: none; }
#root a:focus-visible, .rt button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
:where(#root) img { max-width: 100%; }
/* A new page: its pieces rise in one after another (first load and every theme switch; app.js drops the class after) */
#root.rt-in .wrap > * { animation: rt-rise .55s cubic-bezier(.22, 1, .36, 1) backwards; }
#root.rt-in .wrap > :nth-child(2) { animation-delay: .06s; } #root.rt-in .wrap > :nth-child(3) { animation-delay: .12s; }
#root.rt-in .wrap > :nth-child(4) { animation-delay: .18s; } #root.rt-in .wrap > :nth-child(n+5) { animation-delay: .24s; }
@keyframes rt-rise { from { opacity: 0; translate: 0 14px; } }
/* View transitions (see paint() in app.js). Theme switch: the new theme opens as a circle from the Theme button, over
   the old one held still. Data arriving: a short cross-fade. The switcher has its own name so it never takes part */
.rt { view-transition-name: rt-switch; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .24s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
:root[data-vt="theme"]::view-transition-old(root) { animation: none; z-index: 0; }
:root[data-vt="theme"]::view-transition-new(root) { z-index: 1; animation: rt-open .62s cubic-bezier(.45, 0, .15, 1) both; }
@keyframes rt-open { from { clip-path: circle(0 at var(--rx, 90%) var(--ry, 95%)); } to { clip-path: circle(160vmax at var(--rx, 90%) var(--ry, 95%)); } }
::view-transition-group(rt-switch) { z-index: 2; animation: none; }
::view-transition-old(rt-switch) { display: none; } ::view-transition-new(rt-switch) { animation: none; }
#root .hit { animation: rt-hit .9s ease-out; }
@keyframes rt-hit { 0%, 40% { filter: brightness(1.35); } }

.rt { position: fixed; z-index: 60; right: max(14px, env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); font: 600 13px/1.2 system-ui, -apple-system, 'Segoe UI', sans-serif; color: #f2f4fa; }
.rt-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 12px; border-radius: 20px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(16, 18, 28, .82); color: inherit; font: inherit; cursor: pointer; backdrop-filter: blur(10px); box-shadow: 0 6px 20px rgba(0, 0, 0, .35); }
.rt-btn:active { transform: scale(.96); }
.rt-dots { display: flex; } .rt-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid rgba(16, 18, 28, .9); margin-left: -4px; } .rt-dots i:first-child { margin-left: 0; }
.rt-menu { position: absolute; right: 0; bottom: 50px; width: 232px; padding: 6px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(16, 18, 28, .94); backdrop-filter: blur(14px); box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  transform-origin: bottom right; transition: opacity .16s, transform .16s cubic-bezier(.2, .7, .2, 1), visibility .16s; }
.rt-menu[hidden] { display: block; visibility: hidden; opacity: 0; transform: translateY(6px) scale(.97); pointer-events: none; }
.rt-head { padding: 8px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9aa3b8; }
.rt-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.rt-opt:hover { background: rgba(255, 255, 255, .08); }
.rt-opt[aria-checked="true"] { background: rgba(255, 255, 255, .13); }
.rt-opt[aria-checked="true"]::after { content: '✓'; margin-left: auto; }
.rt-sw { flex: none; width: 34px; height: 22px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .3); }
.rt-row { display: flex; gap: 8px; justify-content: flex-end; }
.rt-share { width: 300px; } .rt-cards { display: grid; grid-template-columns: 0.56fr 1fr; gap: 8px; padding: 2px 4px 4px; align-items: end; }
.rt-card { display: grid; gap: 7px; padding: 6px 6px 8px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .07); color: inherit; font: inherit; cursor: pointer; }
.rt-card:hover { background: rgba(255, 255, 255, .15); } .rt-card:active { transform: scale(.97); }
.rt-card img { display: block; width: 100%; border-radius: 6px; background: rgba(255, 255, 255, .06); } .rt-story img { aspect-ratio: 9 / 16; } .rt-link img { aspect-ratio: 1200 / 630; }
.rt-note { padding: 0 10px; font-size: 12px; font-weight: 500; color: #9aa3b8; } .rt-note:not(:empty) { padding-bottom: 8px; }
.rt-shade { position: fixed; inset: 0; z-index: -1; background: rgba(0, 0, 0, .5); transition: opacity .2s, visibility .2s; }
.rt-shade[hidden] { display: block; visibility: hidden; opacity: 0; pointer-events: none; }
@media (min-width: 601px) { .rt-shade { display: none !important; } }
/* phone: the theme list is a sheet across the bottom with thumb-sized rows */
@media (max-width: 600px) {
  .rt-menu { position: fixed; left: 10px; right: 10px; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto; padding: 8px; border-radius: 18px; transform-origin: bottom center; }
  .rt-menu[hidden] { transform: translateY(18px); }
  .rt-opt { padding: 14px 12px; font-size: 15px; } .rt-sw { width: 42px; height: 28px; } .rt-btn { height: 44px; } .rt-card { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { #root.rt-in .wrap > *, #root .hit { animation: none; } .rt-menu, .rt-shade { transition: none; } }
@media (max-width: 900px) { #root { padding-bottom: 56px; } }

/* ── share cards (?card=story|link): a fixed frame the active theme fills. Drawn small and shot enlarged:
   story 450 × 800 → 1080 × 1920, link 800 × 420 → 1200 × 630. A theme tunes it with --z and its own .sc rules ── */
body[data-card] .rt { display: none; } body[data-card] #root { padding: 0; } body[data-card] { overflow: hidden; }
.sc { position: relative; overflow: hidden; box-sizing: border-box; } .sc-story { width: 450px; height: 800px; } .sc-link { width: 800px; height: 420px; }
.sc .in { position: relative; z-index: 1; display: grid; gap: 12px; align-content: start; padding: 16px; zoom: var(--z, 1); }
.sc .col { display: grid; gap: 12px; align-content: start; min-width: 0; }
.sc-link .in { grid-template-columns: 1fr 1fr; } .sc-link .in > .c-a { grid-column: 1 / -1; }
.sc .scf { position: absolute; z-index: 2; left: 0; right: 0; bottom: 10px; display: flex; gap: 8px; align-items: center; justify-content: center; }
