:root {
    --ink: #161522;
    --ink-soft: #63617a;
    --paper: #FAFAF9;
    --panel: #ffffff;
    --line: #ECEAF3;

    /* Primary Brand: IH Blue (replaced purple) */
    --indigo: #0B5FFF;
    --indigo-deep: #0847cc;
    --indigo-light: #EFF4FF;
    --indigo-border: #DBE7FE;

    --sun: #FFC93C;
    --sun-deep: #F0AF0C;
    --coral: #F4867C;
    --coral-deep: #EE6E62;
    --lav: #B9AEFB;
    --lav-deep: #9C8CF7;
    --sky: #6FC1E8;
    --sky-deep: #4CA9D6;

    --radius-lg: 22px;
    --radius-md: 14px;
    --shadow-card: 0 1px 3px rgba(22, 21, 34, .04), 0 10px 24px -14px rgba(22, 21, 34, .14);
    --shadow-card-hover: 0 4px 12px rgba(11, 95, 255, .08), 0 20px 36px -16px rgba(11, 95, 255, .22);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.display-font {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

a {
    text-decoration: none;
    color: inherit;
}

:focus-visible {
    outline: 2.5px solid var(--indigo);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ===== App shell ===== */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

/* ===== Sidebar ===== */
.sidebar {
    --w: 278px;
    width: var(--w);
    flex: 0 0 var(--w);
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 28px 18px;
    transition: margin-left .32s cubic-bezier(.4, 0, .2, 1), opacity .22s ease;
}

.sidebar.is-collapsed {
    margin-left: calc(-1 * var(--w));
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 991.98px) {
    .sidebar.is-collapsed {
        margin-left: 0;
        opacity: 1;
        pointer-events: auto;
    }
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8E8BA7;
    margin: 4px 6px 14px;
}

.course-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.course-item {
    margin-bottom: 4px;
}

.course-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 13px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--ink);
    font-weight: 600;
    font-size: .90rem;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.course-btn .course-name {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.course-btn .course-name i {
    width: 18px;
    color: #9D9BB5;
    font-size: .88rem;
    transition: color .15s ease;
}

.course-btn:hover {
    background: var(--indigo-light);
    color: var(--indigo);
}

.course-btn:hover .course-name i {
    color: var(--indigo);
}

.course-btn .chev {
    color: #C9C6DC;
    font-size: .78rem;
    transition: transform .15s ease;
}

.course-btn.active {
    background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    color: #fff;
    box-shadow: 0 8px 20px -6px rgba(11, 95, 255, .5);
}

.course-btn.active .course-name i {
    color: #fff;
}

.course-btn.active .chev {
    color: rgba(255, 255, 255, .85);
}

.course-btn .count {
    font-size: .72rem;
    font-weight: 700;
    color: #8E8BA7;
    background: #F1F0F8;
    padding: 2px 7px;
    border-radius: 20px;
    margin-right: 4px;
    margin-left: auto;
}

.course-btn.active .count {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

/* ===== Main Area ===== */
.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 26px 36px 60px;
}

@media (max-width: 575.98px) {
    .main {
        padding: 18px 16px 48px;
    }
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1.5px solid var(--line);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    color: var(--ink);
    flex: 0 0 auto;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}

.icon-btn:hover {
    background: var(--indigo-light);
    border-color: var(--indigo-border);
    color: var(--indigo);
}

.icon-btn:active {
    transform: scale(.95);
}

.page-title {
    font-weight: 800;
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    letter-spacing: -.02em;
    color: var(--ink);
    margin: 0;
}

.page-sub {
    color: var(--ink-soft);
    font-size: .95rem;
    margin: 4px 0 0;
    max-width: 680px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-wrap {
    flex: 1 1 320px;
    min-width: 220px;
}

.search-input-group {
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 13px;
    display: flex;
    align-items: center;
    padding: 2px 8px 2px 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.search-input-group:focus-within {
    border-color: var(--indigo);
    box-shadow: 0 0 0 4px rgba(11, 95, 255, .12);
}

.search-input-group i {
    color: #A7A4BE;
    font-size: .98rem;
}

.search-input-group input {
    border: none;
    outline: none;
    padding: 10px 8px;
    flex: 1;
    font-size: .92rem;
    background: transparent;
    font-family: inherit;
    color: var(--ink);
}

.search-clear {
    border: none;
    background: none;
    color: #C9C6DC;
    font-size: 1rem;
    padding: 6px;
    display: none;
    cursor: pointer;
    transition: color .15s ease;
}

.search-clear:hover {
    color: var(--indigo);
}

.search-clear.show {
    display: inline-flex;
    align-items: center;
}

.view-toggle {
    display: flex;
    border: 1.5px solid var(--line);
    border-radius: 13px;
    padding: 3px;
    background: #fff;
}

.view-toggle button {
    border: none;
    background: transparent;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #A7A4BE;
    font-size: .95rem;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.view-toggle button.active {
    background: var(--ink);
    color: #fff;
}

.result-meta {
    font-size: .86rem;
    color: var(--ink-soft);
    margin-bottom: 20px;
}

.result-meta strong {
    color: var(--ink);
}

/* ===== Tutorial Cards (Grid & List View) ===== */
.tut-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform .2s cubic-bezier(.4, 0, .2, 1), box-shadow .2s ease, border-color .2s ease;
}

.tut-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
    border-color: #D3E0FC;
}

.thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0D1B3E;
}

.cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.tut-card:hover .cover-img {
    transform: scale(1.03);
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(13, 27, 62, 0.85);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    z-index: 1;
    letter-spacing: .02em;
}

.play-chip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(11, 95, 255, 0.95);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: all .2s ease;
    box-shadow: 0 6px 18px rgba(11, 95, 255, .4);
    z-index: 2;
}

.tut-card:hover .play-chip {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.card-body-x {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card-meta-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-title-x {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -.01em;
    line-height: 1.35;
    color: var(--ink);
    margin: 0;
}

.card-desc-x {
    font-size: .86rem;
    color: var(--ink-soft);
    line-height: 1.45;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-action-bar {
    margin-top: auto;
    padding-top: 4px;
}

.btn-watch {
    font-size: .82rem;
    font-weight: 700;
    color: var(--indigo);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color .15s ease;
}

.tut-card:hover .btn-watch {
    color: var(--indigo-deep);
}

.tag-pill {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--indigo-light);
    border: 1px solid var(--indigo-border);
    color: var(--indigo);
    font-size: .74rem;
    font-weight: 700;
}

/* ==========================================================
   LIST VIEW OPTIMIZATION & CARD WIDTH CORRECTION
   ========================================================== */
#cardGrid.list-view .col-wrap {
    width: 100%;
    max-width: 100%;
    margin-bottom: 6px;
}

#cardGrid.list-view .tut-card {
    flex-direction: row;
    align-items: stretch;
    min-height: 148px;
    max-height: 180px;
}

#cardGrid.list-view .thumb {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    height: 100%;
    aspect-ratio: 16/9;
    flex: 0 0 250px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    overflow: hidden;
}

#cardGrid.list-view .card-body-x {
    padding: 16px 24px;
    justify-content: center;
    gap: 6px;
}

#cardGrid.list-view .card-title-x {
    font-size: 1.12rem;
}

#cardGrid.list-view .card-desc-x {
    -webkit-line-clamp: 2;
}

@media (max-width: 767.98px) {
    #cardGrid.list-view .tut-card {
        flex-direction: column;
        min-height: 0;
        max-height: none;
    }

    #cardGrid.list-view .thumb {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        flex: auto;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    #cardGrid.list-view .card-body-x {
        padding: 16px 18px 18px;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--ink-soft);
}

.empty-state i {
    font-size: 2.6rem;
    color: #D0CEE5;
    margin-bottom: 14px;
    display: block;
}

/* Modal */
.modal-content {
    border-radius: 18px;
    border: none;
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--line);
    padding: 16px 20px;
}

.modal-title {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--ink);
}

.modal-body {
    padding: 0;
    background: #0b0b12;
}

/* Sidebar mobile offcanvas */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        z-index: 1045;
        top: 0;
        bottom: 0;
        left: 0;
        box-shadow: 0 0 0 100vmax rgba(15, 14, 26, 0.4);
    }
}