:root {
    color-scheme: light;
    --bg: #fff8e8;
    --bg-2: #eaf7ff;
    --panel: #ffffff;
    --text: #203040;
    --muted: #667085;
    --border: #d9e7f2;
    --blue: #3d8bfd;
    --blue-dark: #2167d6;
    --yellow: #ffca3a;
    --green: #7ac943;
    --pink: #ff7ab6;
    --orange: #ff9f1c;
    --purple: #8f7cff;
    --danger: #d92d20;
    --success: #078552;
    --shadow: 0 18px 42px rgb(42 61 91 / 14%);
    --soft-shadow: 0 8px 20px rgb(42 61 91 / 10%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgb(255 202 58 / 22%), transparent 34%),
        linear-gradient(315deg, rgb(61 139 253 / 18%), transparent 38%),
        var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -80px;
    z-index: 20;
    border-radius: 10px;
    background: var(--text);
    color: #fff;
    padding: 10px 12px;
}

.skip-link:focus {
    top: 16px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgb(217 231 242 / 90%);
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(12px);
}

.nav-shell,
.page-shell,
.site-footer {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
}

.nav-shell {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand,
.nav-tabs a {
    text-decoration: none;
    font-weight: 900;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff;
    font-size: 0.86rem;
    box-shadow: var(--soft-shadow);
}

.nav-tabs {
    display: flex;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    padding: 5px;
}

.nav-tabs a {
    border-radius: 12px;
    color: var(--muted);
    padding: 10px 14px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-tabs a:hover,
.nav-tabs a.active {
    background: #e8f2ff;
    color: var(--blue-dark);
    transform: translateY(-1px);
}

.page-shell {
    padding: 28px 0 56px;
}

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

.login-card,
.panel,
.filter-bar,
.empty-state,
.message,
.teacher-lesson-card,
.student-workspace {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-card {
    width: min(430px, 100%);
    padding: 30px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--blue-dark);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 5vw, 3.5rem);
    line-height: 1.02;
}

h2 {
    margin-bottom: 14px;
    font-size: 1.28rem;
}

h3 {
    margin: 0 0 6px;
}

p {
    color: var(--muted);
    line-height: 1.55;
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
    border-radius: 28px;
    padding: 24px;
    background: linear-gradient(135deg, #fff, #f1fbff);
    box-shadow: var(--soft-shadow);
}

.teacher-hero {
    background: linear-gradient(135deg, #fff4cb, #e9f8ff 62%, #f5edff);
}

.student-hero {
    background: linear-gradient(135deg, #e8f7ff, #fff5d4 62%, #fce8f2);
}

.setup-hero {
    background: linear-gradient(135deg, #ecfdf3, #e8f2ff 62%, #fff4cb);
}

.page-heading.compact {
    margin-bottom: 16px;
}

.teacher-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.panel {
    padding: 22px;
}

.setup-panel {
    display: grid;
    gap: 18px;
}

.setup-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.setup-summary div,
.setup-result {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #f8fbff;
    padding: 14px;
}

.setup-summary span {
    display: block;
    margin-bottom: 6px;
    color: var(--blue-dark);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.setup-summary strong {
    overflow-wrap: anywhere;
}

.setup-result p {
    margin-bottom: 7px;
}

.setup-result p:last-child {
    margin-bottom: 0;
}

.setup-table-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.setup-table-list span {
    border-radius: 999px;
    background: #e8f2ff;
    color: var(--blue-dark);
    padding: 7px 10px;
    font-size: 0.84rem;
    font-weight: 900;
}

.action-panel {
    position: relative;
    overflow: hidden;
}

.action-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 8px;
}

.upload-panel::before {
    background: var(--blue);
}

.generate-panel::before {
    background: var(--green);
}

.panel-title {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.panel-title p {
    margin-bottom: 0;
}

.panel-icon {
    display: grid;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 14px;
    background: var(--yellow);
    color: #5f4200;
    font-weight: 900;
}

.simple-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 12px 13px;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
    outline: 4px solid rgb(61 139 253 / 18%);
    border-color: var(--blue);
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 900;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: var(--soft-shadow);
}

.button:disabled,
.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
    transform: none;
    box-shadow: none;
}

.button.primary {
    background: var(--blue);
    color: #fff;
}

.button.primary:hover {
    background: var(--blue-dark);
}

.button.secondary {
    background: var(--green);
    color: #173500;
}

.button.danger {
    background: #fff1f0;
    color: var(--danger);
    border-color: rgb(217 45 32 / 24%);
}

.button.edit-button {
    width: 100%;
    background: #fff8df;
    color: #7a5600;
    border-color: rgb(255 202 58 / 46%);
}

.message {
    margin-bottom: 16px;
    padding: 13px 15px;
    font-weight: 900;
}

.error-message {
    border-color: rgb(217 45 32 / 24%);
    background: #fff0ee;
    color: var(--danger);
}

.success-message {
    border-color: rgb(6 118 71 / 24%);
    background: #ecfdf3;
    color: var(--success);
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 28px 0 14px;
}

.section-row h2 {
    margin-bottom: 0;
}

.count-pill,
.lesson-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    background: #e8f2ff;
    color: var(--blue-dark);
    padding: 7px 11px;
    font-size: 0.84rem;
    font-weight: 900;
}

.teacher-lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
    gap: 14px;
}

.teacher-lesson-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.teacher-lesson-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 48px rgb(42 61 91 / 18%);
}

.teacher-card-main {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    min-width: 0;
}

.teacher-card-copy {
    min-width: 0;
}

.teacher-lesson-card img {
    width: 88px;
    height: 116px;
    border-radius: 16px;
    background: #132238;
    object-fit: cover;
}

.teacher-lesson-card p {
    margin-bottom: 0;
}

.teacher-card-tools {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(96px, 0.5fr) minmax(96px, 0.5fr);
    gap: 9px;
    align-items: start;
}

.teacher-card-tools form {
    margin: 0;
}

.order-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px;
    gap: 7px;
    align-items: center;
    border: 1px solid #d8ebf9;
    border-radius: 16px;
    background: #f5fbff;
    padding: 8px;
}

