/* Content materials studio (T-15, D-27): editor on top of the student view, element picker, media, test builder */
.chain.studio { display: flex; flex-direction: column; gap: 0; }
.chain.studio > .elcard { margin: 0; }
.add-slot { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: 8px 0; padding: 9px; border: 1.5px dashed var(--line);
  border-radius: 14px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: .15s; }
.add-slot:hover, .add-slot:focus-visible { border-color: var(--c-sky); color: var(--brand-sky, #0077B6); background: var(--accent-soft, #E6F6FF); }
.elcard.editing { border-style: solid; }
.el-tools { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.el-tools .btn.sm { padding: 4px 9px; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kind { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: .15s; }
.kind:hover, .kind:focus-visible { border-color: var(--c-sky); box-shadow: var(--shadow); }
.kind-i { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--accent-soft, #E6F6FF); font-size: 17px; }
.media { margin: 10px 0; border-radius: 14px; overflow: hidden; background: #0b1f29; }
.media video { display: block; width: 100%; max-height: 70vh; background: #000; }
.media.pdf, .media.img { background: var(--surface-2); border: 1px solid var(--line); }
.media.pdf iframe { display: block; width: 100%; height: min(75vh, 820px); border: 0; }
.media.img img { display: block; max-width: 100%; margin: auto; }
.media-missing { min-height: 64px; display: grid; place-items: center; }
.media-missing::after { content: attr(data-err); color: var(--muted); font-size: 13px; padding: 12px; }
.notes p { margin: 0 0 10px; line-height: 1.65; }
.upload { margin-top: 6px; }
.qbuild { display: flex; flex-direction: column; gap: 6px; }
.qbuild > .row { padding: 0 6px; gap: 8px; flex-wrap: wrap; }
.qorder { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: q; display: flex; flex-direction: column; gap: 6px; }
.qorder li { counter-increment: q; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.qorder li::before { content: counter(q); display: grid; place-items: center; min-width: 24px; height: 24px; border-radius: 8px; background: var(--accent-soft, #E6F6FF); font-weight: 700; font-size: 12px; margin-right: 6px; }
.qorder li > span:first-child { flex: 1; }
.qmatch { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.qmatch label { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(140px, 1.4fr); align-items: center; gap: 10px; }
.qmatch label > span { font-weight: 600; }
@media (max-width: 740px) {
  .el-tools { width: 100%; justify-content: flex-start; margin-top: 6px; }
  .qmatch label { grid-template-columns: 1fr; gap: 4px; }
  .media.pdf iframe { height: 65vh; }
}

/* Learner media and local lesson orientation; subject cards are unchanged. */
.lesson-media { min-width:0; margin:12px 0; border:1px solid var(--line); border-radius:14px; overflow:hidden; background:var(--surface); }
.lesson-media video { display:block; width:100%; aspect-ratio:16/9; max-height:65vh; object-fit:contain; background:#071c28; }
.lesson-media audio { display:block; width:100%; margin:12px 0; }
.lesson-media iframe { display:block; width:100%; height:60vh; border:0; }
.lesson-media img { display:block; max-width:100%; height:auto; margin:auto; }
.lesson-media-tools { display:flex; gap:10px; flex-wrap:wrap; align-items:center; padding:12px; }
.lesson-media-status { flex:1 1 180px; color:var(--muted); font-size:13px; }
.lesson-media-name { padding:0 12px 12px; margin:0; overflow-wrap:anywhere; }
.lesson-media [hidden] { display:none !important; }
.lesson-next { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.lesson-next { margin-bottom:20px; }
.chain > .elcard { scroll-margin-top:90px; min-width:0; }
.chain > .elcard > .grow { min-width:0; }
@media(max-width:600px){.lesson-media-tools .btn { min-height:44px; }.lesson-next .btn { flex:1; text-align:center; }}
/* Topic counts remain attached to the native keyboard-accessible disclosure. */
.mod-p.topic-progress-label { font-size:12px; white-space:normal; text-align:right; max-width:130px; }
.mod-t { min-width:0; overflow-wrap:anywhere; }
/* Group gallery (D-32) */
.gal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.gal-chip { padding: 7px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.gal-chip.on { border-color: var(--c-sky); background: var(--accent-soft, #E6F6FF); color: var(--brand-sky, #0077B6); }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.gal-item { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gal-item:hover img { transform: scale(1.04); }
.gal-tag { position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; border-radius: 8px; background: rgba(255,255,255,.9); font-size: 13px; }
@media (max-width: 740px) { .gal-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; } .gal-item { border-radius: 8px; } }
/* Homework answer files (T-19) */
.hw-file.img { display: inline-block; width: 120px; height: 120px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); margin: 4px 4px 0 0; vertical-align: top; }
.hw-file.img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* T-47: a continuous learner reading surface; editor and other role screens keep their own layout. */
.pm-workspace[data-role="student"][data-page="olesson"] main { max-width:1040px; }
.pm-workspace .pm-lesson { max-width:880px; background:transparent; border:0; border-radius:0; padding:0; }

.pm-workspace .pm-lesson .page-h { margin-bottom:8px; }
.pm-workspace .pm-lesson .page-h h1 { font-size:30px; overflow-wrap:anywhere; }
.pm-workspace .pm-lesson .lesson-intro { margin:0 0 24px; line-height:1.65; color:var(--muted); }
.pm-workspace .pm-lesson .lesson-reading { gap:0; margin:0; }
.pm-lesson .lesson-section { min-width:0; padding:24px 0; border-bottom:1px solid var(--line); scroll-margin-top:90px; }
.pm-lesson .lesson-section:first-child { padding-top:0; }
.pm-lesson .lesson-section-heading { display:flex; align-items:flex-start; gap:12px; justify-content:space-between; margin-bottom:12px; }
.pm-workspace .pm-lesson .lesson-section h2 { font-size:20px; line-height:1.4; margin:0; overflow-wrap:anywhere; }
.pm-lesson .lesson-section.locked, .pm-lesson .lesson-section.skip { color:var(--muted); }
.pm-lesson .lesson-section > p { margin:10px 0; }
.pm-lesson .lesson-section > .row { gap:12px; flex-wrap:wrap; margin:10px 0; }
.pm-lesson .lesson-section .player { width:100%; }
.pm-lesson .lesson-section .lesson-media { margin:0 0 12px; }
.pm-lesson .lesson-section .hw { margin-top:16px; }
.pm-lesson .lesson-next { margin:24px 0; align-items:center; }
.pm-lesson .lesson-next-title { flex:1 1 180px; font-size:14px; color:var(--muted); overflow-wrap:anywhere; }
@media(max-width:740px) {
  .pm-workspace[data-role="student"][data-page="olesson"] main { padding-left:14px; padding-right:14px; }
  .pm-workspace .pm-lesson { padding:0; border-radius:0; }
  .pm-workspace .pm-lesson .page-h h1 { font-size:26px; }
  .pm-workspace .pm-lesson .lesson-section h2 { font-size:18px; }
  .pm-lesson .lesson-section { padding:22px 0; }

  .pm-lesson .lesson-next-title { flex-basis:100%; }

}

/* Match the learner's reading surface in the existing author preview, without edit controls or learner writes. */
.pm-workspace .chain.studio:not(:has(.editing)) { max-width:880px; gap:0; padding:0; background:transparent; border:0; border-radius:0; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard { padding:24px 0; border:0; border-bottom:1px solid var(--line); border-radius:0; box-shadow:none; background:transparent; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard:first-child { padding-top:0; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard:last-child { border-bottom:0; padding-bottom:0; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard > .elicon { display:none; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard > .grow > .row:first-child { margin-bottom:12px; }
.pm-workspace .chain.studio:not(:has(.editing)) > .elcard > .grow > .row:first-child > b { font-size:20px; line-height:1.4; }
@media(max-width:740px) {
  .pm-workspace .chain.studio:not(:has(.editing)) { padding:0; border-radius:0; }
  .pm-workspace .chain.studio:not(:has(.editing)) > .elcard > .grow > .row:first-child > b { font-size:18px; }
}

/* T-47b: open reading layout with a test shortcut and lesson-level comments. */
.pm-lesson .lesson-test-links { display:flex; flex-wrap:wrap; gap:8px; margin:0 0 20px; }
.pm-lesson .lesson-test-links .btn { min-height:44px; white-space:normal; text-align:left; }
.pm-lesson .lesson-section h2:focus { outline:2px solid var(--accent); outline-offset:5px; }
.pm-lesson .lesson-section .player { border-radius:0; box-shadow:none; }
.pm-lesson .lesson-section .reply { border-radius:0; background:transparent; border-left:2px solid var(--line); }
.pm-lesson .lesson-comments { margin:32px 0 0; }
.pm-workspace .pm-lesson .lesson-comments h2 { font-size:20px; margin:0 0 20px; }
.pm-lesson .lesson-comment { border-bottom:1px solid var(--line); padding:0 0 16px; margin:0 0 16px; }
.pm-lesson .lesson-comment-message { overflow-wrap:anywhere; }
.pm-lesson .lesson-comment-message > p { margin:6px 0; white-space:pre-wrap; }
.pm-lesson .lesson-comment-message + .lesson-comment-message { margin:16px 0 0 16px; border-left:2px solid var(--line); padding-left:16px; }
.pm-lesson .lesson-comment-form { display:grid; gap:10px; }
.pm-lesson .lesson-comment-form label { font-size:14px; font-weight:600; }
.pm-lesson .lesson-comment-form textarea { width:100%; resize:vertical; min-height:96px; }
.pm-lesson .lesson-comment-form .btn { justify-self:start; min-height:44px; }
.pm-lesson .lesson-comment-form [role="status"] { margin:0; }