/* ═══════════════════════════════════════════════════════════
   ENHANCEMENTS.CSS, Global Sidebar Nav, Writing Tools,
   Theme Toggle, Animations & Utilities
   Wonder Notes · Early Help & Assessment
═══════════════════════════════════════════════════════════ */

:root {
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 68px;
    --sidebar-bg: #0d1025;
    --sidebar-bg-hover: rgba(255,255,255,0.04);
    --sidebar-bg-active: rgba(123,47,190,0.12);
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-text: rgba(255,255,255,0.5);
    --sidebar-text-hover: rgba(255,255,255,0.85);
    --sidebar-text-active: #c084fc;
    --sidebar-accent: #7B2FBE;
    --sidebar-transition: 0.3s cubic-bezier(0.4,0,0.2,1);
    --sidebar-z: 200;
}

/* ═══════════════════════════════════════
   SIDEBAR NAVIGATION
═══════════════════════════════════════ */
.sidebar-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: var(--sidebar-z);
    display: flex;
    flex-direction: column;
    transition: width var(--sidebar-transition);
    overflow: hidden;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-nav.collapsed { width: var(--sidebar-collapsed-w); }

/* ─── Push ALL page content when sidebar is present ─── */
body.sidebar-open {
    padding-left: var(--sidebar-w);
    transition: padding-left var(--sidebar-transition);
}

body.sidebar-collapsed {
    padding-left: var(--sidebar-collapsed-w);
    transition: padding-left var(--sidebar-transition);
}

/* ─── Make top-bar span remaining width ─── */
body.sidebar-open .top-bar,
body.sidebar-collapsed .top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

/* ─── Sidebar Brand ─── */
.sidebar-brand {
    padding: 20px 18px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    min-height: 64px;
    overflow: hidden;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #ff1381 0%, #cc0f69 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(255,19,129,0.3);
    overflow: hidden;
}

.sidebar-logo img { height: 22px; width: auto; }

.sidebar-logo-fallback {
    color: white;
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: -0.5px;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-brand-text { opacity: 0; width: 0; }

.sidebar-brand-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
}

.sidebar-brand-sub {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.35);
    font-weight: 500;
}

/* ─── Sidebar Toggle Button ─── */
.sidebar-toggle {
    position: fixed;
    top: 50vh;
    left: calc(var(--sidebar-w) - 12px);
    transform: translateY(-50%);
    width: 24px;
    height: 52px;
    background: #161a35;
    border: 1px solid rgba(255,255,255,0.1);
    border-left: none;
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,0.35);
    transition: background 0.2s, color 0.2s, width 0.2s, left var(--sidebar-transition);
    z-index: 201;
    box-shadow: 3px 0 12px rgba(0,0,0,0.25);
    padding: 0;
    outline: none;
}

.sidebar-nav.collapsed .sidebar-toggle {
    left: calc(var(--sidebar-collapsed-w) - 12px);
}

.sidebar-toggle:hover {
    background: linear-gradient(135deg, #7B2FBE 0%, #E3017E 100%);
    color: white;
    border-color: transparent;
    width: 28px;
}

.sidebar-toggle svg {
    width: 13px;
    height: 13px;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    flex-shrink: 0;
}

.sidebar-nav.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* ─── Sidebar Menu ─── */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }

/* ─── Section Labels ─── */
.sidebar-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: rgba(255,255,255,0.2);
    padding: 18px 10px 8px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-section-label { opacity: 0; height: 0; padding: 0; }

/* ─── Nav Items ─── */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    margin-bottom: 2px;
    position: relative;
    white-space: nowrap;
}

.sidebar-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}
.sidebar-item:hover .sidebar-item-icon {
    color: #f472b6;
    filter: drop-shadow(0 0 4px rgba(227,1,126,0.4));
}

.sidebar-item.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 15%; height: 70%; width: 3px;
    background: var(--sidebar-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-item-icon {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-item-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }

.sidebar-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-item-text { opacity: 0; width: 0; }

.sidebar-item-badge {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-item-badge { opacity: 0; width: 0; padding: 0; }

/* ─── Expandable Sub-Menu ─── */
.sidebar-submenu-trigger { cursor: pointer; }

.sidebar-submenu-trigger .sidebar-chevron {
    margin-left: auto;
    transition: transform 0.3s;
    flex-shrink: 0;
    color: rgba(255,255,255,0.2);
}

.sidebar-submenu-trigger .sidebar-chevron svg { width: 14px; height: 14px; }
.sidebar-submenu-trigger.open .sidebar-chevron { transform: rotate(90deg); }
.sidebar-nav.collapsed .sidebar-chevron { opacity: 0; width: 0; }

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
    margin-left: 8px;
    border-left: 1.5px solid rgba(255,255,255,0.06);
}

.sidebar-submenu.open { max-height: 300px; }
.sidebar-nav.collapsed .sidebar-submenu { display: none; }

.sidebar-sub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px 9px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.18s;
    white-space: nowrap;
    margin: 1px 0;
}

.sidebar-sub-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-sub-item.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-bg-active);
}

.sidebar-sub-icon {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.sidebar-sub-icon svg { width: 16px; height: 16px; stroke-width: 1.8; }

.sidebar-sub-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.28);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.sidebar-footer-btn:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-footer-btn svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }
.sidebar-nav.collapsed .sidebar-footer-btn span { opacity: 0; width: 0; }

