:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #243244;
  --ink-2: #5a6b80;
  --ink-3: #8d9bad;
  --line: #e3e8f0;
  --accent: #3d7ea6;
  --accent-soft: #e8f2f8;
  --gold: #e8a33d;
  --gold-soft: #fdf3e3;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30, 45, 70, .06), 0 6px 18px rgba(30, 45, 70, .05);
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(1200px 400px at 80% -100px, rgba(61, 126, 166, .10), transparent 60%),
    radial-gradient(900px 380px at -100px 30%, rgba(232, 163, 61, .07), transparent 60%),
    var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- 头像图片(自动回退到字牌) ---------- */
.avatar { position: relative; }
.av-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; border-radius: inherit; z-index: 1;
}
.avatar::after { z-index: 2; }
.avatar-big { box-shadow: var(--shadow); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #3d7ea6, #2c5d80);
  color: #fff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.brand-text { line-height: 1.25; }
.brand-text strong { display: block; font-size: 17px; letter-spacing: .5px; }
.brand-text em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink-3); letter-spacing: 1px; }

.search-box {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; width: min(360px, 42vw); color: var(--ink-3);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,126,166,.14); color: var(--accent); }
.search-box input {
  border: 0; outline: 0; background: transparent; flex: 1;
  font-size: 14px; color: var(--ink); min-width: 0;
}
.search-box button {
  border: 0; background: #dfe5ee; color: var(--ink-2); width: 18px; height: 18px;
  border-radius: 50%; font-size: 13px; line-height: 1; cursor: pointer; flex: none;
}
.search-box button:hover { background: #c9d2df; }

/* ---------- 布局 ---------- */
.layout {
  max-width: 1280px; width: 100%; margin: 0 auto; padding: 20px;
  display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 20px;
  flex: 1; align-items: start;
}
.sidebar {
  position: sticky; top: 74px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100vh - 96px);
}
.filters { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); }
.filter-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 12px; padding: 3px 10px; cursor: pointer; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px; transition: all .12s;
  user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .dot { outline: 2px solid rgba(255,255,255,.6); }

.char-list { overflow-y: auto; padding: 8px; flex: 1; }
.char-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 10px; cursor: pointer;
  text-decoration: none; color: inherit; border: 1px solid transparent;
  transition: background .12s;
}
.char-item:hover { background: var(--accent-soft); }
.char-item.active { background: var(--accent-soft); border-color: rgba(61,126,166,.35); }
.char-item .avatar {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  position: relative; overflow: hidden;
}
.char-item .avatar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,.28), transparent 45%);
}
.char-item .ci-body { min-width: 0; line-height: 1.3; }
.char-item .ci-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-item .ci-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.char-item .stars { color: var(--gold); font-size: 11px; letter-spacing: 1px; }
.sidebar-foot {
  padding: 8px 14px; font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--line);
}

/* ---------- 主区 ---------- */
.main { min-width: 0; }

/* 首页 */
.hero {
  background: linear-gradient(120deg, #2c5d80 0%, #3d7ea6 55%, #5794b8 100%);
  border-radius: var(--radius); color: #fff; padding: 30px 32px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.10);
}
.hero::before { width: 260px; height: 260px; right: -60px; top: -120px; }
.hero::after { width: 150px; height: 150px; right: 130px; bottom: -80px; background: rgba(255,255,255,.07); }
.hero h1 { font-size: 24px; letter-spacing: 1px; margin-bottom: 8px; }
.hero p { font-size: 13.5px; opacity: .88; max-width: 640px; line-height: 1.8; }
.hero .stats { display: flex; gap: 26px; margin-top: 18px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .stat b { font-size: 22px; font-weight: 700; }
.hero .stat span { display: block; font-size: 12px; opacity: .8; margin-top: 2px; }

.home-section { margin-top: 22px; }
.home-section h2 { font-size: 15px; color: var(--ink-2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.home-section h2::before { content: ''; width: 4px; height: 15px; border-radius: 2px; background: var(--accent); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(30,45,70,.08), 0 12px 28px rgba(30,45,70,.10); }
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--elem, var(--accent)); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card .avatar {
  width: 52px; height: 52px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px; text-shadow: 0 1px 2px rgba(0,0,0,.25);
  position: relative; overflow: hidden;
}
.card .avatar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255,255,255,.28), transparent 45%); }
.card .ch-name { font-size: 16.5px; font-weight: 700; line-height: 1.3; }
.card .ch-en { font-size: 11px; color: var(--ink-3); letter-spacing: .5px; text-transform: uppercase; }
.card .stars { color: var(--gold); font-size: 13px; letter-spacing: 2px; }
.card .ch-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.elem { color: #fff; border: 0; }
.card .ch-intro {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* 游戏画集 */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.gal-item {
  margin: 0; border-radius: 12px; overflow: hidden; position: relative;
  border: 1px solid var(--line); box-shadow: var(--shadow); background: #0e1420;
}
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 16/9; }
.gal-item figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 12px 8px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(10, 16, 26, .78));
}

