:root {
    --bg: #f6f8ff;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --line: #d8e2f1;
    --text: #12213a;
    --muted: #5f6f86;
    --primary: #245bff;
    --primary-2: #10b981;
    --accent: #ff7a59;
    --accent-2: #8b5cf6;
    --shadow: 0 14px 36px rgba(28, 46, 89, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(36, 91, 255, 0.10), transparent 30%),
        radial-gradient(circle at top right, rgba(255, 122, 89, 0.10), transparent 24%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.08), transparent 20%),
        var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-shell {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 16px;
}

.login-hero,
.login-card,
.hero-card,
.info-card,
.rights-card,
.books-card,
.preview-card,
.whiteboard-card,
.sidebar,
.sidebar-card,
.topbar {
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.login-hero {
    border-radius: 24px;
    padding: 30px;
    color: #10203a;
    background:
        linear-gradient(160deg, rgba(36, 87, 255, 0.09), rgba(16, 185, 129, 0.06)),
        rgba(255, 255, 255, 0.95);
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(36, 87, 255, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
}

.login-hero h1 {
    font-size: clamp(2.2rem, 4vw, 4rem);
    line-height: 1.03;
    margin: 22px 0 16px;
    max-width: 12ch;
}

.login-hero p {
    margin: 0;
    max-width: 56ch;
    color: var(--muted);
    font-size: 1.02rem;
}

.hero-points {
    margin-top: 28px;
    display: grid;
    gap: 14px;
}

.hero-points div {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #20314a;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.login-card {
    border-radius: 24px;
    padding: 24px;
    align-self: center;
}

.card-header,
.section-head,
.topbar,
.hero-grid,
.info-grid,
.books-layout {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.card-header {
    align-items: center;
}

.eyebrow,
.sidebar-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    font-weight: 700;
}

.login-card h2 {
    margin: 8px 0 0;
    font-size: 2rem;
}

.card-icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(36, 87, 255, 0.1);
    color: var(--primary);
    font-size: 1.4rem;
}

.alert-box {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 70, 70, 0.08);
    color: #b42318;
    border: 1px solid rgba(255, 70, 70, 0.18);
}

.login-form {
    margin-top: 24px;
    display: grid;
    gap: 18px;
}

.login-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.login-form input {
    width: 100%;
    padding: 15px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus {
    border-color: rgba(36, 87, 255, 0.4);
    box-shadow: 0 0 0 4px rgba(36, 87, 255, 0.08);
}

.primary-btn,
.secondary-btn,
.logout-link,
.book-item,
.side-link,
.meta-pill,
.chip,
.count-pill,
.sidebar-card,
.preview-meta,
.empty-state,
.preview-empty {
    border-radius: 18px;
}

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #183dce);
    color: #fff;
    box-shadow: 0 12px 30px rgba(36, 87, 255, 0.24);
}

.secondary-btn {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
}

.login-note {
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

.login-note code {
    background: #eef3ff;
    color: var(--primary);
    padding: 3px 6px;
    border-radius: 8px;
}

.panel-page {
    min-height: 100vh;
}

.panel-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
    gap: 12px;
    padding: 12px;
}

.sidebar {
    position: sticky;
    top: 12px;
    align-self: start;
    border-radius: 22px;
    padding: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 255, 0.96)),
        var(--surface);
}

.brand-block {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

.brand-block h1 {
    margin: 0;
    font-size: 1.1rem;
}

.brand-block p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.side-nav {
    display: grid;
    gap: 4px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--muted);
    border: 1px solid transparent;
    transition: 0.2s ease;
    font-size: 0.88rem;
}

.side-link:hover,
.side-link.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(36, 91, 255, 0.12), rgba(16, 185, 129, 0.10));
    border-color: rgba(36, 91, 255, 0.18);
    box-shadow: 0 10px 22px rgba(36, 91, 255, 0.08);
}

.sidebar-card {
    margin-top: 12px;
    padding: 12px;
    display: grid;
    gap: 6px;
}

