/* ink world shared ink-wash components (port of web/index.html, the prototype).
   Used by /read, and free for /write and the landing page. Needs tokens.css first, and art.js's
   installTextures() for the brushed masks (--tx-*). Without the masks everything falls back to flat shapes. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
.num { font-variant-numeric: tabular-nums; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-faint); } .soft { color: var(--ink-soft); } .small { font-size: 14px; } .tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 800; }
.display { font-family: var(--font-display); line-height: 1; font-weight: 400; }

/* ---------- Buttons ---------- */
.iconbtn { width: 44px; height: 44px; border-radius: var(--r-full); display: grid; place-items: center; flex: none; position: relative; }
.iconbtn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 24px; border-radius: var(--r-full); font-weight: 600; font-size: 16px; line-height: 1.2; text-align: center; border: 1.5px solid transparent; text-decoration: none; position: relative; isolation: isolate; transition: scale 150ms ease-out, background-color 150ms, color 150ms; }
.btn:not(:disabled):active { scale: 0.96; }
.btn.outline { border-color: var(--ink); color: var(--ink); }
.btn.azurite { border-color: var(--azurite); color: var(--azurite); }
.btn.azurite.fill { background: var(--azurite); color: #fff; }
.btn.danger { border-color: var(--seal); color: var(--seal); }
.btn.text { min-height: 44px; padding: 0 8px; text-decoration: underline; text-underline-offset: 4px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 0 16px; font-size: 14px; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--wash-deep); color: var(--ink-faint); border-color: transparent; cursor: default; }
/* Brushed fills: the shape comes from a texture mask, the colour from the theme. */
.btn.seal, .btn.ink { background: transparent; }
.btn.seal { color: var(--on-seal); }
.btn.ink { color: var(--paper); }
.btn.seal::before, .btn.ink::before { content: ""; position: absolute; inset: -7px -12px; z-index: -1; border-radius: var(--r-full); transition: background-color 150ms; }
.btn.seal::before { background: var(--seal); }
.btn.ink::before { background: var(--ink); }
.has-tx .btn.seal::before, .has-tx .btn.ink::before { border-radius: 0; -webkit-mask: var(--tx-mask-button) center / 100% 100% no-repeat; mask: var(--tx-mask-button) center / 100% 100% no-repeat; }
.btn.sm.seal::before, .btn.sm.ink::before { inset: -4px -6px; }
.btn.seal:not(:disabled):active::before { background: var(--seal-deep); }
.btn.ink:not(:disabled):active::before { background: var(--ink-soft); }
.btn.seal:disabled, .btn.ink:disabled { background: transparent; }
.btn.seal:disabled::before, .btn.ink:disabled::before { background: var(--wash-deep); }
@media (hover: hover) {
  .btn.outline:not(:disabled):hover, .btn.azurite:not(.fill):not(:disabled):hover { background: var(--wash); }
  .btn.seal:not(:disabled):hover::before { background: var(--seal-deep); }
  .btn.ink:not(:disabled):hover::before { background: var(--ink-soft); }
  .iconbtn:hover { background: var(--wash); }
}

