/* USIO-Sch-watch。月間の表は PC の Schwatch の見た目に合わせる（色は JS が Schwatch.ini の値で付ける）。 */
:root {
  --font: "MS UI Gothic", "Meiryo UI", "Yu Gothic UI", "Hiragino Sans", sans-serif;
  --line: #A0A0A0;
  --side-w: 160px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .search { display:flex } などが hidden の印を上書きしないように */
html, body { margin: 0; height: 100%; background: #F0F0F0; color: #000; font-family: var(--font); font-size: 12px; }
button, input { font: inherit; }
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* 上の帯 */
#bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #FFFFFF; border-bottom: 1px solid var(--line); }
#title { margin: 0; font-size: 14px; font-weight: bold; color: #003F7F; white-space: nowrap; }
.search { display: flex; gap: 4px; flex: 1; max-width: 420px; margin-left: auto; }
.search input { flex: 1; min-width: 0; padding: 3px 6px; border: 1px solid var(--line); }
button.primary { padding: 3px 10px; background: #E1E1E1; border: 1px solid #ADADAD; cursor: pointer; }
button.primary:hover { background: #E5F1FB; border-color: #0078D7; }
button.ghost { padding: 3px 8px; background: transparent; border: 1px solid #ADADAD; cursor: pointer; }
.view[hidden] { display: none !important; }

/* ログイン・誤り */
.card-box { max-width: 420px; margin: 40px auto; padding: 16px 20px; background: #FFF; border: 1px solid var(--line); }
.card-box h2 { margin-top: 0; font-size: 16px; }
.card-box form { display: flex; gap: 6px; margin: 8px 0; }
.card-box input { flex: 1; padding: 6px; border: 1px solid var(--line); }
.lead { color: #333; line-height: 1.6; }
.msg { line-height: 1.6; }
.msg.error { color: #C00000; }
.muted { color: #666; }

/* 月間の画面: 左に表、右に小さなカレンダーと分類、下に状態の帯 */
.cal { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr var(--side-w); grid-template-rows: 1fr auto; gap: 0 4px; padding: 4px; }
.cal-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #FFF; border: 1px solid var(--line); }
.side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.status { grid-column: 1 / -1; padding: 3px 6px; margin-top: 4px; border-top: 1px solid var(--line); background: #F0F0F0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 見出しの帯 */
.mbar { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 2px 0; border-bottom: 1px solid var(--line); background: #FFF; }
.mtitle { border: 0; background: transparent; color: #0000FF; font-family: Tahoma, var(--font); font-weight: bold; font-size: 12px; padding: 1px 24px; cursor: pointer; }
.nav { width: 22px; height: 16px; border: 0; background: transparent; cursor: pointer; position: relative; }
.nav::before, .nav::after { content: ""; position: absolute; top: 3px; border-style: solid; border-color: transparent; }
.nav.mb::before { left: 6px; border-width: 5px 8px 5px 0; border-right-color: #0000FF; }
.nav.mn::before { left: 8px; border-width: 5px 0 5px 8px; border-left-color: #0000FF; }
.nav.yb::before { left: 2px; border-width: 5px 8px 5px 0; border-right-color: #0000FF; }
.nav.yb::after { left: 10px; border-width: 5px 8px 5px 0; border-right-color: #0000FF; }
.nav.yn::before { left: 4px; border-width: 5px 0 5px 8px; border-left-color: #0000FF; }
.nav.yn::after { left: 12px; border-width: 5px 0 5px 8px; border-left-color: #0000FF; }

/* 月間の表（土日は半分の幅＝PC の「土日半分」） */
.month { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grid-head, .week { display: grid; grid-template-columns: 22px repeat(5, 2fr) repeat(2, 1fr); }
.grid-head { border-bottom: 1px solid var(--line); }
.wk-h { background: #F0F0F0; border-right: 1px solid var(--line); }
.wd { text-align: center; padding: 2px 0; border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.weeks { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(6, minmax(0, 1fr)); }
.week { min-height: 0; border-bottom: 1px solid var(--line); }
.wk { display: flex; align-items: center; justify-content: center; background: #F0F0F0; color: #000080; border-right: 1px solid var(--line); }
.cell { min-width: 0; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); padding: 1px 2px 0; cursor: pointer; position: relative; }
.cell.sel::after { content: ""; position: absolute; inset: 0; border: 2px solid #0000FF; pointer-events: none; }
.num { font-family: Arial, var(--font); font-weight: bold; font-size: 12px; line-height: 15px; }
.ev { line-height: 15px; height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.band { margin: 0 -2px; padding: 0 2px; }

/* 右の小さなカレンダー */
.mini { background: #FFF; border: 1px solid var(--line); padding: 2px; }
.mini-t { text-align: center; color: #0000FF; font-weight: bold; padding: 1px 0; }
.mini-row { display: grid; grid-template-columns: 16px repeat(7, 1fr); }
.mini-h .md { font-weight: normal; }
.mwk { color: #000080; font-size: 10px; text-align: center; align-self: center; }
.md { border: 1px solid transparent; background: transparent; padding: 0; font-size: 11px; line-height: 15px; text-align: center; cursor: pointer; font-family: Arial, var(--font); }
.mini-h .md { cursor: default; font-family: var(--font); }
.md.has { text-decoration: underline; }
.md.sel { border-color: #0000FF; }

/* 分類の一覧 */
.cats { border: 1px solid var(--line); padding: 2px 4px; flex: 1; }
.cats-t { padding: 2px 0; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.cat { display: flex; align-items: center; gap: 3px; padding: 1px 0; cursor: pointer; }
.cat input { margin: 0; }
.chip { display: inline-block; min-width: 0; flex: 1; text-align: center; border: 1px solid #A0A0A0; padding: 0 2px; line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td .chip { flex: none; }

/* 窓（日の一覧・検索の結果） */
dialog { border: 1px solid #808080; padding: 0; max-width: min(900px, 96vw); width: 100%; max-height: 86vh; }
dialog::backdrop { background: rgba(0, 0, 0, .25); }
#dlg-body { padding: 10px 12px; overflow: auto; max-height: calc(86vh - 44px); }
.dlg-foot { display: flex; justify-content: flex-end; padding: 6px 12px; border-top: 1px solid #DDD; }
.detail h2 { margin: 0 0 8px; font-size: 14px; }
.dt { border-collapse: collapse; width: 100%; }
.dt th, .dt td { border: 1px solid #C8C8C8; padding: 3px 6px; text-align: left; vertical-align: top; }
.dt th { background: #E4EDF8; color: #004080; font-weight: normal; }
.dt tr.go { cursor: pointer; }
.dt tr.go:hover td { background: #E5F1FB; }

.notice { padding: 4px 10px; background: #FFF4C2; border-bottom: 1px solid #E0C060; color: #5A4300; }
.loading { position: fixed; right: 12px; bottom: 30px; background: #FFFFE1; border: 1px solid #A0A0A0; padding: 4px 10px; }

/* スマホの形（幅 700 未満）: 1 日ずつ縦に並べる。右の欄は下へ */
@media (max-width: 699px) {
  #title { font-size: 13px; }
  .search { max-width: none; }
  .cal { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  .cal-main { min-height: auto; }
  .daylist { display: flex; flex-direction: column; }
  .dl-day { border-bottom: 1px solid var(--line); padding: 3px 6px 4px; }
  .dl-day.sel { outline: 2px solid #0000FF; outline-offset: -2px; }
  .dl-head { display: flex; gap: 4px; align-items: baseline; }
  .dl-num { font-family: Arial, var(--font); font-weight: bold; font-size: 14px; }
  .dl-hol { color: #FF0000; font-size: 11px; }
  .dl-day .ev { font-size: 13px; line-height: 19px; height: auto; white-space: normal; }
  .side { flex-direction: row; flex-wrap: wrap; margin-top: 4px; }
  .mini { flex: 1 1 150px; }
  .cats { flex: 1 1 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 8px; }
  .cats-t { grid-column: 1 / -1; }
  .status { white-space: normal; }
}
