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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #9b72d4 0%, #f3e7ff 50%, #ffffff 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1400px;
    width: 100%;
    overflow: hidden;
}

.container.detail-mode {
    max-width: 900px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    font-weight: 600;
}

.viewer {
    padding: 40px;
}

.search-container {
    position: relative;
    margin-bottom: 30px;
}

#search-input, #grid-search-input {
    width: 100%;
    padding: 15px 20px 15px 50px;
    font-size: 1.1em;
    border: 3px solid #ddd;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#search-input:focus, #grid-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    pointer-events: none;
    z-index: 1;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

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

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-item strong {
    color: #667eea;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex: 1;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.nav-btn:active {
    transform: translateY(0);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.counter {
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
    min-width: 100px;
    text-align: center;
}

.metadata {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 10px;
    border-left: 5px solid #667eea;
}

.metadata h2 {
    font-size: 2em;
    color: #333;
    margin-bottom: 15px;
}

.metadata p {
    font-size: 1.1em;
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.bible-ref {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.bible-ref strong {
    color: #667eea;
}

#bible-reference {
    color: #764ba2;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

#bible-reference:hover {
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.metadata-icons {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.metadata-icon {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1em;
    color: #667eea;
    font-weight: 600;
}

.metadata-icon-emoji {
    font-size: 1.2em;
}

/* Grid View Styles */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.card-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.card-wrapper character-card {
    transform: scale(0.8);
    transform-origin: center;
}

/* Web Component Styles */
#detail-card {
    width: 415px;
    margin: 0 auto 30px;
}

character-card {
    display: block;
    aspect-ratio: 5 / 7;
}

.back-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background 0.3s;
}

.back-btn:hover {
    background: #5568d3;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 10px;
}

.mode-selector label {
    font-weight: 600;
    color: #667eea;
}

.mode-dropdown-external {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    background: white;
    transition: all 0.3s;
}

.mode-dropdown-external:hover {
    border-color: #667eea;
}

.mode-dropdown-external:focus {
    outline: none;
    border-color: #667eea;
}

.filter-heading {
    margin-top: 30px;
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
}

.filter-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
}

.filter-btn:hover {
    border-color: #667eea;
}

.filter-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.filter-btn-emoji {
    font-size: 1.1em;
}

.period-filter-btn {
    font-weight: 600;
    border: 2px solid transparent;
}

.period-filter-btn.active {
    border: 3px solid #333 !important;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .viewer {
        padding: 20px;
    }

    .image-container {
        height: 300px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .nav-btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    .metadata h2 {
        font-size: 1.5em;
    }

    .metadata p {
        font-size: 1em;
    }
}