.sidebar-card strong {
    font-size: 1rem;
}

.sidebar-card span {
    color: var(--muted);
    font-size: 0.94rem;
}

.logout-link {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: #b42318;
    background: rgba(180, 35, 24, 0.06);
    border: 1px solid rgba(180, 35, 24, 0.12);
    font-size: 0.88rem;
}

.panel-main {
    display: grid;
    gap: 12px;
}

.topbar {
    align-items: center;
    border-radius: 22px;
    padding: 12px 14px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.95)),
        var(--surface);
}

.topbar h2 {
    margin: 4px 0 0;
    font-size: clamp(1.1rem, 1.5vw, 1.45rem);
}

.topbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.meta-pill,
.count-pill,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(36, 91, 255, 0.08);
    border: 1px solid rgba(36, 91, 255, 0.12);
    color: var(--muted);
    font-size: 0.8rem;
}
.meta-pill-action {
    color: #245bff;
    text-decoration: none;
    border-color: rgba(36, 91, 255, 0.22);
    background: rgba(36, 91, 255, 0.08);
}
.meta-pill-action:hover {
    background: rgba(36, 91, 255, 0.14);
}

.topbar-compact {
    box-shadow: 0 12px 28px rgba(28, 46, 89, 0.06);
}

.panel-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 12px;
}

.panel-hero-copy,
.panel-hero-media,
.media-slot,
.dialog-card,
.panel-alert {
    border-radius: 22px;
    border: 1px solid rgba(216, 226, 241, 0.9);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-hero-copy {
    padding: 16px;
    background:
        radial-gradient(circle at top left, rgba(36, 91, 255, 0.14), transparent 38%),
        radial-gradient(circle at bottom right, rgba(255, 122, 89, 0.08), transparent 26%),
        var(--surface);
}

.panel-hero-copy h3 {
    margin: 8px 0 10px;
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1.12;
}

.panel-hero-copy p {
    margin: 0;
    max-width: 62ch;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.95rem;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.10);
    color: #1f7b54;
    border: 1px solid rgba(16, 185, 129, 0.12);
    font-size: 0.8rem;
    font-weight: 700;
}

.panel-hero-media {
    padding: 12px;
    display: grid;
    gap: 10px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96));
}

.media-slot {
    overflow: hidden;
    padding: 12px;
    display: grid;
    gap: 10px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96));
}

.media-slot-banner {
    min-height: 164px;
}

.media-slot-image {
    min-height: 156px;
}

.media-slot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.media-slot-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.media-slot img {
    width: 100%;
    height: 100%;
    min-height: 110px;
    max-height: 220px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid rgba(216, 226, 241, 0.9);
}

.media-slot-empty {
    min-height: 110px;
    border-radius: 16px;
    border: 1px dashed rgba(36, 91, 255, 0.22);
    background:
        linear-gradient(135deg, rgba(36, 91, 255, 0.08), rgba(255, 122, 89, 0.06));
    display: grid;
    place-items: center;
    text-align: center;
    gap: 6px;
    padding: 16px;
    color: var(--muted);
}

.media-slot-empty i {
    font-size: 1.3rem;
    color: var(--primary);
}

.media-slot-empty strong {
    font-size: 0.92rem;
    color: var(--text);
}

.media-slot-empty span {
    font-size: 0.8rem;
    line-height: 1.4;
}

.dialog-card,
.panel-alert {
    padding: 12px 14px;
}

.dialog-card {
    background:
        linear-gradient(135deg, rgba(36, 91, 255, 0.08), rgba(16, 185, 129, 0.06)),
        var(--surface);
}

.panel-alert {
    background: rgba(255, 122, 89, 0.08);
    border-color: rgba(255, 122, 89, 0.16);
    color: #9f3d23;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
}

.hero-card,
.info-card,
.rights-card,
.books-card,
.preview-card,
.whiteboard-card {
    border-radius: 22px;
    padding: 12px;
}

