/* 角色卡（星空版）视图 */
:root {
    --cs-text: #f2f6ff;
    --cs-text-muted: rgba(210, 225, 255, 0.82);
    --cs-text-soft: rgba(180, 200, 240, 0.72);
    --cs-accent: #9ec5ff;
    --cs-accent-strong: #c8e0ff;
    --cs-border: rgba(150, 190, 255, 0.38);
    --cs-border-strong: rgba(170, 210, 255, 0.55);
    --cs-surface: rgba(12, 20, 38, 0.82);
    --cs-surface-soft: rgba(18, 28, 50, 0.72);
    --cs-input-bg: rgba(8, 14, 28, 0.88);
    --cs-focus: rgba(130, 180, 255, 0.45);
}

.charsheet-view {
    color: var(--cs-text);
    font-size: 14px;
    line-height: 1.5;
}

body.charsheet-mode {
    overflow: hidden;
}

body.charsheet-mode #particle-bg {
    background:
        radial-gradient(ellipse at 18% 14%, rgba(80, 120, 200, 0.28), transparent 46%),
        radial-gradient(ellipse at 82% 86%, rgba(60, 40, 120, 0.24), transparent 42%),
        #000;
}

.charsheet-view:not(.active) {
    display: none !important;
}

.charsheet-view.active {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 20;
    height: 100vh;
    overflow: hidden;
    background: transparent;
}

.charsheet-scroll {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    padding: 20px 24px 32px;
    scrollbar-gutter: stable;
}

.charsheet-scroll,
.charsheet-panel,
.charsheet-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 180, 255, 0.55) rgba(255, 255, 255, 0.06);
}

.charsheet-scroll::-webkit-scrollbar,
.charsheet-panel::-webkit-scrollbar,
.charsheet-sidebar::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.charsheet-scroll::-webkit-scrollbar-track,
.charsheet-panel::-webkit-scrollbar-track,
.charsheet-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
}

.charsheet-scroll::-webkit-scrollbar-thumb,
.charsheet-panel::-webkit-scrollbar-thumb,
.charsheet-sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(160, 200, 255, 0.65), rgba(100, 140, 220, 0.55));
    border-radius: 999px;
    border: 2px solid rgba(0, 0, 0, 0.25);
}

.charsheet-scroll::-webkit-scrollbar-thumb:hover,
.charsheet-panel::-webkit-scrollbar-thumb:hover,
.charsheet-sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(190, 220, 255, 0.85), rgba(120, 160, 240, 0.75));
}

.charsheet-shell {
    max-width: 1280px;
    margin: 0 auto;
}

.charsheet-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.charsheet-header > div:first-child {
    width: 100%;
    min-width: 0;
}

.charsheet-header .charsheet-actions {
    flex-shrink: 0;
}

.charsheet-kicker {
    font-size: 11px;
    letter-spacing: 4px;
    color: rgba(180, 200, 255, 0.7);
    margin-bottom: 6px;
}

.charsheet-sub {
    font-size: 14px;
    color: var(--cs-text-soft);
}

.charsheet-title {
    font-size: 28px;
    color: var(--cs-accent-strong);
    letter-spacing: 3px;
    margin-bottom: 4px;
    text-shadow: 0 0 18px rgba(140, 180, 255, 0.25);
}

.charsheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.charsheet-login-gate {
    text-align: center;
    padding: 80px 24px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    border: 1px solid rgba(140, 180, 255, 0.2);
}

.charsheet-app {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.charsheet-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 18px;
    align-items: stretch;
    height: clamp(420px, calc(100vh - 220px), 900px);
}

@media (max-width: 900px) {
    .charsheet-layout {
        grid-template-columns: 1fr;
    }
}

.charsheet-sidebar {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(140, 180, 255, 0.18);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
}

.charsheet-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--cs-border);
    border-radius: 10px;
    background: var(--cs-surface-soft);
    color: var(--cs-text);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.charsheet-card:hover,
.charsheet-card.active {
    border-color: rgba(160, 200, 255, 0.55);
    background: rgba(80, 120, 200, 0.12);
}

.charsheet-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--cs-accent-strong);
}

.charsheet-card-meta {
    font-size: 12px;
    color: var(--cs-text-soft);
}

.charsheet-empty,
.charsheet-empty-inline {
    font-size: 13px;
    color: var(--cs-text-soft);
    line-height: 1.6;
}

.charsheet-empty {
    padding: 12px 8px;
}

