/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
}

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

header h1 .site-logo {
    height: 2.75rem;
    width: auto;
    flex-shrink: 0;
    display: block;
}

header h1 .tagline {
    font-size: 0.9rem;
    font-weight: normal;
    opacity: 0.9;
    font-style: italic;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: inherit;
    text-decoration: none;
}

/* Hamburger menu button - hidden on desktop */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
}

.hamburger-icon span {
    display: block;
    height: 3px;
    width: 100%;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active .hamburger-icon span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-icon span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Desktop navigation - visible by default */
.desktop-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mobile-nav {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-nav:not(.hidden) {
    display: flex;
}

nav button {
    padding: 0.5rem 1rem;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.desktop-nav button {
    text-align: center;
}

.mobile-nav button {
    width: 100%;
    padding: 0.75rem 1rem;
    min-height: 44px;
    text-align: left;
}

nav button:hover {
    background: #455a6f;
}

nav button.active {
    background: #3498db;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hidden {
    display: none;
}

.active {
    display: block;
}

/* Landing page */
#landing {
    padding: 2rem 0 4rem;
    text-align: center;
}

.landing-hero {
    max-width: 36rem;
    margin: 0 auto;
}

.landing-logo {
    height: 10rem;
    width: auto;
    margin-bottom: 0.5rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.landing-tagline {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-style: italic;
    margin-bottom: 1.5rem;
}

.landing-intro {
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
    margin-bottom: 2rem;
}

.landing-cta {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.landing-cta:hover {
    background: #2980b9;
}

/* Play selector */
.genre-filters {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.genre-filters button {
    padding: 0.5rem 1rem;
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.genre-filters button:hover {
    background: #d5dbdb;
}

.genre-filters button.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.play-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.play-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.play-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.play-card h3 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.play-card .genre {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-style: italic;
}

/* Play viewer */
#play-viewer {
    position: relative;
}

.play-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem;
    border-bottom: 2px solid #ecf0f1;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    background: white;
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding-left: 2rem;
    padding-right: 2rem;
    box-sizing: border-box;
}

/* play-content margin-top is set dynamically by JavaScript to account for fixed play-header */

.play-header-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-nav {
    padding: 0.5rem 1rem;
    background: #ecf0f1;
    color: #2c3e50;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-nav:hover:not(:disabled) {
    background: #d5dbdb;
    border-color: #95a5a6;
}

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#play-title {
    flex: 1;
    margin: 0;
}

.play-controls {
    display: flex;
    gap: 0.5rem;
}

.play-controls select {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
}

.btn-characters {
    padding: 0.5rem 1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-characters:hover {
    background: #2980b9;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #ecf0f1;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #95a5a6;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close:hover {
    color: #2c3e50;
}

.characters-list {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.character-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    background: #f8f9fa;
    transition: background 0.2s;
}

.character-item:hover {
    background: #e9ecef;
}

.character-name {
    font-weight: 500;
    color: #2c3e50;
}

.character-gender {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.character-gender.Male {
    background: #3498db;
    color: white;
}

.character-gender.Female {
    background: #e91e63;
    color: white;
}

.character-gender.Gender-neutral {
    background: #95a5a6;
    color: white;
}

.play-text {
    font-size: 1.1rem;
    line-height: 1.8;
    max-width: 900px;
    /* margin-top set dynamically by JavaScript to account for headers */
}

.play-text h3 {
    margin: 2rem 0 1rem 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.play-text .speaker {
    font-weight: bold;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

.play-text .line {
    margin-left: 2rem;
    margin-bottom: 0.5rem;
    display: flex;
    gap: 1rem;
}

.play-text .line-number {
    color: #95a5a6;
    font-size: 0.9rem;
    min-width: 3rem;
    text-align: right;
    user-select: none;
    flex-shrink: 0;
}

.play-text .line-text {
    flex: 1;
}

/* Lexicon clickable words */
.lexicon-word {
    color: #3498db;
    cursor: pointer;
    border-bottom: 1px dotted #3498db;
    transition: background-color 0.2s, color 0.2s;
}

.lexicon-word:hover {
    background-color: #e8f4f8;
    color: #2980b9;
    border-bottom-color: #2980b9;
}

/* Lexicon popover */
.lexicon-popover {
    position: absolute;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1000;
    font-size: 0.9rem;
}

.lexicon-popover-header {
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.lexicon-popover-header h4 {
    margin: 0 0 0.25rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.lexicon-popover-header .part-of-speech {
    color: #7f8c8d;
    font-style: italic;
    font-size: 0.85rem;
}

.lexicon-popover .definition {
    margin-bottom: 1rem;
    color: #333;
    line-height: 1.6;
}

.lexicon-popover .occurrences {
    border-top: 1px solid #ecf0f1;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.lexicon-popover .occurrences h5 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 0.95rem;
}

.lexicon-popover .occurrence-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.lexicon-popover .occurrence-item[data-has-warning="true"] {
    border-left-color: #ffc107;
    background: #fffbf0;
}

.lexicon-popover .occurrence-item.clickable-reference {
    cursor: pointer;
    transition: background 0.2s, border-left-color 0.2s;
}

.lexicon-popover .occurrence-item.clickable-reference:hover {
    background: #e9ecef;
    border-left-color: #2980b9;
}

.lexicon-popover .occurrence-item[data-has-warning="true"].clickable-reference:hover {
    background: #fff3cd;
    border-left-color: #ff9800;
}

.lexicon-popover .occurrence-play {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.lexicon-popover .occurrence-ref {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.lexicon-popover .reference-warning {
    display: inline-block;
    margin-left: 0.25rem;
    color: #ff9800;
    font-size: 0.9rem;
    cursor: help;
}

.lexicon-popover .reference-warning-message {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 3px;
    color: #856404;
    font-size: 0.85rem;
    font-style: italic;
}

.lexicon-popover .occurrence-line-text {
    color: #2c3e50;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #ffffff;
    border-radius: 3px;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid #e0e0e0;
}

.lexicon-popover .occurrence-quote {
    color: #555;
    font-style: italic;
    margin-top: 0.25rem;
    padding-left: 0.5rem;
    border-left: 2px solid #e0e0e0;
}

.lexicon-popover .no-occurrences {
    color: #7f8c8d;
    font-style: italic;
}

.play-text .stage-direction {
    font-style: italic;
    color: #7f8c8d;
    margin: 1rem 0;
    padding-left: 1rem;
    border-left: 3px solid #bdc3c7;
}

/* Responsive - Tablet and below */
@media (max-width: 1024px) {
    header h1 {
        font-size: 1.2rem;
    }
    
    /* Show hamburger menu, hide desktop nav */
    .mobile-menu-toggle {
        display: flex;
    }
    
    .desktop-nav {
        display: none;
    }
    
    .mobile-nav:not(.hidden) {
        display: flex;
    }
    
    .play-grid {
        grid-template-columns: 1fr;
    }
    
    .play-text {
        font-size: 1rem;
    }
    
    .play-text .line {
        margin-left: 0.5rem;
        gap: 0.5rem;
    }
    
    .play-text .line-number {
        min-width: 2rem;
        font-size: 0.8rem;
    }
    
    .play-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .play-controls {
        width: 100%;
    }
    
    .play-controls select {
        flex: 1;
    }
}

/* Responsive - Phone (small screens) */
@media (max-width: 480px) {
    /* Header adjustments */
    header {
        padding: 0.75rem;
    }
    
    .header-content {
        margin-bottom: 0;
    }
    
    /* Only show margin when mobile menu is open */
    .mobile-nav:not(.hidden) + *,
    header:has(.mobile-nav:not(.hidden)) {
        /* Margin handled by mobile-nav itself */
    }
    
    header h1 {
        font-size: 1.1rem;
        margin: 0;
    }
    
    /* Hide tagline on small screens */
    header h1 .tagline {
        display: none;
    }
    
    /* Navigation menu buttons */
    .mobile-nav button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    /* Main content padding reduction */
    main {
        padding: 1rem 0.75rem;
    }
    
    /* Play header mobile adjustments */
    .play-header {
        padding: 0.75rem;
        padding-left: 1rem;
        padding-right: 1rem;
        top: 0;
    }
    
    .play-header h2 {
        font-size: 1.1rem;
    }
    
    .btn-nav {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    .play-controls select {
        font-size: 0.9rem;
        padding: 0.625rem;
        min-height: 44px;
    }
    
    .btn-characters {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Play text adjustments */
    .play-text {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    .play-text .speaker {
        font-size: 1rem;
        margin-top: 1.25rem;
    }
    
    .play-text .line {
        margin-left: 0.25rem;
        gap: 0.375rem;
    }
    
    .play-text .line-number {
        min-width: 1.75rem;
        font-size: 0.75rem;
    }
    
    /* Filter containers */
    .filters-container {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .filter-group label {
        font-size: 0.85rem;
    }
    
    .filter-group select,
    .filter-group input {
        padding: 0.625rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Genre filters */
    .genre-filters {
        gap: 0.375rem;
    }
    
    .genre-filters button {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Search input */
    .search-input-group input {
        padding: 0.75rem;
        font-size: 0.95rem;
        min-height: 44px;
    }
    
    .search-input-group button {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
    }
    
    /* Lexicon controls */
    .lexicon-controls {
        margin-bottom: 1.5rem;
    }
    
    .search-input-group {
        margin-bottom: 0.75rem;
    }
    
    /* Letter filters - smaller on phone */
    .letter-filters {
        grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
        gap: 0.25rem;
    }
    
    .letter-filter {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
        min-height: 44px;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .characters-list {
        padding: 1rem;
    }
    
    /* Cards and grids */
    .monologue-card,
    .duologue-card,
    .fight-scene-card,
    .character-card {
        padding: 1rem;
    }
    
    .monologue-header h3,
    .duologue-header h3,
    .fight-scene-header h3 {
        font-size: 1.1rem;
    }
    
    /* Lexicon entry */
    .lexicon-entry {
        padding: 1rem;
    }
    
    .lexicon-entry-header h3 {
        font-size: 1.3rem;
    }
    
    /* Lexicon sense header */
    .lexicon-sense-header {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    #sense-word-title {
        font-size: 1.5rem;
    }
    
    .btn-back-sense {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Button view */
    .btn-view {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Parsing notice */
    .parsing-notice {
        padding: 0.75rem;
    }
    
    .parsing-notice-text {
        font-size: 0.85rem;
    }
    
    .btn-toggle-warnings {
        padding: 0.375rem 0.625rem;
        font-size: 0.8rem;
        min-height: 36px;
    }
}

/* Monologue finder */
.filters-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #2c3e50;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
}

.filter-group input {
    width: 100%;
}

.results-count {
    margin-bottom: 1rem;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.monologues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.monologue-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.monologue-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.monologue-header {
    margin-bottom: 1rem;
}

.monologue-header h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.monologue-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.monologue-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #e9ecef;
    color: #495057;
}

.badge.genre-comedy {
    background: #d4edda;
    color: #155724;
}

.badge.genre-tragedy {
    background: #f8d7da;
    color: #721c24;
}

.badge.genre-history {
    background: #d1ecf1;
    color: #0c5460;
}

.badge.gender-male {
    background: #3498db;
    color: white;
}

.badge.gender-female {
    background: #e91e63;
    color: white;
}

.badge.gender-gender-neutral {
    background: #95a5a6;
    color: white;
}

.monologue-preview {
    margin-bottom: 1rem;
    color: #495057;
    line-height: 1.6;
    font-size: 0.95rem;
}

.btn-view {
    padding: 0.75rem 1.5rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
}

.btn-view:hover {
    background: #2980b9;
}

.error {
    color: #e74c3c;
    padding: 1rem;
    background: #f8d7da;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

/* Highlight for line scrolling */
.line.highlight {
    background: #fff3cd;
    padding: 0.25rem;
    border-radius: 4px;
    animation: highlightFade 2s ease-out;
}

@keyframes highlightFade {
    0% {
        background: #fff3cd;
    }
    100% {
        background: transparent;
    }
}

/* Duologue finder - reuse monologue styles */
.duologues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.duologue-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.duologue-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.duologue-header {
    margin-bottom: 1rem;
}

.duologue-header h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.duologue-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.duologue-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.duologue-preview {
    margin-bottom: 1rem;
    color: #495057;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Fight scene finder - reuse similar styles */
.fight-scenes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.fight-scene-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fight-scene-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.fight-scene-header {
    margin-bottom: 1rem;
}

.fight-scene-header h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.fight-scene-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.fight-scene-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.badge.fight-type-duel {
    background: #e3f2fd;
    color: #1565c0;
}

.badge.fight-type-battle {
    background: #ffebee;
    color: #c62828;
}

.badge.fight-type-skirmish {
    background: #fff3e0;
    color: #e65100;
}

.badge.fight-type-ambush {
    background: #f3e5f5;
    color: #6a1b9a;
}

.badge.outcome-death {
    background: #424242;
    color: white;
}

.badge.outcome-wound {
    background: #d32f2f;
    color: white;
}

.badge.outcome-retreat {
    background: #616161;
    color: white;
}

.fight-scene-characters {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #495057;
}

.fight-scene-characters strong {
    color: #2c3e50;
}

.fight-scene-direction {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #856404;
}

.fight-scene-direction strong {
    color: #2c3e50;
}

.fight-scene-direction em {
    font-style: italic;
}

.fight-scene-preview {
    margin-bottom: 1rem;
    color: #495057;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Search section */
.search-container {
    margin-bottom: 2rem;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.search-input-group button {
    padding: 0.75rem 1.5rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.search-input-group button:hover {
    background: #2980b9;
}

.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-placeholder {
    color: #7f8c8d;
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-result-header {
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-result-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.search-result-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.search-result-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-result-speaker {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.search-result-stage {
    margin-bottom: 0.5rem;
    color: #7f8c8d;
    font-style: italic;
}

.search-result-text {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #2c3e50;
}

.search-context {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dee2e6;
    font-size: 0.9rem;
    color: #7f8c8d;
    line-height: 1.5;
}

.search-result-card mark {
    background: #fff3cd;
    color: #856404;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 500;
}

/* Responsive for monologue/duologue/fight scene finder */
@media (max-width: 768px) {
    .filters-container {
        grid-template-columns: 1fr;
    }
    
    .monologues-grid,
    .duologues-grid,
    .fight-scenes-grid {
        grid-template-columns: 1fr;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .search-input-group button {
        width: 100%;
    }
    
    .search-filters {
        grid-template-columns: 1fr;
    }
    
    .search-result-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Character Companion */
.characters-list-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.characters-play-section {
    margin-bottom: 2rem;
}

.characters-play-section h3 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.3rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.character-card {
    padding: 1.25rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.character-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.character-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.character-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.1rem;
    flex: 1;
}

.character-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.character-aliases {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
    line-height: 1.5;
}

.character-aliases strong {
    color: #495057;
    font-style: normal;
}

.character-scenes {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #495057;
    line-height: 1.5;
}

.character-scenes strong {
    color: #2c3e50;
}

.character-scene-links {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dee2e6;
}

.character-scene-links strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 0.9rem;
}

.scene-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.scene-links-list li {
    margin: 0;
}

.scene-link {
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
    display: inline-block;
}

.scene-link:hover {
    background: #e3f2fd;
    color: #1976d2;
    text-decoration: underline;
}

.badge.gender-male {
    background: #d1ecf1;
    color: #0c5460;
}

.badge.gender-female {
    background: #f8d7da;
    color: #721c24;
}

.badge.gender-genderneutral {
    background: #e2e3e5;
    color: #383d41;
}

/* Parsing notice banner */
.parsing-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.parsing-notice-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.parsing-notice-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.parsing-notice-text {
    flex: 1;
    color: #856404;
    font-size: 0.9rem;
    line-height: 1.5;
}

.parsing-notice-text strong {
    color: #664d03;
}

.btn-toggle-warnings {
    margin-left: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: #ffc107;
    color: #664d03;
    border: 1px solid #ffc107;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s;
}

.btn-toggle-warnings:hover {
    background: #ffca2c;
    border-color: #ffca2c;
}

.btn-toggle-warnings.active {
    background: #664d03;
    color: #fff3cd;
    border-color: #664d03;
}

/* Warning indicators */
.warning-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    font-size: 0.75rem;
    color: #856404;
    cursor: help;
    vertical-align: middle;
}

.warning-indicator.severity-high {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.warning-indicator.severity-medium {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.warning-indicator.severity-low {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.warning-indicator-icon {
    font-size: 0.875rem;
}

.warning-tooltip {
    position: absolute;
    background: #2c3e50;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    max-width: 250px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.warning-tooltip.visible {
    opacity: 1;
}

.warning-tooltip-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.warning-tooltip-description {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Warning details in popover */
.lexicon-popover .warning-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #ffc107;
    background: #fff3cd;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.lexicon-popover .warning-details-title {
    font-weight: 600;
    color: #856404;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lexicon-popover .warning-item {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: 3px;
    border-left: 3px solid #ffc107;
}

.lexicon-popover .warning-item.severity-high {
    border-left-color: #dc3545;
}

.lexicon-popover .warning-item.severity-medium {
    border-left-color: #ffc107;
}

.lexicon-popover .warning-item.severity-low {
    border-left-color: #17a2b8;
}

.lexicon-popover .warning-item-type {
    font-weight: 600;
    color: #664d03;
    margin-bottom: 0.25rem;
}

.lexicon-popover .warning-item-message {
    color: #856404;
    font-size: 0.8rem;
}

/* Contextual warnings on definitions */
.lexicon-popover .definition-warning {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 3px;
    font-size: 0.85rem;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lexicon-popover .definition-warning.severity-high {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.lexicon-popover .definition-warning.severity-medium {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.lexicon-popover .definition-warning.severity-low {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

.lexicon-popover .definition-warning .warning-icon {
    font-size: 1rem;
}

/* Warning indicators in lexicon entries */
.lexicon-entry-header .warning-indicator {
    margin-left: auto;
}

.lexicon-entry.has-warnings {
    border-left: 4px solid #ffc107;
}

.lexicon-entry.has-warnings.severity-high {
    border-left-color: #dc3545;
}

.lexicon-entry.has-warnings.severity-medium {
    border-left-color: #ffc107;
}

.lexicon-entry.has-warnings.severity-low {
    border-left-color: #17a2b8;
}

/* Lexicon browse styles */
.lexicon-controls {
    margin-bottom: 2rem;
}

.letter-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.letter-filter {
    padding: 0.5rem;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
    font-weight: 500;
}

.letter-filter:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.letter-filter.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.lexicon-placeholder,
.lexicon-more,
.no-results {
    text-align: center;
    color: #6c757d;
    padding: 2rem;
    font-style: italic;
}

.lexicon-entry {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.lexicon-entry-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e9ecef;
}

.lexicon-entry-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.lexicon-entry-header .part-of-speech {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-style: italic;
}

.lexicon-sense-section {
    margin-bottom: 1.5rem;
}

.lexicon-sense-section:not(:last-child) {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.sense-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.sense-header .sense-number {
    font-weight: 600;
    color: #2c3e50;
}

.sense-header .part-of-speech.sense-pos {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-style: italic;
}

.lexicon-definitions {
    margin-bottom: 1.5rem;
}

.definition-item {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #495057;
}

.definition-item .sense-number,
.definition .sense-number {
    font-weight: 600;
    color: #2c3e50;
}

.definition-item .definition-text {
    color: #212529;
}

/* Contextual warnings on definitions in lexicon browse */
.lexicon-definitions .definition-warning {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 3px;
    font-size: 0.85rem;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lexicon-definitions .definition-warning.severity-high {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.lexicon-definitions .definition-warning.severity-medium {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.lexicon-definitions .definition-warning.severity-low {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

.lexicon-definitions .definition-warning .warning-icon {
    font-size: 1rem;
}

.lexicon-references {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.lexicon-references h4 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.reference-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.reference-item {
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: background 0.2s, border-color 0.2s;
}

.reference-item[data-has-warning="true"] {
    border-left: 3px solid #ffc107;
    background: #fffbf0;
}

.reference-item.clickable-reference:hover {
    background: #e9ecef;
    border-color: #3498db;
    cursor: pointer;
}

.reference-item[data-has-warning="true"].clickable-reference:hover {
    background: #fff3cd;
    border-color: #ff9800;
}

.reference-item .reference-play {
    font-weight: 600;
    color: #2c3e50;
}

.reference-item .reference-location {
    color: #6c757d;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.reference-item .reference-warning {
    display: inline-block;
    margin-left: 0.25rem;
    color: #ff9800;
    font-size: 0.9rem;
    cursor: help;
}

.reference-item .reference-warning-message {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 3px;
    color: #856404;
    font-size: 0.85rem;
    font-style: italic;
}

.reference-item .reference-line-text {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #ffffff;
    border-radius: 3px;
    color: #2c3e50;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid #dee2e6;
}

.reference-item .reference-quote {
    margin-top: 0.5rem;
    padding-left: 1rem;
    color: #495057;
    font-style: italic;
    font-size: 0.9rem;
    border-left: 3px solid #3498db;
}

.reference-more {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 0.5rem;
}

.lexicon-more {
    text-align: center;
    color: #6c757d;
    padding: 1rem;
    font-style: italic;
    margin-top: 1rem;
}

/* View all references button */
.view-all-references {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.btn-view-all {
    padding: 0.5rem 1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-view-all:hover {
    background: #2980b9;
}

.view-all-references-popover {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.btn-view-all-popover {
    padding: 0.5rem 1rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-view-all-popover:hover {
    background: #2980b9;
}

/* Lexicon sense-specific view */
.lexicon-sense-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ecf0f1;
}

.btn-back-sense {
    padding: 0.5rem 1rem;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-back-sense:hover {
    background: #7f8c8d;
}

#sense-word-title {
    flex: 1;
    margin: 0;
    color: #2c3e50;
    font-size: 1.75rem;
}

.lexicon-sense-header-content {
    margin-bottom: 1.5rem;
}

.lexicon-sense-header-content .part-of-speech {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-style: italic;
}

.lexicon-sense-definition {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

.lexicon-sense-definition .definition-item {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #333;
}

.lexicon-sense-definition .sense-number {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 0.5rem;
}

.lexicon-sense-references h3 {
    margin: 0 0 1.5rem 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.lexicon-sense-references .reference-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lexicon-sense-references .reference-item {
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    transition: box-shadow 0.2s, border-left-color 0.2s;
}

.lexicon-sense-references .reference-item[data-has-warning="true"] {
    border-left-color: #ffc107;
    background: #fffbf0;
}

.lexicon-sense-references .reference-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left-color: #2980b9;
}

.lexicon-sense-references .reference-item[data-has-warning="true"]:hover {
    border-left-color: #ff9800;
}

.lexicon-sense-references .reference-item.clickable-reference {
    cursor: pointer;
}

.lexicon-sense-references .reference-play {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: block;
}

.lexicon-sense-references .reference-location {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.lexicon-sense-references .reference-line-text {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #ffffff;
    border-radius: 3px;
    color: #2c3e50;
    font-size: 0.95rem;
    line-height: 1.5;
    border: 1px solid #dee2e6;
}

.lexicon-sense-references .reference-quote {
    margin-top: 0.5rem;
    padding-left: 1rem;
    color: #495057;
    font-style: italic;
    font-size: 0.95rem;
    border-left: 3px solid #3498db;
}

/* Responsive for character companion */
@media (max-width: 768px) {
    .characters-grid {
        grid-template-columns: 1fr;
    }
    
    .letter-filters {
        grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
        gap: 0.25rem;
    }
    
    .letter-filter {
        padding: 0.4rem 0.3rem;
        font-size: 0.875rem;
    }
    
    .lexicon-entry {
        padding: 1rem;
    }
    
    .lexicon-entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