.hero-card-main h3 {
    font-size: clamp(1.25rem, 1.8vw, 1.8rem);
    line-height: 1.15;
    margin: 8px 0 10px;
    max-width: 18ch;
}

.hero-card-main p {
    margin: 0;
    color: var(--muted);
    max-width: 60ch;
    line-height: 1.55;
    font-size: 0.94rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.stats-card {
    display: grid;
    gap: 10px;
    align-content: start;
}

.stat-item {
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #f7f9ff);
    border: 1px solid var(--line);
}

.stat-item span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.stat-item strong {
    display: block;
    margin-top: 6px;
    font-size: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.section-head {
    align-items: center;
    margin-bottom: 8px;
}

.section-head h3 {
    margin: 0;
    font-size: 1rem;
    display: flex;
    gap: 8px;
    align-items: center;
}

.detail-list {
    display: grid;
    gap: 6px;
    margin: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: #f9fbff;
    border: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-size: 0.8rem;
}

.detail-list dd {
    margin: 0;
    font-weight: 600;
}

.rights-card {
    display: grid;
}

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

.chip-muted {
    color: var(--muted);
}

.books-layout {
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    align-items: start;
    gap: 12px;
}

.books-layout-compact {
    gap: 12px;
}

.books-filter-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: 0 12px 22px rgba(24, 39, 75, 0.06);
}

.books-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 240px));
    gap: 10px;
    align-items: end;
}

.filter-field {
    display: grid;
    gap: 6px;
}

.filter-field-wide {
    min-width: 0;
}

.filter-field span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.filter-field select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    outline: none;
}

.filter-field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    outline: none;
}

.filter-clear {
    justify-self: end;
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
}

.books-grid-wrap {
    display: grid;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    align-items: start;
}

.book-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(216, 226, 241, 0.9);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96));
    box-shadow: 0 12px 22px rgba(28, 46, 89, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.book-card[data-book-filter-card][hidden],
#booksNoResults[hidden] {
    display: none !important;
}

.book-card:hover {
    transform: translateY(-2px);
    border-color: rgba(36, 91, 255, 0.18);
    box-shadow: 0 18px 30px rgba(28, 46, 89, 0.10);
}

.book-card-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(36, 91, 255, 0.12), rgba(255, 122, 89, 0.10));
    display: grid;
    place-items: center;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.book-card-copy strong {
    font-size: 0.9rem;
    line-height: 1.3;
}

.book-card-copy small,
.book-card-copy span {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

.panel-hero,
.books-filter-card,
.book-card,
.book-detail-card,
.chapter-board,
.chapter-preview-panel,
.info-card,
.hero-card,
.topbar {
    backdrop-filter: blur(12px);
}

.book-detail-card,
.chapter-board,
.chapter-preview-panel,
.info-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96)),
        var(--surface);
    border: 1px solid rgba(216, 226, 241, 0.9);
}

.shelf-board {
    display: grid;
    gap: 16px;
}

.shelf-row {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: var(--shadow);
}

.shelf-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.shelf-head h3 {
    margin: 0;
    font-size: 1rem;
}

.shelf-head span {
    color: var(--muted);
    font-size: 0.8rem;
}

.shelf-scroll {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 126px;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.shelf-book {
    display: grid;
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.shelf-book:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(24, 39, 75, 0.08);
}

.shelf-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(31, 94, 255, 0.12), rgba(15, 157, 88, 0.12));
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
}

.shelf-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shelf-book-copy {
    display: grid;
    gap: 3px;
}

.shelf-book-copy strong {
    font-size: 0.82rem;
    line-height: 1.3;
}

.shelf-book-copy small {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.4;
}

.book-list {
    display: grid;
    gap: 6px;
    max-height: 620px;
    overflow: auto;
    padding-right: 4px;
}

.book-group {
    display: grid;
    gap: 6px;
}

