/* ==========================================================================
   library-drawer.css — Classes / Chapters / Lessons drawer (#onenote-nav)
   Loaded after theme-override.css. Selectors are prefixed with
   `html body #onenote-nav.lib-drawer` so older global rules can't leak in.

   Layout
     ≥1100px : chapters and lessons side by side (760px drawer)
     <1100px : one pane at a time, chapter → lessons drill-down
     <600px  : full-screen sheet
   ========================================================================== */

html body #onenote-nav.lib-drawer {
    /* Tokens — dark (default) */
    --lib-bg: #0e1420;
    --lib-surface: #151c2b;
    --lib-raised: #1c2537;
    --lib-hover: rgba(255, 255, 255, 0.05);
    --lib-border: rgba(255, 255, 255, 0.08);
    --lib-text: #e9eef6;
    --lib-muted: #8c98ad;
    --lib-accent: #6d6afe;
    --lib-accent-soft: rgba(109, 106, 254, 0.16);
    --lib-accent-text: #ffffff;
    --lib-amber: #f59e0b;
    --lib-danger: #ef4444;
    --lib-success: #10b981;
    --lib-shadow: 24px 0 64px rgba(0, 0, 0, 0.45);
    --lib-radius: 16px;
    --lib-tap: 48px;
    --lib-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --lib-chapters-w: 300px;

    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0;
    width: 760px !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: var(--z-nav, 10000);

    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0) !important;

    background: var(--lib-bg) !important;
    color: var(--lib-text);
    border: none !important;
    border-right: 1px solid var(--lib-border) !important;
    box-shadow: var(--lib-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    touch-action: pan-x pan-y;

    transform: translateX(-104%);
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.42s var(--lib-ease), visibility 0s linear 0.42s !important;
}

/* responsive-scale.js zooms <body>; size to the body instead of the viewport */
html body.app-zoomed #onenote-nav.lib-drawer {
    height: 100% !important;
}

/* dark drawer: the indigo accent is too light under white button text (4.1:1) */
html[data-theme="dark"] body #onenote-nav.lib-drawer .lib-btn--primary:not(.lib-btn--amber) {
    background: #5C59EE;
}

html[data-theme="light"] body #onenote-nav.lib-drawer {
    --lib-bg: #f6f7fb;
    --lib-surface: #ffffff;
    --lib-raised: #eef1f7;
    --lib-hover: rgba(15, 23, 42, 0.045);
    --lib-border: rgba(15, 23, 42, 0.09);
    --lib-text: #152033;
    --lib-muted: #647189;
    --lib-accent: #5b57f0;
    --lib-accent-soft: rgba(91, 87, 240, 0.11);
    --lib-shadow: 24px 0 64px rgba(15, 23, 42, 0.16);
}

html body #onenote-nav.lib-drawer.show:not(.minimized) {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.42s var(--lib-ease), visibility 0s linear 0s !important;
}

html body #onenote-nav.lib-drawer *,
html body #onenote-nav.lib-drawer *::before,
html body #onenote-nav.lib-drawer *::after {
    box-sizing: border-box;
}

html body #onenote-nav.lib-drawer button {
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html body #onenote-nav.lib-drawer :focus-visible {
    outline: 2px solid var(--lib-accent);
    outline-offset: 2px;
}

