/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1e2d4d;
  --navy-mid: #253860;
  --navy-light: #2d4878;
  --sidebar-bg: #1a2b4a;
  --sidebar-active: #2d4f8a;
  --sidebar-hover: #253f70;
  --accent: #4a7bbd;
  --page-bg: #e8edf5;
  --card-bg: #ffffff;
  --border: #c8d4e8;
  --text: #1a1f36;
  --text-muted: #6b7c9e;
  --header-h: 56px;
  --sidebar-w: 192px;
  --detail-w: 320px;
}

html, body { height: 100%; font-family: 'Noto Sans SC', 'Noto Sans JP', sans-serif; background: var(--page-bg); color: var(--text); overflow: hidden; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ===== HEADER ===== */
#main-header {
  height: var(--header-h);
  display: flex;
  flex-shrink: 0;
  z-index: 100;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-left {
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 40px 0 12px;
  min-width: 220px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 28px) 100%, 0 100%);
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.header-back-btn {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 18px; cursor: default; padding: 4px 6px; border-radius: 4px;
  line-height: 1; flex-shrink: 0;
}
.header-back-btn:not(:disabled) { color: white; cursor: pointer; }
.header-back-btn:not(:disabled):hover { background: rgba(255,255,255,0.15); }

.header-title-link { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.header-title-link:hover .header-title { text-decoration: underline; }
.header-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.6); flex-shrink: 0; }
.header-title { color: white; font-size: 18px; font-weight: 700; letter-spacing: 0.05em; white-space: nowrap; }

.header-right {
  flex: 1;
  background: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: inset 0 1px 0 var(--border);
}

#header-info { font-size: 14px; color: var(--navy); font-weight: 600; flex: 1; }
#header-buttons { display: flex; gap: 8px; }

.header-icon-btn {
  background: none; border: 1px solid var(--border); color: var(--navy-mid);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.header-icon-btn:hover { background: var(--page-bg); }

/* ===== VIEWS ===== */
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }

/* ===== HOME VIEW ===== */
#home-view { flex-direction: row; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-tab {
  display: flex; align-items: center; padding: 12px 16px;
  color: rgba(255,255,255,0.7); font-size: 14px; cursor: pointer;
  border-left: 3px solid transparent; transition: all 0.15s;
  gap: 8px; user-select: none;
}
.sidebar-tab:hover { background: var(--sidebar-hover); color: white; }
.sidebar-tab.active {
  background: var(--sidebar-active);
  color: white; border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-tab-arrow { margin-left: auto; font-size: 10px; opacity: 0.5; transition: transform 0.15s ease; }
.sidebar-tab-arrow.open { transform: rotate(90deg); }
.sidebar-group { display: flex; flex-direction: column; }
.sidebar-tab-group { border-left-color: transparent; }
.sidebar-subtabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 12px 8px 24px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.14);
}
.sidebar-subtab {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,0.68);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.sidebar-subtab:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar-subtab.active {
  background: rgba(255,255,255,0.14);
  color: white;
  font-weight: 600;
}

/* Game subtab bar (mobile only, between sidebar and content) */
#game-subtab-bar {
  display: none;
  position: absolute;
  z-index: 220;
  padding: 0;
  background: transparent;
  border: none;
}
.game-subtab-menu {
  width: 102px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-radius: 10px;
  background: rgba(24, 45, 84, 0.96);
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
  overflow: hidden;
}
.game-subtab-btn {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.game-subtab-btn + .game-subtab-btn {
  border-top: 1px solid rgba(255,255,255,0.14);
}
.game-subtab-btn:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.game-subtab-btn.active {
  background: rgba(91, 144, 219, 0.35);
  color: white;
  font-weight: 600;
}
.sidebar-separator { height: 1px; background: rgba(255,255,255,0.12); margin: 6px 12px; }

/* Chapter panel */
#chapter-panel {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; border-right: 1px solid var(--border);
}

/* Subtab bar (手游 secondary tabs) */
#subtab-bar,
#stage-series-bar {
  background: var(--panel-bg, #f7f8fc);
  border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 6px 10px; flex-shrink: 0;
}
#subtab-bar .subtab-btn,
#stage-series-bar .subtab-btn {
  padding: 5px 13px; font-size: 13px; border: none; background: none;
  border-radius: 5px; cursor: pointer; color: var(--text-muted, #888);
  font-weight: 500; transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
#subtab-bar .subtab-btn:hover,
#stage-series-bar .subtab-btn:hover { background: rgba(0,0,0,0.06); color: var(--navy); }
#subtab-bar .subtab-btn.active,
#stage-series-bar .subtab-btn.active {
  background: var(--accent); color: #fff; font-weight: 700;
}

/* Filter bar */
#filter-bar {
  background: white; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  flex-shrink: 0;
}
#filter-bar label { font-size: 12px; color: var(--text-muted); }
#filter-bar select {
  font-size: 13px; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 5px; background: white; color: var(--text); cursor: pointer;
}
#filter-bar input {
  font-size: 13px; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 5px; background: white; color: var(--text);
  min-width: 120px;
}
.filter-group { display: flex; align-items: center; gap: 5px; }

/* Grid search bar */
#grid-search-bar {
  display: flex; align-items: center; gap: 0;
  padding: 7px 14px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#grid-search-input {
  flex: 1; padding: 5px 10px;
  border: 1px solid var(--border); border-right: none;
  border-radius: 5px 0 0 5px;
  font-size: 13px; font-family: inherit;
  outline: none; background: var(--bg); color: var(--text);
  transition: border-color 0.15s;
}
#grid-search-input:focus { border-color: var(--accent); }
#grid-search-btn {
  padding: 5px 10px;
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 5px 5px 0;
  background: var(--navy); color: white;
  cursor: pointer; display: flex; align-items: center;
  transition: background 0.15s;
}
#grid-search-btn:hover { background: var(--navy-mid); }

#mobile-grid-collapse-wrap {
  display: none;
  position: relative;
  height: 0;
  margin: 0 14px 10px;
  flex-shrink: 0;
}

