/* Class Assist DAILY — N3A daily から流用、ポータル配色に統一 */

:root {
  /* 印刷用：絶対に変更しない（黄色ハイライト・枠線） */
  --n3a-bg: #fff3a0;
  --line: #333;
}

.daily-header {
  padding-top: 16px;
  padding-bottom: 12px;
}

.daily-header .brand h1 {
  font-size: 22px;
  letter-spacing: 0.06em;
}

.daily-header .back-link {
  display: inline-block;
  font-size: 12px;
  color: var(--color-text-soft);
  text-decoration: none;
  margin-bottom: 4px;
}

.daily-header .back-link:hover { color: var(--color-accent); }

.daily-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  padding: 10px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.week-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  max-width: 280px;
}

.day-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.day-tab {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
}

.day-tab.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.day-tab.holiday { color: #aaa; background: #f5f5f5; }
.day-tab.holiday.active { background: #888; border-color: #888; color: white; }

.btn-print {
  margin-left: auto;
  padding: 8px 16px;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
}

.btn-print:hover:not(:disabled) { background: #b59445; }
.btn-print:disabled { opacity: 0.4; cursor: not-allowed; }

.meta {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 12px;
  flex-basis: 100%;
  order: 99;
}

.sheets-container {
  padding: 24px 16px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.sheet {
  background: white;
  width: 210mm;
  min-height: 297mm;
  padding: 10mm 5mm;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  color: #222;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

.sheet-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 4mm;
  margin-bottom: 4mm;
}

.sheet-title {
  font-size: 22pt;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.sheet-title .day-type {
  font-size: 13pt;
  color: #444;
  font-weight: 500;
}

.sheet-meta {
  font-size: 9.5pt;
  color: #333;
  margin-top: 2mm;
  line-height: 1.55;
}

.sheet-meta .item-row { margin-top: 1mm; }
.sheet-meta .item-row strong {
  display: inline-block;
  background: #eee;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  font-size: 9pt;
  font-weight: 700;
}

.grid {
  display: grid;
  border: 1.5px solid var(--line);
  grid-auto-rows: minmax(22mm, auto);
}

.grid > * {
  border-right: 0.5px solid #555;
  border-bottom: 0.5px solid #555;
  padding: 1.5mm 2mm;
  font-size: 9pt;
  display: flex;
  flex-direction: column;
}

.col-header {
  background: #f0f0f0;
  font-weight: 700;
  text-align: center;
  align-items: center;
  justify-content: center;
  padding: 2mm 1mm;
}

.col-header .grade-name { font-size: 13pt; line-height: 1.1; }
.col-header .student-list {
  font-size: 8pt;
  color: #555;
  margin-top: 1mm;
  line-height: 1.3;
  font-weight: 500;
}

.row-header {
  background: #f7f7f7;
  font-weight: 700;
  text-align: center;
  align-items: center;
  justify-content: center;
  font-size: 12pt;
  padding: 2mm 1mm;
}

.cell {
  padding: 1.5mm 2mm 1mm;
  position: relative;
  overflow: hidden;
}

.cell-header {
  display: flex;
  align-items: baseline;
  gap: 2mm;
  border-bottom: 0.5px dashed #999;
  padding-bottom: 0.5mm;
  margin-bottom: 0.5mm;
}

.subject-warn {
  color: #c44;
  font-weight: 700;
  font-size: 9pt;
  background: rgba(196, 68, 68, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px dashed #c44;
}

@media print {
  .subject-warn { border-color: #888; color: #888; background: transparent; }
}

.cell-subject {
  font-weight: 700;
  font-size: 10pt;
  text-align: left;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.teacher-checks {
  margin-left: auto;
  display: flex;
  gap: 1.2mm;
  font-size: 6pt;
  color: #444;
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60%;
}

.tcheck { display: inline-block; }

.cell-content {
  font-size: 9pt;
  line-height: 1.25;
  flex: 1;
  margin-bottom: 1mm;
  overflow: hidden;
  text-align: left;
  word-break: break-word;
}

.cell-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5mm;
}

.cell-fields .field-row {
  border-bottom: 0.5px solid #888;
  min-height: 5mm;
  font-size: 8pt;
  color: #b0b0b0;
  display: flex;
  align-items: flex-end;
}

.cell.place-n3a { background: var(--n3a-bg); }
.cell.place-exchange { background: white; }
.cell.place-dismissed {
  background: repeating-linear-gradient(45deg, #fafafa, #fafafa 3mm, #e0e0e0 3mm, #e0e0e0 3.4mm);
  color: #666;
}

.cell.place-dismissed .cell-fields { display: none; }

.cell.place-dismissed .cell-subject {
  text-align: center;
  border-bottom: 0.5px dashed #999;
  padding-bottom: 1mm;
  margin-bottom: 1mm;
}

.cell.place-dismissed .cell-content {
  text-align: center;
  color: #444;
  font-weight: 500;
}

.cell.place-empty { background: #fafafa; }

.legend {
  margin-top: 3mm;
  font-size: 8.5pt;
  color: #666;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item { display: inline-flex; align-items: center; gap: 4px; }

.legend-swatch {
  width: 12px;
  height: 12px;
  border: 0.5px solid #999;
}

.legend-swatch.n3a { background: var(--n3a-bg); }
.legend-swatch.ex { background: white; }

.memo-area {
  margin-top: 3mm;
  border: 1.2px solid var(--line);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 50mm;
}

.memo-title {
  background: #f0f0f0;
  padding: 1.5mm 3mm;
  font-weight: 700;
  font-size: 11pt;
  border-bottom: 0.8px solid #555;
  display: flex;
  align-items: center;
  gap: 6mm;
}

.memo-title .memo-hint {
  font-size: 8.5pt;
  font-weight: 400;
  color: #888;
}

.memo-lines {
  flex: 1;
  padding: 3mm 4mm;
  display: flex;
}

.memo-inner {
  flex: 1;
  background-image: linear-gradient(to bottom, transparent calc(100% - 0.3mm), #c8c8c8 calc(100% - 0.3mm));
  background-size: 100% calc(100% / 6);
  background-repeat: repeat-y;
}

.error {
  padding: 60px 20px;
  text-align: center;
  color: #c33;
  font-size: 14px;
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--color-text-soft);
  font-size: 14px;
}

.empty .empty-hint {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-soft);
}

.empty a { color: var(--color-accent); text-decoration: none; }
.empty a:hover { text-decoration: underline; }

/* PartV 2026-05-16: 縦/横 名前付き@page。既定は portrait、body.orient-landscape で landscape */
@page portrait  { size: A4 portrait;  margin: 5mm; }
@page landscape { size: A4 landscape; margin: 5mm; }

@media print {
  .portal-header,
  .daily-controls { display: none !important; }

  body { background: white; }

  .sheets-container { padding: 0; gap: 0; }

  .sheet {
    margin: 0;
    box-shadow: none !important;
    border: none !important;
    width: auto;
    min-height: auto;
    padding: 0;
    height: 285mm;
    max-height: 285mm;
    overflow: hidden;
    page-break-after: always;
    page-break-inside: avoid;
    break-inside: avoid;
    display: flex;
    flex-direction: column;
    page: portrait;
  }

  .sheet:last-child { page-break-after: auto; }

  .sheet-header { flex-shrink: 0; padding-bottom: 2mm; margin-bottom: 2mm; }

  .grid { flex-shrink: 0; grid-auto-rows: 25mm; }

  .col-header { padding: 1.5mm 1mm; }
  .col-header .grade-name { font-size: 12pt; }
  .col-header .student-list { font-size: 7.5pt; }

  .row-header { font-size: 11pt; }

  .cell { padding: 1mm 1.5mm 0.8mm; }
  .cell-content { font-size: 8pt; line-height: 1.18; margin-bottom: 0.5mm; }
  .cell-fields { gap: 1mm; }
  .cell-fields .field-row { min-height: 6.5mm; }

  .legend {
    flex-shrink: 0;
    margin-top: 2mm;
    font-size: 8pt;
  }

  .memo-area {
    flex: 1 1 auto;
    min-height: 35mm;
    margin-top: 2mm;
    display: flex;
    flex-direction: column;
  }

  .memo-title { flex-shrink: 0; padding: 1mm 3mm; font-size: 10pt; }
  .memo-title .memo-hint { font-size: 8pt; }

  .memo-lines { flex: 1 1 auto; min-height: 28mm; padding: 2mm 3mm; }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .cell.place-n3a { background: var(--n3a-bg) !important; }

  .cell.place-dismissed {
    background: repeating-linear-gradient(45deg, #fafafa, #fafafa 3mm, #e0e0e0 3mm, #e0e0e0 3.4mm) !important;
  }

  .memo-lines { background-image: none !important; }

  .memo-inner {
    background-image: linear-gradient(to bottom, transparent calc(100% - 0.3mm), #c8c8c8 calc(100% - 0.3mm)) !important;
    background-size: 100% calc(100% / 6) !important;
    background-repeat: repeat-y !important;
  }

  /* PartV 2026-05-16: A4 横切替時の上書き */
  body.orient-landscape .sheet {
    page: landscape;
    height: 195mm;
    max-height: 195mm;
  }
  body.orient-landscape .grid { grid-auto-rows: 18mm; }
  body.orient-landscape .col-header { padding: 1mm 0.8mm; }
  body.orient-landscape .col-header .grade-name { font-size: 11pt; }
  body.orient-landscape .col-header .student-list { font-size: 7pt; }
  body.orient-landscape .row-header { font-size: 10pt; }
  body.orient-landscape .cell { padding: 0.8mm 1.2mm 0.6mm; }
  body.orient-landscape .cell-subject { font-size: 9pt; line-height: 1.05; }
  body.orient-landscape .cell-content { font-size: 7.5pt; line-height: 1.15; margin-bottom: 0.3mm; }
  body.orient-landscape .cell-fields .field-row { min-height: 5mm; }
  body.orient-landscape .teacher-checks { font-size: 5.5pt; }
  body.orient-landscape .legend { font-size: 7.5pt; margin-top: 1.5mm; }
  body.orient-landscape .memo-area { min-height: 22mm; margin-top: 1.5mm; }
  body.orient-landscape .memo-title { padding: 0.8mm 2mm; font-size: 9pt; }
  body.orient-landscape .memo-title .memo-hint { font-size: 7pt; }
  body.orient-landscape .memo-lines { min-height: 18mm; padding: 1.5mm 2mm; }
}

/* ========================================================================
 * PartV 2026-05-16: 縦/横 トグル UI（screen、portal.css のトークン継承）
 * ======================================================================== */
.orientation-toggle {
  display: inline-flex;
  background: var(--color-surface, #fff);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  gap: 0;
}
.orientation-toggle button {
  border: 0;
  background: transparent;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  color: var(--color-text-soft, #888);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.orientation-toggle button:hover {
  color: var(--color-text, #333);
  background: rgba(0, 0, 0, 0.04);
}
.orientation-toggle button.active {
  background: var(--color-text, #2f2a1f);
  color: #fff;
}

/* PartV 2026-05-16: 2本指横スワイプによるブラウザ「戻る」抑止（このページ限定） */
html, body { overscroll-behavior-x: none; }

/* ========================================================================
 * PartV 2026-05-16: Excel 出力モーダル（Canva 風） — weekly.css とミラー
 * ======================================================================== */
.export-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.export-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: inherit;
}
.export-modal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.export-modal-back {
  background: transparent; border: 0;
  font-size: 18px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  color: var(--color-text-soft, #888);
}
.export-modal-back:hover { background: #f3ede0; color: var(--color-text, #333); }
.export-modal-head h2 {
  margin: 0; font-size: 16px; font-weight: 700; color: var(--color-text, #333);
}
.export-section {
  padding: 14px 20px;
  border-bottom: 1px solid #f3ede0;
  overflow-y: auto;
}
.export-section:last-of-type { border-bottom: none; }
.export-section-label {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--color-text-soft, #666);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.export-filetype-row {
  display: flex; gap: 8px;
}
.export-filetype-option {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border: 1.5px solid var(--color-border, #e0dccc);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--color-text, #333);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.export-filetype-option:hover { background: #faf7ee; }
.export-filetype-option.active {
  background: #f0e8d4;
  border-color: var(--color-accent, #c5a458);
  color: var(--color-accent, #c5a458);
}
.export-filetype-icon { font-size: 18px; }
.export-filetype-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--color-text-soft, #888);
  line-height: 1.5;
}
.export-filetype-hint.hidden { display: none; }
.export-orient-row {
  display: flex; gap: 8px;
}
.export-orient-option {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid var(--color-border, #e0dccc);
  border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--color-text, #333);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.export-orient-option:hover { background: #faf7ee; }
.export-orient-option.active {
  background: #f0e8d4;
  border-color: var(--color-accent, #c5a458);
  color: var(--color-accent, #c5a458);
}
.export-orient-option input[type="radio"] {
  accent-color: var(--color-accent, #c5a458);
}
.export-info {
  display: inline-block;
  width: 16px; height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: #ddd6c6;
  color: #6b6353;
  font-size: 11px; font-weight: 700;
  text-align: center; line-height: 16px;
  cursor: help;
  vertical-align: middle;
}
.export-info:hover { background: var(--color-accent, #c5a458); color: #fff; }
.export-section.hidden { display: none; }
.export-option, .export-preset, .export-week-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  color: var(--color-text, #333);
  cursor: pointer;
  border-radius: 6px;
}
.export-option:hover, .export-preset:hover, .export-week-item:hover { background: #faf7ee; }
.export-option input[type="checkbox"],
.export-preset input[type="checkbox"],
.export-week-item input[type="checkbox"] {
  accent-color: var(--color-accent, #c5a458);
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.export-divider {
  border: 0; border-top: 1px dashed #ddd;
  margin: 6px 0;
}
.export-week-list, .export-grade-list {
  max-height: 180px;
  overflow-y: auto;
}
.export-status-inline {
  font-size: 12px; color: #888;
  padding: 8px 4px;
}
.export-status-inline.error { color: #c33; }
.export-status {
  font-size: 12px;
  padding: 8px 20px;
  margin: 0;
  min-height: 1.4em;
}
.export-status.info { color: var(--color-text-soft, #666); }
.export-status.success { color: #2c7a3e; font-weight: 600; }
.export-status.error { color: #c33; font-weight: 600; }
.export-status:empty { display: none; }
.export-modal-foot {
  padding: 14px 20px;
  border-top: 1px solid #eee;
  display: flex; gap: 10px; justify-content: flex-end;
  background: #fafafa;
  position: sticky; bottom: 0;
  flex-shrink: 0;
}
.export-cancel, .export-submit {
  padding: 9px 22px;
  border-radius: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--color-border, #ddd);
  background: #fff;
  color: var(--color-text, #333);
}
.export-cancel:hover { background: #f3ede0; }
.export-submit {
  background: var(--color-accent, #c5a458);
  color: #fff;
  border-color: var(--color-accent, #c5a458);
}
.export-submit:hover:not(:disabled) { background: #b59445; }
.export-submit:disabled { opacity: 0.55; cursor: not-allowed; }
