:root {
    --deep-navy: #06090f;
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-strong: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-muted: #8e94a0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Quicksand', sans-serif;
}

html,
body {
    min-height: 100%;
}

body {
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: white;
    overflow: hidden;
}

button,
.nav-item,
.main-play-btn,
.episode-tile,
.library-lesson-card i {
    -webkit-tap-highlight-color: transparent;
}

/* Mobile portrait mặc định: giữ layout app 9:16 như bản cũ */
.app-container {
    width: 375px;
    height: 812px;
    background: radial-gradient(circle at 0% 0%, #1a2a44 0%, var(--deep-navy) 70%);
    border-radius: 45px;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.8);
}

.app-container::before {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: var(--gold-glow);
    filter: blur(80px);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.app-container::after {
    content: '';
    position: absolute;
    left: -140px;
    bottom: 20%;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: rgba(30, 70, 120, 0.25);
    filter: blur(80px);
    pointer-events: none;
}

/* Navigation Pages */
.page {
    position: absolute;
    width: 100%;
    height: calc(100% - 80px);
    padding: 25px;
    display: none;
    flex-direction: column;
    z-index: 1;
    overflow: hidden;
}

.page.active {
    display: flex;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth Waveform */
.visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100px;
    margin: 40px 0;
}

.bar {
    width: 3px;
    height: 10px;
    background: linear-gradient(to top, var(--gold), #fff);
    border-radius: 5px;
    animation: bounce 1.2s ease-in-out infinite;
}

@keyframes bounce {
    0%,
    100% {
        height: 10px;
    }

    50% {
        height: 60px;
    }
}

.bar:nth-child(2n) {
    animation-delay: 0.2s;
}

.bar:nth-child(3n) {
    animation-delay: 0.4s;
}

.bar:nth-child(4n) {
    animation-delay: 0.1s;
}

.greeting {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.premium-badge {
    color: var(--gold);
    font-size: 0.7rem;
    border: 1px solid var(--gold);
    padding: 2px 8px;
    border-radius: 10px;
    width: fit-content;
    margin-bottom: 30px;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 15px;
    margin-bottom: 20px;
}

.topic-card h3 {
    margin: 5px 0;
}

.eyebrow {
    color: var(--gold);
    font-size: 0.75rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.muted-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.section-title {
    font-weight: 600;
    margin-bottom: 15px;
}

.home-layout,
.library-layout,
.player-shell {
    min-height: 0;
}

.recent-lessons {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none;
}

.recent-lessons::-webkit-scrollbar,
.library-lessons::-webkit-scrollbar,
.transcript-box::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.episode-tile {
    min-width: 140px;
    height: 180px;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.25s ease, opacity 0.25s ease, box-shadow 0.25s ease;
}

.episode-tile span {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.35;
}

.episode-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 35px rgba(0, 0, 0, 0.28);
}

/* Controls */
.main-play-btn {
    width: 70px;
    height: 70px;
    background: var(--gold);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: var(--deep-navy);
    box-shadow: 0 10px 30px var(--gold-glow);
    margin: 20px auto;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.main-play-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 14px 45px var(--gold-glow);
}

.player-header {
    text-align: center;
}

.player-header h3 {
    margin-top: 5px;
}

.player-controls {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    color: var(--gold);
    padding: 0 40px;
}

.player-controls i {
    cursor: pointer;
}

.transcript-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 25px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid var(--glass-border);
    min-height: 0;
    overflow-y: auto;
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.transcript-header span {
    font-size: 0.7rem;
    color: var(--gold);
    letter-spacing: 1.4px;
}

#transcript-en {
    line-height: 1.6;
    font-size: 0.95rem;
}

#transcript-vn {
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--glass-border);
    padding-top: 10px;
    line-height: 1.55;
}

.highlight-word {
    color: var(--gold);
    border-bottom: 1px dashed var(--gold);
    cursor: pointer;
}

.stat-card,
.library-lesson-card {
    display: flex;
    align-items: center;
    gap: 15px;
}

.library-lessons {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 2px;
}

.library-lesson-card {
    margin-bottom: 10px;
}

/* Bottom Menu */
.bottom-nav {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80px;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    z-index: 10;
}

.nav-item {
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    font-size: 1.2rem;
}

.nav-item.active,
.nav-item:hover {
    color: var(--gold);
}

.nav-item span {
    display: block;
    font-size: 0.6rem;
    margin-top: 4px;
}