.mobile-grid-collapse-btn {
  position: absolute;
  right: 0;
  top: 0;
  transform: translateY(-26%);
  min-width: 34px;
  height: 24px;
  border: 1px solid #9db0ca00;
  border-radius: 11px;
  background: #fff;
  color: #6f86a7;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 5px rgba(37,56,96,0.13), 0 0 0 1px rgba(157,176,202,0.2) inset;
  transition: transform 0.22s ease, filter 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.mobile-grid-collapse-btn:hover { filter: brightness(0.98); border-color: #8fa5c3; color: #5f789b; }
.mobile-grid-collapse-btn:active { transform: translateY(-40%); }
.mobile-grid-collapse-btn.folded {
  border-color: #8fa5c3;
  color: #5f789b;
  box-shadow: 0 1px 4px rgba(37,56,96,0.1), 0 0 0 1px rgba(157,176,202,0.28) inset;
}

/* Story grid */
#story-grid {
  flex: 1; overflow-y: auto; padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  grid-auto-rows: min-content;
  gap: 6px;
  align-content: start;
}

/* Group headers and count span all columns in grid */
.story-group-wrapper {
  grid-column: 1 / -1;
}

.story-card {
  display: flex; flex-direction: column; align-items: stretch;
  background: white; border-radius: 8px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.story-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(74,123,189,0.15); }
.story-card.selected { border-color: var(--accent); background: #f0f5ff; }

.story-card-banner {
  width: 100%; aspect-ratio: 3/2; object-fit: cover;
  display: block; background: var(--border);
}
.story-card-banner-card {
  aspect-ratio: 4 / 3;
}
.story-card-banner-placeholder {
  width: 100%; aspect-ratio: 3/2;
  background: linear-gradient(135deg, var(--navy-light), var(--accent));
}

.card-grid-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  grid-auto-rows: min-content;
  gap: 6px;
}

.card-pager {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0 10px;
}

.card-pager-btn {
  min-width: 30px;
  height: 28px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  color: var(--navy-mid);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.card-pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.card-pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.card-pager-text {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
}

.card-detail-cover-wrap {
  padding: 12px 0 6px;
  display: flex;
  justify-content: center;
}

.card-detail-cover {
  width: min(92%, 260px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.card-detail-inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.card-detail-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: #ebf2ff;
  color: var(--navy-mid);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.card-detail-tag.clickable {
  cursor: pointer;
  background: #dfeafe;
}

.card-detail-tag.clickable:hover {
  filter: brightness(0.96);
}

.story-card-info { min-width: 0; padding: 6px 8px 4px; }
.story-card-chapter { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.story-card-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-card-date { font-size: 11px; color: var(--text-muted); padding: 0 8px 6px; white-space: nowrap; }

.story-group-header {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 4px 4px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.story-group-header:hover .story-group-label { color: var(--accent); }
.story-group-arrow { font-size: 10px; color: var(--text-muted); transition: transform 0.2s; width: 12px; text-align: center; }
.story-group-arrow.collapsed { transform: rotate(-90deg); }
.story-group-label { font-size: 12px; font-weight: 600; color: var(--text-muted); flex: 1; }
.story-group-count { font-size: 11px; color: var(--text-muted); }

.story-count { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); padding: 8px 12px; }

/* ===== INTRO GRID ===== */
.intro-garden-header {
  grid-column: 1 / -1;
  font-size: 15px; font-weight: 800; color: var(--navy);
  padding: 8px 6px 6px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 4px; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.intro-garden-header:hover { color: var(--accent); }
.intro-garden-header-collab {
  margin-top: 12px;
  border-bottom-color: #a0855b;
  color: #7a5c2e;
}
.intro-garden-header-collab:hover { color: #a0855b; }
.intro-legion-header {
  grid-column: 1 / -1;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 5px 6px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none;
}
.intro-legion-header:hover { color: var(--accent); }
.intro-collapse-arrow {
  font-size: 9px; transition: transform 0.18s; display: inline-block;
}
.intro-garden-header.collapsed .intro-collapse-arrow,
.intro-legion-header.collapsed .intro-collapse-arrow { transform: rotate(-90deg); }
.intro-chara-row {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 4px 2px 10px;
}

/* Card size based on 224:473 ratio, width=106px → height=224px */
.chara-block {
  position: relative;
  width: 106px;
  cursor: pointer; border-radius: 8px;
  overflow: hidden; border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.chara-block:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(74,123,189,0.25); }
.chara-cover {
  width: 106px; height: 224px; object-fit: cover; object-position: top;
  display: block;
}

/* Collab intro cards use square CharacterJobIconM art */
.chara-block-collab {
  width: 118px;
  background: #fff;
}
.chara-cover-collab {
  width: 118px;
  height: 118px;
  object-fit: contain;
  object-position: center;
  background: #fff;
  padding: 8px;
  box-sizing: border-box;
}
.chara-block-collab .chara-nameplate {
  position: static;
  transform: translateY(0);
  padding: 8px 6px;
  background: linear-gradient(to bottom, rgba(18,32,62,0.92), rgba(18,32,62,0.98));
}

/* Nameplate: hidden by default, slides up on hover (desktop) */
.chara-nameplate {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 20px 6px 8px;
  background: linear-gradient(to bottom, transparent 0%, rgba(18,32,62,0.82) 38%, rgba(18,32,62,0.96) 100%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transform: translateY(100%);
  transition: transform 0.22s ease;
}
@media (hover: hover) {
  .chara-block:hover .chara-nameplate { transform: translateY(0); }
}
@media (hover: none) {
  .chara-nameplate { transform: translateY(0); }
}
.chara-name-jp {
  font-size: 9px; color: rgba(255,255,255,0.55);
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center;
}
.chara-name-cn {
  font-size: 12px; font-weight: 700; color: #e8f0ff;
  letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center;
  text-shadow: 0 0 8px rgba(74,123,189,0.7);
}

/* CV row in detail */
.detail-cv-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.detail-cv-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.06em; flex-shrink: 0;
}
.tag-cv {
  background: #e8edf8; color: var(--navy-mid); font-size: 11px;
}

/* Detail panel */
#detail-panel {
  width: var(--detail-w); flex-shrink: 0;
  background: white; overflow-y: auto;
  display: flex; flex-direction: column;
}

.detail-placeholder {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px; text-align: center; padding: 24px;
}

.detail-title-bar {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f0f4ff 0%, #fff 60%);
}
.detail-title {
  font-size: 22px; font-weight: 800; color: var(--navy);
  letter-spacing: 0.04em;
  position: relative; display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.detail-title::after {
  content: '';
  display: block; margin-top: 5px;
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--navy), transparent);
  width: 100%;
}

.detail-banner {
  width: 100%; aspect-ratio: 3/2; object-fit: cover;
  background: var(--border);
}

/* Intro portrait cover (224:473) */
.intro-detail-cover-wrap {
  display: flex;
  justify-content: center;
  background: #fff;
  padding: 16px 0 8px;
}
.intro-detail-cover {
  width: auto;
  max-width: 60%;
  aspect-ratio: 224 / 473;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* Collab detail cover: square icon style */
.intro-detail-cover-wrap-collab {
  padding: 14px 0 6px;
}
.intro-detail-cover-collab {
  width: min(260px, 62%);
  max-width: 260px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  box-sizing: border-box;
}

.detail-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.detail-meta { font-size: 12px; color: var(--text-muted); line-height: 1.7; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.detail-meta-left span { display: block; }

.tag {
  display: inline-block;
  font-size: 10px; font-weight: 600; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.04em; white-space: nowrap;
  vertical-align: middle;
  user-select: none;
}
.tag-ichiryu  { background: #e8dff7; color: #6b3fa0; }
.tag-elensuge { background: #d6eafc; color: #2060a0; }
.tag-kaminiwa { background: #fef3c7; color: #92610a; }
.tag-alfheim  { background: #d0d9e8; color: #2e3f5c; }
.tag-other    { background: #d4f0e0; color: #2a6645; }
.tag-multi    { background: #e5e5e5; color: #777; }
.tag-collab   { background: #fde8f0; color: #b0306a; }
.tag:not(.tag-multi):not(.tag-collab) { cursor: pointer; }
.tag:not(.tag-multi):not(.tag-collab):hover { filter: brightness(0.92); }
.tag-collab { cursor: default; }
.detail-flag-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 2px;
  color: #ccc; border-radius: 6px; transition: color 0.15s;
  display: flex; align-items: center;
}
.detail-flag-btn:hover { color: #aaa; }
.detail-flag-btn.done { color: var(--accent); }
.detail-flag-btn.done:hover { color: var(--navy-light); }

.detail-progress { font-size: 12px; color: var(--text-muted); }

.card-reading-flag { display: inline-flex; vertical-align: middle; margin-left: 5px; color: var(--accent); }

.detail-memoria-title {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0;
}
.detail-memoria-title-line {
  flex: 1; height: 1px;
  background: linear-gradient(to var(--dir, right), rgba(60,120,220,0.65), transparent);
}
.detail-memoria-title-line-left { --dir: right; }
.detail-memoria-title-line-right { --dir: left; }
.detail-memoria-title-text {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 18px; font-weight: 700;
  color: #111;
  letter-spacing: 0.05em;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: center;
}

.detail-buttons { display: flex; flex-direction: column; gap: 8px; }

.btn-bilibili {
  background: #00a1d6; color: white; border: none;
  padding: 9px 14px; border-radius: 7px; font-size: 13px;
  cursor: pointer; font-weight: 600; text-align: center;
  transition: background 0.15s; text-decoration: none; display: block;
}
.btn-bilibili:hover { background: #0090c0; }

.btn-read {
  background: var(--accent); color: white; border: none;
  padding: 9px 14px; border-radius: 7px; font-size: 14px;
  cursor: pointer; font-weight: 700; text-align: center;
  transition: background 0.15s;
}
.btn-read:hover { background: var(--navy-light); }
.detail-btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.detail-btn-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.detail-btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.detail-btn-text {
  line-height: 1;
}

.detail-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.detail-intro-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-intro-text {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  text-align: justify;
}

.detail-outline { font-size: 13px; line-height: 1.8; color: var(--text); }

/* Character tags for memoria */
.character-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}

.character-tag {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related-item {
  display: flex; gap: 10px; align-items: stretch;
  border: 1px solid var(--border); border-radius: 7px; overflow: hidden;
  margin-bottom: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.related-item.clickable { cursor: pointer; }
.related-item.clickable:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(74,123,189,0.15); }
.related-banner {
  width: 80px; flex-shrink: 0; object-fit: cover;
  background: var(--border);
}
.related-info {
  flex: 1; padding: 8px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.related-relation { font-size: 11px; color: var(--text-muted); }
.related-row { display: flex; align-items: center; gap: 6px; }
.related-name { font-size: 14px; font-weight: 600; flex: 1; }

.related-cardicon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.related-cardicon-btn {
  width: 86px;
  height: 86px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.related-cardicon-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.related-cardicon-img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

/* ===== READING VIEW ===== */
#reading-view { flex-direction: row; position: relative; overflow: hidden; }

/* Episode selector */
#episode-selector {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow-y: auto;
  padding: 8px 0;
  position: relative; z-index: 1;
}
#episode-selector.sidebar-hidden {
  display: none;
}
#reading-view.no-sidebar {
  --sidebar-w: 0px;
}
#reading-view.sidebar-collapsed {
  --sidebar-w: 32px;
}
#reading-view.sidebar-collapsed #episode-selector {
  overflow: hidden;
}
#reading-view.sidebar-collapsed .episode-div {
  display: none;
}

.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 40px;
  background: rgba(255,255,255,0.06); border: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7); font-size: 13px;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.sidebar-collapse-btn:hover { color: white; background: rgba(255,255,255,0.15); }
#reading-view.sidebar-collapsed .sidebar-collapse-btn {
  height: 100%;
  border-bottom: none;
  border-right: 2px solid var(--accent);
  background: rgba(74,123,189,0.15);
  color: rgba(255,255,255,0.9);
  writing-mode: vertical-rl;
  font-size: 11px;
  letter-spacing: 0.2em;
}

.episode-div { display: contents; }
.episode-header {
  display: flex; align-items: center; padding: 11px 14px;
  color: rgba(255,255,255,0.85); font-size: 13px; font-weight: 600;
  cursor: pointer; background: rgba(255,255,255,0.05);
  border-left: 3px solid transparent; gap: 6px;
  transition: background 0.15s;
}
.episode-header:hover { background: rgba(255,255,255,0.1); }
.episode-header.active-ep { border-left-color: var(--accent); color: white; }
.episode-toggle { font-size: 10px; margin-left: auto; transition: transform 0.2s; }
.episode-header.open .episode-toggle { transform: rotate(90deg); }

.episode-sections { display: none; }
.episode-sections.open { display: block; }

.section-item {
  padding: 8px 14px 8px 24px; font-size: 12px;
  color: rgba(255,255,255,0.6); cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.section-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.section-item.active-section {
  color: white; background: rgba(74,123,189,0.2);
  border-left-color: var(--accent); font-weight: 600;
}

/* Story area */
#story-area {
  flex: 1; position: relative; overflow-y: scroll;
  min-height: 0; min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #3a5278 #b8cde8;
  z-index: 1;
}
#story-area::-webkit-scrollbar { width: 8px; }
#story-area::-webkit-scrollbar-track { background: #b8cde8; border-radius: 4px; }
#story-area::-webkit-scrollbar-thumb { background: #3a5278; border-radius: 4px; }
#story-area::-webkit-scrollbar-thumb:hover { background: #2d4060; }

#story-bg {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 0;
  background-color: #1a1f36;
  overflow: hidden;
}
#story-bg::before {
  content: '';
  position: absolute; top: -5%; left: -5%; right: -5%; bottom: -5%;
  background: inherit;
  background-size: 140% auto;
  background-position: left bottom;
  filter: blur(3px) brightness(0.75);
  transition: background-image 0.6s ease;
}

#story-content {
  position: relative; z-index: 1;
  padding: 24px 20px 80px;
  max-width: 820px; margin: 0 auto;
}

/* Row divs */
.row-chapter {
  text-align: center; padding: 40px 16px 32px;
  color: white;
}
.row-chapter .jp-text { font-size: 11px; opacity: 0.65; margin-bottom: 6px; letter-spacing: 0.12em; }
.row-chapter .cn-text {
  font-size: 26px; font-weight: 800; letter-spacing: 0.08em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.row-chapter .cn-text::before,
.row-chapter .cn-text::after {
  content: '';
  flex: 1; height: 2px; max-width: 120px;
  background: linear-gradient(to var(--d, right), transparent 0%, rgba(255,255,255,0.6) 100%);
}
.row-chapter .cn-text::before { --d: right; }
.row-chapter .cn-text::after  { --d: left;  }

.row-telop {
  display: flex; align-items: center; gap: 14px;
  padding: 40px 20px 36px; margin: 8px 0;
}
.telop-deco {
  flex: 1; height: 2px;
  background: linear-gradient(to var(--dir, right),
    transparent 0%, rgba(255,255,255,0.25) 30%, rgba(255,255,255,0.7) 100%);
}
.telop-deco-left  { --dir: right; }
.telop-deco-right { --dir: left;  }
.telop-text {
  flex-shrink: 0;
  font-size: 26px; font-weight: 800;
  color: #fff;
  letter-spacing: 0.12em;
  text-shadow: 0 0 24px rgba(255,255,255,0.35), 0 2px 12px rgba(0,0,0,0.7);
  text-align: center;
}

.row-narration {
  padding: 14px 24px; margin: 6px 0;
  font-style: italic; text-align: center;
  background: rgba(0,0,0,0.35);
  border-radius: 4px;
}
.row-narration .jp-text { font-size: 11px; color: rgba(255,255,255,0.55); margin-bottom: 4px; }
.row-narration .cn-text { font-size: 15px; color: rgba(255,255,255,0.9); line-height: 1.7; }

.row-skill {
  display: flex; justify-content: center; padding: 10px 0; margin: 4px 0;
}
.skill-body {
  display: inline-flex; flex-direction: column; gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgb(255 255 255);
  box-shadow: 0px 0px 2px white;
  border-radius: 4px;
  min-width: 160px; max-width: 320px;
}
.skill-header {
  display: flex; align-items: center; gap: 8px;
  text-shadow: 0 0 2px #c8c8c8;
}
.skill-line {
  flex: 1; height: 1px;
  box-shadow: 0 0 2px #c8c8c8;
  background: linear-gradient(to var(--dir, right), rgba(60,120,220,0.7), transparent);
}
.skill-line-left { --dir: right; }
.skill-line-right { --dir: left; }
.skill-label {
  font-size: 10px; letter-spacing: 0.2em;
  color: rgba(60,120,220,0.8); white-space: nowrap;
}
.skill-content {
  display: flex; align-items: center; gap: 10px;
}
.skill-avatar-wrap { flex-shrink: 0; }
.skill-avatar-wrap .avatar-img,
.skill-avatar-wrap .avatar-placeholder {
  width: 40px; height: 40px; border-radius: 50%;
}
.skill-name { text-align: left; }
.skill-cn { font-size: 15px; font-weight: 600; color: #1a1a2e; letter-spacing: 0.08em; text-shadow: 0 0 2px #b5b5b5; }

.row-dialogue {
  display: flex; gap: 14px; padding: 10px 0; margin: 4px 0;
  align-items: stretch;
}

.avatar-col {
  width: 68px; flex-shrink: 0;
  display: flex; align-items: flex-start; padding-top: 4px;
}
.avatar-img {
  width: 68px; height: 68px; border-radius: 8px;
  object-fit: cover; object-position: top;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.avatar-img.avatar-has-setting {
  cursor: pointer;
  border-color: rgba(100,180,255,0.5);
}
.avatar-img.avatar-has-setting:hover {
  border-color: #64b4ff;
  box-shadow: 0 0 0 3px rgba(100,180,255,0.35), 0 2px 8px rgba(0,0,0,0.3);
  transform: scale(1.06);
  background: rgba(100,180,255,0.1);
}
.avatar-placeholder { width: 68px; height: 68px; }

.dialogue-col {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,0.88);
  border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-left: 3px solid var(--accent);
}
.dialogue-name {
  font-size: 12px; font-weight: 700; color: var(--navy-mid);
  margin-bottom: 4px; letter-spacing: 0.03em;
}
.dialogue-jp { font-size: 11px; color: rgba(0,0,0,0.45); margin-bottom: 4px; line-height: 1.6; }
.dialogue-cn { font-size: 15px; color: var(--text); line-height: 1.75; }
.intro-voice-row {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap;
}
.intro-voice-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; gap: 4px; flex-shrink: 0;
  background: rgba(91,141,217,0.10); border: 1px solid rgba(91,141,217,0.25);
  border-radius: 12px; cursor: pointer; color: var(--accent);
  font-size: 11px; transition: background 0.15s, color 0.15s;
}
.intro-voice-btn:hover:not(:disabled) { background: rgba(91,141,217,0.22); }
.intro-voice-btn.playing { color: var(--navy); background: rgba(91,141,217,0.20); }
.intro-voice-btn.no-voice { color: #bbb; border-color: #ddd; cursor: default; }
.intro-voice-btn:disabled { opacity: 0.5; cursor: default; }
.intro-voice-progress {
  display: flex; align-items: center; gap: 5px; flex: 1; min-width: 80px;
}
.intro-voice-bar {
  flex: 1; height: 3px; background: rgba(91,141,217,0.2); border-radius: 2px; cursor: pointer;
  position: relative;
}
.intro-voice-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 2px;
  transition: width 0.1s linear;
}
.intro-voice-time {
  font-size: 10px; color: var(--text-light); white-space: nowrap; min-width: 32px;
}
@keyframes voice-pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* Background marker */
.bg-marker { height: 0; overflow: hidden; pointer-events: none; }

/* Memoria card display */
.row-memoria {
  display: flex; justify-content: center; align-items: center;
  padding: 20px 0; margin: 16px 0;
  border-radius: 12px;
}

.memoria-img {
  max-width: 100%; max-height: 400px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  object-fit: contain;
}

.memoria-placeholder {
  width: 200px; height: 200px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.3);
  border-radius: 10px;
  color: rgba(0,0,0,0.5);
  font-size: 14px;
  text-align: center;
}

/* Section end marker */
.section-end {
  text-align: center; padding: 40px 20px; color: rgba(255,255,255,0.4);
  font-size: 13px; letter-spacing: 0.1em;
}
.section-end.fin {
  font-size: 28px; font-weight: 700; color: rgba(255,255,255,0.8);
  letter-spacing: 0.2em;
}

/* Loading indicator */
.loading-msg {
  text-align: center; padding: 40px; color: rgba(255,255,255,0.6); font-size: 14px;
}

/* ===== MOBILE READING NAV ===== */
#mobile-reading-nav {
  display: none;
  position: fixed; top: var(--header-h); left: 0; right: 0;
  background: var(--sidebar-bg); z-index: 50;
  padding: 8px 12px; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
#mobile-reading-nav select {
  flex: 1;
  background: var(--navy-mid);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.6)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
#mobile-reading-nav select option {
  background: var(--navy-mid);
  color: white;
}

/* ===== MODAL (mobile detail) ===== */
@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes modalFadeIn {
  from { background: rgba(0,0,0,0); }
  to   { background: rgba(0,0,0,0.5); }
}

#detail-modal {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
}
#detail-modal.open {
  display: flex; align-items: flex-end;
  animation: modalFadeIn 0.25s ease forwards;
}
.modal-inner {
  background: white; width: 100%; max-height: 88vh;
  border-radius: 16px 16px 0 0; overflow-y: auto;
}
#detail-modal.open .modal-inner {
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-header {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--border); gap: 10px; position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header .detail-title { flex: 1; font-size: 17px; }
.modal-close {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  #story-grid { grid-template-columns: repeat(2, 1fr); }

  #home-view { flex-direction: column; position: relative; }

  #sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 6px 8px; gap: 6px; flex-shrink: 0;
    height: auto;
  }
  .sidebar-tab {
    flex-direction: column; padding: 6px 12px; border-left: none;
    border-bottom: 3px solid transparent; white-space: nowrap;
    font-size: 12px; border-radius: 6px;
  }
  .sidebar-tab.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .sidebar-tab-arrow { display: none; }
  .sidebar-group {
    min-width: 102px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
  }
  .sidebar-tab-group {
    flex-direction: row;
    align-items: center;
    border-bottom: none;
  }
  .sidebar-tab-group .sidebar-tab-arrow {
    display: inline-flex;
  }
  .sidebar-subtabs {
    margin: 0 6px 6px;
    padding: 6px 0 0;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.12);
  }
  .sidebar-subtab {
    min-height: 28px;
    padding: 6px 8px;
    font-size: 12px;
  }

  #subtab-bar,
  #stage-series-bar {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    padding: 5px 8px; gap: 4px;
    -webkit-overflow-scrolling: touch;
  }
  #subtab-bar .subtab-btn,
  #stage-series-bar .subtab-btn { font-size: 12px; padding: 4px 11px; }

  #chapter-panel { flex: 1; min-height: 0; }
  #detail-panel { display: none; }

  #home-view.mobile-grid-collapse-enabled #grid-search-bar {
    border-bottom: 1px solid #d9e3f1;
    box-shadow: inset 0 -1px 0 rgba(136,156,183,0.28);
  }

  #home-view.mobile-grid-collapse-enabled #mobile-grid-collapse-wrap {
    display: flex;
    background: transparent;
  }

  #home-view.mobile-grid-collapse-enabled #sidebar,
  #home-view.mobile-grid-collapse-enabled #game-subtab-bar,
  #home-view.mobile-grid-collapse-enabled #subtab-bar,
  #home-view.mobile-grid-collapse-enabled #stage-series-bar,
  #home-view.mobile-grid-collapse-enabled #filter-bar,
  #home-view.mobile-grid-collapse-enabled #grid-search-bar {
    transform: translateY(0);
    opacity: 1;
    transition:
      max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.24s ease,
      transform 0.24s ease,
      padding 0.24s ease,
      margin 0.24s ease,
      border-width 0.24s ease;
  }

  #home-view.mobile-grid-collapse-enabled #sidebar { max-height: 76px; }
  #home-view.mobile-grid-collapse-enabled #subtab-bar,
  #home-view.mobile-grid-collapse-enabled #stage-series-bar,
  #home-view.mobile-grid-collapse-enabled #grid-search-bar { max-height: 64px; }
  #home-view.mobile-grid-collapse-enabled #filter-bar { max-height: 170px; }

  #home-view.mobile-grid-folded #sidebar,
  #home-view.mobile-grid-folded #game-subtab-bar,
  #home-view.mobile-grid-folded #subtab-bar,
  #home-view.mobile-grid-folded #stage-series-bar,
  #home-view.mobile-grid-folded #filter-bar,
  #home-view.mobile-grid-folded #grid-search-bar {
    max-height: 0 !important;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    border-top-width: 0 !important;
    border-bottom-width: 0 !important;
  }

  /* Hide site title when header-info is populated */
  #main-header.has-info .header-title { display: none; }
  #main-header.has-info .header-left { min-width: unset; padding-right: 28px; }

  /* Reading mobile */
  #reading-view { flex-direction: column; }
  #episode-selector { display: none; }
  #mobile-reading-nav { display: flex; }
  #story-area { margin-top: 52px; }
  /* Extend bg upward to cover the area behind mobile-reading-nav */
  #story-bg { top: -450px; }

  #reading-view.no-mobile-nav #mobile-reading-nav { display: none; }
  #reading-view.no-mobile-nav #story-area { margin-top: 0; }

  #story-bg::before {
    background-size: cover;
    background-position: center;
  }

  .row-dialogue { gap: 10px; }
  .avatar-img, .avatar-placeholder { width: 56px; height: 56px; }
  .avatar-col { width: 56px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  :root { --detail-w: 260px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.35); }