/* 角色详情 */
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.detail-head { padding: 26px 30px 20px; display: flex; gap: 24px; position: relative; overflow: hidden; }
.detail-head .dh-bg {
  position: absolute; inset: 0; opacity: .08; pointer-events: none;
  background: radial-gradient(500px 200px at 20% 0%, var(--elem, var(--accent)), transparent 70%);
}
.detail-head .avatar {
  width: 92px; height: 92px; border-radius: 20px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 42px; font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,.25);
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.detail-head .avatar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255,255,255,.3), transparent 45%); }
.dh-body { position: relative; min-width: 0; }
.dh-names { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.dh-names h1 { font-size: 26px; }
.dh-names .en { font-size: 12.5px; color: var(--ink-3); letter-spacing: 1px; text-transform: uppercase; }
.dh-stars { color: var(--gold); font-size: 15px; letter-spacing: 2px; margin: 4px 0 10px; }
.dh-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.badge {
  font-size: 12px; padding: 3.5px 11px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.badge b { font-weight: 600; color: var(--ink); }
.badge.elem { color: #fff; border: 0; font-weight: 600; }
.dh-facts { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--ink-2); }
.dh-facts b { color: var(--ink-3); font-weight: 500; margin-right: 4px; }

.tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-btn {
  border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--ink-2);
  padding: 11px 16px; position: relative; white-space: nowrap;
}
.tab-btn sup { font-size: 10.5px; color: var(--ink-3); margin-left: 3px; }
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: var(--accent); font-weight: 600; }
.tab-btn.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px;
  border-radius: 2px; background: var(--accent);
}
.tab-body { padding: 22px 30px 30px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.subtab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer;
  padding: 5px 14px; font-size: 12.5px; color: var(--ink-2);
}
.subtab.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.quote {
  border-left: 3px solid var(--gold); background: var(--gold-soft);
  padding: 12px 16px; border-radius: 0 10px 10px 0;
  font-size: 13.5px; color: #7a5a20; line-height: 1.8; margin-bottom: 20px;
}
.quote .q-label { font-size: 11px; color: #b08b4a; display: block; margin-bottom: 3px; letter-spacing: 1px; }

.prose { font-size: 14.5px; line-height: 2; color: var(--ink); white-space: pre-wrap; }
.section-title {
  font-size: 13px; color: var(--ink-3); letter-spacing: 2px; margin: 26px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.section-title:first-child { margin-top: 0; }

.story-item { padding: 14px 0 4px; }
.story-item + .story-item { border-top: 1px dashed var(--line); }
.story-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.story-head h3 { font-size: 15.5px; }
.unlock {
  font-size: 11px; color: var(--accent); background: var(--accent-soft);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}

.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }

/* 技能 */
.skill-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 15px 18px; margin-bottom: 12px;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.sk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.sk-head h3 { font-size: 16px; }
.sk-type {
  color: #fff; font-size: 11.5px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
  letter-spacing: 1px; flex: none;
}
.sk-desc { font-size: 13.5px; line-height: 1.95; color: var(--ink); white-space: pre-wrap; }
.voice-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.voice-card .v-title {
  font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.voice-card .v-title::before { content: '♪'; font-size: 11px; }
.voice-card .v-text { font-size: 13.5px; line-height: 1.85; color: var(--ink); }
.voice-card .v-unlock { margin-top: 8px; font-size: 11px; color: var(--ink-3); }

.words-list { display: flex; flex-direction: column; gap: 2px; }
.word-row { display: flex; gap: 14px; padding: 10px 4px; align-items: baseline; }
.word-row + .word-row { border-top: 1px dashed var(--line); }
.word-label {
  flex: none; width: 150px; text-align: right; font-size: 12px; color: var(--ink-3); line-height: 1.6;
}
.word-text { flex: 1; font-size: 14px; line-height: 1.9; min-width: 0; }

.plot-list { position: relative; padding-left: 22px; }
.plot-list::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.plot-item { position: relative; padding: 0 0 22px; }
.plot-item::before {
  content: ''; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 3px solid var(--accent);
}
.plot-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plot-head .ch-no { font-size: 11px; color: var(--ink-3); letter-spacing: 1px; }
.plot-head h3 { font-size: 16px; }
.plot-text { margin-top: 8px; font-size: 13.5px; line-height: 1.9; color: var(--ink-2); white-space: pre-wrap; }
.plot-empty { margin-top: 6px; font-size: 12px; color: var(--ink-3); font-style: italic; }

.detail-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.nav-btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 18px; cursor: pointer; font-size: 13.5px; color: var(--ink-2);
  max-width: 46%; text-decoration: none; display: block; transition: all .12s;
  box-shadow: var(--shadow);
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn small { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.nav-btn.next { text-align: right; margin-left: auto; }

.empty-tip { padding: 60px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }
mark { background: #ffe9a8; border-radius: 3px; padding: 0 1px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .char-list { max-height: 300px; }
  .detail-head { flex-direction: column; gap: 14px; }
  .word-label { width: 110px; }
}
.foot {
  text-align: center; font-size: 11.5px; color: var(--ink-3);
  padding: 18px 20px 22px; border-top: 1px solid var(--line); margin-top: 10px;
  background: rgba(255,255,255,.6);
}
