/* Anime Profiles Pro v15.2 - Responsive & Style Overhaul */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --app-accent: #5865F2;
    --app-accent-dark: #4752C4;
    --app-text: #2E3338;
    --app-text-light: #4E545A;
    --app-text-muted: #747F8D;
    --app-bg: #F2F3F5;
    --app-surface: #FFFFFF;
    --app-border: #E3E5E8;
    --app-font: 'Inter', system-ui, -apple-system, sans-serif;
    --app-star: #FFAC33;
    --app-error: #D63638;
    --app-shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --app-shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
    --app-shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}
*, *::before, *::after { box-sizing: border-box; }
body { font-family: var(--app-font); background-color: var(--app-bg); color: var(--app-text); margin: 0; line-height: 1.6; }
.app-container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
a { color: var(--app-accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--app-accent-dark); }
h1, h2, h3, h4, h5, h6 { margin: 0 0 0.75em; font-weight: 700; line-height: 1.2; }

/* --- Breadcrumbs Navigation (V2 - Improved Style & Specificity) --- */
.app-container .app-breadcrumbs {
    padding: 15px 0;
    margin-bottom: 24px;
    font-size: 0.9em;
    font-weight: 500;
}
.app-container .app-breadcrumbs a {
    color: var(--app-accent);
    text-decoration: none;
    transition: color 0.2s ease;
}
.app-container .app-breadcrumbs a:hover {
    color: var(--app-accent-dark);
    text-decoration: underline;
}
.app-container .app-breadcrumbs .separator {
    margin: 0 8px;
    color: var(--app-border);
}
.app-container .app-breadcrumbs .current {
    color: var(--app-text);
    font-weight: 600;
}


/* Series Hero Banner */
.app-series-hero {
    height: 45vh; min-height: 320px; display: flex; align-items: flex-end; justify-content: flex-start;
    background-size: cover; background-position: center 25%; position: relative; color: white; margin-bottom: 48px;
}
.app-series-hero-content { z-index: 1; padding: 48px 0; }
.app-series-hero-content h1, .app-series-hero-content p { text-shadow: 0 2px 8px rgba(0,0,0,0.7); }
.app-series-hero h1 { font-size: clamp(2.5em, 5vw, 3.5em); font-weight: 800; }
.app-series-hero-score { font-size: 1.1em; font-weight: 600; margin-top: 10px; display: inline-flex; align-items: center; background-color: rgba(0,0,0,0.4); padding: 8px 16px; border-radius: 8px; backdrop-filter: blur(5px); }
.app-series-hero .app-icon-star { font-size: 1.2em; }

/* --- Main Layout & Sidebar (Series & Single) --- */
.app-series-details-grid, .app-single-container { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; align-items: start; }
.app-sidebar .app-sidebar-sticky { position: sticky; top: 40px; display: flex; flex-direction: column; gap: 24px; }

/* Content Panels */
.app-content-panel, .app-sidebar-widget { background: var(--app-surface); border-radius: 12px; padding: 32px; border: 1px solid var(--app-border); box-shadow: var(--app-shadow-sm); }
.app-main-content { display: flex; flex-direction: column; gap: 32px; }

/* Shared Section Styling */
.app-series-section, .app-section { margin: 0; }
.app-series-section:last-child, .app-section:last-child { margin-bottom: 0; }
.app-series-section h2, .app-section h2 { font-size: 1.75em; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--app-border); }
.app-section-description { margin-top: -20px; font-size: 0.9em; color: var(--app-text-muted); margin-bottom: 20px; }
.app-prose { line-height: 1.7; font-size: 1.1em; color: var(--app-text-light); }
.app-prose p:first-child { margin-top: 0; }
.app-prose p:last-child { margin-bottom: 0; }

/* Series Page Specifics */
.app-series-main-content { background: none; border: none; box-shadow: none; padding: 0; }
.app-series-poster-sidebar { width: 100%; border-radius: 12px; box-shadow: var(--app-shadow-lg); display: block; }

