.mm-shuffle-wrap {
  font-family: "Hiragino Kaku Gothic ProN", "メイリオ", sans-serif;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── コントロール ── */
.mm-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px 0 14px;
}

.mm-controls label {
  font-weight: bold;
  font-size: 0.95rem;
}

.mm-controls input[type="number"] {
  width: 70px;
  padding: 7px 10px;
  font-size: 1rem;
  border: 2px solid #3a7bd5;
  border-radius: 6px;
  text-align: center;
  outline: none;
}

.mm-controls input[type="number"]:focus {
  border-color: #1a5bb5;
}

#mm-info {
  font-size: 0.9rem;
  color: #666;
  min-width: 150px;
}

#mm-shuffle-btn {
  background: #3a7bd5;
  color: #fff;
  border: none;
  padding: 9px 26px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#mm-shuffle-btn:hover {
  background: #1a5bb5;
}

/* ── 欠席パネル ── */
.mm-absent-wrap {
  margin-bottom: 18px;
}

.mm-absent-toggle {
  background: none;
  border: 1px solid #aaa;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  color: #555;
  transition: background 0.15s, border-color 0.15s;
}

.mm-absent-toggle:hover {
  background: #f0f0f0;
}

.mm-absent-toggle.mm-has-absent {
  border-color: #e67e22;
  color: #c0620a;
  font-weight: bold;
}

#mm-absent-panel {
  margin-top: 10px;
  padding: 14px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e3e6ea;
}

.mm-absent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 10px;
  margin-bottom: 12px;
}

.mm-absent-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 5px;
  transition: background 0.1s;
}

.mm-absent-item:hover {
  background: #e9ecef;
}

.mm-absent-item input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.mm-absent-item > div {
  display: flex;
  flex-direction: column;
}

.mm-absent-name {
  font-size: 0.8rem;
  font-weight: bold;
  line-height: 1.3;
}

.mm-absent-dir {
  font-size: 0.72rem;
  color: #888;
  line-height: 1.3;
}

.mm-absent-item.mm-is-absent .mm-absent-name,
.mm-absent-item.mm-is-absent .mm-absent-dir {
  text-decoration: line-through;
  opacity: 0.5;
}

.mm-absent-clear {
  background: none;
  border: 1px solid #dc3545;
  color: #dc3545;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.mm-absent-clear:hover {
  background: #dc3545;
  color: #fff;
}

/* ── グループ結果 ── */
#mm-results {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.mm-empty {
  color: #999;
  font-size: 0.95rem;
  padding: 20px 0;
  width: 100%;
}

.mm-card {
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 190px;
  max-width: 230px;
  flex: 1 1 190px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mm-card h3 {
  font-size: 0.95rem;
  font-weight: bold;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
}

.mm-card h3 .mm-count {
  font-size: 0.72rem;
  font-weight: normal;
  opacity: 0.65;
  margin-left: auto;
}

.mm-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mm-card ul li {
  padding: 5px 0;
  font-size: 0.86rem;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  line-height: 1.4;
}

.mm-card ul li:last-child {
  border-bottom: none;
}

.mm-facility {
  font-weight: bold;
}

.mm-director {
  color: #555;
  font-size: 0.8rem;
}

/* ── 保存ボタン ── */
#mm-save-area {
  padding: 14px 0 4px;
}

#mm-save-btn {
  background: #28a745;
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#mm-save-btn:hover:not(:disabled) {
  background: #1e7e34;
}

#mm-save-btn.mm-saved,
#mm-save-btn:disabled {
  background: #6c757d;
  cursor: default;
}

/* ── 履歴 ── */
#mm-history-wrap {
  margin-top: 36px;
  border-top: 2px solid #e9ecef;
  padding-top: 20px;
}

.mm-history-title {
  font-size: 1rem;
  font-weight: bold;
  margin: 0 0 14px;
  color: #444;
}

.mm-hist-entry {
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid #e3e6ea;
}

.mm-hist-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.mm-hist-date {
  font-weight: bold;
  font-size: 0.92rem;
  white-space: nowrap;
}

.mm-hist-meta {
  font-size: 0.82rem;
  color: #888;
  flex: 1;
  white-space: nowrap;
}

.mm-hist-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.mm-hist-toggle {
  background: none;
  border: 1px solid #aaa;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.mm-hist-toggle:hover {
  background: #e9ecef;
}

.mm-hist-delete {
  background: none;
  border: 1px solid #dc3545;
  color: #dc3545;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.mm-hist-delete:hover {
  background: #dc3545;
  color: #fff;
}

.mm-hist-body {
  padding: 12px 14px;
  border-top: 1px solid #e0e0e0;
  background: #fff;
}

.mm-hist-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mm-hist-group {
  min-width: 120px;
  flex: 1 1 120px;
}

.mm-hist-group-title {
  font-weight: bold;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid #ddd;
}

.mm-hist-group-title span {
  font-weight: normal;
  color: #999;
  font-size: 0.72rem;
}

.mm-hist-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mm-hist-group ul li {
  font-size: 0.78rem;
  color: #333;
  padding: 2px 0;
}

/* ── スマートフォン対応 ── */
@media (max-width: 600px) {
  .mm-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 16px 0 12px;
  }

  .mm-controls label {
    font-size: 1rem;
  }

  .mm-controls input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.1rem;
    padding: 11px 12px;
  }

  #mm-info {
    font-size: 0.92rem;
    min-width: unset;
  }

  #mm-shuffle-btn {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
  }

  #mm-save-btn {
    width: 100%;
    padding: 13px;
    font-size: 1rem;
  }

  .mm-absent-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mm-card {
    min-width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .mm-hist-actions {
    margin-left: 0;
    width: 100%;
  }

  .mm-hist-toggle,
  .mm-hist-delete {
    flex: 1;
    text-align: center;
  }
}

/* ── 印刷 ── */
@media print {
  .mm-controls,
  .mm-absent-wrap,
  #mm-save-area,
  #mm-history-wrap { display: none; }
  #mm-results { gap: 8px; }
  .mm-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}
