/* =========================================================================
   RMW Fans — design tokens, v5
   Concept: a system-repair terminal, not an antique archive. RMW is out in
   the field patching a broken world — the UI should read like a diagnostic
   console: cool graphite/slate surfaces, a cyan "signal" accent for repair
   actions and live/OK state, and a warning-red for corruption/danger.
   Serif headings (Noto Serif SC) keep a bit of a "field log" voice against
   the otherwise plain, functional sans UI.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700;800&family=Noto+Serif+SC:wght@600;700;800&family=IBM+Plex+Mono:wght@500;600;700&display=swap');

:root, [data-theme="dark"] {
  --bg: #0f1215;
  --bg-vignette: #171c21;
  --panel: #171a1e;
  --panel-2: #1e2226;
  --panel-3: #262b30;
  --line: #333a40;
  --line-strong: #48515a;
  --ink: #e7ebee;
  --ink-dim: #8b96a1;
  --accent: #3fc7b8;
  --accent-strong: #6fe0d1;
  --accent-ink: #04211c;
  --ok: #6fae7a;
  --danger: #d8604a;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --header-bg: #0a0d10;
  --header-ink: #e7ebee;
  --header-ink-dim: #7c8791;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #eef1f2;
  --bg-vignette: #f8fafa;
  --panel: #ffffff;
  --panel-2: #f2f5f6;
  --panel-3: #e6ebec;
  --line: #d6dcdf;
  --line-strong: #b7c0c4;
  --ink: #1b2124;
  --ink-dim: #5b666c;
  --accent: #0e8f80;
  --accent-strong: #0a6d61;
  --accent-ink: #f2fffb;
  --ok: #3f8455;
  --danger: #b1462f;
  --shadow-color: rgba(15, 30, 32, 0.12);
  --header-bg: #e4e9ea;
  --header-ink: #1b2124;
  --header-ink-dim: #5b666c;
  color-scheme: light;
}

:root {
  --font-ui: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Noto Serif SC", "Inter", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-s: 5px;
  --radius: 9px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse 900px 500px at 50% 0%, var(--bg-vignette), var(--bg) 72%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

h1, h2, h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  padding-bottom: 9px;
  margin-bottom: 13px;
  border-bottom: 1px solid var(--line-strong);
}
h2 { font-size: 16.5px; }
h3 { font-size: 14.5px; }

p { margin: 0 0 12px; max-width: 68ch; color: var(--ink); }

.container {
  position: relative;
  max-width: 900px;
  margin: 12px auto 40px;
  padding: 19px 18px 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 34px -18px var(--shadow-color), 0 1px 2px var(--shadow-color);
}
.container::before, .container::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--accent);
  opacity: 0.55;
  pointer-events: none;
}
.container::before { top: -1px; left: -1px; border-right: none; border-bottom: none; border-radius: var(--radius) 0 0 0; }
.container::after { bottom: -1px; right: -1px; border-left: none; border-top: none; border-radius: 0 0 var(--radius) 0; }
@media (max-width: 640px) {
  .container::before, .container::after { display: none; }
}
.container.narrow { max-width: 480px; }
@media (max-width: 640px) {
  .container { margin: 0; border-left: none; border-right: none; border-radius: 0; padding: 15px 13px 28px; }
}

/* ---- splash screen ---- */
.splash-screen {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: rmw-splash-spin 0.85s linear infinite;
  margin-bottom: 20px;
}
@keyframes rmw-splash-spin { to { transform: rotate(360deg); } }
.splash-mark {
  font-family: var(--font-display); font-weight: 800; font-size: 26px;
  color: var(--ink); display: flex; align-items: center;
  animation: rmw-splash-fade 0.6s ease both;
}
.splash-mark .dot { font-size: 0; }
.splash-mark .dot::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); margin: 0 9px; }
.splash-sub {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim); margin-top: 12px;
}
@keyframes rmw-splash-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- left sidebar ----
   社区导航条:默认只显示图标(收起态),点击顶部的 ☰ 展开成带文字标签的
   抽屉,覆盖在正文之上(不挤压正文布局)。任何屏幕宽度下都是同一套结构,
   只是展开时的宽度不同。 */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  width: 50px;
  background: var(--header-bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 14px;
  overflow: hidden;
  transition: width 0.22s ease, box-shadow 0.22s ease;
}
.sidebar.is-expanded {
  width: 206px;
  align-items: stretch;
  box-shadow: 10px 0 30px var(--shadow-color);
  overflow-y: auto;
}
/* ---- 图标:用生成的 PNG 当 CSS mask,这样图标能跟着文字颜色变(悬停、
   选中态、亮暗主题都会自动着色),而不是被 <img> 写死成一个颜色。 ---- */