.book-item {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 10px;
    text-align: left;
    padding: 8px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.book-item:hover,
.book-item.active {
    transform: translateY(-1px);
    border-color: rgba(36, 87, 255, 0.24);
    box-shadow: 0 16px 30px rgba(36, 87, 255, 0.08);
}

.book-cover {
    width: 54px;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(36, 87, 255, 0.12), rgba(16, 185, 129, 0.12));
    display: grid;
    place-items: center;
    color: var(--primary);
    font-weight: 800;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.book-copy strong {
    font-size: 0.9rem;
}

.book-copy span,
.book-copy small,
.preview-meta span {
    color: var(--muted);
    font-size: 0.82rem;
}

.chapter-list {
    display: grid;
    gap: 4px;
    padding-left: 8px;
    margin-left: 6px;
    border-left: 1px solid var(--line);
}

.chapter-item {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    text-align: left;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fbfdff;
    cursor: pointer;
    transition: 0.18s ease;
}

.chapter-item:hover,
.chapter-item.active {
    border-color: rgba(31, 94, 255, 0.22);
    background: #f5f8ff;
}

.chapter-cover {
    width: 100%;
    aspect-ratio: 4 / 5;
    height: auto;
    border-radius: 16px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(31, 94, 255, 0.12), rgba(15, 157, 88, 0.12));
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow:
        0 12px 22px rgba(24, 39, 75, 0.08),
        0 2px 0 rgba(255, 255, 255, 0.85) inset;
    position: relative;
    isolation: isolate;
    transform: none;
    transition: box-shadow 0.2s ease, filter 0.2s ease;
}

.chapter-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none;
    transition: none;
}

.chapter-list-wide .chapter-item:hover .chapter-cover,
.chapter-list-wide .chapter-item.active .chapter-cover {
    box-shadow:
        0 14px 24px rgba(24, 39, 75, 0.10),
        0 2px 0 rgba(255, 255, 255, 0.85) inset;
    transform: none;
    filter: none;
}

.chapter-list-wide .chapter-item:hover .chapter-cover img,
.chapter-list-wide .chapter-item.active .chapter-cover img {
    transform: none;
}

.chapter-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.chapter-copy strong {
    font-size: 0.92rem;
    line-height: 1.25;
}

.chapter-label,
.chapter-source-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.chapter-copy small,
.chapter-sources {
    font-size: 0.77rem;
    color: var(--muted);
    line-height: 1.45;
    word-break: break-word;
}

.preview-card {
    display: grid;
    gap: 10px;
}

.preview-meta {
    padding: 12px;
    background: #f9fbff;
    border: 1px solid var(--line);
    display: grid;
    gap: 3px;
}

.preview-meta small {
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 700;
}

.preview-stage {
    min-height: 460px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f7f9ff);
    position: relative;
}

.preview-stage iframe,
.whiteboard-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.preview-stage video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.preview-empty,
.empty-state {
    min-height: 460px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    padding: 18px;
}

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

.whiteboard-card {
    display: grid;
    gap: 10px;
}

.whiteboard-frame {
    min-height: 760px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
}

.count-pill {
    background: rgba(36, 87, 255, 0.08);
    color: var(--primary);
    border-color: rgba(36, 87, 255, 0.12);
}

.empty-copy {
    color: var(--muted);
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
}

.book-page-layout {
    display: grid;
    gap: 14px;
    align-items: start;
}

.book-detail-card {
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: 0 16px 30px rgba(24, 39, 75, 0.08);
    border-radius: 20px;
    padding: 14px;
    display: grid;
    gap: 12px;
    position: static;
}

.book-detail-card-wide {
    gap: 4px;
    padding: 8px;
}

.book-detail-layout {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
}

.book-detail-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(31, 94, 255, 0.12), rgba(15, 157, 88, 0.12));
    color: var(--primary);
    font-weight: 800;
    font-size: 1.8rem;
    position: relative;
    isolation: isolate;
    box-shadow:
        0 14px 26px rgba(24, 39, 75, 0.12),
        0 2px 0 rgba(255, 255, 255, 0.85) inset;
    transform: none;
    transition: box-shadow 0.2s ease, filter 0.2s ease;
}