/* Màn hình rất nhỏ: vẫn giữ phong cách mobile nhưng không bị tràn */
@media (max-width: 430px) {
    body {
        align-items: stretch;
    }

    .app-container {
        width: 100vw;
        height: 100dvh;
        min-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .page {
        padding: 22px;
    }
}

/* iPad nằm ngang và Desktop: chuyển UI sang khung rộng */
@media (min-width: 900px), (orientation: landscape) and (min-width: 768px) {
    body {
        padding: 24px;
        background:
            radial-gradient(circle at 12% 15%, rgba(32, 54, 88, 0.9), transparent 34%),
            radial-gradient(circle at 88% 12%, rgba(212, 175, 55, 0.22), transparent 30%),
            #000;
    }

    .app-container {
        width: min(1180px, 96vw);
        height: min(760px, 92vh);
        min-height: 620px;
        border-radius: 34px;
        display: grid;
        grid-template-columns: 112px 1fr;
        overflow: hidden;
    }

    .app-container::before {
        width: 420px;
        height: 420px;
        top: -170px;
        right: -120px;
        filter: blur(110px);
    }

    .page {
        left: 112px;
        top: 0;
        width: calc(100% - 112px);
        height: 100%;
        padding: 38px 42px;
        overflow: hidden;
    }

    .bottom-nav {
        left: 0;
        top: 0;
        bottom: auto;
        width: 112px;
        height: 100%;
        flex-direction: column;
        justify-content: center;
        gap: 28px;
        border-top: none;
        border-right: 1px solid var(--glass-border);
        background: rgba(10, 14, 23, 0.72);
    }

    .nav-item {
        width: 76px;
        height: 76px;
        border-radius: 24px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 1.35rem;
    }

    .nav-item.active {
        background: rgba(212, 175, 55, 0.12);
        box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.22);
    }

    .nav-item span {
        font-size: 0.64rem;
        line-height: 1.2;
    }

    .greeting {
        font-size: clamp(1.9rem, 3vw, 2.8rem);
        margin-bottom: 8px;
    }

    .premium-badge {
        margin-bottom: 26px;
        padding: 5px 12px;
        letter-spacing: 1.6px;
    }

    .card {
        border-radius: 26px;
        padding: 22px;
        margin-bottom: 0;
        background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
    }

    .page-home,
    .page-library {
        overflow-y: auto;
    }

    .home-layout {
        display: grid;
        grid-template-columns: minmax(320px, 0.95fr) minmax(440px, 1.45fr);
        gap: 24px;
        align-items: stretch;
        flex: 1;
        min-height: 0;
    }

    .home-main,
    .home-recent {
        min-width: 0;
    }

    .topic-card {
        height: 100%;
        min-height: 320px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        position: relative;
        overflow: hidden;
    }

    .topic-card::before {
        content: '';
        position: absolute;
        inset: auto -80px -120px auto;
        width: 260px;
        height: 260px;
        border-radius: 50%;
        background: rgba(212, 175, 55, 0.16);
        filter: blur(40px);
    }

    .topic-card > * {
        position: relative;
        z-index: 1;
    }

    .topic-card h3 {
        font-size: clamp(1.65rem, 2.6vw, 2.65rem);
        line-height: 1.08;
        margin: 10px 0 14px;
    }

    .muted-text {
        font-size: 1rem;
        max-width: 560px;
    }

    .section-title {
        font-size: 1.05rem;
        margin-bottom: 18px;
    }

    .recent-lessons {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 18px;
        overflow: visible;
        padding-bottom: 0;
        height: calc(100% - 42px);
    }

    .episode-tile {
        min-width: 0;
        width: 100%;
        height: 100%;
        min-height: 320px;
        border-radius: 26px;
        padding: 22px;
    }

    .episode-tile span {
        font-size: 1.02rem;
    }

    .player-shell {
        display: grid;
        grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
        gap: 26px;
        height: 100%;
        min-height: 0;
    }

    .player-panel,
    .transcript-panel {
        min-width: 0;
        min-height: 0;
    }

    .player-panel {
        background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
        border: 1px solid var(--glass-border);
        border-radius: 30px;
        padding: 32px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .player-header h3 {
        font-size: clamp(1.4rem, 2.2vw, 2.25rem);
        line-height: 1.16;
        max-width: 620px;
        margin-left: auto;
        margin-right: auto;
    }

    .visualizer {
        height: clamp(150px, 23vh, 220px);
        gap: 7px;
        margin: 46px 0 28px;
    }

    .bar {
        width: 6px;
        border-radius: 999px;
    }

    @keyframes bounce {
        0%,
        100% {
            height: 18px;
        }

        50% {
            height: 120px;
        }
    }

    .main-play-btn {
        width: 92px;
        height: 92px;
        font-size: 2rem;
        margin: 18px auto 28px;
    }

    .player-controls {
        max-width: 360px;
        width: 100%;
        margin: 0 auto;
        padding: 0;
        font-size: 1.35rem;
    }

    .transcript-box {
        height: 100%;
        margin-top: 0;
        padding: 34px;
        border-radius: 30px;
        display: flex;
        flex-direction: column;
    }

    .transcript-header {
        margin-bottom: 24px;
    }

    .transcript-header span {
        font-size: 0.8rem;
    }

    #transcript-en {
        font-size: clamp(1.15rem, 1.7vw, 1.55rem);
        line-height: 1.72;
    }

    #transcript-vn {
        margin-top: 24px;
        padding-top: 22px;
        font-size: 1rem;
        line-height: 1.65;
    }

    .library-layout {
        display: grid;
        grid-template-columns: minmax(260px, 0.65fr) minmax(520px, 1.35fr);
        gap: 24px;
        flex: 1;
        min-height: 0;
    }

    .library-stats {
        display: grid;
        gap: 18px;
        align-content: start;
    }

    .stat-card {
        min-height: 120px;
        margin-bottom: 0;
        border-radius: 26px;
    }

    .stat-card i {
        font-size: 1.45rem;
    }

    .library-list-wrap {
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .library-lessons {
        max-height: none;
        height: 100%;
        overflow-y: auto;
        padding-right: 8px;
        display: grid;
        gap: 12px;
        align-content: start;
    }

    .library-lesson-card {
        min-height: 86px;
        margin-bottom: 0;
        border-radius: 24px;
        transition: transform 0.25s ease, background 0.25s ease;
    }

    .library-lesson-card:hover {
        transform: translateX(4px);
        background: var(--glass-strong);
    }
}