/* Where to Watch */
.app-where-to-watch h3 { font-size: 1.1em; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 16px; color: var(--app-text-muted); font-weight: 600; }
.app-streaming-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 12px; }
.app-streaming-link { display: flex; justify-content: center; align-items: center; aspect-ratio: 1.5/1; background: var(--app-bg); border-radius: 8px; border: 1px solid var(--app-border); transition: all 0.2s ease; }
.app-streaming-link:hover { transform: translateY(-3px); border-color: #d0d3d6; background: #e9eaec; box-shadow: var(--app-shadow-sm); }
.app-streaming-link img { height: 28px; max-width: 90%; object-fit: contain; }
.app-streaming-link-name { font-size: 0.8em; font-weight: 600; color: var(--app-text-muted); padding: 5px; text-align: center; }

/* Series Information */
.visual-stats h3 { font-size: 1.1em; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 24px; color: var(--app-text-muted); font-weight: 600; }
.visual-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 20px; }
.stat-item { display: flex; align-items: flex-start; gap: 14px; }
.stat-item.full-width { grid-column: 1 / -1; }
.stat-icon { width: 22px; height: 22px; flex-shrink: 0; margin-top: 3px; color: var(--app-text-muted); opacity: 0.7; }
.stat-label { display: block; font-size: 0.9em; color: var(--app-text-muted); margin-bottom: 3px; line-height: 1.2; font-weight: 500; }
.stat-value { display: block; font-weight: 600; line-height: 1.4; color: var(--app-text); font-size: 1.05em; }
.stat-item-genres { display: flex; align-items: flex-start; gap: 14px; grid-column: 1 / -1; margin-top: 12px; border-top: 1px solid var(--app-border); padding-top: 28px; }
.app-series-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.app-series-tag { background-color: var(--app-bg); color: var(--app-text-muted); padding: 6px 12px; border-radius: 16px; font-size: 0.85em; text-decoration: none; border: 1px solid var(--app-border); transition: all 0.2s ease; font-weight: 500; }
.app-series-tag:hover { background-color: var(--app-accent); color: white; border-color: var(--app-accent); transform: translateY(-2px); }

/* Tabs */
.app-tabs-container { margin: 0; }
.app-tabs-nav { display: flex; overflow-x: auto; border-bottom: 2px solid var(--app-border); margin-bottom: 32px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.app-tabs-nav::-webkit-scrollbar { display: none; }
.app-tab-button { flex-shrink: 0; padding: 12px 20px; background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer; font-size: 1.1em; font-weight: 600; color: var(--app-text-muted); text-decoration: none; transition: all 0.2s ease-in-out; margin-bottom: -2px; white-space: nowrap; }
.app-tab-button:hover { color: var(--app-text); }
.app-tab-button.active { color: var(--app-accent); border-bottom-color: var(--app-accent); }
.app-tab-content-panel { display: none; animation: fadeIn 0.4s ease-in-out; }
.app-tab-content-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Character List & Cards (Series Page) */
.app-character-list-section { background: var(--app-surface); border-radius: 12px; padding: 32px; border: 1px solid var(--app-border); box-shadow: var(--app-shadow-sm); margin-top: 48px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px; }
.app-card { background: var(--app-surface); border-radius: 12px; box-shadow: var(--app-shadow-sm); text-decoration: none; overflow: hidden; transition: all 0.25s ease-in-out; display: flex; flex-direction: column; }
.app-card:hover { transform: translateY(-8px); box-shadow: var(--app-shadow-md); }
.app-card-image { aspect-ratio: 3 / 4; background-size: cover; background-position: center; position: relative; }
.app-card-role-badge { position: absolute; top: 10px; left: 10px; padding: 5px 10px; font-size: 0.75em; font-weight: 700; color: white; border-radius: 6px; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); line-height: 1.2; z-index: 2; }
.app-card-role-badge.role-main { background-color: var(--app-accent); }
.app-card-role-badge.role-supporting { background-color: rgba(116, 127, 141, 0.9); }
.app-card-content { padding: 16px; flex-grow: 1; }
.app-card-title { font-size: 1.1em; font-weight: 600; color: var(--app-text); margin: 0 0 8px; }
.app-card-favorites { font-size: 0.9em; color: var(--app-text-muted); display: flex; align-items: center; gap: 5px; }
.app-card-favorites .app-icon-star { color: var(--app-star); }

/* --- Single Character Page --- */
.app-sidebar .app-main-image { width: 100%; height: auto; border-radius: 12px; margin-bottom: 24px; box-shadow: var(--app-shadow-lg); display: block; }
.app-character-header { text-align: center; }
.app-main-title { font-size: clamp(2em, 5vw, 2.5em); font-weight: 800; line-height: 1.1; color: var(--app-text); }
.app-subtitle { font-size: clamp(1.1em, 3vw, 1.3em); font-weight: 400; color: var(--app-text-muted); margin: 5px 0 0; }
.app-quick-stats h3 { font-size: 1.1em; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 16px; color: var(--app-text-muted); font-weight: 600; }
.app-quick-stats .profile-details { display: flex; flex-direction: column; gap: 12px; font-size: 1.05em; }
.app-quick-stats .profile-details p { margin: 0; }
.app-quick-stats .profile-details strong { color: var(--app-text); font-weight: 600; }
.app-quick-stats .profile-details .app-icon-star { margin-right: 4px; }

