@page {
  size: A4 portrait;
  margin: 13mm 10mm 10mm 13mm; /* top right bottom left */
}

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

body {
  width: 210mm;
  height: 297mm;
  background: white;
}

.page {
  width: 187mm;  /* 210mm - 13mm - 10mm */
  height: 274mm; /* 297mm - 13mm - 10mm */
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border-right: 1px solid #999;
  border-bottom: 1px solid #999;
}

.card {
  border: 1px solid #999;
  display: flex;
  flex-direction: column;
  padding: 1mm;
  overflow: hidden;
  font-size: 6pt;
}

.card-header {
  font-size: 6.5pt;
  font-weight: bold;
  text-align: center;
  border-bottom: 1px solid #ccc;
  padding-bottom: 0.5mm;
  margin-bottom: 0.5mm;
  white-space: nowrap;
  overflow: hidden;
  outline: none;
}

.card-periods {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.period-row {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid #eee;
  flex: 1;
  min-height: 0;
}

.period-label {
  flex-shrink: 0;
  width: 4mm;
  font-size: 6pt;
  line-height: 1.2;
}

.subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1px;
}

.subject {
  font-size: 5.5pt;
  cursor: pointer;
  line-height: 1.3;
  user-select: none;
}

.subject.selected {
  font-weight: bold;
  text-decoration: underline;
}

.subject:not(:last-child)::after {
  content: '・';
  font-size: 5pt;
  color: #aaa;
}

.mochimono-label {
  font-size: 6pt;
  font-weight: bold;
  border-top: 1px solid #ccc;
  padding-top: 0.5mm;
}

.mochimono {
  flex: 0 0 8mm;
  font-size: 6pt;
  outline: none;
}

@media print {
  .subject {
    cursor: default;
  }

  .subject:not(.selected) {
    color: #888;
  }
}

/* 印刷時：外枠の二重線を防ぐため右端・下端のborderを省略 */
.card:nth-child(4n) {
  border-right: none;
}

.card:nth-child(n+13) {
  border-bottom: none;
}

.date-picker {
  margin-bottom: 8px;
  font-size: 14px;
}

@media print {
  body {
    margin: 0;
  }

  .date-picker {
    display: none;
  }

  .page {
    page-break-after: always;
  }
}
