[data-board-background="solid-cloud"] {
  --class-board-background-color: #f5f7fb;
  --class-board-background-image: none;
}

[data-board-background="solid-lavender"] {
  --class-board-background-color: #f0edff;
  --class-board-background-image: none;
}

[data-board-background="solid-sky"] {
  --class-board-background-color: #eaf5ff;
  --class-board-background-image: none;
}

[data-board-background="solid-mint"] {
  --class-board-background-color: #eaf8f2;
  --class-board-background-image: none;
}

[data-board-background="solid-peach"] {
  --class-board-background-color: #fff1e9;
  --class-board-background-image: none;
}

[data-board-background="solid-butter"] {
  --class-board-background-color: #fff8dc;
  --class-board-background-image: none;
}

[data-board-background="gradient-dawn"] {
  --class-board-background-color: #f5efff;
  --class-board-background-image: linear-gradient(135deg, #f4efff 0%, #fff1e7 52%, #eaf6ff 100%);
}

[data-board-background="gradient-sky"] {
  --class-board-background-color: #eaf7ff;
  --class-board-background-image: linear-gradient(135deg, #e4f4ff 0%, #eff8ff 45%, #f4efff 100%);
}

[data-board-background="gradient-mint"] {
  --class-board-background-color: #e9faf4;
  --class-board-background-image: linear-gradient(135deg, #e5faf2 0%, #eef7ff 48%, #f2edff 100%);
}

[data-board-background="gradient-rose"] {
  --class-board-background-color: #fff1f3;
  --class-board-background-image: linear-gradient(135deg, #fff0f3 0%, #fff4e9 52%, #f1edff 100%);
}

[data-board-background="image-stationery-01"] {
  --class-board-background-color: #fbf6e9;
  --class-board-background-image: url("/class-board-assets/backgrounds/stationery-01.webp");
}

.board-focus-panel[data-board-background] {
  background-color: var(--class-board-background-color);
  background-image: var(--class-board-background-image);
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 24px;
  isolation: isolate;
}

body.student-board-page[data-board-has-selection="true"][data-board-background] {
  background-color: var(--class-board-background-color);
  background-image: var(--class-board-background-image);
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

.board-focus-panel[data-board-background] > * {
  position: relative;
  z-index: 1;
}

.board-background-field {
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 18px;
  padding: 18px;
}

.board-background-heading h3,
.board-background-group h4 {
  margin: 0;
}

.board-background-heading p {
  color: #94a3b8;
  font-size: 0.82rem;
  margin: 5px 0 0;
}

.board-background-picker {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.board-background-group {
  display: grid;
  gap: 9px;
}

.board-background-group h4 {
  color: #cbd5e1;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.board-background-choices {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
}

.board-background-group:nth-child(n + 2) .board-background-choices {
  grid-template-columns: repeat(4, minmax(110px, 1fr));
}

.board-background-group:last-child .board-background-choices {
  grid-template-columns: minmax(150px, 210px);
}

.board-background-choice {
  background: rgba(15, 23, 42, 0.5);
  border: 2px solid transparent;
  border-radius: 13px;
  color: #e2e8f0;
  cursor: pointer;
  display: grid;
  gap: 7px;
  padding: 6px;
  text-align: left;
}

.board-background-choice:hover,
.board-background-choice:focus-visible {
  border-color: rgba(96, 165, 250, 0.7);
  outline: none;
}

.board-background-choice.is-selected {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.board-background-choice-preview {
  background-color: var(--class-board-background-color);
  background-image: var(--class-board-background-image);
  background-position: center;
  background-size: cover;
  border-radius: 8px;
  display: block;
  height: 64px;
}

.board-background-choice-label {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 3px 2px;
}

#writeModal .write-modal {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(812px, calc(100dvh - 72px));
  max-width: 1180px;
  overflow: hidden;
  padding: 0;
  width: calc(100vw - 48px);
}

#writeModal .write-modal .modal-header {
  align-items: center;
  background: #ffffff;
  border-bottom: 0;
  display: flex;
  min-height: 72px;
  padding: 20px 28px 10px;
}

#writeModal .write-modal .modal-header h2 {
  color: #0f172a;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

#writeModal .write-modal .close-btn {
  color: #64748b;
}

#writeModal .write-modal .modal-body {
  background: #ffffff;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 28px 22px;
}

#writeModal .write-modal-intro {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #dbe3ee;
  border-radius: 11px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(250px, auto) minmax(0, 1fr) auto;
  margin-bottom: 22px;
  min-height: 58px;
  padding: 9px 14px;
}

#writeModal .writer-lock-group {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 34px auto minmax(110px, 180px);
  margin: 0;
}

#writeModal .write-author-avatar {
  align-items: center;
  background: #e7efff;
  border: 1px solid #c7d8ff;
  border-radius: 50%;
  color: #315fd6;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

#writeModal .writer-lock-group > label {
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0;
}