/* ===== MENU DROPDOWN ===== */
.menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: white; border: 1px solid var(--border);
  border-radius: 8px; min-width: 130px; z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: none; flex-direction: column; overflow: hidden;
}
.menu-dropdown.open { display: flex; }
.menu-item {
  padding: 11px 16px; font-size: 14px; color: var(--text);
  cursor: pointer; border: none; background: none;
  text-align: left; transition: background 0.12s;
}
.menu-item:hover { background: var(--page-bg); }
#menu-container { position: relative; }

.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.menu-item-cache-wrap { position: relative; }
.menu-item-cache { color: #c0392b; width: 100%; }
.menu-item-cache:hover { background: rgba(192,57,43,0.07); }
.menu-cache-tooltip {
  display: none;
  position: absolute;
  right: calc(100% + 8px); top: 0;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  white-space: pre;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 400;
  min-width: 120px;
  line-height: 1.7;
}
.menu-item-cache-wrap:hover .menu-cache-tooltip { display: block; }

/* ===== SEARCH VIEW ===== */
#search-view { flex-direction: column; overflow: hidden; }
#search-container {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  max-width: 860px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}
#search-input-row {
  display: flex; gap: 8px; align-items: center;
}
#search-input {
  flex: 1; padding: 10px 14px; font-size: 15px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: white; color: var(--text); outline: none;
  transition: border-color 0.15s;
}
#search-input:focus { border-color: var(--accent); }
#search-btn {
  padding: 9px 14px; background: var(--accent); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; transition: background 0.15s;
}
#search-btn:hover { background: var(--navy-light); }
.search-loading { color: var(--text-muted); font-size: 14px; padding: 24px 0; text-align: center; }
.search-count { font-size: 12px; color: var(--text-muted); }

.search-result-item {
  background: white; border-radius: 8px; padding: 12px 14px;
  cursor: pointer; border: 1.5px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  display: flex; flex-direction: column; gap: 5px;
}
.search-result-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(74,123,189,0.15); }
.result-meta { display: flex; gap: 8px; align-items: center; }
.result-story { font-size: 12px; font-weight: 700; color: var(--navy-mid); }
.result-label {
  font-size: 11px; color: white; background: var(--accent);
  padding: 1px 7px; border-radius: 10px;
}
.result-jp { font-size: 11px; color: rgba(0,0,0,0.4); line-height: 1.5; }
.result-cn { font-size: 14px; color: var(--text); line-height: 1.6; }
mark { background: #ffe066; color: inherit; border-radius: 2px; padding: 0 1px; }

#search-pagination { display: flex; gap: 6px; flex-wrap: wrap; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--border); background: white; color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: all 0.12s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-ellipsis { display: flex; align-items: center; padding: 0 4px; color: var(--text-muted); font-size: 14px; }

/* ===== UPLOAD VIEW ===== */
#upload-view { flex-direction: column; overflow: hidden; }
#upload-container {
  flex: 1; overflow-y: auto; padding: 40px 24px;
  max-width: 560px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}
#upload-container h2 { font-size: 22px; font-weight: 700; color: var(--navy); }
.upload-hint { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
#upload-dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 36px 20px; text-align: center;
  cursor: pointer; color: var(--text-muted); font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
#upload-dropzone:hover, #upload-dropzone.drag-over {
  border-color: var(--accent); background: #f0f5ff;
}
#upload-dropzone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
#upload-submit {
  padding: 11px 20px; background: var(--accent); color: white;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
#upload-submit:disabled { background: var(--border); color: var(--text-muted); cursor: default; }
#upload-submit:not(:disabled):hover { background: var(--navy-light); }
.upload-status-msg { font-size: 14px; padding: 10px 0; }
.upload-status-msg.success { color: #22863a; }
.upload-status-msg.error { color: #d73a49; }

/* ===== DELETE VIEW ===== */
#delete-view { flex-direction: column; overflow: hidden; }
#delete-container {
  flex: 1; overflow-y: auto; padding: 40px 24px;
  max-width: 560px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}
#delete-container h2 { font-size: 22px; font-weight: 700; color: var(--navy); }
.delete-input-row { display: flex; gap: 10px; }
#delete-name-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text);
  background: white; outline: none; transition: border-color 0.15s;
}
#delete-name-input:focus { border-color: var(--accent); }
#delete-submit {
  padding: 10px 20px; background: #d73a49; color: white;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
#delete-submit:disabled { background: var(--border); color: var(--text-muted); cursor: default; }
#delete-submit:not(:disabled):hover { background: #b02838; }

/* ===== STORY TREE VIEW ===== */
#storytree-view {
  flex-direction: column;
  background: #080f1e;
  overflow: hidden;
}

/* Tree panel inside home-view */
#tree-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #080f1e;
  overflow: hidden;
  min-width: 0;
}

#tree-scroll-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #3a5278 #0d1829;
  cursor: grab;
  user-select: none;
}
#tree-scroll-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
#tree-scroll-wrap::-webkit-scrollbar-track { background: #0d1829; }
#tree-scroll-wrap::-webkit-scrollbar-thumb { background: #3a5278; border-radius: 4px; }

#tree-container {
  position: relative;
  min-width: 1100px;
  min-height: 400px;
}

