:root {
  --bg: #14110f;
  --panel: #1e1a17;
  --line: #322b26;
  --text: #ece4d8;
  --dim: #9a8f82;
  --accent: #d9a05b;
  --me: #3a2f24;
  --danger: #c8644f;
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 17px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.screen { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }

/* 开始页 */
.hero { padding: 8vh 0 24px; }
.hero h1 { font-size: 56px; letter-spacing: .3em; margin: 0 0 16px; font-weight: 600; }
.hero p { color: var(--dim); margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { padding: 10px 14px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--accent); }
.hint { color: var(--dim); font-size: 15px; margin: 0 0 14px; }
.fine { color: var(--dim); font-size: 13px; margin: 12px 0 0; }
.regret { position: relative; margin-bottom: 10px; }
textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; resize: none; outline: none; line-height: 1.6; }
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: #6b6258; }
.regret textarea { padding-bottom: 38px; }
.pin { position: absolute; right: 10px; bottom: 12px; font-size: 13px; color: var(--dim); }
.pin:hover:not(:disabled) { color: var(--accent); }
.pin:disabled { opacity: .5; cursor: default; }
.tag { border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; font-size: 11px; margin-left: 2px; }
.primary { display: block; width: 100%; background: var(--accent); color: #1a1208; border-radius: 10px; padding: 14px; font-weight: 600; margin-top: 14px; }
.primary:disabled { opacity: .45; cursor: default; }
.ghost { display: block; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px; color: var(--dim); }
.or { text-align: center; color: var(--dim); font-size: 13px; margin: 16px 0 10px; }

/* 过场 */
#crash { display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
#crash p { color: var(--dim); }
.truck { font-size: 72px; animation: drive 1.6s cubic-bezier(.5, 0, .9, .4) infinite; }
@keyframes drive { from { transform: translateX(-70vw) scaleX(-1); } to { transform: translateX(70vw) scaleX(-1); } }
@media (prefers-reduced-motion: reduce) { .truck { animation: none; } }

/* 对话页 */
#play { display: flex; flex-direction: column; padding: 0; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.icon { font-size: 28px; line-height: 1; padding: 0 8px; color: var(--dim); }
.where { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.where strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.where span { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--accent); white-space: nowrap; }
.demo { background: #3a2a14; color: #e6c48f; font-size: 13px; padding: 6px 14px; text-align: center; }
.feed { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 84%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise .25s ease-out; }
.msg.character { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.player { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.typing { color: var(--dim); letter-spacing: .3em; }
.note { align-self: center; color: var(--dim); font-size: 14px; text-align: center; padding: 6px 0; animation: rise .25s ease-out; }
.note.premise { font-size: 15px; max-width: 30em; padding-bottom: 12px; }
.note.chapter { color: var(--accent); letter-spacing: .15em; padding: 14px 0 6px; }
.note.wait::before, .note.wait::after { content: " · · · "; opacity: .5; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg, .note { animation: none; } }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px; scrollbar-width: none; }
.quick button { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--dim); white-space: nowrap; }
.quick button:hover { color: var(--text); border-color: var(--accent); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; max-height: 8em; }
.composer button { background: var(--accent); color: #1a1208; border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.composer button:disabled { opacity: .4; cursor: default; }

/* 弹层 */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-body { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 8px; font-size: 22px; }
.sheet h3 { margin: 18px 0 4px; font-size: 14px; color: var(--accent); font-weight: 600; letter-spacing: .1em; }
.sheet ul { margin: 0; padding-left: 1.2em; }
.sheet li { margin: 6px 0; }
#fragments { list-style: none; padding: 0; }
#fragments li { border-left: 2px solid var(--line); padding-left: 12px; margin: 12px 0; }
#fragments li.new { border-color: var(--accent); }
.kicker { color: var(--accent); font-size: 13px; letter-spacing: .3em; margin: 0 0 6px; }
.verdict { color: var(--dim); margin: 0 0 14px; }
blockquote { margin: 20px 0 6px; padding: 12px 14px; border-left: 2px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 20; max-width: 90vw; }
#gate { z-index: 30; }
#gate input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; outline: none; }
#gate input:focus { border-color: var(--accent); }