.order-box span {
    color: var(--blue-dark);
    font-size: 0.84rem;
    font-weight: 900;
}

.order-button {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: #fff;
    box-shadow: none;
}

.edit-drawer {
    min-width: 0;
}

.edit-drawer[open] {
    grid-column: 1 / -1;
    border: 1px solid rgb(255 202 58 / 45%);
    border-radius: 18px;
    background: #fffdf4;
    padding: 10px;
}

.edit-drawer summary {
    list-style: none;
}

.edit-drawer summary::-webkit-details-marker {
    display: none;
}

.edit-drawer[open] .edit-button {
    width: fit-content;
    min-width: 112px;
    margin-bottom: 10px;
}

.edit-form {
    display: grid;
    gap: 11px;
}

.edit-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.teacher-card-tools > form .button {
    width: 100%;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
    padding: 16px;
}

.student-workspace {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.student-workspace:focus {
    outline: 4px solid rgb(61 139 253 / 16%);
    outline-offset: 4px;
}

.lesson-stage {
    display: grid;
    grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    min-width: 0;
}

.stage-toolbar {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto 54px;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(135deg, #f8fbff, #fff8df);
    padding: 12px;
}

.slide-heading {
    min-width: 0;
}

.slide-heading span {
    display: block;
    color: var(--blue-dark);
    font-size: 0.88rem;
    font-weight: 900;
}

.slide-heading h2 {
    margin: 6px 0 4px;
    color: var(--blue-dark);
    font-size: clamp(1.3rem, 3vw, 1.95rem);
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.slide-heading p {
    margin: 0;
    color: var(--muted);
    font-weight: 900;
}

.icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--blue-dark);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 900;
    box-shadow: var(--soft-shadow);
}

.icon-button:focus-visible,
.lesson-thumb:focus-visible,
.slide-dots button:focus-visible,
.state-button:focus-visible {
    outline: 4px solid rgb(61 139 253 / 18%);
    outline-offset: 2px;
}

.viewer-nav-button {
    width: 54px;
    height: 54px;
    font-size: 1.35rem;
}

.student-progress {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    gap: 7px;
}

.student-progress span {
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    padding: 7px 10px;
    box-shadow: var(--soft-shadow);
}

.student-progress strong {
    color: var(--pink);
}

.lesson-rail {
    display: grid;
    align-content: start;
    gap: 10px;
    max-height: min(74vh, 760px);
    min-width: 0;
    overflow-y: auto;
    padding: 2px 4px 2px 2px;
    scrollbar-color: #b8cce0 transparent;
}

.lesson-thumb {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 2px 10px;
    align-items: center;
    width: 100%;
    min-height: 92px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fbff;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    text-align: left;
    transition: border 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.lesson-thumb:hover,
.lesson-thumb.active {
    border-color: rgb(61 139 253 / 50%);
    background: #eaf4ff;
    box-shadow: var(--soft-shadow);
    transform: translateY(-1px);
}

.lesson-thumb img {
    grid-row: 1 / span 4;
    width: 68px;
    height: 76px;
    border-radius: 12px;
    background: #101828;
    object-fit: cover;
}

.lesson-thumb-index,
.lesson-thumb small {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
}

.lesson-thumb strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 0.94rem;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lesson-thumb-states {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 20px;
}

.lesson-thumb .state-marker {
    margin-top: 0;
}

.stage-panel {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    min-width: 0;
}

.slide-stack {
    position: relative;
    height: clamp(430px, 74vh, 780px);
    min-height: 0;
    overflow: hidden;
    border-radius: 22px;
    background: linear-gradient(135deg, #0f172a, #1b2a55);
    box-shadow: 0 26px 54px rgb(42 61 91 / 20%);
    touch-action: pan-y;
}

.lesson-slide {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 14px;
    align-content: stretch;
    justify-content: stretch;
    padding: 16px;
    min-height: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translateX(38px) scale(0.98);
    transition: opacity 260ms ease, transform 260ms ease;
}

.lesson-slide.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

.lesson-slide.is-favorite .video-frame {
    box-shadow: 0 24px 58px rgb(255 122 182 / 28%);
}

.lesson-slide.is-completed .video-frame {
    border-color: #baf29a;
}

.video-frame {
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 6px solid #fff;
    border-radius: 20px;
    background: #101828;
    margin: 0 auto;
    box-shadow: 0 30px 62px rgb(0 0 0 / 30%);
}

.video-frame img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.student-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 0 4px;
}

.student-action-row.compact {
    margin-top: 12px;
}

.state-button {
    min-height: 42px;
    border: 2px solid rgb(255 255 255 / 50%);
    border-radius: 999px;
    background: rgb(255 255 255 / 16%);
    color: #fff;
    cursor: pointer;
    padding: 9px 13px;
    font-weight: 900;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease, border 160ms ease;
}

.state-button:hover {
    transform: translateY(-1px);
}

.state-button.is-favorite {
    border-color: #ffd1e5;
    background: #ffe7f1;
    color: #9f1454;
}

.state-button.is-completed {
    border-color: #c9f7b8;
    background: #e7ffd8;
    color: #246900;
}

.state-marker {
    display: none;
    width: fit-content;
    margin-top: 5px;
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 0.72rem;
    font-weight: 900;
}

.state-marker.is-visible {
    display: inline-flex;
}

.state-marker[data-state-marker="favorite"] {
    background: #ffe7f1;
    color: #9f1454;
}

.state-marker[data-state-marker="completed"] {
    background: #e7ffd8;
    color: #246900;
}

.slide-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.slide-dots button {
    width: 13px;
    height: 13px;
    border: 0;
    border-radius: 999px;
    background: #c9d8e8;
    cursor: pointer;
    transition: width 180ms ease, background 180ms ease;
}

.slide-dots button.active {
    width: 34px;
    background: var(--blue);
}

.empty-state {
    padding: 30px;
    text-align: center;
}

.site-footer {
    padding: 0 0 28px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .teacher-grid,
    .teacher-lessons-grid {
        grid-template-columns: 1fr;
    }

    .stage-toolbar {
        grid-template-columns: 50px minmax(0, 1fr) 50px;
    }

    .student-progress {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: center;
    }

    .lesson-stage {
        grid-template-columns: 1fr;
    }

    .stage-panel {
        order: 1;
    }

    .lesson-rail {
        order: 2;
        display: grid;
        grid-auto-columns: minmax(190px, 240px);
        grid-auto-flow: column;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 2px 2px 10px;
        scroll-snap-type: x proximity;
    }

    .lesson-thumb {
        scroll-snap-align: start;
    }

    .slide-stack {
        height: clamp(420px, 68vh, 700px);
    }
}

@media (max-width: 720px) {
    body {
        background: var(--bg-2);
    }

    .nav-shell,
    .page-heading {
        display: grid;
        grid-template-columns: 1fr;
    }

    .nav-shell {
        padding: 12px 0;
    }

    .nav-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .nav-tabs a {
        flex: 1;
        min-width: 92px;
        text-align: center;
    }

    .page-shell {
        width: min(100% - 18px, 1180px);
        padding-top: 14px;
    }

    .page-heading,
    .panel,
    .student-workspace {
        border-radius: 20px;
        padding: 16px;
    }

    .filter-bar {
        grid-template-columns: 1fr;
        border-radius: 20px;
    }

    .teacher-card-main,
    .teacher-card-tools,
    .edit-field-grid,
    .setup-summary {
        grid-template-columns: 1fr;
    }

    .teacher-lesson-card img {
        width: 100%;
        height: 180px;
    }

    .order-box {
        grid-template-columns: 1fr 44px 44px;
    }

    .button {
        width: 100%;
    }

    .stage-toolbar {
        grid-template-columns: 46px minmax(0, 1fr) 46px;
        gap: 8px;
        padding: 10px;
    }

    .viewer-nav-button {
        width: 46px;
        height: 46px;
    }

    .slide-heading h2 {
        font-size: 1.24rem;
    }

    .slide-heading p {
        font-size: 0.88rem;
    }

    .student-progress {
        gap: 6px;
    }

    .student-progress span {
        padding: 6px 9px;
        font-size: 0.86rem;
    }

    .lesson-stage {
        gap: 12px;
    }

    .lesson-rail {
        grid-auto-columns: minmax(168px, 78vw);
    }

    .lesson-thumb {
        grid-template-columns: 58px minmax(0, 1fr);
        min-height: 82px;
        border-radius: 14px;
    }

    .lesson-thumb img {
        width: 58px;
        height: 66px;
        border-radius: 10px;
    }

    .slide-stack {
        height: clamp(360px, 62vh, 540px);
        border-radius: 18px;
    }

    .lesson-slide {
        gap: 10px;
        padding: 10px;
    }

    .video-frame {
        border-width: 4px;
        border-radius: 16px;
    }

    .student-action-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 0;
    }

    .state-button {
        min-width: 0;
        padding: 8px 10px;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}
