/* --- Global Variables & Resets --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    --primary: #AD6242;
    --primary-light: #C47A5A;
    --primary-dark: #8E4D31;
    --bg-page: #E2AF80;
    --text-main: #1A1A1A;
    --text-muted: rgba(26, 26, 26, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Playfair Display', serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --base-font-size: 16px;
    --surface-primary: rgba(173, 98, 66, 0.8);
    --surface-secondary: rgba(255, 255, 255, 0.03);
    --surface-tertiary: rgba(255, 255, 255, 0.06);
    --surface-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.1);
    --surface-shadow: var(--shadow-md);
}

body[data-theme="default"] {
    --primary: #AD6242;
    --primary-light: #C47A5A;
    --primary-dark: #8E4D31;
    --bg-page: #E2AF80;
    --text-main: #1A1A1A;
    --text-muted: rgba(26, 26, 26, 0.6);
    --surface-primary: rgba(173, 98, 66, 0.8);
    --surface-secondary: rgba(255, 255, 255, 0.03);
    --surface-tertiary: rgba(255, 255, 255, 0.06);
    --surface-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] {
    --primary: #17120f;
    --primary-light: #201814;
    --primary-dark: #0d0907;
    --bg-page: #12100f;
    --text-main: #F4EFE8;
    --text-muted: rgba(244, 239, 232, 0.66);
    --surface-primary: rgba(38, 28, 22, 0.92);
    --surface-secondary: rgba(255, 255, 255, 0.04);
    --surface-tertiary: rgba(255, 255, 255, 0.08);
    --surface-border: rgba(255, 255, 255, 0.12);
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-border: rgba(255, 255, 255, 0.12);
    --surface-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

body[data-font-size="small"] {
    --base-font-size: 14px;
}

body[data-font-size="medium"] {
    --base-font-size: 16px;
}

body[data-font-size="large"] {
    --base-font-size: 18px;
}

*, *:before, *:after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--primary);
    font-family: var(--font-sans);
    color: var(--text-white);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: var(--base-font-size);
}

.hidden {
    display: none !important;
}

/* Page container */
.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    background-color: var(--bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.compact-mode header {
    padding: 12px;
}

body.compact-mode main {
    padding-bottom: 48px;
}

body.compact-mode .latest-card,
body.compact-mode .widget,
body.compact-mode .book-widget,
body.compact-mode .search-container {
    gap: 12px;
}

body.compact-mode .navbar {
    padding: 8px 18px;
}

/* --- Typography --- */
.serif {
    font-family: var(--font-serif);
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
}

.advanced-search-subtitle {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.88rem;
    line-height: 1.5;
}

.advanced-search-icon {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.2s ease;
    display: inline-grid;
    place-items: center;
    font-size: 1.3rem;
    line-height: 1;
}

.advanced-search-body {
    padding-top: 8px;
}

.advanced-search-section {
    display: grid;
    gap: 16px;
}

.advanced-search-section-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.advanced-search-section-header h4 {
    font-size: 1rem;
    color: white;
}

.advanced-search-section-header p {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.85rem;
    line-height: 1.55;
    max-width: 680px;
}

.advanced-search-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 24px 0;
}

.advanced-search-genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.advanced-genre-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.advanced-genre-card.is-included {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.1);
}

.advanced-genre-card.is-excluded {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}

.advanced-genre-name {
    color: white;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.advanced-genre-controls,
.advanced-mode-toggle,
.advanced-search-actions,
.search-result-meta,
.search-result-genres {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.advanced-genre-action,
.advanced-mode-btn,
.reset-filters,
.find-series-btn,
.search-result-more,
.advanced-tag-chip,
.advanced-genre-toggle {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: white;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font-family: inherit;
}

.advanced-genre-action,
.advanced-mode-btn {
    padding: 7px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.advanced-genre-toggle {
    min-width: 88px;
    padding: 7px 12px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.advanced-genre-toggle[data-state="inc"] {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.38);
    color: #d9ffe6;
}

.advanced-genre-toggle[data-state="exc"] {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.34);
    color: #ffd8d8;
}

.advanced-mode-btn.is-active {
    background: rgba(173, 98, 66, 0.18);
    border-color: rgba(173, 98, 66, 0.4);
    color: #ffd8bf;
}

.advanced-tag-picker {
    display: grid;
    gap: 12px;
}

.advanced-tag-input-row {
    position: relative;
    z-index: 8;
}

.advanced-tag-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.45);
}

.advanced-tag-search-input,
.advanced-search-field select {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border-radius: 14px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: white;
    font-family: inherit;
}

.advanced-search-field select {
    padding-left: 14px;
}

