*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: Inter, system-ui, sans-serif; background: #0f0f11; color: #e8e8ec; }
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 28px 40px 40px;
  overflow-x: hidden;
  overflow-y: auto;
}
.view { display: none; width: 100%; }
.view.active { display: block; }
.main.main--profile {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Mount wrappers broke full-height flex after component split — stretch active view shell */
.main.main--profile > [id^="mount-view-"] {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.main.main--profile > [id^="mount-view-"].mount-view--active {
  display: flex;
  flex-direction: column;
}

.main.main--profile > [id^="mount-view-"] > .view {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.main.main--profile > [id^="mount-view-"] > .view.active {
  display: flex;
  flex-direction: column;
}
.view-panel { width: 100%; max-width: 1100px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.lead { font-size: 14px; color: #9a9aaa; margin-bottom: 16px; line-height: 1.5; }
.lead strong { color: #e8e8ec; font-weight: 600; }
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.view-meta { font-size: 13px; color: #9a9aaa; min-height: 20px; margin-bottom: 16px; }
.view-meta.err { color: #f87171; }
.btn-primary {
  border: none;
  background: #6c63ff;
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: #5b52ee; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  border: 1px solid #2a2a32;
  background: transparent;
  color: #c4bfff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { border-color: #6c63ff; background: #6c63ff11; }
.btn-back {
  border: none;
  background: transparent;
  color: #9a9aaa;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px 6px 8px;
  margin-bottom: 16px;
  margin-left: -8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-back:hover { color: #c4bfff; background: #1c1c22; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.community-card {
  background: #18181c;
  border: 1px solid #2a2a32;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.community-card:hover { border-color: #6c63ff66; transform: translateY(-1px); }
.community-card h2 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.community-card p { font-size: 12px; color: #9a9aaa; line-height: 1.45; margin-bottom: 10px; }
.community-card .meta { font-size: 11px; color: #6b6b7a; }
.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}
.pill.public { background: #22c55e22; color: #86efac; }
.pill.private { background: #6b6b7a33; color: #9a9aaa; }
.pill.role-owner { background: #6c63ff33; color: #c4bfff; }
.pill.role-admin { background: #f59e0b22; color: #fcd34d; }
.pill.role-member { background: #38bdf822; color: #7dd3fc; }
.community-card h2 .pill { margin-left: 6px; }
.community-card h2 .pill:first-of-type { margin-left: 8px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.stat-card {
  flex: 1;
  min-width: 140px;
  background: #18181c;
  border: 1px solid #2a2a32;
  border-radius: 12px;
  padding: 16px;
}
.stat-card .num { font-size: 28px; font-weight: 700; color: #c4bfff; }
.stat-card .lbl { font-size: 12px; color: #9a9aaa; margin-top: 4px; }
.module-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.module-item {
  background: #18181c;
  border: 1px solid #2a2a32;
  border-radius: 10px;
  padding: 14px 16px;
}
.module-item h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.module-item p { font-size: 12px; color: #9a9aaa; }
.community-editor-header__left { gap: 8px; }
.community-editor-back {
  border: none;
  background: transparent;
  color: #9a9aaa;
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.community-editor-back:hover { color: #c4bfff; background: #1c1c22; }
.community-panel-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  width: 100%;
}
.community-readonly-value {
  font-size: 14px;
  color: #e8e8ec;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
#community-editor-app .community-editor-panel .module-list,
#module-editor-app .community-editor-panel .module-list {
  width: 100%;
}
#community-editor-app #community-general-form.cdb-ig--readonly .cdb-ig__control,
#community-editor-app #community-general-form.cdb-ig--readonly .cdb-select {
  opacity: 0.85;
  pointer-events: none;
}
#community-editor-actions.hidden,
#module-editor-actions.hidden,
#lesson-editor-actions.hidden {
  display: none;
}

#community-editor-app .community-editor-main,
#module-editor-app .community-editor-main,
#lesson-editor-app .lesson-editor-main,
#profile-settings-app .profile-settings-main {
  align-items: stretch;
  padding: 24px 28px 40px;
}

#community-editor-app .community-editor-panel,
#module-editor-app .community-editor-panel,
#lesson-editor-app .community-editor-panel {
  max-width: none;
  width: 100%;
}

#community-editor-app .profile-settings-row,
#module-editor-app .profile-settings-row,
#lesson-editor-app .lesson-editor-row,
#profile-settings-app .profile-settings-row {
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

#community-editor-app .profile-settings-sidebar,
#module-editor-app .profile-settings-sidebar,
#profile-settings-app .profile-settings-sidebar {
  align-self: stretch;
  min-height: 100%;
}

.module-item--clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.module-item--clickable:hover {
  border-color: #6c63ff;
  background: rgba(108, 99, 255, 0.06);
}

.module-item--with-thumb .module-item__row {
  display: flex;
  gap: 14px;
  align-items: stretch;
}
.module-item__thumb {
  width: 96px;
  min-width: 96px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #2a2a32;
  flex-shrink: 0;
}
.module-item__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f0f11;
  color: #6b6b7a;
  font-size: 20px;
}
.module-item__body {
  flex: 1;
  min-width: 0;
}

#module-banner-upload.cdb-file-upload--banner .cdb-file-upload__drop {
  min-height: 140px;
}
#module-banner-upload.cdb-file-upload--banner .cdb-file-upload__drop--has-file {
  padding: 10px;
}
#module-banner-upload.cdb-file-upload--banner .cdb-file-upload__preview {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 100px;
  max-height: 180px;
  border-radius: 8px;
  display: none;
}
#module-banner-upload.cdb-file-upload--banner .cdb-file-upload__drop--has-file .cdb-file-upload__preview {
  display: block;
}
#module-banner-upload.cdb-file-upload--banner .cdb-file-upload__drop--has-file .cdb-file-upload__prompt {
  display: none;
}
#create-lesson-btn.hidden {
  display: none;
}

#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__drop {
  min-height: 160px;
}
#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__drop--has-file {
  padding: 10px;
}
#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__preview--video {
  width: 100%;
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  background: #0f0f11;
  display: none;
}
#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__drop--has-file .cdb-file-upload__preview--video {
  display: block;
}
#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__drop--has-file .cdb-file-upload__icon,
#lesson-video-upload.cdb-file-upload--video .cdb-file-upload__drop--has-file .cdb-file-upload__prompt {
  display: none;
}

#community-editor-app #community-general-form.cdb-ig--readonly .cdb-select,
#view-module-detail #module-general-form.cdb-ig--readonly .cdb-ig__control,
#view-module-detail #module-general-form.cdb-ig--readonly .cdb-file-upload,
#view-lesson-detail #lesson-general-form.cdb-ig--readonly .cdb-ig__control,
#view-lesson-detail #lesson-general-form.cdb-ig--readonly .cdb-file-upload {
  opacity: 0.85;
  pointer-events: none;
}
.member-item .role-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  background: #6c63ff22;
  color: #c4bfff;
  vertical-align: middle;
  text-transform: capitalize;
}
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%;
  max-width: 420px;
  background: #18181c;
  border: 1px solid #2a2a32;
  border-radius: 14px;
  overflow: hidden;
}
.modal-header { padding: 18px 20px 12px; border-bottom: 1px solid #2a2a32; }
.modal-header h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-header p { font-size: 13px; color: #9a9aaa; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px solid #2a2a32;
}
.btn-cancel {
  border: 1px solid #2a2a32;
  background: transparent;
  color: #e8e8ec;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.form-error { font-size: 12px; color: #f87171; min-height: 16px; }
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  border: 2px solid #2a2a32;
  background: #0f0f11;
  object-fit: cover;
  flex-shrink: 0;
}
.profile-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b6b7a;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 8px;
  line-height: 1.3;
}

.mobile-header, .mobile-tabs { display: none; }
@media (max-width: 720px) {
  .main-sidebar { display: none; }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #141418;
    border-bottom: 1px solid #2a2a32;
  }
  .mobile-tabs {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: #141418;
    border-top: 1px solid #2a2a32;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: #6b6b7a;
    border-radius: 10px;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    min-height: 52px;
  }
  .tab-btn.active { color: #c4bfff; background: #6c63ff18; }
  .app { flex-direction: column; }
  .main { padding: 16px 16px calc(76px + env(safe-area-inset-bottom)); }
}