/* ─── Mobile Sidebar ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--sidebar-z) - 1);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.visible { display: block; opacity: 1; }

.sidebar-hamburger {
    display: none;
    position: fixed;
    top: 18px;
    left: 14px;
    z-index: calc(var(--sidebar-z) + 1);
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.sidebar-hamburger svg { width: 20px; height: 20px; }

@media (max-width: 1024px) {
    .sidebar-nav {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        box-shadow: 4px 0 30px rgba(0,0,0,0.4);
    }
    .sidebar-nav.mobile-open { transform: translateX(0); }
    body.sidebar-open,
    body.sidebar-collapsed { padding-left: 0 !important; }
    .sidebar-hamburger { display: flex; }
    .sidebar-toggle { display: none; }
    .top-bar { padding-left: 62px !important; }
}

/* ─── Tooltip (collapsed mode) ─── */
.sidebar-tooltip {
    position: fixed;
    left: calc(var(--sidebar-collapsed-w) + 10px);
    background: #1a1a2e;
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: calc(var(--sidebar-z) + 10);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.15s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.sidebar-tooltip.visible { opacity: 1; transform: translateX(0); }


/* ═══════════════════════════════════════
   TOP BAR, Slim (no duplicate branding)
═══════════════════════════════════════ */
.top-bar {
    height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: none !important;
}

/* Show auth elements floating top-right instead */
.auth-section {
    position: fixed !important;
    top: 12px;
    right: 20px;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Training page nav, fixed top-left (after sidebar) */
.tb-extra {
    position: fixed !important;
    top: 8px;
    left: calc(var(--sidebar-w) + 16px);
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 2px;
    background: transparent;
    margin: 0 !important;
}
body.sidebar-collapsed .tb-extra { left: calc(var(--sidebar-collapsed-w) + 16px); }
@media (max-width: 1024px) { .tb-extra { display: none !important; } }


/* ═══════════════════════════════════════
   DARK MODE THEME
═══════════════════════════════════════ */
body.dark-mode {
    --surface: #1a1a2e;
    --surface-alt: #111827;
    --text-primary: #e4e6f0;
    --text-secondary: #a0a3b8;
    --text-muted: #6b6e85;
    --border: #2a2d45;
    --border-light: #1f2237;
}

body.dark-mode .card-main,
body.dark-mode .content-panel,
body.dark-mode .content-card .card-main {
    background: #1a1a2e;
    border-color: #2a2d45;
}

body.dark-mode .card-inner,
body.dark-mode .section-title,
body.dark-mode .section-desc,
body.dark-mode .upload-title,
body.dark-mode .feature-name,
body.dark-mode .person-name {
    color: #e4e6f0;
}

body.dark-mode .feature-desc,
body.dark-mode .upload-hint,
body.dark-mode .person-details {
    color: #8e90a6;
}

body.dark-mode .upload-zone {
    background: #111827;
    border-color: #2a2d45;
}

body.dark-mode .upload-zone:hover {
    background: rgba(123,47,190,0.08);
    border-color: #7B2FBE;
}

body.dark-mode .features-strip,
body.dark-mode .tips-strip,
body.dark-mode .submit-bar {
    background: #111827;
    border-color: #1f2237;
}

body.dark-mode .feature-card,
body.dark-mode .tip-card,
body.dark-mode .person-card-mini,
body.dark-mode .person-card {
    background: #1a1a2e;
    border-color: #2a2d45;
}

body.dark-mode .feature-card:hover,
body.dark-mode .tip-card:hover {
    border-color: #3a3d55;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background: #111827;
    border-color: #2a2d45;
    color: #e4e6f0;
}

body.dark-mode .alert-info { background: rgba(123,47,190,0.08); color: #c084fc; border-left-color: #7B2FBE; }
body.dark-mode .alert-danger { background: rgba(220,53,69,0.08); }

body.dark-mode .report-display,
body.dark-mode .report-content {
    background: #111827;
    border-color: #2a2d45;
    color: #e4e6f0;
}

body.dark-mode .editable-answer { color: #e4e6f0; }
body.dark-mode table td { color: #e4e6f0; border-color: #2a2d45; }
body.dark-mode table th { background: #1f2237; border-color: #2a2d45; color: #c084fc; }

body.dark-mode .info-panel,
body.dark-mode .meta-row,
body.dark-mode .settings-panel,
body.dark-mode .preview-section,
body.dark-mode .sample-panel {
    background: #111827;
    border-color: #2a2d45;
}

body.dark-mode .content-divider { background: #2a2d45; }
body.dark-mode .section-header::after { background: #2a2d45; }

body.dark-mode .btn-action,
body.dark-mode .btn-secondary,
body.dark-mode .btn-cancel,
body.dark-mode .btn-back {
    background: #1a1a2e;
    border-color: #2a2d45;
    color: #a0a3b8;
}

body.dark-mode .btn-action:hover,
body.dark-mode .btn-secondary:hover {
    border-color: #7B2FBE;
    color: #c084fc;
}

body.dark-mode .modal-content { background: #1a1a2e; }
body.dark-mode .modal-body { color: #e4e6f0; }
body.dark-mode .coming-soon-title { color: #e4e6f0; }
body.dark-mode .coming-soon-desc { color: #a0a3b8; }

body.dark-mode .file-chip {
    background: #1a1a2e;
    border-color: #2a2d45;
    color: #a0a3b8;
}

body.dark-mode .tp-body { color: #a0a3b8; }
body.dark-mode .tp-line { color: #a0a3b8; }
body.dark-mode .tp-speaker { color: #e4e6f0; }

body.dark-mode .word-counter-bar { background: #111827; border-color: #2a2d45; }

body.dark-mode body,
body.dark-mode {
    background: #111827;
}

/* ─── Template library dark mode ─── */
body.dark-mode .template-card {
    background: #1a1a2e;
    border-color: #2a2d45;
}
body.dark-mode .template-card:hover {
    border-color: rgba(123,47,190,0.4);
    box-shadow: 0 4px 20px rgba(123,47,190,0.12);
}
body.dark-mode .template-name { color: #e4e6f0; }
body.dark-mode .template-desc { color: #a0a3b8; }
body.dark-mode .template-meta { color: #6b6e85; }
body.dark-mode .btn-edit {
    background: #1a1a2e;
    border-color: #2a2d45;
    color: #a0a3b8;
}
body.dark-mode .btn-edit:hover { border-color: #7B2FBE; color: #c084fc; }
body.dark-mode .loading-state p { color: #6b6e85; }
body.dark-mode .empty-state h4 { color: #e4e6f0; }
body.dark-mode .empty-state p { color: #6b6e85; }
body.dark-mode .back-link { color: #a0a3b8; }
body.dark-mode .back-link:hover { color: #c084fc; }

/* ─── Section-header dark mode ─── */
body.dark-mode .section-header { color: #c084fc; }

/* ─── Person role tag dark mode ─── */
body.dark-mode .person-role-tag {
    background: rgba(123,47,190,0.15);
    color: #c084fc;
}

/* ─── Tip callout dark mode ─── */
body.dark-mode .tip-callout {
    background: rgba(123,47,190,0.06);
    border-color: rgba(123,47,190,0.18);
    color: #a0a3b8;
}
body.dark-mode .tip-callout strong { color: #c084fc; }

/* ═══════════════════════════════════════
   LIGHT THEME, explicit contrast fixes
   (default, no class needed)
═══════════════════════════════════════ */

/* Ensure body background and base text are always readable */
body:not(.dark-mode) {
    background: #f4f6fb;
    color: #0d1b3e;
}

/* Content cards stay white with dark text */
body:not(.dark-mode) .card-main,
body:not(.dark-mode) .content-panel {
    background: #ffffff;
    color: #0d1b3e;
}

/* Section headings and descriptions */
body:not(.dark-mode) .section-title,
body:not(.dark-mode) .section-label,
body:not(.dark-mode) h1, body:not(.dark-mode) h2,
body:not(.dark-mode) h3, body:not(.dark-mode) h4 {
    color: #0d1b3e;
}

body:not(.dark-mode) .section-desc,
body:not(.dark-mode) .feature-desc,
body:not(.dark-mode) p {
    color: #444870;
}

/* Hero, always dark regardless of theme (gradient hardcoded, not a CSS variable) */
body:not(.dark-mode) .hero {
    background: linear-gradient(135deg, #0d1b3e 0%, #0e2854 35%, #0f3460 65%, #1a5276 100%) !important;
}
body:not(.dark-mode) .hero h1,
body:not(.dark-mode) .hero h2,
body:not(.dark-mode) .hero h3,
body:not(.dark-mode) .hero h4 { color: white !important; }
body:not(.dark-mode) .hero p   { color: rgba(255,255,255,0.5) !important; }
body:not(.dark-mode) .hero .hero-badge { color: #7dd3fc !important; }

/* Notes page hero, same dark treatment as .hero */
body:not(.dark-mode) .nt-hero { background: var(--gradient-hero) !important; }
body:not(.dark-mode) .nt-hero h1,
body:not(.dark-mode) .nt-hero h2 { color: white !important; }
body:not(.dark-mode) .nt-hero p  { color: rgba(255,255,255,0.52) !important; }
body:not(.dark-mode) .nt-eyebrow { color: rgba(255,255,255,.75) !important; }

/* Training page hero, same dark treatment as .hero */
body:not(.dark-mode) .th-hero { background: var(--gradient-hero) !important; }
body:not(.dark-mode) .th-hero h1,
body:not(.dark-mode) .th-hero h2 { color: white !important; }
body:not(.dark-mode) .th-hero p  { color: rgba(255,255,255,0.52) !important; }
body:not(.dark-mode) .th-eyebrow { color: rgba(255,255,255,.75) !important; }

/* Training module hero, full-bleed inside th-content */
body:not(.dark-mode) .mod-hero { background: var(--gradient-hero) !important; }
body:not(.dark-mode) .mod-hero h1 { color: white !important; }
body:not(.dark-mode) .mod-hero p { color: rgba(255,255,255,0.52) !important; }
body:not(.dark-mode) .mod-back { color: rgba(255,255,255,0.75) !important; }
body:not(.dark-mode) .mod-hero-tag-pill { color: rgba(255,255,255,0.65) !important; }
body:not(.dark-mode) .mod-pill { color: rgba(255,255,255,0.55) !important; }

/* Feature cards */
body:not(.dark-mode) .feature-card {
    background: #ffffff;
    border-color: #e2e5ef;
}
body:not(.dark-mode) .feature-name { color: #0d1b3e; }

/* Transcript cards */
body:not(.dark-mode) .transcript-card {
    background: #ffffff;
    border-color: #e2e5ef;
    color: #0d1b3e;
}
body:not(.dark-mode) .tc-id   { color: #0d1b3e; }
body:not(.dark-mode) .tc-meta { color: #8a8faa; }

/* Form elements */
body:not(.dark-mode) .form-control,
body:not(.dark-mode) .form-select {
    background: #ffffff;
    border-color: #e2e5ef;
    color: #0d1b3e;
}

/* Secondary buttons */
body:not(.dark-mode) .btn-secondary {
    background: #ffffff;
    border-color: #e2e5ef;
    color: #444870;
}
body:not(.dark-mode) .btn-secondary:hover {
    border-color: #7B2FBE;
    color: #7B2FBE;
    background: rgba(123,47,190,0.05);
}

/* Features strip */
body:not(.dark-mode) .features-strip {
    background: #f4f6fb;
    border-color: #e2e5ef;
}
body:not(.dark-mode) .features-label { color: #8a8faa; }

/* Footer always stays dark (brand intentional) */
body:not(.dark-mode) .footer { background: #0d1b3e; }

/* Template selector box */
body:not(.dark-mode) #template-selector {
    background: #f4f6fb;
    border-color: #e2e5ef;
}
body:not(.dark-mode) #template-selector label { color: #0d1b3e; }

/* Theme toggle button (in sidebar footer) */
.theme-toggle {
    display: none;
}


/* ═══════════════════════════════════════
   WRITING TOOLS TOOLBAR
═══════════════════════════════════════ */
.writing-tools-bar {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: #0d1025;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 6px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    backdrop-filter: blur(20px);
    animation: wt-slide-up 0.3s ease-out;
    display: none;
    gap: 4px;
}

.writing-tools-bar.visible { display: flex; }

@keyframes wt-slide-up {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.wt-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 12px;
    background: transparent; border: none;
    color: rgba(255,255,255,0.65);
    font-size: 0.82rem; font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer; transition: all 0.18s; white-space: nowrap;
}

.wt-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.wt-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.wt-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.08); margin: 0 2px; align-self: center; }

.wt-dropdown {
    position: absolute; bottom: calc(100% + 8px);
    left: 50%; transform: translateX(-50%);
    background: #0d1025; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; padding: 6px; min-width: 220px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    display: none; flex-direction: column; gap: 2px;
}

.wt-dropdown.visible { display: flex; }

.wt-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 10px;
    background: transparent; border: none;
    color: rgba(255,255,255,0.65);
    font-size: 0.84rem; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer; transition: all 0.15s;
    text-align: left; width: 100%;
}

.wt-dropdown-item:hover { background: rgba(255,255,255,0.06); color: white; }
.wt-dropdown-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }

/* Word Counter */
.word-counter-bar {
    display: flex; gap: 20px;
    padding: 10px 16px;
    background: var(--surface-alt, #f7f8fc);
    border: 1px solid var(--border-light, #f0f1f8);
    border-top: none; border-radius: 0 0 12px 12px;
    font-size: 0.76rem; color: var(--text-muted, #8e90a6); font-weight: 500;
}

.word-counter-bar span { display: flex; align-items: center; gap: 6px; }
.word-counter-bar .wc-val { font-weight: 700; color: var(--text-secondary, #5a5d7a); font-variant-numeric: tabular-nums; }

/* Loading overlay for writing tools */
.wt-loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(3px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
}

.wt-loading-box {
    background: white; border-radius: 16px;
    padding: 36px 44px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.wt-loading-spinner {
    width: 40px; height: 40px;
    border: 4px solid #f0f1f8; border-top: 4px solid #7B2FBE;
    border-radius: 50%; animation: spin 0.9s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.wt-loading-box h4 { font-size: 1rem; font-weight: 600; color: #1a1a2e; margin-bottom: 6px; }
.wt-loading-box p { font-size: 0.86rem; color: #5a5d7a; margin: 0; }


/* ═══════════════════════════════════════
   SCROLL TO TOP BUTTON
═══════════════════════════════════════ */
.scroll-top-btn {
    position: fixed; bottom: 24px; right: 24px;
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #7B2FBE 0%, #E3017E 100%);
    border: none;
    color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 90; opacity: 0; transform: translateY(10px);
    transition: all 0.3s; pointer-events: none;
    box-shadow: 0 4px 20px rgba(123,47,190,0.4);
}

.scroll-top-btn.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.scroll-top-btn:hover { filter: brightness(1.1); }
.scroll-top-btn svg { width: 20px; height: 20px; }


/* ═══════════════════════════════════════
   GLOBAL MOBILE FIXES
═══════════════════════════════════════ */

/* Prevent horizontal overflow on all screens */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

/* Ensure images/media never overflow their container */
img, video, svg { max-width: 100%; }

/* Tables, wrap in a scroll container on small screens */
@media (max-width: 768px) {
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Writing Tools Bar, scrollable on mobile, full width */
@media (max-width: 768px) {
    .writing-tools-bar {
        left: 8px;
        right: 8px;
        bottom: 12px;
        transform: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-radius: 12px;
        padding: 4px;
        justify-content: flex-start;
    }
    .writing-tools-bar::-webkit-scrollbar { display: none; }
    .wt-btn { padding: 8px 10px; font-size: 0.78rem; flex-shrink: 0; }
    .wt-dropdown {
        left: 0;
        transform: none;
        bottom: calc(100% + 6px);
        min-width: 180px;
    }
}

/* Auth section, keep clear of hamburger on mobile */
@media (max-width: 480px) {
    .auth-section {
        top: 10px;
        right: 12px;
        gap: 8px;
    }
    .auth-section .user-info span,
    .auth-section .auth-btn span { font-size: 0.78rem; }
}

/* Sidebar touch targets */
@media (max-width: 1024px) {
    .sidebar-item { min-height: 44px; }
    .sidebar-sub-item { min-height: 40px; }
    .sidebar-footer-btn { min-height: 44px; }
}

/* Scroll-to-top button, don't overlap writing tools bar */
@media (max-width: 768px) {
    .scroll-top-btn { bottom: 72px; right: 14px; }
}

/* ═══════════════════════════════════════
   ENTRANCE ANIMATIONS
═══════════════════════════════════════ */
.anim-fade-in { animation: animFadeIn 0.6s ease-out both; }
.anim-fade-up { animation: animFadeUp 0.6s ease-out both; }
.anim-scale-in { animation: animScaleIn 0.5s ease-out both; }

.anim-d1 { animation-delay: 0.05s; }
.anim-d2 { animation-delay: 0.12s; }
.anim-d3 { animation-delay: 0.2s; }
.anim-d4 { animation-delay: 0.28s; }
.anim-d5 { animation-delay: 0.36s; }
.anim-d6 { animation-delay: 0.44s; }

@keyframes animFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes animFadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes animScaleIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }


/* ═══════════════════════════════════════════════════════════
   WONDER NOTES BRAND ADDITIONS
   Salford City Council · Professional UI enhancements
═══════════════════════════════════════════════════════════ */

/* ── Sidebar: Wonder Notes brand colours ── */
:root {
    --brand-purple:   #7B2FBE;
    --brand-pink:     #E3017E;
    --brand-orange:   #F5A623;
    --council-red:    #C41230;
}

/* Sidebar logo, transparent bg so the SVG illustration shows through */
.sidebar-logo {
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
}
.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Active item uses brand pink instead of plain accent */
.sidebar-item.active {
    background: linear-gradient(135deg, rgba(123,47,190,0.18) 0%, rgba(227,1,126,0.14) 100%) !important;
    color: #f472b6 !important;
    box-shadow: inset 0 0 0 1px rgba(227,1,126,0.2);
}
.sidebar-item.active::before { display: none !important; }

/* ══════════════════════════════════════════
   GLOBAL ANIMATIONS
══════════════════════════════════════════ */

/* Page content fade-in on load — only opacity, no transform on parent containers
   so position:fixed elements (sidebar) are never affected */
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
main, .page-content, [role="main"], .ds-page-content {
    animation: pageFadeIn 0.4s ease both;
}

/* Button ripple */
.btn, .btn-primary, .btn-secondary, button.auth-btn {
    position: relative; overflow: hidden;
}
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    width: 6px; height: 6px;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    animation: rippleAnim 0.55s linear;
    pointer-events: none;
}
@keyframes rippleAnim {
    to { transform: scale(60); opacity: 0; }
}

/* Upload zone pulse */
@keyframes uploadPulse {
    0%, 100% { border-color: rgba(123,47,190,0.3); box-shadow: 0 0 0 0 rgba(123,47,190,0); }
    50%       { border-color: rgba(227,1,126,0.5);  box-shadow: 0 0 0 6px rgba(227,1,126,0.06); }
}
.upload-zone {
    animation: uploadPulse 3s ease-in-out infinite;
}
.upload-zone:hover { animation: none; }

/* Transcript card hover lift */
.transcript-card {
    transition: all 0.2s cubic-bezier(0.22,1,0.36,1) !important;
}
.transcript-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
}

/* ══════════════════════════════════════════
   SIDEBAR ANIMATIONS
══════════════════════════════════════════ */

/* 1. Staggered slide-in on page load */
@keyframes sidebarItemIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}
.sidebar-item:nth-child(1) { animation: sidebarItemIn 0.4s ease 0.05s both; }
.sidebar-item:nth-child(2) { animation: sidebarItemIn 0.4s ease 0.10s both; }
.sidebar-item:nth-child(3) { animation: sidebarItemIn 0.4s ease 0.15s both; }
.sidebar-item:nth-child(4) { animation: sidebarItemIn 0.4s ease 0.20s both; }
.sidebar-item:nth-child(5) { animation: sidebarItemIn 0.4s ease 0.25s both; }
.sidebar-item:nth-child(6) { animation: sidebarItemIn 0.4s ease 0.30s both; }
.sidebar-item:nth-child(7) { animation: sidebarItemIn 0.4s ease 0.35s both; }
.sidebar-item:nth-child(8) { animation: sidebarItemIn 0.4s ease 0.40s both; }

/* 2. Hover shimmer sweep */
@keyframes hoverShimmer {
    from { transform: translateX(-100%); }
    to   { transform: translateX(200%); }
}
.sidebar-item { overflow: hidden; }
.sidebar-item::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    transform: translateX(-100%);
    pointer-events: none;
}
.sidebar-item:hover::after {
    animation: hoverShimmer 0.55s ease forwards;
}

/* 3. Active item breathing glow */
@keyframes activePulse {
    0%, 100% { box-shadow: inset 0 0 0 1px rgba(227,1,126,0.2), 0 0 0px rgba(227,1,126,0); }
    50%       { box-shadow: inset 0 0 0 1px rgba(227,1,126,0.4), 0 0 14px rgba(227,1,126,0.15); }
}
.sidebar-item.active {
    animation: activePulse 3s ease-in-out infinite !important;
}


/* ── Sidebar: Salford City Council badge ── */
.sidebar-council {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px 14px;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 4px;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-council { padding: 10px 14px; }

.sidebar-council-logo {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    object-fit: contain;
    flex-shrink: 0;
    background: white;
    padding: 2px;
}

.sidebar-council-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar-nav.collapsed .sidebar-council-text { opacity: 0; width: 0; }

.sidebar-council-label {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.25);
}

.sidebar-council-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.1px;
}

/* ── Auth section: floating top-right (improved) ── */
.auth-section {
    position: fixed !important;
    top: 14px;
    right: 20px;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-section .user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7B2FBE 0%, #E3017E 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    color: white;
    flex-shrink: 0;
    letter-spacing: -0.3px;
    box-shadow: 0 2px 8px rgba(227,1,126,0.3);
}

.auth-section .user-name {
    color: rgba(255,255,255,0.85);
    font-size: 0.82rem;
    font-weight: 500;
}

.auth-section .logout-btn {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 0.76rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.auth-section .logout-btn:hover {
    background: rgba(255,255,255,0.16);
    color: rgba(255,255,255,0.9);
}

.auth-section .auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.18);
    padding: 6px 14px;
    border-radius: 7px;
    font-size: 0.81rem;
    font-weight: 600;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s, border-color 0.15s;
}
.auth-section .auth-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.3);
    color: white;
}

/* ── Dark mode: system preference handled via JS (initTheme adds body.dark-mode) ── */
/* No CSS-only media query override here, it would incorrectly affect light-theme users */

/* ── Card hover transitions: tuned for snappiness ── */
.feature-card,
.tip-card,
.transcript-card,
.person-card,
.content-card {
    transition: transform 0.18s ease-out, box-shadow 0.15s ease-out, border-color 0.15s ease !important;
}

.feature-card:hover,
.tip-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
}

/* ── Form validation: field-level error styles ── */
.field-error {
    font-size: 0.78rem;
    color: #dc3545;
    margin-top: 4px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220,53,69,0.12) !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--brand-pink) !important;
    box-shadow: 0 0 0 3px rgba(227,1,126,0.12) !important;
    outline: none !important;
}

/* ── Button: loading state (supplement base.html definition) ── */
.btn-primary,
.btn-action-primary,
[class*="btn-submit"],
[type="submit"] {
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

[type="submit"]:active,
.btn-primary:active {
    transform: scale(0.98);
}

/* ── Scroll-to-top: use brand accent on hover ── */
.scroll-top-btn:hover {
    background: var(--brand-pink) !important;
    border-color: var(--brand-pink) !important;
    box-shadow: 0 4px 16px rgba(227,1,126,0.3) !important;
}

/* ── Toast: use brand gradient ── */
.wn-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 22px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    animation: wn-toast-in 0.25s ease-out both;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    max-width: 380px;
}

.wn-toast-success { background: #15803d; color: white; }
.wn-toast-error   { background: #b91c1c; color: white; }
.wn-toast-info    { background: linear-gradient(135deg, #7B2FBE, #E3017E); color: white; }

@keyframes wn-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Mobile auth: keep clear of hamburger ── */
@media (max-width: 480px) {
    .auth-section {
        top: 10px;
        right: 12px;
        gap: 6px;
    }
    .auth-section .user-name { display: none; }
    .auth-section .logout-btn { padding: 4px 9px; font-size: 0.72rem; }
}

/* ── Brand button shimmer sweep ── */
.btn-main,
.btn-brand,
[class*="btn-submit"],
.btn-generate {
    position: relative;
    overflow: hidden;
}
.btn-main::after,
.btn-brand::after,
[class*="btn-submit"]::after,
.btn-generate::after {
    content: '';
    position: absolute; top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}
.btn-main:hover::after,
.btn-brand:hover::after,
[class*="btn-submit"]:hover::after,
.btn-generate:hover::after {
    left: 150%;
}

/* ── Sidebar footer user card ── */
.sidebar-user-card-wrap { position: relative; margin: 0 10px 10px; overflow: hidden; }
.sidebar-user-card {
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    transition: background 0.15s;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}
.sidebar-user-card:hover { background: rgba(255,255,255,0.07); }

/* Dropdown */
.sidebar-user-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0; right: 0;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
    display: none;
    z-index: 300;
}
.sidebar-user-dropdown.open { display: block; }
.sud-header {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex; align-items: center; gap: 10px;
}
.sud-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #7B2FBE 0%, #E3017E 100%);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.72rem; color: white; flex-shrink: 0;
}
.sud-name { font-size: 0.8rem; font-weight: 600; color: rgba(255,255,255,0.85); }
.sud-role { font-size: 0.68rem; color: rgba(255,255,255,0.35); }
.sud-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 0; }
.sud-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    font-size: 0.82rem; color: rgba(255,255,255,0.65);
    cursor: pointer; transition: background 0.12s, color 0.12s;
    text-decoration: none; background: none; border: none; width: 100%;
}
.sud-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.sud-item.logout:hover { background: rgba(227,1,126,0.12); color: #E3017E; }
.sud-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-user-card-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #7B2FBE 0%, #E3017E 100%);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.72rem; color: white;
    flex-shrink: 0; letter-spacing: -0.3px;
    box-shadow: 0 2px 8px rgba(227,1,126,0.3);
}
.sidebar-user-card-info {
    flex: 1; min-width: 0;
    transition: opacity 0.2s;
}
.sidebar-nav.collapsed .sidebar-user-card-info { opacity: 0; width: 0; }
.sidebar-user-card-name {
    font-size: 0.8rem; font-weight: 600;
    color: rgba(255,255,255,0.85);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-card-role {
    font-size: 0.68rem; color: rgba(255,255,255,0.35);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Transcript card: brand accent on hover/selected ── */
.transcript-card:hover,
.transcript-card.selected {
    border-color: rgba(123,47,190,0.4) !important;
    background: rgba(123,47,190,0.05) !important;
    box-shadow: 0 0 0 3px rgba(123,47,190,0.08);
}
.transcript-card .tc-check {
    background: linear-gradient(135deg, #7B2FBE, #E3017E) !important;
}
.transcript-card .tc-icon {
    background: rgba(123,47,190,0.08) !important;
    color: var(--brand-purple) !important;
}

/* ── Feature card: gradient border glow on hover ── */
.feature-card {
    position: relative;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease !important;
}
.feature-card:hover {
    transform: translateY(-2px) !important;
    border-color: rgba(123,47,190,0.25) !important;
    box-shadow: 0 0 0 3px rgba(123,47,190,0.08), 0 12px 32px rgba(0,0,0,0.08) !important;
}

/* ── Noise texture, use .noise-overlay class on any dark container ── */
.noise-overlay {
    position: relative;
}
.noise-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

/* ── Sidebar tooltip: polished style ── */
.sidebar-tooltip {
    background: linear-gradient(135deg, #1a1a2e 0%, #2a1a4e 100%) !important;
    border: 1px solid rgba(123,47,190,0.25) !important;
    box-shadow: 0 4px 16px rgba(123,47,190,0.2) !important;
}

/* ════════════════════════════════════════════════════════════════
   RICH ANIMATION SYSTEM — Wonder Notes
   ════════════════════════════════════════════════════════════════ */

/* ── Scroll Reveal ────────────────────────────────────────────── */
.sr { opacity: 0; transform: translateY(28px); transition: opacity 0.6s cubic-bezier(0.4,0,0.2,1), transform 0.6s cubic-bezier(0.4,0,0.2,1); }
.sr.sr-left  { transform: translateX(-32px); }
.sr.sr-right { transform: translateX(32px); }
.sr.sr-scale { transform: scale(0.92); }
.sr.sr-up    { transform: translateY(28px); }
.sr.visible  { opacity: 1; transform: none; }
.sr.sr-d1 { transition-delay: 0.05s; }
.sr.sr-d2 { transition-delay: 0.12s; }
.sr.sr-d3 { transition-delay: 0.20s; }
.sr.sr-d4 { transition-delay: 0.30s; }
.sr.sr-d5 { transition-delay: 0.42s; }
.sr.sr-d6 { transition-delay: 0.56s; }
@media (prefers-reduced-motion: reduce) { .sr { opacity: 1 !important; transform: none !important; transition: none !important; } }

/* ── 3D Card Tilt ─────────────────────────────────────────────── */
.tilt-card { transform-style: preserve-3d; will-change: transform; transition: transform 0.15s ease-out, box-shadow 0.15s ease-out; }
.tilt-card:hover { box-shadow: 0 20px 60px rgba(123,47,190,0.22), 0 8px 24px rgba(0,0,0,0.12); }

/* ── Animated Gradient Text ───────────────────────────────────── */
.grad-text-anim {
    background: linear-gradient(90deg, #7B2FBE 0%, #E3017E 35%, #F5A623 65%, #7B2FBE 100%);
    background-size: 300% 100%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    animation: gradientShift 4s ease-in-out infinite;
}
@keyframes gradientShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ── Float / Breathe ──────────────────────────────────────────── */
.float-anim { animation: floatY 4s ease-in-out infinite; }
.float-anim-slow { animation: floatY 6s ease-in-out infinite; }
.breathe { animation: breathe 3.5s ease-in-out infinite; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.05); opacity: 1; } }

/* ── Stat Counter ─────────────────────────────────────────────── */
.stat-counter { font-variant-numeric: tabular-nums; }

/* ── Typewriter ───────────────────────────────────────────────── */
.typewriter-cursor::after { content: '|'; animation: cursorBlink 0.9s step-end infinite; color: #E3017E; margin-left: 2px; }
@keyframes cursorBlink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Skeleton Loader ──────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, #f0f1f8 25%, #e8eaf0 50%, #f0f1f8 75%); background-size: 200% 100%; animation: skeletonShimmer 1.6s ease-in-out infinite; border-radius: 8px; }
body.dark-mode .skeleton { background: linear-gradient(90deg, #252845 25%, #2e3158 50%, #252845 75%); background-size: 200% 100%; }
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Pulse Ring ───────────────────────────────────────────────── */
.pulse-ring { position: relative; }
.pulse-ring::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #7B2FBE; animation: pulseRingAnim 1.8s ease-out infinite; }
@keyframes pulseRingAnim { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.9); opacity: 0; } }

/* ── Slide Up Entrance ────────────────────────────────────────── */
@keyframes slideUpEntrance { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.slide-up-entrance { animation: slideUpEntrance 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ── Staggered Children ───────────────────────────────────────── */
.stagger-children > * { opacity: 0; transform: translateY(16px); transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.4,0,0.2,1); }
.stagger-children.visible > *:nth-child(1) { opacity: 1; transform: none; transition-delay: 0.04s; }
.stagger-children.visible > *:nth-child(2) { opacity: 1; transform: none; transition-delay: 0.10s; }
.stagger-children.visible > *:nth-child(3) { opacity: 1; transform: none; transition-delay: 0.17s; }
.stagger-children.visible > *:nth-child(4) { opacity: 1; transform: none; transition-delay: 0.25s; }
.stagger-children.visible > *:nth-child(5) { opacity: 1; transform: none; transition-delay: 0.34s; }
.stagger-children.visible > *:nth-child(6) { opacity: 1; transform: none; transition-delay: 0.44s; }
@media (prefers-reduced-motion: reduce) { .stagger-children > *, .stagger-children.visible > * { opacity: 1 !important; transform: none !important; transition: none !important; } }

/* ── Magnetic Button ──────────────────────────────────────────── */
.mag-btn { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); display: inline-block; }

/* ── Card Shimmer on Hover ────────────────────────────────────── */
.shimmer-hover { position: relative; overflow: hidden; }
.shimmer-hover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%); transform: translateX(-100%); transition: transform 0s; pointer-events: none; }
.shimmer-hover:hover::after { transform: translateX(100%); transition: transform 0.55s ease; }
body.dark-mode .shimmer-hover::after { background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.08) 50%, transparent 60%); }

/* ── Glow CTA ─────────────────────────────────────────────────── */
.glow-cta { position: relative; }
.glow-cta::before { content: ''; position: absolute; inset: -2px; border-radius: inherit; background: linear-gradient(135deg, #7B2FBE, #E3017E, #F5A623); opacity: 0; filter: blur(8px); transition: opacity 0.3s; z-index: -1; }
.glow-cta:hover::before { opacity: 0.7; }

/* ── Animated Focus Ring ──────────────────────────────────────── */
:focus-visible { outline: none; box-shadow: 0 0 0 0 rgba(123,47,190,0.5); animation: focusRingPop 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes focusRingPop { to { box-shadow: 0 0 0 3px rgba(123,47,190,0.4); } }

/* ══════════════════════════════════════════════════════════════
   FEATURE 1: Floating Labels
══════════════════════════════════════════════════════════════ */
.fl-wrap { position:relative; }
.fl-wrap .fl-label {
    position:absolute; left:13px; top:50%; transform:translateY(-50%);
    font-size:.875rem; color:#9ca3af; pointer-events:none;
    transition:top .2s ease, font-size .2s ease, color .2s ease, transform .2s ease;
    background:var(--surface); padding:0 4px; line-height:1;
}
.fl-wrap.fl-active .fl-label,
.fl-wrap.fl-filled .fl-label {
    top:0; transform:translateY(-50%); font-size:.72rem; color:var(--brand-purple);
}
body.dark-mode .fl-wrap .fl-label { background:#1e2140; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 2: Wrong Answer Shake
══════════════════════════════════════════════════════════════ */
@keyframes shakeX {
    0%,100% { transform:translateX(0); }
    15%     { transform:translateX(-8px); }
    30%     { transform:translateX(7px); }
    45%     { transform:translateX(-6px); }
    60%     { transform:translateX(5px); }
    75%     { transform:translateX(-3px); }
    90%     { transform:translateX(2px); }
}
.shake { animation:shakeX .55s cubic-bezier(.36,.07,.19,.97) both; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 3: Ripple on Buttons
══════════════════════════════════════════════════════════════ */
.ripple-host { position:relative; overflow:hidden; }
.ripple-circle {
    position:absolute; border-radius:50%;
    background:rgba(255,255,255,0.28); pointer-events:none;
    transform:scale(0); animation:rippleAnim .55s linear forwards;
}
body.dark-mode .ripple-circle { background:rgba(255,255,255,0.18); }
@keyframes rippleAnim { to { transform:scale(1); opacity:0; } }

/* ══════════════════════════════════════════════════════════════
   FEATURE 4: Copy-to-Clipboard Morph
══════════════════════════════════════════════════════════════ */
.copy-btn-copied svg.icon-copy { display:none; }
.copy-btn-copied svg.icon-check { display:block !important; }
.copy-btn svg.icon-check { display:none; }
@keyframes checkPop { 0%{transform:scale(0) rotate(-10deg)} 60%{transform:scale(1.25) rotate(3deg)} 100%{transform:scale(1) rotate(0)} }
.copy-btn-copied svg.icon-check { animation:checkPop .35s cubic-bezier(.34,1.56,.64,1) both; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 5: Auto-save Indicator
══════════════════════════════════════════════════════════════ */
#autosave-indicator {
    position:fixed; bottom:28px; left:calc(var(--sidebar-width,260px) + 16px);
    display:flex; align-items:center; gap:7px;
    font-size:.72rem; font-weight:600; color:#6b7280;
    background:var(--surface); border:1px solid var(--border-light);
    padding:5px 12px; border-radius:100px;
    opacity:0; pointer-events:none;
    transition:opacity .3s ease, transform .3s ease;
    transform:translateY(8px);
    box-shadow:0 2px 8px rgba(0,0,0,.08);
    z-index:800;
}
#autosave-indicator.visible { opacity:1; transform:translateY(0); }
#autosave-indicator .as-dot {
    width:7px; height:7px; border-radius:50%;
    background:#16a34a; flex-shrink:0;
    animation:asPulse 1.2s ease-in-out infinite;
}
#autosave-indicator.saved .as-dot { animation:none; background:#16a34a; }
#autosave-indicator.saved { color:#16a34a; }
@keyframes asPulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.6);opacity:.6} }
body.sidebar-collapsed #autosave-indicator { left:calc(68px + 16px); }

/* ══════════════════════════════════════════════════════════════
   FEATURE 7: Page Fade Transition
══════════════════════════════════════════════════════════════ */
/* page-transitioning targets only the content wrapper, NOT body —
   applying transform to body would break position:fixed on the sidebar */
body.page-transitioning main,
body.page-transitioning .page-content,
body.page-transitioning [role="main"],
body.page-transitioning .ds-page-content {
    animation: pageFadeOut .22s ease forwards;
}
@keyframes pageFadeOut { to { opacity:0; transform:translateY(-6px); } }

/* ══════════════════════════════════════════════════════════════
   FEATURE 8: Breadcrumb Stagger
══════════════════════════════════════════════════════════════ */
.breadcrumb > *, .breadcrumbs > *, nav[aria-label="breadcrumb"] > * > * {
    opacity:0; animation:breadcrumbIn .4s ease forwards;
}
.breadcrumb > *:nth-child(1), .breadcrumbs > *:nth-child(1) { animation-delay:.05s; }
.breadcrumb > *:nth-child(2), .breadcrumbs > *:nth-child(2) { animation-delay:.13s; }
.breadcrumb > *:nth-child(3), .breadcrumbs > *:nth-child(3) { animation-delay:.22s; }
.breadcrumb > *:nth-child(4), .breadcrumbs > *:nth-child(4) { animation-delay:.32s; }
@keyframes breadcrumbIn { from{opacity:0;transform:translateX(-10px)} to{opacity:1;transform:none} }

/* ══════════════════════════════════════════════════════════════
   FEATURE 9: Slot Counters
══════════════════════════════════════════════════════════════ */
.slot-flip { display:inline-block; overflow:hidden; vertical-align:bottom; }
.slot-flip-inner { display:flex; flex-direction:column; transition:transform .06s ease; }
.slot-flip-digit { line-height:1; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 10: Donut Chart Draw
══════════════════════════════════════════════════════════════ */
@keyframes donutDraw { from { stroke-dashoffset: var(--dash-total, 440); } }
.donut-segment { animation: donutDraw .9s cubic-bezier(.4,0,.2,1) both; }
.donut-segment:nth-child(2) { animation-delay:.1s; }
.donut-segment:nth-child(3) { animation-delay:.2s; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 11 & 12: Heatmap & Feed Animations
══════════════════════════════════════════════════════════════ */
@keyframes feedSlideIn { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:none} }
.feed-item-anim { opacity:0; animation:feedSlideIn .4s cubic-bezier(.4,0,.2,1) both; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 13: Mesh Gradient Ambient Background
══════════════════════════════════════════════════════════════ */
body::before {
    content:'';
    position:fixed; inset:0; z-index:-1; pointer-events:none;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(123,47,190,.07) 0%, transparent 60%),
        radial-gradient(ellipse 50% 60% at 80% 80%, rgba(227,1,126,.05) 0%, transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 50%, rgba(245,166,35,.03) 0%, transparent 60%);
    background-size:200% 200%;
    animation:meshShift 12s ease-in-out infinite alternate;
}
body.dark-mode::before {
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(123,47,190,.12) 0%, transparent 60%),
        radial-gradient(ellipse 50% 60% at 80% 80%, rgba(227,1,126,.08) 0%, transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 50%, rgba(245,166,35,.04) 0%, transparent 60%);
    background-size:200% 200%;
    animation:meshShift 12s ease-in-out infinite alternate;
}
@keyframes meshShift {
    0%   { background-position: 0% 0%, 100% 100%, 50% 50%; }
    33%  { background-position: 30% 70%, 70% 30%, 80% 20%; }
    66%  { background-position: 70% 30%, 30% 70%, 20% 80%; }
    100% { background-position: 100% 100%, 0% 0%, 50% 50%; }
}
@media (prefers-reduced-motion:reduce) { body::before { animation:none; } }

/* ══════════════════════════════════════════════════════════════
   FEATURE 15: Glassmorphism Cards
══════════════════════════════════════════════════════════════ */
.glass-card {
    background:rgba(255,255,255,0.65) !important;
    backdrop-filter:blur(16px) saturate(180%);
    -webkit-backdrop-filter:blur(16px) saturate(180%);
    border:1px solid rgba(255,255,255,0.4) !important;
    box-shadow:0 8px 32px rgba(123,47,190,.08), 0 1px 0 rgba(255,255,255,.6) inset;
}
body.dark-mode .glass-card {
    background:rgba(30,33,64,0.72) !important;
    border:1px solid rgba(255,255,255,0.08) !important;
    box-shadow:0 8px 32px rgba(0,0,0,.3), 0 1px 0 rgba(255,255,255,.06) inset;
}

/* ══════════════════════════════════════════════════════════════
   FEATURE 16: Morphing Blobs
══════════════════════════════════════════════════════════════ */
.morph-blob {
    position:absolute; border-radius:60% 40% 30% 70% / 60% 30% 70% 40%;
    animation:blobMorph 8s ease-in-out infinite alternate;
    pointer-events:none; z-index:0; filter:blur(40px);
}
@keyframes blobMorph {
    0%   { border-radius:60% 40% 30% 70% / 60% 30% 70% 40%; }
    25%  { border-radius:30% 60% 70% 40% / 50% 60% 30% 60%; }
    50%  { border-radius:50% 60% 30% 60% / 30% 40% 70% 50%; }
    75%  { border-radius:70% 30% 50% 50% / 40% 70% 40% 60%; }
    100% { border-radius:40% 60% 60% 40% / 60% 40% 60% 40%; }
}
@media (prefers-reduced-motion:reduce) { .morph-blob { animation:none; } }

/* ══════════════════════════════════════════════════════════════
   FEATURE 17: Module Card Flip
══════════════════════════════════════════════════════════════ */
/* flip-card: front stays in normal flow so card gets natural height;
   back is absolutely positioned and revealed on hover via 3D rotation */
.flip-card { perspective:1000px; }
a.th-card.flip-card { overflow:visible; } /* override th-card overflow:hidden so 3D works */
.flip-card-inner { position:relative; width:100%; transition:transform .6s cubic-bezier(.4,0,.2,1); transform-style:preserve-3d; }
.flip-card:hover .flip-card-inner { transform:rotateY(180deg); }
.flip-card-front {
    backface-visibility:hidden; -webkit-backface-visibility:hidden;
    border-radius:inherit;
}
.flip-card-back {
    position:absolute; inset:0; backface-visibility:hidden; -webkit-backface-visibility:hidden;
    border-radius:inherit; overflow:hidden;
    transform:rotateY(180deg);
    background:linear-gradient(135deg,#7B2FBE,#E3017E);
    color:#fff; display:flex; flex-direction:column;
    align-items:center; justify-content:center; padding:24px; text-align:center;
}
.flip-card-back-title { font-size:1rem; font-weight:800; margin-bottom:8px; }
.flip-card-back-desc { font-size:.8rem; opacity:.88; line-height:1.5; }
.flip-card-back-cta { margin-top:16px; padding:8px 20px; background:rgba(255,255,255,.2); border:1px solid rgba(255,255,255,.4); border-radius:100px; font-size:.78rem; font-weight:700; color:#fff; cursor:pointer; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 18: Quiz Progress Dots
══════════════════════════════════════════════════════════════ */
.quiz-progress-dots { display:flex; gap:8px; justify-content:center; margin-bottom:20px; }
.qpd { width:10px; height:10px; border-radius:50%; background:var(--border-light); border:2px solid var(--border-light); transition:all .35s cubic-bezier(.34,1.56,.64,1); }
.qpd.answered { background:var(--brand-purple); border-color:var(--brand-purple); transform:scale(1.2); }
.qpd.correct { background:#16a34a; border-color:#16a34a; transform:scale(1.3); }
.qpd.wrong { background:#ef4444; border-color:#ef4444; }
@keyframes dotPop { 0%{transform:scale(1)} 50%{transform:scale(1.6)} 100%{transform:scale(1.2)} }
.qpd.answered { animation:dotPop .4s cubic-bezier(.34,1.56,.64,1) forwards; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 20: Section Completion Checkmarks
══════════════════════════════════════════════════════════════ */
.mod-section-num { position:relative; }
.mod-section-num::after {
    content:'';
    position:absolute; inset:-2px;
    background:rgba(22,163,74,.0); border-radius:50%;
    border:2px solid transparent;
    transition:all .4s ease;
}
.mod-section-num.sec-done { background:#16a34a !important; color:#fff !important; border-color:#16a34a !important; }
.mod-section-num.sec-done::after { background:rgba(22,163,74,.15); border-color:#16a34a; }
@keyframes checkmarkDraw { from{stroke-dashoffset:24} to{stroke-dashoffset:0} }
.sec-check-svg { position:absolute; inset:0; pointer-events:none; }
.sec-check-path { stroke-dasharray:24; stroke-dashoffset:24; animation:checkmarkDraw .4s .1s ease forwards; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 21: Skeleton Screens
══════════════════════════════════════════════════════════════ */
.skeleton-list { display:flex; flex-direction:column; gap:8px; }
.skeleton-list .skeleton { height:52px; border-radius:10px; }

/* ══════════════════════════════════════════════════════════════
   FEATURE 22: Empty State Illustrations
══════════════════════════════════════════════════════════════ */
.empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:48px 24px; text-align:center; gap:12px; }
.empty-state-icon { width:64px; height:64px; border-radius:50%; background:rgba(123,47,190,.08); display:flex; align-items:center; justify-content:center; animation:emptyBreathe 3s ease-in-out infinite; }
.empty-state-icon svg { width:28px; height:28px; color:var(--brand-purple); }
.empty-state-title { font-size:1rem; font-weight:700; color:#1a1a2e; }
.empty-state-desc { font-size:.84rem; color:#9ca3af; max-width:280px; line-height:1.55; }
body.dark-mode .empty-state-title { color:rgba(255,255,255,.88); }
@keyframes emptyBreathe { 0%,100%{transform:scale(1);background:rgba(123,47,190,.08)} 50%{transform:scale(1.08);background:rgba(123,47,190,.14)} }

/* ══════════════════════════════════════════════════════════════
   FEATURE 23: Progressive Image Blur-up
══════════════════════════════════════════════════════════════ */
.blur-up { filter:blur(8px); transition:filter .4s ease; }
.blur-up.loaded { filter:blur(0); }
