@font-face {
    font-family: 'Bast';
    src: url('../fonts/base.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

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

html,
body {
    font-family: 'Bast', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #ffffff;
    color: #000000;
    line-height: 1.6;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.logo {
    font-size: 24px;
    font-weight: 500;
    letter-spacing: 1px;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 32px;
}

nav ul li a {
    text-decoration: none;
    color: #000000;
    font-size: 15px;
    font-weight: 400;
    transition: opacity 0.2s ease;
    position: relative;
}

nav ul li a:hover {
    opacity: 0.6;
}

nav ul li a.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #000000;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.page-section {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.page-section.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#entity-page {
    flex-direction: row;
}

#entity-page .list-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#entity-page .detail-view {
    flex: 1;
    display: none;
    flex-direction: row;
    overflow: hidden;
}

#entity-page .detail-view.active {
    display: flex;
}

.search-section {
    padding: 20px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.search-box {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    background-color: #ffffff;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-box:focus {
    border-color: rgba(0, 0, 0, 0.3);
}

.search-box::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.entity-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding: 40px;
    overflow-y: auto;
}

.entity-card {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #000000;
    display: flex;
    flex-direction: column;
    height: 280px;
}

.entity-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

.entity-card h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.entity-card .author {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.entity-card .description {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    margin-bottom: 16px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow-y: auto;
}

.entity-card .tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: scroll;
    padding-bottom: 4px;
}

.entity-card .description::-webkit-scrollbar,
.entity-card .tags::-webkit-scrollbar {
    width: 2px;
    height: 2px;
}

.entity-card .description::-webkit-scrollbar-track,
.entity-card .tags::-webkit-scrollbar-track {
    background: transparent;
}

.entity-card .description::-webkit-scrollbar-thumb,
.entity-card .tags::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 1px;
}

.entity-card .tags::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.entity-card .tags span {
    font-size: 12px;
    padding: 4px 12px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    white-space: nowrap;
}

.empty-state {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: rgba(0, 0, 0, 0.4);
}

.empty-state h1 {
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 16px;
    color: rgba(0, 0, 0, 0.6);
}

.empty-state p {
    font-size: 16px;
}

.detail-panel {
    width: 100%;
    height: 100%;
    display: flex;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.panel-nav {
    width: 200px;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.back-link {
    padding: 16px 24px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
}

.back-link:hover {
    color: #000000;
}

.back-link svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.nav-item {
    padding: 16px 24px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s ease;
    position: relative;
    color: rgba(0, 0, 0, 0.6);
}

.nav-item:hover {
    color: rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.02);
}

.nav-item.active {
    color: #000000;
    background-color: rgba(0, 0, 0, 0.04);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background-color: #000000;
    border-radius: 0 2px 2px 0;
}

.panel-content {
    flex: 1;
    padding: 40px;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

.content-section {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 40px;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    overflow-y: auto;
}

.content-section.active {
    position: static;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.section-title {
    font-size: 28px;
    font-weight: 500;
    margin-bottom: 8px;
}

.section-author {
    font-size: 15px;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 24px;
}

.section-description {
    font-size: 15px;
    line-height: 1.8;
    color: rgba(0, 0, 0, 0.8);
    margin-bottom: 32px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.info-card {
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    margin-bottom: 24px;
}

.info-card h4 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    color: rgba(0, 0, 0, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-card p {
    font-size: 15px;
    line-height: 1.7;
    color: rgba(0, 0, 0, 0.8);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.tag-item {
    padding: 6px 16px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    font-size: 13px;
}

.list-group {
    margin-bottom: 24px;
}

.list-group h4 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.list-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 15px;
    line-height: 1.7;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item strong {
    font-weight: 500;
    margin-right: 8px;
}

.character-card {
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    margin-bottom: 16px;
}

.character-card h5 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 4px;
}

.character-card .role {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 12px;
}

.character-card .detail-row {
    margin-bottom: 12px;
}

.character-card .detail-row label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.5);
    display: block;
    margin-bottom: 4px;
}

.character-card .detail-row p {
    font-size: 14px;
    line-height: 1.6;
}

.relationship-item {
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
}

.relationship-item:last-child {
    margin-bottom: 0;
}

.relationship-item .rel-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.relationship-item .rel-target {
    font-weight: 500;
    font-size: 14px;
}

.relationship-item .rel-type {
    font-size: 12px;
    padding: 2px 8px;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}

.relationship-item .rel-tension {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.7);
}

.location-card {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.location-card:last-child {
    border-bottom: none;
}

.location-card h5 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 6px;
}

.location-card p {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    line-height: 1.6;
}

.timeline-item {
    position: relative;
    padding-left: 32px;
    padding-bottom: 24px;
    border-left: 2px solid rgba(0, 0, 0, 0.1);
    margin-left: 8px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 4px;
    width: 10px;
    height: 10px;
    background-color: #000000;
    border-radius: 50%;
}

.timeline-item span {
    font-size: 14px;
    line-height: 1.7;
}

.plot-card {
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    margin-bottom: 16px;
}

.plot-card .plot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.plot-card .chapter-num {
    font-size: 13px;
    padding: 4px 12px;
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    font-weight: 500;
}

.plot-card h5 {
    font-size: 18px;
    font-weight: 500;
}

.plot-card .plot-section {
    margin-bottom: 12px;
}

.plot-card .plot-section:last-child {
    margin-bottom: 0;
}

.plot-card .plot-section label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.5);
    display: block;
    margin-bottom: 4px;
}

