:root {
    /* Modern color palette */
    --primary-color: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary-color: #8b5cf6;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #0f172a;
    --dark-card: #1e293b;
    --dark-surface: #334155;
    --light-bg: #f8fafc;
    --light-card: #ffffff;
    --light-surface: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.3);
}

/* Dark theme */
body.dark-theme {
    --primary-color: #60a5fa;
    --primary-dark: #3b82f6;
    --secondary-color: #a78bfa;
    --accent-color: #34d399;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --surface-bg: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
    --glass-bg: rgba(30, 41, 59, 0.95);
    --glass-border: rgba(255, 255, 255, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header - Modern glassmorphism */
.header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

.mobile-menu-toggle:hover {
    background: var(--glass-bg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.125rem 0.5rem;
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    border: 1px solid var(--glass-border);
    display: inline-block;
    margin-top: 0.25rem;
}

/* Navigation */
.main-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 800px;
    margin: 0 auto;
}

.nav-search {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    flex: 1;
    position: relative;
}

.nav-search i {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.nav-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

.nav-search input::placeholder {
    color: var(--text-secondary);
}

.nav-search button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.nav-search button:hover {
    background: var(--danger-color);
    color: white;
}

.nav-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    max-height: 300px;
    overflow-y: auto;
    /* Make sure the search dropdown is above filters/modals */
    z-index: 11000;
    box-shadow: var(--shadow-lg);
}

/* If other components still overlap, consider rendering the dropdown as a direct child of <body>
   or increasing the z-index further. */

.nav-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.nav-search-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-search-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-search-type {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

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

.nav-search-item:hover {
    background: var(--primary-color);
    color: white;
}

.main-nav ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    justify-content: center;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.875rem;
}

.main-nav a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.main-nav a.nav-active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    width: 2.5rem;
    height: 2.5rem;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-load {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--accent-color), #059669);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
}

.btn-load:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Main Content */
.main-content {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    min-height: calc(100vh - 200px);
    height: auto;
}

/* List Container */
.list-container {
    flex: 0 0 380px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    height: auto;
    min-height: 500px;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

.list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-shrink: 0;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.list-header h2 {
    margin: 0;
    font-size: 1.25rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.list-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.list-controls.left {
    display: contents;
}

.filters-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.875rem;
    flex-shrink: 0;
    order: 0;
    width: 2.5rem;
    height: 2.5rem;
}

.filters-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.filter-text {
    display: none;
}

.list-search {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
    overflow: hidden;
    order: 200;
    flex-basis: 100%;
}

.list-search i {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.list-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    min-width: 0;
}

.list-search input::placeholder {
    color: var(--text-secondary);
}

.list-search button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.list-search button:hover {
    background: var(--danger-color);
    color: white;
}

.list-controls.right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    order: 100;
    margin-left: auto;
}

#itemCount {
    background: var(--glass-bg);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    min-width: 2rem;
    text-align: center;
    height: fit-content;
}

.btn-small {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    width: 2.5rem;
    height: 2.5rem;
    order: 1;
}

.btn-small:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Item List */
.item-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    height: 100%;
}

.list-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: var(--transition);
}

.list-item:hover::before,
.list-item.active::before {
    opacity: 1;
}

.list-item:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

.list-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color);
}

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.9375rem;
    line-height: 1.3;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
}

.item-level {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.75rem;
}

.item-school {
    color: var(--text-secondary);
}

/* Full width list mode */
.list-container.full-width {
    flex: 1;
    min-width: 100%;
}

.list-container.full-width .item-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.list-container.full-width .list-item {
    margin-bottom: 0;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Detail View */
.detail-view {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    height: auto;
    min-height: 500px;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

/* Placeholders */
.placeholder {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    flex: 1;
}

.placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
    color: var(--primary-color);
}

.placeholder h2 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.placeholder p {
    color: var(--text-secondary);
    max-width: 300px;
    margin-bottom: 1.5rem;
}

/* Spell Detail */
.detail-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    height: 100%;
}