.advanced-tag-search-input::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.advanced-tag-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    border-radius: 14px;
    overflow: hidden;
    background: #20140e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    max-height: 240px;
    overflow-y: auto;
}

.advanced-tag-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: white;
    padding: 12px 14px;
    cursor: pointer;
    font-family: inherit;
}

.advanced-tag-suggestion:hover {
    background: rgba(255, 255, 255, 0.06);
}

.advanced-tag-suggestion.is-empty {
    color: rgba(255, 255, 255, 0.56);
    cursor: default;
}

.advanced-selected-tags {
    min-height: 48px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.advanced-empty-tags {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.86rem;
    font-style: italic;
}

.advanced-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.advanced-search-other-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.advanced-search-field {
    display: grid;
    gap: 10px;
}

.advanced-search-field label {
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
}

.advanced-choice-list {
    display: grid;
    gap: 10px;
}

.advanced-choice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.84);
    font-size: 0.9rem;
}

.reset-filters,
.find-series-btn {
    padding: 12px 20px;
    font-size: 0.92rem;
    font-weight: 700;
}

.reset-filters {
    min-width: 160px;
}

.find-series-btn {
    background: rgba(173, 98, 66, 0.22);
    border-color: rgba(173, 98, 66, 0.45);
    color: #ffe1cc;
}

.search-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    font-weight: 600;
}

.search-filter-chip.is-include {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.22);
}

