/* ชุมชนบ้านเรียน — community */
.cm { background: #f3efe4; padding: 24px 0 64px; min-height: 70vh; }
.cm-layout { display: grid; grid-template-columns: 250px minmax(0, 640px) 300px; gap: 24px; justify-content: center; align-items: start; }
.cm-left, .cm-right { position: sticky; top: 100px; display: grid; gap: 14px; }
.cm-center { display: grid; gap: 14px; min-width: 0; }
.cm-card { background: var(--paper); border-radius: 18px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(31,77,43,.06), 0 6px 20px -14px rgba(31,77,43,.25); }
.cm-card h2 { font-size: 19px; margin-bottom: 10px; }
.cm-card h3 { font-size: 17px; margin-bottom: 10px; }
.cm-title { font-size: 28px; font-weight: 800; }
.cm-title small { display: block; font-size: 12px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: #9aa59c; }
.cm-muted { color: var(--muted); font-size: 16px; margin: 0; }
.cm-count { font-size: 14px; color: var(--muted); font-weight: 500; }
.cm-more { display: inline-block; margin-top: 8px; font-size: 15px; color: var(--leaf); }
.cm-back { margin: 0; font-size: 15px; }
.cm-back a { color: var(--muted); }
.cm-flash { padding: 12px 16px; border-radius: 14px; background: var(--leaf-soft); color: var(--forest-2); border: 1px solid #cfe2bd; font-size: 16px; }
.cm-flash--err { background: #fdecea; color: #b42318; border-color: #f5c2bd; }
.btn--block { width: 100%; justify-content: center; margin-top: 8px; }

/* Avatars */
.cm-av { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; background: var(--leaf-soft); }
.cm-av--32 { width: 32px; height: 32px; font-size: 14px; }
.cm-av--40 { width: 40px; height: 40px; font-size: 17px; }
.cm-av--48 { width: 48px; height: 48px; font-size: 20px; }
.cm-av--96 { width: 96px; height: 96px; font-size: 38px; }
.cm-av--128 { width: 128px; height: 128px; font-size: 52px; }
.cm-av--txt { color: #fff; font-weight: 700; }
.cm-av--h0 { background: #5e9a35; } .cm-av--h1 { background: #e0892b; } .cm-av--h2 { background: #2f7f9e; } .cm-av--h3 { background: #a0569a; }
.cm-av--h4 { background: #c0533f; } .cm-av--h5 { background: #3f8f6f; } .cm-av--h6 { background: #8a6d2f; } .cm-av--h7 { background: #5566b8; }

/* Buttons */
.cm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 10px; border: 0; background: #ebe6d8; color: var(--forest-2); font: 600 15px/1.2 var(--body); cursor: pointer; text-decoration: none; transition: background .15s; }
.cm-btn:hover { background: #e0d9c6; }
.cm-btn--pri { background: var(--forest); color: #fff; }
.cm-btn--pri:hover { background: var(--leaf); }
.cm-btn--ghost { background: transparent; }
.cm-btn--ghost:hover { background: #f1ede2; }
.cm-btn[disabled] { opacity: .6; cursor: progress; }

/* Left nav */
.cm-me { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; text-decoration: none; color: var(--ink); }
.cm-me:hover { background: #e9e3d4; }
.cm-me b { display: block; font-size: 17px; line-height: 1.3; }
.cm-me small { color: var(--muted); font-size: 14px; }
.cm-nav { display: grid; gap: 2px; }
.cm-nav a, .cm-nav__out { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--ink); font: 500 17px var(--body); background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.cm-nav a:hover, .cm-nav__out:hover { background: #e9e3d4; }
.cm-nav a[aria-current] { background: var(--paper); color: var(--forest-2); font-weight: 700; box-shadow: 0 4px 14px -10px rgba(31,77,43,.5); }
.cm-nav__ico { width: 36px; height: 36px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-size: 18px; flex: none; }
.cm-nav form { margin: 0; }
.cm-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #e0413a; color: #fff; font: 700 13px/22px var(--body); text-align: center; font-style: normal; }
.cm-welcome p { color: var(--muted); font-size: 16px; }

/* Mobile tabs */
.cm-tabs { display: none; }

/* Composer */
.cm-composer__top { display: flex; gap: 12px; align-items: flex-start; }
.cm-composer textarea { flex: 1; resize: vertical; min-height: 48px; border: 0; background: #f3efe4; border-radius: 22px; padding: 12px 18px; font: 400 18px/1.5 var(--body); color: var(--ink); }
.cm-composer textarea:focus { outline: 2px solid var(--leaf); background: #fff; }
.cm-composer__bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.cm-composer__bar select { margin-left: auto; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: 500 15px var(--body); background: #fff; color: var(--ink); }
.cm-composer__photo { cursor: pointer; }
.cm-composer__previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 12px; }
.cm-composer__previews figure { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eee; }
.cm-composer__previews img { width: 100%; height: 100%; object-fit: cover; }
.cm-composer__previews button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; }
.cm-composer__err { margin: 10px 0 0; color: #b42318; font-size: 15px; }
.cm-composer.is-busy { opacity: .7; pointer-events: none; }

.cm-seg { display: flex; gap: 6px; }
.cm-seg a { flex: 1; text-align: center; padding: 10px; border-radius: 12px; background: var(--paper); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 16px; }
.cm-seg a[aria-current] { background: var(--forest); color: #fff; }

/* Post */
.cm-post { padding: 0; overflow: clip; }
.cm-post__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.cm-post__who { flex: 1; min-width: 0; line-height: 1.3; }
.cm-post__name { font-weight: 700; color: var(--forest-2); text-decoration: none; font-size: 17px; }
.cm-post__name:hover { text-decoration: underline; }
.cm-post__who small { display: block; font-size: 14px; color: var(--muted); }
.cm-post__who small a { color: inherit; text-decoration: none; }
.cm-post__who small a:hover { text-decoration: underline; }
.cm-post__body { padding: 4px 18px 12px; font-size: 18px; line-height: 1.65; white-space: normal; overflow-wrap: anywhere; }
.cm-post__body.is-big { font-size: 24px; line-height: 1.5; }
.cm-post__body a { color: var(--leaf); }
.cm-menu { position: relative; }
.cm-menu summary { list-style: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 22px; color: var(--muted); }
.cm-menu summary::-webkit-details-marker { display: none; }
.cm-menu summary:hover { background: #f1ede2; }
.cm-menu__list { position: absolute; right: 0; top: 40px; z-index: 10; min-width: 200px; background: #fff; border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px -8px rgba(0,0,0,.25); }
.cm-menu__list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; font: 500 16px var(--body); cursor: pointer; color: var(--ink); }
.cm-menu__list button:hover { background: #f3efe4; }

/* Photo grid */
.cm-grid { display: grid; gap: 3px; background: #fff; }
.cm-grid__item { position: relative; display: block; overflow: hidden; background: #eee; }
.cm-grid__item img { width: 100%; height: 100%; object-fit: cover; transition: filter .2s; }
.cm-grid__item:hover img { filter: brightness(.93); }
.cm-grid__item.is-hidden { display: none; }
.cm-grid--1 .cm-grid__item img { max-height: 640px; height: auto; object-fit: contain; background: #f3efe4; margin: 0 auto; }
.cm-grid--2 { grid-template-columns: 1fr 1fr; }
.cm-grid--2 .cm-grid__item { aspect-ratio: 1; }
.cm-grid--3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3 / 2; }
.cm-grid--3 .cm-grid__item:first-child { grid-row: 1 / 3; }
.cm-grid--4 { grid-template-columns: 1fr 1fr; }
.cm-grid--4 .cm-grid__item { aspect-ratio: 1; }
.cm-grid__more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font: 700 34px var(--body); }

/* Stats + actions */
.cm-post__stats { display: flex; justify-content: space-between; align-items: center; min-height: 20px; padding: 10px 18px 6px; font-size: 15px; color: var(--muted); }
.cm-post__stats a { color: inherit; text-decoration: none; }
.cm-post__stats a:hover { text-decoration: underline; }
.cm-sum { display: inline-flex; align-items: center; gap: 6px; }
.cm-sum__ico { display: inline-flex; }
.cm-sum__ico i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 14px; margin-left: -4px; box-shadow: 0 0 0 2px #fff; }
.cm-sum__ico i:first-child { margin-left: 0; }
.cm-post__acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 12px; padding: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cm-act { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 9px 6px; border: 0; background: none; border-radius: 10px; font: 600 15px var(--body); color: var(--muted); cursor: pointer; }
.cm-act:hover { background: #f3efe4; }
.cm-act span { font-size: 18px; }
.cm-act.is-on { color: var(--leaf); }
.cm-react { position: relative; }
.cm-react__picker { position: absolute; left: 0; bottom: calc(100% + 6px); display: flex; gap: 2px; padding: 6px 8px; background: #fff; border-radius: 999px; box-shadow: 0 10px 30px -6px rgba(0,0,0,.3); opacity: 0; transform: translateY(8px) scale(.9); pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5; }
.cm-react:hover .cm-react__picker, .cm-react.is-open .cm-react__picker { opacity: 1; transform: none; pointer-events: auto; transition-delay: .25s; }
.cm-react.is-open .cm-react__picker { transition-delay: 0s; }
.cm-react__picker button { width: 42px; height: 42px; border: 0; background: none; font-size: 28px; cursor: pointer; border-radius: 50%; transition: transform .15s; }
.cm-react__picker button:hover { transform: scale(1.3) translateY(-4px); }

/* Comments */
.cm-cmts { padding: 8px 16px 0; display: grid; gap: 8px; }
.cm-cmts:empty { display: none; }
.cm-more-cmts { font-size: 15px; font-weight: 600; color: var(--muted); }
.cm-cmt { display: flex; gap: 8px; align-items: flex-start; }
.cm-cmt__main { min-width: 0; }
.cm-cmt__bubble { background: #f3efe4; border-radius: 18px; padding: 8px 14px; }
.cm-cmt__name { font-weight: 700; font-size: 15px; color: var(--forest-2); text-decoration: none; }
.cm-cmt__bubble p { margin: 0; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.cm-cmt__meta { display: flex; gap: 12px; padding: 2px 12px 0; font-size: 13px; color: var(--muted); }
.cm-cmt__meta button { border: 0; background: none; padding: 0; font: 600 13px var(--body); color: var(--muted); cursor: pointer; }
.cm-cmt__meta button:hover { text-decoration: underline; }
.cm-cform { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; }
.cm-cform input { flex: 1; border: 0; background: #f3efe4; border-radius: 999px; padding: 10px 16px; font: 400 16px var(--body); color: var(--ink); min-width: 0; }
.cm-cform input:focus { outline: 2px solid var(--leaf); background: #fff; }
.cm-cform button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--forest); color: #fff; font-size: 16px; cursor: pointer; }
.cm-login-hint { margin: 0; padding: 12px 18px 16px; font-size: 15px; color: var(--muted); }

.cm-loadmore { text-align: center; }
.cm-empty { text-align: center; padding: 40px 20px; }
.cm-empty > div { font-size: 52px; }
.cm-empty p { color: var(--muted); }

/* People */
.cm-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.cm-person { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.cm-person__main { min-width: 0; flex: 1; }
.cm-person__name { font-weight: 700; color: var(--forest-2); text-decoration: none; font-size: 16px; }
.cm-person__main small { display: block; color: var(--muted); font-size: 13px; }
.cm-person__act { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.cm-person__act .cm-btn { padding: 6px 12px; font-size: 14px; }
.cm-rules-mini ul { margin: 0; padding-left: 1.2em; font-size: 15px; color: var(--muted); }
.cm-rules-mini li { margin-bottom: 4px; }

/* Profile */
.cm-profile { padding: 0; overflow: clip; }
.cm-profile__cover { height: 220px; background: linear-gradient(115deg, #bcd9a3, #f0d59a, #a8d4e6); }
.cm-profile__cover img { width: 100%; height: 100%; object-fit: cover; }
.cm-profile__main { display: flex; align-items: flex-end; gap: 16px; padding: 0 20px 16px; margin-top: -56px; flex-wrap: wrap; }
.cm-profile__av { box-shadow: 0 0 0 5px #fff; }
.cm-profile__info { flex: 1; min-width: 200px; }
.cm-profile__info h1 { font-size: 28px; font-weight: 800; }
.cm-profile__meta { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.cm-profile__act { display: flex; gap: 8px; }
.cm-profile__about { padding: 0 20px 18px; font-size: 16px; }
.cm-profile__about p { margin: 0 0 6px; }
.cm-profile__family { color: var(--muted); }

/* Notifications */
.cm-notis { padding: 8px; }
.cm-noti { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; text-decoration: none; color: var(--ink); font-size: 16px; }
.cm-noti:hover { background: #f3efe4; }
.cm-noti.is-new { background: var(--leaf-soft); }
.cm-noti small { display: block; color: var(--muted); font-size: 13px; }
.cm-noti__ico { position: absolute; left: 44px; top: 42px; width: 24px; height: 24px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

/* Auth + forms */
.cm-auth { display: grid; place-items: center; }
.cm-auth__card { width: min(440px, 100%); padding: 30px 28px; text-align: center; }
.cm-auth__card img { margin: 0 auto 8px; }
.cm-auth__card h1 { font-size: 24px; margin-bottom: 16px; }
.cm-auth__card label, .cm-form label { display: block; text-align: left; font-weight: 600; font-size: 15px; margin-bottom: 12px; color: var(--forest-2); }
.cm-auth__card label small, .cm-form label small { font-weight: 400; color: var(--muted); }
.cm-auth__card input[type=text], .cm-auth__card input[type=email], .cm-auth__card input[type=password],
.cm-form input[type=text], .cm-form input[type=password], .cm-form textarea { display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border: 1px solid #d8d1bf; border-radius: 12px; font: 400 16px var(--body); color: var(--ink); background: #fff; }
.cm-auth__card input:focus, .cm-form input:focus, .cm-form textarea:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(94,154,53,.2); }
.cm-auth__note { text-align: left; margin-bottom: 14px; font-size: 15px; }
.cm-auth__alt { margin: 16px 0 0; font-size: 15px; color: var(--muted); }
.cm-check { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 500 !important; }
.cm-check input { margin-top: 5px; accent-color: var(--leaf); }
.cm-hp { position: absolute !important; left: -9999px; }
.cm-form__av { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.cm-form__av img { width: 96px; height: 96px; }
.cm-pass { margin: 6px 0 16px; }
.cm-pass summary { cursor: pointer; font-weight: 600; color: var(--forest-2); margin-bottom: 10px; }
.cm-prose h2 { font-size: 20px; margin: 18px 0 6px; }
.cm-prose p, .cm-prose li { font-size: 17px; }

/* Lightbox */
.cm-lb { position: fixed; inset: 0; z-index: 100; background: rgba(10,16,12,.94); display: grid; place-items: center; }
.cm-lb img { max-width: 94vw; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.cm-lb button { position: absolute; border: 0; background: rgba(255,255,255,.14); color: #fff; width: 48px; height: 48px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.cm-lb button:hover { background: rgba(255,255,255,.28); }
.cm-lb__close { top: 16px; right: 16px; }
.cm-lb__prev { left: 16px; top: 50%; }
.cm-lb__next { right: 16px; top: 50%; }
.cm-lb__count { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 15px; }

.cm-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 120; background: var(--forest-2); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 16px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); }

@media (max-width: 1180px) {
  .cm-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .cm-right { display: none; }
}
@media (max-width: 860px) {
  .cm { padding-top: 0; }
  .cm-layout { grid-template-columns: minmax(0, 1fr); }
  .cm-left { display: none; }
  .cm-tabs { position: sticky; top: 82px; z-index: 20; display: flex; justify-content: space-around; margin: 0 -16px; padding: 4px 8px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .cm-tabs a { position: relative; flex: 1; display: grid; justify-items: center; padding: 6px 2px 4px; text-decoration: none; color: var(--muted); font-size: 22px; border-bottom: 3px solid transparent; }
  .cm-tabs a small { font-size: 11px; }
  .cm-tabs a[aria-current] { color: var(--forest); border-bottom-color: var(--forest); }
  .cm-tabs .cm-badge { position: absolute; top: 2px; left: 55%; margin: 0; }
  .cm-post__body.is-big { font-size: 21px; }
  .cm-profile__cover { height: 150px; }
  .cm-profile__main { margin-top: -48px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .cm-profile__info { min-width: 0; }
  .cm-profile__info h1 { font-size: 24px; }
  .cm-grid--1 .cm-grid__item img { max-height: 520px; }
}
@media (max-width: 480px) {
  .cm-card { border-radius: 0; margin: 0 -16px; }
  .cm-act { font-size: 13px; }
  .cm-composer__bar { flex-wrap: wrap; }
}
.cm-profile__school { margin: 2px 0 0; font-weight: 600; color: var(--leaf); font-size: 17px; }
.cm-profile__social { margin-top: 8px; }
.cm-profile__social .social-ico { width: 34px; height: 34px; }
.cm-socials { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 4px; margin: 0 0 14px; }
.cm-socials legend { font-weight: 700; color: var(--forest-2); padding: 0 6px; font-size: 15px; }
.cm-socials legend small { font-weight: 400; color: var(--muted); }
.cm-profile__main { align-items: flex-start; }
.cm-profile__info { padding-top: 64px; }
.cm-profile__act { padding-top: 70px; }
@media (max-width: 860px) { .cm-profile__info, .cm-profile__act { padding-top: 0; } }
