/* Self-hosted Baloo 2 (latin + latin-ext). Do not load Google Fonts CDN.
 *
 * Sheet split (load order):
 * - styles.css — shared tokens, chrome, forms, cards (every page)
 * - styles-classroom.css — classroom board + setup-position (after shared)
 * - styles-app.css — resources, pupil, welcome, legal, etc. (after shared)
 */
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/baloo-2-latin-ext.woff2?v=1") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/baloo-2-latin.woff2?v=1") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --color-accent: #19f4ab;
  --color-accent-hover: #45f7bc;
  --color-cauldron-green: #19f4ab;
  --color-text: #fff;
  --color-text-on-accent: #1a2e1a;
  --color-bg-fallback: #1a2e1a;
  --color-bg-index-fallback: #eef2df;
  --color-error: #ff8a8a;
  --color-warning: #ffe08a;
  --color-link: #19f4ab;
  --color-cauldron: #ad96f4;
  --caret-color: color-mix(in srgb, var(--color-accent) 42%, white);
  --cursor-text: url("text-cursor.svg?v=5") 16 16, text;
  --font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", sans-serif;
  --border-subtle: 1px solid rgb(255 255 255 / 35%);
  --border-input: 1px solid rgb(255 255 255 / 40%);
  --border-button: 1px solid rgb(255 255 255 / 50%);
  --radius-card: 16px;
  --radius-input: 10px;
  --radius-control: 10px;
  --radius-pill: 999px;
  --page-panel-gap: 16px;
  --page-body-padding-top: 16px;
  --panel-max-narrow: 420px;
  --panel-max-wide: 1100px;
  --panel-max-content: 900px;
  --site-header-height: 112px;
  /* Shared page backdrop — keep body::before, site-header, and fullscreen in sync. */
  --page-bg-color: var(--color-bg-fallback);
  --page-bg-image: url("bg_cottage_padding.webp?v=2");
  --page-bg-position: center bottom;
  --page-bg-size: cover;
  --shadow-text: 0 2px 6px rgb(0 0 0 / 45%);
  --group-color-1: #7eb8da;
  --group-color-2: #a8d48a;
  --group-color-3: #e8b86d;
  --group-color-4: #c9a0dc;
  --group-color-5: #e88a8a;
  --group-color-6: #e8d86d;
  --group-color-7: #e8a0c0;
  /* Panel glass: Recipe F — deeper purple, near-solid outer (nest/mid/outer/strong). */
  --panel-tint-purple: 120 98 210;
  /* Mint retired — kept equal to purple so any leftover refs stay consistent. */
  --panel-tint-mint: 120 98 210;
  --panel-op-nest: 40%;
  --panel-op-mid: 50%;
  --panel-op-outer: 88%;
  --panel-op-strong: 96%;
  /* Nested D — soft dark wash inside outer cards (sections, empty states, inset panels) */
  --panel-nested-fill: rgb(0 0 0 / 18%);
  /* Teacher-resource display / fullscreen list cards */
  --resource-display-card-fill: rgb(var(--panel-tint-purple) / 92%);

  /* Cauldron layout grid (portrait cells: 5 wide × 7 tall per cell) */
  --grid-cols: 70;
  --grid-rows: 18;
  --grid-cell-aspect-w: 5;
  --grid-cell-aspect-h: 7;
  /* Matches .teacher-panel-nav::before — frosted menu panel height. */
  --classroom-menu-panel-height: calc(3.25rem + 24px + env(safe-area-inset-bottom, 0px));
  /* Stage clears only down to near the tab tops so cauldrons sit lower. */
  --classroom-menu-clearance: calc(3.5rem + 8px + env(safe-area-inset-bottom, 0px));

  /* Typography scale (1rem = 16px) */
  --font-size-title: 1.625rem;
  --font-size-subtitle: 1rem;
  --font-size-label: 1rem;
  --font-size-body: 1.0625rem;
  --font-size-input: 1rem;
  --font-size-button: 1.125rem;
  --font-size-button-secondary: 1rem;
  --font-size-small: 1rem;
  --font-size-caption: 1rem;
  --font-size-footer: 0.6875rem;
  /* Page hierarchy (titles / intros / card+section headings). */
  --font-size-resource-page-title: clamp(2rem, 5vw, 2.6rem);
  --font-size-resource-page-intro: clamp(1.22rem, 2.75vw, 1.45rem);
  /* Card / section headings match page intro. */
  --font-size-resource-section: clamp(1.22rem, 2.75vw, 1.45rem);
  --site-footer-line-height: 1.2;
  --site-footer-padding-block: 2px;
  --site-footer-offset: calc(
    var(--site-footer-padding-block) * 2 + var(--font-size-footer) * var(--site-footer-line-height) +
      env(safe-area-inset-bottom, 0px)
  );
  --line-height-title: 1.2;
  --line-height-tight: 1.35;
  --line-height-body: 1.45;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  min-height: 100dvh;
  /* Keep cover-background framing stable when navigating between
     non-scrolling pages (e.g. classroom) and scrolling pages. */
  scrollbar-gutter: stable;
  /* Gutter is painted from html's background — match the page scene so
     classic scrollbars don't leave a grey slit when unused. */
  background-color: var(--page-bg-color);
  background-image: var(--page-bg-image);
  background-position: var(--page-bg-position);
  background-repeat: no-repeat;
  background-size: var(--page-bg-size);
  background-attachment: fixed;
}

