/* ══════════════════════════════════════════════════════════════════
   COMMUNITY + CLASSROOM — styles for #community-screen (community.js).
   Scoped under .cm and built on Auracle's own theme variables (see :root
   and html.dark in index.html), so it matches the rest of the app in
   light and dark mode. The page itself stays white for a clean read.
   ══════════════════════════════════════════════════════════════════ */
.cm {
  --cm-bg: var(--surface); --cm-alt: var(--taupe); --cm-alt-lt: var(--taupe-lt); --cm-line: var(--border);
  --cm-accent: var(--accent); --cm-accent-hover: var(--accent-hover); --cm-accent-pale: var(--accent-pale); --cm-butter: var(--gold-pale);
  --cm-text: var(--text); --cm-text-lt: var(--text-lt); --cm-text-faint: var(--text-faint); --cm-surface: var(--surface); --cm-on-accent: #FFFFFF;
  --cm-gold: var(--gold); --cm-ok: #4F7D5C; --cm-ok-pale: #E3EEE5; --cm-live: #C2453A; --cm-shadow: rgba(61,50,41,0.08);
  --cm-player-a: #4A3B52; --cm-player-b: #2D2A3A;
  --cm-display: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
  --cm-body: 'DM Sans', system-ui, sans-serif;
  background: var(--cm-bg); color: var(--cm-text); font-family: var(--cm-body); font-weight: 400;
}
html.dark .cm { --cm-ok: #8DBE98; --cm-ok-pale: rgba(79,125,92,0.22); --cm-live: #E2685D; --cm-shadow: rgba(0,0,0,0.35); }
#community-screen { flex-direction: column; }
#community-screen.active { display: flex; }
.cm *, .cm *::before, .cm *::after { box-sizing: border-box; }
.cm button, .cm input, .cm textarea, .cm select { font: inherit; color: inherit; }
.cm button { cursor: pointer; }
.cm :focus-visible { outline: 2px solid var(--cm-accent); outline-offset: 2px; }
.cm h1, .cm h2, .cm h3 { font-family: var(--cm-display); font-weight: 600; margin: 0; color: var(--cm-text); text-wrap: balance; }
.cm .ico { width: 15px; height: 15px; flex-shrink: 0; display: block; }
.cm a { color: var(--cm-accent); }

.cm-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 24px; border-bottom: 1px solid var(--cm-line); background: var(--cm-bg); flex-shrink: 0; }
.cm-top .menu-toggle-btn { color: var(--cm-text); }
.cm-eyebrow { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: var(--cm-accent); font-weight: 600; }
.cm-top h1 { font-size: 21px; line-height: 1.1; }
.cm-top .cm-sp { flex: 1; }
.cm-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--cm-line); background: var(--cm-surface); padding: 8px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 400; color: var(--cm-text); white-space: nowrap; }
.cm-btn:hover { border-color: var(--cm-accent); }
.cm-btn.primary { background: var(--cm-accent); border-color: var(--cm-accent); color: var(--cm-on-accent); }
.cm-btn.primary:hover { background: var(--cm-accent-hover); }
.cm-btn.live { background: var(--cm-live); border-color: var(--cm-live); color: #fff; }
.cm-btn.small { padding: 5px 11px; font-size: 12px; }
.cm-btn:disabled { opacity: .55; cursor: default; }
.cm-btn.danger { color: var(--cm-live); }

.cm-live { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 24px; background: var(--cm-accent-pale); border-bottom: 1px solid var(--cm-line); font-size: 13px; flex-shrink: 0; }
.cm-live .grow { flex: 1; min-width: 180px; }
.cm-pill-live { display: inline-flex; align-items: center; gap: 6px; background: var(--cm-live); color: #fff; font-size: 10px; letter-spacing: 1.5px; font-weight: 600; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; }
.cm-pill-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: cm-pulse 1.4s ease-in-out infinite; }
@keyframes cm-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .cm-pill-live::before { animation: none; } }

.cm-view { flex: 1; overflow-y: auto; min-height: 0; }
.cm-pad { padding: 24px 24px 48px; }
.cm-wrap { max-width: 1040px; margin: 0 auto; }
.cm-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
.cm-tab { border: 1px solid transparent; background: none; padding: 6px 13px; border-radius: 20px; font-size: 13px; color: var(--cm-text-lt); }
.cm-tab:hover { color: var(--cm-text); }
.cm-tab.on { background: var(--cm-surface); border-color: var(--cm-line); color: var(--cm-text); font-weight: 500; }
.cm-muted { color: var(--cm-text-lt); }
.cm-faint { color: var(--cm-text-faint); font-size: 12px; }
.cm-empty { text-align: center; padding: 40px 16px; color: var(--cm-text-lt); max-width: 460px; margin: 0 auto; display: grid; gap: 10px; justify-items: center; }
.cm-empty h3 { font-size: 19px; }

