.ph-elearning-hero {
    border-bottom: 1px solid var(--ph-border);
    background: linear-gradient(180deg, #E9F0FE 0%, var(--ph-bg) 100%);
}

.ph-elearning-hero__inner {
    display: flex;
    min-height: 260px;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding-block: 44px;
}

.ph-elearning-eyebrow {
    margin: 0 0 8px;
    color: var(--ph-primary);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .12em;
}

.ph-elearning-hero h1,
.ph-elearning-detail h1 {
    margin: 0;
    font-family: Newsreader, "IBM Plex Sans Thai", Tahoma, serif;
    font-weight: 500;
    letter-spacing: -.025em;
}

.ph-elearning-hero h1 {
    font-size: 52px;
    line-height: 1.08;
}

.ph-elearning-hero__inner > div > p:last-child {
    max-width: 65ch;
    margin: 14px 0 0;
    color: var(--ph-text-muted);
    font-size: 17px;
}

.ph-elearning-library {
    padding-block: 42px 72px;
}

.ph-elearning-search {
    margin-bottom: 40px;
}

.ph-elearning-search > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.ph-elearning-search__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
}

.ph-elearning-search__row .ph-button,
.ph-elearning-back,
.ph-elearning-card__edit {
    min-height: 44px;
}

.ph-elearning-library__heading {
    margin-bottom: 22px;
}

.ph-elearning-library__heading h2 {
    margin: 0;
    font-size: 24px;
}

.ph-elearning-library__heading p {
    margin: 4px 0 0;
    color: var(--ph-text-subtle);
}

.ph-elearning-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.ph-elearning-card {
    display: flex;
    min-width: 0;
    overflow: hidden;
    flex-direction: column;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-card);
    background: var(--ph-surface);
    transition: border-color 180ms cubic-bezier(.22, 1, .36, 1), box-shadow 180ms cubic-bezier(.22, 1, .36, 1), transform 180ms cubic-bezier(.22, 1, .36, 1);
}

.ph-elearning-card__media {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-bottom: 1px solid var(--ph-border);
    background: var(--ph-code-bg);
}

.ph-elearning-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 200ms cubic-bezier(.22, 1, .36, 1);
}

.ph-elearning-card__placeholder {
    display: grid;
    height: 100%;
    place-items: center;
    color: var(--ph-code-text);
    font-size: 34px;
}

.ph-elearning-card__duration {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 4px 8px;
    border-radius: 7px;
    background: rgba(20, 26, 46, .88);
    color: #F5F7FC;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
}

.ph-elearning-card__body {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    padding: 20px;
}

.ph-elearning-card h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.35;
}

.ph-elearning-card h2 a,
.ph-elearning-card__edit,
.ph-elearning-back {
    color: inherit;
    text-decoration: none;
}

.ph-elearning-card h2 a:hover,
.ph-elearning-card__edit:hover,
.ph-elearning-back:hover {
    color: var(--ph-primary-strong);
}

.ph-elearning-card__body > p {
    display: -webkit-box;
    margin: 9px 0 0;
    overflow: hidden;
    color: var(--ph-text-muted);
    line-height: 1.65;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.ph-elearning-card__meta,
.ph-elearning-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    color: var(--ph-text-subtle);
    font-size: 13px;
}

.ph-elearning-card__meta {
    min-width: 0;
}

.ph-elearning-card__edit {
    display: inline-flex;
    align-items: center;
    color: var(--ph-primary-strong);
    font-weight: 600;
}

.ph-elearning-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 18px;
}

.ph-elearning-card__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ph-elearning-empty {
    padding: 70px 24px;
    border: 1px dashed var(--ph-border-control);
    border-radius: var(--ph-radius-section);
    text-align: center;
}

.ph-elearning-empty > span {
    display: block;
    margin-bottom: 14px;
    color: var(--ph-primary);
    font-size: 32px;
}

.ph-elearning-empty h2,
.ph-elearning-empty p {
    margin: 0;
}

.ph-elearning-empty p {
    margin-top: 8px;
    color: var(--ph-text-muted);
}

.ph-elearning-detail {
    max-width: 980px;
    padding-block: 38px 80px;
}

.ph-elearning-detail__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 40px;
}