/* Classroom / position setup never page-scroll — drop the reserved gutter
   so an empty scrollbar lane does not show on the right. */
html:has(body.page-game),
html:has(body.page-setup-position) {
  scrollbar-gutter: auto;
}

body {
  margin: 0;
  min-height: 100dvh;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--page-bg-color);
  background-image: var(--page-bg-image);
  background-position: var(--page-bg-position);
  background-repeat: no-repeat;
  background-size: var(--page-bg-size);
  pointer-events: none;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: var(--line-height-body);
  color: var(--color-text);
}

a {
  color: var(--color-link);
}

/* Page layouts */

body.page-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  box-sizing: border-box;
  padding: var(--page-panel-gap);
}

body.page-centered:has(.register-card) {
  justify-content: center;
}

body.page-centered:has(.setup-card) {
  justify-content: flex-start;
  padding-inline: var(--page-panel-gap);
  padding-bottom: var(--page-panel-gap);
  padding-top: 0;
}

body.has-site-chrome.page-centered:has(.setup-card) > .setup-card {
  margin-top: var(--page-body-padding-top);
}

body.page-simple {
  display: grid;
  place-items: center;
  padding: var(--page-panel-gap);
  text-align: center;
}

/* Cards */

.register-card,
.setup-card {
  box-sizing: border-box;
  padding: 24px;
  border: var(--border-subtle);
  border-radius: var(--radius-card);
  background: rgb(var(--panel-tint-purple) / var(--panel-op-outer));
  backdrop-filter: blur(8px);
  container-type: inline-size;
  container-name: panel;
}

.setup-card {
  width: min(100%, var(--panel-max-wide));
}

.register-card {
  width: min(100%, var(--panel-max-narrow));
}

/* Register needs a little more width so the long consent lines wrap less
   and the card fits a typical full desktop viewport without scrolling. */
.register-card:has(#register-form) {
  width: min(100%, 560px);
}

.register-closed-notice {
  margin: 0 0 16px;
  padding: 16px 18px;
  border: none;
  border-radius: var(--radius-card);
  background: var(--panel-nested-fill);
  box-sizing: border-box;
  text-align: left;
}

.register-closed-notice > p {
  margin: 0;
  font-size: var(--font-size-body);
  font-weight: 700;
  line-height: var(--line-height-body);
}

.register-closed-notice > p.register-closed-notice-headline {
  text-align: center;
}

.register-closed-notice > p.register-closed-notice-hint {
  margin-top: 8px;
  font-size: var(--font-size-small);
  font-weight: 600;
  opacity: 0.9;
}

.register-notify-signup,
.register-invite-unlock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  text-align: left;
}

.register-invite-label {
  display: block;
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  opacity: 0.9;
}

.register-invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.register-invite-row input {
  flex: 1 1 12rem;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
}

.register-invite-button.submit-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 6rem;
  padding-inline: 18px;
}

.register-notify-signup .field-error:empty,
.register-invite-unlock .field-error:empty {
  display: none;
}

.register-notify-signup .field-error:not(:empty),
.register-invite-unlock .field-error:not(:empty) {
  margin: 0;
}

.register-notify-success {
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  color: var(--color-accent);
}

.register-notify-success[hidden] {
  display: none !important;
}

.register-options--closed {
  opacity: 0.45;
  filter: grayscale(0.4);
  pointer-events: none;
  user-select: none;
}

.register-options--closed .submit-button {
  cursor: not-allowed;
}

body.page-edit-class {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100dvh;
  box-sizing: border-box;
  padding: 0 var(--page-panel-gap) var(--page-panel-gap);
}

body.page-edit-class > .setup-card {
  align-self: center;
  margin-top: var(--page-body-padding-top);
}

.edit-form-actions {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.edit-form-actions .continue-button {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.edit-form-actions .edit-cancel-button {
  flex: 0 1 auto;
}

@media (max-width: 640px) {
  .edit-form-actions {
    flex-direction: column;
  }

  .edit-form-actions .continue-button,
  .edit-form-actions .edit-cancel-button {
    flex: 1 1 auto;
    width: 100%;
    white-space: normal;
  }
}

.edit-cancel-button {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  padding: 10px 16px;
  border: var(--border-button);
  border-radius: var(--radius-pill);
  background: rgb(26 46 26 / 48%);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-button-secondary);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
}

.edit-cancel-button:hover:not(:disabled) {
  background: rgb(26 46 26 / 60%);
}

.edit-cancel-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.delete-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(0 0 0 / 45%);
}

.delete-confirm-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 31;
  width: min(calc(100% - 32px), 480px);
  padding: 24px;
  border: var(--border-subtle);
  border-radius: var(--radius-card);
  background: rgb(26 46 26 / 94%);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgb(0 0 0 / 35%);
  transform: translate(-50%, -50%);
}

.delete-confirm-message {
  margin: 0 0 20px;
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}

.delete-confirm-actions {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.delete-confirm-actions .continue-button {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.delete-confirm-actions .edit-cancel-button {
  flex: 0 1 auto;
}

.image-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 45%);
}