.cm-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 500; font-size: 13px; color: #fff; flex-shrink: 0; text-transform: uppercase; }
.cm-chip { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 500; letter-spacing: .3px; padding: 1px 6px; border-radius: 4px; background: var(--cm-alt); color: var(--cm-text-lt); font-variant-numeric: tabular-nums; }
.cm-chip.match { background: var(--cm-butter); color: var(--cm-text); }
.cm-teacher { font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; color: var(--cm-on-accent); background: var(--cm-accent); padding: 1px 6px; border-radius: 4px; }
.cm-name { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cm-name b { font-weight: 500; }

/* Classroom */
.cm-section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.cm-section-title h2 { font-size: 19px; }
.cm-section-title p { margin: 4px 0 0; }
.cm-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cm-course { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; color: var(--cm-text); box-shadow: 0 6px 24px var(--cm-shadow); }
.cm-course:hover { border-color: var(--cm-accent); }
.cm-course.locked { cursor: default; opacity: .78; }
.cm-cover { aspect-ratio: 16 / 7; max-width: 100%; display: flex; align-items: flex-end; padding: 14px; position: relative; }
.cm-cover .num { font-family: var(--cm-display); font-size: 38px; font-style: italic; color: rgba(255,255,255,.92); line-height: 1; }
.cm-cover .state { position: absolute; top: 12px; right: 12px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; background: rgba(0,0,0,.28); color: #fff; padding: 3px 7px; border-radius: 4px; }
.cm-course-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cm-course-body h3 { font-size: 17px; }
.cm-course-body p { margin: 0; font-size: 13px; color: var(--cm-text-lt); }
.cm-progress { height: 6px; border-radius: 3px; background: var(--cm-alt); overflow: hidden; margin-top: 10px; }
.cm-progress > i { display: block; height: 100%; background: var(--cm-accent); border-radius: 3px; }
.cm-progress-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--cm-text-faint); margin-top: 8px; font-variant-numeric: tabular-nums; }