.ph-elearning-back {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
}

.ph-elearning-detail__header {
    max-width: 74ch;
    margin-bottom: 0;
}

.ph-elearning-detail h1 {
    font-size: 46px;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.ph-elearning-detail__description {
    margin: 14px 0;
    color: var(--ph-text-muted);
    font-size: 18px;
    line-height: 1.65;
}

.ph-elearning-player-frame {
    overflow: hidden;
    aspect-ratio: 16 / 9;
    margin-top: 28px;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-card);
    background: var(--ph-code-bg);
}

.ph-elearning-player {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ph-elearning-prose {
    max-width: 72ch;
    margin: 42px auto 0;
    color: var(--ph-text);
    font-size: 17px;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

.ph-elearning-prose > h2:first-child {
    margin-top: 0;
    font-size: 26px;
}

.ph-elearning-prose img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.ph-elearning-table {
    overflow-x: auto;
}

.ph-elearning-admin,
.ph-elearning-form-page {
    padding-block: 42px 72px;
}

.ph-elearning-admin__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.ph-elearning-admin__filters {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(170px, auto) auto auto;
    gap: 10px;
    margin-block: 28px 20px;
}

.ph-elearning-admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-card);
    background: var(--ph-surface);
}

.ph-elearning-admin-table {
    width: 100%;
    table-layout: fixed;
    min-width: 1080px;
    border-collapse: collapse;
    font-size: 14px;
}

.ph-elearning-admin-col--lesson { width: auto; }
.ph-elearning-admin-col--duration { width: 108px; }
.ph-elearning-admin-col--views { width: 72px; }
.ph-elearning-admin-col--status { width: 78px; }
.ph-elearning-admin-col--updated { width: 104px; }
.ph-elearning-admin-col--actions { width: 320px; }

.ph-elearning-admin-table th,
.ph-elearning-admin-table td {
    padding: 14px;
    border-bottom: 1px solid var(--ph-border);
    text-align: left;
    vertical-align: middle;
}

.ph-elearning-admin-table thead th {
    background: var(--ph-primary-softer);
    color: var(--ph-text-muted);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .025em;
}

.ph-elearning-admin-table tbody tr:last-child > * {
    border-bottom: 0;
}

.ph-elearning-admin-item {
    display: flex;
    min-width: 260px;
    align-items: center;
    gap: 12px;
}

.ph-elearning-admin-item img,
.ph-elearning-admin-item > span {
    width: 96px;
    aspect-ratio: 16 / 9;
    flex: 0 0 96px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--ph-code-bg);
}

.ph-elearning-admin-item > span {
    display: grid;
    place-items: center;
    color: var(--ph-code-text);
}