.icon-mask {
  display: inline-block;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  flex-shrink: 0;
}

.sidebar-toggle {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--header-ink) 16%, transparent);
  background: color-mix(in srgb, var(--header-ink) 6%, transparent);
  color: var(--header-ink);
  cursor: pointer;
  align-self: center;
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle .icon-mask { width: 15px; height: 15px; }
.sidebar.is-expanded .sidebar-toggle { align-self: flex-start; margin-left: 14px; }
.sidebar-toggle:hover { border-color: var(--accent-strong); color: var(--accent-strong); }

.sidebar-brand {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; cursor: pointer; flex-shrink: 0;
  padding: 6px 0 16px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  width: 100%;
}
.sidebar-brand .brand-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  object-fit: contain; border-radius: 5px;
  display: block;
}
.sidebar-brand .label {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  color: var(--header-ink); white-space: nowrap;
  display: none;
}
.sidebar-brand .label .dot { font-size: 0; }
.sidebar-brand .label .dot::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 0 6px; }
.sidebar.is-expanded .sidebar-brand { justify-content: flex-start; padding: 6px 16px 16px; }
.sidebar.is-expanded .sidebar-brand .label { display: inline; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; justify-content: center;
  font-family: var(--font-ui); font-weight: 600; font-size: 12.5px;
  color: var(--header-ink-dim);
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.sidebar-nav a:hover { color: var(--header-ink); text-decoration: none; background: color-mix(in srgb, var(--header-ink) 7%, transparent); }
.sidebar-nav a.active {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-left-color: var(--accent);
}
.sidebar-nav a .icon { width: 18px; height: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav a .icon.icon-mask { width: 16px; height: 16px; }
.sidebar-nav a .label { display: none; }
.sidebar.is-expanded .sidebar-nav a { justify-content: flex-start; padding: 8px 16px; }
.sidebar.is-expanded .sidebar-nav a .label { display: inline; }

.sidebar-footer {
  width: 100%; flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px; margin-top: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-footer-link {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  color: var(--header-ink-dim);
  border: none; background: none; cursor: pointer;
  padding: 7px 0; width: 100%;
}
.sidebar-footer-link:hover { color: var(--header-ink); text-decoration: none; }
.sidebar-footer-link .icon { width: 18px; height: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer-link .icon.icon-mask { width: 15px; height: 15px; }
.sidebar-footer-link .label { display: none; }
.sidebar.is-expanded .sidebar-footer-link { justify-content: flex-start; padding: 7px 16px; }
.sidebar.is-expanded .sidebar-footer-link .label { display: inline; }

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(4, 6, 8, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-scrim.is-visible { opacity: 1; pointer-events: auto; }

body { padding-left: 50px; }
@media (max-width: 480px) {
  .sidebar { width: 44px; }
  .sidebar.is-expanded { width: min(200px, 80vw); }
  body { padding-left: 44px; }
}

/* ---- buttons / inputs ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-ui); font-weight: 600; font-size: 12.5px;
  padding: 7px 13px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--panel-2); color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-danger { border-color: var(--line-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 9px; font-size: 11px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--header-ink) 16%, transparent); background: color-mix(in srgb, var(--header-ink) 6%, transparent); color: var(--header-ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px;
}
.icon-btn:hover { border-color: var(--accent-strong); color: var(--accent-strong); }

.field { margin-bottom: 13px; }
.field label {
  display: block; font-family: var(--font-mono); font-weight: 600;
  font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 6px;
}
.input, .textarea, select.input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
}
.textarea { resize: vertical; min-height: 90px; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); outline: none; }
.hint { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-dim); margin-top: 6px; letter-spacing: 0.01em; }

/* ---- custom dialogs & modal select (js/ui-dialog.js) ----
   Replaces native alert()/confirm()/prompt() and native <select> popups
   with in-app modals that pick up the same theme tokens as everything else. */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6, 8, 10, 0.58);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 20px 18px 24px; width: 100%; max-width: 440px;
  box-shadow: 0 -6px 24px var(--shadow-color);
}
.modal-card h3 { border-bottom: none; margin: 0 0 10px; padding-bottom: 0; font-size: 15.5px; }
.modal-card p { margin-bottom: 16px; }
@media (min-width: 540px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-card { border-radius: var(--radius); box-shadow: 0 14px 34px var(--shadow-color); }
}
.modal-card .btn-row .btn { flex: 1; }

.ui-select-wrap { position: relative; width: 100%; }
.ui-select-native {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.ui-select-button { text-align: left; cursor: pointer; position: relative; padding-right: 36px; }
.ui-select-button::after {
  content: "⌄"; position: absolute; right: 12px; top: 50%;
  transform: translateY(-55%); color: var(--ink-dim); font-size: 14px; pointer-events: none;
}
.ui-select-modal { max-width: 420px; }
.ui-select-options { display: grid; gap: 7px; max-height: 55vh; overflow: auto; }
.ui-select-option {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel-2); color: var(--ink); font: inherit; font-family: var(--font-body); text-align: left; cursor: pointer;
}
.ui-select-option:hover, .ui-select-option.is-selected { border-color: var(--accent); }
.ui-select-option:disabled { opacity: .45; cursor: not-allowed; }

/* ---- choice chips: multi-select checkbox groups (associated chapters/characters) ---- */
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink-dim);
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.choice-chip input { accent-color: var(--accent); margin: 0; }
.choice-chip:hover { border-color: var(--accent); color: var(--ink); }
.choice-chip.is-checked,
.choice-chip:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
.choice-empty { font-size: 12.5px; color: var(--ink-dim); font-style: italic; }

/* ---- panels ---- */
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px var(--shadow-color);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 7px;
  margin: 24px 0 11px;
}
.section-title::before { content: "▸"; color: var(--accent); font-size: 12px; }

/* ---- grids ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 11px;
  padding-top: 4px;
}
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }

/* ---- flat reference cards ---- */
.chapter-card, .character-card, .work-card {
  position: relative;
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow-color);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.chapter-card::before, .character-card::before, .work-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  opacity: 0; transition: opacity 0.15s ease;
  z-index: 3;
}
.grid > a:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px -6px var(--shadow-color);
  border-color: var(--accent);
  text-decoration: none;
  z-index: 2;
}
.grid > a:hover::before { opacity: 1; }