.cm-insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 22px; }
.cm-insight { background: var(--cm-surface); border: 1px solid var(--cm-line); border-left: 3px solid var(--cm-gold); border-radius: 14px; padding: 12px 14px; }
.cm-insight b { display: block; font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.cm-insight span { font-size: 12.5px; color: var(--cm-text-lt); }

.cm-lesson-layout { display: grid; grid-template-columns: 270px 1fr; gap: 24px; align-items: start; }
.cm-lesson-nav { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 10px; position: sticky; top: 0; }
.cm-back { border: 0; background: none; color: var(--cm-text-lt); font-size: 12.5px; padding: 4px 6px; display: inline-flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.cm-back:hover { color: var(--cm-accent); }
.cm-mod { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cm-text-faint); font-weight: 600; padding: 10px 8px 4px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.cm-lesson-link { display: flex; gap: 9px; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 8px; font-size: 13px; color: var(--cm-text-lt); }
.cm-lesson-link:hover { background: var(--cm-alt-lt); color: var(--cm-text); }
.cm-lesson-link.on { background: var(--cm-accent-pale); color: var(--cm-text); font-weight: 500; }
.cm-lesson-link.locked { opacity: .55; cursor: default; }
.cm-lesson-link .dur { margin-left: auto; font-size: 11px; color: var(--cm-text-faint); font-weight: 400; font-variant-numeric: tabular-nums; }
.cm-tick { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--cm-line); flex-shrink: 0; margin-top: 1px; display: grid; place-items: center; }
.cm-tick.done { background: var(--cm-ok); border-color: var(--cm-ok); }
.cm-tick.done::after { content: ""; width: 7px; height: 4px; border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff; transform: rotate(-45deg) translate(1px,-1px); }

.cm-player { aspect-ratio: 16 / 9; max-width: 100%; width: 100%; border-radius: 12px; overflow: hidden; position: relative; box-shadow: 0 10px 30px var(--cm-shadow); background: radial-gradient(120% 90% at 20% 10%, var(--cm-player-a) 0%, var(--cm-player-b) 70%); display: grid; place-items: center; color: #F3EADF; }
.cm-player iframe, .cm-player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cm-player .none { font-family: var(--cm-display); font-style: italic; font-size: 20px; padding: 16px; text-align: center; }
.cm-lesson-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.cm-lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cm-lesson-head h2 { font-size: 24px; line-height: 1.1; }
.cm-prose { max-width: 65ch; font-size: 14.5px; line-height: 1.75; overflow-wrap: anywhere; }
.cm-prose p { margin: 0 0 12px; }
.cm-resource { display: flex; align-items: center; gap: 12px; background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 14px; padding: 12px 14px; max-width: 520px; }
.cm-resource .file { width: 36px; height: 44px; border-radius: 4px; background: var(--cm-accent-pale); color: var(--cm-accent); display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .5px; flex-shrink: 0; }
.cm-resource div { min-width: 0; }
.cm-resource b { display: block; font-size: 13px; font-weight: 500; }
.cm-resource .cm-btn { margin-left: auto; }
.cm-reflect { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.cm-reflect .q { font-family: var(--cm-display); font-size: 17px; font-style: italic; line-height: 1.3; }
.cm-reflect textarea { width: 100%; min-height: 96px; resize: vertical; border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--cm-text); }
.cm-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cm-ai { border-left: 3px solid var(--cm-accent); background: var(--cm-accent-pale); border-radius: 0 12px 12px 0; padding: 12px 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.cm-ai .who { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--cm-accent); font-weight: 600; margin-bottom: 4px; white-space: normal; }

.cm-rec-layout { grid-template-columns: 290px 1fr; margin-top: 4px; }
.cm-rec-nav { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 160px); overflow-y: auto; }
.cm-rec-link { display: flex; gap: 10px; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 7px; border-radius: 10px; color: var(--cm-text-lt); }
.cm-rec-link:hover { background: var(--cm-alt-lt); color: var(--cm-text); }
.cm-rec-link.on { background: var(--cm-accent-pale); color: var(--cm-text); }
.cm-rec-thumb { flex-shrink: 0; width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--cm-player-b); display: grid; place-items: center; color: #F3EADF; }
.cm-rec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-rec-link-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; line-height: 1.35; }
.cm-rec-link-text b { font-weight: 500; }
.cm-rec-main .cm-lesson-head h2 { font-size: 26px; line-height: 1.2; }
/* Recording notes: one size throughout, roomier lines. Headings match the text size, set apart by weight and spacing. */
.cm-md.cm-rec-notes { font-size: 16.5px; line-height: 1.75; color: var(--cm-text); }
.cm-md.cm-rec-notes p { margin: 0 0 14px; }
.cm-md.cm-rec-notes h4, .cm-md.cm-rec-notes .md-h1, .cm-md.cm-rec-notes .md-h2, .cm-md.cm-rec-notes .md-h3 { font-size: 16.5px; line-height: 1.5; margin: 22px 0 8px; }
.cm-md.cm-rec-notes h4:first-child { margin-top: 0; }
.cm-md.cm-rec-notes ul, .cm-md.cm-rec-notes ol { margin: 0 0 14px; }
.cm-md.cm-rec-notes li { margin: 6px 0; }
/* Discussion under recordings and lessons */
.cm-discuss { border-top: 1px solid var(--cm-line); padding-top: 18px; margin-top: 6px; display: flex; flex-direction: column; gap: 14px; }
.cm-discuss-reacts { gap: 6px; }
.cm-discuss-reacts .cm-react { font-size: 13.5px; padding: 3px 11px; }
.cm-discuss-reacts .cm-faint { margin-left: auto; }
.cm-discuss .cm-comment .cm-text { font-size: 15px; }
.cm-ask { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cm-text-lt); margin-top: -4px; cursor: pointer; }
.cm-ask input { width: 16px; height: 16px; accent-color: var(--cm-accent); }
.cm-pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--cm-alt); color: var(--cm-text-lt); }
.cm-pill.butter { background: var(--cm-butter); color: var(--cm-text); }