.charsheet-empty-inline {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px dashed var(--cs-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.charsheet-main {
    background: linear-gradient(180deg, rgba(16, 24, 44, 0.92), rgba(10, 16, 30, 0.88));
    border: 1px solid var(--cs-border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.charsheet-main-head,
.charsheet-tabs {
    flex-shrink: 0;
}

.charsheet-main-head {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(140, 180, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.charsheet-active-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--cs-accent-strong);
    letter-spacing: 1px;
}

.charsheet-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(140, 180, 255, 0.16);
    background: rgba(0, 0, 0, 0.22);
}

.charsheet-tab {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--cs-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--cs-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.charsheet-tab:hover {
    color: var(--cs-accent-strong);
    border-color: var(--cs-border-strong);
}

.charsheet-tab.active {
    background: linear-gradient(135deg, rgba(90, 140, 230, 0.34), rgba(60, 100, 190, 0.24));
    border-color: var(--cs-border-strong);
    color: #fff;
    box-shadow: 0 0 16px rgba(120, 170, 255, 0.18);
}

.charsheet-panel {
    padding: 18px 20px 28px;
    overflow-x: hidden;
    overflow-y: scroll;
    flex: 1;
    min-height: 0;
    scrollbar-gutter: stable;
    background: rgba(0, 0, 0, 0.12);
}

.charsheet-section {
    margin-bottom: 26px;
    padding: 16px;
    border: 1px solid rgba(140, 180, 255, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
}

.charsheet-section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--cs-accent-strong);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(140, 180, 255, 0.2);
    letter-spacing: 0.5px;
}

.charsheet-section-hint {
    margin: -4px 0 14px;
    font-size: 13px;
    color: var(--cs-text-soft);
}

.charsheet-derived-value {
    display: inline-block;
    min-width: 2.5em;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(90, 140, 230, 0.18);
    border: 1px solid rgba(150, 190, 255, 0.35);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
}

.charsheet-label-hint {
    font-size: 11px;
    font-weight: 500;
    color: rgba(160, 200, 255, 0.55);
}

.charsheet-field-mod .charsheet-stat-mod-btn {
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.charsheet-stat-mod-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.charsheet-stat-mod-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px);
    min-width: 190px;
    max-width: min(300px, 72vw);
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(10, 18, 36, 0.96);
    border: 1px solid rgba(150, 190, 255, 0.38);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 12;
    text-align: left;
}

.charsheet-stat-mod-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(150, 190, 255, 0.38);
}

.charsheet-stat-mod-tooltip-line {
    display: block;
    font-size: 12px;
    line-height: 1.55;
    color: rgba(225, 235, 255, 0.92);
}

.charsheet-stat-mod-tooltip-line + .charsheet-stat-mod-tooltip-line {
    margin-top: 4px;
    color: rgba(190, 220, 255, 0.88);
    font-weight: 600;
}

.charsheet-stat-mod-wrap.has-mod-tooltip:hover .charsheet-stat-mod-tooltip,
.charsheet-stat-mod-wrap.has-mod-tooltip:focus-within .charsheet-stat-mod-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.charsheet-field-mod .charsheet-stat-mod-btn:hover {
    background: rgba(110, 160, 240, 0.28);
    border-color: rgba(190, 220, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(130, 180, 255, 0.18);
}

.charsheet-field-mod .charsheet-stat-mod-btn:active {
    transform: scale(0.98);
}

.charsheet-stat-mod-final {
    font-size: 16px;
}

.charsheet-stat-mod-detail {
    font-size: 12px;
    font-weight: 600;
    color: rgba(190, 220, 255, 0.82);
}

body.charsheet-mod-open {
    overflow: hidden;
}

.charsheet-mod-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.charsheet-mod-modal.hidden {
    display: none;
}

.charsheet-mod-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 18, 0.72);
    backdrop-filter: blur(6px);
}

.charsheet-mod-dialog {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: min(82vh, 720px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid rgba(150, 190, 255, 0.35);
    background: linear-gradient(180deg, rgba(18, 28, 52, 0.98), rgba(10, 16, 32, 0.98));
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.charsheet-mod-header,
.charsheet-mod-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(140, 180, 255, 0.16);
}

.charsheet-mod-footer {
    border-bottom: none;
    border-top: 1px solid rgba(140, 180, 255, 0.16);
    justify-content: flex-end;
}

.charsheet-mod-kicker {
    margin: 0 0 4px;
    font-size: 11px;
    letter-spacing: 3px;
    color: rgba(160, 200, 255, 0.65);
}

.charsheet-mod-title {
    margin: 0;
    font-size: 20px;
    color: var(--cs-accent-strong);
}

.charsheet-mod-close {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(150, 190, 255, 0.28);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.charsheet-mod-body {
    padding: 16px 18px;
    overflow-y: auto;
}

.charsheet-mod-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.charsheet-mod-summary-item {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(140, 180, 255, 0.16);
    text-align: center;
}

.charsheet-mod-summary-item strong {
    display: block;
    margin-top: 6px;
    font-size: 20px;
    color: #fff;
}

.charsheet-mod-summary-final {
    background: rgba(90, 140, 230, 0.16);
    border-color: rgba(150, 190, 255, 0.35);
}

.charsheet-mod-summary-label {
    font-size: 12px;
    color: var(--cs-text-soft);
}

.charsheet-mod-list-title {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--cs-accent);
}

.charsheet-mod-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.charsheet-mod-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(140, 180, 255, 0.14);
}