/* --- Chapter --- */
.tree-chapter {
  position: absolute;
  width: 320px; height: 60px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, #1a2b4a 0%, #2d4878 100%);
  border: 1.5px solid #4a7bbd;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(74,123,189,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
  cursor: pointer;
  user-select: none;
  z-index: 10;
  transition: box-shadow 0.2s;
  overflow: hidden;
}
.tree-chapter:hover {
  box-shadow: 0 4px 24px rgba(74,123,189,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}
.tree-chapter-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  color: rgba(74,123,189,0.9);
  background: rgba(74,123,189,0.15);
  padding: 2px 7px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.tree-chapter-title {
  font-size: 14px; font-weight: 700; color: white;
  letter-spacing: 0.04em; flex: 1; text-align: center;
}
.tree-chapter-arrow {
  font-size: 14px; color: rgba(255,255,255,0.5);
  flex-shrink: 0; transition: transform 0.3s ease;
  margin-right: 4px;
}

/* --- Branch --- */
.tree-branch {
  position: absolute;
  width: 220px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: #182e56;
  border: 1px solid rgba(120,180,240,0.38);
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,0.88);
  letter-spacing: 0.04em;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

/* --- Section --- */
.tree-section {
  position: absolute;
  width: 140px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: #0f2242;
  border: 1px solid rgba(100,160,230,0.3);
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.78);
  text-align: center; padding: 0 6px;
  z-index: 10;
}

/* --- SubBranch --- */
.tree-subbranch {
  position: absolute;
  width: 120px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: #1c3d72;
  border: 1px solid rgba(74,123,189,0.78);
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  color: rgba(200,230,255,0.95);
  letter-spacing: 0.03em;
  z-index: 10;
}

/* --- Story --- */
.tree-story {
  position: absolute;
  width: 150px; height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10;
  background-color: #1a2b4a;
  background-size: cover;
  background-position: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.tree-story:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}
.tree-story-mask {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 35%, rgba(0,0,0,0.72) 100%);
}
.tree-story-title {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 8px 8px 7px;
  font-size: 11px; font-weight: 600;
  color: white;
  line-height: 1.35;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  z-index: 1;
}

/* Canvas lines layer */
#tree-lines {
  position: absolute; left: 0; top: 0;
  z-index: 1; pointer-events: none;
}

/* --- has-desc highlight --- */
.tree-chapter.has-desc {
  background: linear-gradient(135deg, #1e3358 0%, #3a5fa0 60%, #4a7bbd 100%);
  box-shadow: 0 2px 20px rgba(74,123,189,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}
.tree-chapter.has-desc:hover {
  box-shadow: 0 4px 30px rgba(100,160,255,0.6), inset 0 1px 0 rgba(255,255,255,0.18);
}
.tree-branch.has-desc {
  background: linear-gradient(135deg, #1e3a6a 0%, #2e5490 100%);
  box-shadow: 0 2px 14px rgba(74,123,189,0.35);
}
.tree-branch.has-desc:hover {
  box-shadow: 0 4px 20px rgba(100,160,255,0.5);
}
.tree-section.has-desc {
  background: linear-gradient(135deg, #172e56 0%, #1e4070 100%);
  box-shadow: 0 2px 10px rgba(74,123,189,0.3);
}
.tree-section.has-desc:hover {
  box-shadow: 0 3px 16px rgba(100,160,255,0.45);
}
.tree-subbranch.has-desc {
  background: linear-gradient(135deg, #1e3d72 0%, #2a5494 100%);
  box-shadow: 0 2px 10px rgba(74,123,189,0.35);
}
.tree-subbranch.has-desc:hover {
  box-shadow: 0 3px 16px rgba(100,160,255,0.5);
}
.tree-story.has-desc {
  box-shadow: 0 4px 16px rgba(74,123,189,0.5), 0 0 0 1.5px rgba(100,160,255,0.5);
}
.tree-story.has-desc:hover {
  box-shadow: 0 8px 24px rgba(74,123,189,0.65), 0 0 0 2px rgba(150,200,255,0.7);
}

/* STORY badge on has-desc nodes */
.tree-desc-badge {
  position: absolute;
  right: 6px; bottom: 5px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  color: rgba(150,210,255,0.75);
  background: rgba(74,123,189,0.18);
  padding: 1px 5px; border-radius: 3px;
  pointer-events: none;
  transition: color 0.2s, background 0.2s, opacity 0.2s;
  opacity: 0.7;
}
.has-desc:hover .tree-desc-badge {
  color: rgba(200,235,255,1);
  background: rgba(74,123,189,0.38);
  opacity: 1;
}
/* For chapter, badge needs position override since chapter uses flex */
.tree-chapter .tree-desc-badge {
  position: relative; right: auto; bottom: auto;
  flex-shrink: 0;
  pointer-events: auto;
  cursor: pointer;
}
/* For story nodes, position in bottom-right like tree-chapter-label */
.tree-story .tree-desc-badge {
  bottom: 22px; right: 5px;
  pointer-events: none;
}

/* Node text wrapper for non-chapter nodes */
.tree-node-text {
  flex: 1;
  text-align: center;
  pointer-events: none;
}

/* Mobile tree overrides */
@media (max-width: 766px) {
  #tree-container { min-width: 380px; }
  .tree-chapter { width: 260px; height: 46px; }
  .tree-chapter-title { font-size: 12px; }
  .tree-branch { width: 190px; height: 40px; font-size: 12px; }
  .tree-section { width: 130px; height: 30px; font-size: 10px; }
  .tree-subbranch { width: 100px; height: 30px; font-size: 10px; }
  .tree-story { width: 110px; height: 64px; }
  .tree-story-title { font-size: 10px; padding: 5px 6px; }
}

/* ===== STORYTREE DESC READ MODAL ===== */
.st-desc-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-h);
  z-index: 300;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}
.st-desc-modal-overlay.active {
  display: flex;
}
.st-desc-modal-inner {
  background: linear-gradient(160deg, #182e56 0%, #0f2040 100%);
  border: 1px solid rgba(100,160,230,0.35);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(74,123,189,0.2);
  width: min(620px, 90vw);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  animation: stDescModalIn 0.22s ease;
}
@keyframes stDescModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.st-desc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(100,160,230,0.18);
  flex-shrink: 0;
}
.st-desc-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: rgba(200,230,255,0.95);
  letter-spacing: 0.04em;
}
.st-desc-modal-close {
  background: none;
  border: none;
  color: rgba(150,190,240,0.6);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.st-desc-modal-close:hover {
  color: white;
  background: rgba(74,123,189,0.25);
}
.st-desc-modal-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #3a5278 transparent;
}
.st-desc-modal-body p {
  margin: 0 0 0.75em;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(220,235,255,0.88);
}
.st-desc-modal-body p:last-child { margin-bottom: 0; }
.st-desc-modal-body p:empty { margin-bottom: 0.4em; }

/* Node images in desc modal */
.st-desc-img-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid rgba(74,123,189,0.2);
}
.st-desc-img {
  width: 96px; height: 96px;
  object-fit: cover; border-radius: 6px;
  border: 1px solid rgba(74,123,189,0.25);
  transition: opacity 0.15s, transform 0.12s;
}
.st-desc-img:hover { opacity: 0.85; transform: scale(1.04); }

/* ===== STORYTREE DETAIL OVERLAY ===== */
#st-detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-h);
  z-index: 200;
  background: rgba(0,0,0,0.35);
}
#st-detail-overlay.active { display: block; }
#st-detail-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--detail-w);
  background: white;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.25);
  animation: stPanelSlideIn 0.2s ease;
}
@keyframes stPanelSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ===== STORY TREE EDITOR ===== */
#storyedit-view {
  flex-direction: row;
  background: #080f1e;
  overflow: hidden;
}
#ste-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
#ste-tree-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.07);
}
#ste-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
#ste-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 40px;
  scrollbar-width: thin;
  scrollbar-color: #3a5278 transparent;
}
#ste-tree::-webkit-scrollbar { width: 5px; }
#ste-tree::-webkit-scrollbar-thumb { background: #3a5278; border-radius: 3px; }
#ste-story-panel {
  width: 280px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(0,0,0,0.18);
}
#ste-story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
#ste-story-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 20px;
  scrollbar-width: thin;
  scrollbar-color: #3a5278 transparent;
}
#ste-story-list::-webkit-scrollbar { width: 5px; }
#ste-story-list::-webkit-scrollbar-thumb { background: #3a5278; border-radius: 3px; }

/* Header add buttons */
#ste-add-chapter-btn, #ste-new-story-btn {
  background: rgba(45,106,191,0.2);
  color: #7db8ff;
  border: 1px solid rgba(45,106,191,0.35);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
#ste-add-chapter-btn:hover, #ste-new-story-btn:hover {
  background: rgba(45,106,191,0.38);
}

/* Tree node rows */
.ste-node {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 36px;
  padding: 5px 10px 5px 0;
  margin: 1px 0;
  border-radius: 6px;
  transition: background 0.1s;
}
.ste-node:hover { background: rgba(255,255,255,0.04); }
.ste-node-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  padding-top: 2px;
}
.ste-node-title {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  line-height: 1.3;
}
/* Type badges */
.ste-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.ste-badge-chapter {
  background: linear-gradient(135deg, #1a4a8a, #2d6abf);
  color: white;
}
.ste-badge-branch {
  background: rgba(45,106,191,0.3);
  color: #8ab4e8;
  border: 1px solid rgba(45,106,191,0.45);
}
.ste-badge-section {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.14);
}
.ste-badge-subbranch {
  background: rgba(100,160,255,0.12);
  color: #7db8ff;
  border: 1px solid rgba(100,160,255,0.28);
}
/* Section side toggle */
.ste-side-btn {
  background: rgba(100,160,255,0.15);
  color: #7db8ff;
  border: 1px solid rgba(100,160,255,0.3);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s;
}
.ste-side-btn:hover { background: rgba(100,160,255,0.3); }
/* Story chips inside subbranch rows */
.ste-story-chip {
  background: rgba(80,180,80,0.18);
  color: #7dcf7d;
  border: 1px solid rgba(80,180,80,0.3);
  border-radius: 9px;
  font-size: 10px;
  padding: 1px 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.ste-story-chip:hover {
  background: rgba(200,60,60,0.25);
  color: #ffaaaa;
  border-color: rgba(200,60,60,0.4);
}
/* SubBranch drop zone */
.ste-node-subbranch {
  border: 1px dashed rgba(100,160,255,0.18);
}
.ste-node-subbranch.ste-drop-hover {
  border-color: #5a9eff;
  background: rgba(100,160,255,0.1);
}
/* Action buttons (hidden until hover) */
.ste-node-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  align-items: center;
  padding-top: 2px;
}
.ste-node:hover .ste-node-actions { opacity: 1; }
.ste-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.55);
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  line-height: 1.4;
}
.ste-btn:hover { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.9); }
.ste-btn-delete:hover {
  background: rgba(200,60,60,0.28);
  border-color: rgba(200,60,60,0.45);
  color: #ffaaaa;
}
.ste-btn-add {
  border-color: rgba(100,160,255,0.3);
  color: #7db8ff;
  font-size: 10px;
}
.ste-btn-add:hover { background: rgba(100,160,255,0.18); color: #aad4ff; border-color: rgba(100,160,255,0.5); }

/* Story sidebar */
.ste-story-section-hdr {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  font-weight: 700;
  padding: 8px 6px 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ste-story-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 7px;
  border-radius: 8px;
  margin-bottom: 5px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: grab;
  transition: background 0.1s, opacity 0.2s;
  user-select: none;
}
.ste-story-card:hover { background: rgba(255,255,255,0.08); }
.ste-story-card.placed { opacity: 0.42; }
.ste-story-card.placed:hover { opacity: 0.72; }
.ste-story-card.ste-dragging { opacity: 0.25; cursor: grabbing; }
.ste-story-cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ste-story-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ste-cover-plus {
  background: none;
  border: 1.5px dashed rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.45);
  font-size: 18px;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, color 0.1s;
  line-height: 1;
}
.ste-cover-plus:hover { background: rgba(255,255,255,0.09); color: white; }
.ste-story-info { flex: 1; min-width: 0; }
.ste-story-title {
  font-size: 12px;
  color: rgba(255,255,255,0.82);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ste-story-id { font-size: 10px; color: rgba(255,255,255,0.3); }
.ste-story-placement { font-size: 10px; color: #7db8ff; margin-top: 2px; }
.ste-story-del {
  background: none;
  border: none;
  color: rgba(255,255,255,0.22);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 5px;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.ste-story-del:hover { color: #ffaaaa; background: rgba(200,60,60,0.2); }

/* Modals */
.ste-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.ste-modal.active { display: flex; }
.ste-modal-inner {
  background: #0e1e38;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 24px 26px;
  min-width: 320px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.ste-modal-inner h3 { color: rgba(255,255,255,0.9); margin: 0 0 16px; font-size: 14px; font-weight: 600; }
.ste-modal-inner label {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin: 10px 0 4px;
}
.ste-modal-inner input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  color: rgba(255,255,255,0.88);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.ste-modal-inner input[type="text"]:focus { border-color: #4a90d9; }
.ste-modal-inner input[readonly] { opacity: 0.45; cursor: default; }
.ste-modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.ste-modal-btns button {
  padding: 7px 18px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: background 0.1s;
  font-family: inherit;
}
#ste-rename-ok, #ste-ns-ok, #ste-cover-ok {
  background: #2060b0;
  color: white;
}
#ste-rename-ok:hover, #ste-ns-ok:hover { background: #2d72cc; }

/* Node image grid (rename modal) */
.ste-node-imgs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 6px;
}
.ste-node-img-cell {
  position: relative;
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 6px; overflow: hidden;
  background: rgba(10,24,50,0.6);
}
.ste-node-img-thumb {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.ste-node-img-del {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: #c03030; border: none; border-radius: 50%;
  color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; opacity: 0; transition: opacity 0.15s;
}
.ste-node-img-cell:hover .ste-node-img-del { opacity: 1; }
.ste-node-img-del:hover { background: #e03030; }
.ste-node-img-add {
  border: 1.5px dashed rgba(74,123,189,0.45);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.ste-node-img-add:hover, .ste-node-img-add.drag-over {
  border-color: rgba(74,123,189,0.8);
  background: rgba(74,123,189,0.1);
}
.ste-node-img-add-icon {
  font-size: 22px; color: rgba(74,123,189,0.6);
  user-select: none; line-height: 1;
}
#ste-cover-ok:not(:disabled):hover { background: #2d72cc; }
#ste-cover-ok:disabled { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.28); cursor: default; }
#ste-rename-cancel, #ste-ns-cancel, #ste-cover-cancel, #ste-move-cancel {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
}
#ste-rename-cancel:hover, #ste-ns-cancel:hover, #ste-cover-cancel:hover, #ste-move-cancel:hover {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.8);
}
/* Move modal */
#ste-move-list { max-height: 220px; overflow-y: auto; margin-bottom: 4px; }
.ste-move-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.78);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.1s;
  font-family: inherit;
}
.ste-move-option:hover { background: rgba(45,106,191,0.3); color: white; }
/* Cover upload */
#ste-cover-dropzone {
  border: 1.5px dashed rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 22px 16px;
  text-align: center;
  color: rgba(255,255,255,0.38);
  font-size: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  margin-top: 6px;
}
#ste-cover-dropzone:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.32); }
#ste-cover-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
#ste-cover-status {
  font-size: 12px;
  color: #7db8ff;
  margin-top: 10px;
  min-height: 16px;
}

/* ===== MEMORIA ===== */
.hidden { display: none !important; }

#memoria-filter-bar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--page-bg);
  flex-shrink: 0;
}
#memoria-filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
#memoria-filter-bar label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
#memoria-char-filter {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.15s;
}
#memoria-char-filter:focus {
  outline: none;
  border-color: var(--accent);
}
#memoria-grid {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 20px;
}
#memoria-grid .story-count {
  padding: 6px 4px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Memoria card cover: square-ish card art */