/* Biography DL */
.app-bio-list { display: grid; grid-template-columns: 120px 1fr; gap: 12px 16px; }
.app-bio-list dt { font-weight: 600; color: var(--app-text); }
.app-bio-list dd { margin: 0; color: var(--app-text-light); }
.app-prose .app-bio-list { margin-bottom: 1.5em; }

/* Skill Analysis */
.app-stats-list { display: flex; flex-direction: column; gap: 20px; }
.app-stat-item { position: relative; }
.app-stat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 1em; }
.app-stat-label { font-weight: 600; color: var(--app-text); }
.app-stat-value { font-size: 0.9em; color: var(--app-text-muted); font-weight: 500; }
.app-stat-bar-container { width: 100%; background-color: var(--app-bg); border-radius: 6px; height: 12px; overflow: hidden; }
.app-stat-bar { height: 100%; border-radius: 6px; transition: width 0.8s cubic-bezier(0.25, 1, 0.5, 1); }

/* Appearances & Related Grids */
.app-media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px; }
.app-media-card { text-decoration: none; display: flex; flex-direction: column; gap: 12px; }
.app-media-card-image { aspect-ratio: 10 / 16; background-size: cover; background-position: center; border-radius: 8px; box-shadow: var(--app-shadow-sm); transition: all 0.25s ease; }
.app-media-card:hover .app-media-card-image { transform: scale(1.05); box-shadow: var(--app-shadow-md); }
.app-media-card-content { text-align: center; }
.app-media-card-title { font-size: 1em; font-weight: 600; color: var(--app-text); margin: 0 0 4px; line-height: 1.3; }
.app-media-card-role { font-size: 0.85em; color: var(--app-text-muted); }
.app-grid-related { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* Staff & VA Grids */
.app-staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 24px; }
.app-staff-card { text-align: center; }
.app-staff-image { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; box-shadow: var(--app-shadow-md); }
.app-staff-name { display: block; font-weight: 600; font-size: 0.95em; line-height: 1.3; }
.app-staff-role { display: block; font-size: 0.8em; color: var(--app-text-muted); }

.app-va-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 20px; }
.app-va-card { position: relative; text-align: center; }
.app-va-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; box-shadow: var(--app-shadow-sm); }
.app-va-card-name { font-weight: 600; font-size: 0.9em; line-height: 1.4; margin-top: 8px; }

/* Sources */
.app-source-attribution { text-align: center; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--app-border); }
.app-source-attribution h3 { font-size: 1em; color: var(--app-text-muted); text-transform: uppercase; letter-spacing: 1px; }
.app-source-list { list-style: none; padding: 0; margin: 10px 0 0; display: inline-flex; gap: 20px; }

/* Load More Button & Loader */
.app-load-more-container { margin-top: 40px; text-align: center; }
.app-load-more-btn { background-color: var(--app-accent); color: #fff; border: none; border-radius: 8px; padding: 14px 32px; font-size: 1.1em; font-weight: 700; cursor: pointer; transition: all 0.2s ease; }
.app-load-more-btn:hover { background-color: var(--app-accent-dark); transform: translateY(-2px); box-shadow: var(--app-shadow-md); }
.app-loader { border: 5px solid var(--app-bg); border-top: 5px solid var(--app-accent); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 0 auto; }
#app-load-more-loader { width: 30px; height: 30px; border-width: 4px; }
@keyframes spin { 100% { transform: rotate(360deg); } }


/* --- Database Explorer Page Styles (V3 - Unified) --- */
.app-explorer-container {
    display: grid;
    grid-template-columns: 280px 1fr; /* Sidebar width and main content */
    gap: 48px;
    align-items: flex-start;
}

.app-explorer-sidebar .app-desktop-filter-title {
    font-size: 1.5em;
    border-bottom: 1px solid var(--app-border);
    padding-bottom: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-explorer-sidebar .filter-group {
    margin-bottom: 24px;
}

.app-explorer-sidebar .filter-group label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    color: var(--app-text);
}

.app-explorer-sidebar input[type="text"],
.app-explorer-sidebar select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--app-border);
    font-size: 1em;
    background: var(--app-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.app-explorer-sidebar input[type="text"]:focus,
.app-explorer-sidebar select:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
    outline: none;
}