/* ---------- Chips, badges, drops pill ---------- */
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: var(--r-full); background: var(--wash); font-weight: 600; font-size: 14px; color: var(--ink); border: 1.5px solid transparent; position: relative; isolation: isolate; text-decoration: none; }
.chip.on, .chip[aria-pressed="true"] { background: transparent; color: var(--paper); }
.chip.on::before, .chip[aria-pressed="true"]::before { content: ""; position: absolute; inset: -3px -6px; background: var(--ink); z-index: -1; border-radius: var(--r-full); }
.has-tx .chip.on::before, .has-tx .chip[aria-pressed="true"]::before { border-radius: 0; -webkit-mask: var(--tx-mask-pill) center / 100% 100% no-repeat; mask: var(--tx-mask-pill) center / 100% 100% no-repeat; }
@media (hover: hover) { .chip:not(.on):not([aria-pressed="true"]):hover { border-color: var(--ink-faint); } }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--r-sm); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.badge.fresh { background: var(--seal); color: var(--on-seal); }
.badge.free { border: 1.5px solid var(--malachite); color: var(--malachite); }
.badge.done { background: var(--wash-deep); color: var(--ink-soft); }
.badge.sub { background: var(--azurite); color: #fff; }
.badge.rating { border: 1.5px solid var(--ink-soft); color: var(--ink-soft); }
.drops { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 12px 0 9px; border-radius: var(--r-full); border: 1.5px solid var(--ink); font-weight: 800; font-size: 14px; position: relative; overflow: visible; text-decoration: none; color: var(--ink); }
.drops svg { width: 12px; height: 15px; flex: none; }
@media (hover: hover) { .drops:hover { background: var(--wash); } }
.drip { position: absolute; left: 14px; top: 100%; width: 8px; height: 11px; color: var(--ink); pointer-events: none; }
.drip svg { width: 8px; height: 11px; }
.drip::after { content: ""; position: absolute; left: 50%; top: 100%; width: 22px; height: 6px; margin-left: -11px; border-radius: 50%; background: color-mix(in oklab, var(--ink) 18%, transparent); transform: scale(0); }
@media (prefers-reduced-motion: no-preference) {
  .drip { animation: drip 650ms cubic-bezier(.5,0,.75,0) forwards; }
  .drip::after { animation: absorb 650ms ease-out forwards; }
}
@media (prefers-reduced-motion: reduce) { .drip { display: none; } }
@keyframes drip { 0% { transform: translateY(-6px) scale(.6); opacity: 0; } 15% { opacity: 1; } 70% { transform: translateY(34px) scale(1, 1.15); opacity: 1; } 100% { transform: translateY(40px) scale(1.4, .2); opacity: 0; } }
@keyframes absorb { 0%, 65% { transform: scale(0); opacity: 0; } 75% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

/* ---------- Section titles, rules, progress ---------- */
.sec { font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1; margin: 28px 0 14px; position: relative; padding-bottom: 9px; }
.sec::after { content: ""; position: absolute; left: -2px; bottom: 0; width: 76px; height: 6px; background: var(--ink); opacity: .85; border-radius: 3px; }
.has-tx .sec::after { height: 8px; border-radius: 0; -webkit-mask: var(--tx-mask-underline) left center / 100% 100% no-repeat; mask: var(--tx-mask-underline) left center / 100% 100% no-repeat; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.has-tx .divider { height: 5px; background: var(--ink); opacity: .35; -webkit-mask: var(--tx-mask-rule) center / 100% 100% no-repeat; mask: var(--tx-mask-rule) center / 100% 100% no-repeat; }
.progress { height: 5px; border-radius: var(--r-full); background: var(--wash-deep); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); }
.has-tx .progress i { -webkit-mask: var(--tx-mask-progress) left center / 100% 100% no-repeat; mask: var(--tx-mask-progress) left center / 100% 100% no-repeat; }

/* ---------- Segmented control and tabs ---------- */
.seg { display: flex; min-height: 44px; padding: 4px; border-radius: var(--r-full); background: var(--wash); }
.seg button { flex: 1; min-height: 36px; padding: 0 12px; border-radius: var(--r-full); font-weight: 600; font-size: 14px; color: var(--ink-soft); transition: background-color 150ms, color 150ms; }
.seg button.on, .seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Inputs ---------- */
.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-md); border: 1.5px solid var(--ink-faint); background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; }
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 0; border-color: var(--ink); box-shadow: inset 0 0 0 0.5px var(--ink); }
.input[aria-invalid="true"] { border-color: var(--seal); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 700; font-size: 14px; }
.err { color: var(--seal); font-size: 14px; font-weight: 600; }
.search { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: var(--r-full); background: var(--wash); border: 1.5px solid transparent; }
.search:focus-within { border-color: var(--ink); }
.search input { flex: 1; min-width: 0; background: none; border: 0; font: inherit; font-size: 16px; color: var(--ink); min-height: 44px; }
.search input:focus { outline: 0; }
.search svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; flex: none; }
.search kbd { font: inherit; font-size: 12px; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: var(--r-full); background: var(--wash-deep); position: relative; flex: none; cursor: pointer; transition: background-color 150ms; margin: 8px 0; border: 1.5px solid var(--ink-faint); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); transition: translate 150ms var(--ease); }
.switch:checked { background: var(--ink); border-color: var(--ink); }
.switch:checked::after { translate: 20px 0; }