.memoria-card .story-card-banner,
.memoria-card .story-card-banner-placeholder {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px 6px 0 0;
}

/* Character tags in detail panel */
.character-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 10px;
}
.character-tag {
  display: inline-block;
  padding: 3px 11px;
  background: rgba(74, 123, 189, 0.10);
  color: var(--accent);
  border: 1px solid rgba(74, 123, 189, 0.28);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.character-tag-link {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.character-tag-link:hover {
  background: rgba(74, 123, 189, 0.22);
  border-color: var(--accent);
}

/* ===== Choice System ===== */
.row-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  margin: 8px 0;
}
.choice-btn {
  width: 100%;
  max-width: 480px;
  padding: 12px 24px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 4px;
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.choice-btn:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-1px);
}
.choice-btn:active {
  transform: translateY(0);
}

/* ===== Bad End ===== */
.row-bad-end {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 40px 20px 36px;
  margin: 8px 0;
}
.bad-end-deco {
  flex: 1;
  height: 2px;
  background: linear-gradient(to var(--dir, right),
    transparent 0%, rgba(180,30,30,0.4) 30%, rgba(220,50,50,0.85) 100%);
}
.bad-end-deco-left  { --dir: right; }
.bad-end-deco-right { --dir: left; }
.bad-end-text {
  flex-shrink: 0;
  font-size: 26px;
  font-weight: 800;
  color: #e05050;
  letter-spacing: 0.18em;
  text-shadow: 0 0 24px rgba(220,50,50,0.5), 0 2px 12px rgba(0,0,0,0.7);
  text-align: center;
}
/* After bad-end, choice buttons get a distinct style */
.row-bad-end + .row-choice .choice-btn {
  border-color: rgba(200,50,50,0.35);
}
.row-bad-end + .row-choice .choice-btn:first-child {
  background: rgba(180,30,30,0.12);
}
.row-bad-end + .row-choice .choice-btn:first-child:hover {
  background: rgba(180,30,30,0.22);
  border-color: rgba(200,50,50,0.6);
}

/* ===== DICT VIEWS (names / words) ===== */
#names-view, #words-view { flex-direction: column; overflow: hidden; }
.dict-view-container { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 16px; }
.dict-view-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; flex-shrink: 0; }
.dict-search-input { flex: 1; min-width: 120px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); }
.dict-search-input:focus { outline: none; border-color: var(--accent); }
.dict-cat-select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); }
.dict-dl-btn { padding: 7px 14px; background: var(--navy-light, #2a3a6a); color: #fff; border-radius: 6px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.dict-dl-btn:hover { opacity: 0.85; }
#names-view-table, #words-view-table { flex: 1; min-height: 0; overflow-y: auto; }
.dict-table-wrap { height: 100%; }
.dict-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dict-table th { position: sticky; top: 0; background: var(--navy, #1a2a5a); color: #fff; padding: 9px 12px; text-align: left; font-weight: 600; z-index: 1; }
.dict-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; word-break: break-all; }
.dict-table tr:last-child td { border-bottom: none; }
.dict-table tr:hover td { background: rgba(0,0,0,0.04); }
.dict-empty { padding: 32px; text-align: center; color: var(--text-light, #888); font-size: 14px; }

/* ===== VOICE VIEW ===== */
#voice-view.active { display: flex; flex-direction: column; min-height: 0; flex: 1; position: relative; }

#voice-view-layout {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
#voice-view-container { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }

/* PC: right detail panel */
#voice-detail-panel {
  display: none;
}
@media (min-width: 900px) {
  #voice-detail-panel {
    display: flex; flex-direction: column;
    width: 340px; flex-shrink: 0;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    background: #f8f9fc;
  }
}

#voice-tab-header {
  display: flex; background: #fff; border-bottom: 2px solid var(--border);
  padding: 0 16px; flex-shrink: 0; overflow-x: auto;
}
.voice-tab-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  color: var(--text-muted, #6a7a90); padding: 10px 18px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: color 0.15s;
}
.voice-tab-btn:hover { color: var(--navy); }
.voice-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

#voice-tab-content { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }

.voice-loading, .voice-error, .voice-empty {
  padding: 40px; text-align: center; color: var(--text-muted, #888); font-size: 14px;
}
.voice-error { color: #c0392b; }

.voice-card-list { display: flex; flex-direction: column; gap: 8px; max-width: 700px; }

.voice-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.voice-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(74,123,189,0.12); }

.voice-card-name {
  font-size: 12px; font-weight: 600; color: var(--text-muted, #6a7a90);
  margin-bottom: 6px; word-break: break-all;
}

.voice-card-row {
  display: flex; align-items: flex-start; gap: 10px;
}

.voice-play-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--accent); padding: 2px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, transform 0.12s;
}
.voice-play-btn:hover { color: var(--navy-light); transform: scale(1.1); }
.voice-play-btn.playing { color: var(--navy); animation: voice-pulse 1s ease-in-out infinite; }
@keyframes voice-pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.voice-texts { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.voice-text-jp { font-size: 12px; color: var(--text-muted, #6a7a90); line-height: 1.5; word-break: break-all; }
.voice-text-cn { font-size: 13px; color: var(--text); line-height: 1.5; word-break: break-all; }

/* voice progress bar */
.voice-progress-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
}
.voice-progress-bar {
  flex: 1; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden; cursor: pointer;
}
.voice-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 2px; transition: width 0.1s linear;
}
.voice-progress-time {
  font-size: 11px; color: var(--text-muted, #888);
  white-space: nowrap; min-width: 70px; text-align: right;
}

/* voice fetch overlay */
.voice-fetch-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(255,255,255,0.75);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  backdrop-filter: blur(2px);
  pointer-events: all;
}
.voice-fetch-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: voice-spin 0.7s linear infinite;
}
@keyframes voice-spin { to { transform: rotate(360deg); } }
.voice-fetch-label { font-size: 14px; color: var(--navy); font-weight: 600; }

/* ===== STAGE GRID ===== */
.stage-grid-container { padding: 14px 14px 32px; grid-column: 1 / -1; width: 100%; box-sizing: border-box; }

.stage-grid-container .story-group-wrapper { display: flex; flex-direction: column; margin-bottom: 16px; }
.stage-group-body { display: flex; flex-wrap: wrap; gap: 12px; }

.stage-card {
  width: 120px; cursor: pointer; border-radius: 8px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: transform 0.15s, box-shadow 0.15s; position: relative;
  flex-shrink: 0;
}
.stage-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.stage-card:hover .stage-nameplate { opacity: 1; }

.stage-card-img {
  width: 120px; height: 170px; object-fit: cover; display: block;
}
.stage-nameplate {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(15,25,55,0.65) 5%, transparent 100%);
  display: flex; align-items: flex-end;
  padding: 8px 7px; font-size: 11px; font-weight: 700;
  color: #fff; line-height: 1.4;
  opacity: 0; transition: opacity 0.2s;
}

/* ===== STAGE DETAIL PANEL ===== */
.stage-detail-cover { margin-bottom: 12px; border-radius: 8px; overflow: hidden; }
.stage-detail-cover img { width: 100%; display: block; border-radius: 8px; }
.stage-detail-meta { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.stage-meta-row { display: flex; gap: 8px; font-size: 13px; }
.stage-meta-key { color: var(--text-muted); flex-shrink: 0; min-width: 48px; }
.stage-meta-val { color: var(--text); }
.stage-detail-section-title { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.stage-detail-synopsis-text { font-size: 13px; line-height: 1.75; color: var(--text); }
.stage-detail-synopsis { margin-bottom: 12px; }

/* ===== CAST VIEW ===== */
#cast-view.active { flex: 1; overflow: hidden; min-height: 0; display: flex; flex-direction: column; }
#cast-view-layout { display: flex; flex: 1; min-height: 0; }
#cast-main {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
#cast-detail-panel {
  width: 320px; flex-shrink: 0; overflow-y: auto;
  border-left: 1px solid var(--border); background: var(--panel-bg);
}

.cast-view-title {
  font-size: 20px; font-weight: 800; color: var(--navy);
  padding-bottom: 12px; border-bottom: 2px solid var(--accent);
  margin-bottom: 4px;
}
.cast-view-empty { color: var(--text-muted); font-size: 14px; padding: 24px 0; }

.cast-year-group { margin-bottom: 8px; }
.cast-year-body { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 0 4px; }

.cast-actor-card {
  width: 130px; border-radius: 8px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  cursor: pointer; position: relative; transition: transform 0.15s, box-shadow 0.15s;
}
.cast-actor-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.16); }
.cast-actor-img { width: 130px; height: 174px; object-fit: cover; display: block; }
.cast-actor-nameplate {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(15,25,55,0.85) 60%, transparent);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 18px 6px 5px; text-align: center;
  opacity: 0; transition: opacity 0.15s;
}
.cast-actor-card:hover .cast-actor-nameplate { opacity: 1; }
.cast-actor-role {
  font-size: 10px; font-weight: 400; opacity: 0.85;
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 768px) {
  #cast-detail-panel { display: none; }
  .cast-actor-card { width: 110px; }
  .cast-actor-img { width: 110px; height: 147px; }
  .cast-actor-nameplate { opacity: 1; }
}

/* ===== STAGE READ VIEW ===== */
#stage-read-view {
  flex: 1; overflow-y: auto; background: var(--page-bg);
  min-height: 0;
}
#sr-content { max-width: 1100px; margin: 0 auto; padding: 0 0 48px; }

