:root {
  color-scheme: light;
  --accent: #e33f70;
  --accent-strong: #bb2855;
  --accent-soft: #fff0f4;
  --teal: #168b86;
  --teal-soft: #e8f6f4;
  --ink: #242127;
  --muted: #716b73;
  --faint: #9b949c;
  --line: #e8e3e6;
  --line-strong: #d9d1d5;
  --surface: #ffffff;
  --surface-alt: #f7f5f6;
  --canvas: #f2f0f1;
  --header: rgba(255, 255, 255, .94);
  --shadow: 0 8px 24px rgba(43, 29, 36, .07);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "Segoe UI", "Microsoft YaHei UI", "Noto Sans SC", system-ui, sans-serif; letter-spacing: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar { height: 70px; padding: 0 clamp(18px, 3.2vw, 52px); display: flex; align-items: center; gap: 28px; position: sticky; top: 0; z-index: 20; background: var(--header); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 7px 7px 7px 2px; font: 700 22px/1 Arial, sans-serif; box-shadow: 3px 3px 0 #f4b5c8; }
.brand b { display: block; font: 700 15px/1.1 Arial, sans-serif; letter-spacing: 1px; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.main-nav { align-self: stretch; display: flex; align-items: center; gap: 24px; margin-right: auto; }
.nav-link { height: 100%; padding: 2px 1px 0; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: 13px; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--accent-strong); border-color: var(--accent); font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
#voiceCount { padding-right: 10px; white-space: nowrap; }
.text-button, .icon-button { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); transition: border-color .15s, background .15s, color .15s; }
.text-button { padding: 7px 11px; font-size: 12px; font-weight: 600; }
.icon-button { width: 34px; padding: 0; font-size: 16px; }
.text-button:hover, .icon-button:hover { border-color: #d68ca2; color: var(--accent-strong); background: var(--accent-soft); }
.language-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

.layout { width: 100%; max-width: 1500px; min-height: calc(100vh - 70px); margin: 0 auto; display: grid; grid-template-columns: 330px minmax(0, 1fr); background: var(--surface); border-inline: 1px solid var(--line); }
.character-panel { min-width: 0; padding: 28px 20px 20px; background: var(--surface-alt); border-right: 1px solid var(--line); position: sticky; top: 70px; align-self: start; height: calc(100vh - 70px); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: end; margin: 0 2px 16px; }
.panel-head h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.1; }
.panel-head > span { color: var(--faint); font-size: 12px; }
.eyebrow { margin: 0; color: var(--teal); font: 700 10px/1.2 Arial, sans-serif; letter-spacing: 1.4px; }
.search { height: 42px; margin-bottom: 15px; padding: 0 12px; display: flex; align-items: center; gap: 8px; color: var(--faint); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22, 139, 134, .1); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search input::placeholder { color: var(--faint); }
.character-grid { height: calc(100% - 96px); padding: 1px 4px 26px 0; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 8px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.character-card { min-width: 0; height: 82px; padding: 8px 6px; display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 7px; color: var(--ink); background: transparent; text-align: left; transition: background .15s, border-color .15s, transform .15s; }
.character-card:hover { background: var(--surface); border-color: var(--line); transform: translateY(-1px); }
.character-card.active { background: var(--surface); border-color: #eaa2b7; box-shadow: 0 3px 12px rgba(180, 51, 89, .1); }
.character-card img { width: 48px; height: 48px; display: block; object-fit: cover; border-radius: 50%; background: var(--line); }
.character-card.active img { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px #e88da8; }
.character-copy { min-width: 0; display: block; }
.character-copy b, .character-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.character-copy b { font-size: 11px; font-weight: 700; }
.character-copy small { margin-top: 4px; color: var(--faint); font-size: 9px; }

.content-panel { min-width: 0; padding: clamp(30px, 4vw, 58px) clamp(24px, 5vw, 70px); background: var(--surface); }
#content { max-width: 1000px; margin: 0 auto; }
.loading { min-height: 65vh; display: grid; place-items: center; align-content: center; color: var(--muted); font-size: 13px; }
.loading > span { width: 28px; height: 28px; border: 3px solid #f7c5d4; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.character-hero { min-height: 124px; padding: 4px 2px 30px; display: flex; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); }
.character-hero img { width: 94px; height: 94px; flex: 0 0 auto; object-fit: cover; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 5px var(--surface), 0 0 0 6px #ef9db5, var(--shadow); }
.character-hero h2, .global-hero h2 { margin: 5px 0 7px; font-size: clamp(27px, 3vw, 34px); line-height: 1.2; }
.character-hero p:last-child, .global-hero p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.global-hero { padding: 10px 2px 30px; border-bottom: 1px solid var(--line); }

.filter-row { padding: 22px 0 16px; display: flex; flex-wrap: wrap; gap: 7px; }
.filter { height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); background: var(--surface); font-size: 12px; transition: all .15s; }
.filter small { min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--surface-alt); color: var(--faint); font: 600 9px/1.5 Arial, sans-serif; }
.filter:hover { border-color: #d991a6; color: var(--accent-strong); }
.filter.active { border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: 0 3px 9px rgba(227, 63, 112, .2); }
.filter.active small { color: var(--accent-strong); background: #fff; }
.voice-toolbar { min-height: 45px; padding: 0 0 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.voice-toolbar strong { font-size: 15px; }
.voice-toolbar > span { color: var(--faint); font-size: 11px; }
.autoplay { margin-left: auto; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.autoplay input { width: 15px; height: 15px; accent-color: var(--teal); }
.voice-search { max-width: 100%; margin: 14px 0 3px; }

.voice-list { min-height: 260px; padding-bottom: 8px; }
.voice-item { min-height: 76px; padding: 13px 6px; display: grid; grid-template-columns: 38px minmax(0, 1fr) 32px 38px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); transition: background .15s; }
.voice-item:hover { background: var(--accent-soft); }
.voice-item.playing { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.play { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--accent-strong); background: var(--accent-soft); font-size: 11px; transition: transform .15s, background .15s, color .15s; }
.play:hover { transform: scale(1.06); color: #fff; background: var(--accent); }
.voice-item.playing .play { color: #fff; background: var(--teal); }
.voice-copy { min-width: 0; }
.voice-meta { display: flex; align-items: center; gap: 8px; }
.voice-meta b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; font-weight: 700; }
.voice-meta span { flex: 0 0 auto; padding: 2px 6px; border-radius: 3px; color: var(--teal); background: var(--teal-soft); font-size: 9px; font-weight: 700; }
.voice-copy p { margin: 4px 0 0; overflow: hidden; color: var(--ink); font-size: 13px; line-height: 1.55; text-overflow: ellipsis; white-space: nowrap; }
.voice-copy mark { padding: 0 2px; border-radius: 2px; color: #5f3410; background: #ffd99b; font: inherit; }
.download-button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 5px; color: var(--faint); text-decoration: none; font-size: 17px; }
.download-button:hover { color: var(--accent-strong); background: #fff; }
.voice-item time { color: var(--faint); font: 500 10px/1 Arial, sans-serif; text-align: right; }
.empty { margin: 0; padding: 64px 0; color: var(--muted); font-size: 13px; text-align: center; }

.pagination { padding: 25px 0 36px; display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.pagination button { min-height: 34px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); font-size: 12px; }
.pagination button:hover:not(:disabled) { border-color: #d68ca2; color: var(--accent-strong); }
.pagination button:disabled { opacity: .38; cursor: default; }
.pagination label { display: flex; align-items: center; gap: 5px; }
.pagination input { width: 52px; height: 34px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); text-align: center; font-size: 12px; }

.global-view .layout { display: block; max-width: 1200px; }
.global-view .character-panel { display: none; }
.global-view .content-panel { min-height: calc(100vh - 70px); }

html[data-theme="dark"] {
  color-scheme: dark;
  --accent: #f05a86;
  --accent-strong: #ff8dab;
  --accent-soft: #3b222c;
  --teal: #67c9c1;
  --teal-soft: #193b39;
  --ink: #f2edf0;
  --muted: #beb5ba;
  --faint: #91878d;
  --line: #3c363a;
  --line-strong: #51484e;
  --surface: #211e22;
  --surface-alt: #29262a;
  --canvas: #181619;
  --header: rgba(30, 27, 31, .94);
  --shadow: 0 8px 24px rgba(0, 0, 0, .22);
}
html[data-theme="dark"] .brand-mark { box-shadow: 3px 3px 0 #613142; }
html[data-theme="dark"] .character-card.active { border-color: #8b4a60; }
html[data-theme="dark"] .voice-copy mark { color: #fff1d7; background: #70491e; }
html[data-theme="dark"] .download-button:hover { background: #302a2e; }

@media (max-width: 900px) {
  .topbar { gap: 18px; }
  #voiceCount { display: none; }
  .layout { grid-template-columns: 270px minmax(0, 1fr); }
  .character-grid { grid-template-columns: 1fr; }
  .content-panel { padding-inline: 30px; }
}

@media (max-width: 700px) {
  .topbar { height: auto; min-height: 62px; padding: 0 14px; gap: 12px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .main-nav { gap: 14px; }
  .nav-link { font-size: 12px; }
  .topbar-actions { margin-left: auto; }
  .language-button { width: 34px; padding: 0; }
  .language-button #langLabel { display: none; }
  .layout { display: block; min-height: calc(100vh - 62px); border: 0; }
  .character-panel { height: 140px; padding: 10px 14px; position: static; border: 0; border-bottom: 1px solid var(--line); }
  .panel-head { display: none; }
  .character-panel > .search { height: 36px; margin: 0 0 7px; display: flex; }
  .character-grid { height: 76px; padding: 4px 0 9px; display: flex; gap: 7px; overflow-x: auto; overflow-y: hidden; }
  .character-card { width: 64px; height: 64px; flex: 0 0 64px; padding: 4px; display: block; text-align: center; }
  .character-card img { width: 44px; height: 44px; margin: 0 auto; }
  .character-copy b { margin-top: 3px; font-size: 9px; }
  .character-copy small { display: none; }
  .content-panel { padding: 25px 16px; }
  .character-hero { min-height: 96px; padding-bottom: 24px; gap: 16px; }
  .character-hero img { width: 70px; height: 70px; }
  .character-hero h2, .global-hero h2 { font-size: 24px; }
  .filter-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 12px; }
  .filter { flex: 0 0 auto; }
  .voice-toolbar { flex-wrap: wrap; }
  .voice-toolbar .autoplay { margin-left: 0; }
  #batchDownload { margin-left: auto; }
  .voice-item { grid-template-columns: 36px minmax(0, 1fr) 30px; gap: 9px; padding-inline: 2px; }
  .voice-item time { display: none; }
  .voice-copy p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .pagination { gap: 8px; }
  .pagination button { padding-inline: 9px; }
  .global-view .content-panel { min-height: calc(100vh - 62px); }
}