/* ---------- Cards and covers ---------- */
.card { border-radius: var(--r-md); background: var(--wash); padding: 16px; }
.card.line { background: var(--paper); border: 1.5px solid var(--ink); }
.cover { border-radius: var(--r-md); border: 1.5px solid var(--ink); background: #FDFDFB; position: relative; overflow: hidden; aspect-ratio: 2/3; display: block; flex: none; }
.cover svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cover.lit svg { }
@media (prefers-reduced-motion: no-preference) { .cover svg.ink-in { animation: inkIn 600ms var(--ease) var(--d, 0ms) both; } }
@keyframes inkIn { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
.cover .ct { position: absolute; left: 8px; bottom: 8px; right: 8px; font-family: var(--font-display); font-size: 18px; line-height: 1.05; color: #141414; }
.cover .ct span { background: #FDFDFB; padding: 1px 4px 0; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* ---------- Sheets (Bloom) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(20,20,20,0); transition: background-color 450ms var(--ease); pointer-events: none; visibility: hidden; }
.overlay.open { background: rgba(20,20,20,.5); pointer-events: auto; visibility: visible; }
.overlay.closing { visibility: visible; }
.sheet { width: 100%; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); color: var(--ink); border-radius: 22px 22px 0 0; padding: 12px max(20px, env(safe-area-inset-left, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; position: relative; opacity: 0; transition: opacity 150ms linear; }
.overlay.open .sheet { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { clip-path: ellipse(14% 3% at 50% 100%); transition: clip-path 450ms var(--ease), opacity 150ms linear 100ms; }
  .overlay.open .sheet { clip-path: ellipse(160% 130% at 50% 100%); }
}
.sheet::before { content: ""; position: sticky; z-index: 2; display: block; flex: none; top: -12px; margin: -12px -20px -14px; height: 24px; border-top: 2px solid var(--ink); border-radius: 22px 22px 0 0; pointer-events: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--wash-deep); align-self: center; flex: none; }
.sheet h2, .sheet h3 { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1; }
.sheet .body { color: var(--ink-soft); }
.sheet .kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sheet .kv b { font-weight: 800; }
.sheet .x { position: absolute; top: 8px; right: 8px; z-index: 3; }
.sheet.ember { background-image: var(--tx-wash-ember); background-size: 100% 180px; background-repeat: no-repeat; }
@media (min-width: 720px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 480px; max-height: 86dvh; border-radius: 22px; padding: 20px 24px 24px; box-shadow: var(--shadow); }
  .sheet::before { display: none; }
  .sheet .grab { display: none; }
  @media (prefers-reduced-motion: no-preference) {
    .sheet { clip-path: none; transform: translateY(8px); filter: blur(3px); transition: opacity 280ms var(--ease), transform 520ms var(--ease), filter 280ms var(--ease); }
    .overlay.open .sheet { clip-path: none; transform: none; filter: none; }
  }
  .overlay.side { justify-content: flex-end; align-items: stretch; padding: 0; }
  .overlay.side .sheet { max-width: 440px; max-height: none; height: 100dvh; border-radius: 22px 0 0 22px; }
}
.tipamts { display: flex; gap: 10px; }
.tipamts button { flex: 1; min-height: 56px; border-radius: var(--r-md); border: 1.5px solid var(--ink); font-weight: 800; display: grid; place-items: center; line-height: 1.1; }
.tipamts button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tipamts button small { font-weight: 400; font-size: 12px; opacity: .8; }
.tier { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-md); border: 1.5px solid var(--line); text-align: left; width: 100%; }
.tier.on { border-color: var(--azurite); box-shadow: inset 0 0 0 0.5px var(--azurite); }
.tier b { font-weight: 800; display: block; } .tier span { font-size: 13px; color: var(--ink-soft); }
.tier .p { font-weight: 800; color: var(--azurite); white-space: nowrap; font-size: 14px; }
@media (hover: hover) { button.tier:hover { border-color: var(--ink-faint); } }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); translate: -50% 0; display: flex; align-items: center; gap: 10px; min-height: 44px; max-width: calc(100vw - 32px); padding: 8px 18px 8px 14px; color: var(--paper); font-weight: 600; font-size: 14px; z-index: 80; opacity: 0; transition: opacity 150ms; pointer-events: none; isolation: isolate; }
.toast::before { content: ""; position: absolute; inset: -4px -10px; background: var(--ink); z-index: -1; border-radius: var(--r-full); }
.has-tx .toast::before { border-radius: 0; -webkit-mask: var(--tx-mask-pill) center / 100% 100% no-repeat; mask: var(--tx-mask-pill) center / 100% 100% no-repeat; }
.toast.show { opacity: 1; }
.toast:empty { display: none; }
.toast i { width: 10px; height: 10px; border-radius: var(--r-full); background: var(--seal); flex: none; }

