:root {
    --bg-deep: #07050f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f4f0ff;
    --text-muted: #a89ec4;
    --accent: #f59e0b;
    --accent-soft: rgba(245, 158, 11, 0.15);
    --purple: #a855f7;
    --purple-soft: rgba(168, 85, 247, 0.18);
    --success: #34d399;
    --danger: #f87171;
    --radius: 1rem;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    --font-body: "DM Sans", system-ui, sans-serif;
    --font-display: "Fraunces", Georgia, serif;
    --player-height: 5.75rem;
    --player-settings-height: 7.5rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg-deep);
    line-height: 1.6;
}

body.app-body {
    display: flex;
    flex-direction: column;
}

.bg-glow {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(168, 85, 247, 0.22), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(245, 158, 11, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 100%, rgba(99, 102, 241, 0.1), transparent 55%),
        linear-gradient(180deg, #0c0818 0%, #07050f 100%);
}

.bg-glow::before,
.bg-glow::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: float 18s ease-in-out infinite;
}

.bg-glow::before {
    width: 420px;
    height: 420px;
    top: -120px;
    left: -80px;
    background: rgba(168, 85, 247, 0.15);
}

.bg-glow::after {
    width: 360px;
    height: 360px;
    right: -60px;
    bottom: 10%;
    background: rgba(245, 158, 11, 0.1);
    animation-delay: -9s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -16px) scale(1.05); }
}

.app-navbar {
    backdrop-filter: blur(16px);
    background: rgba(7, 5, 15, 0.72) !important;
    border-bottom: 1px solid var(--border) !important;
    padding-block: 0.85rem;
}

.navbar-brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    color: var(--text) !important;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, var(--purple), var(--accent));
    color: #fff;
    font-size: 1rem;
    margin-right: 0.55rem;
    vertical-align: middle;
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.35);
}

.nav-link {
    color: var(--text-muted) !important;
    font-weight: 500;
    padding: 0.45rem 0.85rem !important;
    border-radius: 999px;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text) !important;
    background: rgba(255, 255, 255, 0.06);
}

.app-main {
    flex: 1;
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0 0 0.35rem;
    line-height: 1.15;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0;
    font-size: 1.02rem;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.glass-card-hover {
    transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.glass-card-hover:hover {
    transform: translateY(-3px);
    background: var(--bg-card-hover);
    border-color: rgba(245, 158, 11, 0.25);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(245, 158, 11, 0.08);
}

.btn-accent {
    --bs-btn-color: #1a1008;
    --bs-btn-bg: linear-gradient(135deg, #fbbf24, #f59e0b);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: linear-gradient(135deg, #fcd34d, #fbbf24);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: #d97706;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: none;
    color: #1a1008;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.65rem 1.35rem;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 36px rgba(245, 158, 11, 0.35);
    color: #1a1008;
}

.btn-ghost {
    --bs-btn-color: var(--text);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.06);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.18);
    --bs-btn-hover-color: var(--text);
    border-radius: 999px;
    font-weight: 500;
}

.form-label {
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.form-control,
.form-select {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 0.75rem !important;
    padding: 0.75rem 1rem !important;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(168, 85, 247, 0.5) !important;
    box-shadow: 0 0 0 0.2rem rgba(168, 85, 247, 0.15) !important;
}

.form-control::placeholder {
    color: #6b6280 !important;
}

.input-group-text {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: var(--border) !important;
    color: var(--text-muted) !important;
}

.form-text {
    color: var(--text-muted) !important;
}

.alert-app {
    border-radius: 0.85rem;
    border: 1px solid transparent;
    backdrop-filter: blur(8px);
}

.alert-success-app {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.25);
    color: #a7f3d0;
}

.alert-danger-app {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.25);
    color: #fecaca;
}