.image-picker-backdrop[hidden] {
  display: none;
}

.image-picker-dialog {
  width: min(calc(100% - 32px), 520px);
  max-height: min(90vh, 640px);
  padding: 24px;
  overflow: auto;
  border: var(--border-subtle);
  border-radius: var(--radius-card);
  background: rgb(26 46 26 / 94%);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgb(0 0 0 / 35%);
}

.image-picker-title {
  margin: 0 0 16px;
  font-size: var(--font-size-subtitle);
  font-weight: 600;
  text-align: center;
}

.image-picker-body {
  margin-bottom: 16px;
}

.image-picker-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-picker-actions .quiet-button {
  width: 100%;
  justify-content: center;
  white-space: normal;
}

.image-crop-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.image-crop-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.image-crop-image {
  display: block;
  max-width: 100%;
  max-height: min(60vh, 420px);
}

.image-crop-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

.image-crop-rect {
  position: absolute;
  border: 2px solid var(--color-accent);
  background: rgb(201 160 220 / 14%);
  display: none;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 10%);
}

.image-crop-rect.is-visible {
  display: block;
}

.image-crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-accent);
  border: 2px solid #fff;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.image-crop-handle--tl {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}

.image-crop-handle--tr {
  left: 100%;
  top: 0;
  cursor: nesw-resize;
}

.image-crop-handle--bl {
  left: 0;
  top: 100%;
  cursor: nesw-resize;
}

.image-crop-handle--br {
  left: 100%;
  top: 100%;
  cursor: nwse-resize;
}

.image-picker-status {
  margin: 0 0 12px;
  font-size: var(--font-size-body);
  text-align: center;
  opacity: 0.85;
}

.image-picker-status.is-success {
  color: var(--color-accent);
  opacity: 1;
}

.image-picker-status.is-error {
  color: var(--color-danger, #ff8a8a);
  opacity: 1;
}

.image-picker-status.is-warning {
  color: var(--color-warning);
  opacity: 1;
}

.image-picker-empty {
  margin: 0;
  text-align: center;
  opacity: 0.85;
}

.image-picker-section-title {
  margin: 0 0 10px;
  font-size: var(--font-size-caption);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
}

.image-picker-section-title + .image-picker-grid {
  margin-bottom: 16px;
}

.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.image-picker-grid-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: var(--radius-control);
  background: rgb(255 255 255 / 8%);
  cursor: pointer;
}

.image-picker-grid-item:hover,
.image-picker-grid-item:focus-visible {
  border-color: var(--color-accent);
}

.image-picker-grid-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: calc(var(--radius-control) - 2px);
  background: rgb(0 0 0 / 18%);
}

.image-picker-grid-thumb.is-load-failed {
  opacity: 0.35;
}

.image-picker-grid-filename {
  font-size: var(--font-size-caption);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.image-attachment {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
}

.image-attachment-preview {
  display: flex;
  justify-content: center;
}

.image-attachment-thumb {
  display: block;
  max-width: 100%;
  max-height: 120px;
  border-radius: var(--radius-control);
  object-fit: contain;
}

.image-attachment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Quiet utility controls (optional extras, copy, nav, clear) — not Cancel/Back. */
.quiet-button,
.image-attachment-add,
.image-attachment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 18%);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
}

.quiet-button:hover,
.image-attachment-add:hover,
.image-attachment-remove:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.quiet-button:disabled,
.image-attachment-add:disabled,
.image-attachment-remove:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.image-attachment-add[hidden],
.image-attachment-remove[hidden] {
  display: none !important;
}

a.quiet-button {
  display: inline-flex;
}

.image-attachment-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Text field + optional image on one wrapping row (points / prompts). */
.image-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}

.image-field-row > input {
  flex: 1 1 14rem;
  width: auto;
  min-width: 0;
}

.image-field-row > [class$="-image-host"],
.image-field-row > .revision-board-point-image-host,
.image-field-row > .pop-pal-prompts-prompt-image-host {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
}

.image-field-row .image-attachment {
  padding: 0;
}

.image-field-row
  > .revision-board-point-image-host:has(.image-attachment-preview:not([hidden])),
.image-field-row
  > .pop-pal-prompts-prompt-image-host:has(.image-attachment-preview:not([hidden])) {
  flex: 1 1 100%;
}

.grupop-image-frame {
  /* Basis tracks rendered image width; updated by applyImageFrame / ResizeObserver.
     Provisional value stays small until measured so cauldron-sized images are not oversized. */
  --grupop-frame-basis: 48px;
  box-sizing: border-box;
  border: max(1.5px, calc(var(--grupop-frame-basis) * 0.0375)) solid var(--color-accent);
  border-radius: max(3px, calc(var(--grupop-frame-basis) * 0.1));
  box-shadow:
    0 0 0 max(1px, calc(var(--grupop-frame-basis) * 0.025)) var(--color-cauldron),
    0 2px 6px rgb(0 0 0 / 25%);
  background: rgb(26 46 26 / 35%);
}

/* Frame hugs the bitmap: keep intrinsic aspect ratio; size caps come from context
   (e.g. .image-attachment-thumb max-height) so setup thumbs stay compact. */
