body { font-family: "Yu Gothic UI","Meiryo",sans-serif; padding: 12px; max-width: 1500px; margin: 0 auto; font-size: 14px; color: #222; }
h1 { font-size: 1.25em; background: #e8eef5; padding: 8px 14px; border-left: 6px solid #4a6fa5; margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#scroll-bottom-btn { padding: 4px 8px; background: #fff; border: 1px solid #4a6fa5; border-radius: 4px; cursor: pointer; color: #4a6fa5; line-height: 1; }
#scroll-bottom-btn:hover { background: #d8e0f0; }
.legend { background: #f5f5f5; padding: 8px 12px; margin: 8px 0; font-size: 0.92em; line-height: 1.6; }
.legend p { margin: 2px 0; }
.legend .warn { color: #c00; }
.nav { margin: 12px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav button { padding: 6px 12px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* 年月ピッカー: input自体をアイコンサイズに固定し、内蔵のpicker indicatorで透明クリック領域を作る */
#month-picker {
  position: relative; /* picker-indicator のabsolute基準を確実にinputへ束ねる */
  width: 36px;
  height: 30px;
  box-sizing: border-box;
  vertical-align: middle;
  padding: 0;
  margin: 0;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
  background-color: #fff;
  touch-action: manipulation;
  flex: 0 0 36px; /* flexコンテナ内で勝手に広がらない */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='1.5' y='3.5' width='13' height='11' rx='1' fill='none' stroke='%234a6fa5' stroke-width='1.4'/><line x1='1.5' y1='6.5' x2='14.5' y2='6.5' stroke='%234a6fa5' stroke-width='1.4'/><line x1='5' y1='1.5' x2='5' y2='4.5' stroke='%234a6fa5' stroke-width='1.4'/><line x1='11' y1='1.5' x2='11' y2='4.5' stroke='%234a6fa5' stroke-width='1.4'/><rect x='4' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='7' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='10' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='4' y='11.5' width='2' height='2' fill='%234a6fa5'/><rect x='7' y='11.5' width='2' height='2' fill='%234a6fa5'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  color: transparent;
  text-shadow: 0 0 0 transparent;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
  flex: 0 0 auto;
}
#month-picker:hover { background-color: #e8eef5; }
#month-picker:focus { outline: 2px solid #4a6fa5; }
/* テキスト部分・picker indicatorを完全に透明化（クリック領域はそのまま） */
#month-picker::-webkit-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  margin: 0;
  padding: 0;
}
#month-picker::-webkit-date-and-time-value { color: transparent; opacity: 0; visibility: hidden; }
#month-picker::-moz-color-swatch { display: none; }
#current-month { font-weight: bold; min-width: 100px; text-align: center; cursor: pointer; padding: 4px 6px; border-radius: 4px; user-select: none; }
#current-month:hover { background: #e8eef5; }
#me-selector { margin: 8px 0; padding: 8px 12px; background: #fff8e1; border-radius: 4px; }
#me-selector select { font-size: 1em; padding: 2px 6px; }
#status-msg { color: #060; font-size: 0.9em; }
#error-msg { color: #c00; font-size: 0.9em; }

/* === テーブル === */
table.grid { border-collapse: collapse; }
table.grid th, table.grid td { border: 1px solid #888; padding: 4px 6px; text-align: center; font-size: 13px; color: #000; }
table.grid th { background: #f5f5f5; }

/* 日付・グループ列（クリックで活動実施/休止トグル） */
table.grid th.date-cell { text-align: left; padding: 4px 8px; min-width: 130px; white-space: nowrap; cursor: pointer; user-select: none; }
table.grid th.date-cell:hover { outline: 2px solid #4a6fa5; outline-offset: -2px; }
table.grid th.date-cell.date-saturday { background: #fff5d0; }
table.grid th.date-cell.date-tuesday  { background: #f0fff0; }
table.grid th.date-cell .grp-batsai   { color: #804000; font-weight: bold; }
table.grid th.date-cell .grp-satoyama { color: #006080; font-weight: bold; }
table.grid th.date-cell .cancel-mark  { color: #c00; font-weight: bold; margin-left: 6px; }

/* 活動休止（全日）状態の行 */
tr.row-cancelled th.date-cell { background: #ffd0d0 !important; }
tr.row-cancelled td.cell { background: #d8d8d8 !important; color: #999 !important; opacity: 0.5; cursor: not-allowed !important; pointer-events: none; }
tr.row-cancelled td.count-cell { background: #d8d8d8 !important; color: #999 !important; opacity: 0.5; }
/* 部分休止（午前/午後）の行 */
tr.row-partial th.date-cell { background: #ffe9c8 !important; }
tr.row-partial th.date-cell .cancel-mark { color: #c66; }

/* 集計列 */
table.grid th.count-header { min-width: 28px; }
table.grid td.count-cell { background: #fafafa; min-width: 28px; }
table.grid td.count-cell.max-d { background: #bfd8ff; font-weight: bold; }
table.grid td.count-cell.max-m { background: #c8eebf; font-weight: bold; }
table.grid td.count-cell.max-t { background: #ffe5a8; font-weight: bold; }
table.grid td.count-cell.max-x { background: #ffd0d0; font-weight: bold; }

/* メンバーヘッダ */
table.grid th.member-header { min-width: 50px; cursor: pointer; user-select: none; }
table.grid th.member-header:hover { background: #fffacd; }
table.grid th.member-header.member-mine { background: #ffe066; color: #c00; font-weight: bold; }

/* 出欠セル */
table.grid td.cell { min-width: 36px; user-select: none; cursor: not-allowed; font-weight: bold; color: #000; }
table.grid td.cell.editable { cursor: pointer; }
table.grid td.cell.editable:hover { outline: 2px solid #4a6fa5; outline-offset: -2px; }
table.grid td.bg-d { background: #bfd8ff; }
table.grid td.bg-m { background: #c8eebf; }
table.grid td.bg-t { background: #ffe5a8; }
table.grid td.bg-x { background: #ffd0d0; }
/* 特別活動日 */
tr.row-special th.date-cell { background: #f0e0ff !important; color: #602080; }
tr.row-special th.date-cell .special-tag { background: #b080d0; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 0.85em; margin-left: 4px; font-weight: bold; }
tr.row-special td.cell { background: #faf0ff; }
tr.row-special td.count-cell { background: #f5e8fa; }

/* === コメント === */
.comments { margin-top: 24px; }
.comments h2 { font-size: 1.05em; margin: 0 0 8px; background: #e8eef5; padding: 6px 12px; border-left: 6px solid #4a6fa5; }
.comment { padding: 6px 4px; border-bottom: 1px solid #eee; }
.comment-meta { font-size: 0.85em; color: #555; }
.comment-body { margin-top: 2px; white-space: pre-wrap; }
#comment-form textarea { width: 100%; box-sizing: border-box; font-family: inherit; padding: 4px; }
#comment-form button { padding: 6px 16px; margin-top: 4px; cursor: pointer; }
#comment-form .hint { font-size: 0.85em; color: #666; margin-left: 6px; }

/* === 活動日別集計 === */
.daily-summary { margin-top: 24px; }
.daily-summary h2 { font-size: 1.05em; margin: 0 0 8px; background: #e8eef5; padding: 6px 12px; border-left: 6px solid #4a6fa5; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#toggle-all-summary { font-size: 0.9em; padding: 4px 12px; cursor: pointer; background: #fff; border: 1px solid #4a6fa5; border-radius: 4px; color: #4a6fa5; }
#toggle-all-summary:hover { background: #d8e0f0; }
details.day-block { border: 1px solid #bbb; border-radius: 4px; margin: 8px 0; padding: 4px 10px; }
details.day-block[open] { padding: 8px 12px; }
details.day-block.day-saturday { background: #fffbe5; border-color: #e8d080; }
details.day-block.day-tuesday  { background: #f5fff5; border-color: #b0d8b0; }
details.day-block.day-cancelled { background: #d8d8d8 !important; border-color: #888 !important; }
details.day-block summary { cursor: pointer; user-select: none; list-style: none; padding: 4px 0; }
details.day-block summary::-webkit-details-marker { display: none; }
details.day-block summary::before { content: '▶'; color: #888; margin-right: 6px; font-size: 0.8em; transition: transform 0.15s; display: inline-block; }
details.day-block[open] summary::before { transform: rotate(90deg); }
details.day-block[open] summary { padding-bottom: 4px; border-bottom: 1px dashed #ccc; margin-bottom: 6px; }
details.day-block .day-body { padding-top: 2px; }
.day-block .day-header { font-weight: bold; font-size: 1.05em; }
.day-block .day-header .hcount { margin-left: 10px; font-weight: normal; font-size: 0.95em; }
.day-block .day-header .grp { margin-left: 8px; padding: 1px 6px; border-radius: 3px; font-size: 0.85em; }
.day-block .day-header .grp.batsai   { background: #f5e0c0; color: #804000; }
.day-block .day-header .grp.satoyama { background: #c0e0e8; color: #006080; }
.day-block .day-header .total { font-weight: normal; color: #666; font-size: 0.9em; margin-left: 8px; }
.day-block .day-row { margin: 3px 0; line-height: 1.6; }
.day-block .day-row .label { display: inline-block; width: 110px; font-weight: bold; }
.day-block .day-row .names-empty { color: #bbb; font-size: 0.9em; }
.day-block .day-row.r-cancel { color: #c00; font-weight: bold; font-size: 1.05em; padding: 4px 0; border-bottom: 1px solid #aaa; margin-bottom: 4px; }
.day-copy-btn {
  margin-left: 8px;
  padding: 2px 6px;
  cursor: pointer;
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 3px;
  vertical-align: middle;
  color: #4a6fa5;
  line-height: 1;
}
.day-copy-btn:hover { background: #e8eef5; }
.day-copy-btn svg { vertical-align: middle; display: inline-block; }

/* === 運営者用セクション === */
.admin-section { margin-top: 24px; border: 1px solid #c0c0c0; border-radius: 4px; }
.admin-section summary { cursor: pointer; padding: 8px 12px; background: #f0f0f0; font-weight: bold; user-select: none; }
.admin-section summary:hover { background: #e8e8e8; }
.admin-section .admin-body { padding: 10px 14px; background: #fff8e1; }
.admin-section .admin-body .warn { color: #c00; font-weight: bold; }
.admin-section .admin-item { padding: 8px 0; border-bottom: 1px dashed #d0c080; }
.admin-section .admin-item:last-child { border-bottom: 0; }
.admin-section .admin-item h3 { font-size: 1em; margin: 0 0 4px; color: #604000; }
.admin-section #members-table { border-collapse: collapse; width: 100%; max-width: 400px; margin-top: 4px; }
.admin-section #members-table th, .admin-section #members-table td { border: 1px solid #c0c0c0; padding: 4px 8px; text-align: left; font-size: 0.95em; }
.admin-section #members-table th { background: #f0f0f0; }
.admin-section #members-table .del-btn { padding: 2px 8px; cursor: pointer; color: #c00; background: #fff; border: 1px solid #c66; border-radius: 3px; }
.admin-section #members-table .del-btn:hover { background: #ffe0e0; }
.admin-section #special-table { border-collapse: collapse; width: 100%; max-width: 500px; margin-top: 4px; }
.admin-section #special-table th, .admin-section #special-table td { border: 1px solid #c0c0c0; padding: 4px 8px; text-align: left; font-size: 0.95em; }
.admin-section #special-table th { background: #f0f0f0; }
.admin-section #special-table .del-btn { padding: 2px 8px; cursor: pointer; color: #c00; background: #fff; border: 1px solid #c66; border-radius: 3px; }
.admin-section .special-add-row .field-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.admin-section .special-add-row .field-row label { min-width: 60px; font-weight: bold; color: #604000; }
.admin-section .special-month-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-section .special-month-nav button { padding: 4px 10px; cursor: pointer; touch-action: manipulation; }
.admin-section .special-month-nav #special-current-month { font-weight: bold; min-width: 90px; text-align: center; cursor: pointer; padding: 4px 6px; border-radius: 4px; user-select: none; }
.admin-section .special-month-nav #special-current-month:hover { background: #e8eef5; }
.admin-section .special-month-nav #special-month-picker {
  position: relative; width: 32px; height: 28px; box-sizing: border-box; padding: 0; margin: 0;
  border: 1px solid #c0c0c0; border-radius: 4px; background-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='1.5' y='3.5' width='13' height='11' rx='1' fill='none' stroke='%234a6fa5' stroke-width='1.4'/><line x1='1.5' y1='6.5' x2='14.5' y2='6.5' stroke='%234a6fa5' stroke-width='1.4'/><line x1='5' y1='1.5' x2='5' y2='4.5' stroke='%234a6fa5' stroke-width='1.4'/><line x1='11' y1='1.5' x2='11' y2='4.5' stroke='%234a6fa5' stroke-width='1.4'/><rect x='4' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='7' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='10' y='8.5' width='2' height='2' fill='%234a6fa5'/><rect x='4' y='11.5' width='2' height='2' fill='%234a6fa5'/><rect x='7' y='11.5' width='2' height='2' fill='%234a6fa5'/></svg>");
  background-repeat: no-repeat; background-position: center; background-size: 16px 16px;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  color: transparent; font-size: 0; overflow: hidden; touch-action: manipulation; flex: 0 0 32px;
}
.admin-section .special-month-nav #special-month-picker::-webkit-calendar-picker-indicator {
  opacity: 0; cursor: pointer; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.admin-section .special-add-row .field-row input[type=date],
.admin-section .special-add-row .field-row input[type=text] { font-size: 16px; padding: 6px 8px; border: 1px solid #c0c0c0; border-radius: 4px; flex: 1; min-width: 140px; }
.admin-section code#distrib-url-text { display: block; padding: 8px; background: #fff; border: 1px solid #ccc; word-break: break-all; font-family: Consolas, "Courier New", monospace; font-size: 0.92em; }
.admin-section button { padding: 6px 14px; cursor: pointer; }

/* === ポップアップ === */
.status-popup { position: absolute; background: #fff; border: 2px solid #4a6fa5; border-radius: 4px; padding: 4px; box-shadow: 2px 2px 8px rgba(0,0,0,0.3); z-index: 100; min-width: 160px; }
.status-popup button { display: block; width: 100%; padding: 8px 12px; margin: 2px 0; cursor: pointer; text-align: left; border: 1px solid #ccc; background: #fff; font-size: 0.95em; color: #000; }
.status-popup button:hover { background: #f0f8ff; }
.status-popup button.opt-d { background: #bfd8ff; }
.status-popup button.opt-m { background: #c8eebf; }
.status-popup button.opt-t { background: #ffe5a8; }
.status-popup button.opt-x { background: #ffd0d0; }
.status-popup button.opt-cancel { background: #ffd0d0; color: #c00; font-weight: bold; }
.status-popup button.opt-active { background: #bfd8ff; color: #06c; font-weight: bold; }

/* === モバイル対応 === */
@media (max-width: 720px) {
  body { padding: 6px; font-size: 13px; }
  h1 { font-size: 1.05em; padding: 6px 10px; }
  .legend { font-size: 0.85em; padding: 6px 8px; }
  .nav { gap: 6px; }
  .nav button { padding: 8px 12px; min-height: 36px; min-width: 44px; }
  #me-selector select { min-height: 36px; padding: 4px 8px; }
  table.grid th, table.grid td { padding: 6px 5px; font-size: 12px; }
  table.grid th.date-cell { min-width: 110px; font-size: 11px; }
  table.grid td.cell { min-width: 36px; min-height: 36px; }
  table.grid th.member-header { min-width: 44px; font-size: 11px; }
  .status-popup button { padding: 10px 14px; font-size: 1em; min-height: 40px; }
  #comment-form textarea { font-size: 16px; }
  #comment-form button { padding: 8px 16px; min-height: 36px; }
  .day-block .day-row .label { width: 90px; font-size: 0.9em; }
}

/* === ローディング表示 === */
body[data-loading="true"] { cursor: progress; }
body[data-loading="true"] .nav button,
body[data-loading="true"] .admin-section button,
body[data-loading="true"] #post-comment,
body[data-loading="true"] #delete-comment {
  opacity: 0.6;
  pointer-events: none;
}
#loading-spinner {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 3px solid #e8eef5;
  border-top-color: #4a6fa5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
  z-index: 1000;
  background: transparent;
}
body[data-loading="true"] #loading-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === メンバー管理: 削除済み行 === */
.admin-section #members-table tr.member-inactive { background: #f0f0f0; color: #888; }
.admin-section #members-table tr.member-inactive td { color: #888; }
.admin-section #members-table .restore-btn { padding: 2px 8px; cursor: pointer; color: #060; background: #fff; border: 1px solid #6c6; border-radius: 3px; }
.admin-section #members-table .restore-btn:hover { background: #e0ffe0; }
.admin-section #members-table .section-header td { background: #e8eef5; font-weight: bold; color: #4a6fa5; padding: 4px 8px; }