.chapter-card .cover {
  height: 88px; background: var(--panel-3) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.chapter-card .order-tag {
  position: absolute; bottom: 7px; left: 8px;
  font-family: var(--font-mono); font-weight: 700; font-size: 11px; color: #fff;
  background: rgba(10, 14, 20, 0.62);
  border-radius: 3px;
  padding: 2px 7px;
}
.chapter-card .body { padding: 10px 12px; }
.chapter-card h3 { margin-bottom: 3px; font-size: 13.5px; }
.chapter-card p {
  font-family: var(--font-body); font-size: 11.5px; margin-bottom: 0; color: var(--ink-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- chapter detail: cover banner ---- */
.chapter-cover {
  margin: 0 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px var(--shadow-color);
}
.chapter-cover img {
  display: block; width: 100%;
  max-height: 320px; object-fit: cover;
}

.character-card { text-align: center; padding: 13px 8px 11px; }
.character-card .avatar {
  width: 50px; height: 50px; border-radius: 50%; margin: 0 auto 8px;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 16px; color: var(--ink-dim);
}
.character-card .name { font-family: var(--font-ui); font-weight: 600; font-size: 12.5px; }
.character-card .alias { font-family: var(--font-body); font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.character-card .chapters { font-family: var(--font-body); font-size: 10.5px; color: var(--ink-dim); margin-top: 3px; }

.work-card .thumb { height: 118px; background: var(--panel-3) center/cover no-repeat; border-bottom: 1px solid var(--line); }
.work-card .body { padding: 9px 11px; }
.work-card .title {
  font-family: var(--font-ui); font-weight: 600; font-size: 12px; margin-bottom: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.work-card .meta { font-family: var(--font-body); font-size: 10.5px; color: var(--ink-dim); display: flex; justify-content: space-between; gap: 6px; }
.work-card-meta-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.like-count-mini { color: var(--danger); font-weight: 600; }

/* ---- tag / relation chips (chapters a character belongs to, characters a work depicts) ---- */
.chapter-badge, .character-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  color: var(--ink);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
}
.chapter-badge:hover, .character-badge:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0; }

/* ---- wiki article layout: main column + infobox ---- */
.wiki-layout { display: flex; gap: 28px; align-items: flex-start; }
.wiki-main { flex: 1 1 380px; min-width: 0; }
.wiki-main h1 { margin-bottom: 4px; border-bottom: none; padding-bottom: 0; }
.wiki-main .subtitle { color: var(--ink-dim); font-style: italic; margin-bottom: 18px; font-size: 13.5px; }
.wiki-main .subtitle + .section-title { margin-top: 20px; }

.infobox {
  flex: 0 0 240px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.infobox-title {
  background: var(--header-bg);
  color: var(--header-ink);
  font-family: var(--font-ui); font-weight: 800; font-size: 14.5px;
  text-align: center;
  padding: 10px 12px;
}
.infobox-image {
  width: 100%; aspect-ratio: 1 / 1.05;
  background: var(--panel-3) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.infobox-image--empty {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 38px; color: var(--ink-dim);
}
.infobox-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.infobox-table th, .infobox-table td {
  text-align: left; vertical-align: top;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}
.infobox-table th {
  width: 34%;
  font-family: var(--font-ui); font-weight: 600; color: var(--ink-dim);
}
.infobox-table td { font-family: var(--font-body); color: var(--ink); }
.infobox-table tr:first-child th, .infobox-table tr:first-child td { border-top: none; }

@media (max-width: 720px) {
  .wiki-layout { flex-direction: column; }
  .infobox { flex: 1 1 auto; width: 100%; order: -1; max-width: 320px; }
}

/* ---- article figures (full art / work images) ---- */
.full-art, .work-detail img, .work-detail video {
  width: 100%; max-height: 65vh; object-fit: contain;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  display: block;
}

.work-detail .meta {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-dim);
  margin-bottom: 6px;
}

/* ---- 点赞 ---- */
.interaction-bar { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-dim);
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.like-btn:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.like-btn .like-icon { font-size: 15px; line-height: 1; }
.like-btn.is-liked { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.like-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.interaction-bar .hint { font-size: 12.5px; color: var(--ink-dim); }

/* ---- 短评 ---- */
.comment-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.comment-section-title {
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; color: var(--ink);
  margin-bottom: 12px;
}
.comment-form { display: flex; gap: 8px; margin-bottom: 14px; }
.comment-form .input { flex: 1; }
.comment-list { display: flex; flex-direction: column; }
.comment-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.comment-row:last-child { border-bottom: none; }
.comment-row-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 12px; color: var(--ink-dim); margin-bottom: 3px;
}
.comment-row-meta [data-author-slot] { font-weight: 600; color: var(--ink); }
.comment-row-time { flex: 1; }
.comment-delete {
  border: none; background: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 11.5px; color: var(--ink-dim);
  padding: 0; text-decoration: underline;
}
.comment-delete:hover { color: var(--danger); }
.comment-row-text { font-family: var(--font-body); font-size: 13.5px; color: var(--ink); word-break: break-word; }

/* ---- status badges ---- */
.stamp {
  font-family: var(--font-mono); font-weight: 600;
  font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
}
.stamp::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 5px currentColor; flex-shrink: 0;
}
.stamp.pending { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.stamp.approved { color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, transparent); }
.stamp.rejected { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }

/* ---- submission / data rows ---- */
.submission-row, .data-row {
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.submission-row { display: flex; align-items: center; gap: 12px; }
.submission-row:last-child, .data-row:last-child { border-bottom: none; }
.submission-row .meta, .data-row .top .meta { flex: 1; min-width: 0; font-family: var(--font-body); }
.submission-row .title { font-family: var(--font-ui); font-weight: 600; font-size: 14px; }
.submission-row .sub { font-size: 12.5px; color: var(--ink-dim); }
.submission-row .reason { font-size: 12.5px; color: var(--danger); margin-top: 4px; }

.data-row .top { display: flex; align-items: center; gap: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---- states ---- */
.empty-state, .error-state, .loading-state {
  font-family: var(--font-mono);
  text-align: left; padding: 24px 0; color: var(--ink-dim); font-size: 13.5px;
  letter-spacing: 0.01em;
}
.empty-state::before, .error-state::before, .loading-state::before { content: "// "; opacity: 0.6; }
.error-state { color: var(--danger); }
.error-text { color: var(--danger); font-size: 12.5px; margin-top: 8px; min-height: 1em; font-family: var(--font-mono); }
.success-text { color: var(--ok); font-size: 12.5px; margin-top: 8px; min-height: 1em; font-family: var(--font-mono); }

/* ---- gate: a clean access notice ---- */
.gate {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 22px 22px;
  text-align: left;
}
.gate p { font-family: var(--font-body); margin-bottom: 14px; }
.gate h2 {
  font-family: var(--font-display);
  border-bottom: none; padding-bottom: 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.gate h2::before {
  content: "SYSTEM";
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent-ink); background: var(--accent);
  border-radius: var(--radius-s);
  padding: 2px 7px;
}

/* ---- copyright notice: fixed team statement + per-work license chips ---- */
.copyright-notice {
  font-family: var(--font-body); font-size: 12.5px; color: var(--ink-dim);
  background: var(--panel-2);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 10px 14px;
  margin: 4px 0 16px;
}
.license-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.license-chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 11px; letter-spacing: 0.01em;
  padding: 3px 9px;
  border-radius: var(--radius-s);
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
}
.license-chip::before { content: "["; opacity: 0.6; margin-right: 1px; }
.license-chip::after { content: "]"; opacity: 0.6; margin-left: 1px; }
.license-chip.cc { color: var(--accent); border-color: var(--accent); }
.license-chip.cc:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); text-decoration: none; }

/* small lock badge overlaid on a work card's thumbnail when it carries a license restriction */
.license-badge {
  position: absolute; top: 7px; right: 7px;
  width: 21px; height: 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
  background: rgba(10, 14, 20, 0.62); color: #fff;
}
.badge-icon { width: 12px; height: 12px; flex-shrink: 0; }

/* soft deterrent for works marked "不可保存" — not a real technical block, just a nudge */
.no-save-img { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* small badge overlaid on a work card's thumbnail: article icon, or "N images" count */
.type-badge {
  position: absolute; top: 7px; left: 7px;
  min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--font-mono); font-size: 11px; line-height: 1;
  background: rgba(10, 14, 20, 0.62); color: #fff;
}

/* ---- 投稿表单:同人文章正文分块编辑器(段落 / 图片,可调整顺序) ---- */
.content-blocks-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.content-block {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px; background: var(--panel);
}
.content-block .textarea { flex: 1 1 auto; min-height: 80px; margin-bottom: 0; }
.content-block-img { flex: 1 1 auto; }
.content-block-img img {
  max-width: 100%; max-height: 160px; border-radius: var(--radius-s);
  border: 1px solid var(--line); display: block;
}
.content-block-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.content-block-actions button {
  width: 26px; height: 26px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink-dim);
  font-size: 12px; line-height: 1; cursor: pointer;
}
.content-block-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.content-block-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
.content-block-actions button.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.content-block-actions button.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ---- 同人文章正文(详情页) ---- */
.article-body { margin: 4px 0 18px; }
.article-body p { white-space: pre-wrap; line-height: 1.8; margin-bottom: 14px; }
.article-body img { width: 100%; max-height: none; object-fit: contain; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 14px; display: block; }

/* small preview of the current image when editing an existing submission */
.current-file-preview { margin-bottom: 8px; }
.current-file-preview img,
.current-file-preview video {
  max-width: 220px; max-height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

/* ---- character image gallery (public) ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.gallery-thumb {
  display: block; aspect-ratio: 1 / 1;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.gallery-thumb:hover { border-color: var(--accent); }

/* ---- admin: gallery manager ---- */
.gallery-editor {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 10px;
}
.gallery-editor:empty { display: none; }
.gallery-editor-item { position: relative; width: 74px; height: 74px; }
.gallery-editor-item img {
  width: 100%; height: 100%; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius-s); display: block;
}
.gallery-editor-item button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--danger); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ---- admin: repeatable custom section rows ---- */
.extra-section-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--panel);
}
.extra-section-row .input { margin-bottom: 8px; }
.extra-section-row .textarea { margin-bottom: 8px; min-height: 70px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab-btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px;
  padding: 8px 12px;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--ink-dim); cursor: pointer;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); background: var(--panel-2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- community framing: home hero + community badge ---- */
.hero-panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 15px 17px;
  margin-bottom: 5px;
}
.hero-panel h2 {
  font-family: var(--font-display);
  border-bottom: none; padding-bottom: 0; margin-bottom: 8px;
}
.hero-panel p { margin-bottom: 14px; color: var(--ink-dim); }
.hero-panel p:last-of-type { margin-bottom: 0; }