img.grupop-image-frame {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
}

.image-attachment-thumb.grupop-image-frame {
  max-width: 100%;
  max-height: 120px;
}

.tag.is-marked-removed {
  opacity: 0.55;
  border-style: dashed;
}

.tag.is-marked-removed > span:first-child {
  text-decoration: line-through;
}

.tag.is-new-pupil {
  border-color: var(--color-accent);
}

.tag .pupil-name-input {
  min-width: 5.5rem;
  max-width: 10rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
}

.tag .pupil-name-input:focus {
  outline: 2px solid rgb(255 255 255 / 45%);
  outline-offset: 2px;
}

/* Typography */

h1 {
  margin: 0 0 4px;
  font-size: var(--font-size-resource-page-title);
  font-weight: 700;
  line-height: var(--line-height-title);
  text-align: center;
  text-shadow: var(--shadow-text);
}

.setup-card > h2,
.register-card > h2 {
  margin: 0 0 12px;
  font-size: var(--font-size-resource-section);
  font-weight: 700;
  line-height: var(--line-height-tight);
}

.setup-card h2,
.register-card h2,
.resource-create-columns-label {
  text-shadow: var(--shadow-text);
}

.subtitle {
  margin: 0 0 16px;
  font-size: var(--font-size-resource-page-intro);
  font-weight: 600;
  line-height: var(--line-height-tight);
  text-align: center;
  opacity: 0.85;
}

.subtitle a {
  color: var(--color-link);
  text-decoration: none;
}

.subtitle a:hover {
  text-decoration: underline;
}

.subtitle--spaced {
  margin-bottom: 24px;
}

.renew-status {
  margin: 0 0 18px;
  text-align: center;
  font-size: var(--font-size-small);
  color: var(--color-text-muted, #4a5a4a);
}

.renew-summary-intro {
  margin: 0 0 12px;
  line-height: var(--line-height-body);
}

.renew-summary-list {
  margin: 0 0 8px;
  padding-left: 1.25rem;
  line-height: var(--line-height-body);
}

.renew-summary-list li + li {
  margin-top: 6px;
}

/* Page toolbars: centred title on its own row, optional actions below */

.turn-taking-toolbar,
.random-order-toolbar,
.team-builder-toolbar,
.jobs-board-toolbar,
.image-library-toolbar,
.quiet-countdown-toolbar,
.quiet-pops-toolbar,
.pop-pal-prompts-toolbar,
.group-checklist-toolbar,
.revision-board-toolbar,
.what-if-board-toolbar,
.class-schedule-toolbar,
.pupil-codes-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.turn-taking-toolbar h1,
.random-order-toolbar h1,
.team-builder-toolbar h1,
.jobs-board-toolbar h1,
.image-library-toolbar h1,
.quiet-countdown-toolbar h1,
.quiet-pops-toolbar h1,
.pop-pal-prompts-toolbar h1,
.group-checklist-toolbar h1,
.revision-board-toolbar h1,
.what-if-board-toolbar h1,
.class-schedule-toolbar h1,
.pupil-codes-toolbar h1 {
  margin: 0;
  width: 100%;
}

.resource-page-heading {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.resource-page-heading h1 {
  width: auto;
  margin: 0;
  font-size: var(--font-size-resource-page-title);
  line-height: 1.15;
}

.resource-page-intro {
  margin: 0 0 16px;
  font-size: var(--font-size-resource-page-intro);
  font-weight: 600;
  line-height: var(--line-height-body);
  opacity: 0.85;
  text-align: center;
}

.resource-page-body {
  margin: 0 0 16px;
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: var(--line-height-body);
  opacity: 0.92;
  text-align: left;
}

.resource-page-heading-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  height: 2.85rem;
  color: currentColor;
}

.resource-page-heading-icon .teacher-resource-icon {
  width: 100%;
  height: 100%;
}

.class-schedule-toolbar {
  margin-bottom: 16px;
}

.resource-toolbar-actions,
.class-schedule-toolbar-actions,
.pupil-codes-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.pupil-codes-actions[hidden] {
  display: none;
}

.resource-panel-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  margin-top: clamp(8px, 2vw, 16px);
  box-sizing: border-box;
}

.resource-panel-actions:has(> .resource-setup-next-hint) {
  flex-wrap: wrap;
}

.resource-panel-actions > .resource-setup-next-hint {
  flex: 1 0 100%;
  width: 100%;
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  opacity: 0.9;
  text-align: center;
}

.resource-panel-actions > .resource-setup-next-hint[hidden] {
  display: none !important;
}

/* Primary grows; secondary Cancel/Back/Skip hug their label. */
.resource-panel-actions > .continue-button,
.resource-panel-actions > .class-schedule-submit {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}

.resource-panel-actions > .edit-cancel-button,
.resource-panel-actions > a.edit-cancel-button,
.resource-panel-actions > .quiet-button,
.resource-panel-actions > a.quiet-button {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}

