/* Noxley: player pages. Colours as tokens; light, dark (device or chosen) and sepia. */
:root {
  --bg: #f6f3ee; --panel: #fffdf9; --ink: #23211d; --muted: #6d675d; --line: #e2dcd2;
  --me: #3b4fa8; --me-ink: #ffffff; --accent: #3b4fa8; --danger: #b3261e; --good: #2e7d4f;
  --story-font: Georgia, "Iowan Old Style", "Palatino Linotype", serif; --story-size: 16.5px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #14151b; --panel: #1c1e26; --ink: #ebe7e0; --muted: #a09a90; --line: #2d303a; --me: #5568c4; --accent: #8a9bf0; --danger: #ff8a80; --good: #6fcf97; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #14151b; --panel: #1c1e26; --ink: #ebe7e0; --muted: #a09a90; --line: #2d303a; --me: #5568c4; --accent: #8a9bf0; --danger: #ff8a80; --good: #6fcf97; color-scheme: dark; }
:root[data-theme="sepia"] { --bg: #f1e7d0; --panel: #faf3e3; --ink: #3b2f22; --muted: #76664f; --line: #e0d0b0; --me: #8a5a2b; --accent: #8a5a2b; }
:root[data-font="clean"] { --story-font: system-ui, "Segoe UI", Roboto, sans-serif; }
:root[data-size="small"] { --story-size: 14.5px; }
:root[data-size="large"] { --story-size: 19px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, .btn { font: 600 14px system-ui, sans-serif; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font: 600 20px Georgia, serif; letter-spacing: .02em; color: var(--ink); text-decoration: none; }
.brand b { color: var(--accent); }
.top .sp { flex: 1; }
.top button { padding: 6px 10px; font-size: 13px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 18px 16px 40px; }
h1 { font: 600 26px/1.25 Georgia, serif; margin: 6px 0 6px; }
h2 { font: 600 19px Georgia, serif; margin: 26px 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.note { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 14px; }

/* sign in / sign up */
.auth { max-width: 420px; margin: 6vh auto; padding: 0 16px; }
.auth form { display: grid; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.auth label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); }
.auth .check input { width: auto; margin-top: 3px; }
.auth .swap { text-align: center; margin-top: 14px; }
.tagline { font: italic 17px Georgia, serif; color: var(--muted); text-align: center; margin: 0 0 20px; }

/* library */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { font: 600 18px Georgia, serif; margin: 0; }
.card p { margin: 0; font-family: var(--story-font); }
.card .meta { font-size: 12.5px; color: var(--muted); font-family: system-ui, sans-serif; }
.card .go { margin-top: auto; padding-top: 6px; }
.chip { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; align-self: flex-start; }

/* chat */
.chat { display: flex; flex-direction: column; height: 100dvh; }
.chat .log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; font: var(--story-size)/1.55 var(--story-font); }
.ai-note { font: 12.5px system-ui, sans-serif; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 10px; padding: 6px 10px; }
.narr { color: var(--muted); font-style: italic; text-align: center; padding: 2px 20px; margin: 0; }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg .who { font: 600 13px system-ui, sans-serif; margin: 0 0 3px 2px; }
.msg .who span { font-weight: 400; color: var(--muted); }
.msg .bubble { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line)); border-radius: 12px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me .bubble { background: var(--me); color: var(--me-ink); border: 0; }
.sys { text-align: center; font: 12px system-ui, sans-serif; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.oops { align-self: center; font: 13px system-ui, sans-serif; color: var(--danger); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; background: var(--panel); }
.care { align-self: stretch; font: 14px/1.5 system-ui, sans-serif; border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 12px; padding: 12px 14px; background: var(--panel); }
.care b { display: block; margin-bottom: 4px; }
.typing { color: var(--muted); font: italic 14px system-ui, sans-serif; padding: 0 4px; }
.typing::after { content: "\2026"; display: inline-block; animation: dots 1.2s steps(4) infinite; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
@media (prefers-reduced-motion: reduce) { .typing::after { animation: none; } }
.say { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.say form { display: flex; gap: 8px; max-width: 860px; margin: 0 auto; }
.say textarea { resize: none; height: 46px; max-height: 160px; font: 16px/1.4 system-ui, sans-serif; }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); padding: 20px; max-width: min(460px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin-top: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) { .msg { max-width: 94%; } .wrap { padding: 14px 16px 32px; } }

.err:empty { display: none; }
.top button { white-space: nowrap; }
@media (max-width: 420px) { .top .note { display: none; } }
.msg .who { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.av { position: relative; flex: none; width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--c, var(--line)); background: var(--c, #888); color: #fff; font: 600 11px/1 system-ui, sans-serif; display: inline-grid; place-items: center; overflow: hidden; cursor: zoom-in; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
dialog.portrait { padding: 0; overflow: hidden; max-width: min(420px, calc(100% - 32px)); cursor: zoom-out; }
dialog.portrait img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
dialog.portrait .cap { margin: 0; padding: 10px 14px 12px; }
dialog.portrait .note { padding: 24px 18px 0; margin: 0; }
.scene { margin: 4px 0; align-self: center; max-width: 100%; }
.scene img { display: block; max-width: 100%; max-height: 60vh; border-radius: 12px; border: 1px solid var(--line); }
.scene figcaption { text-align: center; font: italic 13px system-ui, sans-serif; color: var(--muted); margin-top: 6px; }
@media (max-width: 560px) { .top button:not(.av) { padding: 6px 8px; } }
.recap { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 16px 12px; background: var(--panel); }
.recap h3, .epilogue h3 { font: 600 12px system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.recap .rtext { font-style: italic; }
.epilogue { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 8px; margin: 8px 0; }
.epilogue .etext { margin: 0 0 10px; }
.theend { text-align: center; font: italic 600 22px Georgia, serif; color: var(--muted); padding: 4px 0 8px; }
.msg, .narr, .scene { position: relative; }
.rep { position: absolute; top: 0; right: -30px; padding: 2px 6px; font-size: 12px; border: 0; background: none; color: var(--muted); opacity: 0; transition: opacity .15s; }
.msg:hover .rep, .narr:hover .rep, .scene:hover .rep, .rep:focus-visible { opacity: .8; }
.msg.me .rep { display: none; }
@media (hover: none) { .rep { opacity: .5; right: -24px; } }
