.material-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: start;
}

.material-side {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  position: sticky;
  top: 18px;
}

.material-side h4 {
  margin: 0 0 10px;
}

.material-record-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.material-record-btn {
  width: 100%;
  text-align: left;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px;
  cursor: pointer;
}

.material-record-btn.active {
  background: #172033;
  color: #fff;
}

.material-record-btn strong {
  display: block;
  margin-bottom: 4px;
}

.material-record-btn span {
  display: block;
  font-size: 12px;
  opacity: .76;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-page-wrap {
  overflow: auto;
  padding-bottom: 40px;
}

.material-page {
  width: 297mm;
  min-height: 210mm;
  margin: 0 auto;
  background: #fff;
  position: relative;
  padding: 42px 70px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(23,32,51,.08);
}

.material-blue-band {
  background: #1f2f5d;
  color: #fff;
  padding: 8px 14px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.material-toolbar {
  margin: 14px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.material-toolbar button,
.material-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  font-size: 13px;
}

.material-toolbar input[type="file"] {
  display: none;
}

.material-area {
  position: relative;
  width: 100%;
  height: 500px;
  background: #f7f8fb;
  overflow: hidden;
  border: 1px solid #edf0f6;
}

.material-area.empty::before {
  content: "画像を貼り付け / ドラッグ＆ドロップ / 画像選択";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9ca3af;
  font-weight: 800;
  letter-spacing: .05em;
}

.material-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.white-mask {
  position: absolute;
  background: #fff;
  border: 1px dashed rgba(0,0,0,0.3);
  cursor: move;
}

.white-mask .mask-resize,
.free-text .text-resize {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #1f2f5d;
  cursor: nwse-resize;
  border-radius: 3px;
}

.white-mask .mask-delete,
.free-text .text-delete {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: #dc2626;
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  cursor: pointer;
  font-weight: 900;
  font-size: 13px;
}

.free-text {
  position: absolute;
  background: rgba(255,255,255,0.7);
  padding: 4px 8px;
  cursor: move;
  min-width: 40px;
  min-height: 22px;
  border: 1px dashed rgba(31,47,93,.2);
}

.free-text.placeholder {
  color: #aaa;
}

.material-footer {
  margin-top: 14px;
  border-top: 2px solid #1f2f5d;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-weight: 900;
  color: #172033;
}

.material-footer span {
  display: inline-block;
  margin-right: 18px;
}

.material-empty-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1200px) {
  .material-layout {
    grid-template-columns: 1fr;
  }

  .material-side {
    position: relative;
    top: auto;
  }

  .material-page {
    transform-origin: top left;
  }
}

@media print {
  .material-side,
  .material-toolbar {
    display: none !important;
  }

  .material-layout {
    display: block;
  }

  .material-page {
    box-shadow: none;
    border: none;
    margin: 0;
    width: 297mm;
    height: 210mm;
    border-radius: 0;
  }

  .white-mask,
  .free-text {
    border-color: transparent !important;
  }

  .mask-resize,
  .mask-delete,
  .text-resize,
  .text-delete {
    display: none !important;
  }
}