/* ── Shared controls ──────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--lib-border);
    border-radius: 12px;
    background: var(--lib-surface);
    color: var(--lib-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.12s;
}

html body #onenote-nav.lib-drawer .lib-icon-btn:hover {
    background: var(--lib-raised);
    color: var(--lib-text);
}

html body #onenote-nav.lib-drawer .lib-icon-btn:active,
html body #onenote-nav.lib-drawer .lib-btn:active,
html body #onenote-nav.lib-drawer .lib-chip:active {
    transform: scale(0.96);
}

html body #onenote-nav.lib-drawer .lib-icon-btn--accent {
    background: var(--lib-accent);
    border-color: transparent;
    color: var(--lib-accent-text);
}

html body #onenote-nav.lib-drawer .lib-icon-btn--accent:hover {
    background: var(--lib-accent);
    color: var(--lib-accent-text);
    filter: brightness(1.08);
}

html body #onenote-nav.lib-drawer .lib-text-btn {
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--lib-accent);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

html body #onenote-nav.lib-drawer .lib-text-btn:hover {
    background: var(--lib-accent-soft);
}

html body #onenote-nav.lib-drawer .lib-btn {
    flex: 1;
    height: var(--lib-tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 16px;
    border: 1px solid var(--lib-border);
    border-radius: 14px;
    background: var(--lib-surface);
    color: var(--lib-text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, filter 0.15s, transform 0.12s;
}

html body #onenote-nav.lib-drawer .lib-btn:hover {
    background: var(--lib-raised);
}

html body #onenote-nav.lib-drawer .lib-btn i {
    font-size: 0.95em;
    opacity: 0.85;
}

html body #onenote-nav.lib-drawer .lib-btn--primary {
    background: var(--lib-accent);
    border-color: transparent;
    color: var(--lib-accent-text);
    box-shadow: 0 6px 18px -6px var(--lib-accent);
}

html body #onenote-nav.lib-drawer .lib-btn--primary:hover {
    background: var(--lib-accent);
    filter: brightness(1.08);
}

html body #onenote-nav.lib-drawer .lib-btn--primary.lib-btn--amber {
    background: var(--lib-amber);
    color: #1F2937;
    box-shadow: 0 6px 18px -6px var(--lib-amber);
}

html body #onenote-nav.lib-drawer .lib-count {
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--lib-raised);
    color: var(--lib-muted);
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ── Header ───────────────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 8px 20px;
    flex-shrink: 0;
}

html body #onenote-nav.lib-drawer .lib-profile {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 6px 6px;
    margin-inline-start: -6px;
    border: none;
    border-radius: 14px;
    /* ClassroomManager writes an inline background here; keep the drawer look */
    background: transparent !important;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s;
}

html body #onenote-nav.lib-drawer .lib-profile:hover {
    background: var(--lib-hover) !important;
}

html body #onenote-nav.lib-drawer .lib-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 14px;
    background: var(--lib-accent);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
}

html body #onenote-nav.lib-drawer .lib-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

html body #onenote-nav.lib-drawer .lib-profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

html body #onenote-nav.lib-drawer .lib-eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-profile-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--lib-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Class rail ───────────────────────────────────────────────────────── */

/* "Classes" label + always-visible Class Roster button */
html body #onenote-nav.lib-drawer .lib-classes-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 6px 16px 0 20px;
}

html body #onenote-nav.lib-drawer .lib-roster-btn {
    height: 40px;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid color-mix(in srgb, var(--lib-accent) 28%, transparent);
    border-radius: 12px;
    background: var(--lib-accent-soft);
    color: color-mix(in srgb, var(--lib-accent) 60%, var(--lib-text));
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.12s;
}

html body #onenote-nav.lib-drawer .lib-roster-btn:hover {
    background: var(--lib-accent);
    color: var(--lib-accent-text);
}

html body #onenote-nav.lib-drawer .lib-roster-btn:active {
    transform: scale(0.96);
}

html body #onenote-nav.lib-drawer .lib-classes {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 4px 16px 12px 0;
}

/* "+ New class" chip that leads the rail */
html body #onenote-nav.lib-drawer .lib-chip--new {
    border: 1.5px dashed color-mix(in srgb, var(--lib-accent) 55%, transparent);
    background: transparent;
    color: var(--lib-accent);
}

html body #onenote-nav.lib-drawer .lib-chip--new .lib-chip-initial {
    background: var(--lib-accent-soft);
    color: var(--lib-accent);
    font-size: 0.9rem;
}

html body #onenote-nav.lib-drawer .lib-chip--new:hover {
    background: var(--lib-accent-soft);
    border-style: solid;
}

/* ── No classes yet (teachers): guide to the Class Roster ─────────────── */

html body #onenote-nav.lib-drawer .lib-empty.lib-no-classes {
    display: none;
    flex: 1;
    overflow-y: auto;
}

html body.is-teacher #onenote-nav.lib-drawer.lib-no-classes-state:not(.lib-has-class) .lib-empty.lib-no-classes {
    display: flex;
}