/* Desktop lớn: tận dụng thêm chiều rộng */
@media (min-width: 1280px) {
    .app-container {
        width: min(1320px, 94vw);
        height: min(820px, 90vh);
        grid-template-columns: 124px 1fr;
    }

    .page {
        left: 124px;
        width: calc(100% - 124px);
        padding: 46px 52px;
    }

    .bottom-nav {
        width: 124px;
    }

    .home-layout,
    .player-shell,
    .library-layout {
        gap: 32px;
    }
}

/* iPad ngang thấp chiều cao: giảm padding để không tràn */
@media (orientation: landscape) and (max-height: 700px) and (min-width: 768px) {
    body {
        padding: 14px;
    }

    .app-container {
        height: 96vh;
        min-height: 540px;
    }

    .page {
        padding: 26px 30px;
    }

    .visualizer {
        margin: 24px 0 14px;
        height: 130px;
    }

    .main-play-btn {
        width: 78px;
        height: 78px;
        margin: 12px auto 18px;
    }

    .episode-tile,
    .topic-card {
        min-height: 250px;
    }
}


/* Episode cover thumbnails */
.episode-tile {
    position: relative;
    overflow: hidden;
    background-size: cover !important;
    background-position: center !important;
}

.episode-tile::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 10%, rgba(212, 175, 55, 0.18), transparent 42%);
    pointer-events: none;
}

.episode-tile span,
.episode-tile small {
    position: relative;
    z-index: 1;
}

.episode-tile small {
    display: block;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.68rem;
}

.lesson-thumb {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    border-radius: 18px;
    overflow: hidden;
    display: grid;
    place-items: center;
    color: var(--gold);
    background: linear-gradient(145deg, rgba(212,175,55,0.16), rgba(255,255,255,0.06));
    border: 1px solid var(--glass-border);
}

.lesson-thumb img,
.player-cover img,
.admin-thumb img,
.cover-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.player-cover {
    width: 132px;
    height: 132px;
    margin: 22px auto 0;
    border-radius: 34px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid rgba(212,175,55,0.32);
    background: linear-gradient(145deg, rgba(212,175,55,0.20), rgba(255,255,255,0.06));
    box-shadow: 0 22px 70px rgba(0,0,0,0.38), 0 0 36px rgba(212,175,55,0.14);
}

.player-cover-fallback {
    font-size: 2.2rem;
    color: var(--gold);
}

@media (min-width: 768px) and (orientation: landscape), (min-width: 1024px) {
    .player-cover {
        width: 180px;
        height: 180px;
        border-radius: 42px;
    }

    .lesson-thumb {
        width: 68px;
        height: 68px;
        flex-basis: 68px;
        border-radius: 22px;
    }
}

/* Admin premium UI */
.admin-body,
.admin-login-body {
    min-height: 100vh;
    height: auto;
    color: #fff;
    background:
        radial-gradient(circle at 8% 0%, rgba(26,42,68,0.92), transparent 36%),
        radial-gradient(circle at 100% 12%, rgba(212,175,55,0.22), transparent 34%),
        #000;
    padding: 28px;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
    justify-content: flex-start;
}

.admin-shell {
    width: min(1320px, 100%);
    margin: 0 auto;
}

.admin-header {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    backdrop-filter: blur(18px);
    box-shadow: 0 30px 90px rgba(0,0,0,0.38);
}

.admin-header h1 {
    font-size: clamp(1.35rem, 2.3vw, 2.2rem);
    margin-bottom: 6px;
}

.admin-header p,
.admin-muted {
    color: var(--text-muted);
}