.community-badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 10.5px; letter-spacing: 0.04em;
  color: var(--accent-ink); background: var(--accent);
  border-radius: 3px; padding: 2px 7px;
  flex-shrink: 0;
}

/* ---- 首页社区公告:自定义 HTML + 动态效果 + 粒子背景特效 ---- */
.announcement-panel { position: relative; overflow: hidden; }
.announcement-body { position: relative; z-index: 1; }
.announcement-particles { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.announcement-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.announcement-content img { max-width: 100%; border-radius: var(--radius-s); }

@keyframes rmw-anim-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes rmw-anim-glow { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); } 50% { box-shadow: 0 0 22px 2px color-mix(in srgb, var(--accent) 45%, transparent); } }
@keyframes rmw-anim-shimmer { 0% { filter: brightness(1); } 50% { filter: brightness(1.12); } 100% { filter: brightness(1); } }
@keyframes rmw-anim-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
.announcement-panel.anim-float { animation: rmw-anim-float 3.6s ease-in-out infinite; }
.announcement-panel.anim-glow { animation: rmw-anim-glow 2.6s ease-in-out infinite; }
.announcement-panel.anim-shimmer { animation: rmw-anim-shimmer 2.2s ease-in-out infinite; }
.announcement-panel.anim-pulse { animation: rmw-anim-pulse 2.4s ease-in-out infinite; }