/* Sole action (Show board, or Back alone): keep a full-width tap target. */
.resource-panel-actions:has(> :only-child) > .continue-button,
.resource-panel-actions:has(> :only-child) > .edit-cancel-button,
.resource-panel-actions:has(> :only-child) > .class-schedule-submit,
.resource-panel-actions:has(> :only-child) > a.edit-cancel-button,
.resource-panel-actions:has(> .resource-setup-next-hint):not(:has(> .edit-cancel-button)):not(:has(> .quiet-button)) > .continue-button {
  flex: 1 1 100%;
  width: 100%;
  box-sizing: border-box;
  white-space: normal;
}

.resource-panel-actions > a.edit-cancel-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
}

@media (max-width: 480px) {
  .resource-panel-actions {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .resource-panel-actions > .continue-button,
  .resource-panel-actions > .edit-cancel-button,
  .resource-panel-actions > .class-schedule-submit,
  .resource-panel-actions > a.edit-cancel-button,
  .resource-panel-actions > .quiet-button,
  .resource-panel-actions > a.quiet-button {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    white-space: normal;
  }

  .resource-panel-actions > .continue-button,
  .resource-panel-actions > .class-schedule-submit {
    font-size: var(--font-size-button-secondary);
  }
}

.subtitle--groups {
  margin-bottom: 18px;
}

/* Form fields */

.field {
  margin-bottom: 10px;
}

label,
.pool-label {
  display: block;
  margin-bottom: 4px;
  font-size: var(--font-size-label);
  font-weight: 600;
  line-height: var(--line-height-tight);
}

.field-heading {
  display: block;
  margin-bottom: 8px;
  font-size: var(--font-size-resource-page-intro);
  font-weight: 700;
  line-height: var(--line-height-tight);
}

.setup-nested-card {
  margin: 0 0 20px;
  padding: 18px 20px;
  border: none;
  border-radius: var(--radius-card);
  background: var(--panel-nested-fill);
  box-sizing: border-box;
}

.setup-nested-card:last-of-type {
  margin-bottom: 20px;
}

.setup-nested-card > .field-heading:first-child,
.setup-nested-card > h2:first-child {
  margin-top: 0;
}

.setup-nested-card .unassigned-pool {
  margin-top: 0;
}

.setup-nested-card .random-button {
  margin-top: 12px;
  margin-bottom: 0;
}

.setup-nested-card .groups-row {
  margin-top: 8px;
}

.section-hint {
  margin: 0 0 10px;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  opacity: 0.9;
}

.required-mark {
  color: var(--color-accent);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  border: var(--border-input);
  border-radius: var(--radius-input);
  background: rgb(255 255 255 / 22%);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-input);
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea {
  caret-color: var(--caret-color);
  cursor: var(--cursor-text);
}

select {
  color-scheme: dark;
}

select option {
  color: var(--color-text);
  background-color: var(--color-bg-fallback);
}

input::placeholder,
textarea::placeholder {
  color: rgb(255 255 255 / 45%);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

input.invalid {
  border-color: #ff6b6b;
}

html.hints-disabled .welcome-hero-cauldron-hint,
html.hints-disabled .pupil-intro-cauldron-hint,
html.hints-disabled .help-hints-demo-hint {
  display: none !important;
}

.field-error {
  min-height: 1rem;
  margin: 2px 0 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  color: var(--color-error);
}

.form-message {
  min-height: 1rem;
  margin: 0 0 8px;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  text-align: center;
  color: var(--color-text);
}

.form-message.is-success,
.form-message.success {
  color: var(--color-accent);
}

.form-message.is-error {
  color: var(--color-error);
}

.form-message.is-warning {
  color: var(--color-warning);
}

#setup-form > .form-message:empty,
#edit-form > .form-message:empty {
  display: none;
  min-height: 0;
  margin: 0;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 14px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.checkbox-field label {
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  cursor: pointer;
}

.register-card .checkbox-field label {
  font-size: 0.85rem;
  line-height: 1.3;
}

.register-card .field {
  margin-bottom: 4px;
}

.register-card .checkbox-field {
  margin: 6px 0 8px;
}

.checkbox-field a {
  color: var(--color-link);
}

.section {
  margin-bottom: 18px;
}

.section:last-of-type {
  margin-bottom: 22px;
}

.form-fields-grid {
  display: grid;
  gap: 0 16px;
}

.form-fields-grid .section {
  margin-bottom: 0;
}

.text-mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.text-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid rgb(255 255 255 / 28%);
  border-radius: var(--radius-pill);
  background: var(--panel-nested-fill);
  font-size: var(--font-size-small);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.text-mode-option:has(input:checked) {
  border-color: rgb(255 255 255 / 72%);
  background: rgb(var(--panel-tint-purple) / var(--panel-op-mid));
}

.text-mode-option input {
  accent-color: var(--color-accent);
}

.section-hint--text-mode {
  margin-bottom: 14px;
}

.mode-question {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-question[hidden] {
  display: none;
}

.mode-question-legend {
  margin: 0 0 4px;
  padding: 0;
  color: #fff;
  font-size: var(--font-size-body);
  font-weight: 700;
  -webkit-text-stroke: 0.05em var(--color-cauldron-green);
  paint-order: stroke fill;
  text-shadow: var(--shadow-text);
}

.mode-question-hint {
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  opacity: 0.9;
}

.mode-question-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid rgb(255 255 255 / 28%);
  border-radius: var(--radius-card);
  cursor: pointer;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: 1.45;
}

.mode-question-option:has(input:checked) {
  border-color: rgb(255 255 255 / 72%);
  background: rgb(var(--panel-tint-purple) / var(--panel-op-mid));
}

.mode-question-option input {
  margin-top: 0.2em;
  flex-shrink: 0;
  accent-color: var(--color-accent);
}

.mode-question u {
  color: var(--color-accent);
}

.mode-derived-label {
  margin: 8px 0 0;
  font-size: var(--font-size-small);
  font-weight: 700;
  color: var(--color-accent);
}

.mode-reward-hint {
  margin: 8px 0 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--color-text);
  opacity: 0.9;
}

.section--text-mode {
  margin-bottom: 24px;
}

.group-header.is-minimal-text {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 48px 10px 10px;
}

.group-header-image-host {
  width: 100%;
}

.group-header-image-host .image-attachment {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.group-header-image-host .image-attachment-preview {
  width: 100%;
}

.group-header-image-host .image-attachment-thumb {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 72px;
  margin-inline: auto;
  object-fit: contain;
}

.group-header-image-host .image-attachment-thumb.grupop-image-frame {
  max-height: 72px;
}

.group-header-image-host .image-attachment-actions {
  justify-content: center;
}

.group-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.group-identity-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.group-identity--chip .group-identity-image {
  max-height: 1.5em;
  max-width: 4.5em;
}

.group-label.has-group-image,
.turn-taking-current-name.has-group-image,
.pop-progress-group-name.has-group-image {
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-label.has-group-image .group-identity-image {
  max-height: 100%;
}

body.page-turn-taking .turn-taking-current-name.has-group-image .group-identity-image {
  max-height: clamp(1.75rem, 6vw, 4rem);
  max-width: min(50vw, 28rem);
}

.turn-taking-done-list .has-group-image .group-identity-image {
  max-height: 1.4em;
  max-width: 4rem;
}

.pop-progress-group-name.has-group-image .group-identity-image,
.pop-stats-list-name.has-group-image .group-identity-image {
  max-height: 1.5em;
  max-width: 4.5em;
}

.form-fields-grid .section--full {
  grid-column: 1 / -1;
}

@container panel (min-width: 560px) {
  .form-fields-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-fields-grid.form-fields-grid--pupils {
    grid-template-columns: 1fr;
    align-items: start;
    margin-bottom: 18px;
  }
}

@container panel (min-width: 800px) {
  .form-fields-grid.form-fields-grid--triple {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .form-fields-grid.form-fields-grid--triple .section--full {
    grid-column: auto;
  }
}

/* Buttons */

.submit-button,
.continue-button {
  width: 100%;
  padding: 10px 16px;
  border: var(--border-button);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  font-family: inherit;
  font-size: var(--font-size-button);
  font-weight: 700;
  cursor: pointer;
}

.submit-button:hover:not(:disabled),
.continue-button:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.submit-button:disabled,
.continue-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.resend-verification-hint {
  margin: 16px 0 0;
  font-size: var(--font-size-small);
  line-height: var(--line-height-body);
  text-align: center;
  color: var(--color-text);
}

.resend-verification-button {
  margin-top: 12px;
}

.login-inline-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--color-link);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  text-decoration: underline;
  cursor: pointer;
}

.login-inline-button:hover {
  color: var(--color-accent-hover);
}

.add-button,
.random-button {
  padding: 8px 16px;
  border: var(--border-button);
  border-radius: var(--radius-input);
  background: rgb(255 255 255 / 28%);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-button-secondary);
  font-weight: 700;
  cursor: pointer;
}

.add-button {
  white-space: nowrap;
}

.random-button {
  display: block;
  width: 100%;
  margin-bottom: 18px;
  padding: 10px 16px;
  background: rgb(255 255 255 / 25%);
}

.add-button:hover,
.random-button:hover {
  background: rgb(255 255 255 / 28%);
}

.control-button {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 60%);
  border-radius: 50%;
  background: rgb(0 0 0 / 35%);
  color: white;
  cursor: pointer;
}