.admin-nav {
    margin: 18px 0 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-nav a,
.admin-btn,
.admin-pagination a,
.admin-pagination span {
    color: #fff;
    text-decoration: none;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.07);
    border-radius: 999px;
    padding: 10px 16px;
    cursor: pointer;
    transition: 0.25s ease;
    font-weight: 700;
    font-family: 'Quicksand', sans-serif;
}

.admin-nav a:hover,
.admin-nav a.active,
.admin-btn:hover,
.admin-pagination .current {
    color: var(--deep-navy);
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 12px 34px var(--gold-glow);
}

.admin-card,
.login-box {
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(18px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.42);
    overflow: hidden;
}

.admin-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    font-weight: 800;
}

.admin-card-body {
    padding: 24px;
}

.admin-grid-2,
.admin-grid-3 {
    display: grid;
    gap: 18px;
}

.admin-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.admin-form {
    padding-bottom: 92px;
}

.admin-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 22px -24px -24px;
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(6, 9, 15, 0.86);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
}

.admin-form-actions .admin-btn {
    min-width: 170px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.84);
    font-weight: 800;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select,
.admin-search input {
    width: 100%;
    padding: 12px 14px;
    color: #fff;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.28);
    outline: none;
    font-family: 'Quicksand', sans-serif;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.admin-search input:focus {
    border-color: rgba(212,175,55,0.62);
    box-shadow: 0 0 0 4px rgba(212,175,55,0.12);
}

.form-group textarea {
    min-height: 110px;
    resize: vertical;
}

textarea.large-textarea {
    min-height: 220px;
}

.admin-message {
    padding: 13px 16px;
    margin-bottom: 18px;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
}

.admin-message.success {
    color: #dcfce7;
    background: rgba(34,197,94,0.12);
    border-color: rgba(34,197,94,0.28);
}

.admin-message.error {
    color: #fee2e2;
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.28);
}

.admin-search {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.admin-search input {
    max-width: 420px;
}

.admin-table-wrap {
    overflow-x: auto;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
}

.admin-table {
    width: 100%;
    min-width: 940px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    color: var(--gold);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(0,0,0,0.18);
}

.admin-table tr:hover {
    background: rgba(255,255,255,0.045);
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-btn.primary,
.admin-btn.success { background: var(--gold); color: var(--deep-navy); border-color: var(--gold); }
.admin-btn.danger { background: rgba(239,68,68,0.16); border-color: rgba(239,68,68,0.32); color: #fecaca; }
.admin-btn.warning { background: rgba(245,158,11,0.16); border-color: rgba(245,158,11,0.32); color: #fde68a; }
.admin-btn.small { padding: 7px 11px; font-size: 0.78rem; }

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}
.status-pill.ok { color: #dcfce7; background: rgba(34,197,94,0.14); }
.status-pill.warn { color: #fde68a; background: rgba(245,158,11,0.15); }

.admin-thumb,
.cover-preview {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid var(--glass-border);
    background: linear-gradient(145deg, rgba(212,175,55,0.18), rgba(255,255,255,0.06));
    color: var(--gold);
}

.cover-field {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 16px;
    align-items: start;
}

.admin-pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-login-body {
    display: grid;
    place-items: center;
}

.login-box {
    width: min(420px, 94vw);
    padding: 34px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 22px;
    color: #fff;
}

@media (max-width: 760px) {
    .admin-body,
    .admin-login-body {
        padding: 14px;
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
        border-radius: 24px;
    }

    .admin-grid-2,
    .admin-grid-3,
    .cover-field {
        grid-template-columns: 1fr;
    }

    .admin-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-form {
        padding-bottom: 96px;
    }

    .admin-form-actions {
        margin-left: -24px;
        margin-right: -24px;
        padding: 14px 18px;
        justify-content: stretch;
    }

    .admin-form-actions .admin-btn {
        width: 100%;
        min-width: 0;
    }

}

/* TinyMCE editor inside admin form */
.admin-body .tox-tinymce {
    border: 1px solid var(--glass-border) !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    box-shadow: 0 20px 45px rgba(0,0,0,.28) !important;
}

.admin-body .tox .tox-toolbar,
.admin-body .tox .tox-toolbar__overflow,
.admin-body .tox .tox-toolbar__primary,
.admin-body .tox .tox-menubar,
.admin-body .tox .tox-statusbar {
    background: rgba(10,14,23,.96) !important;
}

.admin-body .tox .tox-tbtn,
.admin-body .tox .tox-mbtn,
.admin-body .tox .tox-statusbar__path-item,
.admin-body .tox .tox-statusbar__wordcount {
    color: rgba(255,255,255,.82) !important;
}

.admin-body .tox .tox-tbtn:hover,
.admin-body .tox .tox-mbtn:hover,
.admin-body .tox .tox-tbtn--enabled {
    background: rgba(212,175,55,.16) !important;
}

@media (max-width: 760px) {
    .admin-body .tox-tinymce {
        min-height: 420px;
    }
}

/* Admin configuration pages */
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    background: rgba(0,0,0,.18);
}

.settings-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 800;
    transition: .25s ease;
}

.settings-tabs a:hover,
.settings-tabs a.active {
    color: var(--deep-navy);
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 12px 34px var(--gold-glow);
}

.settings-form {
    padding-bottom: 86px;
}

.align-start {
    align-items: start;
}

.sub-panel {
    background: rgba(255,255,255,.045);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    min-width: 0;
}

.sub-panel h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    color: #fff;
}

.user-edit-card {
    background: rgba(0,0,0,.22);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 14px;
}

.admin-grid-2.compact {
    gap: 12px;
}

.admin-grid-2.compact .form-group {
    margin-bottom: 8px;
}

.admin-body input:disabled {
    color: rgba(255,255,255,.55);
    background: rgba(255,255,255,.04);
    cursor: not-allowed;
}

.admin-actions form {
    display: inline-flex;
}

@media (max-width: 760px) {
    .settings-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }

    .settings-tabs a {
        justify-content: center;
    }

    .sub-panel {
        padding: 16px;
    }
}


/* ===== Updates: Home cover + fixed player info scroll + perfectly round play button ===== */

/* Home topic cover */
.topic-card {
    overflow: hidden;
}

.topic-cover {
    width: calc(100% + 30px);
    height: 168px;
    margin: -15px -15px 16px;
    border-radius: 20px 20px 18px 18px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 25% 10%, rgba(212, 175, 55, 0.22), transparent 38%),
        linear-gradient(145deg, rgba(212, 175, 55, 0.16), rgba(255, 255, 255, 0.055));
    border-bottom: 1px solid var(--glass-border);
}