.ph-elearning-admin-item div,
.ph-elearning-admin-table td {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ph-elearning-admin-item strong,
.ph-elearning-admin-item code,
.ph-elearning-admin-table td > small {
    display: block;
}

.ph-elearning-admin-item code,
.ph-elearning-admin-table td > small {
    margin-top: 4px;
    color: var(--ph-text-subtle);
    font-size: 12px;
}

.ph-elearning-admin-table__meta {
    white-space: nowrap;
}

.ph-elearning-admin-actions {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ph-elearning-admin-actions form {
    margin: 0;
}

.ph-elearning-admin-actions .ph-inline-confirm {
    position: relative;
    min-width: 0;
}

.ph-elearning-admin-actions .ph-inline-confirm > summary {
    list-style: none;
}

.ph-elearning-admin-actions .ph-inline-confirm > summary::-webkit-details-marker {
    display: none;
}

.ph-elearning-admin-actions .ph-inline-confirm__panel {
    position: absolute;
    z-index: 20;
    right: 0;
    top: calc(100% + 8px);
    width: min(320px, calc(100vw - 32px));
    max-width: none;
    padding: 14px;
    border: 1px solid #EDC3BC;
    border-radius: 11px;
    background: var(--ph-surface);
    box-shadow: 0 16px 34px -18px rgba(27, 30, 26, .42);
}

.ph-elearning-admin-actions .ph-inline-confirm__panel p {
    margin: 0 0 12px;
    overflow-wrap: anywhere;
    color: var(--ph-text-muted);
}

.ph-elearning-admin-table-wrap:has(.ph-inline-confirm[open]) {
    padding-bottom: 150px;
}

.ph-elearning-form-page {
    max-width: 816px;
}

.ph-elearning-form {
    max-width: 760px;
}

.ph-elearning-form .ph-form-section > header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.ph-elearning-form .ph-form-section > header > div {
    min-width: 0;
    flex: 1;
}

.ph-elearning-form .ph-form-section > header h2,
.ph-elearning-form .ph-form-section > header p {
    margin: 0;
}

.ph-elearning-form .ph-form-section > header > div > p {
    margin-top: 3px;
    color: var(--ph-text-subtle);
    font-size: 14px;
}

.ph-elearning-form .ph-form-section__step {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border-radius: 50%;
    background: var(--ph-primary-soft);
    color: var(--ph-primary-strong) !important;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.ph-elearning-form .ph-textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border: 1px solid var(--ph-border-control);
    border-radius: var(--ph-radius-control);
    background: var(--ph-surface);
    color: var(--ph-text);
    font: inherit;
    line-height: 1.6;
    resize: vertical;
}

.ph-elearning-form .ph-elearning-editor {
    min-height: 420px;
}

.ph-elearning-form .ph-textarea:focus-visible {
    border-color: var(--ph-primary);
    box-shadow: var(--ph-focus);
    outline: 0;
}

.ph-elearning-video-preview {
    display: grid;
    gap: 8px;
    min-width: 0;
    margin: 0;
}

.ph-elearning-video-preview[hidden] {
    display: none;
}

.ph-elearning-video-preview video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--ph-radius-control);
    background: var(--ph-code-bg);
    object-fit: contain;
}

.ph-elearning-video-preview video[hidden] {
    display: none;
}

.ph-elearning-video-preview figcaption {
    color: var(--ph-text-muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.ph-elearning-upload-status {
    padding: 18px;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-control);
    background: var(--ph-bg);
}

.ph-elearning-upload-status > p {
    margin-top: 0;
}

.ph-elearning-upload-status progress {
    width: 100%;
    height: 12px;
    accent-color: var(--ph-primary);
}

.ph-elearning-upload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.ph-elearning-upload-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin: 12px 0 0;
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius-control);
    background: var(--ph-border);
}

.ph-elearning-upload-meta > div {
    padding: 12px;
    background: var(--ph-surface);
}

.ph-elearning-upload-meta dt {
    color: var(--ph-text-subtle);
    font-size: 12px;
}

.ph-elearning-upload-meta dd {
    margin: 4px 0 0;
    font-weight: 600;
}

.ph-elearning-cover-preview {
    display: block;
    width: min(100%, 480px);
    aspect-ratio: 16 / 9;
    margin-bottom: 12px;
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    object-fit: cover;
}

.ph-elearning-cover-field {
    margin-top: 18px;
}

.ph-elearning-editor-upload {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--ph-border);
    border-radius: 12px;
    background: var(--ph-primary-softer);
}

.ph-elearning-editor-upload h3,
.ph-elearning-editor-upload p {
    margin: 0;
}

.ph-elearning-editor-upload > p {
    color: var(--ph-text-muted);
    font-size: 14px;
}

.ph-elearning-editor-upload .ph-button {
    justify-self: start;
}

.ph-elearning-admin :where(a, button, input, select, textarea, summary),
.ph-elearning-form-page :where(.ph-button, .ph-input, .ph-select, .ph-textarea, .ph-back-link) {
    min-height: 44px;
}

.ph-elearning-admin-table-wrap:focus-visible,
.ph-elearning-admin :where(a, button, input, select, summary):focus-visible,
.ph-elearning-form-page :where(.ph-button, .ph-input, .ph-select, .ph-textarea, .ph-back-link):focus-visible {
    outline: 3px solid var(--ph-primary);
    outline-offset: 3px;
}

.ph-elearning-card :focus-visible,
.ph-elearning-search :focus-visible,
.ph-elearning-detail :focus-visible,
.ph-elearning-table:focus-visible {
    outline: 3px solid var(--ph-primary);
    outline-offset: 3px;
}