/* Chat */
.cm-chat { display: flex; flex-direction: column; height: 100%; }
.cm-chat-head { padding: 10px max(24px, calc((100% - 880px) / 2)); border-bottom: 1px solid var(--cm-line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.cm-chat-head .cm-tabs { margin: 0; }
.cm-chat-head .cm-faint { margin-left: auto; }
.cm-chat-pin { display: flex; gap: 10px; align-items: center; padding: 9px max(24px, calc((100% - 880px) / 2)); background: var(--cm-accent-pale); border-bottom: 1px solid var(--cm-line); font-size: 13px; flex-shrink: 0; }
.cm-chat-pin span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-msgs { flex: 1; overflow-y: auto; padding: 18px max(24px, calc((100% - 880px) / 2)); display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.cm-day { text-align: center; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--cm-text-faint); }
.cm-msg { display: flex; gap: 10px; max-width: 760px; }
.cm-msg-body { min-width: 0; }
.cm-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.cm-meta time { font-size: 11px; color: var(--cm-text-faint); }
.cm-text { font-size: 14.5px; line-height: 1.55; margin-top: 2px; overflow-wrap: anywhere; white-space: pre-wrap; }
.cm-msg.teacher .cm-text { background: var(--cm-accent-pale); padding: 8px 12px; border-radius: 4px 14px 14px 14px; display: inline-block; }
.cm-reacts { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.cm-react { border: 1px solid var(--cm-line); background: var(--cm-surface); border-radius: 12px; padding: 1px 8px; font-size: 12px; color: var(--cm-text-lt); font-variant-numeric: tabular-nums; }
.cm-react.on { border-color: var(--cm-accent); background: var(--cm-accent-pale); color: var(--cm-text); }
.cm-react.tool { opacity: .7; }
.cm-composer { display: flex; gap: 8px; padding: 12px max(24px, calc((100% - 880px) / 2)); border-top: 1px solid var(--cm-line); background: var(--cm-bg); flex-shrink: 0; }
.cm-composer textarea { flex: 1; min-width: 0; border: 1px solid var(--cm-line); background: var(--cm-surface); border-radius: 12px; padding: 10px 16px; font-size: 14px; resize: none; height: 42px; max-height: 140px; color: var(--cm-text); }

/* Photos, videos and voice notes */
.cm-composer { flex-wrap: wrap; align-items: flex-end; }
.cm-composer .cm-tray { flex-basis: 100%; }
.cm-icon-btn { flex-shrink: 0; width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid var(--cm-line); background: var(--cm-surface); border-radius: 12px; color: var(--cm-text-lt); padding: 0; }
.cm-icon-btn .ico { width: 18px; height: 18px; }
.cm-icon-btn:hover { color: var(--cm-text); border-color: var(--cm-accent); }
.cm-icon-btn.rec, .cm-btn.rec { background: var(--cm-live); border-color: var(--cm-live); color: #fff; }
.cm-comment-form .cm-icon-btn { width: 34px; height: auto; min-height: 34px; }
.cm-comment-form .cm-icon-btn .ico { width: 16px; height: 16px; }
.cm-tray:empty { display: none; }
.cm-tray { display: flex; flex-direction: column; gap: 8px; }
.cm-pends { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cm-pend { position: relative; border-radius: 10px; overflow: hidden; background: var(--cm-alt-lt); border: 1px solid var(--cm-line); }
.cm-pend.image, .cm-pend.video { width: 72px; height: 72px; }
.cm-pend img, .cm-pend video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-pend.audio { padding: 4px 34px 4px 4px; min-width: 220px; }
.cm-pend.audio .cm-voice { background: none; padding: 2px; }
.cm-pend-tag { position: absolute; left: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; font-size: 10.5px; color: #fff; background: rgba(0,0,0,.55); border-radius: 6px; padding: 1px 5px; font-variant-numeric: tabular-nums; }
.cm-pend-tag .ico { width: 10px; height: 10px; }
.cm-pend-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 22px; padding: 0; text-align: center; }
.cm-recbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--cm-accent-pale); font-size: 13px; font-variant-numeric: tabular-nums; }
.cm-recbar .cm-sp { flex: 1; }
.cm-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cm-live); animation: cm-blink 1.2s ease-in-out infinite; }
@keyframes cm-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .cm-rec-dot { animation: none; } }
.cm-up { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--cm-text-lt); font-variant-numeric: tabular-nums; }
.cm-up-bar { flex: 1; max-width: 240px; height: 4px; border-radius: 2px; background: var(--cm-alt); overflow: hidden; }
.cm-up-bar span { display: block; height: 100%; background: var(--cm-accent); transition: width .2s; }
.cm-attach-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-attach-row .cm-btn .ico { width: 15px; height: 15px; }