#writeModal .writer-lock-input-wrap {
  align-items: center;
  display: flex;
  gap: 7px;
}

#writeModal .writer-lock-input-wrap input {
  background: transparent;
  border: 0;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 0;
  padding: 0;
}

#writeModal .writer-lock-badge {
  background: #e8efff;
  border: 1px solid #c4d5ff;
  border-radius: 999px;
  color: #315fd6;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
}

#writeModal .writer-lock-group > .input-helper-text {
  display: none;
}

#writeModal .write-status-text {
  color: #64748b;
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#writeModal .write-intro-actions {
  align-items: center;
  display: flex;
  gap: 18px;
}

#writeModal .write-intro-actions .btn-outline {
  align-items: center;
  border: 0;
  color: #334155;
  display: inline-flex;
  gap: 7px;
  padding: 8px 10px;
}

#writeModal .write-intro-actions .input-helper-text {
  color: #78869a;
  font-size: 0.76rem;
  white-space: nowrap;
}

#writeModal .write-form-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.board-page #writeModal .write-form-stack {
  display: grid;
  gap: 18px 22px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

body.board-page #writeModal #postTitleGroup,
body.board-page #writeModal #postShelfGroup,
body.board-page #writeModal #postContentGroup {
  grid-column: 1;
}

body.board-page #writeModal #writeAttachmentPanel {
  border-left: 1px dashed #cbd5e1;
  border-top: 0;
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 0 0 0 22px;
}

#writeModal .write-form-stack > .form-group,
#writeModal .write-attachment-panel {
  margin: 0;
}

#writeModal .write-modal .form-group > label,
#writeModal .write-attachment-header-title {
  color: #0f172a;
  font-size: 0.94rem;
  font-weight: 800;
  margin-bottom: 8px;
}

#writeModal #postTitle,
#writeModal #postShelf {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  box-sizing: border-box;
  color: #172033;
  display: block;
  min-height: 50px;
  padding: 0 14px;
  width: 100%;
}

#writeModal .input-meta-row {
  min-height: 19px;
}

#writeModal .rich-editor-shell {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  overflow: hidden;
}

#writeModal .rich-editor-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #dbe3ee;
  gap: 6px;
  padding: 8px 10px;
}

#writeModal .rich-editor-btn,
#writeModal .rich-editor-color {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 7px;
  color: #172033;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  width: 38px;
}

#writeModal .rich-editor {
  color: #172033;
  min-height: 250px;
  padding: 16px;
}

#writeModal .write-attachment-panel {
  background: transparent;
  border: 0;
  border-top: 1px dashed #cbd5e1;
  border-radius: 0;
  padding: 16px 0 0;
}

#writeModal .write-attachment-header {
  display: none;
}

#writeModal .write-attachment-content {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0;
}

body.board-page #writeModal .write-attachment-content {
  grid-template-columns: 1fr;
}

#writeModal .write-attachment-content > .form-group {
  background: #ffffff;
  border: 1px solid #d9e1eb;
  border-radius: 12px;
  min-width: 0;
  padding: 16px;
}

#writeModal .write-attachment-label {
  align-items: center;
  display: flex;
  gap: 9px;
}

#writeModal .write-attachment-label i {
  align-items: center;
  background: #e7efff;
  border-radius: 9px;
  color: #3b6fe8;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

#writeModal .write-attachment-content input[type="url"] {
  background: #f8fafc;
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  min-height: 42px;
}

#writeModal .write-attachment-content .upload-row {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#writeModal .write-attachment-content input[type="file"] {
  max-width: 100%;
}

#writeModal .image-dropzone {
  min-height: 42px;
  padding: 9px;
}

#writeModal #boardPostCurrentFiles,
#writeModal #studentBoardPostCurrentFiles {
  grid-column: 1 / -1;
}