.search-filter-chip.is-exclude {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.search-result-card {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 18px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-result-cover-link {
    display: block;
    width: 132px;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.search-result-cover,
.search-result-cover-fallback {
    width: 100%;
    height: 100%;
}

.search-result-cover {
    object-fit: cover;
}

.search-result-cover-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
}

.search-result-main {
    min-width: 0;
    display: grid;
    gap: 12px;
}

.search-result-title {
    margin: 0 0 6px 0;
    font-size: 1.35rem;
    line-height: 1.15;
    color: white;
}

.search-result-author {
    color: rgba(255, 255, 255, 0.68);
    font-style: italic;
    line-height: 1.5;
}

.search-result-genre-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(173, 98, 66, 0.12);
    border: 1px solid rgba(173, 98, 66, 0.22);
    color: #ffd7c2;
    font-size: 0.75rem;
    font-weight: 600;
}

.search-result-meta {
    justify-content: flex-end;
}

.search-result-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-result-synopsis-text {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-synopsis-text[data-expanded="true"] {
    display: block;
    overflow: visible;
}

.search-result-more {
    padding: 8px 0;
    border: none;
    background: transparent;
    color: #ffd7c2;
    font-size: 0.84rem;
    font-weight: 700;
}

@media (max-width: 900px) {
    .search-result-card {
        grid-template-columns: 96px 1fr;
    }

    .search-result-cover-link {
        width: 96px;
    }
}

@media (max-width: 680px) {
    .advanced-search-section-header,
    .advanced-search-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-result-card {
        grid-template-columns: 1fr;
    }

    .search-result-cover-link {
        width: 132px;
    }
}

/* --- Navigation Bar --- */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 20px;
}

.navbar {
    background: rgba(173, 98, 66, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    box-shadow: var(--shadow-lg);
}

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

.logo a {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.navlist {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navlist li a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.navlist li a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* --- Profile & Dropdowns --- */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-search-category,
.nav-search-input {
    border: none;
    outline: none;
    background: transparent;
    color: white;
    font-size: 13px;
    font-family: var(--font-sans);
}

.nav-search-category {
    min-width: 108px;
    padding: 8px 10px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.14);
    cursor: pointer;
}

.nav-search-category option {
    color: var(--text-main);
}

.nav-search-input {
    min-width: 220px;
    padding: 8px 4px;
}

.nav-search-input::placeholder {
    color: rgba(255, 255, 255, 0.65);
}

.nav-search-submit {
    border: none;
    border-radius: var(--radius-full);
    padding: 9px 16px;
    background: white;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.nav-search-submit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.profile-circle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
    cursor: pointer;
    display: block;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.profile-circle:hover {
    border-color: white;
    transform: scale(1.05);
}

.profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    width: 220px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.profile-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.profile-dropdown a:hover {
    background: #F5F5F5;
}

.logout-link {
    color: #EF4444 !important;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    right: -320px;
    top: 0;
    width: 320px;
    height: 100%;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: white;
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 40px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
}

.sidebar.expanded {
    transform: translateX(-320px);
}

.sidebar-close {
    font-size: 32px;
    cursor: pointer;
    opacity: 0.5;
    transition: var(--transition);
}

.sidebar-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 40px 0 0;
}

.sidebar-menu li {
    margin-bottom: 24px;
}

.sidebar-menu li a {
    color: white;
    text-decoration: none;
    font-size: 24px;
    font-family: var(--font-serif);
    font-weight: 700;
    opacity: 0.7;
    transition: var(--transition);
}

.sidebar-menu li a:hover {
    opacity: 1;
    padding-left: 12px;
}

/* --- Search Section --- */
.search-container {
    padding: 80px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.search-wrapper {
    width: 100%;
    max-width: 800px;
    position: relative;
    display: flex;
    background: white;
    border-radius: var(--radius-full);
    padding: 8px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.search-wrapper:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    z-index: 1001;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    display: none;
    text-align: left;
}

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

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-main);
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

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

.suggestion-item:hover {
    background: #F5F5F5;
}

.suggestion-cover {
    width: 32px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: #EEE;
}

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-author {
    font-size: 0.8rem;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 24px;
    font-size: 18px;
    font-family: var(--font-sans);
    outline: none;
    color: var(--text-main);
}

.search-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.search-button:hover {
    background: var(--primary-dark);
}

/* --- Content Cards --- */
.latest-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 32px;
    color: white;
}

.latest-grid-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 24px;
    padding: 16px;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.latest-grid-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

.widget .latest-grid-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.widget .latest-grid-row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.cell.book {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cell-book-cover {
    width: 48px;
    height: 72px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: var(--shadow-md);
}

/* --- Widgets --- */
.widget {
    background: var(--surface-primary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--surface-shadow);
    padding: 32px;
    color: white;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.widget-body {
    /* content */
}

/* --- Footer --- */
footer {
    margin-top: auto;
    padding: 60px 20px;
    background: var(--primary-dark);
}

.latest-card {
    background: var(--surface-primary) !important;
    border-color: var(--surface-border) !important;
    box-shadow: var(--surface-shadow);
    color: white !important;
}

.list-card-surface,
.profile-library-card,
.profile-stat-card,
.library-search-form input,
.library-search-form select,
.bookshelf-page input,
.bookshelf-page textarea,
.bookshelf-page select {
    background: var(--surface-secondary);
    border: 1px solid var(--surface-border);
    color: white;
}

.profile-stat-card,
.profile-library-card {
    border-radius: 16px;
    padding: 16px;
}

.profile-stat-card strong {
    display: block;
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.profile-stat-card span {
    opacity: 0.62;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-library-grid,
.list-grid-profile {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.library-search-form {
    display: grid;
    gap: 16px;
}

.library-search-form input,
.library-search-form select,
.bookshelf-page input,
.bookshelf-page textarea,
.bookshelf-page select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    outline: none;
    font-family: inherit;
}

.library-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.footerlist {
    display: flex;
    gap: 32px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.footerlist a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.footerlist a:hover {
    color: white;
}

body[data-theme="dark"] .widget,
body[data-theme="dark"] .latest-card,
body[data-theme="dark"] footer.widget,
body[data-theme="dark"] .list-card-surface,
body[data-theme="dark"] .advanced-genre-card,
body[data-theme="dark"] .advanced-selected-tags,
body[data-theme="dark"] .search-result-card,
body[data-theme="dark"] .profile-library-card,
body[data-theme="dark"] .profile-stat-card {
    background: var(--surface-primary) !important;
    border-color: var(--surface-border) !important;
    color: white !important;
}

body[data-theme="dark"] .library-search-form input,
body[data-theme="dark"] .library-search-form select,
body[data-theme="dark"] .bookshelf-page input,
body[data-theme="dark"] .bookshelf-page textarea,
body[data-theme="dark"] .bookshelf-page select,
body[data-theme="dark"] .messages-page textarea,
body[data-theme="dark"] .messages-page input,
body[data-theme="dark"] .messages-page select {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: white !important;
}

body[data-theme="dark"] .footerlist a,
body[data-theme="dark"] .widget-title {
    color: white;
}

body[data-theme="dark"] .page {
    background-color: var(--bg-page);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .latest-grid-row {
        grid-template-columns: 1fr 1fr;
    }
    .latest-grid-row .column:last-child {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 8px 16px;
    }
    .navlist {
        display: none;
    }
    .nav-search-form {
        display: none;
    }
    .latest-grid-row {
        grid-template-columns: 1fr;
    }
    .search-wrapper {
        border-radius: var(--radius-md);
        flex-direction: column;
        padding: 16px;
        gap: 12px;
    }
    .search-button {
        width: 100%;
    }
}

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-8 { gap: 32px; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.text-center { text-align: center; }
.w-4 { width: 16px; }
.h-4 { height: 16px; }
.w-5 { width: 20px; }
.h-5 { height: 20px; }
.w-6 { width: 24px; }
.h-6 { height: 24px; }