/* ---------- Mo ---------- */
.mo { display: block; overflow: visible; }
.mo .body { transform-origin: 60px 126px; }
.mo .eye { transform-origin: center; transform-box: fill-box; }
.mo-wrap { display: grid; place-items: center; gap: 4px; }
.mo-say { font-family: var(--font-display); font-size: 22px; color: var(--ink); text-align: center; text-wrap: balance; }
@media (prefers-reduced-motion: no-preference) {
  .mo.idle .body, .mo.lantern .body { animation: breathe 4s ease-in-out infinite; }
  .mo.idle .eye, .mo.lantern .eye, .mo.read .eye, .mo.wave .eye { animation: blink 6s linear infinite; }
  .mo.splash .body { animation: splash 900ms var(--ease) 2 both; }
  .mo.splash .ripple { animation: ripple 900ms ease-out 2 both; transform-origin: 60px 128px; }
  .mo.cheer .body { animation: cheer 600ms var(--ease) 1 both; }
  .mo.cheer .fly { animation: fly 600ms ease-out 1 both; }
  .mo.sleep .body, .mo.read .body { animation: breathe 5s ease-in-out infinite; }
  .mo.lantern .lamp { transform-origin: 101px 98px; animation: sway 3.2s ease-in-out infinite; }
  .mo.read .eye { animation: readEyes 4s ease-in-out infinite; }
  .mo.wave .wavearm { transform-origin: 88px 96px; animation: waveArm 1.2s ease-in-out 2 both; }
  .mo.poke .body { animation: poke 450ms var(--ease) 1 both; }
  .mo.dip .body { animation: dip 600ms var(--ease) 1 both; }
}
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, 0.98); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes splash { 0% { transform: translateY(-40px) scale(0.9, 1.1); } 45% { transform: translateY(0) scale(1.18, 0.78); } 70% { transform: translateY(-6px) scale(0.96, 1.04); } 100% { transform: none; } }
@keyframes ripple { 0% { transform: scale(0.3); opacity: 0; } 45% { opacity: .6; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes cheer { 0% { transform: translateY(0); } 40% { transform: translateY(-22px) scale(0.96, 1.06); } 100% { transform: translateY(0); } }
@keyframes fly { 0% { transform: translate(0, 0) scale(0.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; } }
@keyframes sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes readEyes { 0%, 40% { transform: translateX(-1.5px); } 50%, 90% { transform: translateX(1.5px); } 100% { transform: translateX(-1.5px); } }
@keyframes waveArm { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(14deg); } }
@keyframes poke { 0% { transform: none; } 35% { transform: scale(1.12, 0.86); } 70% { transform: scale(0.96, 1.05); } 100% { transform: none; } }
@keyframes dip { 0% { transform: none; } 45% { transform: translateY(26px) scale(1.1, .82); } 70% { transform: translateY(-6px) scale(.96, 1.05); } 100% { transform: none; } }
.poke-ring { position: fixed; pointer-events: none; z-index: 70; width: 120px; height: 120px; margin: -60px 0 0 -60px; color: var(--ink); }
.poke-ring svg { width: 100%; height: 100%; display: block; }
@media (prefers-reduced-motion: no-preference) { .poke-ring { animation: pokeRing 600ms ease-out both; } }
@media (prefers-reduced-motion: reduce) { .poke-ring { display: none; } }
@keyframes pokeRing { from { transform: scale(0.4); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }
/* Mo wanders on empty pages and leaves three dots. */
.mo-walk { position: relative; width: 100%; height: 150px; overflow: hidden; container-type: inline-size; }
.mo-walk .walker { position: absolute; bottom: 0; left: 0; }
.mo-walk .trail { position: absolute; bottom: 14px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); opacity: 0; }
@media (prefers-reduced-motion: no-preference) { .mo-walk .walker { animation: moWalk 9s ease-in-out infinite; } .mo-walk .trail { animation: trail 9s linear infinite; } }
@media (prefers-reduced-motion: reduce) { .mo-walk .walker { left: 50%; margin-left: -42px; } }
@keyframes moWalk { 0% { transform: translateX(6px); } 45% { transform: translateX(calc(100cqw - 96px)); } 50% { transform: translateX(calc(100cqw - 96px)) scaleX(-1); } 95% { transform: translateX(6px) scaleX(-1); } 100% { transform: translateX(6px); } }
@keyframes trail { 0%, 8% { opacity: 0; transform: scale(.4); } 10% { opacity: .5; transform: scale(1); } 40% { opacity: .25; } 55%, 100% { opacity: 0; } }

/* ---------- Rings: cosmetic borders reused as UI moments ---------- */
@property --a { syntax: "<angle>"; inherits: false; initial-value: 360deg; }
.ringed { position: relative; width: var(--s); height: var(--s); display: grid; place-items: center; flex: none; margin: 0 auto; }
.ringed .in { position: absolute; inset: 11%; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--paper); }
.ringed.seal-wash .in { background: radial-gradient(circle at 50% 60%, color-mix(in oklab, var(--seal) 14%, var(--paper)), var(--paper) 70%); }
.ringed.mint-wash .in { background: radial-gradient(circle at 50% 60%, color-mix(in oklab, var(--malachite) 14%, var(--paper)), var(--paper) 70%); }
.ringed.sky-wash .in { background: radial-gradient(circle at 50% 60%, color-mix(in oklab, var(--azurite) 14%, var(--paper)), var(--paper) 70%); }
.ringed .in .mo-wrap { margin-top: 8%; }
.ringed .in > svg { width: 100%; height: 100%; display: block; }
.ringed .rg { position: absolute; inset: 0; pointer-events: none; color: var(--ink); }
.ringed .rg svg { width: 100%; height: 100%; display: block; }
@media (prefers-reduced-motion: no-preference) {
  .ringed.draw .rg { -webkit-mask: conic-gradient(from -90deg, #000 var(--a), transparent 0); mask: conic-gradient(from -90deg, #000 var(--a), transparent 0); animation: ringDraw 700ms var(--ease) var(--rd, 0ms) both; }
  .ringed.draw .in { animation: ringIn 300ms ease-out var(--rd, 0ms) both; }
  .stage > * { animation: ringIn 300ms ease-out both; } .stage > :nth-child(2) { animation-delay: 100ms; } .stage > :nth-child(3) { animation-delay: 200ms; } .stage > :nth-child(4) { animation-delay: 300ms; } .stage > :nth-child(5) { animation-delay: 400ms; }
}
@media (prefers-reduced-motion: reduce) { .ringed.draw .rg, .ringed.draw .in, .stage > * { animation: fadeIn 150ms linear both; } }
@keyframes ringDraw { from { --a: 0deg; } to { --a: 360deg; } }
@keyframes ringIn { from { opacity: 0; filter: blur(4px); transform: translateY(12px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Seal stamp ---------- */
.stamp { position: fixed; z-index: 90; translate: -50% -50%; pointer-events: none; }
.stamp .ringed { --s: 96px; flex: none; }
.stamp .ringed .in { inset: 18%; background: transparent; overflow: visible; }
.stamp b { width: 60px; height: 60px; border-radius: 10px; display: grid; place-items: center; background: var(--seal); color: #fff; font-family: var(--font-brush); font-weight: 400; font-size: 32px; line-height: 1; box-shadow: 0 0 0 4px rgba(200,55,31,.12); rotate: -4deg; }
@media (prefers-reduced-motion: no-preference) { .stamp b { animation: stamp 350ms cubic-bezier(.3,1.4,.5,1) both; } }
@media (prefers-reduced-motion: reduce) { .stamp b { animation: fadeIn 150ms linear both; } }
.stamp.out { opacity: 0; transition: opacity 150ms linear; }
@keyframes stamp { 0% { transform: scale(1.15) rotate(-6deg); opacity: 0; filter: blur(4px); } 40% { opacity: 1; } 100% { transform: none; opacity: 1; filter: none; } }

/* ---------- Avatars, borders, seals, banners ---------- */
.avc { position: relative; width: var(--s, 40px); height: var(--s, 40px); flex: none; display: inline-block; }
.avc .avi { position: absolute; inset: 8.33%; border-radius: 50%; overflow: hidden; background: #FDFDFB; }
.avc .avb { position: absolute; inset: 0; pointer-events: none; color: var(--ink); }
.avc svg { width: 100%; height: 100%; display: block; }
.chop { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 6px; font-family: var(--font-brush), serif; font-size: 13px; line-height: 1; color: #fff; background: var(--seal); border-radius: 3px; rotate: -4deg; vertical-align: -3px; font-weight: 400; flex: none; }
.chop.round { border-radius: 50%; }
.chop.azurite { background: var(--azurite); }
.profile { position: relative; border-radius: var(--r-md); overflow: hidden; border: 1.5px solid var(--ink); background: var(--paper); }
.profile .bn { height: 96px; background: var(--wash); }
.profile .bn.plain { height: 52px; }
.profile .bn svg { width: 100%; height: 100%; display: block; }
.profile .pbody { display: flex; align-items: flex-end; gap: 12px; padding: 0 14px 14px; margin-top: -40px; position: relative; }
.profile .pbody .avc { --s: 88px; }
.profile .nm { font-family: var(--font-display); font-size: 26px; line-height: 1.1; padding-bottom: 6px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); grid-auto-rows: 1fr; gap: 14px 10px; }
.cos-grid.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cos { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: var(--r-md); border: 1.5px solid transparent; text-align: center; }
.cos[aria-pressed="true"] { border-color: var(--ink); background: var(--wash); }
@media (hover: hover) { .cos:hover { background: var(--wash); } }
.cos .avc { --s: 84px; }
.cos .nm { font-size: 13px; font-weight: 700; line-height: 1.2; }
.cos .pr { font-size: 12px; color: var(--ink-soft); display: inline-flex; gap: 4px; align-items: center; min-height: 16px; }
.cos .pr svg { width: 9px; height: 12px; }
.cos .pr.own { color: var(--malachite); font-weight: 700; }
.cos .bnp { width: 100%; height: 56px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); display: block; }
.cos .bnp svg { width: 100%; height: 100%; display: block; }
.cos .chopbig { width: 52px; height: 52px; display: grid; place-items: center; }
.cos .chopbig .chop { width: 40px; height: 40px; font-size: 28px; margin: 0; }
@media (prefers-reduced-motion: no-preference) { .cos.just .avc .avb { -webkit-mask: conic-gradient(from -90deg, #000 var(--a), transparent 0); mask: conic-gradient(from -90deg, #000 var(--a), transparent 0); animation: ringDraw 600ms var(--ease) both; } }

/* ---------- Tap blot ---------- */
.blot-host { position: relative; overflow: hidden; }
.blot { position: absolute; width: 88px; height: 88px; margin: -44px 0 0 -44px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(20,20,20,.18) 0 34%, rgba(20,20,20,.08) 52%, transparent 70%); transform: scale(.08); z-index: 0; }
@media (prefers-reduced-motion: no-preference) { .blot { animation: blot 450ms var(--ease) forwards; } }
@media (prefers-reduced-motion: reduce) { .blot { display: none; } }
@keyframes blot { 0% { transform: scale(.08); opacity: 1; } 70% { opacity: .9; } 100% { transform: scale(1); opacity: 0; } }

/* ---------- Settle: the page transition ---------- */
.bloom { position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0; overflow: hidden; }
.bloom::after { content: ""; position: absolute; left: var(--x, 50%); top: var(--y, 50%); width: 200px; height: 200px; margin: -100px 0 0 -100px; border-radius: 50%; background: radial-gradient(circle, color-mix(in oklab, var(--ink) 15%, transparent) 0%, color-mix(in oklab, var(--ink) 8%, transparent) 32%, transparent 62%); transform: scale(0.15); }
@media (prefers-reduced-motion: no-preference) {
  .bloom.run { animation: settleInk 1100ms linear both; }
  .bloom.run::after { animation: settleSpread 1100ms var(--ease) both; }
  .leaving { transition: opacity 280ms ease-out, filter 280ms ease-out; opacity: 0; filter: blur(3px); }
  .settle { animation: settleIn 520ms var(--ease) both; }
}
@media (prefers-reduced-motion: reduce) { .settle { animation: fadeIn 200ms linear both; } .leaving { opacity: 0; transition: opacity 150ms linear; } }
@keyframes settleInk { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes settleSpread { from { transform: scale(0.15); } to { transform: scale(1); } }
@keyframes settleIn { from { opacity: 0; filter: blur(4px); transform: translateY(8px); } to { opacity: 1; filter: none; transform: none; } }
/* Brush reveal for a chapter numeral and title. Body text never moves. */
.brush-in { width: fit-content; max-width: 100%; }
@media (prefers-reduced-motion: no-preference) {
  .brush-in { -webkit-mask-image: linear-gradient(90deg, #000 44%, transparent 56%); mask-image: linear-gradient(90deg, #000 44%, transparent 56%); -webkit-mask-size: 260% 100%; mask-size: 260% 100%; animation: brushIn 700ms cubic-bezier(.45,0,.2,1) var(--d, 0ms) both; }
}
@keyframes brushIn { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }

/* ---------- Rice paper grain ---------- */
.paper-grain { position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: .025; mix-blend-mode: multiply; background-size: 220px 220px, 520px 520px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .paper-grain { display: none; } }
:root[data-theme="dark"] .paper-grain { display: none; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 16px; text-align: center; color: var(--ink-soft); }
.empty b { color: var(--ink); font-size: 18px; }