#writeModal .write-modal .modal-footer {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  gap: 12px;
  justify-content: flex-end;
  padding: 14px 28px 18px;
}

#writeModal .write-modal .modal-footer .btn-secondary,
#writeModal .write-modal .modal-footer .btn-primary {
  border-radius: 10px;
  min-height: 48px;
  min-width: 104px;
  padding: 0 22px;
}

#writeModal .write-modal .modal-footer .btn-primary {
  background: #3567e8;
  border-color: #3567e8;
  box-shadow: 0 7px 18px rgba(53, 103, 232, 0.25);
}

@media (max-width: 960px) {
  .board-background-choices,
  .board-background-group:nth-child(n + 2) .board-background-choices {
    grid-template-columns: repeat(3, minmax(90px, 1fr));
  }

  #writeModal .write-modal-intro {
    grid-template-columns: 1fr auto;
  }

  #writeModal .write-modal .modal-body {
    overflow-y: auto;
  }

  body.board-page #writeModal .write-form-stack {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }

  body.board-page #writeModal #writeAttachmentPanel {
    border-left: 0;
    border-top: 1px dashed #cbd5e1;
    grid-column: auto;
    grid-row: auto;
    padding: 16px 0 0;
  }

  body.board-page[data-board-role="student"] #writeModal .write-status-text {
    display: block;
    grid-column: 1 / -1;
    white-space: normal;
  }

  #writeModal .write-intro-actions .input-helper-text {
    display: none;
  }

  #writeModal .write-attachment-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .board-background-choices,
  .board-background-group:nth-child(n + 2) .board-background-choices {
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }

  #writeModal .write-modal {
    border-radius: 16px 16px 0 0;
    max-height: 94dvh;
    width: 100vw;
  }

  #writeModal .write-modal .modal-header,
  #writeModal .write-modal .modal-body,
  #writeModal .write-modal .modal-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  #writeModal .write-modal-intro {
    grid-template-columns: 1fr;
  }

  #writeModal .write-intro-actions {
    justify-content: flex-start;
  }

  #writeModal .rich-editor-toolbar {
    overflow-x: auto;
  }
}

/* Shared board composer overlay and native student dialog. */
body.board-page #writeModal {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

body.board-page #writeModal.write-dialog {
  background: transparent;
  border: 0;
  box-sizing: border-box;
  height: 100dvh;
  inset: 0;
  margin: 0;
  max-height: none;
  max-width: none;
  overflow: hidden;
  padding: 24px;
  width: 100vw;
}

body.board-page #writeModal.write-dialog[open] {
  align-items: center;
  display: flex;
  justify-content: center;
}

body.board-page #writeModal.write-dialog:not([open]) {
  display: none !important;
}

body.board-page #writeModal.write-dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(7px);
}

body.board-page #writeModal .write-modal {
  box-sizing: border-box;
  margin: 0;
  min-width: 0;
}

body.board-page #writeModal .write-modal .modal-body {
  display: block !important;
  grid-template-columns: none !important;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

body.board-page #writeModal .write-form-stack,
body.board-page #writeModal .write-modal-intro,
body.board-page #writeModal .writer-lock-input-wrap {
  max-width: 100%;
  min-width: 0;
}

body.board-page #writeModal .writer-lock-group {
  grid-column: auto;
  grid-row: auto;
}

body.board-page #writeModal .writer-lock-input-wrap input {
  width: 100%;
}

body.board-page .student-board-compose {
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: auto !important;
  position: fixed !important;
  right: calc(28px + env(safe-area-inset-right, 0px)) !important;
  top: auto !important;
  z-index: 1700;
}

body.board-page .student-board-compose[hidden] {
  display: none !important;
}