.control-button:hover {
  background: rgb(0 0 0 / 50%);
}

/* Site header (logo + controls) */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--site-header-height);
  padding: 8px var(--page-panel-gap);
  /* Opaque band so page content scrolls under the logo, not through it.
     Uses the same tokens + fixed attachment so framing matches body::before. */
  background-color: var(--page-bg-color);
  background-image: var(--page-bg-image);
  background-position: var(--page-bg-position);
  background-repeat: no-repeat;
  background-size: var(--page-bg-size);
  background-attachment: fixed;
  pointer-events: none;
}

.site-header > * {
  pointer-events: auto;
}

.site-header-logo-link {
  display: block;
  line-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.site-header-logo {
  display: block;
  width: auto;
  height: 80px;
}

.settings-toggle {
  transition: opacity 0.15s ease;
}

.teacher-resource-icon {
  display: block;
  width: 32px;
  height: 32px;
}

.toolbar-toggle {
  transition: opacity 0.15s ease;
}

.toolbar-toggle .toolbar-toggle-icon {
  width: 32px;
  height: 32px;
}

.toolbar-toggle-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  margin: 0 0.15em;
  border: var(--border-button);
  border-radius: 50%;
  background: rgb(0 0 0 / 35%);
  color: #fff;
  vertical-align: middle;
}