.alert-warning-app {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.tag-masked {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.chapter-edit-area {
    width: 100%;
    min-height: 28rem;
    font-family: var(--font-body);
    font-size: 0.98rem;
    line-height: 1.7;
    color: var(--text);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 0.25rem);
    padding: 1rem 1.1rem;
    resize: vertical;
}

.badge-status {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
}

.badge-draft {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.badge-ready {
    background: rgba(52, 211, 153, 0.15);
    color: #6ee7b7;
}

.badge-error {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
}

.book-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.book-card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 0.35rem;
    color: var(--text);
}

.book-card-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.25rem;
    background: var(--purple-soft);
    color: var(--purple);
    font-size: 2rem;
}

.chapter-item {
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
}

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

.chapter-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.65rem;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 0.85rem;
    flex-shrink: 0;
}

.chapter-preview {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 0.25rem 0 0;
}

.chapter-text {
    display: block;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 6rem;
    overflow: hidden;
    line-height: 1.55;
}

.chapter-text.translated {
    color: #c4b5fd;
}

.chapter-actions {
    min-width: 9.5rem;
    flex-shrink: 0;
}

.tag-translated {
    color: var(--success);
    background: rgba(52, 211, 153, 0.1);
}

.chapter-full-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    color: var(--text);
    max-height: 70vh;
    overflow-y: auto;
}

.chapter-full-text.translated {
    color: #c4b5fd;
}

.tag-untranslated {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.upload-zone {
    border: 2px dashed rgba(168, 85, 247, 0.35);
    border-radius: 1rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: rgba(168, 85, 247, 0.04);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.06);
}

.upload-zone-icon {
    font-size: 2.5rem;
    color: var(--purple);
    margin-bottom: 0.75rem;
}

.hero-card {
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: "";
    position: absolute;
    top: -40%;
    right: -10%;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.12), transparent 70%);
    pointer-events: none;
}

.hero-stat {
    text-align: center;
    padding: 1rem;
}

.hero-stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent);
}

.hero-stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.88rem;
}

.meta-chip a {
    color: var(--accent);
    text-decoration: none;
}

.meta-chip a:hover {
    text-decoration: underline;
}

.navbar-toggler {
    border-color: var(--border) !important;
}

.navbar-toggler-icon {
    filter: invert(1) opacity(0.7);
}

.app-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.genre-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.genre-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.genre-check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    margin: 0;
}

.genre-check:has(input:checked) {
    background: var(--accent-soft);
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--accent);
}

.genre-check input {
    accent-color: var(--accent);
}

.genre-picker {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.genre-picker .form-select {
    flex: 1;
}

.genre-add-toggle {
    flex-shrink: 0;
    width: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.genre-add-panel .glass-card {
    border-color: rgba(168, 85, 247, 0.25);
    background: rgba(168, 85, 247, 0.04);
}

/* Form sections */
.form-card {
    max-width: 720px;
}

.form-section {
    padding-bottom: 1.75rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.form-section-title i {
    color: var(--accent);
}

/* Language options */
.lang-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.65rem;
}

.lang-option {
    display: block;
    margin: 0;
    cursor: pointer;
}

.lang-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.lang-option-body {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    height: 100%;
}

.lang-option-body strong {
    display: block;
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.lang-option-body small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.lang-option-flag {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
}

.lang-option:has(input:checked) .lang-option-body {
    border-color: rgba(245, 158, 11, 0.45);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.12);
}

.lang-option:has(input:checked) .lang-option-body strong {
    color: var(--accent);
}

.lang-option-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.lang-hint {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: #d8b4fe;
    font-size: 0.88rem;
}

/* Genre filter */
.genre-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.genre-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.genre-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.genre-chip.active {
    background: var(--accent-soft);
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--accent);
}

.genre-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--purple-soft);
    color: #d8b4fe;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

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

.book-card-wrap {
    min-width: 0;
}

/* Delete button */
.btn-danger-ghost {
    --bs-btn-color: var(--danger);
    --bs-btn-border-color: rgba(248, 113, 113, 0.35);
    --bs-btn-hover-bg: rgba(248, 113, 113, 0.12);
    --bs-btn-hover-border-color: rgba(248, 113, 113, 0.5);
    --bs-btn-hover-color: #fecaca;
    border-radius: 999px;
    font-weight: 500;
}