/* Hero — title banner, no cover image */
.sr-hero {
  background: var(--navy); padding: 24px 36px 20px;
}
.sr-hero-overlay { display: flex; flex-direction: column; gap: 4px; }
.sr-title { font-size: 24px; font-weight: 800; color: #fff; }
.sr-title-jp { font-size: 13px; color: rgba(255,255,255,0.65); }

/* Row 1: vertical cover + profile/note */
.sr-row1 {
  display: flex; gap: 24px; padding: 24px 28px 0; align-items: flex-start;
}
.sr-cover-wrap { flex-shrink: 0; width: 180px; }
.sr-cover-img { width: 180px; border-radius: 8px; display: block; box-shadow: 0 4px 16px rgba(0,0,0,0.18); }

.sr-profile-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.sr-bili-links { display: flex; flex-direction: column; gap: 8px; }
.sr-bili-btn { text-decoration: none; }

.sr-profile-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sr-profile-table th {
  text-align: left; padding: 5px 10px 5px 0; color: var(--text-muted);
  font-weight: 600; white-space: nowrap; vertical-align: top; width: 72px;
}
.sr-profile-table td { padding: 5px 0; color: var(--text); line-height: 1.5; }
.sr-profile-table tr + tr th, .sr-profile-table tr + tr td {
  border-top: 1px solid var(--border);
}

.sr-note {
  font-size: 12px; line-height: 1.75; color: var(--text-muted);
  background: rgba(255,255,255,0.7); border-left: 3px solid var(--border);
  padding: 8px 12px; border-radius: 4px;
}
.sr-note-label { font-weight: 700; color: var(--navy); margin-right: 6px; }

/* Row 2: synopsis + schedule side by side */
.sr-row2 {
  display: flex; gap: 24px; padding: 24px 28px 0; align-items: flex-start;
}
.sr-synopsis-col { flex: 3; min-width: 0; }
.sr-schedule-col { flex: 2; min-width: 220px; }

.sr-section { display: flex; flex-direction: column; gap: 8px; }
.sr-section-title {
  font-size: 15px; font-weight: 700; color: var(--navy);
  border-bottom: 2px solid var(--accent); padding-bottom: 4px; margin-bottom: 4px;
}
.sr-synopsis { font-size: 14px; line-height: 1.85; color: var(--text); }

.sr-schedule-list {
  list-style: none; display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-muted);
}
.sr-schedule-list li::before { content: '◆ '; color: var(--accent); }