.book-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none;
    transition: none;
}

.book-detail-copy {
    display: grid;
    gap: 6px;
}

.book-detail-copy-wide {
    align-content: start;
}

.book-detail-copy h3 {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.2;
}

.book-detail-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 0.66rem;
    line-height: 1.2;
}

.chapter-board {
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: 0 16px 30px rgba(24, 39, 75, 0.08);
    border-radius: 20px;
    padding: 16px;
    display: grid;
    gap: 14px;
}

.detail-table {
    display: grid;
    gap: 8px;
}

.detail-table-wide {
    margin-top: 2px;
}

.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fbfdff;
}

.detail-key {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    word-break: break-word;
}

.detail-value {
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
}

.chapter-list-board {
    padding-bottom: 14px;
}

.chapter-list-wide {
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
    padding-left: 0;
    margin-left: 0;
    border-left: 0;
}

.chapter-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) 320px;
    gap: 14px;
    align-items: start;
}

.chapter-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    align-items: start;
    align-content: start;
    max-height: 720px;
    overflow: auto;
    padding-right: 4px;
    padding-left: 0;
    margin-left: 0;
    border-left: 0;
    perspective: 1200px;
}

.preview-card-book {
    min-height: 0;
}

.preview-stage-book {
    min-height: 680px;
}

.chapter-selected-panel {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f9fbff);
}

.chapter-selected-panel h4 {
    margin: 8px 0 6px;
    font-size: 1.15rem;
}

.chapter-selected-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.chapter-list-wide .chapter-item {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 10px;
    justify-items: stretch;
    align-content: start;
    border: 1px solid rgba(228, 234, 243, 0.95);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 249, 255, 0.98));
    box-shadow:
        0 14px 24px rgba(24, 39, 75, 0.08);
    transform: none;
    transition:
        box-shadow 0.18s ease,
        border-color 0.18s ease,
        background 0.18s ease;
}

.chapter-list-grid .chapter-item {
    width: 100%;
}

.chapter-list-grid .chapter-cover {
    min-width: 0;
    max-width: 100%;
}

.chapter-list-grid .chapter-cover img {
    position: absolute;
    inset: 0;
}

.chapter-list-wide .chapter-item:hover,
.chapter-list-wide .chapter-item.active {
    border-color: rgba(31, 94, 255, 0.22);
    box-shadow:
        0 18px 30px rgba(24, 39, 75, 0.10);
    transform: none;
}

.chapter-caption {
    display: grid;
    min-width: 0;
    width: 100%;
    gap: 2px;
    margin-top: 6px;
    text-align: left;
}

.chapter-title {
    display: block;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--text);
}

.chapter-note {
    font-size: 0.76rem;
    color: var(--muted);
    line-height: 1.35;
}

.chapter-list-wide .chapter-copy strong {
    font-size: 0.95rem;
}

.chapter-list-wide .chapter-copy small {
    font-size: 0.76rem;
}

.chapter-preview-panel {
    background: var(--surface);
    border: 1px solid rgba(228, 234, 243, 0.9);
    box-shadow: var(--shadow);
    border-radius: 20px;
    padding: 12px;
    display: grid;
    gap: 10px;
    position: sticky;
    top: 14px;
}

.chapter-preview-card {
    display: grid;
    gap: 12px;
    transform: translateZ(0);
}

.chapter-preview-card-no-cover {
    gap: 10px;
}

.chapter-preview-card-no-cover .chapter-preview-cover {
    display: none !important;
}

.chapter-preview-cover {
    min-height: 360px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f7f9ff);
    display: grid;
    place-items: center;
    box-shadow:
        0 16px 28px rgba(24, 39, 75, 0.08),
        0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.chapter-preview-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chapter-preview-fallback {
    width: 100%;
    height: 100%;
    min-height: 360px;
    display: grid;
    place-items: center;
    color: var(--primary);
    font-size: 2.6rem;
}