html body.is-teacher #onenote-nav.lib-drawer.lib-no-classes-state .lib-pick-class,
html body #onenote-nav.lib-drawer.lib-no-classes-state .lib-classes-toggle {
    display: none;
}

html body #onenote-nav.lib-drawer .lib-no-classes-cta {
    flex: 0 0 auto;
    margin-top: 14px;
    padding: 0 22px;
}

html body #onenote-nav.lib-drawer .lib-steps {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: start;
}

html body #onenote-nav.lib-drawer .lib-steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    line-height: 1.35;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-step-num {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--lib-raised);
    color: var(--lib-text);
    font-size: 0.8rem;
    font-weight: 700;
}

html body #onenote-nav.lib-drawer .lib-steps li:first-child .lib-step-num {
    background: var(--lib-accent);
    color: var(--lib-accent-text);
}

html body #onenote-nav.lib-drawer .lib-classes-rail {
    flex: 1;
    min-width: 0;
}

html body #onenote-nav.lib-drawer .lib-classes-toggle {
    height: var(--lib-tap);
    margin-top: 2px;
}

/* "Show all classes": the row wraps into a scrollable grid */
html body #onenote-nav.lib-drawer.lib-classes-expanded .lib-classes-rail {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    align-content: start;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: min(42vh, 330px);
    overscroll-behavior: contain;
    touch-action: pan-y;
    scroll-snap-type: none;
    mask-image: none;
    -webkit-mask-image: none;
}

html body #onenote-nav.lib-drawer.lib-classes-expanded .lib-chip {
    max-width: none;
    min-width: 0;
    height: auto;
    min-height: var(--lib-tap);
    padding-block: 5px;
    padding-inline-end: 10px;
    text-align: start;
}

html body #onenote-nav.lib-drawer.lib-classes-expanded .lib-chip-name {
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

html body #onenote-nav.lib-drawer.lib-classes-expanded .lib-classes-toggle {
    background: var(--lib-accent-soft);
    color: var(--lib-accent);
    border-color: transparent;
}

html body #onenote-nav.lib-drawer .lib-classes-rail {
    display: flex;
    gap: 8px;
    padding: 2px 20px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 20px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
}

html body #onenote-nav.lib-drawer .lib-classes-rail::-webkit-scrollbar {
    display: none;
}

html body #onenote-nav.lib-drawer .lib-chip {
    --chip-accent: var(--lib-accent);
    height: var(--lib-tap);
    max-width: 220px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 0 6px;
    border: 1px solid var(--lib-border);
    border-radius: 14px;
    background: var(--lib-surface);
    color: var(--lib-text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    scroll-snap-align: start;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.2s, transform 0.12s;
}

html body #onenote-nav.lib-drawer .lib-chip:hover {
    background: var(--lib-raised);
}

html body #onenote-nav.lib-drawer .lib-chip-initial {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--chip-accent) 18%, transparent);
    color: var(--chip-accent);
    font-weight: 700;
    font-size: 1rem;
}

html body #onenote-nav.lib-drawer .lib-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html body #onenote-nav.lib-drawer .lib-class-chip.active {
    /* the per-class hue is too light for white text (2.5:1); deepen it under the label */
    background: color-mix(in srgb, var(--chip-accent) 60%, #141A33);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px -8px var(--chip-accent);
}

html body #onenote-nav.lib-drawer .lib-class-chip.active .lib-chip-initial {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

html body #onenote-nav.lib-drawer .lib-chip.is-archived {
    opacity: 0.6;
}

html body #onenote-nav.lib-drawer .lib-chip--archive {
    padding: 0 12px 0 16px;
    background: transparent;
    border-style: dashed;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-chip--archive.is-open {
    background: var(--lib-raised);
    color: var(--lib-text);
    border-style: solid;
}