@media (hover: hover) {
    .ph-elearning-card:hover {
        transform: translateY(-2px);
        border-color: var(--ph-border-control);
        box-shadow: 0 16px 34px -28px rgba(27, 30, 26, .55);
    }
    .ph-elearning-card:hover .ph-elearning-card__media img { transform: scale(1.015); }
}

@media (max-width: 1023px) {
    .ph-elearning-form .ph-elearning-editor { min-height: 320px; }
    .ph-elearning-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ph-elearning-hero h1 { font-size: 44px; }
    .ph-elearning-admin__filters { grid-template-columns: minmax(0, 1fr) minmax(160px, auto) auto; }
    .ph-elearning-admin__filters .ph-button--quiet { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 767px) {
    .ph-elearning-hero__inner { min-height: 0; flex-direction: column; align-items: flex-start; padding-block: 36px; }
    .ph-elearning-hero h1 { font-size: 38px; }
    .ph-elearning-library, .ph-elearning-detail { padding-inline: 16px; }
    .ph-elearning-search__row { grid-template-columns: 1fr; }
    .ph-elearning-search__row .ph-button { width: 100%; }
    .ph-elearning-grid { grid-template-columns: 1fr; }
    .ph-elearning-detail__toolbar { align-items: flex-start; flex-direction: column; margin-bottom: 30px; }
    .ph-elearning-detail h1 { font-size: 36px; }
    .ph-elearning-detail__description { font-size: 16px; }
    .ph-elearning-player-frame { margin-inline: -16px; border-right: 0; border-left: 0; border-radius: 0; }
    .ph-elearning-prose { margin-top: 34px; font-size: 16px; }
    .ph-elearning-admin, .ph-elearning-form-page { padding-inline: 16px; }
    .ph-elearning-admin__heading { flex-direction: column; }
    .ph-elearning-admin__filters { grid-template-columns: 1fr; }
    .ph-elearning-admin__filters .ph-button--quiet { grid-column: auto; justify-self: stretch; }
    .ph-elearning-admin-table-wrap { overflow: visible; border: 0; background: transparent; }
    .ph-elearning-admin-table { min-width: 0; }
    .ph-elearning-admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .ph-elearning-admin-table, .ph-elearning-admin-table tbody, .ph-elearning-admin-table tr, .ph-elearning-admin-table th, .ph-elearning-admin-table td { display: block; width: 100%; }
    .ph-elearning-admin-table tr { margin-bottom: 14px; padding: 14px; border: 1px solid var(--ph-border); border-radius: var(--ph-radius-card); background: var(--ph-surface); }
    .ph-elearning-admin-table th, .ph-elearning-admin-table td { display: grid; grid-template-columns: minmax(90px, .38fr) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--ph-border); }
    .ph-elearning-admin-table th::before, .ph-elearning-admin-table td::before { content: attr(data-label); color: var(--ph-text-subtle); font-size: 12px; font-weight: 600; }
    .ph-elearning-admin-table th[data-label="บทเรียน"] { grid-template-columns: 1fr; }
    .ph-elearning-admin-table th[data-label="บทเรียน"]::before { display: none; }
    .ph-elearning-admin-table__meta { white-space: normal; }
    .ph-elearning-admin-actions { display: grid; grid-template-columns: 1fr; min-width: 0; }
    .ph-elearning-admin-actions .ph-button, .ph-elearning-admin-actions form, .ph-elearning-admin-actions details, .ph-elearning-admin-actions form .ph-button { width: 100%; }
    .ph-elearning-admin-table-wrap:has(.ph-inline-confirm[open]) { padding-bottom: 0; }
    .ph-elearning-admin-actions .ph-inline-confirm__panel { position: static; width: 100%; max-width: none; margin-top: 8px; box-shadow: none; }
    .ph-elearning-upload-actions { display: grid; grid-template-columns: 1fr; }
    .ph-elearning-upload-meta { grid-template-columns: 1fr; }
    .ph-elearning-editor-upload { padding: 16px; }
    .ph-elearning-editor-upload .ph-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .ph-elearning-card,
    .ph-elearning-card__media img { transition: none; }
    .ph-elearning-card:hover,
    .ph-elearning-card:hover .ph-elearning-card__media img { transform: none; }
}