.chapter-preview-copy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chapter-preview-copy strong {
    font-size: 1.04rem;
    line-height: 1.3;
}

.chapter-detail-name {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fbfdff;
}

.chapter-detail-label {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.chapter-detail-name strong {
    font-size: 1rem;
    line-height: 1.35;
    word-break: break-word;
}
.chapter-whiteboard-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    margin-top: 6px;
    padding: 7px 10px;
    border: 1px solid rgba(36, 91, 255, 0.2);
    border-radius: 9px;
    color: #245bff;
    background: rgba(36, 91, 255, 0.08);
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
}
.chapter-whiteboard-action:hover {
    background: rgba(36, 91, 255, 0.14);
}

.chapter-resource-section {
    display: grid;
    gap: 10px;
}

.chapter-resource-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    align-items: end;
}

.chapter-resource-head h4 {
    margin: 0;
    font-size: 0.94rem;
}

.chapter-resource-head span {
    color: var(--muted);
    font-size: 0.76rem;
}

.chapter-resource-list {
    display: grid;
    gap: 8px;
}

.chapter-resource-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fbfdff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.chapter-resource-item:hover {
    border-color: rgba(31, 94, 255, 0.2);
    box-shadow: 0 12px 22px rgba(24, 39, 75, 0.08);
    transform: translateY(-1px);
}

.chapter-resource-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(31, 94, 255, 0.1);
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.chapter-resource-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.chapter-resource-copy strong {
    font-size: 0.88rem;
    line-height: 1.25;
}

.chapter-resource-copy small {
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.chapter-preview-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: rgba(31, 94, 255, 0.1);
    color: var(--primary);
    font-size: 1.35rem;
    flex-shrink: 0;
}

@media (max-width: 1180px) {
    .panel-shell,
    .login-shell,
    .hero-grid,
    .panel-hero,
    .info-grid,
    .books-layout,
    .book-page-layout,
    .chapter-layout,
    .book-detail-layout {
        grid-template-columns: 1fr;
    }

    .chapter-list-grid {
        max-height: none;
        overflow: visible;
    }

    .books-filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-clear {
        justify-self: start;
    }

    .chapter-preview-panel {
        position: static;
    }

    .sidebar {
        position: static;
    }

    .panel-hero-media {
        order: 2;
    }
}