/* ── Selected class bar ───────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-classbar {
    --chip-accent: var(--lib-accent);
    display: none;
    align-items: center;
    gap: 12px;
    margin: 0 16px 12px;
    padding: 10px 10px 10px 18px;
    border-radius: var(--lib-radius);
    background: linear-gradient(135deg, color-mix(in srgb, var(--chip-accent) 16%, var(--lib-surface)), var(--lib-surface));
    border: 1px solid var(--lib-border);
    flex-shrink: 0;
}

html body #onenote-nav.lib-drawer.lib-has-class .lib-classbar {
    display: flex;
}

html body #onenote-nav.lib-drawer .lib-classbar-title {
    flex: 1;
    min-width: 0;
}

html body #onenote-nav.lib-drawer .lib-classbar-name {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html body #onenote-nav.lib-drawer .lib-classbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Body & panes ─────────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    border-top: 1px solid var(--lib-border);
}

html body #onenote-nav.lib-drawer .lib-pane {
    min-width: 0;
    min-height: 0;
    display: none;
    flex-direction: column;
}

html body #onenote-nav.lib-drawer.lib-has-class .lib-pane {
    display: flex;
}

html body #onenote-nav.lib-drawer.lib-has-class .lib-pick-class {
    display: none;
}

html body #onenote-nav.lib-drawer .lib-chapters {
    width: var(--lib-chapters-w);
    flex-shrink: 0;
    border-right: 1px solid var(--lib-border);
    background: color-mix(in srgb, var(--lib-surface) 45%, var(--lib-bg));
}

html body #onenote-nav.lib-drawer .lib-lessons {
    flex: 1;
}

html body #onenote-nav.lib-drawer .lib-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 12px 10px 20px;
    flex-shrink: 0;
}

html body #onenote-nav.lib-drawer .lib-pane-head--lessons {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px 12px 20px;
}

html body #onenote-nav.lib-drawer .lib-pane-title {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-pane-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

html body #onenote-nav.lib-drawer .lib-lessons-titlerow {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}

html body #onenote-nav.lib-drawer .lib-chapter-title {
    flex: 1;
    min-width: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--lib-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html body #onenote-nav.lib-drawer .lib-back {
    display: none;
}

html body #onenote-nav.lib-drawer .lib-lessons-tools {
    display: flex;
    gap: 8px;
}

html body #onenote-nav.lib-drawer .lib-search,
html body #onenote-nav.lib-drawer .lib-sort {
    position: relative;
    height: 44px;
    display: flex;
    align-items: center;
    border: 1px solid var(--lib-border);
    border-radius: 12px;
    background: var(--lib-surface);
    color: var(--lib-muted);
    transition: border-color 0.15s, box-shadow 0.15s;
}

html body #onenote-nav.lib-drawer .lib-search {
    flex: 1;
    min-width: 0;
    padding-inline-start: 14px;
}

html body #onenote-nav.lib-drawer .lib-search:focus-within {
    border-color: var(--lib-accent);
    box-shadow: 0 0 0 3px var(--lib-accent-soft);
}

html body #onenote-nav.lib-drawer .lib-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 12px 0 10px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--lib-text);
    font: inherit;
    font-size: 16px; /* 16px stops iOS zooming on focus */
}

html body #onenote-nav.lib-drawer .lib-search input::placeholder {
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-search input::-webkit-search-cancel-button {
    cursor: pointer;
}

html body #onenote-nav.lib-drawer .lib-sort {
    flex-shrink: 0;
    padding-inline-start: 12px;
}

html body #onenote-nav.lib-drawer .lib-sort i {
    pointer-events: none;
}

html body #onenote-nav.lib-drawer .lib-sort select {
    height: 100%;
    padding: 0 12px 0 8px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--lib-text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

html body #onenote-nav.lib-drawer .lib-sort select option {
    background: var(--lib-surface);
    color: var(--lib-text);
}

html body #onenote-nav.lib-drawer .lib-lesson-actions {
    gap: 8px;
}

/* ── Lists & rows ─────────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 4px 12px 96px; /* bottom room for the floating bulk bar */
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--lib-border) transparent;
}

html body #onenote-nav.lib-drawer .lib-row {
    --row-accent: var(--lib-accent);
    position: relative;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 8px 8px;
    border-radius: 14px;
    color: var(--lib-text);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s, transform 0.12s;
    animation: libRowIn 0.28s var(--lib-ease) backwards;
}

html body #onenote-nav.lib-drawer .lib-row--lesson {
    min-height: 64px;
}