.filter-checkbox-group {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    padding: 15px;
    border-radius: 8px;
    background: var(--app-surface);
}

.filter-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    margin-bottom: 12px;
    cursor: pointer;
}
.filter-checkbox-group label:last-child {
    margin-bottom: 0;
}
.filter-checkbox-group input[type="checkbox"] {
    width: 1.3em;
    height: 1.3em;
    accent-color: var(--app-accent);
    flex-shrink: 0;
}

.app-radio-group {
    display: flex;
    gap: 10px;
    background-color: var(--app-bg);
    border-radius: 8px;
    padding: 5px;
}
.app-radio-group label {
    flex-grow: 1;
    padding: 8px 12px;
    margin: 0;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}
.app-radio-group input[type="radio"] {
    display: none; /* Hide the actual radio button */
}
.app-radio-group input[type="radio"]:checked + label {
    background-color: var(--app-surface);
    color: var(--app-accent);
    box-shadow: var(--app-shadow-sm);
}
#character-filters {
    transition: all 0.3s ease-in-out;
}

#app-explorer-results {
    min-height: 400px; /* Ensures loader is visible on an empty page */
    transition: opacity 0.3s ease-in-out;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-mobile-filter-button {
    display: none; /* Hidden by default, shown on mobile */
}


/* --- RESPONSIVE STYLES --- */
@media (min-width: 992px) {
    .app-series-details-grid { grid-template-columns: minmax(0, 2.5fr) minmax(320px, 1fr); }
    .app-series-main-content { order: 0; }
    .app-single-container { grid-template-columns: 320px 1fr; }
}

@media (max-width: 991px) {
    .app-series-main-content { order: -1; }
    .app-series-details-grid, .app-single-container { gap: 32px; }
    .app-sidebar .app-sidebar-sticky { position: static; }

    /* --- Explorer Mobile Styles --- */
    .app-explorer-container {
        grid-template-columns: 1fr; /* Stack sidebar on top of content */
    }

    .app-explorer-sidebar .app-desktop-filter-title {
        display: none; /* Hide the "Filters" H3 on mobile */
    }

    #app-explorer-filters {
        display: none; /* Hide the form by default on mobile */
        border: 1px solid var(--app-border);
        padding: 24px;
        border-radius: 12px;
        margin-top: 16px;
        background: var(--app-surface);
    }

    .app-mobile-filter-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        background: var(--app-surface);
        border: 1px solid var(--app-border);
        color: var(--app-text);
        padding: 14px;
        font-size: 1.1em;
        font-weight: 600;
        border-radius: 8px;
        cursor: pointer;
    }

    .app-mobile-filter-button.is-open {
        background-color: var(--app-accent);
        border-color: var(--app-accent-dark);
        color: white;
    }

}

@media (max-width: 768px) {
    .app-container { padding: 0 16px; }
    .app-series-hero { margin-bottom: 32px; min-height: 280px; }
    .app-series-hero-content { padding: 32px 0; }
    .app-content-panel, .app-sidebar-widget { padding: 24px; }
    .app-character-list-section { padding: 24px; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
    .app-media-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; }
    .app-single-container .app-sidebar { text-align: center; }
    .app-single-container .app-main-image { max-width: 280px; margin-left: auto; margin-right: auto; }
    .app-bio-list { grid-template-columns: 100px 1fr; }
}

@media (max-width: 480px) {
    body { font-size: 15px; }
    .app-content-panel, .app-sidebar-widget { padding: 20px; }
    .app-series-section h2, .app-section h2 { font-size: 1.5em; }
    .app-grid { grid-template-columns: repeat(2, 1fr); }
    .app-media-grid { grid-template-columns: repeat(3, 1fr); }
    .app-bio-list { grid-template-columns: 1fr; gap: 4px; }
    .app-bio-list dt { margin-bottom: 2px; }
    .app-bio-list dd { margin-bottom: 10px; }
    .visual-stats-grid { grid-template-columns: 1fr; }
    .stat-item.full-width { border-top: 1px solid var(--app-border); padding-top: 25px; }
    .stat-item-genres { border-top: none; padding-top: 0; }
}