.chapter-item-manage {
    transition: background 0.2s;
}

.chapter-item-manage:hover {
    background: rgba(255, 255, 255, 0.02);
}

.workspace-label {
    color: var(--accent);
    letter-spacing: 0.1em;
    font-weight: 600;
    font-size: 0.72rem;
}

/* Reader */
.reader-main {
    max-width: 720px;
    margin: 0 auto;
}

.reader-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.reader-back {
    font-size: 0.9rem;
}

.reader-article {
    margin-bottom: 1.5rem;
}

.reader-book-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.reader-chapter-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    margin: 0 0 0.35rem;
    line-height: 1.2;
}

.reader-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.reader-content {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.85;
    font-size: 1.05rem;
    color: var(--text);
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
}

.reader-with-player {
    padding-bottom: 0.5rem;
}

body:has(.audio-player) .app-main {
    padding-bottom: calc(var(--player-height) + 1.25rem);
}

body:has(.audio-player.is-settings-open) .app-main {
    padding-bottom: calc(var(--player-height) + var(--player-settings-height) + 1.25rem);
}

body:has(.audio-player) .app-footer {
    margin-bottom: var(--player-height);
}

.reader-nav-btn {
    min-width: 7rem;
}

.reader-nav-spacer {
    min-width: 7rem;
}

.chapter-list-read {
    display: flex;
    flex-direction: column;
}

.chapter-read-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

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

.chapter-read-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chapter-read-preview {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.25rem;
}

.chapter-read-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
}

.chapter-read-row:last-child {
    border-bottom: none;
}

.chapter-read-row .chapter-read-item {
    border-bottom: none;
    flex: 1;
    min-width: 0;
}

.chapter-play-btn {
    flex-shrink: 0;
    align-self: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-right: 1rem;
    border: none;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, color 0.2s;
}

.chapter-play-btn:hover {
    background: rgba(245, 158, 11, 0.28);
    color: #fbbf24;
    transform: scale(1.05);
}

.listen-main {
    max-width: 860px;
    margin: 0 auto;
}

.listen-hero {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.listen-hero__art {
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--accent);
    background: linear-gradient(135deg, var(--purple-soft), var(--accent-soft));
    border: 1px solid var(--border);
}