/* ---- 后台:公告编辑面板 ---- */
.announcement-editor { display: grid; gap: 18px; }
@media (min-width: 760px) {
  .announcement-editor { grid-template-columns: 1fr 220px; align-items: start; }
}
#aContent { min-height: 140px; font-family: var(--font-mono); font-size: 12.5px; }
#aPreview .announcement-panel { margin-bottom: 0; }
#aPreview:empty::before { content: "预览会在这里显示"; color: var(--ink-dim); font-size: 12.5px; }

/* ---- tag chips: quick facts on chapter / character records ---- */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.tag-chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--ink-dim); background: var(--panel-3);
  border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 3px 10px;
}
.tag-chip::before { content: "#"; opacity: 0.6; margin-right: 1px; }

/* ---- ARG 解密文档链接:章节详情页的醒目入口 ---- */
.arg-doc-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 18px; }
.arg-doc-link {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-ui); font-weight: 700; font-size: 13.5px;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-s);
  padding: 11px 14px;
}
.arg-doc-link:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
.arg-doc-link .arg-doc-icon { width: 15px; height: 15px; flex-shrink: 0; }
.arg-doc-link .arg-doc-sub { font-family: var(--font-mono); font-weight: 500; font-size: 11px; opacity: 0.75; margin-left: auto; }

