* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.6; color: #222; max-width: 1600px; margin: 0 auto; padding: 1rem; background: #fafafa; }
header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #e74c3c; padding-bottom: 0.5rem; margin-bottom: 1rem; background: #fff; padding: 1rem; border-radius: 8px; flex-wrap: wrap; gap: 0.5rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07); }
h1 { font-size: 1.4rem; color: #c0392b; }
h2 { margin: 1rem 0 0.5rem; }
h3 { margin: 1rem 0 0.5rem; color: #333; }
h4 { margin: 0.5rem 0; }
.card { border: 1px solid #ddd; padding: 1rem; margin: 0.5rem 0; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.grid2 button { grid-column: 1/-1; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
input, select, button { display: block; width: 100%; padding: 0.55rem; margin: 0.3rem 0; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; font-family: inherit; }
button { background: #b42318; color: #fff; border: none; cursor: pointer; font-weight: 600; }
button:hover { background: #8f1d14; }
button:disabled { opacity: 0.55; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
button.secondary { background: #666; }
button.small { padding: 0.3rem 0.6rem; width: auto; display: inline-block; font-size: 0.85em; }
.msg { color: #b42318; min-height: 1.2em; }
.auth-loading { margin: 1rem 0; color: #555; }
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.lesson-card { border: 1px solid #ddd; padding: 0.8rem; border-radius: 8px; background: #fff; }
.lbl { font-size: 0.85em; opacity: 0.8; }
.lbl-inline { font-size: 0.9em; opacity: 0.8; }
.hint { font-size: 0.85em; opacity: 0.7; margin: 0.3rem 0; }
.hint-inline { font-size: 0.8em; opacity: 0.6; font-weight: normal; }
.field-err { color: #b42318; font-size: 0.85em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.full { grid-column: 1/-1; }

/* 折りたたみ・トグル */
.details-box { border: 1px solid #eee; border-radius: 6px; padding: 0.5rem; margin-top: 0.5rem; background: #fafafa; }
.details-box summary { cursor: pointer; font-size: 0.9em; color: #555; font-weight: 600; }
.linkish { background: none; border: none; color: #c0392b; cursor: pointer; font-size: 0.85em; padding: 0; margin: 0; text-decoration: underline; font-weight: 600; width: auto; display: inline; }
.legend-extra { display: inline; }
.list-section { margin-top: 1rem; }
.list-toggle { background: #fff; color: #555; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-size: 0.9em; padding: 0.4rem 0.8rem; width: 100%; text-align: left; }
.list-toggle:hover { background: #f5f5f5; }

/* オーバーレイ（モーダル共通） */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; z-index: 50; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* 稼働状況ライン */
.avail-status { font-size: 0.85em; opacity: 0.75; margin-top: 0.3rem; }

/* ナビ */
nav { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.nav-link { padding: 0.35rem 0.8rem; border-radius: 4px; text-decoration: none; color: #c0392b; font-weight: 600; font-size: 0.95em; }
.nav-link:hover { background: #fdecea; }
.nav-link.active { background: #b42318; color: #fff; }
.user-info { font-size: 0.85em; opacity: 0.75; padding: 0 0.5rem; }

/* コントロール行 */
.control-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.control-row input[type="date"] { width: auto; }
.date-range { font-size: 0.85em; opacity: 0.7; }

/* 凡例 */
.legend { font-size: 0.85em; opacity: 0.75; margin: 0.5rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.legend-box { display: inline-block; width: 12px; height: 12px; vertical-align: middle; margin-right: 0.3rem; }

/* 週表示タブ */
.week-tabs { display: flex; gap: 0.3rem; padding: 0.5rem; border-bottom: 1px solid #eee; flex-wrap: wrap; }
.week-tabs button.tab { background: #eee; color: #333; }
.week-tabs button.tab:hover { background: #ddd; }
.week-tabs button.tab.active { background: #b42318; color: #fff; }

/* 稼働時間の曜日チェック */
.weekday-checks { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.3rem 0; }
.weekday-checks label { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.9em; }
.weekday-checks input { width: auto; margin: 0; }
.time-pair { display: flex; gap: 0.3rem; align-items: center; }
.time-pair input { width: auto; }

/* Calendar */
.calendar { background: #fff; border: 1px solid #ddd; border-radius: 8px; overflow: auto; }
.cal-header { display: grid; border-bottom: 2px solid #ddd; background: #f9fafb; position: sticky; top: 0; z-index: 2; }
.cal-header .time-col { border-right: 1px solid #ddd; padding: 0.5rem; font-size: 0.85em; opacity: 0.6; }
.cal-header .teacher-col { padding: 0.6rem; text-align: center; font-weight: 700; border-right: 1px solid #eee; }
.cal-header .teacher-col:last-child { border-right: none; }
.cal-body { display: grid; position: relative; }
.cal-body .time-col { border-right: 1px solid #eee; }
.cal-body .time-slot { height: 40px; border-bottom: 1px solid #f5f5f5; padding: 0.2rem 0.4rem; font-size: 0.75em; color: #666; }
.cal-body .time-slot:nth-child(4n+1) { border-top: 1px solid #ececec; }
.cal-body .teacher-col { position: relative; border-right: 1px solid #eee; cursor: pointer; }
.cal-body .teacher-col:last-child { border-right: none; }
.avail-block { position: absolute; left: 4px; right: 4px; background: repeating-linear-gradient(45deg, rgba(147, 197, 253, 0.30) 0 6px, rgba(147, 197, 253, 0.12) 6px 12px); border: 1px dashed #60a5fa; border-radius: 4px; pointer-events: none; }
.lesson-block { position: absolute; left: 4px; right: 4px; border-radius: 6px; padding: 0.3rem 0.4rem; font-size: 0.85em; cursor: pointer; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.lesson-block:focus-visible { outline: 3px solid #e74c3c; outline-offset: 1px; }
.lesson-block.REGULAR { background: #bbf7d0; border: 1px solid #4ade80; }
.lesson-block.TRIAL { background: #fde68a; border: 1px solid #fbbf24; }
.lesson-block.CANCELLED { background: #fee2e2; border: 1px solid #fca5a5; opacity: 0.7; text-decoration: line-through; }
.lesson-block.student { background: #f0f9ff; border: 1px dashed #7dd3fc; }
.lesson-block:hover { filter: brightness(0.95); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 6; pointer-events: none; }
.now-line .now-label { position: absolute; left: 2px; top: -11px; background: #ef4444; color: #fff; font-size: 0.68em; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 3px; }
.week-grid { display: grid; grid-template-columns: 80px repeat(7, 1fr); }
.week-day { padding: 0.3rem; border-right: 1px solid #eee; border-bottom: 1px solid #eee; min-height: 48px; font-size: 0.85em; }
.week-day.today { background: #fff7ed; }
.badge { display: inline-block; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.75em; font-weight: 700; }

/* 全体表示（2ペイン） */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 0.75rem; align-items: start; }
.overview-pane { min-width: 0; }
.overview-title { font-weight: 700; font-size: 0.95em; margin: 0.2rem 0 0.4rem; color: #333; }
.overview-pane .calendar { max-height: 72vh; overflow: auto; }

/* モーダル */
.modal-box { max-width: 520px; width: 90%; max-height: 88vh; overflow: auto; }
.confirm-box { max-width: 360px; width: 90%; }

/* トースト */
.toast { position: fixed; top: 1rem; right: 1rem; max-width: 90vw; background: #333; color: #fff; padding: 0.7rem 1rem; border-radius: 6px; display: none; align-items: center; gap: 0.7rem; z-index: 200; box-shadow: 0 2px 8px rgba(0,0,0,0.25); font-size: 0.95em; }
.toast.ok { background: #2e7d32; }
.toast.err { background: #c62828; }
.toast .toast-action { background: #fff; color: #333; margin: 0; white-space: nowrap; }

/* Mobile / Responsive */
@media (max-width: 900px) {
  .overview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  body { padding: 0.5rem; }
  header { flex-direction: column; align-items: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 button { grid-column: 1; }
  #calendarControls .control-row { flex-direction: column; align-items: stretch; }
  #calendarControls .control-row > * { width: 100%; }
  .cal-header .teacher-col { font-size: 0.8em; padding: 0.4rem; }
  .cal-body .time-slot { height: 40px; }
  .lesson-block { font-size: 0.75em; padding: 0.2rem; }
  .week-grid { grid-template-columns: 60px repeat(7, 1fr); min-width: 560px; }
  .week-day { min-height: 48px; font-size: 0.7em; padding: 0.2rem; }
  .lesson-card { font-size: 0.9em; }
  .lesson-card button { float: none !important; margin-top: 0.3rem; }
  .toast { top: 0.5rem; right: 0.5rem; left: 0.5rem; max-width: none; }
  nav .nav-link { font-size: 0.85em; padding: 0.3rem 0.5rem; }
  .week-tabs { justify-content: flex-start; }
}