.listen-hero__eyebrow {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.listen-chapter-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

/* Sticky audio player bar */
.audio-player {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    border-top: 1px solid var(--border);
    background: rgba(12, 8, 24, 0.96);
    backdrop-filter: blur(16px);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

.audio-player__inner {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    min-height: var(--player-height);
}

.audio-player__track {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.audio-player__art {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.65rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: var(--accent);
    background: linear-gradient(135deg, var(--purple-soft), var(--accent-soft));
    border: 1px solid var(--border);
}

.audio-player__meta {
    min-width: 0;
}

.audio-player__title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-player__chapter {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-player__center {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.audio-player__transport {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.audio-player__btn {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, transform 0.1s;
}

.audio-player__btn:hover:not(:disabled) {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.audio-player__btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.audio-player__btn--play {
    width: 2.65rem;
    height: 2.65rem;
    background: var(--accent);
    color: #1a1208;
    font-size: 1.15rem;
}

.audio-player__btn--play:hover:not(:disabled) {
    background: #fbbf24;
    color: #1a1208;
}

.audio-player.is-playing .audio-player__btn--play {
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.audio-player__timeline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-player__time {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    min-width: 2.5rem;
}

.audio-player__time:last-child {
    text-align: right;
}

.audio-player__seek {
    flex: 1;
    height: 0.35rem;
    appearance: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.audio-player__seek::-webkit-slider-thumb {
    appearance: none;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #1a1208;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.audio-player__seek::-moz-range-thumb {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #1a1208;
}

.audio-player__side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.audio-player__speed {
    width: 4.25rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 0.45rem;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
}

.audio-player__volume {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.audio-player__volume-range {
    width: 4.5rem;
    height: 0.3rem;
    appearance: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.audio-player__volume-range::-webkit-slider-thumb {
    appearance: none;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--text);
}

.audio-player__settings {
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.audio-player__settings[hidden] {
    display: none !important;
}

.audio-player__settings-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: end;
}

.audio-player__select {
    min-width: 10rem;
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--border);
    color: var(--text);
}

.audio-player__status {
    min-height: 1.25em;
}

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

@media (max-width: 992px) {
    .audio-player__inner {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.75rem 1rem 0.65rem;
    }

    .audio-player__track {
        order: 1;
    }

    .audio-player__center {
        order: 2;
    }

    .audio-player__side {
        order: 3;
        justify-content: center;
        flex-wrap: wrap;
    }

    .audio-player__volume-range {
        width: 5rem;
    }

    .audio-player__settings-grid {
        grid-template-columns: 1fr;
    }

    .listen-hero {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .audio-player__rewind,
    .audio-player__forward {
        display: none;
    }

    #audioRewindBtn,
    #audioForwardBtn {
        display: none;
    }
}

@media (min-width: 992px) {
    .app-main:has(.reader-main) {
        max-width: 800px;
    }
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-shell {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: 1.25rem;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-brand {
    padding: 3rem 2.5rem;
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.25), rgba(245, 158, 11, 0.08));
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    margin: 0 0 0.75rem;
}

.login-brand p {
    color: var(--text-muted);
    margin: 0;
    line-height: 1.7;
}

.login-form-panel {
    padding: 3rem 2.5rem;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
}

.sync-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(7, 5, 15, 0.72);
    backdrop-filter: blur(8px);
}

.sync-overlay.d-none {
    display: none !important;
}

.sync-overlay-card {
    width: min(420px, 100%);
    padding: 1.75rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: rgba(20, 16, 36, 0.95);
    box-shadow: var(--shadow);
    text-align: center;
}

.sync-spinner {
    width: 2.25rem;
    height: 2.25rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    border: 3px solid rgba(245, 158, 11, 0.2);
    border-top-color: var(--accent);
    animation: sync-spin 0.8s linear infinite;
}

@keyframes sync-spin {
    to {
        transform: rotate(360deg);
    }
}

.sync-overlay-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin: 0;
}

.sync-overlay-message {
    font-size: 0.95rem;
    min-height: 1.4em;
}

.sync-progress-track {
    height: 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.sync-progress-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #fbbf24);
    transition: width 0.25s ease;
}

.sync-overlay-count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.voice-player-sticky {
    position: sticky;
    top: 4.5rem;
    z-index: 20;
}

.voice-audio {
    width: min(360px, 100%);
    height: 2.5rem;
}

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

.voice-card.is-playing {
    border-color: rgba(245, 158, 11, 0.45);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

.voice-play-btn {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tts-panel {
    padding: 1rem 1.1rem;
    border-radius: calc(var(--radius) - 0.25rem);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.tts-select {
    min-width: 8.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--border);
    color: var(--text);
}

.tts-audio {
    max-width: 100%;
}

/* Premium Login Page & Brand Shell */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-shell {
    width: min(940px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    border-radius: 1.25rem;
    overflow: hidden;
    background: rgba(15, 12, 28, 0.75);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.6), 0 0 40px rgba(168, 85, 247, 0.15);
}

.login-brand {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(245, 158, 11, 0.08), rgba(12, 8, 24, 0.85));
    padding: 3.5rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-badge-wrapper {
    display: inline-block;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--purple), var(--accent));
    color: #ffffff;
    font-size: 1.6rem;
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.45);
}

.brand-title {
    font-family: var(--font-display);
    font-size: 2.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #ffffff 30%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.brand-description {
    color: #e2d9f3;
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 1.5rem;
}

.brand-feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #f4f0ff;
    font-size: 0.9rem;
    font-weight: 500;
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.bg-success-soft { background: rgba(52, 211, 153, 0.15); }
.bg-warning-soft { background: rgba(245, 158, 11, 0.15); }
.bg-info-soft { background: rgba(56, 189, 248, 0.15); }

.login-form-panel {
    padding: 3.5rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(10, 7, 20, 0.4);
}

/* Alert Styling Fixes */
.alert-app {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.88rem;
    font-weight: 500;
}

.alert-danger-app {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #fca5a5;
}

.alert-success-app {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}

/* Form Controls */
.login-form-panel .form-label {
    color: #e2d9f3;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}

.login-form-panel .form-control {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    padding: 0.65rem 0.9rem;
    font-size: 0.925rem;
}

.login-form-panel .form-control::placeholder {
    color: rgba(255, 255, 255, 0.35) !important;
}

.login-form-panel .form-control:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--purple) !important;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25) !important;
}

.login-form-panel .input-group-text {
    border-color: rgba(255, 255, 255, 0.12) !important;
}

@media (max-width: 768px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand {
        padding: 2.5rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .login-form-panel {
        padding: 2.5rem 1.5rem;
    }
}

/* Auth Tabs & Social Buttons */
.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.auth-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.auth-tab-btn.active {
    background: linear-gradient(135deg, var(--purple), #8b5cf6);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
}

.social-login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.social-login-divider::before,
.social-login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.social-login-divider span {
    padding: 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.social-btn-group {
    display: flex;
    gap: 0.75rem;
}

.btn-social {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-social:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: translateY(-1px);
}

.btn-social.google:hover {
    box-shadow: 0 4px 14px rgba(234, 67, 53, 0.25);
}

.btn-social.facebook:hover {
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.25);
}

.password-toggle-icon {
    cursor: pointer;
    user-select: none;
}

.password-strength-meter {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 0.4rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-bar.weak { width: 33%; background-color: var(--danger); }
.password-strength-bar.medium { width: 66%; background-color: var(--accent); }
.password-strength-bar.strong { width: 100%; background-color: var(--success); }

/* Dashboard UI Styles (Admin & User) */
.border-purple-glow {
    border-color: rgba(168, 85, 247, 0.35) !important;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.15) !important;
}

.stat-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    font-size: 1.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: #ffffff;
    line-height: 1.1;
}

.custom-admin-table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
}

.admin-book-thumb,
.admin-book-thumb-placeholder {
    width: 42px;
    height: 56px;
    object-fit: cover;
    border-radius: 0.4rem;
    border: 1px solid var(--border);
}

.admin-book-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* User Dashboard Styles */
.hero-user-card {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(245, 158, 11, 0.1), rgba(12, 8, 24, 0.85));
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-user-card p {
    color: #e2d9f3 !important;
}

.user-badge-box {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
}

.user-badge-box .text-muted {
    color: #cbd5e1 !important;
}

.user-avatar-large {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.4);
}

.featured-story-card {
    background: rgba(20, 16, 38, 0.65);
    border: 1px solid rgba(245, 158, 11, 0.25);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.featured-book-cover,
.featured-book-cover-placeholder {
    width: 180px;
    height: 250px;
    object-fit: cover;
    margin: 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.featured-book-cover-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
    font-size: 3.5rem;
}

.user-book-thumb,
.user-book-thumb-placeholder {
    width: 60px;
    height: 80px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.user-book-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 1.5rem;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Immersive Highlight Styles */
.reader-p {
    margin-bottom: 1.25rem;
    transition: background-color 0.3s ease, opacity 0.3s ease, border-left 0.3s ease, padding-left 0.3s ease;
    border-left: 4px solid transparent;
    padding-left: 0;
}

.reader-content.is-reading .reader-p {
    opacity: 0.45;
}

.reader-content.is-reading .reader-p.is-active {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--accent);
    padding-left: 12px;
    border-radius: 0 4px 4px 0;
}



