/* Azur Lane Story Reader.
   Layout: three screens. The library (every published story), an event's home (cover art, title,
   chapter list) and a full-screen story stage with the game's habits: dialogue panel at the bottom,
   small controls top-right, a backlog. Deliberately one dark look: stories are read at night. */
:root {
  color-scheme: dark;
  --ink: #05080e;          /* stage black */
  --bg: #0b1019;           /* page */
  --panel: #0b111d;        /* dialogue + sheets */
  --raise: #141c2b;
  --line: #ffffff1f;
  --fg: #eef1f6;
  --muted: #a3acbd;
  --brass: #d6b06a;
  --brass-soft: #d6b06a2e;
  --ok: #7fcfa6;
  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --font-body: "Literata", "Iowan Old Style", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 3px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0;
}
html.reading, html.reading body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }

/* ================= home ================= */
.cover { position: fixed; inset: 0; z-index: 0; background: var(--ink); }
.cover img { width: 100%; height: 100%; object-fit: cover; opacity: .6; filter: saturate(.95); }
.cover::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #05080ef0 0%, #05080ec4 34%, #05080e59 62%, #05080e40 100%),
              linear-gradient(0deg, #05080ecc 0%, transparent 30%); }
.feature { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 18%, #000 46%); mask-image: linear-gradient(90deg, transparent 18%, #000 46%);
  animation: featurein 1.1s cubic-bezier(.2,.7,.2,1) both .1s; }
@keyframes featurein { from { opacity: 0; translate: 30px 0 } }   /* ends at the element's own opacity (dimmer on phones) */
.ffig { position: absolute; left: 0; top: 0; }
.ffig img { position: absolute; display: block; max-width: none; }
.ffig .paint { inset: 0; width: 100%; height: 100%; }
@media (max-width: 899px) { .feature { opacity: .15; -webkit-mask-image: linear-gradient(180deg, #000 25%, transparent 70%); mask-image: linear-gradient(180deg, #000 25%, transparent 70%); } }
.home { position: relative; z-index: 1; min-height: 100%; display: grid; align-content: start; gap: 26px;
  grid-template-columns: minmax(0, 1fr); max-width: 540px; margin-left: clamp(0px, 5vw, 96px);
  padding-block: calc(env(safe-area-inset-top, 0px) + 8vh) 28px; }
.hero { display: grid; gap: 14px; align-content: start; min-width: 0; }
.kick { color: var(--brass); }
.hero h1 { margin: 0; font-family: var(--font-display); font-weight: 800; line-height: 1.04;
  font-size: clamp(36px, 6.4vw, 72px); text-wrap: balance; letter-spacing: -.01em; }
.hero .meta { color: var(--muted); }
.rule { width: 72px; height: 2px; background: var(--brass); }
.acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.primary { display: grid; gap: 2px; text-align: left; padding: 12px 22px 12px 18px; border: 0; color: #191306; background: var(--brass);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); }
.primary span { font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.primary small { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.primary:hover { filter: brightness(1.08); }
.ghost { padding: 0 16px; min-height: 44px; border: 1px solid var(--line); background: #0b111d99; }
.ghost:hover { border-color: var(--brass); }
.note { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; max-width: 46ch; line-height: 1.5; }
.chapters { min-width: 0; background: #0b111dcc; border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(6px); }
.chapters ol { list-style: none; margin: 0; padding: 6px 0; }
.chapters li + li { border-top: 1px solid #ffffff0d; }
.chapters button { width: 100%; text-align: left; border: 0; background: none; padding: 11px 16px;
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; }
.chapters button:hover { background: var(--brass-soft); }
.chapters .num { font-family: var(--font-display); font-weight: 800; color: var(--brass); font-size: 17px; font-variant-numeric: tabular-nums; }
.chapters .nm { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.chapters .day { grid-column: 2; color: var(--muted); }
.chapters .st { grid-row: 1 / span 2; grid-column: 3; align-self: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.chapters .st.done { color: var(--ok); }
.chapters .st.cur { color: var(--brass); }
.foot { grid-column: 1 / -1; color: #8d97aa; font-size: 12px; line-height: 1.55; max-width: 72ch; }
.foot a { color: inherit; }

/* ================= reader ================= */
.reader { position: fixed; inset: 0; z-index: 20; background: var(--ink); }
.stage:focus { outline: none; }
.stage { position: absolute; inset: 0; overflow: hidden; container-type: size; user-select: none;
  -webkit-tap-highlight-color: transparent; cursor: pointer; background: var(--ink); color: var(--fg); }
.stage .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .7s ease; }
.stage .bg.on { opacity: 1; }
.stage.black .bg { opacity: 0 !important; }
/* cut-in panel over the background (transparent art), centred, sliding in */
.stage .ov { position: absolute; z-index: 0; left: 50%; top: 46%; max-width: none; height: auto; opacity: 0; pointer-events: none;
  translate: -50% -50%; transition: opacity .35s ease, translate .5s cubic-bezier(.2,.7,.2,1); }
.stage .ov:not(.on) { translate: -56% -50%; }
.stage .ov.on { opacity: 1; }
.stage.black .ov { opacity: 0; }
/* drifting sparks over a fire (the game's huohua effect), two layers of glowing specks rising */
.sparks { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 1s ease; }
.stage.fx-sparks .sparks { opacity: 1; }
.sparks i { position: absolute; left: 0; right: 0; top: 0; height: calc(100% + 420px); mix-blend-mode: screen;
  background-image:
    radial-gradient(2.5px 2.5px at 12% 18%, #ffd08a, transparent), radial-gradient(2px 2px at 34% 64%, #ff9a4a, transparent),
    radial-gradient(3px 3px at 58% 32%, #ffb866, transparent), radial-gradient(1.8px 1.8px at 77% 81%, #ff8240, transparent),
    radial-gradient(2.2px 2.2px at 91% 44%, #ffc47a, transparent), radial-gradient(1.6px 1.6px at 46% 92%, #ff7a3a, transparent);
  background-size: 420px 420px; animation: sparks-rise 9s linear infinite; }
.sparks i + i { background-size: 300px 300px; animation: sparks-rise-near 6s linear infinite; opacity: .75; filter: blur(.6px); }
.sparks::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 90% 55% at 50% 105%, #ff6a1f33, transparent 70%); }
@keyframes sparks-rise { from { transform: translate3d(0, 0, 0) } to { transform: translate3d(0, -420px, 0) } }
@keyframes sparks-rise-near { from { transform: translate3d(0, 0, 0) } to { transform: translate3d(0, -300px, 0) } }
@media (prefers-reduced-motion: reduce) { .sparks i { animation: none; } }
.stage.old .bg, .stage.old .fig { filter: sepia(.55) saturate(.7) contrast(.95) brightness(.92); }
.stage.old::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 55%, #1a120688 100%); }
.fig { position: absolute; left: 0; top: 0; z-index: 1; opacity: 0; transition: opacity .22s ease, filter .3s ease; will-change: transform, opacity; }
.fig.on { opacity: 1; }
.fig.dim { filter: brightness(.5) saturate(.75); z-index: 0; }
.fog { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 1.4s ease;
  background: radial-gradient(ellipse 70% 60% at 50% 42%, transparent 30%, #eef2f8b3 100%); }
.stage.fx-fog .fog { opacity: 1; animation: breathe 7s ease-in-out infinite alternate; }
.stage.fx-fogdark .fog { opacity: 1; background: radial-gradient(ellipse 70% 60% at 50% 42%, transparent 25%, #1b0a0fd9 100%); }
@keyframes breathe { from { filter: blur(0) } to { filter: blur(6px); transform: scale(1.03) } }
.fig .mv, .fig .in { position: relative; width: 100%; height: 100%; }
.fig.flip .in { transform: scaleX(-1); }
.fig img { position: absolute; display: block; max-width: none; }
.fig .paint { inset: 0; width: 100%; height: 100%; }
.fig.noise .in { animation: noise .35s steps(2) infinite; }
@keyframes noise { 0% { translate: 0 0; opacity: .92 } 50% { translate: 3px 0; opacity: .7 } 100% { translate: -2px 0; opacity: .95 } }
.flash { position: absolute; inset: 0; background: #000; pointer-events: none; opacity: 0; z-index: 3; }
.flash.go { animation: flash .7s ease-out; }
@keyframes flash { from { opacity: 1 } to { opacity: 0 } }

/* dialogue panel */
.dlg {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); isolation: isolate;
  bottom: calc(3cqh + env(safe-area-inset-bottom, 0px));
  width: min(calc(100cqw - 2 * max(16px, env(safe-area-inset-left, 0px))), 1000px); min-height: min(20cqh, 176px);
  padding: 26px clamp(18px, 3cqw, 36px) 36px;
  font-size: clamp(15.5px, 1.2cqw + 7.5px, 23px); line-height: 1.58;
}
.dlg::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(#d6b06a80, #d6b06a80) top / 100% 1px no-repeat, linear-gradient(180deg, #0b111dd4, #0b111df4);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
}
.dlg.shake { animation: shake .32s linear 2; }
@keyframes shake { 25% { transform: translateX(calc(-50% - 9px)) } 75% { transform: translateX(calc(-50% + 9px)) } }
.who {
  position: absolute; left: clamp(18px, 3cqw, 36px); top: -15px; line-height: 1.3;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(15px, .9cqw + 9px, 21px); letter-spacing: .02em;
  color: var(--brass); background: var(--ink); padding: 3px 14px 3px 10px; border-left: 3px solid currentColor;
}
.dlg.narr .txt { font-style: italic; color: #d9dee8; }
.txt { margin: 0; max-width: 64ch; text-wrap: pretty; }
.dlg.hasport { padding-left: calc(clamp(18px, 3cqw, 36px) + clamp(64px, 11cqh, 108px) + 18px); }
.port { position: absolute; left: clamp(18px, 3cqw, 36px); top: 24px; width: clamp(64px, 11cqh, 108px); aspect-ratio: 1;
  border: 1px solid #d6b06a66; background-color: #141c2b; background-repeat: no-repeat; }
.dlg.hasport .who { left: calc(clamp(18px, 3cqw, 36px) + clamp(64px, 11cqh, 108px) + 18px); }
.more { position: absolute; right: 18px; bottom: 10px; color: var(--brass); font-size: 12px; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(3px) } }
.pos { position: absolute; left: clamp(18px, 3cqw, 36px); bottom: 12px; color: #8d97aa; font-variant-numeric: tabular-nums; }

/* choices */
.choices { position: absolute; inset: 0; z-index: 5; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 0 16px 24cqh; pointer-events: none; }
.choices button {
  pointer-events: auto; width: min(560px, 88cqw); padding: 12px 20px; border: 1px solid #d6b06a88;
  background: #0b111de8; color: var(--fg); font-size: clamp(15px, 1cqw + 8px, 19px); text-align: left;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); animation: rise .35s ease both;
}
.choices button:nth-child(2) { animation-delay: .07s } .choices button:nth-child(3) { animation-delay: .14s }
.choices button:hover, .choices button:focus-visible { background: #2a2210f2; border-color: var(--brass); }
.choices button::before { content: "▸  "; color: var(--brass); }

/* cards: chapter title, location caption, monologue */
.card { position: absolute; inset: 0; z-index: 6; display: grid; overflow: hidden; background: #05080ed9; }
.stage.black .card { background: #000; }
.card .back { position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); max-width: none; object-fit: cover;
  filter: blur(16px) brightness(.32) saturate(.8); transform: scale(1.04); }
.card .c { position: relative; align-self: center; justify-self: center; display: grid; justify-items: center; gap: 14px; padding: 24px; text-align: center; }
.card.instant * { animation-delay: 0s !important; animation-duration: .01s !important; }
.t-ev { color: var(--brass); animation: rise .8s ease both .1s; }
.t-row { display: flex; align-items: center; gap: 18px; }
.t-row i { display: block; height: 1px; width: clamp(40px, 12cqw, 140px); background: #d6b06a99; transform-origin: center; animation: grow .9s cubic-bezier(.2,.7,.2,1) both .25s; }
.t-num { font-family: var(--font-display); font-weight: 800; color: var(--brass); font-size: clamp(22px, 2cqw + 12px, 38px); font-variant-numeric: tabular-nums; animation: rise .7s ease both .35s; }
.t-name { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(28px, 3.4cqw + 12px, 64px); line-height: 1.1; text-wrap: balance; max-width: 18ch; animation: rise .9s ease both .55s; }
.t-day { color: var(--muted); animation: rise .7s ease both .85s; }
.hint { white-space: nowrap; position: absolute; left: 50%; bottom: calc(6cqh + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); color: #8d97aa; animation: fadein .6s ease both 1.6s, pulse 2.4s ease-in-out infinite 2.2s; }
.card.loc .c { justify-self: start; justify-items: start; text-align: left; gap: 6px; margin-left: clamp(16px, 9cqw, 160px); padding-left: 22px; border-left: 2px solid var(--brass); }
.card.loc .c > * { animation: slidein .7s cubic-bezier(.2,.7,.2,1) both; }
.l-main { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 2cqw + 12px, 40px); line-height: 1.15; }
.l-sub { color: var(--muted); font-size: 12px; }
.card.mono-log .c { gap: 16px; max-width: min(760px, 90cqw); }
.card.mono-log p { margin: 0; font-style: italic; font-size: clamp(16px, 1cqw + 10px, 22px); line-height: 1.6; color: #e3e7ee; animation: rise 1s ease both; text-wrap: pretty; }
.card.plain p { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(18px, 1.4cqw + 10px, 28px); animation: rise .8s ease both; text-wrap: balance; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes grow { from { transform: scaleX(0) } to { transform: scaleX(1) } }
@keyframes slidein { from { opacity: 0; transform: translateX(-14px) } to { opacity: 1; transform: none } }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
@keyframes pulse { 50% { opacity: .45 } }

/* chapter end */
.end { position: absolute; inset: 0; z-index: 7; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; background: #05080ee6; text-align: center; cursor: default; }
.end h3 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 2cqw + 12px, 38px); text-wrap: balance; }
.endrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.endrow .ghost { min-height: 44px; }

/* top controls, game-style: small and out of the way */
.bar { position: absolute; z-index: 10; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 22px max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(#05080ecc, #05080e00); pointer-events: none; }
.bar > * { pointer-events: auto; }
.bar .chl { flex: 1; min-width: 0; color: #c9cfda; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tb { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border: 1px solid #ffffff2e; background: #05080e8c; color: #e4e8ef;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.tb:hover { border-color: var(--brass); color: var(--brass); }
.tb[aria-pressed="true"] { border-color: var(--brass); color: #191306; background: var(--brass); }
.tb svg { width: 15px; height: 15px; flex: none; }
.tb.icon { width: 34px; padding: 0; justify-content: center; }
.lbl { display: none; }
@media (min-width: 640px) { .lbl { display: inline; } }

/* script (scroll) reading style */
.script { position: absolute; inset: 0; overflow: auto; background: var(--bg); padding-top: calc(env(safe-area-inset-top, 0px) + 56px); }
.script .wrap { max-width: 760px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 80px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 2px; }
.script h3 { font-family: var(--font-display); font-weight: 800; font-size: 30px; margin: 6px 0 4px; text-wrap: balance; line-height: 1.15; }
.row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 7px 10px; border-radius: var(--r); cursor: pointer; }
.row:hover { background: #ffffff0a; }
.row.cur { background: var(--brass-soft); box-shadow: inset 2px 0 0 var(--brass); }
.row .w2 { font-family: var(--font-display); font-weight: 800; font-size: 14px; color: var(--brass); line-height: 1.3; }
.row .t { line-height: 1.62; min-width: 0; overflow-wrap: anywhere; }
.row.narr .t { font-style: italic; color: #c5ccd8; }
.av { width: 44px; height: 44px; border-radius: 50%; background-color: var(--raise); background-repeat: no-repeat; border: 1px solid var(--line); }
.av.ini { display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; color: var(--brass); font-size: 17px; }
.sc { margin: 14px 0 6px; height: 64px; border-radius: var(--r); overflow: hidden; position: relative; background: var(--ink); }
.sc img { width: 100%; height: 100%; object-fit: cover; opacity: .85; display: block; }
.sc span { position: absolute; left: 10px; bottom: 7px; color: #fff; text-shadow: 0 1px 3px #000; }
.cardrow { text-align: center; padding: 14px 10px; font-family: var(--font-display); font-weight: 600; color: var(--muted); }
.cardrow div + div { margin-top: 4px; }
.choice { margin: 6px 0 2px 56px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--brass); color: var(--brass); padding: 3px 10px; border-radius: 999px; font-size: 13px; background: none; }
.chip[aria-pressed="true"] { background: var(--brass); color: #191306; }
.branch { margin-left: 56px; border-left: 2px solid var(--brass-soft); }
.branch .row { grid-template-columns: 36px minmax(0, 1fr); }
.branch .av { width: 36px; height: 36px; }
.branch-h { margin: 6px 0 0 66px; color: var(--muted); }

/* sheets: backlog + menu */
.sheet { position: absolute; z-index: 15; top: 0; right: 0; bottom: 0; width: min(560px, 100%); display: flex; flex-direction: column;
  background: #0b111df7; border-left: 1px solid var(--line); box-shadow: -20px 0 50px #0008; animation: sheetin .22s ease; }
@keyframes sheetin { from { transform: translateX(24px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet header { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 14px) max(16px, env(safe-area-inset-right, 0px)) 12px 18px; border-bottom: 1px solid var(--line); }
.sheet h4 { margin: 0; flex: 1; font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.sheet .list { flex: 1; overflow: auto; padding: 10px 8px calc(env(safe-area-inset-bottom, 0px) + 24px); display: grid; align-content: start; gap: 2px; }
.menu { position: absolute; z-index: 16; top: calc(env(safe-area-inset-top, 0px) + 54px); right: max(16px, env(safe-area-inset-right, 0px));
  width: min(340px, calc(100vw - 32px)); max-height: calc(100% - 70px); overflow: auto; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 18px 50px #000a; padding: 16px; display: grid; gap: 14px; animation: rise .18s ease; }
.menu h4 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); }
.field input[type="text"] { height: 36px; border: 1px solid var(--line); background: var(--raise); border-radius: var(--r); padding: 0 10px; }
.seg { display: inline-flex; width: max-content; max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: none; height: 32px; padding: 0 11px; }
.seg button[aria-pressed="true"] { background: var(--brass); color: #191306; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sw button { min-width: 64px; height: 30px; border: 1px solid var(--line); background: var(--raise); font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.sw button[aria-pressed="true"] { border-color: var(--brass); color: #191306; background: var(--brass); }
.menu .acts2 { display: flex; flex-wrap: wrap; gap: 8px; }
.menu .acts2 button { height: 34px; padding: 0 12px; border: 1px solid var(--line); background: var(--raise); }
.menu .acts2 button:hover { border-color: var(--brass); }
.menu .note { font-size: 12.5px; }
.danger { color: #e2877d; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: #eef1f6; color: #0b1019; padding: 10px 14px; border-radius: var(--r); font-size: 14px; display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast button { border: 0; background: none; color: #7a5818; font-weight: 600; padding: 0; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ================= library ================= */
body[data-view="library"] { background: radial-gradient(ellipse 80% 50% at 70% 0%, #1b2436 0%, var(--bg) 70%) var(--bg); }
.lib { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; display: grid; gap: 22px;
  padding-block: calc(env(safe-area-inset-top, 0px) + 32px) 40px; }
.lib-head { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: end; justify-content: space-between;
  padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.lib-head > div { display: grid; gap: 10px; min-width: 0; }
.lib-head h1 { margin: 0; font-family: var(--font-display); font-weight: 800; line-height: 1.04; letter-spacing: -.01em;
  font-size: clamp(32px, 5vw, 56px); text-wrap: balance; }
.made { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; max-width: 64ch;
  padding: 9px 12px; border: 1px solid #d6b06a59; background: #d6b06a12; font-size: 14px; line-height: 1.45; }
.made b { color: var(--brass); font-weight: 600; }
.linkish { border: 0; background: none; padding: 0; color: var(--brass); text-decoration: underline; text-underline-offset: 3px; }
.lib-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-tools .ghost { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7487; }
.dot.on { background: var(--ok); }
.dot.err { background: #e2877d; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { height: 32px; padding: 0 12px; border: 1px solid var(--line); background: none; color: var(--muted); }
.filters button[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.ev-card { position: relative; display: grid; align-content: end; min-height: 200px; padding: 18px; overflow: hidden;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); text-align: left; }
.ev-card img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; opacity: .6;
  transition: transform .6s cubic-bezier(.2,.7,.2,1), opacity .3s ease; }
.ev-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #05080ef2 8%, #05080e66 60%, #05080e1f); }
.ev-card:hover img, .ev-card:focus-visible img { transform: scale(1.04); opacity: .75; }
.ev-card:hover { border-color: #d6b06a88; }
.ev-card .in { position: relative; z-index: 1; display: grid; gap: 6px; }
.ev-card .kind { color: var(--brass); }
.ev-card h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1.15; text-wrap: balance; }
.ev-card .stat { color: #c3cad6; }
.ev-card .stat .done { color: var(--ok); }
.ev-card .meter { position: absolute; z-index: 1; left: 0; bottom: 0; height: 3px; background: var(--brass); }
.lib-empty { padding: 40px 0; color: var(--muted); }
/* stories nobody has compared with the game yet: their own section, set apart by dashed edges */
.pending { display: grid; gap: 14px; padding-top: 22px; border-top: 1px dashed #ffffff33; }
.pending:first-child, .grid[hidden] + .pending { border-top: 0; padding-top: 0; }
.pending-head { display: grid; gap: 6px; max-width: 70ch; }
.pending-head h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1.2; }
.pending-head p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.pending-head a { color: var(--brass); }
.pending .ev-card { border-style: dashed; border-color: #ffffff38; }
.pending .ev-card .tag { position: absolute; z-index: 1; top: 12px; right: 12px; padding: 3px 7px;
  border: 1px dashed #ffffff55; background: #05080ecc; color: #c3cad6; font-size: 11px; }
.review-note { margin: 0; max-width: 46ch; padding: 9px 12px; border: 1px dashed #ffffff40; background: #05080e99;
  font-size: 14px; line-height: 1.45; color: #c9cfda; }
.review-note b { color: var(--fg); font-weight: 600; }
.backlink { justify-self: start; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.backlink:hover { color: var(--brass); }

/* ================= dialogs (about, sync) ================= */
.dialog { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: #000000b3;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 16px) max(16px, env(safe-area-inset-left, 0px)); }
.dialog .box { width: min(560px, 100%); max-height: 100%; overflow: auto; display: grid; gap: 14px; padding: 22px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 60px #000c; animation: rise .2s ease; }
.dialog h3 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1.2; }
.dialog h4 { margin: 4px 0 0; font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.dialog p { margin: 0; line-height: 1.6; color: #d3d8e1; }
.dialog .row2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dialog .row2 button, .dialog .btn { height: 38px; padding: 0 14px; border: 1px solid var(--line); background: var(--raise); color: var(--fg); }
.dialog .row2 button:hover, .dialog .btn:hover { border-color: var(--brass); }
.dialog .row2 button.go { background: var(--brass); border-color: var(--brass); color: #191306; font-weight: 600; }
.dialog .x { justify-self: end; margin: -8px -8px 0 0; }
.dialog input[type="text"] { height: 40px; min-width: 0; flex: 1 1 220px; border: 1px solid var(--line); background: var(--raise);
  padding: 0 12px; font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.keybox { padding: 14px 12px; border: 1px dashed var(--brass); text-align: center; font-family: var(--font-mono); font-size: clamp(15px, 3.6vw, 20px);
  letter-spacing: .08em; color: var(--brass); user-select: all; overflow-wrap: anywhere; }
.status { color: var(--muted); font-size: 13px; }
.status.err { color: #e2877d; }
.hr { height: 1px; background: var(--line); }