.post-card[data-post-background="post-cloud"],
.post-color-swatch[data-post-background="post-cloud"] { --post-pastel: #f8fafc; }
.post-card[data-post-background="post-butter"],
.post-color-swatch[data-post-background="post-butter"] { --post-pastel: #fff8dc; }
.post-card[data-post-background="post-peach"],
.post-color-swatch[data-post-background="post-peach"] { --post-pastel: #fff0e8; }
.post-card[data-post-background="post-rose"],
.post-color-swatch[data-post-background="post-rose"] { --post-pastel: #ffecef; }
.post-card[data-post-background="post-lavender"],
.post-color-swatch[data-post-background="post-lavender"] { --post-pastel: #f1edff; }
.post-card[data-post-background="post-sky"],
.post-color-swatch[data-post-background="post-sky"] { --post-pastel: #eaf5ff; }
.post-card[data-post-background="post-mint"],
.post-color-swatch[data-post-background="post-mint"] { --post-pastel: #eaf8f2; }
.post-card[data-post-background="post-sage"],
.post-color-swatch[data-post-background="post-sage"] { --post-pastel: #f0f5e8; }

body.board-page .post-card[data-post-background] {
  background: var(--post-pastel);
  overflow: visible;
  position: relative;
}

body.board-page .post-card[data-post-background] .post-body,
body.board-page .post-card[data-post-background] .comments-section {
  background: transparent;
}

body.board-page .post-head-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  position: relative;
}

.post-overflow-menu {
  position: relative;
  z-index: 5;
}

.post-overflow-menu[open] {
  z-index: 30;
}

.post-overflow-trigger {
  align-items: center;
  border: 1px solid rgba(100, 116, 139, 0.22);
  border-radius: 10px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  list-style: none;
  width: 36px;
}

.post-overflow-trigger::-webkit-details-marker { display: none; }
.post-overflow-trigger:hover,
.post-overflow-trigger:focus-visible,
.post-overflow-menu[open] .post-overflow-trigger {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(59, 130, 246, 0.46);
  color: #1d4ed8;
  outline: none;
}

.post-overflow-panel {
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
  display: grid;
  gap: 7px;
  min-width: 224px;
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 40;
}

.post-menu-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: #334155;
  cursor: pointer;
  display: flex;
  font-weight: 750;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.post-menu-action:hover,
.post-menu-action:focus-visible { background: #f1f5f9; outline: none; }
.post-menu-action.danger { color: #be123c; }
.post-menu-label { color: #64748b; font-size: 0.74rem; font-weight: 800; padding: 4px 4px 0; }

.post-color-palette {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(4, 32px);
  padding: 2px 4px 5px;
}

.post-color-swatch {
  background: var(--post-pastel);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
  height: 30px;
  width: 30px;
}

.post-color-swatch:hover,
.post-color-swatch:focus-visible,
.post-color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px #3b82f6;
  outline: none;
}

.post-pinned-chip {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 999px;
  color: #315fd6;
  display: inline-flex;
  font-size: 0.68rem;
  font-weight: 850;
  gap: 4px;
  margin-left: 5px;
  padding: 3px 7px;
  vertical-align: middle;
}

body.board-page dialog.student-board-admin-dialog[open] {
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
  width: min(470px, calc(100vw - 32px));
}

body.board-page .student-board-admin-dialog .student-teacher-login-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-sizing: border-box;
  color: #172033;
  padding: 30px;
  position: relative;
  width: 100%;
}

body.board-page .student-board-admin-dialog .student-teacher-login-card h2 {
  color: #0f172a;
  font-size: 1.45rem;
  margin: 0 42px 8px 0;
}

body.board-page .student-board-admin-dialog .auth-message {
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 22px;
}

body.board-page .student-board-admin-dialog .board-teacher-login-close {
  align-items: center;
  background: #f1f5f9;
  border: 0;
  border-radius: 10px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 18px;
  top: 18px;
  width: 38px;
}

body.board-page .student-board-admin-dialog .student-teacher-login-form {
  gap: 9px;
}

body.board-page .student-board-admin-dialog .student-teacher-login-form label {
  color: #334155;
  font-size: 0.84rem;
  font-weight: 800;
}

body.board-page .student-board-admin-dialog .student-teacher-login-form input {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  box-sizing: border-box;
  color: #172033;
  min-height: 48px;
  padding: 0 13px;
}

body.board-page .student-board-admin-dialog .privacy-note,
body.board-page .student-board-admin-dialog .student-teacher-login-message {
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.55;
  margin: 4px 0;
}

body.board-page .student-board-admin-dialog .student-teacher-login-submit {
  border-radius: 11px;
  min-height: 50px;
  width: 100%;
}

@media (max-width: 620px) {
  body.board-page #writeModal.write-dialog { align-items: flex-end; padding: 0; }
  body.board-page .student-board-compose {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    right: calc(18px + env(safe-area-inset-right, 0px)) !important;
  }
  .post-overflow-panel { max-width: calc(100vw - 40px); }
  body.board-page .student-board-admin-dialog .student-teacher-login-card { padding: 26px 22px; }
}
