:root {
    --learnory-primary: #5b4cf0;
    --learnory-primary-dark: #4338ca;
    --learnory-ink: #172033;
}

body {
    color: var(--learnory-ink);
}

.login-page {
    background:
        radial-gradient(circle at 12% 15%, rgba(91, 76, 240, 0.18), transparent 28%),
        radial-gradient(circle at 85% 80%, rgba(14, 165, 233, 0.14), transparent 30%),
        #f4f6fb;
}

.login-card {
    max-width: 920px;
    border-radius: 1.25rem;
}

.login-visual {
    min-height: 540px;
    color: white;
    background:
        linear-gradient(145deg, rgba(21, 27, 67, 0.08), rgba(21, 27, 67, 0.52)),
        linear-gradient(145deg, var(--learnory-primary), #17133f);
}

.tracking-wide {
    letter-spacing: 0.09em;
}

.brand-mark {
    display: inline-flex;
    width: 3rem;
    height: 3rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    color: var(--learnory-primary-dark);
    background: white;
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow: 0 0.5rem 1.5rem rgba(23, 32, 51, 0.18);
}

.brand-mark-sm {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    font-size: 1rem;
    box-shadow: none;
}

.btn-primary {
    --bs-btn-bg: var(--learnory-primary);
    --bs-btn-border-color: var(--learnory-primary);
    --bs-btn-hover-bg: var(--learnory-primary-dark);
    --bs-btn-hover-border-color: var(--learnory-primary-dark);
}

.text-primary {
    color: var(--learnory-primary) !important;
}

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

.admin-shell {
    min-height: 100vh;
}

.admin-sidebar {
    --bs-offcanvas-width: 270px;
    width: 270px;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
}

.admin-sidebar .offcanvas-body {
    overflow-y: auto;
}

.sidebar-brand {
    color: var(--bs-body-color);
    font-size: 1.05rem;
    font-weight: 750;
}

.sidebar-label {
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.admin-nav-link {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 0.8rem;
    border: 0;
    border-radius: 0.75rem;
    color: var(--bs-secondary-color);
    background: transparent;
    font-weight: 600;
    text-align: left;
    transition: color 160ms ease, background-color 160ms ease;
}

.admin-nav-link:hover,
.admin-nav-link:focus-visible {
    color: var(--bs-body-color);
    background: var(--bs-tertiary-bg);
}

.admin-nav-link.active {
    color: white;
    background: var(--learnory-primary);
}

.nav-symbol {
    display: inline-grid;
    width: 1.75rem;
    height: 1.75rem;
    place-items: center;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.72rem;
    font-weight: 800;
}

.admin-nav-link.active .nav-symbol {
    background: rgba(255, 255, 255, 0.18);
}

.sidebar-account {
    border-top: 1px solid var(--bs-border-color);
}

.admin-content {
    min-width: 0;
}

.management-search {
    width: min(100%, 360px);
}

.overview-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.82rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.overview-list > div:last-child {
    border-bottom: 0;
}

.user-avatar {
    display: grid;
    width: 2.7rem;
    height: 2.7rem;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: linear-gradient(145deg, #0ea5e9, var(--learnory-primary));
    font-weight: 800;
}

.user-identity {
    min-width: 235px;
}

.dashboard-state {
    min-height: 45vh;
}

.metric-card {
    border-radius: 1rem;
}

.metric-value {
    font-size: clamp(1.65rem, 4vw, 2.2rem);
    font-weight: 750;
    line-height: 1;
}

.story-cover-placeholder {
    position: relative;
    display: grid;
    width: 2.8rem;
    height: 3.5rem;
    place-items: center;
    border-radius: 0.65rem;
    color: white;
    background: linear-gradient(145deg, var(--learnory-primary), #0ea5e9);
    font-weight: 800;
    overflow: hidden;
}

.story-cover-placeholder img {
    position: absolute;
    width: 2.8rem;
    height: 3.5rem;
    object-fit: cover;
}

.story-identity {
    min-width: 260px;
    max-width: 430px;
}

.story-description {
    max-width: 350px;
}

.story-name {
    color: var(--learnory-ink);
}

.story-name:hover {
    color: var(--learnory-primary);
}

.empty-state-icon {
    display: inline-grid;
    width: 4rem;
    height: 4rem;
    place-items: center;
    border-radius: 1.2rem;
    color: white;
    background: linear-gradient(145deg, var(--learnory-primary), #0ea5e9);
    font-size: 1.6rem;
    font-weight: 800;
}

.upload-zone {
    cursor: pointer;
    border: 2px dashed #c7ccda;
    border-radius: 1rem;
    background: #f8f9fc;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.upload-zone:hover,
.upload-zone:focus-within {
    border-color: var(--learnory-primary);
    background: #f3f1ff;
}

.upload-zone-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 1rem;
    color: var(--learnory-primary-dark);
    background: #e8e5ff;
    font-size: 0.82rem;
    font-weight: 800;
}

.json-preview {
    max-height: 55vh;
    overflow: auto;
    padding: 1rem;
    border-radius: 0.75rem;
    color: #dbeafe;
    background: #111827;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.pre-line {
    white-space: pre-line;
}

@media (min-width: 992px) {
    .admin-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1030;
        visibility: visible !important;
        transform: none !important;
    }

    .admin-content {
        width: calc(100% - 270px);
        margin-left: 270px;
    }
}

@media (max-width: 767.98px) {
    .login-card {
        max-width: 480px;
    }

    .table > :not(caption) > * > * {
        padding: 0.8rem;
    }
}

/* Shared light/dark surfaces, including dynamically generated table content. */
.table-themed {
    --bs-table-bg: var(--bs-tertiary-bg);
    --bs-table-color: var(--bs-body-color);
}

[data-bs-theme="dark"] {
    --learnory-ink: #e2e8f0;
    --learnory-primary: #a59aff;
    --learnory-primary-dark: #c0b8ff;
}

[data-bs-theme="dark"] .btn-primary,
[data-bs-theme="dark"] .admin-nav-link.active {
    --bs-btn-bg: #5b4cf0;
    --bs-btn-border-color: #5b4cf0;
    --bs-btn-hover-bg: #4939d6;
    --bs-btn-hover-border-color: #4939d6;
    background-color: #5b4cf0;
}

[data-bs-theme="dark"] .login-page {
    background: radial-gradient(circle at 12% 15%, rgba(91, 76, 240, 0.2), transparent 40%), #151821;
}

[data-bs-theme="dark"] .upload-zone {
    background: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .upload-zone:hover,
[data-bs-theme="dark"] .upload-zone:focus-within {
    background: #302949;
    border-color: var(--learnory-primary);
}

[data-bs-theme="dark"] .text-success {
    color: #75d7ad !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: #a59aff;
    --bs-btn-border-color: #a59aff;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 0.5rem;
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.admin-sidebar .brand-mark,
.navbar .brand-mark {
    color: var(--learnory-primary);
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
}

.admin-nav-link .nav-symbol {
    background: var(--bs-tertiary-bg);
}

.admin-nav-link.active .nav-symbol {
    background: rgba(255, 255, 255, 0.18);
}

/* Analytics page */
.analytics-value {
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.analytics-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 84px;
}

.analytics-bar-column {
    flex: 1 1 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    min-width: 2px;
}

.analytics-bar {
    width: 100%;
    background: var(--learnory-primary);
    border-radius: 2px 2px 0 0;
    opacity: 0.85;
}

.analytics-hbar {
    display: grid;
    grid-template-columns: minmax(150px, 220px) 1fr;
    gap: 4px 12px;
    align-items: center;
    margin-bottom: 10px;
}

.analytics-hbar-track {
    height: 10px;
    background: var(--bs-tertiary-bg);
    border-radius: 99px;
    overflow: hidden;
}

.analytics-hbar-fill {
    height: 100%;
    background: var(--learnory-primary);
    border-radius: 99px;
}

.analytics-hbar-text {
    font-size: 0.9rem;
}

.analytics-hbar-note {
    grid-column: 2;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

@media (max-width: 575.98px) {
    .analytics-hbar {
        grid-template-columns: 1fr;
    }

    .analytics-hbar-note {
        grid-column: 1;
    }
}

/* Language versions shown under their English story. */
.story-version-row > td {
    background-color: var(--bs-tertiary-bg);
}

.story-version-row .story-identity {
    padding-left: 1.5rem;
}

/* Story gallery: one card per story or weekly series. */
.story-card {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.story-card:hover,
.story-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--bs-box-shadow) !important;
}

.story-card-cover {
    aspect-ratio: 16 / 9;
    background: var(--bs-tertiary-bg);
    overflow: hidden;
    position: relative;
}

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

.story-card-ribbon {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
}

.story-group-panel {
    --bs-offcanvas-width: min(1180px, 96vw);
}

/* Table view: series header row, then episodes, then their languages. */
.story-series-row > td {
    background-color: var(--bs-secondary-bg);
}

.story-depth-1 .story-identity {
    padding-left: 1.5rem;
}

.story-depth-2 .story-identity {
    padding-left: 3rem;
}