html body #onenote-nav.lib-drawer .lib-row:hover {
    background: var(--lib-hover);
}

html body #onenote-nav.lib-drawer .lib-row:active {
    transform: scale(0.985);
}

html body #onenote-nav.lib-drawer .lib-row.active {
    background: var(--lib-accent-soft);
}

html body #onenote-nav.lib-drawer .lib-row.active::before {
    content: '';
    position: absolute;
    inset-inline-start: -8px;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--lib-accent);
}

html body #onenote-nav.lib-drawer .lib-row-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--row-accent) 16%, transparent);
    color: var(--row-accent);
    font-size: 1rem;
}

html body #onenote-nav.lib-drawer .lib-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

html body #onenote-nav.lib-drawer .lib-row-title {
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

html body #onenote-nav.lib-drawer .lib-row.active .lib-row-title {
    color: var(--lib-accent);
}

html[data-theme="light"] body #onenote-nav.lib-drawer .lib-row.active .lib-row-title {
    color: var(--lib-accent);
}

html body #onenote-nav.lib-drawer .lib-row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 0.8rem;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-row-meta i {
    margin-inline-end: 3px;
}

html body #onenote-nav.lib-drawer .lib-badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--lib-raised);
    color: var(--lib-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

html body #onenote-nav.lib-drawer .lib-badge--amber {
    background: color-mix(in srgb, var(--lib-amber) 16%, transparent);
    color: var(--lib-amber);
}

html body #onenote-nav.lib-drawer .lib-badge--danger {
    background: color-mix(in srgb, var(--lib-danger) 16%, transparent);
    color: var(--lib-danger);
}

html body #onenote-nav.lib-drawer .lib-badge--done {
    background: color-mix(in srgb, var(--lib-success) 16%, transparent);
    color: var(--lib-success);
}

html body #onenote-nav.lib-drawer .lib-row.is-hidden .lib-row-icon {
    background: var(--lib-raised);
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-row.is-hidden .lib-row-title {
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lib-row-more {
    width: 40px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--lib-muted);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
}

html body #onenote-nav.lib-drawer .lib-row:hover .lib-row-more,
html body #onenote-nav.lib-drawer .lib-row.active .lib-row-more,
html body #onenote-nav.lib-drawer .lib-row-more:focus-visible {
    opacity: 1;
}

html body #onenote-nav.lib-drawer .lib-row-more:hover {
    background: var(--lib-raised);
    color: var(--lib-text);
}

/* Touch devices: keep the "more" button fully visible — there's no hover */
@media (hover: none) {
    html body #onenote-nav.lib-drawer .lib-row-more {
        opacity: 0.9;
    }
}

/* Selection mode */
html body #onenote-nav.lib-drawer .lib-check {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--lib-border);
    border-radius: 50%;
    color: transparent;
    font-size: 0.72rem;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

html body #onenote-nav.lib-drawer .lib-row.is-checked {
    background: var(--lib-accent-soft);
}

html body #onenote-nav.lib-drawer .lib-row.is-checked .lib-check {
    background: var(--lib-accent);
    border-color: var(--lib-accent);
    color: #fff;
}

html body #onenote-nav.lib-drawer.lib-selecting-chapters #btn-lib-select-chapters,
html body #onenote-nav.lib-drawer.lib-selecting-lessons #btn-lib-select-lessons {
    background: var(--lib-accent);
    color: var(--lib-accent-text);
}

/* Empty states & loading */
html body #onenote-nav.lib-drawer .lib-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    gap: 6px;
}

html body #onenote-nav.lib-drawer .lib-pick-class {
    flex: 1;
}

html body #onenote-nav.lib-drawer .lib-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: var(--lib-accent-soft);
    color: var(--lib-accent);
    font-size: 1.6rem;
}

html body #onenote-nav.lib-drawer .lib-empty-icon--amber {
    background: color-mix(in srgb, var(--lib-amber) 16%, transparent);
    color: var(--lib-amber);
}

html body #onenote-nav.lib-drawer .lib-empty-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--lib-text);
}

html body #onenote-nav.lib-drawer .lib-empty-sub {
    margin: 0;
    max-width: 260px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--lib-muted);
}