.topic-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.topic-cover-fallback {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    color: var(--gold);
    font-size: 2rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid rgba(212, 175, 55, 0.24);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.topic-content {
    position: relative;
    z-index: 1;
}

/* Player mobile: keep the player header/audio stable and scroll only the main content */
.page-player {
    overflow: hidden;
}

.page-player .player-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.page-player .player-panel {
    flex: 0 0 auto;
    min-height: 0;
}

.page-player .transcript-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.transcript-box {
    width: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.transcript-fixed-top {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 3;
    background: linear-gradient(180deg, rgba(6, 9, 15, 0.96), rgba(6, 9, 15, 0.82));
    backdrop-filter: blur(16px);
    margin: -20px -20px 0;
    padding: 20px 20px 14px;
    border-bottom: 1px solid var(--glass-border);
    border-radius: 25px 25px 0 0;
}

.transcript-fixed-top .transcript-header {
    margin-bottom: 10px;
}

.transcript-fixed-top h2,
#transcript-en {
    color: #fff;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.transcript-content,
#transcript-vn.transcript-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin-top: 0;
    padding-top: 16px;
    padding-right: 4px;
    border-top: 0;
    color: rgba(255, 255, 255, 0.78);
}

/* Render rich HTML from TinyMCE cleanly */
.transcript-content p,
.transcript-content ul,
.transcript-content ol,
.transcript-content blockquote,
.transcript-content table,
.transcript-content h1,
.transcript-content h2,
.transcript-content h3,
.transcript-content h4 {
    margin-bottom: 12px;
}

.transcript-content p {
    line-height: 1.72;
}

.transcript-content h1,
.transcript-content h2,
.transcript-content h3,
.transcript-content h4 {
    color: #fff;
    line-height: 1.25;
}

.transcript-content ul,
.transcript-content ol {
    padding-left: 22px;
}

.transcript-content li {
    margin-bottom: 7px;
    line-height: 1.65;
}

.transcript-content a {
    color: var(--gold);
    text-decoration: none;
    border-bottom: 1px dashed rgba(212, 175, 55, 0.55);
}

.transcript-content img {
    max-width: 100%;
    height: auto;
    border-radius: 18px;
    margin: 10px 0;
    border: 1px solid var(--glass-border);
}

.transcript-content table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.transcript-content th,
.transcript-content td {
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    text-align: left;
}

.transcript-content th {
    color: var(--gold);
    background: rgba(255,255,255,0.06);
}

.transcript-content blockquote {
    padding: 12px 14px;
    border-left: 3px solid var(--gold);
    background: rgba(255,255,255,0.045);
    border-radius: 14px;
}

/* Keep Play/Pause perfectly round in all layouts */
.main-play-btn {
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
    max-width: 70px;
    max-height: 70px;
    aspect-ratio: 1 / 1;
    flex: 0 0 70px;
    padding: 0;
    border: 0;
    line-height: 1;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
}

.main-play-btn i {
    display: block;
    line-height: 1;
}

/* Make the player fit better on small mobile screens while keeping content scrollable */
@media (max-width: 430px) {
    .player-cover {
        width: 104px;
        height: 104px;
        border-radius: 28px;
        margin-top: 14px;
    }

    .visualizer {
        height: 74px;
        margin: 18px 0 10px;
    }

    .main-play-btn {
        width: 64px;
        height: 64px;
        min-width: 64px;
        min-height: 64px;
        max-width: 64px;
        max-height: 64px;
        flex-basis: 64px;
        margin: 12px auto 14px;
    }

    .player-controls {
        padding: 0 34px;
    }

    .transcript-box {
        margin-top: 14px;
    }

    .transcript-fixed-top {
        margin: -20px -20px 0;
        padding: 18px 20px 12px;
    }

    .transcript-content,
    #transcript-vn.transcript-content {
        font-size: 0.88rem;
    }
}