/* ---- 社区补充资料卡片 ---- */
.supplement-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.supplement-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.supplement-title { font-family: var(--font-ui); font-weight: 700; font-size: 14.5px; }
.supplement-content { font-family: var(--font-body); font-size: 13.5px; white-space: pre-wrap; margin-bottom: 10px; }
.supplement-card .gallery-grid { margin-bottom: 10px; }
.supplement-card-foot {
  display: flex; justify-content: space-between; gap: 10px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim);
  padding-top: 8px; border-top: 1px dashed var(--line);
}

/* ---- admin: repeatable ARG doc-link rows (mirrors .extra-section-row) ---- */
.arg-doc-row {
  display: flex; gap: 8px; align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px;
  margin-bottom: 8px;
  background: var(--panel);
}
.arg-doc-row .input { margin-bottom: 0; }
.arg-doc-row button { flex-shrink: 0; }

/* ---- 自定义称号徽章(同人展卡片、评论区、个人主页弹窗共用,保持文字胶
   囊样式不变) ---- */
.title-badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 9.5px; letter-spacing: 0.02em;
  color: var(--ink); background: var(--panel-3);
  border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 1px 6px;
  flex-shrink: 0;
}

/* ---- 勋章(贡献者 / 优秀创作者):实际画出来的小圆章图标(image/icons/
   medal-*.png),不是纯 CSS 拼的渐变圆点,所以不会显得单薄或者像随手贴
   了个符号上去。不跟着站点亮/暗主题变色。点击会弹出勋章详情(见
   profile-popup.js 的 showBadgeInfo)。 ---- */