html body.is-teacher #onenote-nav.lib-drawer .lib-empty-sub.teacher-only {
    display: block !important;
}

html body #onenote-nav.lib-drawer .loading-spinner {
    display: flex;
    justify-content: center;
    padding: 40px 0;
    color: var(--lib-accent);
    font-size: 1.4rem;
}

/* ── Drag to reorder ──────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lib-chip,
html body #onenote-nav.lib-drawer .lib-row {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Touch: the item sinks slightly while the finger holds it, then lifts */
html body #onenote-nav.lib-drawer .lib-press {
    transform: scale(0.97);
    transition: transform 0.35s ease-out !important;
}

html body #onenote-nav.lib-drawer .lib-dragging {
    position: relative;
    z-index: 20;
    cursor: grabbing !important;
    transition: none !important;
    animation: none !important;
    background: var(--lib-surface) !important;
    box-shadow: 0 16px 36px -10px rgba(15, 23, 42, 0.45), 0 0 0 2px var(--lib-accent);
    will-change: transform;
}

html body #onenote-nav.lib-drawer .lib-class-chip.lib-dragging.active {
    background: var(--chip-accent) !important;
}

html body #onenote-nav.lib-drawer.lib-is-sorting,
html body #onenote-nav.lib-drawer.lib-is-sorting * {
    cursor: grabbing !important;
}

html body #onenote-nav.lib-drawer.lib-is-sorting .lib-row:hover:not(.lib-dragging),
html body #onenote-nav.lib-drawer.lib-is-sorting .lib-chip:hover:not(.lib-dragging) {
    background: inherit;
}

html body #onenote-nav.lib-drawer.lib-is-sorting .lib-row:not(.lib-dragging) {
    animation: none;
}

@keyframes libRowIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ── Narrow: single pane with drill-down (tablet portrait & below) ──── */

@media (max-width: 1099px) {
    html body #onenote-nav.lib-drawer {
        width: 440px !important;
    }

    html body #onenote-nav.lib-drawer .lib-body {
        overflow: hidden;
    }

    html body #onenote-nav.lib-drawer.lib-has-class .lib-pane {
        position: absolute;
        inset: 0;
        width: 100%;
        border-right: none;
        background: var(--lib-bg);
        transition: transform 0.34s var(--lib-ease);
    }

    html body #onenote-nav.lib-drawer .lib-lessons {
        transform: translateX(100%);
    }

    html body #onenote-nav.lib-drawer.lib-show-lessons .lib-chapters {
        transform: translateX(-30%);
    }

    html body #onenote-nav.lib-drawer.lib-show-lessons .lib-lessons {
        transform: translateX(0);
        box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
    }

    html body #onenote-nav.lib-drawer .lib-back {
        display: inline-flex;
    }

    /* RTL: slide the other way */
    html[dir="rtl"] body #onenote-nav.lib-drawer .lib-lessons {
        transform: translateX(-100%);
    }

    html[dir="rtl"] body #onenote-nav.lib-drawer.lib-show-lessons .lib-chapters {
        transform: translateX(30%);
    }

    html[dir="rtl"] body #onenote-nav.lib-drawer.lib-show-lessons .lib-lessons {
        transform: translateX(0);
    }

    html[dir="rtl"] body #onenote-nav.lib-drawer .lib-back i {
        transform: scaleX(-1);
    }
}

@media (max-width: 599px) {
    html body #onenote-nav.lib-drawer {
        width: 100vw !important;
        border-right: none !important;
    }

    html body.app-zoomed #onenote-nav.lib-drawer {
        width: 100% !important;
    }

    html body #onenote-nav.lib-drawer .lib-top {
        padding-inline: 16px 12px;
    }

    html body #onenote-nav.lib-drawer .lib-classes-rail {
        padding-inline: 16px;
    }

    html body #onenote-nav.lib-drawer .lib-classes {
        padding-inline-end: 12px;
    }

    html body #onenote-nav.lib-drawer .lib-classes-head {
        padding-inline: 16px 12px;
    }

    html body #onenote-nav.lib-drawer .lib-classbar {
        margin-inline: 12px;
        padding-inline-start: 14px;
    }

    html body #onenote-nav.lib-drawer .lib-classbar-actions .lib-icon-btn {
        width: 40px;
        min-width: 40px;
    }
}