/* Wide layout refinements */
@media (min-width: 900px), (orientation: landscape) and (min-width: 768px) {
    .topic-card {
        justify-content: flex-start;
    }

    .topic-cover {
        width: calc(100% + 44px);
        height: clamp(210px, 36vh, 330px);
        margin: -22px -22px 22px;
        border-radius: 26px 26px 22px 22px;
    }

    .topic-cover-fallback {
        width: 96px;
        height: 96px;
        border-radius: 30px;
        font-size: 2.6rem;
    }

    .topic-content {
        margin-top: auto;
    }

    .page-player .player-shell {
        display: grid;
    }

    .page-player .transcript-panel {
        min-height: 0;
        display: flex;
    }

    .transcript-fixed-top {
        margin: -34px -34px 0;
        padding: 32px 34px 20px;
        border-radius: 30px 30px 0 0;
    }

    .transcript-content,
    #transcript-vn.transcript-content {
        padding-top: 24px;
        padding-right: 10px;
        font-size: 1rem;
        line-height: 1.72;
    }

    .main-play-btn {
        width: 92px;
        height: 92px;
        min-width: 92px;
        min-height: 92px;
        max-width: 92px;
        max-height: 92px;
        flex-basis: 92px;
    }
}

@media (orientation: landscape) and (max-height: 700px) and (min-width: 768px) {
    .topic-cover {
        height: 150px;
    }

    .player-cover {
        width: 116px;
        height: 116px;
        border-radius: 30px;
        margin-top: 14px;
    }

    .main-play-btn {
        width: 78px;
        height: 78px;
        min-width: 78px;
        min-height: 78px;
        max-width: 78px;
        max-height: 78px;
        flex-basis: 78px;
    }

    .transcript-fixed-top {
        padding-top: 24px;
        padding-bottom: 16px;
    }
}

/* Mobile: hide cover image in Player tab to give more room for lesson content */
@media (max-width: 767px), (orientation: portrait) and (max-width: 899px) {
    .page-player .player-cover,
    #player .player-cover {
        display: none !important;
    }

    .page-player .visualizer,
    #player .visualizer {
        margin-top: 18px;
        margin-bottom: 8px;
    }

    .page-player .transcript-box,
    #player .transcript-box {
        margin-top: 12px;
    }
}

/* Player Prev / Next controls */
.player-control-btn {
    width: 38px;
    height: 38px;
    aspect-ratio: 1 / 1;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 999px;
    color: var(--gold);
    background: rgba(255, 255, 255, 0.045);
    cursor: pointer;
    transition: transform .22s ease, background .22s ease, opacity .22s ease, border-color .22s ease;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.player-control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.45);
}

.player-control-btn:disabled,
.player-control-btn.is-disabled {
    opacity: .28;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(1);
}

.player-control-btn i {
    pointer-events: none;
}

@media (min-width: 900px), (orientation: landscape) and (min-width: 768px) {
    .player-control-btn {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
        font-size: 1.15rem;
    }
}


/* ===== Fix: restore Home topic cover + full-screen Admin layout ===== */
.topic-card.has-cover .topic-cover {
    background: rgba(0, 0, 0, 0.22);
}

.topic-card .topic-cover {
    flex: 0 0 auto;
}

.topic-card .topic-content {
    width: 100%;
}

.admin-body.admin-fullscreen,
.admin-body {
    width: 100%;
}

.admin-fullscreen .admin-shell,
.admin-body .admin-shell {
    width: 100%;
    max-width: none;
    margin: 0;
}

.admin-fullscreen .admin-card,
.admin-body .admin-card {
    width: 100%;
}

.admin-fullscreen .admin-card-body,
.admin-body .admin-card-body {
    width: 100%;
}

.admin-fullscreen .admin-table-wrap,
.admin-body .admin-table-wrap {
    width: 100%;
}

.admin-fullscreen .admin-table,
.admin-body .admin-table {
    min-width: 1120px;
}

@media (min-width: 1200px) {
    .admin-body,
    .admin-login-body {
        padding-left: 32px;
        padding-right: 32px;
    }

    .admin-fullscreen .admin-card-body,
    .admin-body .admin-card-body {
        padding: 28px 32px;
    }
}