.toolbar-toggle-preview .toolbar-toggle-icon {
  width: 1em;
  height: 1em;
}

body.has-site-chrome:not(.page-game) {
  padding-top: var(--site-header-height);
}

body.has-site-chrome.page-centered,
body.has-site-chrome.page-simple {
  min-height: 100dvh;
}

body.has-site-footer {
  padding-bottom: var(--site-footer-offset);
}

body.has-site-footer.page-game {
  padding-bottom: 0;
}

body.has-site-footer.page-centered,
body.has-site-footer.page-simple,
body.has-site-footer.page-edit-class,
body.has-site-footer.page-pupil-login,
body.has-site-footer.page-info,
body.has-site-footer.page-turn-taking,
body.has-site-footer.page-random-order,
body.has-site-footer.page-team-builder,
body.has-site-footer.page-jobs-board,
body.has-site-footer.page-quiet-countdown,
body.has-site-footer.page-quiet-pops,
body.has-site-footer.page-pop-pal-prompts,
body.has-site-footer.page-group-checklist,
body.has-site-footer.page-revision-board,
body.has-site-footer.page-what-if-board,
body.has-site-footer.page-first-next-then,
body.has-site-footer.page-class-schedule,
body.has-site-footer.page-image-library {
  padding-bottom: calc(var(--page-panel-gap) + var(--site-footer-offset));
}

body.has-site-footer.page-pupil {
  padding-bottom: calc(32px + var(--site-footer-offset));
}

body.has-site-footer.page-setup-position {
  padding-bottom: var(--site-footer-offset);
  height: calc(100dvh - var(--site-footer-offset));
  min-height: calc(100dvh - var(--site-footer-offset));
}

/* Shared inset below site header (matches teacher-resources) */

.info-page-body,
.turn-taking-page-body,
.random-order-page-body,
.team-builder-page-body,
.jobs-board-page-body,
.image-library-page-body,
.quiet-countdown-page-body,
.quiet-pops-page-body,
.pop-pal-prompts-page-body,
.group-checklist-page-body,
.revision-board-page-body,
.what-if-board-page-body,
.first-next-then-page-body,
.class-schedule-page-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  padding: var(--page-body-padding-top) var(--page-panel-gap) var(--page-panel-gap);
}

.turn-taking-shell,
.random-order-shell,
.team-builder-shell,
.jobs-board-shell,
.image-library-shell,
.quiet-countdown-shell,
.quiet-pops-shell,
.pop-pal-prompts-shell,
.group-checklist-shell,
.revision-board-shell,
.what-if-board-shell,
.first-next-then-shell,
.class-schedule-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  width: min(100%, var(--panel-max-wide));
  margin-inline: auto;
  box-sizing: border-box;
}

.site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  margin: 0;
  padding: var(--site-footer-padding-block) 12px
    calc(var(--site-footer-padding-block) + env(safe-area-inset-bottom, 0px));
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-footer);
  font-weight: 600;
  line-height: var(--site-footer-line-height);
  text-align: center;
  color: var(--color-text);
  opacity: 0.45;
  pointer-events: none;
}

.site-footer--public {
  pointer-events: auto;
}

.site-footer--public a {
  color: var(--color-link);
  text-decoration: none;
}

.site-footer--public a:hover {
  text-decoration: underline;
}


/* Links */

.login-link {
  margin: 14px 0 0;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-body);
  text-align: center;
}

.login-link a {
  color: var(--color-link);
  text-decoration: none;
}

.login-link a:hover {
  text-decoration: underline;
}

.register-start-over-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--color-link);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.register-start-over-button:hover {
  text-decoration: underline;
}

.login-link--field {
  margin: 8px 0 0;
  text-align: left;
  font-weight: 500;
}

.login-link--registration-closed {
  opacity: 0.45;
  filter: grayscale(0.35);
}

.login-link--registration-closed a {
  cursor: not-allowed;
}

/* Tags & chips */

.tag-list,
.chip-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list {
  min-height: 36px;
  margin-top: 12px;
}

.chip-area {
  min-height: 40px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-pill);
  background: rgb(25 244 171 / 18%);
  font-size: var(--font-size-small);
  font-weight: 600;
}

.tag-remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgb(0 0 0 / 30%);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.tag-remove:hover {
  background: rgb(0 0 0 / 50%);
}

.pupil-chip {
  padding: 8px 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  background: rgb(140 140 140 / 55%);
  color: #fff;
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pupil-chip:hover {
  filter: brightness(1.08);
}

.pupil-chip--display {
  cursor: default;
}

.pupil-chip--display:hover {
  filter: none;
}

.pupil-entry-row {
  display: flex;
  gap: 8px;
}

.pupil-entry-row input {
  flex: 1;
}

.setup-duplicate-warning {
  margin: 0 0 12px;
}

.duplicate-warning {
  min-height: 0;
  margin: 8px 0 0;
  font-size: var(--font-size-caption);
  font-weight: 600;
  line-height: var(--line-height-body);
  color: var(--color-warning);
}

.duplicate-warning:empty {
  display: none;
}

/* Setup groups */

.unassigned-pool {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px dashed rgb(255 255 255 / 35%);
  border-radius: 12px;
  background: var(--panel-nested-fill);
}

.unassigned-pool.is-collapsed {
  display: none;
}

.pool-label {
  margin: 0 0 10px;
}

.groups-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
  align-items: start;
}