.plot-card .plot-section p {
    font-size: 14px;
    line-height: 1.6;
}

.plot-card .foreshadowing-list {
    list-style: none;
    padding-left: 0;
}

.plot-card .foreshadowing-list li {
    font-size: 14px;
    line-height: 1.6;
    padding: 6px 0;
    padding-left: 16px;
    position: relative;
}

.plot-card .foreshadowing-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: rgba(0, 0, 0, 0.5);
}

.pacing-content,
.techniques-content {
    font-size: 15px;
    line-height: 1.8;
    color: rgba(0, 0, 0, 0.8);
}

footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 20px 40px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    text-decoration: none;
    color: rgba(0, 0, 0, 0.6);
    font-size: 13px;
    transition: opacity 0.2s ease;
}

.footer-links a:hover {
    opacity: 1;
}

.copyright {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-top-color: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Component Page ===== */

.component-list-view {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.component-sidebar {
    width: 200px;
    padding: 20px 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.component-search {
    padding: 0 16px 16px;
}

.component-search input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    background-color: #ffffff;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.component-search input:focus {
    border-color: rgba(0, 0, 0, 0.3);
}

.component-search input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.component-category-item {
    padding: 10px 20px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
}

.component-category-item:hover {
    color: rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.02);
}

.component-category-item.active {
    color: #000000;
    background-color: rgba(0, 0, 0, 0.04);
    font-weight: 500;
}

.component-main {
    flex: 1;
    overflow-y: auto;
}

.component-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
}

.component-card {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 220px;
}

.component-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

.component-card h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.component-category-tag {
    font-size: 12px;
    padding: 3px 10px;
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 12px;
    flex-shrink: 0;
    color: rgba(0, 0, 0, 0.6);
}

.component-card .description {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    margin-bottom: 12px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.component-card .tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    flex-shrink: 0;
    overflow-x: scroll;
    padding-bottom: 2px;
}

.component-card .tags::-webkit-scrollbar {
    height: 2px;
}

.component-card .tags::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 1px;
}

.component-card .tags span {
    font-size: 12px;
    padding: 3px 10px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    white-space: nowrap;
}

.component-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: rgba(0, 0, 0, 0.4);
}

.component-detail-view {
    flex: 1;
    display: none;
    overflow-y: auto;
}

.component-detail-view.active {
    display: block;
}

.component-detail-content {
    max-width: 720px;
    padding: 40px;
}

.component-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin-bottom: 32px;
    border: none;
    background: none;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s ease;
}

.component-back-btn:hover {
    color: #000000;
}

.component-back-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.component-detail-category {
    font-size: 13px;
    padding: 4px 12px;
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 20px;
    color: rgba(0, 0, 0, 0.6);
}

@media (max-width: 768px) {
    header {
        padding: 16px 20px;
    }

    nav ul {
        gap: 16px;
    }

    nav ul li a {
        font-size: 14px;
    }

    .search-section {
        padding: 16px 20px;
    }

    .entity-list {
        padding: 20px;
        grid-template-columns: 1fr;
    }

    .panel-nav {
        width: 160px;
    }

    .nav-item {
        padding: 14px 16px;
        font-size: 13px;
    }

    .panel-content,
    .content-section {
        padding: 24px;
    }

    .section-title {
        font-size: 22px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}