.cm-media { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; }
.cm-post .cm-media { max-width: 560px; }
.cm-media-grid { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; }
.cm-media-grid.n2, .cm-media-grid.n4 { grid-template-columns: 1fr 1fr; }
.cm-media-grid.n3 { grid-template-columns: 1fr 1fr; }
.cm-media-grid.n3 .cm-media-img:first-child { grid-column: span 2; }
.cm-media-img { border: 0; padding: 0; background: var(--cm-alt-lt); display: block; cursor: zoom-in; }
.cm-media-img img { display: block; width: 100%; height: 100%; object-fit: cover; max-height: 420px; min-height: 80px; }
.cm-media-grid:not(.n1) .cm-media-img img { aspect-ratio: 1; max-height: 260px; }
.cm-media-video video { display: block; width: 100%; max-height: 480px; border-radius: 12px; background: #000; }
.cm-voice { display: flex; align-items: center; gap: 10px; background: var(--cm-alt-lt); border-radius: 22px; padding: 5px 14px 5px 5px; max-width: 320px; }
.cm-msg.teacher .cm-voice { background: var(--cm-accent-pale); }
.cm-voice-btn { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--cm-accent); color: var(--cm-on-accent); display: grid; place-items: center; padding: 0; }
.cm-voice-btn .ico { width: 14px; height: 14px; }
.cm-voice-bar { flex: 1; min-width: 60px; height: 22px; display: flex; align-items: center; cursor: pointer; position: relative; }
.cm-voice-bar::before { content: ''; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--cm-line); }
.cm-voice-fill { position: relative; height: 4px; border-radius: 2px; background: var(--cm-accent); width: 0; }
.cm-voice-time { font-size: 12px; color: var(--cm-text-lt); font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }
.cm-voice audio { display: none; }
.cm-lightbox { position: fixed; inset: 0; z-index: 500; background: rgba(10,8,6,.92); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.cm-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.cm-lightbox-x { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 18px; }

/* Feed */
.cm-feed { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.cm-feed-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cm-start { display: flex; align-items: center; gap: 10px; background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 12px 14px; color: var(--cm-text-faint); text-align: left; width: 100%; }
.cm-start:hover { border-color: var(--cm-accent); }
.cm-pins { background: var(--cm-accent-pale); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cm-pins-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; gap: 8px; flex-wrap: wrap; }
.cm-post { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cm-post.teaching { background: linear-gradient(var(--cm-butter), var(--cm-butter)) top/100% 6px no-repeat, var(--cm-surface); }
.cm-post-top { display: flex; gap: 10px; align-items: center; }
.cm-post-top .who { min-width: 0; font-size: 13px; }
.cm-flags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cm-flag { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: var(--cm-alt); color: var(--cm-text-lt); white-space: nowrap; }
.cm-flag.pin { background: var(--cm-accent-pale); color: var(--cm-accent); }
.cm-flag.teach { background: var(--cm-butter); color: var(--cm-text); }
.cm-flag.win { background: var(--cm-ok-pale); color: var(--cm-ok); }
.cm-flag.call { background: var(--cm-accent-pale); color: var(--cm-accent); }
.cm-post h3 { font-size: 18px; line-height: 1.2; }
.cm-post .body { font-size: 14px; color: var(--cm-text-lt); margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.cm-source { display: flex; gap: 10px; align-items: center; background: var(--cm-ok-pale); border-radius: 10px; padding: 10px 12px; font-size: 13px; flex-wrap: wrap; }
.cm-source b { color: var(--cm-ok); font-weight: 500; }
.cm-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.cm-ghost { border: 0; background: none; padding: 5px 8px; border-radius: 6px; font-size: 12.5px; color: var(--cm-text-lt); display: inline-flex; gap: 6px; align-items: center; }
.cm-ghost:hover { background: var(--cm-alt-lt); color: var(--cm-text); }
.cm-ghost.on { color: var(--cm-accent); font-weight: 500; }
.cm-actions .last { margin-left: auto; font-size: 11.5px; color: var(--cm-text-faint); }
.cm-comments { border-top: 1px solid var(--cm-line); margin-top: 6px; padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.cm-comment { display: flex; gap: 9px; }
.cm-comment .cm-avatar { width: 28px; height: 28px; font-size: 11px; }
.cm-comment-form { display: flex; gap: 8px; }
.cm-comment-form input { flex: 1; min-width: 0; border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 12px; padding: 7px 14px; font-size: 13px; color: var(--cm-text); }
.cm-replies { display: flex; flex-direction: column; gap: 10px; margin: -4px 0 0 37px; padding-left: 10px; border-left: 2px solid var(--cm-line); }
.cm-comment.reply .cm-avatar { width: 24px; height: 24px; font-size: 10px; }
.cm-replying { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cm-text-lt); margin-bottom: -6px; }
.cm-react.like { display: inline-flex; align-items: center; gap: 4px; }
.cm-react.like .ico { width: 12px; height: 12px; }
.cm-react.like.on { color: var(--cm-accent); }
.cm-react.like.on .ico path { fill: currentColor; }
.cm-emoji-btn { border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 12px; padding: 0 10px; font-size: 16px; line-height: 1; flex-shrink: 0; }
.cm-emoji-btn.on { border-color: var(--cm-accent); background: var(--cm-accent-pale); }
.cm-emoji-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: -4px; }
.cm-emoji-row button { border: 0; background: none; font-size: 20px; line-height: 1; padding: 6px; border-radius: 8px; }
.cm-emoji-row button:hover { background: var(--cm-accent-pale); }
.cm-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.cm-card { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.cm-call-date { font-family: var(--cm-display); font-size: 24px; line-height: 1.1; }
/* Upcoming live calls: pinned above the feed, swipe sideways when there's more than one */
.cm-calls { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cm-calls-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm-calls-track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding-bottom: 2px; }
.cm-call { flex: 0 0 min(240px, 78%); scroll-snap-align: start; position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--cm-line); border-radius: 10px; background: var(--cm-bg); }
.cm-call:only-child { flex-basis: 100%; }
.cm-call.next { border-color: var(--cm-accent); background: var(--cm-accent-pale); }
.cm-call-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cm-callpop { width: min(440px, 100%); }
.cm-callpop-name { font-size: 13px; color: var(--cm-text-lt); margin-bottom: -6px; }
.cm-callpop h2 { font-size: 24px; }
.cm-callpop-when { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.cm-callpop-when span { color: var(--cm-text-lt); font-size: 13.5px; }
.cm-callpop-join { justify-content: center; padding: 11px 16px; font-size: 14px; }
.cm-callpop-cal { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-callpop-cal .cm-btn { flex: 1 1 140px; justify-content: center; }
.cm-call-tag { position: absolute; top: 10px; right: 12px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; color: var(--cm-accent); }

/* Members */
.cm-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cm-member { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.cm-member-top { display: flex; gap: 10px; align-items: center; }
.cm-member-top b { display: block; font-size: 14px; font-weight: 500; }
.cm-shared { font-size: 12.5px; }
.cm-shared mark { background: var(--cm-butter); color: inherit; padding: 0 3px; border-radius: 3px; }

/* Modal + toast */
.cm-modal-bg { position: fixed; inset: 0; background: rgba(30,22,18,.45); display: grid; place-items: center; z-index: 400; padding: 16px; }
.cm-modal { background: var(--cm-surface); color: var(--cm-text); border-radius: 12px; padding: 20px; width: min(580px, 100%); display: grid; gap: 12px; box-shadow: 0 20px 60px var(--cm-shadow); max-height: calc(100% - 32px); overflow-y: auto; font-family: var(--cm-body); font-weight: 400; }
.cm-modal h2 { font-size: 20px; }
.cm-modal label { display: grid; gap: 4px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--cm-text-faint); font-weight: 600; }
.cm-modal label.inline { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--cm-text-lt); font-weight: 400; }
.cm-modal input:not([type=checkbox]), .cm-modal textarea, .cm-modal select { border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 10px; padding: 9px 11px; font-size: 14px; width: 100%; color: var(--cm-text); text-transform: none; letter-spacing: 0; font-weight: 400; }
.cm-modal textarea { min-height: 110px; resize: vertical; }
.cm-modal .hint { font-size: 12px; color: var(--cm-text-faint); text-transform: none; letter-spacing: 0; font-weight: 400; }
.cm-modal .err { color: var(--cm-live); font-size: 13px; }
.cm-modal .row-end { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cm-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.cm-cats button { border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 16px; padding: 4px 11px; font-size: 12.5px; color: var(--cm-text-lt); }
.cm-cats button.on { border-color: var(--cm-accent); background: var(--cm-accent-pale); color: var(--cm-text); font-weight: 500; }
.cm-pick { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.cm-pick button { text-align: left; border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.cm-pick button.on { border-color: var(--cm-accent); background: var(--cm-accent-pale); }
.cm-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #2D2A3A; color: #F8F3EC; padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 450; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-family: 'DM Sans', sans-serif; }

/* Sidebar block (lives in Auracle's own sidebar) */
.cm-sidebar { border-top: 1px solid var(--border); padding: 4px 0 6px; flex-shrink: 0; }
.cm-sidebar .sidebar-section-label { display: flex; align-items: center; gap: 8px; }
.cm-sidebar .cm-new { font-size: 8.5px; letter-spacing: 1px; background: var(--alert-pale, rgba(184,101,79,0.12)); color: var(--alert, #B8654F); padding: 1px 5px; border-radius: 4px; }
.cm-nav { margin: 0 8px; border-radius: 8px; }
.cm-nav.active { background: var(--accent-pale); color: var(--brown-dk); font-weight: 600; }
.cm-badge { margin-left: auto; font-size: 10px; font-weight: 600; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--alert, #B8654F); color: #fff; display: inline-grid; place-items: center; }
.cm-badge[hidden] { display: none; }
.cm-livedot { margin-left: auto; font-size: 9px; letter-spacing: 1px; font-weight: 700; color: #fff; background: var(--alert, #B8654F); padding: 1px 6px; border-radius: 4px; }

@media (max-width: 1000px) {
  .cm-feed, .cm-lesson-layout { grid-template-columns: 1fr; }
  .cm-side, .cm-lesson-nav { position: static; }
  .cm-rec-layout .cm-rec-main { order: -1; }
  .cm-rec-nav { max-height: none; }
}
@media (max-width: 700px) {
  .cm-top, .cm-live, .cm-chat-head, .cm-chat-pin, .cm-msgs, .cm-composer, .cm-chat-replying, .cm-pad { padding-left: 16px; padding-right: 16px; }
  .cm-top h1 { font-size: 19px; }
  .cm-chat-head .cm-faint { display: none; }
  .cm-lesson-head h2 { font-size: 20px; }
  .cm-composer { gap: 6px; }
  .cm-composer .cm-icon-btn { width: 38px; }
  .cm-composer .cm-btn.primary { padding-left: 12px; padding-right: 12px; }
}
/* Phones: the comment box gets its own line; emoji, photo, voice and Reply sit under it. */
@media (max-width: 480px) {
  .cm-comment-form { flex-wrap: wrap; }
  .cm-comment-form input { flex-basis: 100%; padding-top: 9px; padding-bottom: 9px; }
  .cm-comment-form .cm-btn.primary { margin-left: auto; }
  .cm-comment-form .cm-emoji-btn, .cm-comment-form .cm-icon-btn { min-height: 34px; }
}

/* New-activity dot on Auracle's menu button (phones, where the sidebar is hidden) */
.menu-toggle-btn.cm-has-new { position: relative; }
.menu-toggle-btn.cm-has-new::after { content: ""; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.cm-modal .hint { display: block; }

/* Formatted text (posts, comments, lessons, notes) */
.cm-md { white-space: normal; }
.cm-md p { margin: 0 0 8px; }
.cm-md p:last-child, .cm-md ul:last-child, .cm-md ol:last-child { margin-bottom: 0; }
.cm-md h4, .cm-editor h2, .cm-editor h3 { font-family: var(--cm-display); color: var(--cm-text); margin: 16px 0 4px; line-height: 1.25; font-weight: 600; }
.cm-md h4:first-child, .cm-editor h2:first-child, .cm-editor h3:first-child { margin-top: 0; }
.cm-editor h2 { font-size: 18px; } .cm-editor h3 { font-size: 15.5px; }
.cm-md h4:first-child { margin-top: 0; }
.cm-md .md-h1 { font-size: 18px; }
.cm-md .md-h2 { font-size: 15.5px; }
.cm-md .md-h3 { font-size: 14px; }
.cm-md ul, .cm-md ol { margin: 0 0 10px; padding-left: 22px; }
.cm-md li { margin: 2px 0; }
.cm-md strong { font-weight: 600; color: var(--cm-text); }
.cm-post .body.cm-md { white-space: normal; }
.cm-text.cm-md { white-space: normal; }
.cm-toolbar { display: flex; gap: 4px; flex-wrap: wrap; text-transform: none; letter-spacing: 0; }
.cm-toolbar button { border: 1px solid var(--cm-line); background: var(--cm-bg); border-radius: 6px; padding: 4px 9px; font-size: 12.5px; color: var(--cm-text); min-width: 32px; font-weight: 500; }
.cm-toolbar button:hover:not(:disabled) { border-color: var(--cm-accent); }
.cm-toolbar button:disabled { opacity: .4; cursor: default; }
.cm-toolbar .cm-tb-preview { margin-left: auto; }
.cm-preview { border: 1px dashed var(--cm-line); border-radius: 10px; padding: 12px; min-height: 120px; font-size: 14px; line-height: 1.65; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--cm-text); }

/* @mentions */
.cm-mention { color: var(--cm-accent); font-weight: 500; }
.cm-mention.me { background: var(--cm-accent-pale); border-radius: 4px; padding: 0 3px; }
.cm-quote { display: block; max-width: 100%; text-align: left; margin: 4px 0 2px; padding: 4px 10px; border: 0; border-left: 3px solid var(--cm-accent); border-radius: 4px; background: var(--cm-surface); font-size: 12.5px; color: var(--cm-text-lt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-quote b { color: var(--cm-text); font-weight: 600; }
.cm-chat-replying { display: flex; align-items: center; gap: 8px; padding: 8px max(24px, calc((100% - 880px) / 2)) 0; font-size: 12.5px; color: var(--cm-text-lt); border-top: 1px solid var(--cm-line); background: var(--cm-bg); flex-shrink: 0; }
.cm-chat-replying span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-chat-replying + .cm-composer { border-top: 0; }
.cm-msg.flash { animation: cm-flash 1.6s ease-out; }
@keyframes cm-flash { from { background: var(--cm-accent-pale); } to { background: transparent; } }
.cm-msg.mentioned { box-shadow: inset 3px 0 0 var(--cm-accent); padding-left: 8px; border-radius: 4px; }
.cm-mention-box { position: fixed; z-index: 500; width: 260px; max-height: 240px; overflow-y: auto; background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 10px; box-shadow: 0 10px 30px var(--cm-shadow); padding: 4px; display: flex; flex-direction: column; }
.cm-mention-box button { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--cm-text); min-height: 34px; }
.cm-mention-box button.on, .cm-mention-box button:hover { background: var(--cm-accent-pale); }
.cm-mention-box small { flex-basis: 100%; color: var(--cm-text-faint); font-size: 11px; }

/* Notifications bell (in every screen header) */
.cm-bell { position: relative; background: none; border: none; cursor: pointer; color: var(--text-lt, #6B6578); padding: 6px; border-radius: 8px; display: inline-grid; place-items: center; flex-shrink: 0; }
.cm-bell:hover { color: var(--accent, #D48B6C); background: var(--taupe, #EEE8DF); }
.cm-bell svg { width: 20px; height: 20px; display: block; }
.cm-bell-dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent, #D48B6C); box-shadow: 0 0 0 2px var(--surface, #fff); }
.cm-bell-dot[hidden], .cm-bell[hidden] { display: none; }
.app-screen-header .back-to-chat-btn + .cm-bell { margin-left: 4px; }
.cm-bell-panel { position: fixed; z-index: 460; width: min(380px, calc(100vw - 16px)); max-height: min(70vh, 560px); display: flex; flex-direction: column; background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: 12px; box-shadow: 0 18px 50px rgba(45,42,58,0.18); overflow: hidden; font-size: 13.5px; }
.cm-bell-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--cm-line); }
.cm-bell-head b { font-family: var(--cm-display); font-size: 17px; font-weight: 600; }
.cm-bell-list { overflow-y: auto; display: flex; flex-direction: column; }
.cm-bell-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; border-bottom: 1px solid var(--cm-line); background: none; padding: 11px 14px; color: var(--cm-text); line-height: 1.45; }
.cm-bell-item:last-child { border-bottom: 0; }
.cm-bell-item:hover { background: var(--cm-alt-lt); }
.cm-bell-item.new { background: var(--cm-accent-pale); }
.cm-bell-item .ic { width: 26px; height: 26px; border-radius: 50%; background: var(--cm-alt); display: grid; place-items: center; flex-shrink: 0; font-size: 13px; color: var(--cm-accent); font-weight: 600; }
.cm-bell-item .tx { min-width: 0; overflow-wrap: anywhere; }
.cm-bell-item b { font-weight: 600; }
.cm-bell-item small { display: block; color: var(--cm-text-faint); font-size: 11.5px; margin-top: 2px; }

/* "Auracle has been updated" notice */
.cm-update { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 470; display: flex; align-items: center; gap: 10px; background: #2D2A3A; color: #F8F3EC; padding: 10px 10px 10px 16px; border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.25); font-family: 'DM Sans', system-ui, sans-serif; font-size: 13.5px; max-width: calc(100vw - 24px); }
.cm-update-go { border: 0; background: #7D5F42; color: #fff; border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cm-update-x { border: 0; background: none; color: #F8F3EC; opacity: .7; font-size: 18px; cursor: pointer; padding: 0 4px; }

/* Rich text editor */
.cm-editor-wrap { display: grid; gap: 0; border: 1px solid var(--cm-line); border-radius: 10px; background: var(--cm-bg); overflow: hidden; }
.cm-editor-wrap:focus-within { border-color: var(--cm-accent); }
.cm-editor-wrap .cm-toolbar { padding: 6px; border-bottom: 1px solid var(--cm-line); background: var(--cm-alt-lt); }
.cm-toolbar button.on { background: var(--cm-accent-pale); border-color: var(--cm-accent); }
.cm-toolbar button svg { display: block; margin: 1px auto; }
.cm-tb-sep { width: 1px; background: var(--cm-line); margin: 2px 4px; align-self: stretch; }
.cm-editor { padding: 12px 14px; font-size: 14.5px; line-height: 1.65; color: var(--cm-text); outline: none; overflow-y: auto; max-height: 50vh; text-transform: none; letter-spacing: 0; font-weight: 400; overflow-wrap: anywhere; }
.cm-editor p { margin: 0 0 8px; }
.cm-editor ul, .cm-editor ol { margin: 0 0 8px; padding-left: 22px; }
.cm-editor { position: relative; }
.cm-editor.is-empty::before { content: attr(data-placeholder); color: var(--cm-text-faint); position: absolute; top: 12px; left: 14px; pointer-events: none; }