@media (max-width: 430px) {
    .topic-cover {
        height: 148px;
    }
}

/* ===== Fix scroll for Tab Dang phat / Dang nghe main content ===== */
#player.page-player,
#player.page-player.active {
    overflow: hidden !important;
}

#player .player-shell,
#player .transcript-panel,
#player .transcript-box {
    min-height: 0 !important;
}

#player .transcript-panel {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#player .transcript-box {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100% !important;
    max-height: 100% !important;
}

/* Keep header + episode title fixed at top */
#player .transcript-header,
#player #transcript-en {
    flex: 0 0 auto !important;
}

#player .transcript-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: linear-gradient(180deg, rgba(6, 9, 15, 0.98), rgba(6, 9, 15, 0.88));
    backdrop-filter: blur(16px);
    margin: -20px -20px 0;
    padding: 20px 20px 12px;
    border-radius: 25px 25px 0 0;
    border-bottom: 1px solid var(--glass-border);
}

#player #transcript-en {
    position: relative;
    z-index: 4;
    margin: 0 -20px;
    padding: 14px 20px 12px;
    background: rgba(6, 9, 15, 0.72);
    border-bottom: 1px solid var(--glass-border);
}

/* Scroll only lesson main content */
#player #transcript-vn,
#player .episode-main-content,
#player .main-content-html {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 4px 28px 0 !important;
    margin-top: 0 !important;
    border-top: 0 !important;
}

#player #transcript-vn::-webkit-scrollbar,
#player .episode-main-content::-webkit-scrollbar,
#player .main-content-html::-webkit-scrollbar {
    width: 6px;
}

#player #transcript-vn::-webkit-scrollbar-thumb,
#player .episode-main-content::-webkit-scrollbar-thumb,
#player .main-content-html::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.35);
    border-radius: 999px;
}

@media (max-width: 767px), (orientation: portrait) and (max-width: 899px) {
    #player .player-shell {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    #player .player-panel {
        flex: 0 0 auto !important;
        min-height: 0 !important;
    }

    #player .transcript-panel {
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }

    #player .transcript-box {
        flex: 1 1 auto !important;
        margin-top: 12px !important;
    }
}

@media (min-width: 900px), (orientation: landscape) and (min-width: 768px) {
    #player .player-shell {
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    #player .transcript-box {
        height: 100% !important;
    }

    #player .transcript-header {
        margin: -34px -34px 0;
        padding: 32px 34px 18px;
        border-radius: 30px 30px 0 0;
    }

    #player #transcript-en {
        margin: 0 -35px;
        padding: 35px 5px 5px;
    }

    #player #transcript-vn,
    #player .episode-main-content,
    #player .main-content-html {
        padding: 24px 10px 34px 0 !important;
    }
}

/* Audio timeline in player tab */
.audio-timeline {
    width: 100%;
    max-width: 360px;
    margin: 4px auto 18px;
}

.audio-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.audio-progress {
    --progress-percent: 0%;
    width: 100%;
    height: 8px;
    display: block;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold) var(--progress-percent), rgba(255,255,255,.13) var(--progress-percent), rgba(255,255,255,.13) 100%);
}

.audio-progress:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.audio-progress::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: transparent;
}

.audio-progress::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -5px;
    border-radius: 50%;
    border: 3px solid var(--deep-navy);
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(212,175,55,.18), 0 8px 20px rgba(0,0,0,.32);
}

.audio-progress::-moz-range-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.13);
}

.audio-progress::-moz-range-progress {
    height: 8px;
    border-radius: 999px;
    background: var(--gold);
}

.audio-progress::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid var(--deep-navy);
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(212,175,55,.18), 0 8px 20px rgba(0,0,0,.32);
}

@media (max-width: 430px) {
    .audio-timeline {
        margin: 0 auto 14px;
    }

    .audio-time-row {
        font-size: 0.72rem;
    }
}

/* Library saved sentences + downloads */
.library-filter-card {
    width: 100%;
    border: 1px solid var(--glass-border);
    color: #fff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.library-filter-card:hover,
.library-filter-card.active {
    transform: translateY(-2px);
    border-color: rgba(212, 175, 55, 0.45);
    background: rgba(212, 175, 55, 0.10);
}

.library-panel {
    display: none;
    min-height: 0;
}

.library-panel.active {
    display: block;
}

.library-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.library-panel-head small {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.transcript-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -8px 0 14px;
}

.mini-action-btn {
    border: 1px solid rgba(212, 175, 55, 0.28);
    border-radius: 999px;
    padding: 8px 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.mini-action-btn:hover {
    transform: translateY(-1px);
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.55);
}

.mini-action-btn.danger {
    border-color: rgba(255, 99, 99, 0.25);
    color: #ffb8b8;
}

.saveable-sentence {
    cursor: pointer;
    border-radius: 10px;
    padding: 3px 5px;
    margin-left: -5px;
    transition: background 0.2s ease, color 0.2s ease;
}

.saveable-sentence:hover,
.selected-sentence {
    background: rgba(212, 175, 55, 0.14);
    color: #fff !important;
}

.saved-sentence-list,
.download-list {
    max-height: 430px;
    overflow-y: auto;
    padding-right: 4px;
}

.saved-item-card,
.download-item-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
    padding: 14px;
    border-radius: 20px;
}

