/*
 * KARIM ACADEMY — VISUAL RHYTHM + SOCIAL FEED REFRESH
 * Release 2026-11-07 / V3.1
 * A UI-only layer. Existing MVC5, permissions, exam and payments logic are not modified.
 * All colors derive from the active theme, so the saved student/admin styles still work.
 */
:root {
  --kf-visual-space: clamp(16px, 1.7vw, 26px);
  --kf-visual-edge: color-mix(in srgb,var(--line,#e4e0ef) 78%,var(--primary,#6553d8) 22%);
  --kf-visual-shadow: 0 4px 18px rgba(37,30,91,.045),0 20px 52px rgba(37,30,91,.045);
  --kf-visual-soft: color-mix(in srgb,var(--surface,#fff) 94%,var(--primary,#6654d8) 6%);
  --kf-visual-subtle: color-mix(in srgb,var(--surface,#fff) 97%,var(--ink,#29253c) 3%);
}

/* 1 — Global editorial rhythm: improve hierarchy without changing template themes */
.app { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.app :where(h1,h2,h3,h4,p,small,strong) { overflow-wrap: anywhere; }
.app :where(.panel,.course,.stat-card,.feature-grid > article) {
  border-color: var(--kf-visual-edge);
  box-shadow: var(--kf-visual-shadow);
}
.app :where(.portal-main,.container) { min-width:0; }
.app .portal-main { padding-block: clamp(18px,2.6vw,33px) 65px; }
.app .panel { padding: clamp(18px,2.1vw,28px); margin-bottom: 22px; }
.app .panel h2 {font-size: clamp(18px,1.55vw,23px);line-height:1.55;}
.app .panel h3 {font-size: clamp(15px,1.25vw,19px);line-height:1.55;}
.app .panel p {font-size: clamp(12px,1vw,14px);line-height:1.95;}
.app .section-heading { margin-bottom: 20px; gap: 14px; align-items:center; }
.app .section-heading h2 {font-size:clamp(20px,2vw,27px);line-height:1.55;margin:0 0 5px;}
.app .section-heading p {font-size:clamp(12px,.95vw,14px);line-height:1.85;}
.app .page-title {display:flex;flex-wrap:wrap;align-items:center;gap:16px;margin:0 0 26px;padding:6px 0 18px;border-bottom:1px solid var(--kf-visual-edge);}
.app .page-title>div:first-child {min-width:0;max-width:780px;}
.app .page-title h1,.learner-app .page-title h1 {
  font-size: clamp(23px,2.5vw,31px);
  line-height: 1.47;
  letter-spacing: 0;
  margin: 4px 0 7px;
}
.app .page-title .eyebrow {font-size:12px;line-height:1.6;letter-spacing:0;color:var(--primary);font-weight:700;}
.app .page-title p,.portal .page-title p {font-size:clamp(12px,1vw,14px);line-height:1.85;color:var(--muted);max-width:700px;}
.portal .page-title h1 {font-size:clamp(22px,2.35vw,29px);}
.app .course-body {padding:clamp(17px,2vw,22px);}
.app .course-body h3 {line-height:1.65;font-size:clamp(15px,1.3vw,18px);}
.app .course-body p {font-size:clamp(12px,1vw,14px);line-height:1.75;}
.app .course-body>small {font-size:12px;}
.app .stat-card { min-width:0; }
.app .stat-card small {font-size:clamp(11px,.9vw,13px);line-height:1.5;}
.app .stat-card strong {font-size:clamp(19px,2vw,25px);}
.app .btn {line-height:1.45;min-height:40px;font-size:clamp(12px,.96vw,14px);}
.app .field > span {font-size:12px;line-height:1.6;}
.app .field input:not([type=checkbox]):not([type=color]),
.app .field textarea,.app .field select {font-size:13px;line-height:1.65;}
.app .portal-header { gap:16px; }
.app .portal-header b {font-size:clamp(12px,1.04vw,14px);font-weight:700;}
.app .portal-header>div {font-size:11px;}
.app .sidebar :where(nav a,.sidebar-foot>a,.sidebar-foot>button) {line-height:1.65;}
.learner-app .sidebar nav a {font-size:clamp(12px,.95vw,14px);}
.app .social-community {font-size:14px;line-height:1.7;min-width:0;}

/* 2 — Compact, legible page masthead, no oversized purple box */
.app .social-community .social-heading {
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:18px 28px;
  min-height:0;
  margin:0 0 18px;
  padding:20px clamp(18px,2vw,28px);
  background:var(--surface);
  border:1px solid var(--kf-visual-edge);
  border-inline-start:5px solid var(--social-blue,var(--primary));
  border-radius:18px;
  box-shadow:var(--kf-visual-shadow);
}
.app .social-community .social-heading>div {flex:1 1 350px;max-width:750px;min-width:0;}
.app .social-community .social-eyebrow {display:inline-block;font-weight:700;line-height:1.6;font-size:12px;color:var(--primary);}
.app .social-community .social-heading h1,
.app .social-community .social-heading h2 {
  font-size:clamp(24px,2.3vw,32px);
  line-height:1.38;
  letter-spacing:0;
  margin:6px 0 8px;
  font-weight:800;
}
.app .social-community .social-heading p {
  font-size:clamp(12px,1vw,14px);
  line-height:1.75;
  color:var(--muted);
  max-width:620px;
  margin:0;
}
.app .social-community .social-refresh {
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:10px 16px;
  border:1px solid var(--kf-visual-edge);
  background:var(--kf-visual-soft);
  color:var(--primary);
  border-radius:12px;
  font-size:12px;
  box-shadow:none;
}
.app .social-community .social-navigation {
  gap:7px;
  padding:5px;
  border:1px solid var(--kf-visual-edge);
  border-radius:14px;
  margin:0 0 20px;
  box-shadow:0 4px 18px rgba(37,30,91,.035);
}
.app .social-community .social-navigation button {
  gap:9px;
  padding:11px 17px;
  font-size:13px;
  min-height:44px;
  border-radius:10px;
}
.app .social-community .social-navigation button>span {font-size:11px;padding:2px 8px;}

/* 3 — Facebook-like post feed, grouped actions, clear nested comments */
.app .social-community .social-feed-layout {
  grid-template-columns:minmax(0,1fr) minmax(245px,275px);
  gap:clamp(18px,2vw,27px);
  align-items:start;
}
.app .social-community .social-feed {gap:24px;min-width:0;}
.app .social-community .social-feed-tools {gap:12px;flex-wrap:wrap;margin:0 0 2px;}
.app .social-community .social-feed-tools select {font-size:12px;padding:11px 13px;max-width:185px;min-height:43px;}
.app .social-community .social-search {min-height:43px;}
.app .social-community .social-search input {font-size:13px;}
.app .social-community .social-post {
  display:block;
  overflow:hidden;
  background:var(--surface);
  border:1px solid var(--kf-visual-edge);
  border-radius:20px;
  box-shadow:var(--kf-visual-shadow);
  isolation:isolate;
  min-width:0;
}
.app .social-community .social-post>header {
  display:flex;
  align-items:center;
  gap:12px;
  padding:20px clamp(16px,2.1vw,24px) 14px;
  background:var(--surface);
}
.app .social-community .social-post>header .social-avatar {
  width:46px;height:46px;flex:0 0 46px;
  box-shadow:0 0 0 3px var(--kf-visual-soft);
}
.app .social-community .social-post>header strong {
  display:flex;
  align-items:center;
  gap:6px;
  font-size:clamp(13px,1vw,15px);
  color:var(--ink);
  line-height:1.55;
  font-weight:800;
  margin:0 0 3px;
}
.app .social-community .social-post>header small {
  display:flex;align-items:center;gap:6px;
  font-size:11px;line-height:1.65;
  color:var(--muted);
}
.app .social-community .social-post-copy {
  display:block;
  padding:8px clamp(16px,2.1vw,24px) 22px;
}
.app .social-community .social-post-copy h3 {
  font-size:clamp(17px,1.5vw,21px);
  line-height:1.55;
  font-weight:800;
  margin:0 0 11px;
  color:var(--ink);
}
.app .social-community .social-post-copy>p {
  font-size:clamp(13px,1.03vw,15px);
  line-height:1.95;
  margin:0;
  color:var(--ink);
  white-space:pre-wrap;
}
.app .social-community .social-post-flags {gap:8px;padding:0 clamp(16px,2.1vw,24px) 12px;}
.app .social-community .social-post-flags>span {padding:6px 9px;font-size:11px;border-radius:8px;}
.app .social-community .social-post-image {background:var(--kf-visual-subtle);}
.app .social-community .social-post-counts {
  display:flex;justify-content:space-between;align-items:center;
  flex-wrap:wrap;gap:7px 16px;
  margin:0 clamp(16px,2.1vw,24px);
  padding:13px 0 10px;
  border-top:1px solid var(--kf-visual-edge);
  color:var(--muted);
  font-size:12px;
}
.app .social-community .social-post-counts>span {gap:7px;}
.app .social-community .social-post-counts button {color:inherit;font-size:12px;}
.app .social-community .social-post-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  padding:8px clamp(16px,2.1vw,24px) 14px;
  margin:0;
  border:0;
  background:var(--surface);
}
.app .social-community .social-post-actions>button {
  display:flex;align-items:center;justify-content:center;gap:10px;
  min-height:43px;
  padding:10px;
  border:1px solid transparent;
  border-radius:12px;
  background:var(--kf-visual-subtle);
  color:var(--ink);
  font-size:13px;
  font-weight:700;
}
.app .social-community .social-post-actions>button:hover {
  border-color:var(--kf-visual-edge);
  background:var(--kf-visual-soft);
}
.app .social-community .social-post-actions>button.liked {color:var(--social-blue);background:var(--social-soft);}
.app .social-community .social-post-actions svg {width:19px;height:19px;}
.app .social-community .social-comments {
  display:block;
  padding:17px clamp(16px,2.1vw,24px) 21px;
  border-top:1px solid var(--kf-visual-edge);
  background:var(--kf-visual-subtle);
}
.app .social-community .social-older-comments {
  display:inline-flex;align-items:center;gap:6px;
  margin:0 0 15px;
  color:var(--social-blue);
  font-size:12px;
  font-weight:700;
}
.app .social-community .social-comment {
  display:flex;align-items:flex-start;
  gap:10px;margin:0 0 16px;min-width:0;
}
.app .social-community .social-comment>.social-avatar {
  display:inline-flex;
  width:36px;height:36px;
  min-width:36px;
  font-size:11px;
  background:var(--surface);
  border:1px solid var(--kf-visual-edge);
  box-shadow:0 2px 8px rgba(32,20,91,.07);
}
.app .social-community .social-comment>div {
  min-width:0;
  max-width:min(100%,calc(100% - 47px));
  flex:1;
}
.app .social-community .social-comment>div>div {
  display:block;
  padding:12px 15px 13px;
  border:1px solid var(--kf-visual-edge);
  background:var(--surface);
  border-radius:15px 15px 15px 6px;
  min-width:0;
  box-shadow:0 2px 7px rgba(32,20,91,.025);
}
.app .social-community .social-comment b {
  display:block;
  margin:0 0 5px;
  font-size:13px;
  line-height:1.55;
  color:var(--primary);
  font-weight:800;
}
.app .social-community .social-comment p {
  display:block;
  font-size:13px;
  line-height:1.85;
  color:var(--ink);
  margin:0;
}
.app .social-community .social-comment time {
  display:block;
  font-size:11px;
  line-height:1.4;
  margin:6px 10px 0;
  color:var(--muted);
}
.app .social-community .social-comment-form {
  display:flex;
  align-items:flex-end;
  gap:10px;
  margin:18px 0 0;
  padding-top:15px;
  border-top:1px solid var(--kf-visual-edge);
}
.app .social-community .social-comment-form>.social-avatar {
  display:inline-flex;
  width:36px;height:36px;
  min-width:36px;
}
.app .social-community .social-comment-form>label {display:block;min-width:0;flex:1;}
.app .social-community .social-comment-form textarea {
  min-height:43px;
  font-size:13px;
  line-height:1.75;
  padding:11px 14px;
  background:var(--surface);
  border:1px solid var(--kf-visual-edge);
  border-radius:15px;
}
.app .social-community .social-comment-form>button {
  display:grid;place-items:center;
  width:43px;height:43px;
  border-radius:12px;
  color:#fff;
  background:var(--social-blue);
}
.app .social-community .social-comments-closed {
  display:flex;align-items:center;gap:8px;
  padding:12px 14px;
  border:1px dashed var(--kf-visual-edge);
  border-radius:11px;
  color:var(--muted);
  background:var(--surface);
  font-size:12px;
  line-height:1.8;
}
.app .social-community .social-student-welcome,
.app .social-community .social-composer,
.app .social-community .social-empty,
.app .social-community .social-aside-card {
  background:var(--surface);
  border:1px solid var(--kf-visual-edge);
  border-radius:18px;
  box-shadow:var(--kf-visual-shadow);
}
.app .social-community .social-student-welcome strong {font-size:15px;}
.app .social-community .social-student-welcome span:not(.social-avatar) {font-size:13px;line-height:1.8;}
.app .social-community .social-composer footer button {font-size:12px;min-height:40px;}
.app .social-community .social-feed-aside {gap:18px;}
.app .social-community .social-guidance {
  padding:23px 21px;
  border:1px solid var(--kf-visual-edge);
  border-radius:18px;
  background:var(--surface);
  box-shadow:var(--kf-visual-shadow);
}
.app .social-community .social-guidance>svg {margin-bottom:10px;}
.app .social-community .social-guidance h3 {font-size:16px;line-height:1.55;margin:0 0 8px;}
.app .social-community .social-guidance p {font-size:13px;line-height:1.9;}
.app .social-community .social-aside-title h3 {font-size:15px;}
.app .social-community .social-aside-title p {font-size:12px;}

/* 4 — Chat distinction: teacher/user names and text remain readable */
.app .social-community .social-rooms-layout {
  min-height:620px;
  border-radius:19px;
  border-color:var(--kf-visual-edge);
  box-shadow:var(--kf-visual-shadow);
}
.app .social-community .social-room-list {background:var(--kf-visual-subtle);}
.app .social-community .social-room-button {padding-block:12px;border-radius:13px;}
.app .social-community .social-room-button strong {font-size:14px;line-height:1.5;}
.app .social-community .social-room-button small {font-size:11px;line-height:1.6;}
.app .social-community .social-room-button em {font-size:10px;}
.app .social-community .social-room-welcome {
  padding:35px 25px;
  background:var(--surface);
  border-radius:0;
}
.app .social-community .social-room-welcome h3 {font-size:23px;}
.app .social-community .social-room-welcome p {font-size:14px;line-height:1.85;}
.app .social-community .social-room-welcome small {font-size:11px;line-height:1.75;}
.app .social-community .social-chat {background:var(--surface);}
.app .social-community .social-chat-head {
  padding:16px 20px;
  gap:13px;
  border-bottom:1px solid var(--kf-visual-edge);
}
.app .social-community .social-chat-head h3 {font-size:17px;margin:0 0 4px;}
.app .social-community .social-chat-head p {font-size:11px;line-height:1.6;}
.app .social-community .social-room-description {font-size:12px;line-height:1.85;}
.app .social-community .social-chat-messages {
  gap:15px;
  background:color-mix(in srgb,var(--surface) 88%,var(--primary) 12%);
  background-image:none;
  padding:20px;
}
.app .social-community .social-day-separator {text-align:center;}
.app .social-community .social-day-separator>span {
  font-size:11px;color:var(--muted);
  background:var(--surface);
  border-radius:999px;border:1px solid var(--kf-visual-edge);
  padding:5px 12px;
}
.app .social-community .social-message {gap:9px;max-width:min(86%,570px);}
.app .social-community .social-message>div {
  padding:11px 15px 10px;
  background:var(--surface);
  color:var(--ink);
  border:1px solid var(--kf-visual-edge);
  border-radius:15px 15px 15px 5px;
  box-shadow:0 5px 14px rgba(35,29,73,.07);
}
.app .social-community .social-message.mine>div {
  border-color:var(--social-blue);
  border-radius:15px 15px 5px 15px;
  background:var(--social-blue);
  color:#fff;
}
.app .social-community .social-message strong {font-size:11px;line-height:1.4;margin:0 0 6px;}
.app .social-community .social-message p {font-size:13px;line-height:1.75;color:var(--ink);}
.app .social-community .social-message.mine p {color:#fff;}
.app .social-community .social-message footer {font-size:10px;margin-top:8px;}
.app .social-community .social-message .social-avatar {
  display:inline-flex;width:31px;height:31px;min-width:31px;
  background:var(--surface);color:var(--primary);
  border:1px solid var(--kf-visual-edge);
  font-size:10px;
}
.app .social-community .social-message.mine .social-avatar {display:none;}
.app .social-community .social-chat-bottom {padding:14px 18px 13px;}
.app .social-community .social-chat-compose textarea {font-size:13px;min-height:55px;line-height:1.75;}
.app .social-community .social-chat-bottom>small {font-size:11px;line-height:1.7;}
.app .social-community .social-chat-bottom .social-notice {font-size:12px;line-height:1.8;}

/* 5 — Responsive: avoid giant title bars and mixed columns on mobile */
@media(max-width:1100px) {
  .app .social-community .social-feed-layout {grid-template-columns:minmax(0,1fr) 240px;}
  .app .social-community .social-feed-aside {position:static;}
  .app .portal-main {padding-inline:clamp(14px,2vw,28px);}
}
@media(max-width:850px) {
  .app .social-community .social-feed-layout {grid-template-columns:minmax(0,1fr);}
  .app .social-community .social-feed-aside {display:none;}
  .app .page-title {align-items:flex-start;}
  .app .social-community .social-heading {padding:17px 20px;}
  .app .social-community .social-heading>div {flex-basis:270px;}
  .app .social-community .social-heading h1,.app .social-community .social-heading h2 {font-size:clamp(22px,3.4vw,29px);}
}
@media(max-width:580px) {
  .app .portal-main,.learner-app .portal-main {padding-inline:13px;}
  .app .page-title {margin-bottom:19px;padding-bottom:13px;}
  .app .social-community .social-heading {border-radius:14px;gap:12px;padding:15px 15px 16px;}
  .app .social-community .social-heading>div {flex-basis:100%;}
  .app .social-community .social-heading h1,.app .social-community .social-heading h2 {font-size:24px;}
  .app .social-community .social-heading p {font-size:12px;}
  .app .social-community .social-refresh {min-height:38px;padding:8px 12px;}
  .app .social-community .social-navigation {display:grid;grid-template-columns:1fr 1fr;width:100%;}
  .app .social-community .social-navigation button {font-size:12px;padding:10px 8px;justify-content:center;gap:5px;}
  .app .social-community .social-post {border-radius:15px;}
  .app .social-community .social-post>header {padding:16px 15px 10px;gap:10px;}
  .app .social-community .social-post>header .social-avatar {width:40px;height:40px;flex-basis:40px;}
  .app .social-community .social-post-copy {padding:7px 15px 17px;}
  .app .social-community .social-post-counts {margin-inline:15px;padding-block:12px 10px;}
  .app .social-community .social-post-actions {padding:7px 15px 12px;}
  .app .social-community .social-comments {padding:16px 12px 18px;}
  .app .social-community .social-comment>div>div {padding:11px 12px;}
  .app .social-community .social-comment-form>.social-avatar {display:none;}
  .app .social-community .social-chat-messages {padding:14px 10px;}
  .app .social-community .social-message {max-width:92%;}
  .app .social-community .social-message>div {padding:10px 12px;}
  .app .social-community .social-chat-head {padding:12px 14px;}
  .app .social-community .social-chat-bottom {padding:11px 12px;}
}
@media(prefers-reduced-motion:reduce) {
  .app .social-community :where(button,a) {scroll-behavior:auto;}
}
