:root {
    --bg: #111318;
    --panel: #1a1d24;
    --panel-soft: #20242d;
    --border: #343a48;
    --text: #edf0f5;
    --muted: #9ba3b3;
    --purple: #b98be8;
    --green: #78c985;
    --danger: #ef8c8c;
    --font-serif: "Noto Serif SC", serif;
    --font-sans: "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0, rgba(155, 107, 201, 0.12), transparent 35rem),
        radial-gradient(circle at 90% 90%, rgba(95, 173, 106, 0.08), transparent 32rem),
        var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
}

.home-shell { width: min(1040px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0; }
.home-header { position: relative; margin-bottom: 1.5rem; text-align: center; }
.home-title-row { display: flex; align-items: baseline; justify-content: center; gap: 0.8rem; }
.home-header h1 { margin: 0.35rem 0; font-family: var(--font-serif); font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: 0.12em; }
.home-header > p { color: var(--muted); font-size: 0.88rem; }
.home-version { color: var(--purple); font-size: 1rem; font-weight: 600; white-space: nowrap; }


.home-grid > :only-child { grid-column: 1 / -1; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr); gap: 1rem; }
.home-panel { margin-bottom: 1rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: 14px; background: rgba(26, 29, 36, 0.94); box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin-top: 0.18rem; font-family: var(--font-serif); font-size: 1.15rem; }
.status-badge { padding: 0.35rem 0.65rem; border: 1px solid rgba(185, 139, 232, 0.45); border-radius: 999px; color: var(--purple); font-size: 0.78rem; }
.home-main-role { display: flex; align-items: center; justify-content: space-between; margin: 1rem 0; padding: 0.8rem; border-radius: 9px; background: var(--panel-soft); }
.home-main-role span { color: var(--muted); font-size: 0.78rem; }
.home-main-role strong { color: var(--text); font-family: var(--font-serif); }

.save-version-label { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.8rem; }
.save-version-label[hidden] { display: none; }
.save-version-select { min-width: 9rem; padding: 0.48rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }

.home-save-format-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.home-save-format-row label { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.save-format-select { flex: 1; min-width: 0; padding: 0.48rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
.home-sn-uid-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.sn-uid-input { flex: 1; min-width: 0; padding: 0.48rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.82rem; }
.sn-uid-input::placeholder { color: var(--muted); opacity: 0.7; }
.home-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem; padding: 0.65rem 1rem; border: 1px solid transparent; border-radius: 8px; cursor: pointer; color: var(--text); font: 500 0.85rem var(--font-sans); text-decoration: none; transition: transform 0.15s, border-color 0.15s, background 0.15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { border-color: rgba(185, 139, 232, 0.55); background: rgba(155, 107, 201, 0.2); color: #d7b3fa; }
.btn-secondary { border-color: var(--border); background: transparent; color: var(--muted); }
.home-message { min-height: 1.5rem; margin-top: 0.8rem; color: var(--muted); font-size: 0.76rem; line-height: 1.5; }
.home-message.is-success { color: var(--green); }
.home-message.is-error { color: var(--danger); }
.archive-import-panel { display: flex; flex-direction: column; }
.home-panel-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: auto; }
.home-panel-footer .home-message { margin-bottom: 0; }
.home-community { margin-top: 0.8rem; color: var(--muted); font-size: 0.76rem; line-height: 1.5; white-space: nowrap; }

.exporter-panel { display: flex; flex-direction: column; }
.exporter-panel > p { margin: 1rem 0; color: var(--muted); font-size: 0.8rem; line-height: 1.6; }
.exporter-actions { display: grid; gap: 0.65rem; width: 100%; margin-top: auto; }
.exporter-download, .exporter-query { width: 100%; }
.exporter-download[hidden] { display: none; }
.module-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.module-grid.is-gated .module-card { opacity: 0.45; pointer-events: none; filter: saturate(0.4); }
.module-card { min-height: 8.5rem; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-soft); color: var(--text); text-decoration: none; transition: transform 0.15s, border-color 0.15s, background 0.15s; }
.module-card:hover { transform: translateY(-2px); border-color: rgba(185, 139, 232, 0.65); background: rgba(155, 107, 201, 0.1); }
.module-card strong { display: block; margin-bottom: 0.65rem; color: var(--purple); font-family: var(--font-serif); }
.module-card span { color: var(--muted); font-size: 0.75rem; line-height: 1.6; }

.changelog-button { position: relative; margin-left: auto; white-space: nowrap; }
.changelog-unread-dot {
    position: absolute;
    top: -0.22rem;
    right: -0.22rem;
    width: 0.58rem;
    height: 0.58rem;
    border: 2px solid var(--panel);
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.changelog-unread-dot[hidden], .changelog-modal-overlay[hidden] { display: none; }
body.changelog-modal-open { overflow: hidden; }
.changelog-modal-overlay {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(5, 7, 10, 0.72);
    backdrop-filter: blur(4px);
}
.changelog-modal {
    display: flex;
    flex-direction: column;
    width: min(760px, calc(100vw - 2rem));
    max-height: min(82vh, 52rem);
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
.changelog-panel { overflow-y: auto; scrollbar-color: var(--border) transparent; }
.changelog-modal-body { min-height: 0; padding-right: 0.35rem; overscroll-behavior: contain; }
.changelog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.changelog-header h2 { font-family: var(--font-serif); font-size: 1.15rem; }
.changelog-kicker { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.12em; }
.changelog-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: 1.65rem/1 var(--font-sans);
}
.changelog-close-button:hover { border-color: var(--danger); color: var(--danger); }
.changelog-button:focus-visible, .changelog-close-button:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.changelog-entry { padding: 1rem 0 0.25rem; }
.changelog-entry + .changelog-entry { margin-top: 0.75rem; border-top: 1px solid var(--border); }
.changelog-entry.is-current { margin-top: 0.85rem; padding: 0.9rem; border: 1px solid rgba(185, 139, 232, 0.4); border-radius: 10px; background: rgba(155, 107, 201, 0.08); }
.changelog-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.changelog-meta h3 { color: var(--purple); font-family: var(--font-serif); }
.changelog-meta h3 time { color: inherit; font: inherit; }
.changelog-entry ul { margin: 0.6rem 0 0 1.2rem; color: var(--muted); font-size: 0.78rem; line-height: 1.65; }
.changelog-entry li + li { margin-top: 0.3rem; }
.changelog-entry li::marker { color: var(--purple); }
.changelog-entry a {
    color: #cda8f3;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}
.changelog-entry a:hover,
.changelog-entry a:focus-visible { color: #ead9ff; }
.app-footer { padding: 0.5rem 0 1.5rem; color: var(--muted); font-size: 0.72rem; text-align: center; }
.app-footer a { color: var(--purple); }

@media (max-width: 760px) {
    .home-shell { width: min(100% - 1rem, 1040px); padding: 1.5rem 0; }
    .home-grid { grid-template-columns: 1fr; }
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
    .home-header h1 { letter-spacing: 0.06em; }
    .home-title-row { gap: 0.55rem; }
    .home-version { font-size: 0.9rem; }
    .home-panel-footer { align-items: flex-start; flex-direction: column; gap: 0; }
    .panel-heading { align-items: stretch; }
    .home-panel { padding: 1rem; }
    
.home-save-format-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.home-save-format-row label { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.save-format-select { flex: 1; min-width: 0; padding: 0.48rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
.home-sn-uid-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.sn-uid-input { flex: 1; min-width: 0; padding: 0.48rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.82rem; }
.sn-uid-input::placeholder { color: var(--muted); opacity: 0.7; }
.home-actions, .save-version-label { align-items: stretch; flex-direction: column; }
    .changelog-button { margin-left: 0; }
    .save-version-select { width: 100%; }
    .module-grid { grid-template-columns: 1fr; }
    .module-card { min-height: auto; }
    .changelog-modal-overlay { align-items: stretch; padding: 0.4rem; }
    .changelog-modal { width: 100%; max-height: calc(100dvh - 0.8rem); padding: 1rem; border-radius: 8px; }
}

/* Feature center from the reference layout */
.feature-center-panel {
    padding: 1.35rem;
}

.feature-center-heading {
    align-items: center;
}

.feature-search-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.55rem 1rem;
    margin-top: 1rem;
}

.feature-search-label {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.78rem;
}

.feature-search-input {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.68rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font: inherit;
}

.feature-search-input:focus-visible,
.feature-favorite-button:focus-visible,
.feature-card-link:focus-visible {
    outline: 2px solid var(--purple);
    outline-offset: 3px;
}

.feature-search-count {
    align-self: center;
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.favorite-section,
.feature-module {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

.favorite-section h3,
.feature-module-heading h3 {
    color: var(--text);
    font-family: var(--font-serif);
    font-size: 1rem;
}

.feature-module-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.7rem;
}

.feature-module-heading p,
.feature-module-heading > span {
    margin-top: 0.28rem;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.5;
}

.favorite-grid,
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 0.7rem;
}

.feature-card {
    position: relative;
    min-width: 0;
}

.feature-access-scope.is-gated .feature-card-link {
    opacity: 0.45;
    pointer-events: none;
    filter: saturate(0.4);
}

.feature-access-scope.is-gated .feature-card.is-public .feature-card-link {
    opacity: 1;
    pointer-events: auto;
    filter: none;
}

.wuxia-home .feature-card .module-card {
    display: block;
    min-height: 7.5rem;
    padding: 1rem 1rem 2.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-soft);
}

.wuxia-home .feature-card .module-card::after {
    display: none;
}

.feature-favorite-button {
    position: absolute;
    right: 0.7rem;
    bottom: 0.65rem;
    min-height: 2rem;
    padding: 0.32rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: 500 0.72rem var(--font-sans);
}

.feature-favorite-button:hover,
.feature-favorite-button.is-favorite {
    border-color: var(--purple);
    color: var(--purple);
}

.feature-empty {
    padding: 0.9rem 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.feature-search-empty {
    text-align: center;
}

html[data-theme="bright"] .feature-search-input {
    border-color: var(--wuxia-hairline);
    background: rgba(251, 248, 239, 0.82);
    color: var(--wuxia-ink);
}

html[data-theme="bright"] .favorite-section,
html[data-theme="bright"] .feature-module {
    border-color: var(--wuxia-hairline);
}

html[data-theme="bright"] .favorite-section h3,
html[data-theme="bright"] .feature-module-heading h3 {
    color: var(--wuxia-pine-deep);
}

html[data-theme="bright"] .wuxia-home .feature-card .module-card {
    border-color: var(--wuxia-hairline);
    background: rgba(251, 248, 239, 0.58);
}

html[data-theme="bright"] .wuxia-home .feature-card .module-card:hover {
    border-color: rgba(49, 89, 77, 0.45);
    background: rgba(49, 89, 77, 0.055);
}

html[data-theme="bright"] .feature-favorite-button {
    border-color: var(--wuxia-hairline);
    color: var(--wuxia-ink-soft);
}

html[data-theme="bright"] .feature-favorite-button:hover,
html[data-theme="bright"] .feature-favorite-button.is-favorite {
    border-color: rgba(166, 63, 49, 0.48);
    color: var(--wuxia-cinnabar-deep);
}

html[data-theme="bright"] .feature-search-input:focus-visible,
html[data-theme="bright"] .feature-favorite-button:focus-visible,
html[data-theme="bright"] .feature-card-link:focus-visible {
    outline-color: var(--wuxia-cinnabar);
}

@media (max-width: 760px) {
    .favorite-grid,
    .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
    .feature-center-panel { padding: 1rem; }
    .feature-search-wrap { grid-template-columns: 1fr; }
    .feature-search-label { grid-column: auto; }
    .feature-search-count { white-space: normal; }
    .favorite-grid,
    .feature-grid { grid-template-columns: 1fr; }
    .feature-module-heading { align-items: flex-start; }
    .wuxia-home .feature-card .module-card { min-height: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .feature-favorite-button,
    .feature-card-link { transition: none; }
}


.home-shell{padding-bottom:2rem}.home-grid{grid-template-columns:1fr}.archive-import-panel{max-width:none}
.portal-quick-actions{display:flex;gap:.65rem;flex-wrap:wrap;margin-top:.75rem}.portal-note{color:var(--muted);font-size:.76rem;line-height:1.55;margin-top:.6rem}
.portal-mode-badge{display:inline-flex;align-items:center;padding:.28rem .55rem;border:1px solid var(--border);border-radius:999px;font-size:.7rem;color:var(--muted)}
.feature-card .feature-status{position:absolute;left:.9rem;bottom:.82rem;color:var(--muted);font-size:.66rem}.feature-card.is-new .feature-status{color:var(--green)}
.feature-card-link{display:block}.portal-main-role-meta{display:flex;gap:.55rem;align-items:center;color:var(--muted);font-size:.72rem}.portal-main-role-meta b{color:var(--text)}
.portal-import-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.65rem;align-items:center}.portal-import-row .btn{white-space:nowrap}
.portal-changelog ul{margin:.65rem 0 0 1.1rem;color:var(--muted);font-size:.78rem;line-height:1.65}
@media(max-width:600px){.portal-import-row{grid-template-columns:1fr}.portal-import-row .btn{width:100%}}

/* v4.24 reference-home alignment */
.home-grid { grid-template-columns: 1fr; }
.feature-center-panel { width: 100%; }
.portal-main-role-meta { display:flex; flex-wrap:wrap; gap:.65rem 1.2rem; margin:-.35rem 0 .45rem; color:var(--muted); font-size:.76rem; }
.portal-main-role-meta b { color:var(--text); font-weight:600; }
.feature-card-link.is-disabled { opacity:.5; cursor:not-allowed; filter:saturate(.35); }
.feature-card.is-disabled .feature-status { color:var(--muted); }
.feature-status { position:absolute; left:.72rem; bottom:.78rem; color:var(--green); font-size:.68rem; }
@media (min-width: 761px) { .archive-import-panel { min-height: 245px; } }

/* v4.24.2 source verification */
.source-audit-banner{margin:0 0 1rem;padding:.8rem 1rem;border:1px solid var(--border);border-radius:9px;background:var(--panel-soft);color:var(--muted);font-size:.76rem;line-height:1.6}
.source-audit-banner.is-warning{border-color:rgba(193,97,63,.45);background:rgba(193,97,63,.07);color:var(--text)}
.source-audit-banner.is-ok{border-color:rgba(73,132,96,.42);background:rgba(73,132,96,.06)}
.feature-status.verify-verified{color:var(--green)}
.feature-status.verify-mapped{color:var(--purple)}
.feature-status.verify-conditional{color:#c98d42}
.feature-status.verify-runtime,.feature-status.verify-version{color:#c1604d;font-weight:600}
.feature-status.verify-data{color:var(--muted)}

#portalDbLabel{opacity:.72}
#portalDbLabel.is-ready{opacity:1;box-shadow:inset 0 0 0 1px rgba(126,91,50,.32)}



.home-import-disclaimer{
    margin-top:.85rem;
    padding:.85rem 1rem;
    border:1px solid var(--border-color);
    border-radius:8px;
    background:rgba(126,91,50,.06);
    color:var(--text-secondary);
    font-size:.78rem;
    line-height:1.65;
}
.home-import-disclaimer strong{
    display:block;
    margin-bottom:.25rem;
    color:var(--text-primary);
    font-size:.82rem;
}
.home-import-disclaimer p{margin:.18rem 0}


/* v4.26.2: 主角行区服/角色切换 */
.home-main-role { position: relative; }
.home-main-role.is-switchable {
  cursor: pointer;
  user-select: none;
  padding-right: 2.35rem;
  outline: none;
}
.home-main-role.is-switchable::after {
  content: "▾";
  position: absolute;
  right: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .78rem;
  transition: transform .16s ease;
  pointer-events: none;
}
.home-main-role.is-switchable[aria-expanded="true"]::after { transform: translateY(-50%) rotate(180deg); }
.home-main-role.is-switchable:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft, rgba(139,65,44,.18)); }
.home-role-save-menu {
  position: absolute;
  z-index: 120;
  left: 0;
  right: 0;
  top: calc(100% + .38rem);
  display: grid;
  gap: .3rem;
  max-height: 18rem;
  overflow-y: auto;
  padding: .42rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel, var(--bg));
  box-shadow: 0 10px 28px rgba(0,0,0,.12);
}
.home-role-save-menu[hidden] { display: none; }
.home-role-save-option {
  width: 100%;
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: .55rem .7rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-role-save-option:hover,
.home-role-save-option:focus-visible { background: var(--panel-soft); outline: none; }
.home-role-save-option.is-current { border-color: var(--border); background: var(--panel-soft); }
.home-role-save-option.is-current::after { content: "当前"; flex: 0 0 auto; color: var(--accent, var(--text)); font-size: .7rem; }
.home-role-save-option-main { min-width: 0; font-family: var(--font-serif); font-weight: 700; }
.home-role-save-option-sub { min-width: 0; color: var(--muted); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .home-role-save-option { align-items: flex-start; flex-direction: column; gap: .18rem; }
  .home-role-save-option.is-current::after { position: absolute; right: .65rem; }
}