.saved-item-content,
.download-item-content {
    flex: 1;
    min-width: 0;
}

.saved-item-content p,
.download-item-content p {
    font-weight: 700;
    font-size: 0.86rem;
    line-height: 1.5;
}

.saved-item-content small,
.download-item-content small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.35;
}

.saved-item-actions {
    display: flex;
    gap: 7px;
    flex-shrink: 0;
}

.saved-item-actions button {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: var(--gold);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.download-item-card > i {
    color: var(--gold);
    font-size: 1.35rem;
    margin-top: 3px;
}

.empty-library-state {
    min-height: 180px;
    border: 1px dashed rgba(212, 175, 55, 0.28);
    border-radius: 24px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 26px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.035);
}

.empty-library-state i {
    color: var(--gold);
    font-size: 2rem;
    margin-bottom: 10px;
}

.empty-library-state p {
    color: #fff;
    font-weight: 800;
    margin-bottom: 4px;
}

@media (max-width: 760px) {
    .library-panel-head,
    .saved-item-card,
    .download-item-card {
        flex-direction: column;
    }

    .saved-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}


/* Save lesson buttons */
.transcript-header {
    align-items: center;
}

.transcript-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-action-btn,
.lesson-icon-btn {
    border: 1px solid rgba(212, 175, 55, 0.28);
    color: var(--gold);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.icon-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
}

.lesson-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lesson-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
}

.icon-action-btn:hover,
.lesson-icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.55);
}

.save-lesson-btn.is-saved {
    color: #07111f;
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.32);
}

.app-toast-message {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%) translateY(14px);
    z-index: 9999;
    max-width: min(320px, calc(100vw - 40px));
    padding: 12px 16px;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 999px;
    color: #fff;
    background: rgba(7, 17, 31, 0.92);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ===== Update: Home recent lessons 6 cards / 2 rows + save sentence hint ===== */
.selected-sentence-hint {
    flex: 1 1 100%;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.45;
    margin-top: 2px;
}

.selected-sentence-hint.has-selection {
    color: var(--gold);
}

.save-sentence-btn {
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.42);
}

@media (min-width: 900px), (orientation: landscape) and (min-width: 768px) {
    .home-layout {
        grid-template-columns: minmax(320px, 0.92fr) minmax(520px, 1.48fr);
        gap: 24px;
        align-items: stretch;
    }

    .home-main,
    .home-recent {
        height: 100%;
        min-height: 0;
    }

    .topic-card {
        min-height: 0;
        height: 100%;
    }

    .home-recent {
        display: flex;
        flex-direction: column;
    }

    .home-recent .section-title {
        flex: 0 0 auto;
        margin-bottom: 14px;
    }

    .recent-lessons {
        flex: 1 1 auto;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 1fr));
        gap: 14px;
        height: auto !important;
        min-height: 0;
        overflow: visible;
        padding-bottom: 0;
    }

    .episode-tile {
        min-width: 0;
        width: 100%;
        height: 100%;
        min-height: 0 !important;
        border-radius: 22px;
        padding: 16px;
    }

    .episode-tile span {
        font-size: 0.88rem;
        line-height: 1.25;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .episode-tile small {
        font-size: 0.68rem;
        margin-top: 4px;
    }

    .topic-cover {
        height: clamp(190px, 32vh, 290px);
    }
}

@media (max-width: 899px) {
    .recent-lessons {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        overflow: visible;
        padding-bottom: 0;
    }

    .episode-tile {
        min-width: 0;
        height: 118px;
        min-height: 118px;
        padding: 13px;
    }

    .episode-tile span {
        font-size: 0.78rem;
        line-height: 1.25;
    }
}


/* ===== Update: replace Save Lesson with Save Sentence flow ===== */
.save-sentence-header-btn {
    width: auto;
    min-width: 82px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.16);
    border-color: rgba(212, 175, 55, 0.46);
    color: var(--gold);
    font-size: 0.68rem;
    font-weight: 800;
    white-space: nowrap;
}

.save-sentence-header-btn:hover,
.save-sentence-flow-btn:hover {
    background: rgba(212, 175, 55, 0.22);
    border-color: rgba(212, 175, 55, 0.66);
}

.save-sentence-flow-btn {
    color: var(--gold);
}

.save-sentence-flow-btn i {
    pointer-events: none;
}
