.materials-main {
  padding: 26px 0 0;
}

.workspace-intro h1 {
  font-size: 2.3rem;
  margin: 14px 0;
}

.workspace-intro p,
.library-note {
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.75;
}

.workspace-status {
  min-height: 24px;
  color: var(--accent);
  font-family: var(--hand);
  font-size: 1.25rem;
  line-height: 1.6;
  margin: 18px 0;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(300px,.9fr) minmax(0,1.1fr);
  gap: 24px;
  align-items: start;
}

.editor-panel,
.preview-panel {
  position: relative;
  background: #fffefa;
  border-radius: 6px;
  box-shadow: var(--paper-shadow);
  padding: 30px 24px 24px;
  min-width: 0;
}

/* A magnet holds each panel to the fridge. */
.editor-panel::before,
.preview-panel::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff9 0 4px, var(--orange) 5px);
  box-shadow: 0 4px 5px #0004;
}

.preview-panel::before {
  background: radial-gradient(circle at 35% 30%, #fff9 0 4px, var(--blue) 5px);
}

.editor-panel textarea {
  min-height: 78px;
}

.editor-panel fieldset {
  border: 2px dashed #d6dcea;
  border-radius: 10px;
  padding: 16px;
  margin: 22px 0;
}

.editor-panel legend {
  font-size: .9rem;
  font-weight: 650;
  padding: 0 6px;
}

.editor-panel label {
  line-height: 1.5;
}

.field-hint {
  line-height: 1.6;
}

.editor-actions,
.print-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.editor-actions .primary-button {
  margin: 0;
}

.text-button {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 700;
  padding: 10px;
  text-decoration: underline wavy;
  text-underline-offset: 5px;
}

.question-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.question-footer label {
  margin: 0;
}

.level-fields input {
  margin-bottom: 4px;
}

.preview-toolbar,
.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-toolbar h2,
.library-toolbar h2 {
  margin: 0;
}

.preview-note {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.6;
}

.material-sheet {
  margin-top: 20px;
  background: #fff;
  border: 1px solid #e5e6ef;
  padding: 24px;
  overflow-wrap: anywhere;
  color: #252737;
  font-size: 1rem;
  line-height: 1.7;
}

.material-sheet h1 {
  font-size: 1.5rem;
  letter-spacing: -.5px;
  line-height: 1.3;
  margin: 0 0 18px;
}

.material-sheet p {
  white-space: pre-wrap;
}

.empty-preview {
  color: var(--muted);
}

.sheet-question {
  margin: 24px 0;
  break-inside: avoid;
}

.sheet-question>p {
  font-weight: 600;
}

.answer-lines {
  height: 84px;
  background: repeating-linear-gradient(to bottom,transparent 0,transparent 27px,#ccd0da 27px,#ccd0da 28px);
}

.answer-key-label {
  font-weight: 650;
  color: var(--accent);
}

.rubric-table-wrap {
  overflow-x: auto;
}

.rubric-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: .875rem;
  line-height: 1.6;
  table-layout: fixed;
}

.rubric-table th,
.rubric-table td {
  border: 1px solid #d9d9e7;
  padding: 12px;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rubric-table th {
  background: #f2efff;
  text-align: left;
}

.rubric-table th:first-child {
  width: 18%;
}

.sheet-meta {
  font-size: .875rem;
  color: #5f6475;
}

.library-toolbar>div {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.library-note {
  max-width: 750px;
  margin: 20px 0;
}

.library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #fffefa;
  border-left: 8px solid var(--yellow);
  border-radius: 6px;
  box-shadow: var(--paper-shadow);
  padding: 20px;
  margin: 14px 0;
}

.library-row:nth-child(3n+2) {
  border-left-color: var(--pink);
}

.library-row:nth-child(3n) {
  border-left-color: var(--green);
}

.library-row h3 {
  font-size: 1rem;
  margin: 0 0 7px;
  overflow-wrap: anywhere;
}

.library-row p {
  margin: 0;
  font-size: .8rem;
  color: var(--muted);
}

.library-row>div:last-child {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.library-empty {
  background: #fff27a;
  border-radius: 4px;
  box-shadow: var(--paper-shadow);
  font-family: var(--hand);
  font-size: 1.35rem;
  padding: 28px;
  line-height: 1.7;
  color: var(--muted);
}

#material-print {
  display: none;
}

[hidden] {
  display: none !important;
}

@media (max-width:1100px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
  .materials-main {
    padding-top: 22px;
  }
  .preview-panel {
    position: static;
  }
}

@media (max-width:600px) {
  .materials-main {
    padding-top: 18px;
  }
  .editor-panel,
  .preview-panel {
    padding: 18px;
  }
  .material-sheet {
    padding: 16px;
  }
  .library-row {
    flex-direction: column;
    align-items: start;
  }
  .workspace-intro h1 {
    font-size: 2rem;
  }
  .rubric-table th,
  .rubric-table td {
    padding: 9px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 16mm;
  }
  body {
    background: white;
  }
  body>* {
    display: none !important;
  }
  #material-print {
    display: block !important;
    color: #222;
  }
  #material-print .material-sheet {
    border: 0;
    padding: 0;
    margin: 0;
    font-size: 12pt;
  }
  #material-print .rubric-table-wrap {
    overflow: visible;
  }
  #material-print .rubric-table {
    min-width: 0;
    font-size: 9pt;
  }
  #material-print .rubric-table th,
  #material-print .rubric-table td {
    padding: 7px;
  }
  #material-print .rubric-table tr {
    break-inside: avoid;
  }
  #material-print h1 {
    font-size: 20pt;
  }
  #material-print .answer-key-label {
    color: #222;
  }
  #material-print .sheet-question {
    break-inside: avoid;
  }
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