.spell-level-school {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spell-properties {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.spell-property {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.property-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.property-value {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.spell-description {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.spell-description p {
    margin-bottom: 1rem;
}

/* Filters Panel */
.filters-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    display: none;
    min-width: 300px;
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.filters-header h3 {
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-filters {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.close-filters:hover {
    background: var(--danger-color);
    color: white;
}

.filters-content {
    display: grid;
    gap: 1.5rem;
}

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

.filter-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.filter-group select {
    padding: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    outline: none;
    transition: var(--transition);
}

.filter-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-group select[multiple] {
    min-height: 120px;
    max-height: 200px;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.btn-primary, .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9375rem;
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--surface-bg);
    transform: translateY(-2px);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

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

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.close-modal:hover {
    background: var(--danger-color);
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.modal-body ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.modal-body li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.modal-body kbd {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.375rem;
    font-size: 0.875rem;
    font-family: monospace;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
}

/* Utility Classes */
.highlight {
    background: linear-gradient(120deg, rgba(251, 191, 36, 0.3), rgba(251, 191, 36, 0.1));
    color: inherit;
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-sm);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
    animation: spin 1s linear infinite;
}

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

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
    text-align: center;
}

.no-results i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.no-results p {
    margin: 0.5rem 0;
}

.no-results small {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.sort-select:focus {
    border-color: var(--primary-color);
}

/* Detail headers */
.detail-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.detail-title {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
}

/* ================== МОБИЛЬНАЯ АДАПТАЦИЯ ================== */
@media (max-width: 1024px) {
    .main-content {
        gap: 1rem;
    }
    
    .list-container {
        flex: 0 0 320px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 0.75rem 1rem;
        margin-bottom: 0.5rem;
        flex-wrap: nowrap;
        position: relative;
        min-height: 60px;
    }
    
    .mobile-menu-toggle {
        display: flex;
        order: 1;
    }
    
    .logo {
        order: 2;
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    .logo i {
        font-size: 1.75rem;
    }
    
    .logo h1 {
        font-size: 1.125rem;
    }
    
    .subtitle {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
    }
    
    .header-actions {
        order: 3;
        gap: 0.5rem;
    }
    
    .theme-toggle {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }
    
    .btn-load {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .btn-load span {
        display: none;
    }
    
    .main-nav {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-lg);
        margin: 0 1rem;
        padding: 1rem;
        z-index: 9999;
        box-shadow: var(--shadow-xl);
        display: none;
        max-width: calc(100vw - 2rem);
    }
    
    .main-nav.mobile-open {
        display: flex;
    }
    
    .nav-search {
        margin-bottom: 0.75rem;
    }
    
    .main-nav ul {
        flex-direction: column;
        width: 100%;
    }
    
    .main-nav a {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }
    
    .main-content {
        flex-direction: column;
        min-height: auto;
        gap: 0.75rem;
    }
    
    .list-container {
        flex: none;
        width: 100%;
        height: auto;
        max-height: none;
        min-height: 300px;
    }
    
    .list-header {
        padding: 0.75rem;
        flex-direction: row;
        align-items: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .list-controls.left {
        display: contents;
    }
    
    .list-header h2 {
        display: none;
    }
    
    .list-controls.right {
        order: 100;
        margin-left: auto;
    }
    
    .filters-toggle {
        padding: 0.5rem;
        font-size: 0.875rem;
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .filter-text {
        display: none;
    }
    
    .list-search {
        order: 200;
        flex-basis: 100%;
        min-width: 0;
    }
    
    .list-search input {
        font-size: 0.8125rem;
    }
    
    .item-list {
        padding: 0.5rem;
        overflow: visible;
        height: auto;
        max-height: none;
    }
    
    .list-item {
        padding: 0.625rem;
        margin-bottom: 0.375rem;
    }

    /* Hide toggleView on mobile */
    #toggleView {
        display: none;
    }

    /* By default on mobile hide the inline detail area (so only the list is visible) */
    .detail-view {
        display: none;
    }

    /* Mobile: show detail popup and hide list when open */
    body.mobile-detail-open .list-container {
        display: none;
    }

    body.mobile-detail-open .detail-view {
        position: fixed;
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
        z-index: 11002;
        border-radius: var(--radius-lg);
        max-height: calc(100vh - 24px);
        height: auto;
        display: flex;
        flex-direction: column;
        box-shadow: var(--shadow-xl);
        overflow: auto;
        padding: 1rem;
        transition: transform 0.18s ease, opacity 0.18s ease;
        transform: translateY(0);
        opacity: 1;
        background: var(--glass-bg);
    }

    .mobile-back-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        color: var(--text-primary);
        padding: 0.5rem;
        border-radius: var(--radius-full);
        margin-right: 0.5rem;
        cursor: pointer;
        font-size: 1rem;
        line-height: 1;
    }

    .detail-header { display:flex; align-items:center; gap:0.75rem; }
    
    .item-name {
        font-size: 0.875rem;
        margin-bottom: 0.125rem;
    }
    
    .item-meta {
        font-size: 0.75rem;
    }
    
    .item-level {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
    }
    
    /* Full width list mode on mobile */
    .list-container.full-width .item-list {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .detail-view {
        display: none;
    }
    
    .detail-content {
        padding: 1rem;
    }
    
    .detail-title {
        font-size: 1.5rem;
    }
    
    .spell-properties {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
    
    .spell-property {
        gap: 0.25rem;
    }
    
    .property-label {
        font-size: 0.75rem;
    }
    
    .property-value {
        font-size: 0.9375rem;
    }
    
    .spell-description {
        font-size: 0.9375rem;
        line-height: 1.6;
    }
    
    .placeholder {
        padding: 1.5rem;
    }
    
    .placeholder i {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .placeholder h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .placeholder p {
        max-width: 250px;
        margin-bottom: 1rem;
    }
    
    /* More compact filters panel on mobile */
    .filters-panel {
        padding: 1rem;
        min-width: 280px;
        max-height: 80vh;
    }
    
    .filters-header h3 {
        font-size: 1.125rem;
    }
    
    .filter-group label {
        font-size: 0.875rem;
    }
    
    .filter-group select {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .header {
        min-height: 56px;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .subtitle {
        font-size: 0.625rem;
        padding: 0.125rem 0.25rem;
    }
    
    .list-container {
        min-height: 250px;
        max-height: none;
        height: auto;
    }
    
    .item-list {
        padding: 0.375rem;
    }
    
    .list-item {
        padding: 0.5rem;
    }
    
    .item-name {
        font-size: 0.8125rem;
    }
    
    .item-meta {
        font-size: 0.6875rem;
    }
    
    .detail-content {
        padding: 0.75rem;
    }
    
    .detail-title {
        font-size: 1.25rem;
    }
    
    .spell-level-school {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}

/* ================== СТИЛИ ДЛЯ МОНСТРОВ ================== */
.monster-basic-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.monster-type-size {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.monster-cr {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
}

.monster-statblock {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}

.statblock-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.monster-abilities {
    margin-bottom: 1.5rem;
}

.monster-abilities h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.ability-scores {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ability-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.5rem;
}

.ability-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.ability-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.ability-modifier {
    font-size: 0.875rem;
    color: var(--accent-color);
    font-weight: 600;
}

.monster-properties {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.property-group h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.property-group p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.monster-description {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.monster-description h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.description-text {
    color: var(--text-primary);
    line-height: 1.6;
}

.description-text p {
    margin-bottom: 1rem;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .ability-scores {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.375rem;
    }
    
    .monster-statblock {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .ability-score {
        padding: 0.5rem 0.25rem;
    }
    
    .ability-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .ability-scores {
        grid-template-columns: repeat(2, 1fr);
    }
}



/* ================== СТИЛИ ДЛЯ МОНСТРОВ ================== */
.monster-basic-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.monster-type-size {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.monster-cr {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
}

.monster-statblock {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}

.statblock-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

.monster-abilities {
    margin-bottom: 1.5rem;
}

.monster-abilities h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.ability-scores {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ability-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.5rem;
}

.ability-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.ability-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.ability-modifier {
    font-size: 0.875rem;
    color: var(--accent-color);
    font-weight: 600;
}

.monster-properties {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.property-group h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.property-group p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.monster-features,
.monster-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.monster-features h3,
.monster-actions h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.feature-item,
.action-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.feature-item:last-child,
.action-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.feature-item strong,
.action-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}

.feature-item p,
.action-item p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.monster-description {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.monster-description h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.description-text {
    color: var(--text-primary);
    line-height: 1.6;
}

.description-text p {
    margin-bottom: 1rem;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .ability-scores {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.375rem;
    }
    
    .monster-statblock {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .ability-score {
        padding: 0.5rem 0.25rem;
    }
    
    .ability-value {
        font-size: 1.25rem;
    }
    
    .monster-basic-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .ability-scores {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .monster-cr {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ================== СТИЛИ ДЛЯ ЗАКЛИНАНИЙ МОНСТРА ================== */
.monster-spells {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.monster-spells h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.spellcasting-description {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.spellcasting-description strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.spell-level-group {
    margin-bottom: 1.5rem;
}

.spell-level-group h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--glass-border);
}

.monster-spell-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

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

.monster-spell-header strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.monster-spell-meta {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.monster-spell-properties {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.monster-spell-properties span {
    display: block;
    color: var(--text-secondary);
}

.monster-spell-properties strong {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 0.25rem;
}

.monster-spell-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .monster-spell-properties {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    
    .monster-spell-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .monster-spell-item {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .spellcasting-description {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* ================== СТИЛИ ДЛЯ ЛЕГЕНДАРНЫХ ДЕЙСТВИЙ ================== */
.monster-legendary-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--glass-border);
}

.monster-legendary-actions h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
}

.legendary-intro {
    background: rgba(139, 92, 246, 0.1);
    border-left: 4px solid var(--secondary-color);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.legendary-action-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.legendary-action-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--secondary-color), #a78bfa);
}

.legendary-action-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.legendary-action-header strong {
    font-size: 1.1rem;
    color: var(--text-primary);
    flex: 1;
    min-width: 200px;
}

.legendary-action-cost {
    background: linear-gradient(90deg, #3a506b 0%, #2d4263 100%);
    color: #4cc9f0;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    border: 1px solid #4a4a6a;
    white-space: nowrap;
}

.legendary-action-description {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.legendary-action-description p {
    margin-bottom: 0.5rem;
}

.legendary-action-description p:last-child {
    margin-bottom: 0;
}

/* Стили для свойств с ограниченным использованием */
.feature-item .limited-uses,
.action-item .limited-uses,
.legendary-action-description .limited-uses {
    display: inline-block;
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .monster-legendary-actions {
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }
    
    .legendary-action-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .legendary-action-header strong {
        min-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .legendary-action-cost {
        align-self: flex-start;
    }
}

/* ================== STICKY HEADER FOR MOBILE ================== */
@media (max-width: 768px) {
    .list-container {
        position: relative;
    }
    
    .list-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        padding: 0.75rem;
        border-bottom: 1px solid var(--glass-border);
        margin-bottom: 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .item-list {
        padding-top: 0.5rem;
        height: auto;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .list-header::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: linear-gradient(90deg, 
            transparent 0%, 
            var(--glass-border) 20%, 
            var(--glass-border) 80%, 
            transparent 100%
        );
    }
    
    /* Улучшаем скролл на iOS */
    .item-list {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Убираем лишние отступы при прокрутке */
    .list-item:first-child {
        margin-top: 0;
    }
    
    /* Прячем заголовок раздела в мобильной версии */
    .list-header h2 {
        display: none;
    }
    
    /* Улучшаем видимость sticky-шапки при прокрутке */
    .list-header {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* На очень маленьких экранах дополнительная оптимизация */
@media (max-width: 480px) {
    .list-header {
        padding: 0.5rem;
    }
    
    .filters-toggle, .btn-small {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.875rem;
    }
    
    .list-search {
        padding: 0.375rem 0.75rem;
    }
    
    #itemCount {
        font-size: 0.6875rem;
        min-width: 1.75rem;
        padding: 0.125rem 0.375rem;
    }
    
    .item-list {
        max-height: calc(100vh - 100px);
    }
}

/* Для Android и других браузеров - улучшаем sticky позиционирование */
@supports (position: sticky) or (position: -webkit-sticky) {
    @media (max-width: 768px) {
        .list-header {
            position: -webkit-sticky; /* Для Safari */
            position: sticky;
        }
    }
}

/* Улучшаем отображение при открытом фильтре или модальном окне */
@media (max-width: 768px) {
    .filters-panel[style*="display: block"] ~ .container .list-header,
    .modal-overlay[style*="display: flex"] ~ .container .list-header {
        z-index: 10001; /* Ниже модальных окон, но выше контента */
    }
    
    /* Когда открыт детальный просмотр, шапка должна скрываться */
    body.mobile-detail-open .list-header {
        display: none;
    }
}

/* Плавная прокрутка для всего приложения */
html {
    scroll-behavior: smooth;
}

/* Улучшаем видимость счетчика элементов */
#itemCount {
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

/* Анимация появления/скрытия шапки при прокрутке */
.list-header {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Когда пользователь прокручивает вниз, можно немного уменьшить шапку */
.list-header.scrolled {
    padding: 0.5rem 0.75rem;
}

.scrolled .filter-text,
.scrolled .filters-toggle span:not(.fa) {
    display: none;
}

.scrolled .filters-toggle,
.scrolled .btn-small {
    width: 2.25rem;
    height: 2.25rem;
}

/* ================== LIST HEADER WRAPPER ================== */
.list-header-wrapper {
    position: relative;
    z-index: 100;
}

@media (max-width: 768px) {
    .list-header-wrapper {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .list-header {
        margin-bottom: 0;
    }
}


.nav-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    max-height: 300px;
    overflow-y: auto;
    /* Увеличиваем z-index чтобы был выше других элементов */
    z-index: 11000;
    box-shadow: var(--shadow-lg);
}


/* Добавьте в styles.css */
.ability-score .proficiency-indicator {
    color: #ffd700;
    margin-left: 4px;
    font-size: 0.9em;
    cursor: help;
}

.monster-proficiency-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin: 20px 0;
    background: rgba(30, 30, 46, 0.7);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #3a506b;
}

@media (max-width: 768px) {
    .monster-proficiency-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.proficiency-bonus h4,
.saving-throws h4 {
    color: #4cc9f0;
    margin-bottom: 8px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.proficiency-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffd700;
    text-align: center;
    margin: 0;
}

.saving-throws-list {
    margin: 0;
    line-height: 1.5;
    color: #e0e0e0;
}

.monster-cr {
    font-size: 0.95em;
    color: #fff;
    margin-top: 5px;
}

/* Добавьте в styles.css */


.legendary-action-cost.cost-2 {
    background: linear-gradient(90deg, #4a2d63 0%, #3a1d5b 100%);
    color: #c89bff;
}

.legendary-action-cost.cost-3 {
    background: linear-gradient(90deg, #634a2d 0%, #5b3a1d 100%);
    color: #ffcc89;
}

.skills-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.skill-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
}

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

.skill-name {
    flex: 1;
    font-weight: 500;
}

.skill-bonus {
    font-weight: bold;
    color: #4cc9f0;
    min-width: 40px;
    text-align: right;
}

.skill-ability {
    color: #a0a0c0;
    font-size: 0.9em;
    min-width: 50px;
}

.expertise-marker {
    background: linear-gradient(90deg, #4a2d63 0%, #3a1d5b 100%);
    color: #c89bff;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: bold;
    border: 1px solid #6a4d8a;
}

.half-proficiency-marker {
    background: linear-gradient(90deg, #3a506b 0%, #2d4263 100%);
    color: #a0a0c0;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: bold;
    border: 1px solid #4a4a6a;
}

/* Добавьте в styles.css */
.letter-header {
    padding: 0.75rem 0.5rem;
    margin: 0.5rem 0;
    background: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        var(--secondary-color) 100%
    );
    color: white;
    font-weight: bold;
    border-radius: var(--radius-md);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

/* Для мобильных */
@media (max-width: 768px) {
    .letter-header {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}

/* Добавьте в styles.css */

/* Заголовки букв */
.letter-header {
    background: linear-gradient(90deg, 
        rgba(59, 130, 246, 0.1) 0%, 
        rgba(139, 92, 246, 0.1) 100%
    );
    border-left: 4px solid var(--primary-color);
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
    border-radius: var(--radius-md);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

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

.letter-header .letter {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.letter-header .count {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Цвета для CR (Опасности) */
.cr-deadly {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: white !important;
}

.cr-hard {
    background: linear-gradient(135deg, #ea580c, #c2410c) !important;
    color: white !important;
}

.cr-medium {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    color: white !important;
}

.cr-easy {
    background: linear-gradient(135deg, #65a30d, #4d7c0f) !important;
    color: white !important;
}

/* Индикатор загрузки в элементе списка */
.item-loading {
    color: var(--primary-color);
    font-size: 0.75rem;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .letter-header {
        padding: 0.375rem 0.75rem;
        margin: 0.375rem 0;
    }
    
    .letter-header .letter {
        font-size: 1rem;
    }
    
    .letter-header .count {
        font-size: 0.6875rem;
    }
}

/* Улучшения для списка */
.list-item {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.list-item:hover {
    transform: translateX(3px);
    box-shadow: var(--shadow-md);
}

.list-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary-color);
    border-left-width: 3px;
}

/* Плавная прокрутка к активному элементу */
.list-item.active:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, 
        var(--primary-color), 
        var(--secondary-color)
    );
}