.medal-shape {
  display: inline-block;
  flex-shrink: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.medal-shape.medal-contributor { background-image: url('../image/icons/medal-contributor.png'); }
.medal-shape.medal-excellent_creator { background-image: url('../image/icons/medal-excellent-creator.png'); }

.badge-medal {
  width: 16px; height: 16px;
  border: none; padding: 0; cursor: pointer;
  vertical-align: middle;
  background-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.badge-info { text-align: center; padding: 2px 2px 0; }
.badge-info-medal { width: 52px; height: 52px; margin: 2px auto 12px; }
.badge-info-name { font-family: var(--font-ui); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.badge-info-desc { font-family: var(--font-body); font-size: 12px; color: var(--ink-dim); line-height: 1.6; }

/* ---- 作者小卡片:头像 + 用户名 + 徽章,点了弹出对方主页 ---- */
.author-chip { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; vertical-align: middle; }
.author-chip:hover .author-name { text-decoration: underline; }
.author-avatar {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 8.5px; color: var(--ink-dim);
}
.author-name { font-weight: inherit; }

/* ---- 侧边栏底部:登录后用头像代替"退出登录" ---- */
.sidebar-footer-link .icon.avatar-icon {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 8.5px; color: var(--ink-dim);
}

/* ---- 个人主页小弹窗:贴着触发元素定位的小卡片,不是全屏大弹层 ----
   .profile-popup-scrim 是透明的整屏点击捕获层,只用来接"点旁边关闭",
   不会像 .sidebar-scrim / 对话框那样把画面整个压暗。 */
.profile-popup-scrim { position: fixed; inset: 0; z-index: 90; background: transparent; }
.profile-popup {
  position: fixed; z-index: 91;
  width: 272px; max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px); overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 44px var(--shadow-color);
  padding: 18px 16px 14px;
  text-align: center;
  opacity: 0; transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.profile-popup.is-open { opacity: 1; transform: translateY(0); }
.profile-popup-close {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel-3); color: var(--ink-dim);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.profile-popup-avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 4px auto 10px;
  background: var(--panel-3) center/cover no-repeat;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 19px; color: var(--ink-dim);
}
.profile-popup-name { font-family: var(--font-ui); font-weight: 700; font-size: 14.5px; }
.profile-popup-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.profile-popup-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-dim); margin-top: 6px; letter-spacing: 0.03em; }
.profile-popup-bio { font-family: var(--font-body); font-size: 12px; color: var(--ink-dim); margin-top: 10px; white-space: pre-wrap; }
.profile-popup-bio.empty { font-style: italic; opacity: 0.7; }
.profile-popup-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.profile-popup-actions .btn { width: 100%; }
.profile-popup-actions .hint { font-size: 11px; }
.profile-popup-more {
  display: block; margin-top: 10px;
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .grid { gap: 12px; }
  .infobox { max-width: none; }
}