@media (max-width: 760px) {
    .panel-shell,
    .login-page {
        padding: 10px;
    }

    .login-hero,
    .login-card,
    .hero-card,
    .panel-hero-copy,
    .panel-hero-media,
    .media-slot,
    .info-card,
    .rights-card,
    .books-card,
    .preview-card,
    .whiteboard-card,
    .sidebar,
    .topbar {
        border-radius: 16px;
        padding: 14px;
    }

    .detail-list div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .whiteboard-frame,
    .preview-stage,
    .empty-state,
    .preview-empty {
        min-height: 420px;
    }

    .panel-hero {
        gap: 10px;
    }

    .media-slot-banner,
    .media-slot-image {
        min-height: 140px;
    }

    .book-detail-card {
        position: static;
    }

    .book-detail-layout {
        gap: 12px;
    }

    .chapter-list-wide {
        max-height: none;
        overflow: visible;
    }

    .chapter-list-grid {
        grid-template-columns: 1fr;
    }

    .shelf-scroll {
        grid-auto-columns: 112px;
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

.chapter-ai-action{background:#e9efff!important;color:#365cbd!important;border:1px solid #cddafa!important;font-weight:700}


.chapter-learning-actions{display:flex;flex-wrap:wrap;gap:10px}.chapter-learning-actions .chapter-whiteboard-action{margin-top:0}

/* Dark navigation for the Teacher Panel; the content area keeps its light theme. */
.panel-page .sidebar{background:linear-gradient(180deg,#111e34,#172b47);border-color:#2a3e5b;box-shadow:0 16px 38px #10203b24;color:#f0f5ff}
.panel-page .sidebar .brand-block h1{color:#f0f5ff}.panel-page .sidebar .brand-block p{color:#a6b8d2}
.panel-page .sidebar .side-link{color:#bdcce1}.panel-page .sidebar .side-link i{color:#93acd0}
.panel-page .sidebar .side-link:hover{color:#fff;background:#203754;border-color:#354f73;box-shadow:none}
.panel-page .sidebar .side-link.active{color:#fff;background:linear-gradient(110deg,#284f88,#244765);border-color:#4773a9;box-shadow:inset 3px 0 #8ec5ff}
.panel-page .sidebar .side-link.active i{color:#b9dcff}
.panel-page .sidebar .sidebar-card{background:#192e49;border-color:#324966;box-shadow:none;min-width:0}
.panel-page .sidebar .sidebar-label{color:#9cb2d1}.panel-page .sidebar .sidebar-card strong{color:#f0f5ff;overflow-wrap:anywhere;min-width:0}.panel-page .sidebar .sidebar-card span{color:#b0c2dc}
.panel-page .sidebar .logout-link{background:#402b3b;border-color:#74404e;color:#ffb8be}.panel-page .sidebar .logout-link:hover{background:#57303f;color:#fff}
.panel-page .sidebar a:focus-visible{outline:3px solid #8ec5ff;outline-offset:3px}

/* Chapter details share the dark navigation palette. */
.panel-page .chapter-preview-panel{background:linear-gradient(180deg,#111e34,#172b47);border-color:#2a3e5b;color:#f0f5ff;box-shadow:0 16px 38px #10203b24}
.panel-page .chapter-preview-panel .section-head h3,.panel-page .chapter-preview-panel .chapter-resource-head h4{color:#f0f5ff}
.panel-page .chapter-preview-panel .chapter-detail-name{background:#192e49;border-color:#324966}
.panel-page .chapter-preview-panel .chapter-detail-name strong{color:#f0f5ff}
.panel-page .chapter-preview-panel .chapter-detail-label,.panel-page .chapter-preview-panel .chapter-resource-head span{color:#b0c2dc}
.panel-page .chapter-preview-panel .chapter-preview-cover{background:#192e49;border-color:#324966;box-shadow:0 12px 24px #08142733}
.panel-page .chapter-preview-panel .chapter-whiteboard-action,.panel-page .chapter-preview-panel .chapter-ai-action{background:#284f78!important;border:1px solid #4773a9!important;color:#dceeff!important}
.panel-page .chapter-preview-panel .chapter-whiteboard-action:hover{background:#345f8b!important;color:#fff!important}
.panel-page .chapter-preview-panel .chapter-resource-item{background:#192e49;border-color:#324966;color:#f0f5ff}
.panel-page .chapter-preview-panel .chapter-resource-item:hover{background:#203b5b;border-color:#5b87ba;box-shadow:0 10px 22px #08142733}
.panel-page .chapter-preview-panel .chapter-resource-icon{background:#294563;color:#b9dcff}
.panel-page .chapter-preview-panel .chapter-resource-copy small{color:#b0c2dc}
.panel-page .chapter-preview-panel a:focus-visible{outline:3px solid #8ec5ff;outline-offset:3px}

/* Fill the desktop viewport and keep account actions at the bottom. */
@media(min-width:1181px){
    .panel-page .panel-shell>.sidebar{display:flex;flex-direction:column;height:calc(100dvh - 24px);min-height:0;overflow-y:auto;position:sticky;top:12px}
    .panel-page .panel-shell>.sidebar .sidebar-card{margin-top:auto}
    .panel-page .panel-shell>.sidebar .brand-block,.panel-page .panel-shell>.sidebar .side-nav,.panel-page .panel-shell>.sidebar .sidebar-card,.panel-page .panel-shell>.sidebar .logout-link{flex-shrink:0}
    .panel-page .panel-shell>.sidebar .side-nav{margin-bottom:20px}
    .panel-page .panel-shell>.sidebar .logout-link{align-self:flex-start}
}