.charsheet-mod-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.charsheet-mod-item-value {
    min-width: 48px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(90, 140, 230, 0.2);
    border: 1px solid rgba(150, 190, 255, 0.3);
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.charsheet-mod-item-note {
    color: var(--cs-text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.charsheet-mod-form-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

@media (max-width: 640px) {
    .charsheet-mod-summary {
        grid-template-columns: 1fr;
    }

    .charsheet-mod-form-grid {
        grid-template-columns: 1fr;
    }
}

.charsheet-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.charsheet-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.charsheet-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-text-muted);
    letter-spacing: 0.3px;
}

.charsheet-input,
.charsheet-textarea,
.charsheet-cell {
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--cs-border);
    background: var(--cs-input-bg);
    color: var(--cs-text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.charsheet-input::placeholder,
.charsheet-textarea::placeholder {
    color: rgba(170, 190, 230, 0.45);
}

.charsheet-input:hover,
.charsheet-textarea:hover,
.charsheet-cell:hover {
    border-color: var(--cs-border-strong);
}

.charsheet-input:focus,
.charsheet-textarea:focus,
.charsheet-cell:focus {
    outline: none;
    border-color: rgba(170, 210, 255, 0.75);
    box-shadow: 0 0 0 3px var(--cs-focus);
    background: rgba(10, 18, 36, 0.95);
}

.charsheet-textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.65;
}

.charsheet-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.charsheet-stat {
    padding: 12px;
    border-radius: 12px;
    background: var(--cs-surface-soft);
    border: 1px solid rgba(140, 180, 255, 0.18);
}

.charsheet-stat-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--cs-accent);
    margin-bottom: 8px;
    white-space: pre-line;
}

.charsheet-stat-half {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--cs-text-soft);
}

.charsheet-skills {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
    gap: 10px;
}

.charsheet-skill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--cs-surface-soft);
    border: 1px solid rgba(140, 180, 255, 0.16);
}

.charsheet-skill-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--cs-text);
    flex: 1;
    min-width: 0;
}

.charsheet-skill-input {
    width: 72px;
    min-width: 72px;
    text-align: center;
    font-weight: 700;
    color: var(--cs-accent-strong);
}

.charsheet-custom-skills-section {
    background: linear-gradient(180deg, rgba(70, 110, 190, 0.08), rgba(255, 255, 255, 0.02));
}

.charsheet-custom-skills {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.charsheet-custom-skill {
    display: grid;
    grid-template-columns: 1fr 88px 36px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--cs-surface-soft);
    border: 1px dashed rgba(150, 190, 255, 0.28);
}

.charsheet-custom-skill-name {
    font-weight: 600;
}

.charsheet-add-custom-skill {
    margin-top: 4px;
}

.charsheet-res-row {
    display: grid;
    grid-template-columns: 64px 72px 100px 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.charsheet-res-type {
    font-size: 13px;
    font-weight: 700;
    color: var(--cs-accent);
}

.charsheet-table-wrap {
    overflow: auto;
}

.charsheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.charsheet-table th,
.charsheet-table td {
    border: 1px solid rgba(140, 180, 255, 0.2);
    padding: 6px;
    vertical-align: top;
}

.charsheet-table th {
    background: rgba(80, 120, 200, 0.24);
    color: var(--cs-accent-strong);
    font-weight: 700;
}

.charsheet-row-del {
    border: none;
    background: rgba(200, 80, 80, 0.2);
    color: #ffb0b0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

.charsheet-add-row {
    margin-top: 12px;
}

.charsheet-portal {
    border: 1px solid rgba(140, 180, 255, 0.38);
    background:
        linear-gradient(135deg, rgba(80, 120, 200, 0.14), rgba(40, 60, 120, 0.1)),
        rgba(255, 255, 255, 0.04);
}

.charsheet-portal:hover {
    border-color: rgba(170, 200, 255, 0.65);
    box-shadow: 0 0 28px rgba(120, 160, 255, 0.22);
}

.charsheet-portal .library-portal-glow {
    background: radial-gradient(circle, rgba(140, 180, 255, 0.16), transparent 60%);
}

.charsheet-portal .library-portal-icon {
    background: rgba(80, 120, 200, 0.22);
    color: #d8e8ff;
    box-shadow: 0 0 16px rgba(120, 160, 255, 0.28);
}

.charsheet-portal .library-portal-title {
    color: #eef4ff;
}

.charsheet-companion {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px dashed rgba(140, 180, 255, 0.15);
}