/* Cast — full width row */
.sr-cast-section { padding: 24px 28px 0; }
.sr-cast-group-label {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--border);
}
.sr-cast-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.sr-cast-card {
  width: 90px; text-align: center; background: #fff;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 5px rgba(0,0,0,0.08); padding-bottom: 8px;
}
.sr-cast-img { width: 90px; height: 120px; object-fit: cover; display: block; cursor: zoom-in; flex-shrink: 0; }
.sr-cast-actor { font-size: 11px; font-weight: 700; color: var(--navy); margin-top: 5px; padding: 0 4px; }
.sr-cast-actor.clickable {
  cursor: pointer;
  transition: color 0.15s;
}
.sr-cast-actor.clickable:hover { color: var(--accent); text-decoration: underline; }
.sr-cast-role { font-size: 11px; color: var(--text-muted); padding: 0 4px; }
.sr-cast-role-btn {
  cursor: pointer; margin-top: 3px; padding: 2px 6px;
  border-radius: 4px; border: 1px solid rgba(74,123,189,0.3);
  background: rgba(74,123,189,0.07); color: #4a7bbd;
  font-size: 10px; font-weight: 600; letter-spacing: 0.03em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: inline-block;
}
.sr-cast-role-btn:hover {
  background: rgba(74,123,189,0.18); border-color: rgba(74,123,189,0.55);
  color: #2a5a9d;
}
.sr-cast-note { font-size: 10px; color: #999; padding: 2px 4px 0; line-height: 1.4; }

@media (max-width: 768px) {
  .sr-hero { padding: 16px 18px 14px; }
  .sr-title { font-size: 18px; }
  .sr-row1 { flex-direction: column; padding: 16px 16px 0; gap: 16px; }
  .sr-cover-wrap { width: 100%; }
  .sr-cover-img { width: 100%; max-width: 260px; }
  .sr-row2 { flex-direction: column; padding: 16px 16px 0; gap: 16px; }
  .sr-schedule-col { min-width: 0; }
  .sr-cast-section { padding: 16px 16px 0; }
  .stage-card { width: 100px; }
  .stage-card-img { width: 100px; height: 142px; }
  .stage-nameplate { opacity: 1; }
  .fumi-btn-row { justify-content: stretch; }
  .fumi-btn-send { width: 100%; }
}

/* btn-voice in intro detail */
.btn-voice {
  background: var(--navy-mid, #253860); color: #fff; border: none;
  padding: 9px 14px; border-radius: 7px; font-size: 14px;
  cursor: pointer; font-weight: 600; text-align: center;
  transition: background 0.15s;
}
.btn-voice:hover { background: var(--navy-light); }

/* btn-wiki-detail */
.btn-wiki-detail {
  background: linear-gradient(135deg, #0f2242 0%, #1a3860 100%);
  color: #fff; border: 1px solid rgba(74,123,189,0.55);
  padding: 9px 14px; border-radius: 7px; font-size: 14px;
  cursor: pointer; font-weight: 600; text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}
.btn-wiki-detail:hover {
  background: linear-gradient(135deg, #1a3860 0%, #2a5090 100%);
  border-color: rgba(100,160,240,0.85);
  color: #fff;
}

/* ===== FUMI VIEW ===== */
#fumi-view.active { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
#fumi-area { padding: 20px 24px; background: linear-gradient(135deg, #f5f9ff 0%, #f9f5ff 100%); flex: 1; }
.fumi-layout { display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
.fumi-card { background: var(--white); border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,0.08); padding: 16px 18px; }
.fumi-card-header { display: flex; align-items: center;  margin-bottom: 12px; gap: 40px; }
.fumi-section-title { font-size: 14px; font-weight: 700; color: var(--navy); margin: 0; display: flex; align-items: center; gap: 6px; }
.fumi-title-icon { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.fumi-input-row { display: flex; gap: 8px; align-items: flex-start; }
.fumi-btn-row { display: flex; justify-content: flex-end; margin-top: 8px; }
.fumi-textarea { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; resize: vertical; min-height: 100px; }
.fumi-textarea:focus { outline: none; border-color: var(--accent); }
.fumi-btn-send { padding: 10px 20px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: background 0.15s; white-space: nowrap; height: fit-content; }
.fumi-btn-send:hover { background: var(--navy-light, #334e88); }
.fumi-btn-send:disabled { background: #ccc; cursor: not-allowed; }
.fumi-status { padding: 10px 14px; border-radius: 6px; font-size: 13px; display: none; }
.fumi-status.show { display: block; }
.fumi-status.loading { background: #e7f1ff; color: #0056b3; }
.fumi-status.success { background: #e8f5e9; color: #2e7d32; }
.fumi-status.error { background: #ffebee; color: #c62828; }
.fumi-qa-card { background: #fffde7; border-left: 3px solid #fbc02d; }
.fumi-qa-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.fumi-qa-toggle:hover { opacity: 0.8; }
.fumi-qa-arrow { font-size: 11px; color: var(--text-light); transition: transform 0.2s; }
.fumi-qa-arrow.collapsed { transform: rotate(-90deg); }
.fumi-qa-list { margin-top: 12px; display: none; }
.fumi-qa-list.show { display: block; }
.fumi-qa-item { margin-bottom: 10px; padding: 8px; background: rgba(0,0,0,0.02); border-radius: 4px; font-size: 12px; line-height: 1.5; }
.fumi-qa-item strong { color: var(--navy); }
.fumi-answer-card { background: #f0f5ff; border-left: 3px solid var(--accent); }
.fumi-answer-text { font-size: 14px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-all; }
.fumi-loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); display: none; z-index: 1000; }
.fumi-loading-overlay.show { display: flex; align-items: center; justify-content: center; }
.fumi-spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.fumi-balls { display: flex; align-items: center; gap: 6px; }
.fumi-ball {
  width: 12px; height: 12px; border-radius: 50%;
  background: #4a90e2;
  box-shadow: 0 0 6px 1px rgb(74 199 226 / 30%), 0 0 12px 2px rgba(74, 144, 226, 0.35);
  transition: background 0.3s, box-shadow 0.3s;
  display: inline-block;
}
.fumi-ball.used { background: #b0bec5; box-shadow: none; }
.fumi-ratelimit-msg {
  margin-top: 8px; padding: 10px 14px;
  background: #f0f4ff; border-radius: 6px;
  font-size: 14px; color: var(--navy); line-height: 1.8;
  text-align: center;
}
.fumi-countdown { font-size: 22px; font-weight: 700; color: #4a90e2; font-variant-numeric: tabular-nums; }
.fumi-ball-tooltip {
  position: absolute; z-index: 9999;
  background: rgba(30,40,70,0.92); color: #fff;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 6px;
  pointer-events: none; white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0; transition: opacity 0.15s;
}
.fumi-ball-tooltip.show { opacity: 1; }

/* ===== SETTING CARD (设定集 grid) ===== */
.setting-card {
  position: relative;
  width: 160px;
  cursor: pointer; border-radius: 8px;
  overflow: hidden; border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  background: var(--border); box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.setting-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(74,123,189,0.3);
  transform: translateY(-2px);
}
.setting-card-banner {
  width: 160px; height: 120px;
  object-fit: cover; object-position: center;
  display: block;
}
.setting-card-banner-placeholder {
  width: 160px; height: 120px;
  background: linear-gradient(135deg, #1e3060 0%, #2d4878 100%);
  display: flex; align-items: center; justify-content: center;
}
.setting-card-nameplate {
  padding: 7px 10px 8px;
  background: linear-gradient(to bottom, rgba(18,32,62,0.85) 0%, rgba(18,32,62,0.97) 100%);
}
.setting-card-banner, .setting-card-banner-placeholder { display: block; }
.setting-card-name {
  font-size: 12px; font-weight: 700; color: #e8f0ff;
  letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 8px rgba(74,123,189,0.6);
}

/* Video card */
.video-card { width: 200px; }
.video-card .setting-card-banner { width: 200px; height: 160px; }
.video-card .setting-card-banner-placeholder { width: 200px; height: 160px; }
.video-card .setting-card-nameplate {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(15,25,55,0.88) 0%, transparent 100%);
  padding: 28px 10px 8px;
  display: flex; align-items: flex-end;
}
.video-card .setting-card-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; line-height: 1.4; width: 100%;
}
.video-card:hover .setting-card-nameplate {
  background: linear-gradient(to top, rgba(15,25,55,0.95) 50%, transparent 100%);
  padding-top: 48px;
}
.video-card:hover .setting-card-name {
  white-space: normal; overflow: visible; text-overflow: unset;
}

/* ===== SETTING ARTICLE MODAL ===== */
#setting-article-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,18,40,0.72);
  z-index: 1200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#setting-article-modal.open { display: flex; }

.setting-modal-inner {
  width: min(860px, 96vw);
  max-height: 92vh;
  background: #0d1728;
  border-radius: 12px;
  border: 1px solid rgba(74,123,189,0.35);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(74,123,189,0.15);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.setting-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid rgba(74,123,189,0.25);
  background: linear-gradient(135deg, #111f3a 0%, #0d1728 100%);
  flex-shrink: 0;
}
.setting-modal-title {
  font-size: 17px; font-weight: 800; color: #c8d8f8;
  letter-spacing: 0.06em;
}
.setting-modal-close {
  background: none; border: none; color: #7a9ac8; font-size: 18px;
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.setting-modal-close:hover { color: #e8f0ff; background: rgba(74,123,189,0.2); }

.setting-modal-body {
  overflow-y: auto; flex: 1;
  padding: 0 0 24px;
  scrollbar-width: thin; scrollbar-color: rgba(74,123,189,0.4) transparent;
}

.setting-modal-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 60px 24px;
  color: #7a9ac8; font-size: 14px;
}
.setting-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(74,123,189,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.setting-modal-error {
  padding: 40px 24px; text-align: center;
  color: #e07070; font-size: 14px;
}

/* ===== OPUS CONTENT RENDERER ===== */
.opus-cover-wrap {
  width: 100%; max-height: 260px; overflow: hidden;
  border-bottom: 1px solid rgba(74,123,189,0.2);
}
.opus-cover-img {
  width: 100%; max-height: 260px; object-fit: cover; display: block;
}

.opus-meta-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 22px 8px;
  border-bottom: 1px solid rgba(74,123,189,0.15);
}
.opus-meta-tag {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(74,123,189,0.2); color: #90b4e8;
  border: 1px solid rgba(74,123,189,0.3);
}
.opus-meta-words {
  font-size: 11px; color: #5a7aa8; margin-left: auto;
}

.opus-article-title {
  font-size: 20px; font-weight: 800; color: #c8d8f8;
  padding: 18px 22px 4px;
  letter-spacing: 0.04em; line-height: 1.4;
}
.opus-title-divider {
  height: 2px; margin: 8px 22px 16px;
  background: linear-gradient(to right, var(--accent), transparent);
  border-radius: 1px;
}

.opus-content {
  padding: 0 22px;
  display: flex; flex-direction: column; gap: 6px;
}

.opus-para {
  font-size: 14px; line-height: 1.9; color: #b8cae8;
  margin: 0;
}

.opus-bold { font-weight: 700; }

.opus-highlight {
  background-color: rgba(100, 160, 240, 0.45);
  border-radius: 3px; padding: 0 3px;
  color: #ffffff;
}

.opus-blockquote {
  border-left: 3px solid rgba(74,123,189,0.6);
  margin: 4px 0;
  padding: 8px 14px;
  background: rgba(74,123,189,0.08);
  border-radius: 0 6px 6px 0;
  font-size: 14px; line-height: 1.85; color: #9ab8e0;
  font-style: italic;
}

.opus-divider {
  height: 1px; margin: 12px 0;
  background: rgba(74,123,189,0.25);
  border-radius: 1px;
}

.opus-list-item {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 14px; line-height: 1.85; color: #b8cae8;
}
.opus-list-bullet {
  color: var(--accent); flex-shrink: 0; margin-top: 1px;
  font-size: 16px; line-height: 1.6;
}

.opus-heading {
  font-size: 16px; font-weight: 800; color: #dde9ff;
  padding: 10px 14px 10px 16px;
  margin: 10px 0 4px;
  border-left: 4px solid var(--heading-accent, var(--accent));
  background: linear-gradient(to right, rgba(74,123,189,0.12), transparent);
  border-radius: 0 6px 6px 0;
  letter-spacing: 0.04em; line-height: 1.4;
}

.opus-img-wrap {
  margin: 10px 0;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}
.opus-img-container {
  width: 100%; max-width: 480px;
  height: 280px;
  border-radius: 8px;
  border: 1px solid rgba(74,123,189,0.25);
  overflow: hidden;
  background: rgba(10,20,40,0.6);
  display: flex; align-items: center; justify-content: center;
}
.opus-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.opus-img:hover { opacity: 0.88; }

.opus-link-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(74,123,189,0.1);
  border: 1px solid rgba(74,123,189,0.28);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  margin: 4px 0;
}
.opus-link-card:hover {
  background: rgba(74,123,189,0.2);
  border-color: rgba(74,123,189,0.5);
}
.opus-link-icon {
  color: var(--accent); font-size: 16px; flex-shrink: 0;
}
.opus-link-text {
  font-size: 13px; color: #90b8e8; line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
}

/* Opus matched cards (stage/story replacing link-cards) */
.opus-matched-row {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 8px 0 12px; margin: 4px 0;
}
.opus-matched-card {
  width: 140px; flex-shrink: 0; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(74,123,189,0.25);
  border-radius: 6px; overflow: hidden; transition: border-color 0.15s, background 0.15s;
}
.opus-matched-card:hover {
  background: rgba(74,123,189,0.15); border-color: rgba(74,123,189,0.6);
}
.opus-matched-card-img {
  width: 140px; height: 88px; object-fit: cover; display: block;
}
.opus-matched-card-placeholder {
  background: rgba(255,255,255,0.06);
}
.opus-matched-card-label {
  padding: 5px 8px; font-size: 12px; color: #c0d0e8; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}


@media (max-width: 768px) {
  .setting-modal-inner { width: 100vw; max-height: 100vh; border-radius: 0; }
  .opus-content { padding: 0 14px; }
  .opus-article-title { padding: 14px 14px 4px; font-size: 17px; }
  .opus-title-divider { margin: 6px 14px 12px; }
  .opus-meta-bar { padding: 8px 14px 6px; }
  .setting-card { width: 140px; }
  .setting-card-banner { width: 140px; height: 105px; }
  .setting-card-banner-placeholder { width: 140px; height: 105px; }
}

/* ===== LILY WIKI DETAIL MODAL ===== */
#lily-wiki-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4,10,28,0.78);
  z-index: 1300;
  align-items: center; justify-content: center;
  backdrop-filter: blur(5px);
}
#lily-wiki-modal.open { display: flex; }

.lily-wiki-inner {
  width: min(780px, 96vw);
  max-height: 92vh;
  background: #070f22;
  border-radius: 12px;
  border: 1px solid rgba(74,123,189,0.4);
  box-shadow: 0 0 0 1px rgba(74,123,189,0.12), 0 12px 60px rgba(0,0,0,0.75), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: lwModalIn 0.22s ease;
}
@keyframes lwModalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* header */
.lily-wiki-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 11px;
  background: linear-gradient(135deg, #0d1a35 0%, #091527 100%);
  border-bottom: 1px solid rgba(74,123,189,0.28);
  flex-shrink: 0;
  gap: 12px;
}
.lily-wiki-header-left {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.lily-wiki-tag {
  font-size: 9px; font-weight: 800; letter-spacing: 0.16em;
  color: rgba(74,123,189,0.9);
  background: rgba(74,123,189,0.14);
  border: 1px solid rgba(74,123,189,0.35);
  padding: 2px 8px; border-radius: 3px;
  white-space: nowrap; flex-shrink: 0;
}
.lily-wiki-title {
  font-size: 18px; font-weight: 800; color: #c8d8f8;
  letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lily-wiki-close {
  background: none; border: none; color: #6080a8; font-size: 17px;
  cursor: pointer; padding: 3px 7px; border-radius: 4px; flex-shrink: 0;
  transition: color 0.15s, background 0.15s; line-height: 1;
}
.lily-wiki-close:hover { color: #e0eeff; background: rgba(74,123,189,0.22); }

/* body — scrolls as a whole */
.lily-wiki-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(74,123,189,0.3) transparent;
  display: flex; flex-direction: column;
}

/* loading / error / empty */
.lily-wiki-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 60px 24px; color: #6080a8; font-size: 13px;
}
.lily-wiki-spinner {
  width: 30px; height: 30px;
  border: 2.5px solid rgba(74,123,189,0.25);
  border-top-color: #4a7bbd;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.lily-wiki-error { padding: 40px 24px; text-align: center; color: #e07070; font-size: 13px; }
.lily-wiki-empty { padding: 40px 24px; text-align: center; color: #6080a8; font-size: 13px; }

/* ── Two-column layout (portrait | nameplate+档案) ── */
.lwc-layout {
  display: flex;
  min-height: 340px;
  border-bottom: 1px solid rgba(74,123,189,0.15);
}

/* left col: portrait with overlaid vertical tab strip */
.lwc-left-col {
  width: 220px; flex-shrink: 0;
  background: linear-gradient(180deg, #0a1730 0%, #040c1e 100%);
  border-right: 1px solid rgba(74,123,189,0.2);
}

.lwc-portrait-wrap {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.lwc-portrait {
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.7));
  transition: opacity 0.18s;
}
.lwc-icon {
  position: absolute; top: 8px; left: 8px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(74,123,189,0.5);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  z-index: 2;
}

/* vertical tab strip overlaid on left edge of portrait */
.lwc-tab-strip {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 52px;
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 10px 0;
  z-index: 3;
  /* left-to-right fade mask */
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
  mask-image: linear-gradient(to right, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
}
.lwc-tab {
  display: block;
  background: rgba(6,14,30,0.55);
  border: none;
  border-left: 2px solid rgba(74,123,189,0.3);
  color: rgba(130,170,220,0.7);
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  padding: 5px 8px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
}
.lwc-tab:hover {
  background: rgba(74,123,189,0.28);
  color: rgba(200,230,255,0.95);
  border-left-color: rgba(100,160,240,0.8);
  transform: scaleY(1.08);
}
.lwc-tab.active {
  background: rgba(74,123,189,0.38);
  color: #d0e8ff;
  border-left-color: #6aa0e0;
}

/* right col: nameplate + 档案, no scroll needed */
.lwc-right-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

.lwc-nameplate-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid rgba(74,123,189,0.18);
  flex-shrink: 0;
}

.lwc-nameplate {
  padding: 18px 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-width: 0;
  background: linear-gradient(180deg, rgba(10,20,40,0.6) 0%, transparent 100%);
}

/* Wiki button in nameplate row */
.lwc-wiki-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  flex-shrink: 0;
  text-decoration: none;
  background: transparent;
  border-left: 1px solid rgba(74,123,189,0.2);
  color: rgba(100,180,255,0.75);
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
  cursor: pointer;
  min-width: 64px;
}
.lwc-wiki-btn:hover {
  background: rgba(74,123,189,0.08);
  color: #80ccff;
  box-shadow: inset 0 0 16px rgba(74,160,255,0.12);
}
.lwc-wiki-btn-label {
  font-size: 9px; font-weight: 900; letter-spacing: 0.2em;
  color: inherit;
  border: 1px solid currentColor;
  padding: 2px 6px; border-radius: 2px;
  text-shadow: 0 0 8px currentColor;
  box-shadow: 0 0 6px rgba(74,160,255,0.3);
  white-space: nowrap;
}
.lwc-wiki-btn:hover .lwc-wiki-btn-label {
  text-shadow: 0 0 12px currentColor;
  box-shadow: 0 0 10px rgba(74,160,255,0.55);
}
.lwc-wiki-btn-name {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  color: inherit; opacity: 0.7;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* sections inside right col (only 档案) */
.lwc-sections-wrap {
  flex: 1;
}

/* ── Bottom: 卡司 + 简介, full width ── */
.lwc-bottom {
  border-top: 1px solid rgba(74,123,189,0.12);
}
.lwc-ruby {
  font-size: 11px; color: #5a7aa0;
  letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lwc-name {
  font-size: 26px; font-weight: 800; color: #d0e4ff;
  letter-spacing: 0.06em; line-height: 1.2;
}
.lwc-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px;
}
.lwc-chip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(74,123,189,0.1);
  border: 1px solid rgba(74,123,189,0.25);
  border-radius: 4px; padding: 2px 8px;
}
.lwc-chip-label {
  font-size: 10px; font-weight: 700; color: rgba(74,123,189,0.85);
  letter-spacing: 0.06em;
}
.lwc-chip-val {
  font-size: 11px; font-weight: 600; color: #98b8d8;
}
.lwc-id-tags {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px;
}
.lwc-id-tag {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  padding: 2px 10px; border-radius: 3px; color: white;
}
.lwc-tag-linker     { background: #3a5a8a; border: 1px solid #5a8aaa; }
.lwc-tag-enhanced   { background: #6a2020; border: 1px solid #8a3030; }
.lwc-tag-huge       { background: #7a1a1a; border: 1px solid #aa3030; }
.lwc-tag-ability    { background: #1a3a7a; border: 1px solid #3a5aaa; }
.lwc-tag-instructor { background: #2a4a2a; border: 1px solid #4a7a4a; }
.lwc-tag-dead       { background: #222; border: 1px solid #555; }
.lwc-tag-missing    { background: #303040; border: 1px solid #505060; }

/* ── Sections ── */
.lwc-section {
  padding: 0 0 4px;
  border-bottom: 1px solid rgba(74,123,189,0.12);
}
.lwc-section:last-child { border-bottom: none; }
.lwc-section-title {
  font-size: 10px; font-weight: 800; letter-spacing: 0.14em;
  color: rgba(74,123,189,0.8);
  background: linear-gradient(90deg, rgba(74,123,189,0.12) 0%, transparent 100%);
  padding: 7px 20px 6px;
  border-bottom: 1px solid rgba(74,123,189,0.12);
  text-transform: uppercase;
}

/* ── Profile table ── */
.lwc-table {
  display: flex; flex-direction: column;
  padding: 4px 0;
}
.lwc-row {
  display: flex; align-items: baseline;
  padding: 5px 20px;
  border-bottom: 1px solid rgba(74,123,189,0.07);
}
.lwc-row:last-child { border-bottom: none; }
.lwc-row:hover { background: rgba(74,123,189,0.06); }
.lwc-key {
  font-size: 11px; font-weight: 700; color: #5a7aaa;
  letter-spacing: 0.06em; min-width: 90px; flex-shrink: 0;
}
.lwc-val {
  font-size: 13px; color: #b0cae8;
  line-height: 1.5;
}

/* ── Cast ── */
.lwc-cast-list { padding: 8px 20px 4px; display: flex; flex-direction: column; gap: 10px; }
.lwc-cast-row { display: flex; align-items: center; gap: 12px; }
.lwc-cast-img {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; border: 1.5px solid rgba(74,123,189,0.4);
  flex-shrink: 0;
}
.lwc-cast-info { display: flex; flex-direction: column; gap: 4px; }
.lwc-cast-name { font-size: 13px; font-weight: 700; color: #b8d0f0; }
.lwc-cast-work {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: #8098b8;
  margin-right: 8px;
}
.lwc-work-type {
  font-size: 9px; font-weight: 800; letter-spacing: 0.08em;
  padding: 1px 5px; border-radius: 2px; color: white;
}
.lwc-work-type-舞台 { background: #6a2020; }
.lwc-work-type-动画 { background: #1a3a7a; }
.lwc-work-type-手游 { background: #1a4a2a; }

/* ── Intro ── */
.lwc-intro { padding: 10px 20px 12px; }
.lwc-intro-line {
  font-size: 13px; line-height: 1.85; color: #98b8d8;
  margin: 0 0 4px;
}

/* mobile */
@media (max-width: 600px) {
  .lily-wiki-inner { width: 100vw; max-height: 100svh; border-radius: 0; }
  .lwc-layout { flex-direction: column; min-height: auto; }
  .lwc-left-col { width: 100%; height: 260px; border-right: none; border-bottom: 1px solid rgba(74,123,189,0.2); }
  .lwc-name { font-size: 20px; }
  .lwc-tab-strip { top: auto; bottom: 0; height: auto; width: 100%; flex-direction: row; justify-content: flex-start; align-items: flex-end; padding: 0 6px 4px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 40%, rgba(0,0,0,0.85) 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.85) 40%, rgba(0,0,0,0.85) 100%);
  }
  .lwc-tab { border-left: none; border-bottom: 2px solid rgba(74,123,189,0.3); width: auto; padding: 4px 10px; }
  .lwc-tab.active { border-bottom-color: #6aa0e0; }
}

/* ===== HOMEPAGE PANEL ===== */
#homepage-panel {
  flex: 1; min-width: 0; min-height: 0;
  overflow: hidden;
  background: #0d1728;
  display: flex; flex-direction: column;
}

#homepage-layout {
  display: flex; flex: 1; min-height: 0;
}

#homepage-content {
  flex: 1; min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(74,123,189,0.25) transparent;
  background: #0d1728;
  padding-bottom: 60px;
}
/* Override opus styles inside homepage for consistent dark theme */
#homepage-content .opus-article-title {
  font-size: 18px; font-weight: 800; color: #c8d8f8;
  padding: 20px 28px 6px; letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(74,123,189,0.18);
}
#homepage-content .opus-title-divider { display: none; }
#homepage-content .opus-cover-wrap {
  max-height: 220px;
  border-bottom: 1px solid rgba(74,123,189,0.2);
  background: #070e1e;
}
#homepage-content .opus-content { padding: 4px 28px; }
#homepage-content .opus-heading {
  font-size: 13px; font-weight: 700; letter-spacing: 0.14em;
  color: #4a7bbd; text-transform: uppercase;
  padding: 18px 0 6px;
  border-bottom: 1px solid rgba(74,123,189,0.2);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
#homepage-content .opus-heading::before {
  content: ''; display: inline-block;
  width: 3px; height: 14px;
  background: var(--accent, #4a7bbd);
  border-radius: 2px; flex-shrink: 0;
}
#homepage-content .opus-para {
  font-size: 13.5px; line-height: 1.95; color: #8aaad0;
}
#homepage-content .opus-blockquote {
  border-left: 2px solid rgba(74,123,189,0.5);
  background: rgba(74,123,189,0.06);
  padding: 8px 16px; color: #7090b8;
}
#homepage-content .opus-img-wrap { margin: 10px 0; }
#homepage-content .opus-img {
  border-radius: 6px;
  border: 1px solid rgba(74,123,189,0.2);
}
#homepage-content .opus-link-card {
  background: rgba(74,123,189,0.08);
  border: 1px solid rgba(74,123,189,0.25);
  border-radius: 6px; padding: 8px 14px;
  color: #7090b8; font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}
#homepage-content .opus-link-card:hover {
  background: rgba(74,123,189,0.15); border-color: rgba(74,123,189,0.45);
  color: #a0c0e8;
}
#homepage-content .opus-matched-row { padding: 6px 0; }
#homepage-content .opus-matched-card {
  border: 1px solid rgba(74,123,189,0.25);
  background: rgba(10,22,46,0.8);
}
#homepage-content .opus-matched-card:hover {
  border-color: rgba(74,123,189,0.5);
  background: rgba(20,38,70,0.9);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 1px rgba(74,123,189,0.2);
}

/* ── TOC sidebar ── */
#homepage-toc {
  width: 188px; flex-shrink: 0;
  background: #080f1e;
  border-left: 1px solid rgba(74,123,189,0.14);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: rgba(74,123,189,0.15) transparent;
  display: flex; flex-direction: column;
}

.homepage-toc-header {
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(74,123,189,0.14);
  flex-shrink: 0;
}
.homepage-toc-label {
  font-size: 9px; font-weight: 800; letter-spacing: 0.22em;
  color: #2a4a78; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.homepage-toc-label::before {
  content: ''; display: inline-block;
  width: 16px; height: 1px;
  background: #2a4a78;
}

#homepage-toc-list { padding: 8px 0 24px; }

.homepage-toc-item {
  font-size: 11px; line-height: 1.4; color: #3a5a88;
  padding: 6px 16px 6px 14px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.homepage-toc-item:hover {
  color: #7090b8; background: rgba(74,123,189,0.06);
  border-left-color: rgba(74,123,189,0.3);
}
.homepage-toc-item.active {
  color: #90b4e0; font-weight: 600;
  border-left-color: #4a7bbd;
  background: rgba(74,123,189,0.1);
}

/* loading / error */
.homepage-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 80px 24px; color: #3a5a88; font-size: 13px;
}
.homepage-error {
  padding: 40px 24px; text-align: center; color: #c06060; font-size: 13px;
}

/* ── Welcome section ── */
.hp-welcome {
  padding: 24px 28px 0;
}
.hp-welcome-body {
  background: rgba(10,20,42,0.7);
  border: 1px solid rgba(74,123,189,0.2);
  border-radius: 8px;
  padding: 20px 24px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.hp-welcome-line {
  font-size: 13.5px; line-height: 1.8; color: #8aaad0;
  margin: 0;
}
.hp-welcome-sub {
  color: #6080a0; font-size: 12.5px;
  margin-top: -4px;
}
.hp-welcome-up {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: #8aaad0;
}
.hp-welcome-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(74,123,189,0.5);
  object-fit: cover; flex-shrink: 0;
}
.hp-welcome-link {
  color: #6aa0e0; text-decoration: none;
  border-bottom: 1px solid rgba(74,123,189,0.3);
  transition: color 0.15s;
}
.hp-welcome-link:hover { color: #a0c8f8; border-bottom-color: rgba(74,123,189,0.6); }
.hp-welcome-qq {
  font-weight: 700; color: #7090b8;
  font-family: monospace; letter-spacing: 0.05em;
}
.hp-welcome-img-wrap {
  margin-top: 6px;
}
.hp-welcome-img {
  max-width: 200px; border-radius: 6px;
  border: 1px solid rgba(74,123,189,0.2);
  display: block;
}
.hp-welcome-divider {
  height: 1px; margin: 20px 0 0;
  background: linear-gradient(to right, transparent, rgba(74,123,189,0.3) 20%, rgba(74,123,189,0.3) 80%, transparent);
}

/* ── Image lightbox ── */
#hp-lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(4,8,20,0.92);
  z-index: 2000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#hp-lightbox.open { display: flex; }
#hp-lightbox.locked { pointer-events: auto; }
#hp-lightbox-inner {
  position: relative; max-width: 94vw; max-height: 92vh;
  min-width: 220px; min-height: 160px;
  display: flex; align-items: center; justify-content: center;
}
#hp-lightbox-img {
  max-width: 94vw; max-height: 88vh;
  border-radius: 8px;
  border: 1px solid rgba(74,123,189,0.3);
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.08s ease;
  will-change: transform;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}
#hp-lightbox-close {
  position: absolute; top: -14px; right: -14px;
  width: 28px; height: 28px;
  background: #0d1728; border: 1px solid rgba(74,123,189,0.4);
  border-radius: 50%; color: #7a9ac8;
  font-size: 13px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 12;
}

#hp-lightbox-close:hover {
  background: rgba(74,123,189,0.3);
  color: #c8d8f8;
}

#hp-lightbox-close:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#card-anim-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(5, 12, 28, 0.82);
  align-items: center;
  justify-content: center;
}
#card-anim-lightbox.open { display: flex; }
#card-anim-lightbox-inner {
  position: relative;
  width: min(92vw, 980px);
  height: min(88vh, 1360px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(166, 191, 236, 0.28);
  box-shadow: 0 18px 56px rgba(0,0,0,0.45);
  background: #081326;
}
#card-anim-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #081326;
}
#card-anim-lightbox-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(166, 191, 236, 0.3);
  background: rgba(23, 42, 78, 0.72);
  color: #d7e7ff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
#card-anim-lightbox-close:hover {
  background: rgba(74,123,189,0.3);
  color: #c8d8f8;
}

/* ===== JobSpine Lightbox ===== */
#jobspine-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(5, 12, 28, 0.82);
  align-items: center;
  justify-content: center;
}
#jobspine-lightbox.open { display: flex; }
#jobspine-lightbox-inner {
  position: relative;
  width: min(96vw, 980px);
  height: min(92vh, 1000px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(166, 191, 236, 0.28);
  box-shadow: 0 18px 56px rgba(0,0,0,0.45);
  background: #0d1a2e;
}
#jobspine-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #0d1a2e;
}
#jobspine-lightbox-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(166, 191, 236, 0.3);
  background: rgba(23, 42, 78, 0.72);
  color: #d7e7ff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
#jobspine-lightbox-close:hover { background: rgba(74,123,189,0.3); color: #c8d8f8; }

/* ===== Cloth-view choice dialog ===== */
#clothview-dialog {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(5, 12, 28, 0.72);
  align-items: center;
  justify-content: center;
}
#clothview-dialog.open { display: flex; }
#clothview-dialog-inner {
  position: relative;
  background: #0e1d38;
  border: 1px solid rgba(166, 191, 236, 0.3);
  border-radius: 14px;
  padding: 32px 36px 28px;
  min-width: 280px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
#clothview-dialog-label {
  font-size: 15px;
  color: #c8d8f8;
  margin-bottom: 20px;
  font-weight: 600;
}
#clothview-dialog-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
}
#clothview-btn-static, #clothview-btn-dynamic {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  border: 1px solid rgba(166, 191, 236, 0.35);
  background: rgba(30, 60, 110, 0.6);
  color: #d7e7ff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
#clothview-btn-static:hover { background: rgba(50, 90, 150, 0.7); }
#clothview-btn-dynamic { border-color: rgba(130, 190, 255, 0.5); }
#clothview-btn-dynamic:hover { background: rgba(40, 100, 180, 0.7); }
#clothview-dialog-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(166, 191, 236, 0.3);
  background: rgba(23, 42, 78, 0.72);
  color: #d7e7ff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
#clothview-dialog-close:hover { background: rgba(74,123,189,0.3); }


#hp-lightbox-loading {
  position: absolute;
  left: 50%;
  top: 64%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 12, 28, 0.78);
  color: #cde0ff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(108, 169, 255, 0.45);
  border: 1px solid rgba(101, 159, 248, 0.28);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 180px;
  z-index: 6;
  user-select: none;
  pointer-events: none;
}

#hp-lightbox-cloth {
  position: absolute;
  top: 12px;
  left: 12px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  max-height: calc(88vh - 24px);
  overflow: hidden;
  padding: 10px 7px;
  border-radius: 10px;
  border: 1px solid rgba(108, 166, 255, 0.38);
  background: linear-gradient(180deg, rgba(18, 32, 58, 0.82), rgba(9, 18, 36, 0.66));
  color: #d9e9ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.35;
  text-shadow: 0 0 10px rgba(125, 183, 255, 0.42);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(120, 179, 255, 0.12) inset;
  z-index: 7;
  pointer-events: none;
}

@media (max-width: 700px) {
  #homepage-toc { display: none; }
  #homepage-content .opus-content { padding: 4px 16px; }
  #homepage-content .opus-article-title { padding: 16px 16px 6px; }
}
