/* Plum Beta 共用樣式。顏色與元件照 design/README.md 的「共用的視覺語言」。 */

:root {
  --bg: #17111f;
  --text: #f4eefc;
  --text-2: #cdbfe0;
  --muted: #9d90b3;
  --faint: #7d6f91;
  --pink: #ffc2d4;
  --yellow: #fff0c4;
  --green: #cdf7e2;
  --red: #ff8fa3;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.14);
  --selected: rgba(255, 159, 192, 0.3);
  --toggle-on: linear-gradient(90deg, #ffb3c8, #e2cfff);
  --rainbow: linear-gradient(115deg, #ffd3e6 0%, #e2cfff 28%, #c6e4ff 52%, #cdf7e2 74%, #fff0c4 100%);
  /* 日夜共用的色票（11/23 日夜開關）。下面是夜晚；白天在 :root[data-theme="day"] */
  --surface: #221930;
  --bg-rgb: 23, 17, 31;
  --line-rgb: 255, 255, 255;
  --ink-rgb: 244, 238, 252;
  --glass-rgb: 34, 25, 48;
  --accent: #ffb3c8;
  --accent-2: #c9a8ff;
  --accent2-rgb: 201, 168, 255;
  --tabbar-bg: rgba(30, 22, 42, 0.94);
  --tabbar-solid: #1e162a;
  --on-rainbow: #2a2140;
  --serif: 'Noto Serif TC', serif;
  --sans: 'Noto Sans TC', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

a { color: #e9dcff; }
a:hover { color: #ffffff; }

.page { max-width: 480px; margin: 0 auto; min-height: 100vh; }

/* 頂欄 */
.topbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
}
.topbar .back { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.topbar .title { font-size: 16px; font-weight: 700; }
.topbar .status { font-size: 11px; color: var(--muted); }

.content { padding: 16px 16px 48px; display: flex; flex-direction: column; gap: 22px; }

/* 區塊 */
.section-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 6px; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 700; }
.card {
  padding: 14px;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  display: flex; flex-direction: column; gap: 16px;
}

/* 欄位 */
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > b, .f > label > b { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.f small, .hint { font-size: 11px; color: var(--muted); line-height: 1.6; }
.f em { align-self: flex-end; font-style: normal; font-size: 10px; color: var(--faint); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: #2a2140; color: var(--text); }
textarea { border-radius: 14px; resize: vertical; line-height: 1.7; font-family: var(--serif); min-height: 160px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(255, 194, 212, 0.6); }
::placeholder { color: #6f6383; }
input.num { width: 96px; text-align: center; padding: 8px 10px; }

/* 分段切換 */
.seg { display: flex; padding: 3px; border-radius: 999px; background: rgba(var(--line-rgb), 0.07); border: 1px solid var(--card-border); }
.seg button { flex: 1; padding: 7px 4px; border-radius: 999px; border: none; background: none; color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--selected); }

/* 一般按鈕 */
.btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(var(--glass-rgb), 0.72);
  color: var(--text);
  font-family: inherit; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}
a.btn { display: inline-block; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: rgba(255, 143, 163, 0.4); }
.btn.primary { border: 1.5px solid rgba(255, 255, 255, 0.85); background: var(--rainbow); color: var(--text); font-weight: 700; }

.row { display: flex; align-items: center; gap: 8px; }
.row > .grow { flex: 1; min-width: 0; }

/* 提醒框 */
.notice { display: flex; gap: 8px; padding: 9px 12px; border-radius: 12px; font-size: 12px; line-height: 1.6; }
.notice.warn { background: rgba(255, 240, 196, 0.07); border: 1px solid rgba(255, 240, 196, 0.25); color: var(--yellow); }
.notice.ok { background: rgba(205, 247, 226, 0.07); border: 1px solid rgba(205, 247, 226, 0.3); color: var(--green); }
.notice.err { background: rgba(255, 143, 163, 0.08); border: 1px solid rgba(255, 143, 163, 0.35); color: var(--red); }
.notice.info { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-2); }
.notice > .grow { flex: 1; min-width: 0; }
.notice > .btn { flex: none; align-self: center; }

/* 開關 */
.toggle { width: 40px; height: 24px; flex: none; border-radius: 999px; border: none; padding: 2px; background: rgba(255, 255, 255, 0.15); display: flex; justify-content: flex-start; cursor: pointer; }
.toggle::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); }
.toggle[aria-checked=true] { background: var(--toggle-on); justify-content: flex-end; }
.toggle:disabled { opacity: 0.6; cursor: not-allowed; }

/* 滑桿參數 */
.param { display: flex; flex-direction: column; gap: 4px; }
.param .row b { font-size: 14px; }
.param .value { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.param input[type=range] { width: 100%; accent-color: #ffb3c8; }
.param.locked { opacity: 0.45; }
.param .lock-note { font-size: 11px; color: var(--yellow); }

/* 進階設定（收起） */
details.card { gap: 0; }
details.card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▸"; margin-left: auto; color: var(--text-2); }
details.card[open] > summary::after { content: "▾"; }
details.card[open] > .details-body { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }

.footnote { font-size: 11px; color: var(--faint); line-height: 1.6; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 聊天室 ---------- */

.icon-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: none; color: var(--text); font-size: 18px; cursor: pointer; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 38px; z-index: 5; min-width: 132px;
  display: flex; flex-direction: column; padding: 6px;
  border-radius: 12px; background: rgba(30, 22, 42, 0.97); border: 1px solid var(--card-border);
}
.menu a, .menu button, .msg-menu button {
  padding: 8px 12px; border: none; border-radius: 8px; background: none; text-align: left;
  color: var(--text); font-family: inherit; font-size: 13px; text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu button:hover, .msg-menu button:hover { background: rgba(255, 255, 255, 0.08); }
.danger-text { color: var(--red) !important; }

/* 選角色 */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-item {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-radius: 16px; background: var(--card-bg); border: 1px solid var(--card-border);
  color: var(--text); text-decoration: none;
}
.card-item:hover { border-color: rgba(255, 194, 212, 0.45); color: var(--text); }
.card-name { flex: 1; font-family: var(--serif); font-size: 16px; font-weight: 700; }
.card-meta { font-size: 11px; color: var(--muted); }
.card-item::after { content: "›"; color: var(--text-2); font-size: 18px; }

/* 聊天室版面：頂欄、全文往上捲、輸入區固定在底部 */
.chat-page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.chat-page .topbar { gap: 6px; }
.chat-page .topbar .title { font-family: var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-page .topbar .status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.story {
  flex: 1; padding: 18px 20px 24px;
  display: flex; flex-direction: column; gap: 18px;
  font-family: var(--serif); font-size: 15.5px; line-height: 1.9;
}
.story p { margin: 0 0 0.6em; overflow-wrap: anywhere; }
.story p:last-child { margin-bottom: 0; }
.dialogue { color: var(--pink); }
.action { font-style: italic; color: var(--text-2); }
.story strong { font-weight: 700; color: var(--text); }
.story .quote { margin: 0; padding: 2px 0 2px 12px; border-left: 3px solid rgba(226, 207, 255, 0.4); color: var(--text-2); }
.story .quote p { margin: 0 0 0.3em; }
.opening-picker { margin: auto 0; display: flex; flex-direction: column; gap: 10px; text-align: center; font-family: var(--sans); }
.opening-choice { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--card-border); background: var(--card-bg); color: var(--text); font-family: inherit; text-align: left; cursor: pointer; }
.opening-choice:hover { border-color: rgba(255, 194, 212, 0.45); }
.opening-choice b { font-family: var(--serif); font-size: 15px; }
.opening-preview { font-size: 12px; color: var(--muted); line-height: 1.6; }
.scene-break { width: 40%; margin: 4px auto; border: none; border-top: 1px solid rgba(226, 207, 255, 0.3); }

.msg { position: relative; }
.msg.assistant .msg-body { padding-right: 22px; }
.msg.user { align-self: flex-end; max-width: 86%; }
.msg.user .msg-body {
  padding: 8px 14px 8px 14px; margin-right: 22px;
  border-radius: 14px 14px 4px 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border);
  color: var(--text-2); font-size: 14.5px; line-height: 1.8;
}
.msg.user .dialogue { color: #f0b9c9; }
.msg.pending { opacity: 0.6; }
.msg-note { margin-top: 4px; font-family: var(--sans); font-size: 11px; color: var(--yellow); }

.more-btn {
  position: absolute; right: -4px; top: 2px; width: 26px; height: 26px;
  border: none; border-radius: 50%; background: none;
  color: var(--faint); font-size: 16px; line-height: 1; cursor: pointer;
}
.more-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.msg-menu {
  position: absolute; right: 0; top: 30px; z-index: 3; min-width: 112px;
  display: flex; flex-direction: column; padding: 6px;
  border-radius: 12px; background: rgba(30, 22, 42, 0.97); border: 1px solid var(--card-border);
  font-family: var(--sans);
}
.msg .edit-box { min-height: 120px; font-size: 14.5px; }
.msg-actions { justify-content: flex-end; margin-top: 6px; font-family: var(--sans); }

.blocked { font-family: var(--sans); }

.empty { margin: auto 0; text-align: center; display: flex; flex-direction: column; gap: 6px; padding: 40px 12px; }
.empty-title { font-size: 16px; color: var(--text-2); }
.empty .hint { font-family: var(--sans); }

.waiting { display: flex; align-items: center; gap: 5px; font-family: var(--sans); }
.waiting span { width: 6px; height: 6px; border-radius: 50%; background: var(--pink); animation: plum-blink 1.2s infinite ease-in-out; }
.waiting span:nth-child(2) { animation-delay: 0.2s; }
.waiting span:nth-child(3) { animation-delay: 0.4s; }
.waiting em { margin-left: 6px; font-style: normal; font-size: 12px; color: var(--muted); }
@keyframes plum-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer {
  position: sticky; bottom: 0; z-index: 2;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--card-border);
  display: flex; flex-direction: column; gap: 6px;
}
.composer-notes { display: flex; flex-direction: column; gap: 4px; }
.composer-notes:empty { display: none; }
.tiny { font-size: 11px; color: var(--muted); padding: 0 4px; }
.composer-row { align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 40vh; padding: 10px 14px; font-size: 15px; resize: none; field-sizing: content; }

/* 記憶筆記面板 */
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(10, 6, 16, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 480px; max-height: 85vh;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: #21182d; border: 1px solid var(--card-border);
  display: flex; flex-direction: column; gap: 10px;
}
.sheet textarea { min-height: 220px; }

/* ---------- 開發者頁 ---------- */

.dev-page { max-width: 960px; }
.dev-tabs { position: sticky; top: 62px; z-index: 1; background: var(--bg); }
.dev-tabs button { white-space: nowrap; }
.dev-foot { text-align: left; margin-top: 12px; }
.dev-foot code, .hint code { font-size: 0.95em; color: var(--text-2); }

.dev-editor { display: flex; gap: 14px; align-items: flex-start; }
.dev-editor > .grow { flex: 1; min-width: 0; }
.dev-text { min-height: 55vh; font-family: var(--sans); font-size: 13.5px; line-height: 1.75; }
#p-count.over { color: var(--red); }
.dev-vars { width: 230px; flex: none; }
.var-list { display: flex; flex-direction: column; gap: 6px; }
.var-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px;
  border-radius: 10px; border: 1px solid var(--card-border); background: var(--input-bg);
  color: var(--text); font-family: inherit; font-size: 11px; text-align: left; cursor: pointer;
}
.var-chip:hover { border-color: rgba(255, 194, 212, 0.45); }
.var-chip code { font-size: 12.5px; color: var(--pink); }
.var-chip span { color: var(--muted); line-height: 1.5; }

.dev-pre {
  margin: 0; padding: 12px 14px; max-height: 60vh; overflow: auto;
  border-radius: 12px; background: rgba(var(--line-rgb), 0.07); border: 1px solid var(--card-border);
  font-family: var(--sans); font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* 版本 */
.version-list { display: flex; flex-direction: column; gap: 6px; }
.version-row { display: flex; align-items: center; gap: 10px; }
.version-row input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: #ffb3c8; }
.version-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; padding: 9px 12px;
  border-radius: 12px; border: 1px solid var(--card-border); background: var(--card-bg);
  color: var(--text); font-family: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.version-open:hover { border-color: rgba(255, 194, 212, 0.45); }
.version-time { flex: none; font-variant-numeric: tabular-nums; color: var(--text-2); }
.version-note { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.version-chars { flex: none; font-size: 11px; color: var(--muted); }

.diff-legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; }
.diff-legend span { padding: 2px 8px; border-radius: 6px; }
.diff-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1px;
  max-height: 70vh; overflow: auto; border-radius: 10px; border: 1px solid var(--card-border);
  font-size: 12.5px; line-height: 1.7;
}
.diff-head { position: sticky; top: 0; padding: 4px 10px; background: #2a2140; font-weight: 700; font-size: 12px; }
.diff-cell { padding: 1px 10px; white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(255, 255, 255, 0.02); }
.diff-del { background: rgba(255, 110, 135, 0.22); color: #ffd6de; }
.diff-add { background: rgba(110, 230, 170, 0.18); color: #d9fbe9; }
.diff-empty { background: rgba(var(--line-rgb), 0.06); }
.diff-same-note { grid-column: 1 / -1; padding: 8px 10px; }

/* 預覽 */
.source-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 8px; }
.src-tag { flex: none; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.src-platform { background: rgba(226, 207, 255, 0.18); color: #e2cfff; }
.src-author { background: rgba(255, 194, 212, 0.18); color: var(--pink); }
.src-player { background: rgba(205, 247, 226, 0.15); color: var(--green); }
.segment-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.segment { border-radius: 12px; background: var(--card-bg); border: 1px solid var(--card-border); }
.segment > summary {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px;
}
.segment > summary::-webkit-details-marker { display: none; }
.segment > summary::after { content: "▸"; color: var(--text-2); }
.segment[open] > summary::after { content: "▾"; }
.segment-label { flex: 1; min-width: 0; font-weight: 500; }
.segment-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.segment > .dev-pre { margin: 0 10px 10px; }
#pv-total { gap: 6px; }
.total-row { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.total-row:first-child { margin-top: 0; }
.total-label { flex: none; width: 96px; color: var(--text-2); font-size: 13px; }
.total-value { flex: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-note { padding-left: 106px; }

/* 平台設定 */
.price-table { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px 12px; align-items: center; }
.price-table input.num { width: 100%; }
.price-head { font-size: 11px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .dev-editor { flex-direction: column; align-items: stretch; }
  .dev-vars { width: auto; }
  .var-list { flex-direction: row; flex-wrap: wrap; }
  .dev-tabs button { font-size: 12px; }
  .total-row { flex-direction: column; gap: 0; }
  .total-label { width: auto; }
  .total-note { padding-left: 0; }
}

/* ---------- 作者後台 ---------- */

.warn-text { color: var(--yellow); }
.author-body input[type=text], .author-body input[type=number], .author-body textarea, .author-body select { font-size: 16px; } /* iPhone 小於 16px 會自動放大 */
.author-body textarea { min-height: 0; resize: none; overflow: hidden; }
.author-body .card-meta { text-align: right; line-height: 1.6; }

.author-page { max-width: 1120px; margin: 0 auto; min-height: 100vh; }
.ed-head { position: sticky; top: 0; z-index: 4; background: var(--bg); border-bottom: 1px solid var(--card-border); }
.ed-head .topbar { position: static; border-bottom: none; padding-bottom: 6px; }
.ed-kind { font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.ed-name { font-family: var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-where { display: none; font-size: 12px; color: var(--text-2); max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-toggle { display: none; }

.actionbar { padding: 4px 16px 10px; display: flex; align-items: center; gap: 16px; }
.actionbar .total { flex: 1; min-width: 0; }
.total-line { display: flex; font-size: 12px; color: var(--text-2); }
.total-line .grow { flex: 1; }
#total-text { font-variant-numeric: tabular-nums; }
#total-text.near, em.near { color: var(--yellow) !important; }
#total-text.over, em.over { color: var(--red) !important; font-weight: 700; }
#total-text span.near { color: var(--yellow); }
#total-text span.over { color: var(--red); font-weight: 700; }
.total-bar { margin-top: 5px; height: 6px; border-radius: 3px; background: rgba(var(--line-rgb), 0.1); overflow: hidden; display: flex; }
.action-row { flex: none; }
.save-state { font-size: 11px; color: var(--muted); max-width: 320px; }
.save-state.ok { color: var(--green); }
.save-state.dirty { color: var(--yellow); }
.save-state.err { color: var(--red); }
#publish-btn.missing { background: rgba(255, 240, 196, 0.12); color: var(--yellow); border: 1px solid rgba(255, 240, 196, 0.45); }

.ed-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; padding: 16px; align-items: start; }
.tree { position: sticky; top: 130px; max-height: calc(100vh - 146px); overflow: auto; padding: 8px; border-radius: 16px; background: var(--card-bg); border: 1px solid var(--card-border); display: flex; flex-direction: column; gap: 10px; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-folder, .tree-file {
  width: 100%; display: flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px calc(8px + var(--depth, 0) * 16px);
  border: none; border-radius: 8px; background: none; color: var(--text);
  font-family: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.tree-folder { font-weight: 700; color: var(--text-2); }
.tree-folder:hover, .tree-file:hover { background: rgba(255, 255, 255, 0.06); }
.tree-file[aria-current=page] { background: var(--selected); color: var(--text); }
.tree-file { padding-left: calc(26px + var(--depth, 0) * 16px - 16px); }
.caret { width: 12px; flex: none; font-size: 11px; color: var(--muted); }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-sub { margin-left: auto; font-size: 10px; font-weight: 400; color: var(--faint); }
.dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--yellow); }
.tree-foot { margin-top: auto; padding: 10px 8px 4px; border-top: 1px solid var(--card-border); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.pane { min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-bottom: 60px; }
.page-head h1 { margin: 0; font-family: var(--serif); font-size: 20px; }
.page-head .hint { margin-top: 4px; }
.tag { padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 400; }
.tag.req { background: rgba(255, 179, 200, 0.18); color: var(--pink); }
.tag.opt { color: var(--muted); }
.f.flash, .card.flash { animation: plum-flash 1.6s ease-out; border-radius: 12px; }
@keyframes plum-flash { 0%, 30% { box-shadow: 0 0 0 3px rgba(255, 240, 196, 0.7); } 100% { box-shadow: 0 0 0 3px rgba(255, 240, 196, 0); } }
.row.wrap { flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: #ffb3c8; }
input.num.bad { border-color: var(--red); }
input:disabled { opacity: 0.45; }
.seg button:disabled { opacity: 0.35; cursor: not-allowed; }
.insert-row { gap: 6px; }
.insert-row code { color: var(--pink); font-size: 11px; }
.add-btn { padding: 11px; border: 1.5px dashed rgba(255, 255, 255, 0.3); background: none; }
.serif { font-family: var(--serif); }
.stage-preview .row { padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.stage-name { font-family: var(--serif); font-weight: 700; }
.floor-row { display: flex; align-items: flex-start; gap: 8px; }
.floor-row textarea { flex: 1; min-width: 0; }
.floor-num { flex: none; padding-top: 11px; font-size: 12px; color: var(--muted); width: 22px; text-align: right; }
.floor-tools { flex: none; gap: 4px; padding-top: 6px; }
.publish-body { display: flex; flex-direction: column; gap: 12px; }
.publish-body .btn.primary { padding: 12px; text-align: center; }
.missing-list { display: flex; flex-direction: column; gap: 6px; }
.missing-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--card-bg); color: var(--text); font-family: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.missing-item .grow { flex: 1; }
.tree-backdrop { position: fixed; inset: 0; z-index: 8; background: rgba(10, 6, 16, 0.6); }

/* 手機：一欄、目錄改抽屜、存檔與發佈黏在底部 */
@media (max-width: 760px) {
  html { scroll-padding-bottom: 120px; }
  .tree-toggle { display: inline-block; }
  .ed-where { display: block; }
  .ed-layout { display: block; padding: 12px 12px 0; }
  .pane { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
  .tree {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 9; width: min(86vw, 320px); max-height: none;
    border-radius: 0 16px 16px 0; background: #21182d; padding-top: calc(16px + env(safe-area-inset-top));
    transform: translateX(-105%); transition: transform 0.2s ease;
  }
  body.tree-open .tree { transform: none; }
  .tree-folder, .tree-file { padding-top: 10px; padding-bottom: 10px; font-size: 15px; }
  .actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    flex-direction: column; align-items: stretch; gap: 6px;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--card-border);
  }
  .save-state { max-width: none; flex: 1; min-width: 0; }
  .floor-tools { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .tree { transition: none; } }

/* 小工具：取代 HTML 裡的 style="…"（安全標頭不准內嵌樣式） */
.u-fill { flex: 1; min-width: 0; }
.u-mt10 { margin-top: 10px; }
.u-mt14 { margin-top: 14px; }
.u-mt18 { margin-top: 18px; }
.u-small { font-size: 12px; }
.u-normal { font-weight: 400; }
#new-card { padding: 12px; }

/* 角色回覆的對白、出戲與狀態欄（11/22 接上演出指令） */
.msg-body .talk .talk-who { color: var(--muted); font-family: var(--sans); font-size: 12px; margin-right: 2px; }
.msg-body .ooc { color: var(--muted); font-family: var(--sans); font-size: 12.5px; }

/* ---------- 聊天室日間版（11/22 前端先行・第一輪：照畫布《聊天室》日間版） ---------- */
/* 只有聊天室換日間；其他頁之後輪到時再換。換的是共用顏色變數，元件不用各改一次 */

  /* 白天（原本聊天室日間版的那組） */
:root[data-theme="day"] {
  --surface: #ffffff;
  --bg-rgb: 251, 248, 255;
  --line-rgb: 90, 60, 140;
  --ink-rgb: 42, 33, 64;
  --glass-rgb: 255, 255, 255;
  --accent: #c23a6e;
  --accent-2: #7a4fc0;
  --accent2-rgb: 122, 79, 192;
  --tabbar-bg: rgba(250, 246, 240, 0.92);
  --tabbar-solid: #faf6f0;
  --bg: #fbf8ff;
  --text: #2a2140;
  --text-2: #5a4d70;
  --muted: #6e6285;
  --faint: #9a8fae;
  --pink: #5b2f9e;
  --yellow: #8a5a00;
  --green: #2f7a55;
  --red: #c2334f;
  --card-bg: rgba(90, 60, 140, 0.05);
  --card-border: rgba(90, 60, 140, 0.12);
  --input-bg: rgba(90, 60, 140, 0.07);
  --input-border: rgba(90, 60, 140, 0.16);
  --selected: rgba(232, 81, 127, 0.16);
}
:root[data-theme="day"] a { color: var(--accent-2); }
:root[data-theme="day"] a:hover { color: var(--text); }
:root[data-theme="day"] ::placeholder { color: var(--faint); }
:root[data-theme="day"] input:focus, :root[data-theme="day"] textarea:focus { border-color: rgba(232, 81, 127, 0.5); }
:root[data-theme="day"] .btn { background: var(--surface); border-color: rgba(var(--line-rgb), 0.25); }
:root[data-theme="day"] .btn.primary { border-color: rgba(255, 255, 255, 0.85); background: var(--rainbow); }
:root[data-theme="day"] .msg-menu {
  background: var(--surface); border-color: rgba(var(--line-rgb), 0.14);
  box-shadow: 0 10px 24px rgba(var(--line-rgb), 0.18);
}
:root[data-theme="day"] .msg-menu button:hover { background: rgba(var(--line-rgb), 0.08); }
:root[data-theme="day"] .more-btn:hover { background: rgba(var(--line-rgb), 0.08); }
:root[data-theme="day"] .sheet-backdrop { background: rgba(var(--ink-rgb), 0.35); }
:root[data-theme="day"] .sheet { background: var(--surface); border-color: rgba(var(--line-rgb), 0.14); }
:root[data-theme="day"] .notice.warn { background: rgba(255, 196, 80, 0.14); border-color: rgba(160, 110, 0, 0.28); }
:root[data-theme="day"] .notice.err { background: rgba(232, 81, 127, 0.08); border-color: rgba(194, 51, 79, 0.3); }
:root[data-theme="day"] .notice.ok { background: rgba(47, 122, 85, 0.08); border-color: rgba(47, 122, 85, 0.3); }

/* 頂欄：返回、頭像、名字、呈現 ▾、設定 */
.room-top { gap: 10px; padding: 10px 12px; background: rgba(var(--bg-rgb), 0.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.room-top .back { color: var(--text); flex: none; }
.room-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%; padding: 2px;
  background: conic-gradient(#ffd3e6, #e2cfff, #c6e4ff, #cdf7e2, #fff0c4, #ffd3e6);
  box-shadow: 0 0 10px rgba(214, 190, 255, 0.45);
}
.room-avatar span {
  width: 100%; height: 100%; border-radius: 50%; background: #efe6ff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 15px; font-weight: 700; color: #5b2f9e;
}
.room-top .title { font-size: 15px; }
.view-pill {
  flex: none; padding: 6px 10px; border-radius: 999px; border: none;
  background: linear-gradient(115deg, #ffd3e6, #e2cfff 40%, #c6e4ff);
  color: var(--text); font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.room-top .icon-btn { width: 40px; height: 40px; flex: none; color: var(--text); display: flex; align-items: center; justify-content: center; }

/* 彈出的小面板（呈現、閱讀） */
.chat-page { position: relative; }
.popover {
  position: fixed; top: 60px; right: max(12px, calc(50vw - 228px)); z-index: 6;
  width: 252px; padding: 8px; border-radius: 16px; background: var(--surface);
  border: 1px solid rgba(var(--line-rgb), 0.14); box-shadow: 0 12px 30px rgba(var(--line-rgb), 0.22);
  display: flex; flex-direction: column; gap: 2px; font-family: var(--sans); color: var(--text);
}
.pop-label { padding: 6px 12px 8px; font-size: 11px; letter-spacing: 2px; color: var(--text-2); }
.pop-note { padding: 6px 12px 2px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.view-menu button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: none;
  background: none; color: var(--text); font-family: inherit; text-align: left; cursor: pointer;
}
.view-menu b { display: block; font-size: 13px; }
.view-menu small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.view-menu i { font-style: normal; color: var(--accent); font-size: 13px; visibility: hidden; }
.view-menu button[aria-checked=true] { background: rgba(232, 81, 127, 0.12); }
.view-menu button[aria-checked=true] i { visibility: visible; }

.reading-pop { padding: 14px; gap: 8px; }
.reading-pop .pop-label { padding: 0; }
.reading-pop > b, .width-field > b { font-size: 13px; }
.width-field { display: flex; flex-direction: column; gap: 8px; }
.reading-pop .pop-note { padding: 0; }
.size-group { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(var(--line-rgb), 0.06); }
.size-group button {
  flex: 1; height: 44px; border-radius: 9px; border: none; background: none; color: var(--text-2);
  font-family: var(--serif); font-weight: 700; cursor: pointer;
}
.size-group [data-size=s] { font-size: 13px; }
.size-group [data-size=m] { font-size: 15px; }
.size-group [data-size=l] { font-size: 17px; }
.size-group [data-width] { font-size: 14px; }
.size-group button[aria-pressed=true] { background: rgba(232, 81, 127, 0.22); color: var(--accent); }
.pop-links { display: flex; flex-direction: column; margin-top: 4px; padding-top: 6px; border-top: 1px solid rgba(var(--line-rgb), 0.1); }
.pop-links button, .pop-links a {
  padding: 9px 4px; border: none; background: none; text-align: left; color: var(--text) !important;
  font-family: inherit; font-size: 13px; text-decoration: none; cursor: pointer;
}
.pop-links .danger-text { color: var(--red) !important; }

/* 互動式小說：全文往上捲 */
body.room-day .story { font-size: var(--story-size, 17px); padding: 20px 20px 28px; gap: 16px; }
body.room-day .msg.user { max-width: 80%; }
body.room-day .msg.user .msg-body {
  padding: 0; margin-right: 24px; border: none; border-radius: 0; background: none;
  font-family: var(--sans); font-size: calc(var(--story-size, 17px) - 1px); color: var(--text-2); text-align: right;
}
body.room-day .msg.user .dialogue { color: var(--text-2); }
body.room-day .story .quote { border-left-color: rgba(var(--accent2-rgb), 0.35); }
body.room-day .scene-break { border-top-color: rgba(var(--accent2-rgb), 0.35); }
.msg.flash { animation: plum-flash 1.6s ease; border-radius: 12px; }
@keyframes plum-flash { 0%, 40% { background: rgba(232, 81, 127, 0.12); } 100% { background: transparent; } }

/* 角色回覆的對白、出戲（11/22 接上演出指令） */
.msg-body .talk .talk-who { color: var(--muted); font-family: var(--sans); font-size: 12px; margin-right: 2px; }
.msg-body .ooc { color: var(--muted); font-family: var(--sans); font-size: 12.5px; }

/* 沉浸式體驗：一段一段點著讀 */
.vn {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px var(--stage-side, 16px) 14px;
  background:
    radial-gradient(120% 70% at 50% 15%, rgba(226, 207, 255, 0.55), transparent 70%),
    radial-gradient(90% 60% at 80% 90%, rgba(255, 211, 230, 0.5), transparent 70%),
    var(--bg);
}
.vn-box {
  position: relative; padding: 26px 16px 10px; border-radius: 16px;
  background: rgba(var(--glass-rgb), 0.9); border: 1px solid rgba(var(--line-rgb), 0.12);
  box-shadow: 0 8px 24px rgba(var(--line-rgb), 0.12);
}
.vn-name {
  position: absolute; left: 14px; top: -14px; padding: 4px 14px; border-radius: 999px;
  background: linear-gradient(115deg, #ffd3e6, #e2cfff 40%, #c6e4ff);
  font-family: var(--serif); font-size: 14px; font-weight: 700; letter-spacing: 2px; color: var(--text);
}
.vn-text {
  display: flex; align-items: flex-start; width: 100%; min-height: 7.6em; padding: 0; border: none; background: none; text-align: left;
  font-family: var(--serif); font-size: var(--story-size, 17px); line-height: 1.85; color: var(--text);
  cursor: pointer; overflow-wrap: anywhere; white-space: pre-wrap;
}
.vn-text.quote { color: #5b2f9e; }
.vn-text.ooc { color: var(--muted); font-family: var(--sans); font-size: 14px; }
.vn-text.hint { color: var(--muted); font-size: 15px; cursor: default; }
.vn-ctrl { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-family: var(--sans); }
.vn-prev {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(var(--line-rgb), 0.08);
  color: var(--text-2); font-size: 18px; line-height: 1; cursor: pointer;
}
.vn-prev:disabled { opacity: 0.35; cursor: default; }
.vn-auto {
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.2); background: none;
  color: var(--text-2); font-family: inherit; font-size: 11px; cursor: pointer;
}
.vn-auto[aria-pressed=true] { border-color: var(--accent); background: rgba(232, 81, 127, 0.14); color: var(--accent); }
.vn-page { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }

/* 輸入區：狀態欄浮在上面，下面是圓角輸入框＋彩虹送出鍵 */
body.room-day .composer {
  border-top: none; padding: 6px 10px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(var(--bg-rgb), 0), var(--bg) 18px);
}
.composer-box {
  display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 8px 10px; border-radius: 20px;
  background: rgba(var(--glass-rgb), 0.95); border: 1px solid rgba(var(--line-rgb), 0.12);
}
.composer-line { display: flex; align-items: flex-end; gap: 8px; }
.quick-row { display: flex; align-items: center; gap: 6px; }
.quick {
  padding: 5px 14px; border-radius: 999px; border: none; font-family: var(--sans); font-size: 12px; cursor: pointer;
}
.quick.say { background: rgba(232, 81, 127, 0.18); color: var(--accent); font-weight: 700; }
.quick.act { background: rgba(var(--line-rgb), 0.08); color: var(--text-2); font-style: italic; }

/* 最後一則下面的重刷選單：重刷、校正、歸位 */
.reply-tools { margin-top: 6px; font-family: var(--sans); }
.reply-tools-row { display: flex; align-items: center; }
.reroll-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: none; padding: 0;
  color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer;
}
.reroll-btn:hover, .reroll-btn.on { background: rgba(var(--line-rgb), 0.1); color: var(--text); }
.reroll-chips { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.reroll-chips button {
  padding: 6px 14px; border-radius: 999px; border: none; background: rgba(var(--line-rgb), 0.1);
  color: var(--text); font-family: inherit; font-size: 12px; cursor: pointer;
}
.reroll-chips button:hover { background: rgba(232, 81, 127, 0.16); color: var(--accent); }
.reroll-hint { margin-top: 6px; text-align: right; font-size: 11px; color: var(--muted); line-height: 1.5; }
.reply-tools.in-vn { margin-top: 2px; }
.reply-tools.in-vn .reroll-hint { text-align: left; }

body.room-day .composer textarea {
  flex: 1; min-width: 0; min-height: 40px; max-height: 40vh; padding: 9px 12px;
  border: none; border-radius: 12px; background: rgba(var(--line-rgb), 0.07);
  font-family: var(--sans); font-size: 15px; line-height: 1.5; resize: none; field-sizing: content;
}
.composer .send {
  width: 40px; height: 40px; flex: none; border-radius: 50%; padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(135deg, #ffd3e6, #e2cfff 35%, #c6e4ff 60%, #cdf7e2 80%, #fff0c4);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.composer .send:disabled { cursor: default; }
.composer .send.busy svg { animation: plum-blink 1.2s infinite ease-in-out; }

/* 狀態欄（照畫布）：回數膠囊、一行摘要、展開面板 */
.status-bar {
  border-radius: 14px; background: rgba(var(--glass-rgb), 0.94); border: 1px solid rgba(var(--line-rgb), 0.14);
  overflow: hidden; font-family: var(--sans);
}
.status-bar.past { border-color: rgba(232, 81, 127, 0.45); }
.status-detail {
  max-height: 150px; overflow-y: auto; padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(var(--line-rgb), 0.1);
  display: flex; flex-direction: column; gap: 5px; font-size: 12px; line-height: 1.5; color: var(--text-2);
}
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 8px; }
.status-cell.wide { grid-column: 1 / -1; }
.status-cell b, .status-item b { font-weight: 500; color: var(--muted); margin-right: 1em; }
.status-item.aside span { color: var(--accent); }
.status-main { display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 6px; font-size: 12px; }
.status-wheel { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 2px; touch-action: none; }
.wheel-chip {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 26px; padding: 0 10px;
  border-radius: 999px; border: 1.5px solid rgba(var(--line-rgb), 0.2); background: rgba(var(--line-rgb), 0.06);
  color: var(--accent-2); font-family: inherit; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.wheel-chip.on { border-color: var(--accent); background: rgba(232, 81, 127, 0.14); color: var(--accent); }
.wheel-arrow { font-size: 10px; }
.wheel-near {
  height: 22px; padding: 0 10px; border: none; background: none; color: var(--muted);
  font-family: inherit; font-size: 11px; white-space: nowrap; opacity: 0.6; transform: scale(0.92); cursor: pointer;
}
.wheel-near:disabled { visibility: hidden; }
.status-line { flex: 1; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-toggle {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: none; background: none; padding: 0;
  color: var(--text-2); font-family: inherit; font-size: 13px; cursor: pointer;
}
.status-toggle.on { background: rgba(var(--line-rgb), 0.1); }

@media (prefers-reduced-motion: reduce) { .msg.flash { animation: none; } .composer .send.busy svg { animation: none; } }

/* iPhone 的瀏覽器：輸入框字小於 16px 時，一點下去整頁會自動放大、版面跑掉（11/22 小梅手機回報）。
   兩層擋：每頁 viewport 加 maximum-scale=1（iPhone 照樣能兩指放大，只是不會自己放大），
   加上手指操作的裝置把輸入框字放到 16px；電腦版排版不變 */
@media (pointer: coarse) {
  input, select, textarea, body.room-day .composer textarea, .dev-text, .msg .edit-box { font-size: 16px; }
}

/* 咒語（11/22 前端先行第三輪）：輸入區的「✦ 咒語」鍵、選好的咒語條、面板 */
.quick.spell { background: rgba(var(--accent2-rgb), 0.1); color: var(--accent-2); font-weight: 700; }
.quick.spell.on { background: rgba(var(--accent2-rgb), 0.2); }
.spell-chip {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 12px;
  background: rgba(var(--accent2-rgb), 0.1); color: #5b2f9e; font-family: var(--sans); font-size: 12px; font-weight: 700;
}
.spell-chip button { width: 26px; height: 26px; border: none; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.spell-panel {
  max-height: 46vh; overflow-y: auto; padding: 12px; border-radius: 16px;
  background: rgba(var(--glass-rgb), 0.97); border: 1px solid rgba(var(--line-rgb), 0.14);
  box-shadow: 0 8px 24px rgba(var(--line-rgb), 0.14); font-family: var(--sans); color: var(--text);
  display: flex; flex-direction: column; gap: 8px;
}
.spell-head { font-size: 11px; letter-spacing: 2px; color: var(--text-2); align-items: center; }
.spell-list { display: flex; flex-direction: column; gap: 6px; }
.spell-list.fixed { flex-direction: row; }
.spell-list.fixed .spell-item { flex: 1; text-align: center; }
.spell-item {
  min-width: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(var(--line-rgb), 0.12);
  background: rgba(var(--line-rgb), 0.04); color: var(--text); font-family: inherit; text-align: left; cursor: pointer;
}
.spell-item.on { border-color: var(--accent); background: rgba(232, 81, 127, 0.1); }
.spell-item b { display: block; font-size: 13px; }
.spell-item small {
  display: block; margin-top: 2px; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spell-mine { display: flex; align-items: center; gap: 4px; }
.spell-mine .spell-item { flex: 1; }
.spell-edit-btn { width: 36px; height: 36px; flex: none; border: none; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.spell-add { border: none; background: none; color: var(--accent); font-family: inherit; font-size: 12px; letter-spacing: 0; cursor: pointer; }
.spell-empty, .spell-note { font-size: 11px; color: var(--muted); line-height: 1.6; }
.spell-editor { display: flex; flex-direction: column; gap: 8px; }
.spell-editor input, .spell-editor textarea { width: 100%; font-size: 14px; }
.spell-count { text-align: right; font-size: 11px; color: var(--muted); }
.spell-editor-actions { gap: 6px; }
.msg-spell {
  display: inline-block; margin-bottom: 4px; padding: 2px 10px; border-radius: 999px;
  background: rgba(var(--accent2-rgb), 0.1); color: var(--accent-2); font-family: var(--sans); font-size: 12px; font-weight: 700;
}

/* 對話列表與垃圾桶（11/22 前端先行②） */
.section-head .btn.small { margin-left: auto; }
.room-row { display: flex; align-items: stretch; gap: 6px; }
.room-row .room-item { flex: 1; min-width: 0; }
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.room-preview { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-trash {
  flex: none; width: 44px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--card-bg);
  color: var(--muted); font-size: 15px; cursor: pointer;
}
.trash-item { display: flex; flex-direction: column; gap: 8px; }
.trash-item .room-preview { white-space: normal; }
.room-tag {
  margin-left: 6px; padding: 1px 8px; border-radius: 999px; vertical-align: 2px;
  background: rgba(194, 155, 255, 0.18); color: #d9c4ff; font-family: var(--sans); font-size: 11px; font-weight: 500;
}
.room-trash { display: flex; align-items: center; justify-content: center; }
.room-trash.armed { width: auto; padding: 0 10px; border-color: rgba(255, 107, 138, 0.6); color: var(--red); font-size: 12px; font-family: var(--sans); white-space: nowrap; }
.trash-item .btn.armed { border-color: rgba(255, 107, 138, 0.6); color: var(--red); }

/* 角色頁（11/23，照畫布《角色頁・檔案風》日間版）：圖片鋪滿全螢幕，文字疊在下半。
   作者沒放圖時用彩虹漸層＋名字第一個字 */
.char-page { position: relative; min-height: 100dvh; overflow: hidden; background: var(--bg); color: var(--text); }
.char-hero {
  position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 22vh;
  overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(70% 60% at 30% 30%, rgba(255, 211, 230, 0.9), transparent 70%),
    radial-gradient(70% 60% at 75% 40%, rgba(198, 228, 255, 0.9), transparent 70%),
    radial-gradient(80% 70% at 50% 80%, rgba(226, 207, 255, 0.95), transparent 75%), #f3ecff;
}
.char-hero span { font-family: var(--serif); font-size: 160px; font-weight: 700; color: rgba(91, 47, 158, 0.16); }
.char-page.has-img .char-hero { background: #2a2140; padding-top: 0; }
.char-img, .char-img-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; pointer-events: none;
}
.char-img.contain { object-fit: contain; object-position: center 30% !important; height: 72%; }
.char-img.full { height: 100%; object-position: center !important; }
.char-img-bg { filter: blur(28px) saturate(1.1); transform: scale(1.15); opacity: 0.85; }
.char-fade {
  position: fixed; left: 0; right: 0; bottom: 0; height: 64vh; pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.9) 45%, var(--bg));
}
.char-page.has-img .char-fade {
  height: 58vh;
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.82) 38%, rgba(var(--bg-rgb), 0.97) 70%);
}
.char-ui { transition: opacity 0.3s ease; }
.char-page.viewing .char-ui, .char-page.viewing .char-fade { opacity: 0; pointer-events: none; }
.char-fade { transition: opacity 0.3s ease; }
.char-top { position: relative; z-index: 2; display: flex; padding: 14px 12px; }
.char-round {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(var(--line-rgb), 0.25); background: rgba(var(--glass-rgb), 0.72);
  display: flex; align-items: center; justify-content: center; color: var(--text) !important;
}
.char-arrow {
  position: fixed; z-index: 2; top: 34vh; width: 40px; height: 40px; border-radius: 50%; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.6); background: rgba(var(--ink-rgb), 0.38); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.char-arrow[hidden] { display: none; }
.char-arrow.prev { left: 10px; }
.char-arrow.next { right: 10px; }
.char-body {
  position: fixed; z-index: 2; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  width: min(480px, 100vw); box-sizing: border-box; padding: 0 20px;
  display: flex; flex-direction: column; gap: 10px; max-height: calc(100dvh - 170px); overflow: hidden;
}
.char-dots { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.char-dots[hidden] { display: none; }
.char-dot-row { display: flex; gap: 4px; }
.char-dot-row span { width: 6px; height: 5px; border-radius: 3px; background: rgba(var(--ink-rgb), 0.28); transition: width 0.2s ease; }
.char-dot-row span.on { width: 16px; background: var(--accent-2); }
.char-count { padding: 2px 8px; border-radius: 999px; background: rgba(var(--glass-rgb), 0.75); font-size: 11px; color: var(--text-2); }
.char-body h1 { margin: 0; font-family: var(--serif); font-size: 32px; letter-spacing: 3px; text-shadow: 0 0 6px rgba(255, 255, 255, 0.95); }
.char-identity { font-family: var(--serif); font-size: 14px; line-height: 1.6; color: var(--text-2); }
.char-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.char-tags[hidden] { display: none; }
.char-tag { padding: 3px 10px; border-radius: 999px; background: rgba(var(--accent2-rgb), 0.1); border: 1px solid rgba(var(--accent2-rgb), 0.14); font-size: 12px; color: var(--accent-2); }
.char-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.char-author { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.char-author-dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--input-border); display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-2);
}
.char-intro {
  padding: 0; border: none; background: none; text-align: left; cursor: pointer; color: var(--text-2);
  display: flex; flex-direction: column; gap: 2px; font-family: var(--serif);
}
.char-intro[hidden] { display: none; }
.char-intro-text {
  font-size: 14px; line-height: 1.85; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.char-more { font-family: var(--sans); font-size: 12px; color: var(--accent); }
.char-full { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.9; color: var(--text); white-space: pre-line; }
.char-full.note { font-family: var(--sans); font-size: 14px; color: var(--text-2); }
.char-full-tagline { margin: 0 0 4px; font-family: var(--serif); font-size: 14px; color: var(--muted); }
.char-full-version { font-size: 12px; color: var(--faint); }
/* 聊天室裡「作者在幾月幾號更新了角色」那一行（11/23） */
.card-update { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-family: var(--sans); font-size: 12px; color: var(--muted); text-align: center; }
.card-update::before, .card-update::after { content: ""; flex: 1; min-width: 16px; height: 1px; background: rgba(var(--line-rgb), 0.18); }
.card-update-text { max-width: 80%; }
.char-start {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom));
  width: min(342px, calc(100vw - 48px)); height: 56px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(115deg, #ffd3e6 0%, #e2cfff 28%, #c6e4ff 52%, #cdf7e2 74%, #fff0c4 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.9), 0 8px 24px rgba(190, 160, 255, 0.35);
  color: var(--text); font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 6px; cursor: pointer;
}
.char-sheet-backdrop { position: fixed; inset: 0; z-index: 5; background: rgba(var(--ink-rgb), 0.36); }
.char-sheet {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: 0; width: min(480px, 100vw);
  max-height: 86dvh; overflow-y: auto; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface); border-top: 1px solid rgba(var(--line-rgb), 0.14);
  display: flex; flex-direction: column; gap: 10px; box-sizing: border-box; font-family: var(--sans);
}
.char-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: rgba(var(--line-rgb), 0.25); align-self: center; }
.char-sheet-title { font-size: 16px; font-weight: 700; }
#char-sheet-body { display: flex; flex-direction: column; gap: 10px; }
.char-sheet-label { font-size: 12px; color: var(--muted); line-height: 1.6; }
.char-list { display: flex; flex-direction: column; gap: 8px; }
.char-group { margin-top: 2px; font-size: 12px; color: var(--text-2); }
.char-choice {
  display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 14px;
  border: 1px solid rgba(var(--line-rgb), 0.12); background: rgba(var(--line-rgb), 0.04); color: var(--text) !important;
  font-family: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.char-choice.on { border: 1.5px solid rgba(255, 159, 192, 0.8); background: rgba(232, 81, 127, 0.12); }
.char-choice.on > b { color: var(--accent); }
.char-choice b { font-size: 13px; }
.char-choice > span, .char-choice .u-fill > span { font-family: var(--serif); font-size: 12.5px; line-height: 1.6; color: var(--text-2); }
.char-choice.card-pick { flex-direction: row; align-items: center; gap: 10px; cursor: default; }
.char-choice.card-pick .u-fill { display: flex; flex-direction: column; gap: 2px; }
.char-choice.card-pick .u-fill > span { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.char-choice.off { opacity: 0.45; }
.char-pc-dot {
  width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--input-border); display: flex; align-items: center;
  justify-content: center; font-size: 13px; color: var(--text-2); font-family: var(--sans) !important;
}
.char-room-top { display: flex; gap: 8px; font-family: var(--sans) !important; font-size: 12px !important; color: var(--text-2); }
.char-room-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2) !important; font-size: 13px !important; }
.char-go {
  height: 52px; margin-top: 4px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(115deg, #ffd3e6 0%, #e2cfff 28%, #c6e4ff 52%, #cdf7e2 74%, #fff0c4 100%);
  color: var(--text); font-family: var(--serif); font-size: 16px; font-weight: 700; letter-spacing: 3px; cursor: pointer;
}
.char-go:disabled { opacity: 0.6; cursor: default; }
.char-new {
  height: 50px; border-radius: 999px; border: 1px solid rgba(255, 159, 192, 0.6); background: rgba(232, 81, 127, 0.14);
  color: var(--accent); font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.char-back { height: 36px; border: none; background: none; color: var(--muted); font-family: inherit; font-size: 13px; cursor: pointer; }
.char-page .room-tag { background: rgba(var(--accent2-rgb), 0.12); color: var(--accent-2); }

/* 底部導覽列：之後每一頁共用 */
.tabbar {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-around;
  padding: 0 10px calc(14px + env(safe-area-inset-bottom)); min-height: 88px;
  background: var(--tabbar-bg); border-radius: 50% 50% 0 0 / 34px 34px 0 0;
  box-shadow: 0 -2px 0 rgba(214, 190, 255, 0.6), 0 -10px 30px rgba(var(--line-rgb), 0.12);
}
.tabbar a {
  flex: 1; max-width: 90px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
  min-height: 48px; text-decoration: none; color: var(--text-2) !important; font-size: 11px;
}
.tabbar a[hidden] { display: none; }
.tabbar .tab-home { color: var(--text) !important; font-size: 12px; font-weight: 700; gap: 4px; }
.tab-bubble {
  width: 62px; height: 62px; margin-top: -30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ffd3e6, #e2cfff 35%, #c6e4ff 60%, #cdf7e2 80%, #fff0c4);
  border: 3px solid var(--bg); box-shadow: 0 6px 18px rgba(150, 120, 210, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

/* 我的（11/23 前端先行） */
.me-page { min-height: 100dvh; padding-bottom: 120px; background: var(--bg); color: var(--text); }
.me-head { padding: 22px 20px 6px; max-width: 480px; margin: 0 auto; }
.me-head h1 { margin: 0; font-family: var(--serif); font-size: 26px; letter-spacing: 2px; }
.me-main { max-width: 480px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 18px; }
.me-section { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.12); }
.me-section-head { display: flex; align-items: baseline; gap: 8px; }
.me-section-head h2 { margin: 0; font-size: 16px; }
.me-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.me-hint { margin: 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
.me-list { display: flex; flex-direction: column; gap: 8px; }
.me-pc {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; text-align: left; cursor: pointer;
  border: 1px solid rgba(var(--line-rgb), 0.12); background: rgba(var(--line-rgb), 0.04); color: var(--text); font-family: inherit;
}
.me-pc-dot {
  width: 40px; height: 40px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(#ffd3e6, #e2cfff, #c6e4ff, #cdf7e2, #fff0c4, #ffd3e6); font-family: var(--serif); font-weight: 700; color: #5b2f9e;
}
.me-pc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.me-pc-text b { font-size: 14px; }
.me-pc-text > span { font-size: 12px; color: var(--text-2); }
.me-pc-text small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-pc-go { color: var(--muted); font-size: 18px; }
.me-tag { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: rgba(var(--accent2-rgb), 0.12); color: var(--accent-2); font-size: 11px; font-weight: 500; }
.me-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.me-add {
  padding: 9px 14px; border-radius: 999px; border: 1px solid rgba(255, 159, 192, 0.6); background: rgba(232, 81, 127, 0.12);
  color: var(--accent); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.me-add:disabled, .me-add.off { opacity: 0.45; cursor: default; }
.me-field { display: flex; flex-direction: column; gap: 6px; }
.me-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.me-label em { font-style: normal; font-weight: 500; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: rgba(var(--line-rgb), 0.08); color: var(--text-2); }
.me-label em.seen { background: rgba(47, 122, 85, 0.1); color: #2f7a55; }
.me-field input, .me-field textarea { width: 100%; box-sizing: border-box; }
.me-seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(var(--line-rgb), 0.06); }
.me-seg button { flex: 1; height: 40px; border: none; border-radius: 9px; background: none; color: var(--text-2); font-family: inherit; font-size: 14px; cursor: pointer; }
.me-seg button[aria-checked=true] { background: rgba(232, 81, 127, 0.2); color: var(--accent); font-weight: 700; }
.me-sub { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.me-tiny { font-size: 11px; color: var(--muted); }
.me-counter { text-align: right; }
.me-editor-actions { display: flex; align-items: center; gap: 8px; }
.me-links { display: flex; flex-direction: column; }
.me-link {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 4px; border-top: 1px solid rgba(var(--line-rgb), 0.08);
  color: var(--text) !important; text-decoration: none; font-size: 14px;
}
.me-link:first-child { border-top: none; }
.me-link small { font-size: 11px; color: var(--muted); }
.me-link.off { opacity: 0.5; }
.tabbar .tab-on { color: var(--accent) !important; font-weight: 700; }
.char-choice:focus-visible, .me-pc:focus-visible, .char-go:focus-visible, .char-new:focus-visible { outline: 2px solid rgba(232, 81, 127, 0.55); outline-offset: 2px; }

/* 作者後台「簡介與 tag」「圖片」（11/23） */
.u-hidden { display: none !important; }
.tag-chosen { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.tag-chip {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--input-border); background: var(--input-bg);
  color: var(--text-2); font-family: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.tag-chip[aria-pressed=true], .tag-chip.on { background: var(--selected); border-color: rgba(255, 159, 192, 0.55); color: var(--text); }
.tag-chip:disabled { opacity: 0.4; cursor: default; }
.tag-chip .x { font-size: 14px; line-height: 1; color: var(--pink); }
.tag-group { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.tag-group-name { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-own { margin-top: 12px; gap: 8px; }
.tag-own input { flex: 1; min-width: 0; }
.img-top { align-items: center; gap: 10px; }
.img-empty { padding: 4px 2px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.img-item {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px;
  background: var(--card-bg); border: 1px solid var(--card-border);
}
.img-frame { position: relative; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #000; }
.img-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-frame.wide img:not(.bg) { object-fit: contain; object-position: center 30% !important; height: 72%; }
.img-frame img.bg { filter: blur(18px); transform: scale(1.15); opacity: 0.8; }
.img-badge, .img-warn {
  position: absolute; left: 8px; top: 8px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--rainbow); color: var(--text);
}
.img-warn { top: auto; bottom: 8px; background: rgba(23, 17, 31, 0.8); color: var(--yellow); font-weight: 500; }
.img-ctl { display: flex; flex-wrap: wrap; gap: 6px; }
.img-ctl .btn { padding-left: 10px; padding-right: 10px; }
.img-ctl .btn:last-child { margin-left: auto; }
.img-foot { align-items: flex-end; gap: 8px; }
.img-face { display: flex; flex-direction: column; gap: 4px; }
.face-grid { display: grid; grid-template-columns: repeat(3, 22px); grid-template-rows: repeat(3, 22px); gap: 3px; }
.face-grid button {
  padding: 0; border-radius: 5px; border: 1px solid var(--input-border); background: var(--input-bg); cursor: pointer;
}
.face-grid button[aria-pressed=true] { background: var(--pink); border-color: var(--pink); }
.btn.armed { border-color: rgba(255, 107, 138, 0.7); background: rgba(255, 107, 138, 0.12); }
.img-frame.cropped img { object-fit: cover; max-width: none; }

/* 裁切編輯器（11/23）：圖檔不動，只記框 */
body.crop-open { overflow: hidden; }
.crop-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 7, 16, 0.86);
  display: flex; align-items: center; justify-content: center; padding: 12px; box-sizing: border-box;
}
.crop-box {
  width: min(520px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--card-border);
}
.crop-head { display: flex; flex-direction: column; gap: 4px; }
.crop-stage {
  position: relative; display: flex; justify-content: center; overflow: hidden; border-radius: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: move; background: #000;
}
.crop-stage img { display: block; max-width: 100%; max-height: 56dvh; pointer-events: none; -webkit-user-drag: none; }
.crop-frame {
  position: absolute; box-sizing: border-box; border: 2px solid #fff; border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(10, 7, 16, 0.58); pointer-events: none;
  background:
    linear-gradient(90deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.45) 33.33%, transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.45) 66.66%, transparent calc(66.66% + 0.5px)),
    linear-gradient(180deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.45) 33.33%, transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.45) 66.66%, transparent calc(66.66% + 0.5px));
}
.crop-size { align-items: center; gap: 10px; }
.crop-size input { flex: 1; accent-color: #ffb3c8; }
.crop-actions { gap: 8px; }
.img-face { flex-direction: row; align-items: center; gap: 8px; }
.char-img.cropped { right: auto; bottom: auto; object-fit: cover; max-width: none; }
#import-result, .notice.multi { white-space: pre-line; display: block; }
.crop-text-zone {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px; box-sizing: border-box; font-size: 10px; color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.35) 40%, rgba(var(--bg-rgb), 0.5));
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* 探索（11/23，照畫布《探索》改日間配色） */
.ex-page { min-height: 100dvh; padding-bottom: 120px; background: var(--bg); color: var(--text); }
.ex-head { max-width: 560px; margin: 0 auto; padding: 22px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.ex-head h1 { margin: 0; font-family: var(--serif); font-size: 26px; letter-spacing: 2px; }
.ex-search {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 42px; border-radius: 999px;
  background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.16); color: var(--faint);
}
.ex-search input { flex: 1; min-width: 0; border: none; background: none; outline: none; color: var(--text); font-family: inherit; font-size: 14px; }
.ex-tabs { display: flex; gap: 18px; border-bottom: 1px solid rgba(var(--line-rgb), 0.12); }
.ex-tabs button {
  padding: 6px 2px 9px; border: none; background: none; font-family: inherit; font-size: 15px; color: var(--faint); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; align-items: baseline; gap: 6px;
}
.ex-tabs button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.ex-tabs button:disabled { cursor: default; }
.ex-tabs small { font-size: 10px; color: var(--faint); font-weight: 400; }
.ex-tagrow { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 2px; margin: 0 -16px; scrollbar-width: none; }
.ex-tagrow::-webkit-scrollbar { display: none; }
.ex-tagrow[hidden] { display: none; }
.ex-tag {
  flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.18); background: var(--surface);
  color: var(--text-2); font-family: inherit; font-size: 12px; cursor: pointer;
}
.ex-tag[aria-pressed=true] { background: #2a2140; border-color: var(--text); color: #fff; }
.ex-main { max-width: 560px; margin: 0 auto; padding: 8px 16px 0; display: flex; flex-direction: column; gap: 22px; }
.ex-main section[hidden] { display: none; }
.ex-sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ex-sec-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; letter-spacing: 1px; }
.ex-sec-head span { font-size: 11px; color: var(--faint); }
.ex-cover { position: relative; overflow: hidden; background: var(--card-bg); }
.ex-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.ex-cover.cropped img { right: auto; bottom: auto; max-width: none; object-position: center; }
.ex-cover.blank {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(70% 60% at 30% 30%, rgba(255, 211, 230, 0.9), transparent 70%),
    radial-gradient(70% 60% at 75% 40%, rgba(198, 228, 255, 0.9), transparent 70%),
    radial-gradient(80% 70% at 50% 80%, rgba(226, 207, 255, 0.95), transparent 75%), #f3ecff;
}
.ex-cover.blank .ex-initial { font-family: var(--serif); font-weight: 700; font-size: 64px; color: rgba(91, 47, 158, 0.18); }
.ex-hero {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -16px; padding: 0 16px;
}
.ex-hero::-webkit-scrollbar { display: none; }
.ex-slide {
  position: relative; flex: none; width: 86%; scroll-snap-align: center; border-radius: 20px; overflow: hidden;
  text-decoration: none; color: #fff !important; box-shadow: 0 10px 28px rgba(var(--line-rgb), 0.18);
}
.ex-slide:only-child { width: 100%; }
.ex-cover.hero { height: min(460px, 62vh); }
.ex-cover.hero.blank .ex-initial { font-size: 120px; }
.ex-slide-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; background: linear-gradient(180deg, rgba(23, 17, 31, 0), rgba(23, 17, 31, 0.82)); pointer-events: none; }
.ex-slide-text { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.ex-slide-text b { font-family: var(--serif); font-size: 24px; letter-spacing: 2px; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.ex-slide-line { font-family: var(--serif); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ex-slide-text small { font-size: 11px; color: rgba(255, 255, 255, 0.78); }
.ex-new { align-self: flex-start; padding: 1px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; color: var(--text); background: var(--rainbow); }
.ex-hero-dots { display: flex; justify-content: center; gap: 4px; margin-top: 10px; }
.ex-hero-dots[hidden] { display: none; }
.ex-hero-dots span { width: 6px; height: 5px; border-radius: 3px; background: rgba(var(--ink-rgb), 0.22); transition: width 0.2s ease; }
.ex-hero-dots span.on { width: 16px; background: var(--accent-2); }
.ex-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ex-card {
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--surface);
  border: 1px solid rgba(var(--line-rgb), 0.1); text-decoration: none; color: var(--text) !important;
}
.ex-cover.grid { aspect-ratio: 3 / 4; }
.ex-kind { position: absolute; left: 8px; top: 8px; padding: 1px 8px; border-radius: 999px; font-size: 10px; background: rgba(var(--glass-rgb), 0.85); color: var(--text-2); }
.ex-card-text { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px 11px; }
.ex-card-text b { font-family: var(--serif); font-size: 15px; letter-spacing: 1px; }
.ex-card-line { font-size: 12px; line-height: 1.5; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ex-card-text small { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-empty { grid-column: 1 / -1; padding: 20px 0; text-align: center; }
.ex-foot { margin: 4px 0 0; text-align: center; font-size: 11px; color: var(--faint); }
.ex-card:focus-visible, .ex-slide:focus-visible, .ex-tag:focus-visible { outline: 2px solid rgba(232, 81, 127, 0.55); outline-offset: 2px; }

/* 我的：頭像列、設定、管理員（11/23） */
.me-profile { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.me-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--rainbow); border: 2px solid #fff; box-shadow: 0 4px 14px rgba(150, 120, 210, 0.3);
  font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--text);
}
.me-profile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.me-profile-text b { font-family: var(--serif); font-size: 18px; letter-spacing: 1px; }
.me-profile-text small { font-size: 12px; color: var(--muted); }
button.me-link { width: 100%; border: none; border-top: 1px solid rgba(var(--line-rgb), 0.08); background: none; text-align: left; font-family: inherit; cursor: pointer; }
.me-links > .me-link:first-child { border-top: none; }
.me-link[hidden] { display: none; }
.me-link.preview::after { content: "預覽"; align-self: flex-start; margin-top: 2px; padding: 0 7px; border-radius: 999px; font-size: 10px; color: var(--accent-2); background: rgba(var(--accent2-rgb), 0.1); }
.me-admin { border-color: rgba(232, 81, 127, 0.25); }
.me-sub-head { margin-top: 6px; }
.me-sub-head h3 { margin: 0; font-size: 13px; color: var(--text-2); }

/* 讀取中的球（11/23 小梅的 logo；之後再幫它畫動畫，現在先慢慢呼吸） */
.plum-loading { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0; font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.plum-loading[hidden] { display: none; }
.plum-loading img { width: 56px; height: 56px; animation: plum-breathe 2.4s ease-in-out infinite; }
@keyframes plum-breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.75; }
  50% { transform: scale(1.04); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .plum-loading img { animation: none; } }
.char-loading { position: fixed; z-index: 2; left: 0; right: 0; top: 38vh; color: var(--muted); }
.char-loading img { width: 72px; height: 72px; }
.char-page.is-loading .char-body, .char-page.is-loading .char-start { visibility: hidden; }

/* 預覽頁（11/23）：之後開放的頁面，只給管理員看 */
.pv-page { min-height: 100dvh; background: var(--bg); color: var(--text); padding-bottom: 60px; }
.pv-top { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: rgba(var(--bg-rgb), 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(var(--line-rgb), 0.08); }
.pv-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pv-title b { font-family: var(--serif); font-size: 18px; letter-spacing: 1px; }
.pv-title small { font-size: 11px; color: var(--accent); }
.pv-main { max-width: 520px; margin: 0 auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.pv-note { margin: 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
.pv-sec { display: flex; flex-direction: column; gap: 10px; }
.pv-sec-head { display: flex; align-items: baseline; gap: 8px; }
.pv-sec-head h2 { margin: 0; font-family: var(--serif); font-size: 16px; }
.pv-sec-head span { font-size: 11px; color: var(--faint); }
.pv-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.12); }
.pv-btn { padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.25); background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer; }
.pv-btn.primary { background: var(--rainbow); border-color: rgba(255, 255, 255, 0.9); font-weight: 700; box-shadow: 0 4px 14px rgba(190, 160, 255, 0.3); }
.pv-btn.danger { color: #c23a4e; border-color: rgba(194, 58, 78, 0.4); align-self: flex-start; }
.pv-mini { padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.18); background: var(--surface); color: var(--text-2); font-family: inherit; font-size: 11px; cursor: pointer; }
.pv-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.pv-bar { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--faint); }
.pv-tabs { display: flex; gap: 16px; border-bottom: 1px solid rgba(var(--line-rgb), 0.12); }
.pv-tabs button { padding: 6px 2px 9px; border: none; background: none; font-family: inherit; font-size: 14px; color: var(--faint); border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 5px; align-items: baseline; }
.pv-tabs button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.pv-tabs small { font-size: 10px; color: var(--faint); font-weight: 400; }
.pv-thumb { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.pv-thumb.blank, .pv-mem-bg.blank, .pv-share-bg.blank { background: linear-gradient(135deg, #ffd3e6, #e2cfff 40%, #c6e4ff 70%, #cdf7e2); }
.pv-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--rainbow); font-family: var(--serif); font-size: 13px; font-weight: 700; }
.pv-collect-head { display: flex; align-items: center; gap: 8px; }
.pv-collect-head b { font-family: var(--serif); font-size: 15px; }
.pv-collect-head small { margin-left: auto; font-size: 11px; color: var(--faint); }
.pv-collect-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pv-still { padding: 0; border: none; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; cursor: pointer; background: #eee; }
.pv-empty { grid-column: 1 / -1; font-size: 12px; color: var(--faint); padding: 6px 0; }
.pv-viewer { position: fixed; inset: 0; z-index: 20; background: rgba(10, 7, 16, 0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.pv-viewer img { max-width: 100%; max-height: 70dvh; border-radius: 12px; }
.pv-album { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pv-slot { padding: 0; border: none; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface); }
.pv-slot.empty { border: 1.5px dashed rgba(var(--line-rgb), 0.2); background: rgba(255, 255, 255, 0.6); }
.pv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-chip { padding: 6px 13px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.18); background: var(--surface); color: var(--text-2); font-family: inherit; font-size: 13px; cursor: pointer; }
.pv-chip[aria-pressed=true] { background: #2a2140; border-color: var(--text); color: #fff; text-decoration: line-through; }
.pv-list { display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.12); overflow: hidden; }
.pv-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px; border: none; border-top: 1px solid rgba(var(--line-rgb), 0.08); background: none; text-align: left; font-family: inherit; color: var(--text); box-sizing: border-box; }
.pv-row:first-child { border-top: none; }
.pv-row-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pv-row-text b { font-size: 14px; font-weight: 500; }
.pv-row-text small { font-size: 11px; color: var(--faint); }
.pv-row-right { font-size: 12px; color: var(--faint); }
.pv-chev { color: var(--faint); }
.pv-switch { flex: none; width: 46px; height: 28px; border-radius: 999px; border: none; padding: 3px; background: rgba(var(--line-rgb), 0.18); display: flex; cursor: pointer; }
.pv-switch::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.pv-switch[aria-checked=true] { background: linear-gradient(90deg, #cdf7e2, #c6e4ff); justify-content: flex-end; }
.pv-mem-hero, .pv-inv-chat { position: relative; height: 260px; margin: -14px -16px 0; overflow: hidden; }
.pv-mem-bg { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.pv-mem-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 70%; background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), var(--bg)); }
.pv-mem-title { display: flex; align-items: baseline; gap: 8px; margin-top: -40px; position: relative; }
.pv-mem-title b { font-family: var(--serif); font-size: 22px; letter-spacing: 2px; }
.pv-mem-title small { font-size: 11px; color: var(--faint); }
.pv-mem-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv-mem-stats > div { display: flex; flex-direction: column; gap: 3px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.12); }
.pv-mem-stats > div:first-child { grid-column: 1 / -1; }
.pv-mem-stats small { font-size: 11px; color: var(--faint); }
.pv-mem-stats b { font-family: var(--serif); font-size: 16px; }
.pv-mem-stats span { font-size: 11px; color: var(--muted); line-height: 1.6; }
.pv-mem-list { display: flex; flex-direction: column; gap: 8px; }
.pv-mem { padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.12); display: flex; flex-direction: column; gap: 4px; }
.pv-mem small { font-size: 11px; color: var(--faint); }
.pv-mem p { margin: 0; font-family: var(--serif); font-size: 14px; line-height: 1.8; }
.pv-mem-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.pv-inv-line { position: absolute; left: 18px; right: 18px; bottom: 16px; margin: 0; font-family: var(--serif); font-size: 14px; line-height: 1.8; }
.pv-inv-pop { margin-top: -30px; position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.14); box-shadow: 0 12px 30px rgba(var(--line-rgb), 0.18); }
.pv-inv-pop b { font-family: var(--serif); font-size: 17px; }
.pv-inv-pop p { margin: 0; font-family: var(--serif); font-size: 14px; line-height: 1.8; }
.pv-inv-pop small { font-size: 11px; color: var(--faint); }
.pv-inv-img { position: relative; height: 150px; border-radius: 14px; overflow: hidden; }
.pv-tagchip { position: absolute; left: 8px; top: 8px; padding: 1px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; background: var(--rainbow); color: var(--text); }
.pv-ro-head { display: flex; align-items: center; gap: 10px; }
.pv-ro-head > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pv-ro-head b { font-family: var(--serif); font-size: 16px; }
.pv-ro-head small { font-size: 11px; color: var(--faint); }
.pv-ro-head .pv-tagchip { position: static; background: rgba(var(--line-rgb), 0.12); }
.pv-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: center 20%; }
.pv-ro-story { display: flex; flex-direction: column; gap: 10px; opacity: 0.75; }
.pv-ro-story p { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.9; }
.pv-ro-end { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--faint); }
.pv-ro-end::before, .pv-ro-end::after { content: ""; flex: 1; height: 1px; background: rgba(var(--line-rgb), 0.15); }
.pv-share { position: relative; aspect-ratio: 4 / 5; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 30px rgba(var(--line-rgb), 0.2); }
.pv-share-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.pv-share-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 60%; background: linear-gradient(180deg, rgba(23, 17, 31, 0), rgba(23, 17, 31, 0.8)); }
.pv-share-quote { position: absolute; left: 22px; right: 22px; bottom: 64px; font-family: var(--serif); font-size: 22px; line-height: 1.6; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.pv-share-sign { position: absolute; left: 22px; bottom: 26px; font-size: 12px; color: rgba(255, 255, 255, 0.85); }
.pv-share-sign b { font-family: var(--serif); font-size: 14px; }
.pv-share-logo { position: absolute; right: 18px; bottom: 20px; width: 30px; height: 30px; }
.pv-share-picks { display: flex; gap: 8px; }
.pv-share-picks button { padding: 0; width: 64px; height: 80px; border-radius: 10px; overflow: hidden; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(var(--line-rgb), 0.2); cursor: pointer; }
.pv-ap-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-top: 8px; }
.pv-ap-avatar { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--rainbow); border: 3px solid #fff; box-shadow: 0 6px 18px rgba(150, 120, 210, 0.3); font-family: var(--serif); font-size: 28px; font-weight: 700; }
.pv-ap-head > b { font-family: var(--serif); font-size: 20px; letter-spacing: 1px; }
.pv-ap-head p { margin: 0; font-size: 13px; color: var(--muted); }
.pv-ap-stats { font-size: 12px; color: var(--muted); }
.pv-ap-stats b { color: var(--text); }
.pv-ap-wall { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pv-ap-card { position: relative; aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; text-decoration: none; color: #fff !important; }
.pv-ap-name { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.pv-ap-name b { font-family: var(--serif); font-size: 15px; }
.pv-ap-name small { font-size: 10px; opacity: 0.85; }
.pv-toast { position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 9px 16px; border-radius: 999px; background: rgba(var(--ink-rgb), 0.92); color: #fff; font-size: 12px; opacity: 0; pointer-events: none; transition: all 0.25s ease; }
.pv-toast.on { opacity: 1; transform: translate(-50%, 0); }
.pv-sec > .pv-btn { align-self: flex-start; }

/* 對話列表（11/23 照畫布《對話列表》改日間配色） */
.cv-page { min-height: 100dvh; padding-bottom: 120px; background: var(--bg); color: var(--text); }
.cv-head { max-width: 560px; margin: 0 auto; padding: 22px 16px 6px; display: flex; flex-direction: column; gap: 12px; }
.cv-title { display: flex; align-items: baseline; gap: 10px; }
.cv-title h1 { margin: 0; font-family: var(--serif); font-size: 26px; letter-spacing: 2px; }
.cv-title > span:not(.u-fill) { font-size: 12px; color: var(--faint); }
.cv-trash { display: inline-flex; align-items: center; gap: 4px; align-self: center; padding: 5px 11px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.18); background: var(--surface); font-size: 12px; color: var(--text-2) !important; text-decoration: none; }
.cv-filters { display: flex; gap: 6px; }
.cv-main { max-width: 560px; margin: 0 auto; padding: 6px 16px 0; display: flex; flex-direction: column; gap: 14px; }
.cv-list { display: flex; flex-direction: column; border-radius: 18px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.1); overflow: hidden; }
.cv-row { display: flex; align-items: center; border-top: 1px solid rgba(var(--line-rgb), 0.08); }
.cv-row:first-child { border-top: none; }
.cv-row.readonly { opacity: 0.6; }
.cv-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 14px; text-decoration: none; color: var(--text) !important; }
.cv-avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(var(--line-rgb), 0.15); display: flex; align-items: center; justify-content: center; background: var(--rainbow);  position: relative;}
.cv-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.cv-avatar span { font-family: var(--serif); font-weight: 700; font-size: 20px; color: rgba(var(--ink-rgb), 0.7); }
.cv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cv-top { display: flex; align-items: center; gap: 6px; }
.cv-top b { font-family: var(--serif); font-size: 15px; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-top small { flex: none; font-size: 11px; color: var(--faint); }
.cv-chip { flex: none; padding: 0 7px; border-radius: 999px; font-size: 10px; line-height: 18px; }
.cv-chip.branch { background: rgba(var(--accent2-rgb), 0.12); color: var(--accent-2); }
.cv-chip.ro { background: rgba(var(--line-rgb), 0.1); color: var(--faint); }
.cv-last { font-family: var(--serif); font-size: 13px; line-height: 1.6; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cv-meta { font-size: 11px; color: var(--faint); }
.cv-row .room-trash { flex: none; margin-right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(var(--line-rgb), 0.15); background: var(--surface); color: var(--faint); cursor: pointer; }
.cv-row .room-trash.armed { width: auto; padding: 0 10px; color: #c23a4e; border-color: rgba(194, 58, 78, 0.4); }
.cv-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 16px; }
.cv-empty p { margin: 0; color: var(--muted); font-size: 14px; }
.cv-go { padding: 10px 20px; border-radius: 999px; background: var(--rainbow); color: var(--text) !important; font-weight: 700; text-decoration: none; font-size: 14px; }
.cv-none { padding: 20px; text-align: center; }
.cv-list .plum-loading { padding: 30px 0; }
.cv-legacy { border-radius: 16px; background: #17111f; color: var(--text); padding: 10px 14px; }
.cv-legacy[hidden] { display: none; }
.cv-legacy summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
.cv-legacy > section { margin-top: 12px; }
.cv-legacy h2, .cv-legacy b, .cv-legacy label { color: var(--text) !important; }

/* 作者後台：卡面機制、附卡（11/23） */
.mech-list { display: flex; flex-direction: column; gap: 10px; }
.mech { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text); font-family: inherit; }
.mech b { font-size: 15px; }
.mech span { font-size: 12px; line-height: 1.7; color: var(--text-2); }
.mech.on { border-color: rgba(255, 159, 192, 0.7); background: var(--selected); }
.lore-search { width: 100%; box-sizing: border-box; }
.lore-list { display: flex; flex-direction: column; gap: 8px; }
.lore-empty { padding: 4px 2px; }
.lore-item { border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); display: flex; flex-direction: column; }
.lore-item.open { border-color: rgba(255, 159, 192, 0.35); padding-bottom: 12px; gap: 10px; }
.lore-item.open > :not(.lore-head) { margin: 0 14px; }
.lore-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: none; background: none; color: var(--text); font-family: inherit; text-align: left; cursor: pointer; }
.lore-title { display: flex; align-items: center; gap: 6px; flex: none; max-width: 55%; }
.lore-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lore-head small { flex: 1; min-width: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lore-arrow { color: var(--muted); }
.lore-chip { flex: none; padding: 0 7px; border-radius: 999px; font-size: 10px; line-height: 18px; background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.lore-chip.on { background: rgba(255, 240, 196, 0.15); color: var(--yellow); }
.lore-bar { align-items: center; gap: 8px; font-size: 13px; }
.lore-always { align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--card-border); }
.lore-always-text { display: flex; flex-direction: column; gap: 2px; }
.lore-always-text small { font-size: 11px; color: var(--muted); }

/* 書房（作者後台首頁，11/23 照畫布《書房》） */
.study-head { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; padding: 18px 16px 6px; }
.study-kicker { font-size: 10px; letter-spacing: 4px; color: var(--muted); }
.study-title { font-family: var(--serif); font-size: 24px; letter-spacing: 2px; }
.study-main { max-width: 760px; margin: 0 auto; }
.study-tip {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 18px; text-align: left; cursor: pointer;
  border: 1px solid rgba(255, 211, 230, 0.3); background: linear-gradient(115deg, rgba(255, 211, 230, 0.12), rgba(198, 228, 255, 0.1)); color: var(--text); font-family: inherit;
}
.study-tip[hidden] { display: none; }
.study-tip-orb { width: 40px; height: 40px; flex: none; animation: plum-breathe 2.4s ease-in-out infinite; }
.study-tip-text { flex: 1; font-size: 13px; line-height: 1.6; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.25); text-underline-offset: 3px; }
.study-tip-dots { display: flex; gap: 3px; }
.study-tip-dots span { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.study-tip-dots span.on { background: var(--pink); }
.study-bar { align-items: center; gap: 10px; }
.study-link { font-size: 12px; color: var(--muted) !important; text-decoration: none; }
.study-seg { flex: none; width: 150px; }
.study-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.study-list { display: flex; flex-direction: column; gap: 8px; }
.study-new, .study-card { border-radius: 16px; overflow: hidden; text-decoration: none; color: var(--text) !important; font-family: inherit; }
.study-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; cursor: pointer;
  border: 1.5px dashed rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.02); font-size: 13px; }
.study-plus { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--rainbow); color: var(--text); font-size: 20px; }
.study-card { position: relative; display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--card-border); }
.study-pic { display: block; aspect-ratio: 3 / 4; background: linear-gradient(135deg, rgba(255, 211, 230, 0.35), rgba(198, 228, 255, 0.3)); position: relative; }
.study-pic img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.study-initial { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 44px; font-weight: 700; color: rgba(255, 255, 255, 0.45); }
.study-text { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px 11px; }
.study-text b { font-family: var(--serif); font-size: 15px; letter-spacing: 1px; }
.study-st { font-size: 11px; color: var(--green); }
.study-st.warn { color: var(--yellow); }
.study-tags { font-size: 11px; color: var(--muted); }
.study-list .study-new { flex-direction: row; min-height: 0; padding: 12px; justify-content: flex-start; }
.study-list .study-plus { width: 30px; height: 30px; font-size: 16px; }
.study-list .study-card { flex-direction: row; align-items: center; }
.study-list .study-pic { width: 64px; flex: none; }


/* ---------- 日夜開關修正（11/23）---------- */
/* 彩虹底上的字一律深色，不跟著主題變 */
.btn.primary, .char-start, .lobby-continue, .cv-go, .pv-btn.primary, .ex-new, .study-plus, .img-badge, .pv-tagchip,
.me-avatar, .pv-dot, .pv-ap-avatar, .char-go, .composer .send, .room-avatar, .view-pill, .vn-name, .me-pc-dot { color: var(--on-rainbow) !important; }
.tabbar .tab-home { color: var(--text) !important; }
/* 疊在照片上的東西：深色玻璃與白字，不跟著主題變 */
.char-arrow { background: rgba(42, 33, 64, 0.38); }
.char-sheet-backdrop, :root[data-theme="day"] .sheet-backdrop { background: rgba(42, 33, 64, 0.36); }
.pv-toast { background: rgba(42, 33, 64, 0.92); color: #fff; }
.cv-legacy { background: #17111f; }
/* 按下去的 tag：白天深底白字，夜晚淺底深字 */
.ex-tag[aria-pressed=true], .pv-chip[aria-pressed=true] { background: var(--text); border-color: var(--text); color: var(--bg); }
.me-theme { flex-direction: row; align-items: center; gap: 10px; }
.me-theme > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.me-theme-seg { flex: none; }
.me-theme-seg button { flex: none; height: 34px; padding: 0 10px; font-size: 12px; }
.char-line-intro { margin: -2px 0 2px; font-family: var(--serif); font-size: 12px; line-height: 1.7; color: var(--muted); white-space: pre-line; }

/* ---------- 幕後（作者看思考鏈） ---------- */
.backstage { position: fixed; inset: 0; z-index: 80; overflow-y: auto; padding: 16px 16px 40px; background: var(--surface); }
.backstage-head button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; }
.backstage-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem; margin-bottom: 6px; }
.backstage-note { font-size: 0.85rem; opacity: 0.7; margin: 4px 0 12px; }
.backstage-item { border: 1px solid rgba(var(--line-rgb), 0.15); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.backstage-item summary { cursor: pointer; font-size: 0.92rem; }
.backstage-think { margin: 10px 0 6px; padding: 10px; border-radius: 8px; background: rgba(var(--accent2-rgb), 0.12); font-size: 0.9rem; line-height: 1.7; }
.backstage-floor { margin-top: 6px; font-weight: 600; color: var(--accent); }
.backstage-nums { font-size: 0.78rem; opacity: 0.6; }
.dev-backstage { border-top: 1px solid rgba(var(--line-rgb), 0.12); padding: 8px 0; }
.dev-backstage pre { white-space: pre-wrap; font: inherit; font-size: 0.88rem; margin: 4px 0; }
.dev-backstage .dev-think { padding: 8px; border-radius: 8px; background: rgba(var(--accent2-rgb), 0.12); }

/* 作者後台：基本資料的頭像、主卡一對齊畫布（11/23） */
.avatar-pick { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px; }
.avatar-opt { flex: none; width: 56px; height: 56px; padding: 0; border-radius: 50%; overflow: hidden; border: 2px solid transparent; background: rgba(var(--line-rgb), 0.06); cursor: pointer;  position: relative;}
.avatar-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--bg-rgb), 1) inset; }
.avatar-dot { flex: none; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(var(--accent2-rgb), 0.15); color: var(--accent-2); font-family: var(--serif); font-weight: 700; }
.page-head { position: relative; }
.core-diff-btn { position: absolute; right: 0; top: 0; }
.core-diff-btn[aria-pressed="true"] { background: var(--selected); }
.core-f + .core-f { margin-top: 10px; }
.core-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.core-top label b { font-size: 14px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.core-top small { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.core-full-btn { flex: none; align-self: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(var(--line-rgb), 0.15); background: none; color: var(--text-2); font-size: 15px; cursor: pointer; }
.core-old { padding: 8px 10px; border-radius: 10px; border: 1px dashed rgba(var(--line-rgb), 0.2); background: rgba(var(--line-rgb), 0.03); font-family: var(--serif); font-size: 13px; line-height: 1.7; color: var(--text-2); white-space: pre-wrap; }
.core-old-label { font-family: var(--sans); font-size: 10px; color: var(--muted); }
.core-foot { display: flex; align-items: baseline; gap: 8px; font-size: 11px; color: var(--muted); }
.core-foot em { font-style: normal; font-size: 10px; color: var(--faint); }
.core-foot em.near { color: var(--yellow); }
.core-foot em.over { color: var(--red); }
.core-guide-btn { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(var(--line-rgb), 0.1); background: rgba(var(--line-rgb), 0.03); color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.core-guide { padding: 8px 4px 0; font-size: 12.5px; line-height: 1.8; color: var(--text-2); }
body.full-open { overflow: hidden; }
.full-editor { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
.full-head { display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid rgba(var(--line-rgb), 0.1); }
.full-head b { flex: 1; font-size: 16px; }
.core-foot .grow { flex: 1; min-width: 0; }
.full-head em { font-style: normal; font-size: 11px; color: var(--muted); }
.full-editor textarea { flex: 1; min-height: 0; margin: 0; padding: 16px 18px; border: none; border-radius: 0; outline: none; background: none; resize: none; font-size: 15.5px; line-height: 1.95; }

/* 附卡劇照（11/23）：後台的縮圖、聊天室彈在回覆最上面、點開看大圖 */
.lore-img-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.lore-still { margin: 0 0 12px; }
.lore-still-btn { display: block; width: 100%; padding: 0; border: 1px solid rgba(var(--line-rgb), 0.14); border-radius: 16px; overflow: hidden; background: rgba(var(--line-rgb), 0.05); cursor: zoom-in; }
.lore-still-btn img { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: cover; }
.lore-still figcaption { margin-top: 6px; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.lore-still-new { display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(var(--accent2-rgb), 0.12); color: var(--accent-2); font-weight: 700; font-size: 11px; }
.still-view { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10, 6, 16, 0.92); cursor: zoom-out; }
.still-view img { max-width: 100%; max-height: 100%; object-fit: contain; }
.still-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 16px; cursor: pointer; }
.still-name { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-family: var(--sans); font-size: 13px; }
.pv-dot.img { object-fit: cover; padding: 0; }
.pv-still-name { color: #fff; font-size: 13px; }

/* 開發者頁手機好操作（11/23）：變數收成可展開、存檔列黏在下面 */
.dev-vars summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.dev-vars summary::-webkit-details-marker { display: none; }
.dev-vars summary::after { content: "▸"; color: var(--muted); font-size: 12px; }
.dev-vars[open] summary::after { content: "▾"; }
.dev-save-bar { position: sticky; bottom: 8px; z-index: 2; padding: 8px 10px; border-radius: 999px; background: var(--surface); box-shadow: 0 4px 16px rgba(var(--ink-rgb), 0.1); }
@media (max-width: 640px) {
  .dev-text { min-height: 60vh; }
  .dev-tabs { overflow-x: auto; }
}
.pv-input { flex: 1; min-width: 0; }
.pv-slot[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: -3px; }
a.pv-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* nav.js 還沒把導覽列改好之前先藏起來，免得先閃一下舊樣子；萬一 nav.js 沒跑，1.2 秒後照舊樣子顯示 */
.tabbar:not(.nav-live) { visibility: hidden; animation: navFallback 0s linear 1.2s forwards; }
@keyframes navFallback { to { visibility: visible; } }

/* 底部導覽列動畫（11/23 接上 Oct 15 定案，nav.js）：白框是一條 SVG 弧，泡泡跟著所在頁走 */
.tabbar.nav-live {
  background: none; box-shadow: none; border-radius: 0; overflow: visible;
  min-height: 0; height: calc(86px + env(safe-area-inset-bottom)); align-items: flex-end; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.tabbar.nav-live a { position: relative; z-index: 1; pointer-events: auto; transition: opacity 0.1s linear; }
.tabbar.nav-live.nav-faded a { opacity: 0; }              /* 沉著時看不見，但照樣點得到 */
.nav-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.nav-glow { fill: none; stroke: rgba(var(--line-rgb), 0.045); stroke-width: 12; stroke-linejoin: round; }
.nav-fill { fill: var(--tabbar-solid); }   /* 不透明：後面的卡片文字不能透出來 */
.nav-edge { fill: none; stroke: rgba(214, 190, 255, 0.7); stroke-width: 2; }
.nav-bubble {
  position: absolute; z-index: 2; top: 0; left: 0; width: 52px; height: 52px; box-sizing: border-box; pointer-events: none;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--on-rainbow);
  background: linear-gradient(135deg, #ffd3e6, #e2cfff 35%, #c6e4ff 60%, #cdf7e2 80%, #fff0c4);
  border: 3px solid rgba(255, 255, 255, 0.92); box-shadow: 0 6px 18px rgba(150, 120, 210, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.9);
}
.nav-bubble.moving { transition: left 0.3s cubic-bezier(0.5, 0, 0.3, 1); }
.nav-bubble-icon { display: flex; transition: opacity 0.1s linear; }
.nav-bubble-icon.out { opacity: 0; }
.tabbar.nav-live .nav-here svg { opacity: 0; }               /* 所在頁：圖示在泡泡裡，原位只留字 */
.tabbar.nav-live a.nav-here, .tabbar.nav-live .tab-home.nav-here { color: var(--text-2) !important; font-weight: 500; }
.tabbar.nav-live .tab-home { font-size: 11px; font-weight: 500; gap: 3px; }
.tabbar.nav-live .nav-rainbow svg { stroke: url(#plumNavRainbow); }
.tabbar.nav-live .nav-rainbow {
  font-weight: 700; color: transparent !important; -webkit-background-clip: text; background-clip: text;
  background-image: linear-gradient(90deg, #e0559a, #f0a040, #4fb8a0, #5b7ee8, #a35be0);
  background-size: 2.4em 100%; background-repeat: no-repeat; background-position: center;   /* 彩虹只鋪在兩個字上 */
}
@media (prefers-reduced-motion: reduce) {
  .nav-bubble.moving { transition: left 0.3s ease-in-out; }
}

/* 出戲提示框（11/24，引擎窗提）：<ooc> 跟正文分開，字級跟正文差不多，日夜都看得清楚 */
.ooc-box { margin: 14px 0; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(var(--accent2-rgb), 0.35); background: rgba(var(--accent2-rgb), 0.08); font-family: var(--sans); }
.ooc-box p { margin: 6px 0 0; font-size: 14px; line-height: 1.8; color: var(--text); text-indent: 0; }
.ooc-label { display: inline-block; padding: 1px 9px; border-radius: 999px; background: rgba(var(--accent2-rgb), 0.16); color: var(--accent-2); font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.vn-text.ooc { color: var(--text); font-family: var(--sans); font-size: 14.5px; line-height: 1.8; }

/* 創作首頁（書房）也有底部導覽列，內容底下留位置 */
.study-main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* iOS 26 Safari 不會把固定在底部的導覽列畫到網址列下面（網頁自己的限制）。
   做法跟別的網站一樣：捲動的是 body，不是整份文件，內容永遠停在導覽列底邊，網址列那一截只會看到單色背景 */
html.nav-page { height: 100%; overflow: hidden; background: var(--bg); }
html.nav-page body { height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: none; -webkit-overflow-scrolling: touch; }

/* 頁面標題上面的小英文（跟書房的 STUDIO 同一個樣子，11/24 小梅要每頁都有） */
.page-kicker { margin-bottom: 4px; }
.kicker-title { display: flex; flex-direction: column; }

/* 探索的欄位（11/24 小梅定）：每欄兩列，往左滑看更多 */
.ex-rows { display: flex; flex-direction: column; gap: 22px; }
.ex-rows[hidden] { display: none; }
.ex-row2 {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: 42%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; scroll-padding-left: 16px;
}
.ex-row2.few { grid-template-rows: auto; }
.ex-row2::-webkit-scrollbar { display: none; }
.ex-row2 > .ex-card { scroll-snap-align: start; }
.ex-tabs { overflow-x: auto; scrollbar-width: none; }
.ex-tabs::-webkit-scrollbar { display: none; }
.ex-tabs button { flex: none; }
#exSoon .ex-sec-head:not(:first-child) { margin-top: 12px; }

/* 新推出輪播改橫式（11/24 小梅定）：手機 3:2、電腦 16:9。作者自己框橫版封面的功能做好之前，先拿現有封面置中裁 */
.ex-cover.hero { height: auto; aspect-ratio: 3 / 2; }
.ex-cover.hero.blank .ex-initial { font-size: 84px; }
.ex-slide-fade { height: 70%; }
.ex-slide-text b { font-size: 20px; }
.ex-slide-line { -webkit-line-clamp: 1; }
@media (min-width: 700px) { .ex-cover.hero { aspect-ratio: 16 / 9; } }

/* 編輯器總覽（11/24 照畫布《單人卡編輯器》）：每組一張圓角卡、一行一個子頁，右邊是狀態 */
.ov-head { display: flex; align-items: center; gap: 10px; }
.ov-head h1 { margin: 0; font-family: var(--serif); font-size: 22px; letter-spacing: 2px; }
.ov-total { padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.1); display: flex; flex-direction: column; gap: 7px; }
.ov-total .total-line { display: flex; font-size: 13px; }
.ov-total .total-bar { margin-top: 0; }
/* 字數／token 開關：膠囊裡一顆彩虹珠，字在空的那邊；切到 token 時珠子滑到右邊、膠囊染上一層彩虹 */
.unit-switch { position: relative; flex: none; display: flex; align-items: center; width: 84px; height: 34px; padding: 0 12px 0 38px; border-radius: 999px;
  border: 1px solid rgba(var(--line-rgb), 0.18); background: var(--surface); color: var(--text-2); font: 700 12px var(--sans); letter-spacing: 0.5px; cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18); transition: padding 0.22s ease; -webkit-tap-highlight-color: transparent; }
.unit-switch::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--rainbow); opacity: 0; transition: opacity 0.22s ease; }
.unit-text { position: relative; flex: 1; text-align: center; white-space: nowrap; }
.unit-knob { position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: var(--rainbow); border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(150, 120, 210, 0.35), inset 0 -2px 4px rgba(255, 255, 255, 0.6); transition: transform 0.22s cubic-bezier(0.3, 1.3, 0.5, 1); }
.unit-switch[aria-checked="true"] { padding: 0 38px 0 12px; }
.unit-switch[aria-checked="true"]::before { opacity: 0.22; }
.unit-switch[aria-checked="true"] .unit-knob { transform: translateX(50px); }
.ov-head .grow { flex: 1; }
.reserve-hint { display: block; margin-top: 5px; font-size: 11px; color: var(--yellow); }
.reserve-hint[hidden] { display: none; }
/* 世界線頁的分段標題 */
.box-head { display: flex; align-items: center; gap: 8px; padding: 10px 4px 0; }
.box-head > b { font-family: var(--serif); font-size: 16px; letter-spacing: 1px; }
.box-head .grow { flex: 1; }
.box-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.box-dot.world { background: #fff0c4; box-shadow: 0 0 0 1px rgba(var(--line-rgb), 0.18); }
.box-dot.role { background: #ffb3c8; }
.box-count { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.box-count.near { color: var(--yellow); }
.box-count.over { color: var(--red); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .unit-switch, .unit-switch::before, .unit-knob { transition: none; } }
.ov-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-2); }
.ov-key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.ov-group { display: flex; flex-direction: column; gap: 7px; }
.ov-group-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.ov-group-head > b { font-size: 14px; }
.ov-list { border-radius: 16px; background: var(--surface); border: 1px solid rgba(var(--line-rgb), 0.1); overflow: hidden; }
.ov-row {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; padding: 12px 14px; border: none; background: none;
  border-top: 1px solid rgba(var(--line-rgb), 0.07); color: var(--text); font-family: inherit; text-align: left; cursor: pointer; box-sizing: border-box;
}
.ov-list > .ov-row:first-child { border-top: none; }
.ov-row:hover:not(.later) { background: rgba(var(--line-rgb), 0.04); }
.ov-row.later { cursor: default; opacity: 0.5; }
.ov-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: rgba(var(--line-rgb), 0.2); }
.ov-dot.ok { background: #8fd9b6; }
.ov-dot.miss { background: #ff9fc0; }
.ov-row.later .ov-dot { background: transparent; border: 1px dashed rgba(var(--line-rgb), 0.35); box-sizing: border-box; }
.ov-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ov-name { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ov-sub { font-size: 11px; color: var(--muted); line-height: 1.5; }
.ov-st { flex: none; font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.ov-row.later .ov-st { padding: 1px 7px; border-radius: 999px; border: 1px solid rgba(var(--line-rgb), 0.2); }
.ov-arrow { flex: none; color: var(--muted); margin-top: 1px; }
.ov-lines { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; font-size: 12px; color: var(--text-2); }
.ov-line { display: flex; }
.ov-off { padding: 11px 14px; border-radius: 16px; border: 1px dashed rgba(var(--line-rgb), 0.22); font-size: 12px; line-height: 1.7; color: var(--muted); }
.tag.core { border: 1px solid rgba(255, 190, 0, 0.5); color: #b8860b; background: none; }
.ov-line .grow, .ov-group-head .grow { flex: 1; }
.ov-line > span:first-child { min-width: 5em; }

/* 11/24 小梅：目錄搬到右上（左邊是返回鍵，會誤按），手機抽屜改從右邊滑出；總覽頁不顯示底下的總字數；拿掉存草稿（本來就會自動存） */
body.ed-overview .actionbar .total { display: none; }
@media (max-width: 760px) {
  .ed-where { display: none; }
  .tree { left: auto; right: 0; border-radius: 16px 0 0 16px; transform: translateX(105%); }
  body.tree-open .tree { transform: none; }
}

/* 角色頁（11/24 小梅）：頂端跟圖一起、不留淺色條；「開始」縮小 */
html.char-html { background: var(--bg); }
.char-start { width: min(220px, calc(100vw - 96px)); height: 46px; font-size: 16px; letter-spacing: 5px; }
.char-body { bottom: calc(84px + env(safe-area-inset-bottom)); }
.char-arrow { top: 50vh; transform: translateY(-50%); }

/* 角色頁資訊區（手機，11/24 小梅）：每個角色一樣高；露一行簡介漸層淡出，往上拉越拉越高，看完整簡介與作者留言 */
.char-grip, .char-extra { display: none; }
@media (max-width: 760px) {
  .char-body {
    left: 0; right: 0; transform: none; width: 100%; max-height: none; bottom: 0;
    height: var(--sheet-h, 322px); padding: 0 20px calc(84px + env(safe-area-inset-bottom)); gap: 6px;
    transition: none;
  }
  .char-body.snap { transition: height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .char-body::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 22px 22px 0 0; pointer-events: none;
    background: rgba(var(--bg-rgb), 0.96); opacity: var(--p, 0); box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  }
  .char-grip { display: flex; justify-content: center; align-self: stretch; flex: none; padding: 6px 0 2px; border: none; background: none; cursor: pointer; }
  .char-grip span { width: 38px; height: 4px; border-radius: 2px; background: rgba(var(--line-rgb), 0.45); }
  .char-scroll {
    flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px;
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 30px), transparent);
    mask-image: linear-gradient(180deg, #000 calc(100% - 30px), transparent);
  }
  .char-body.open .char-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 24px), transparent); }
  .char-identity { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: none; min-height: 3.2em; }
  .char-identity[hidden] { display: -webkit-box; visibility: hidden; }
  .char-body.open .char-identity { display: block; }
  .char-tags { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: none; }
  .char-tags::-webkit-scrollbar { display: none; }
  .char-tag { flex: none; }
  .char-meta, .char-body h1 { flex: none; }
  .char-more { display: none; }
  .char-intro-text { -webkit-line-clamp: unset; display: block; }
  .char-body.open .char-intro { display: none; }
  .char-extra:not([hidden]) { display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; }
  .char-body:not(.open) .char-extra { display: none; }
  .char-extra-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
  .char-page:has(.char-body.open) .char-arrow { opacity: 0; pointer-events: none; }
}

/* 11/24 小梅：圖要看得更大。手機上黑色漸層只從資訊區上緣一點點開始，不再從畫面四成就變暗；字加淡陰影撐住亮圖 */
@media (max-width: 760px) {
  .char-page.has-img .char-fade {
    height: calc(var(--sheet-h, 322px) + 70px);
    background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.78) 70px, rgba(var(--bg-rgb), 0.92) 55%, var(--bg));
  }
  .char-page.has-img .char-identity, .char-page.has-img .char-meta, .char-page.has-img .char-intro-text { text-shadow: 0 1px 6px rgba(var(--bg-rgb), 0.9); }
}
@media (max-width: 760px) {
  /* 頁數點點浮在資訊區上緣外面，不佔資訊區的高度（不然有多張圖的角色會少露一行簡介） */
  .char-body { overflow: visible; }
}

/* 11/25 小梅的大膽嘗試：手機上幾乎拿掉黑色漸層，字直接壓在圖上，靠「深色光暈＋一點亮光」撐住。
   只在收起、有圖的時候；往上拉開後照舊有底色。要退回上一版，刪掉這一段就好 */
@media (max-width: 760px) {
  /* 註一（11/25）：不要一整條實色，用漸層慢慢變深，後面的字透出來沒關係；夜間變黑、日間變白 */
  .char-page.has-img .char-fade {
    height: calc(84px + env(safe-area-inset-bottom) + 110px);
    background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.5) 40%, rgba(var(--bg-rgb), 0.9) 80%, var(--bg));
  }
  .char-page.has-img .char-body:not(.open) {
    --halo: 0 0 1px rgba(10, 6, 18, 0.9), 0 1px 3px rgba(10, 6, 18, 0.85), 0 0 12px rgba(10, 6, 18, 0.7), 0 0 26px rgba(10, 6, 18, 0.45);
  }
  .char-page.has-img .char-body:not(.open) h1 {
    color: #fff;
    text-shadow: 0 0 2px rgba(10, 6, 18, 0.9), 0 0 14px rgba(10, 6, 18, 0.6), 0 0 8px rgba(255, 255, 255, 0.85);
  }
  .char-page.has-img .char-body:not(.open) .char-identity,
  .char-page.has-img .char-body:not(.open) .char-intro-text,
  .char-page.has-img .char-body:not(.open) .char-author,
  .char-page.has-img .char-body:not(.open) .char-version { color: #fff; text-shadow: var(--halo); }
  .char-page.has-img .char-body:not(.open) .char-version { color: rgba(255, 255, 255, 0.85); }
  .char-page.has-img .char-body:not(.open) .char-tag {
    color: #fff; background: rgba(20, 14, 30, 0.42); border-color: rgba(255, 255, 255, 0.28);
    text-shadow: 0 0 1px rgba(10, 6, 18, 0.9), 0 0 6px rgba(10, 6, 18, 0.6);
  }
  .char-page.has-img .char-body:not(.open) .char-grip span { background: rgba(255, 255, 255, 0.7); box-shadow: 0 0 6px rgba(10, 6, 18, 0.6); }
}
@media (max-width: 760px) {
  .char-page.has-img .char-body:not(.open) .char-meta,
  .char-page.has-img .char-body:not(.open) .char-meta * { color: #fff; text-shadow: var(--halo); }
  .char-page.has-img .char-body:not(.open) .char-author-dot { background: rgba(20, 14, 30, 0.55); color: #fff; }
}
/* 頂端那條淺紫色：iOS Safari 取的是 body 的底色，角色頁的 body 也改深色 */
html.char-html body, html.char-html .char-page { background: var(--bg); }

/* 圖片頁數搬到右上角，跟返回鍵對稱（11/25 小梅）：一顆玻璃膠囊，細條＋數字 */
.char-top { align-items: center; }
.char-top .char-dots {
  margin: 0 0 0 auto; height: 40px; padding: 0 14px; gap: 9px; border-radius: 999px;
  border: 1px solid rgba(var(--line-rgb), 0.25); background: rgba(var(--glass-rgb), 0.72);
}
.char-top .char-dot-row { gap: 3px; }
.char-top .char-dot-row span { width: 8px; height: 3px; border-radius: 2px; background: rgba(var(--ink-rgb), 0.25); }
.char-top .char-dot-row span.on { width: 18px; background: linear-gradient(90deg, #ffb3c8, #c9a7ff); }
.char-top .char-count { padding: 0; background: none; font-family: var(--serif); font-size: 13px; letter-spacing: 1px; color: var(--text); }

/* 11/25 小梅：字外面會出現一圈透明的框。原因是字的光暈被「裁切」切掉了（文字框、捲動區都有 overflow: hidden），
   光暈在框邊被截斷就看得出一個方框。做法：讓文字框和捲動區往外多留一圈空間，光暈畫得完整 */
@media (max-width: 760px) {
  .char-body { padding-left: 0; padding-right: 0; }
  .char-scroll { padding: 6px 20px 0; }
  .char-page.has-img .char-identity,
  .char-page.has-img .char-intro-text { padding: 14px; margin: -14px; }
  .char-page.has-img .char-intro-text { overflow: visible; }
}

/* 11/25 小梅：目錄抽屜跟著日夜主題（原本寫死深色，日間字看不到）；每一組框成一張圓角卡，跟總覽一樣 */
@media (max-width: 760px) {
  .tree { background: var(--bg); border: 1px solid rgba(var(--line-rgb), 0.12); }
}
.tree-list[role="tree"] { display: flex; flex-direction: column; gap: 8px; }
.tree-group { border-radius: 14px; background: rgba(var(--line-rgb), 0.05); border: 1px solid rgba(var(--line-rgb), 0.1); overflow: hidden; }
.tree-group .tree-list { padding-bottom: 4px; }

/* 11/25 小梅：Safari 頂端那條不追圖片顏色了，夜間就夜間底色、日間就日間底色。
   iOS 26 Safari 拿頂端固定全寬元素（角色頁是 .char-hero）的底色來塗，所以有圖時它的底色設成頁面底色 */
.char-page.has-img .char-hero { background: var(--char-top, var(--bg)); }
/* 11/25 小梅改回來：Safari 分頁裡頂端那條跟著目前這張圖最上緣的顏色（比單色好看）。細條保險見 chat.js charTopTint */
.top-tint { position: fixed; top: 0; left: 0; right: 0; height: 24px; z-index: 60; opacity: 0.12; pointer-events: none; }
html.char-html, html.char-html body { background: var(--char-top, var(--bg)); }

/* 加入主畫面打開（standalone）：網頁畫到最頂端，時間電池疊在畫面上。
   一般頁面頂端留出時間那一排的高度，塗頁面底色；角色頁讓圖鋪上去（只有夜間，見 theme.js） */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); z-index: 100; background: var(--bg); pointer-events: none; }
  .topbar, .ed-head, .pv-top { top: env(safe-area-inset-top); }
  .dev-tabs { top: calc(62px + env(safe-area-inset-top)); }
  html.char-html body { padding-top: 0; }
  html.char-html body::before { background: linear-gradient(180deg, rgba(10, 6, 18, 0.45), rgba(10, 6, 18, 0)); height: calc(env(safe-area-inset-top) + 16px); }
  .char-top { padding-top: calc(14px + env(safe-area-inset-top)); }
}

/* 11/25 小梅：新推出的 NEW 放右上角 */
.ex-new.corner { position: absolute; top: 12px; right: 12px; z-index: 2; }

/* 11/25 小梅：新推出輪播的卡片陰影，被可以左右滑的那一層切掉，上下變成一條有硬邊的淡色帶。拿掉陰影 */
.ex-slide { box-shadow: none; }

/* 後台基本資料（11/25）：相簿、頭像、頁尾；圖片頁的橫版封面 */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.album-cell { aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; padding: 0; border: 1px solid rgba(var(--line-rgb), 0.15); background: rgba(var(--line-rgb), 0.05); cursor: pointer; }
.album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cell.add { border: 1.5px dashed rgba(var(--line-rgb), 0.35); color: var(--text-2); font-size: 24px; display: flex; align-items: center; justify-content: center; }
.avatar-row { gap: 14px; align-items: center; }
.avatar-big { flex: none; width: 72px; height: 72px; border-radius: 50%; overflow: hidden; padding: 0; cursor: pointer; border: 2px solid rgba(var(--line-rgb), 0.25); background: none;  position: relative;}
.avatar-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 作者框過的頭像：圖片照框放大位移（寬高與位置由程式算） */
.cv-avatar img.framed, .avatar-opt img.framed, .avatar-big img.framed { position: absolute; max-width: none; object-fit: fill; }
.crop-frame.round { border-radius: 50%; }
.avatar-edit { flex: none; align-self: center; }
.avatar-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.avatar-txt > b { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.avatar-txt small { font-size: 11px; color: var(--muted); line-height: 1.6; }
.avatar-wrap { position: relative; flex: none; display: flex; }
.avatar-pen { position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--rainbow); border: 2px solid var(--bg); color: #3a2a4a; font-size: 13px; line-height: 1; pointer-events: none; }
.avatar-big.empty { border: 1.5px dashed rgba(var(--line-rgb), 0.35); color: var(--text-2); font-size: 24px; display: flex; align-items: center; justify-content: center; }
.avatar-opt[aria-pressed="true"] { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.page-foot { margin: 8px 0 0; text-align: center; font-size: 12px; line-height: 1.8; color: var(--muted); }
.cover-previews { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; align-items: end; }
.cover-item { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cover-frame { position: relative; width: 100%; border-radius: 12px; overflow: hidden; background: rgba(var(--line-rgb), 0.08); }
.cover-frame.wide { aspect-ratio: 16 / 9; }
.cover-frame.phone { aspect-ratio: 3 / 2; }
.cover-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-frame.cropped img { position: absolute; max-width: none; object-fit: fill; }
.cover-tag { position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10px; background: rgba(var(--glass-rgb), 0.85); color: var(--text-2); }
.crop-box .avatar-pick { flex-wrap: wrap; max-height: 50vh; overflow-y: auto; }

/* 後台每頁底下的上一步／下一步（11/25） */
.page-steps { display: flex; gap: 10px; margin-top: 18px; }
.page-steps .btn { display: flex; flex-direction: column; gap: 1px; padding: 9px 16px; border-radius: 16px; max-width: 48%; text-align: left; }
.page-steps .step-next { align-items: flex-end; text-align: right; }
.page-steps small { font-size: 11px; color: var(--muted); }
.page-steps span { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.page-steps .grow { flex: 1; }

.album-head { display: flex; align-items: center; gap: 8px; }
.album-note { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: -4px; }
.core-guide-dl { margin-top: 10px; }
.pane > .core-f { padding: 0 2px; }