/* Stack group/team/job columns on narrow screens (JS may set columns inline). */
@media (max-width: 700px) {
  .groups-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .groups-row .group-add-column {
    justify-content: center;
  }

  .groups-row .group-add-column .resource-instance-add-button {
    margin-left: 0;
  }
}

@media (min-width: 701px) and (max-width: 900px) {
  .groups-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

.group-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.group-add-column {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  align-self: start;
  min-width: 0;
}

.group-add-column .resource-instance-add-button {
  /* Match .group-header height: borders + padding + title line, floored by action buttons */
  --group-header-height: max(
    52px,
    calc(8px + 32px + (var(--font-size-button) * var(--line-height-title)))
  );
  box-sizing: border-box;
  width: var(--group-header-height);
  min-width: var(--group-header-height);
  height: var(--group-header-height);
  aspect-ratio: auto;
  align-self: flex-start;
  margin: 0 0 10px 3px; /* grid gap 12px + 3px ≈ 15px from last group */
  border-width: 4px;
  padding: 0;
}

.group-add-column .resource-instance-add-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.group-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 52px;
  margin: 0 0 10px;
  padding: 8px 100px 8px 10px;
  border: 4px solid transparent;
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: var(--font-size-button);
  font-weight: 700;
  line-height: var(--line-height-title);
  text-align: center;
  color: var(--color-text-on-accent);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.group-header .resource-rename-label {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.group-header .resource-rename-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-header .resource-rename-label.is-editing .resource-rename-text {
  display: none !important;
}

.group-header .resource-rename-input,
.group-name-input {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: center;
  color: inherit;
  caret-color: var(--caret-color);
  cursor: var(--cursor-text);
}

.group-header .resource-rename-input:focus,
.group-name-input:focus {
  outline: none;
}

.group-header-actions {
  position: absolute;
  top: 50%;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
}

.group-header .resource-rename-button {
  position: static;
  width: 36px;
  height: 36px;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 70%);
}

.group-header .resource-rename-button:hover {
  background: rgb(0 0 0 / 72%);
  color: #fff;
  box-shadow: 0 0 0 2px #fff;
}

.group-header .resource-rename-icon {
  width: 20px;
  height: 20px;
}

.group-header .resource-rename-icon path {
  stroke-width: 1.85;
}

.group-remove-button {
  position: static;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 70%);
  font-family: inherit;
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.group-remove-button:hover {
  background: rgb(0 0 0 / 72%);
  box-shadow: 0 0 0 2px #fff;
}

.add-group-button {
  padding: 8px 16px;
  border: var(--border-button);
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 25%);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-button-secondary);
  font-weight: 700;
  cursor: pointer;
}

.add-group-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 28%);
}

.add-group-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.group-header.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 40%), 0 0 18px rgb(255 255 255 / 60%);
}

.group-drop-zone {
  flex: 1;
  min-height: 80px;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: var(--radius-input);
  background: var(--panel-nested-fill);
}

.group-drop-zone.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-drop-zone.is-empty::before {
  content: attr(data-empty-label);
  display: block;
  width: 100%;
  padding: 8px 4px;
  font-size: var(--font-size-small);
  font-weight: 600;
  text-align: center;
  opacity: 0.72;
}

/* Phone / tablet: renaming a job/team expands that column (like FNT edit). */
@media (max-width: 900px) {
  .groups-row:has(.resource-rename-label.is-editing) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .groups-row:has(.resource-rename-label.is-editing)
    > .group-column:not(:has(.resource-rename-label.is-editing)),
  .groups-row:has(.resource-rename-label.is-editing) > .group-add-column {
    display: none;
  }

  .groups-row:has(.resource-rename-label.is-editing)
    > .group-column:has(.resource-rename-label.is-editing) {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 700px) {
  body.page-jobs-board .group-drop-zone,
  body.page-team-builder .group-drop-zone,
  body.page-group-checklist .group-drop-zone {
    min-height: 96px;
    padding: 12px;
  }

  body.page-jobs-board .pupil-chip,
  body.page-team-builder .pupil-chip,
  body.page-group-checklist .pupil-chip,
  body.page-jobs-board .unassigned-pool .pupil-chip,
  body.page-team-builder .unassigned-pool .pupil-chip,
  body.page-group-checklist .unassigned-pool .pupil-chip {
    padding: 10px 14px;
    font-size: var(--font-size-body);
  }

  body.page-jobs-board .group-header,
  body.page-team-builder .group-header,
  body.page-group-checklist .group-header {
    min-height: 56px;
    padding-block: 10px;
    padding-inline: 10px 100px;
  }
}

/* Utilities */

.hidden {
  display: none !important;
}

/* Teacher resource pages: block interaction while class/config reconcile */
body.is-resource-updating .resource-load-gate {
  pointer-events: none;
  cursor: wait;
}