/* ── RTL details ──────────────────────────────────────────────────────── */

html[dir="rtl"] body #onenote-nav.lib-drawer .lib-chapters {
    border-right: none;
    border-left: 1px solid var(--lib-border);
}

html[dir="rtl"] body #onenote-nav.lib-drawer .lib-row.active::before {
    border-radius: 4px 0 0 4px;
}

html[dir="rtl"] body #onenote-nav.lib-drawer .lib-classes-rail {
    mask-image: linear-gradient(to left, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to left, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
}

@media (prefers-reduced-motion: reduce) {
    html body #onenote-nav.lib-drawer,
    html body #onenote-nav.lib-drawer .lib-pane,
    html body #onenote-nav.lib-drawer .lib-row {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Compact density (Oct 2026) ───────────────────────────────────────────
   Less chrome above the lists so more chapters and lessons fit on screen.
   Every tap target stays ≥ 40px. Wide screens also get a wider drawer. */

html body #onenote-nav.lib-drawer .lib-top { padding: 10px 12px 2px 16px; gap: 10px; }
html body #onenote-nav.lib-drawer .lib-avatar { width: 38px; height: 38px; }
html body #onenote-nav.lib-drawer .lib-classes-head { min-height: 34px; padding: 0 12px 0 16px; }
html body #onenote-nav.lib-drawer .lib-roster-btn { height: 36px; padding: 0 12px; font-size: 0.84rem; }
html body #onenote-nav.lib-drawer .lib-classes { padding: 2px 12px 8px 0; }
html body #onenote-nav.lib-drawer .lib-classes-rail { padding: 2px 16px 4px; gap: 6px; }
html body #onenote-nav.lib-drawer .lib-chip { height: 42px; padding: 0 14px 0 5px; gap: 8px; }
html body #onenote-nav.lib-drawer .lib-chip-initial { width: 32px; height: 32px; }
html body #onenote-nav.lib-drawer .lib-classes-toggle { height: 42px; }
html body #onenote-nav.lib-drawer .lib-classbar { margin: 0 12px 8px; padding: 5px 6px 5px 14px; gap: 8px; }
html body #onenote-nav.lib-drawer .lib-classbar-name { font-size: 1.05rem; }
html body #onenote-nav.lib-drawer .lib-classbar-actions .lib-icon-btn { width: 40px; min-width: 40px; height: 40px; }
html body #onenote-nav.lib-drawer .lib-pane-head { padding: 8px 10px 6px 16px; }
html body #onenote-nav.lib-drawer .lib-pane-head--lessons { gap: 8px; padding: 8px 12px 8px 16px; }
html body #onenote-nav.lib-drawer .lib-pane-head .lib-icon-btn { width: 40px; min-width: 40px; height: 40px; }
html body #onenote-nav.lib-drawer .lib-text-btn { height: 36px; padding: 0 10px; }
html body #onenote-nav.lib-drawer .lib-lessons-titlerow { min-height: 36px; }
html body #onenote-nav.lib-drawer .lib-chapter-title { font-size: 1.1rem; }
html body #onenote-nav.lib-drawer .lib-search,
html body #onenote-nav.lib-drawer .lib-sort { height: 40px; }
html body #onenote-nav.lib-drawer .lib-lesson-actions .lib-btn { height: 42px; border-radius: 12px; }
html body #onenote-nav.lib-drawer .lib-list { padding: 2px 10px 96px; gap: 4px; }
html body #onenote-nav.lib-drawer .lib-row { min-height: 50px; padding: 6px 4px 6px 8px; gap: 10px; }
html body #onenote-nav.lib-drawer .lib-row--lesson { min-height: 54px; }
html body #onenote-nav.lib-drawer .lib-row-icon { width: 36px; height: 36px; }
html body #onenote-nav.lib-drawer .lib-row-more { width: 40px; height: 40px; }

@media (min-width: 1100px) {
    html body #onenote-nav.lib-drawer {
        width: min(880px, calc(var(--app-vw, 100vw) - 48px)) !important;
        --lib-chapters-w: 300px;
    }
}
