*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  margin: 0;
  padding: 16px;
  background: #f5f6f8;
  color: #111827;
  /* Avoid clipping the calendar on small screens */
  overflow-x: auto;
}
.bar {
  display: flex;
  gap: 8px;
  row-gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
input,
button {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #cfd6e4;
  background: #ffffff;
  color: #111827;
}
button {
  cursor: pointer;
}
button:hover {
  box-shadow: 0 1px 6px rgba(17, 24, 39, 0.1);
}
button:active {
  transform: translateY(0.5px);
}

.muted {
  color: #6b7280;
  font-size: 12px;
}
.err {
  color: #b91c1c;
  white-space: pre-wrap;
}

.wrap {
  display: grid;
  gap: 14px;
  max-width: 980px;
  margin: 0 auto;
}
@media (max-width: 520px) {
  body {
    padding: 10px;
  }
}
.roomTitle {
  font-weight: 800;
  margin: 8px 0 2px;
}

.cal {
  width: 100%;
  max-width: 100%;
  border: 1px solid #d7dde8;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  min-width: 0;
}
.dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid #e5e7eb;
  background: #f3f4f6;
  width: 100%;
}
.dow div {
  padding: 10px;
  font-weight: 700;
  font-size: 12px;
  color: #374151;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
}

.grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.day {
  min-height: 86px;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 6px 34px; /* bottom space reserved for room dots */
  position: relative;
  min-width: 0;
  overflow: hidden;
}
.day:nth-child(7n) {
  border-right: none;
}

/* --- multi-day bar (Google Calendar-like, per-day segment) --- */
.bars {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 26px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.barEvt {
  height: 16px;
  border-radius: 8px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #111827;
  pointer-events: none;
}
.barEvt.approved {
  background: rgba(34, 197, 94, 0.18);
}
.barEvt.tentative {
  background: rgba(245, 158, 11, 0.18);
}

/* 既存の style="" を使ってるならこのままでOK。CSSに寄せたいなら↓ */

.barEvt.none {
  background: rgba(156, 163, 175, 0.18);
  color: #374151;
}

/* “+N” indicator (not disabled-looking) */
.barEvt.more {
  background: rgba(148, 163, 184, 0.22);
  color: #111827;
  font-weight: 900;
}

/* segment shaping so it feels continuous across days */
.barEvt.seg-mid {
  border-radius: 4px;
}
.barEvt.seg-start {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}
.barEvt.seg-end {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

@media (max-width: 520px) {
  .bars {
    top: 34px;
  }
  .barEvt {
    height: 14px;
    font-size: 10px;
    padding: 0 5px;
    letter-spacing: 0.02em;
  }
}

/* hide room dots when bars are present (avoid overlap) */
.day.hasBars .room-dots {
  display: none;
}

/* layering fix: bars should be above cell contents */
.bars {
  z-index: 5;
}
.num {
  position: relative;
  z-index: 6;
}
.closedMark {
  z-index: 7;
}

.num {
  font-weight: 800;
  font-size: 14px;
}
.out {
  opacity: 0.35;
}
.dayBadge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #1e263a;
  background: #0b1020;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Badge label: keep it compact everywhere */
.label-long {
  display: none;
}
.label-short {
  display: inline;
}

/* --- mobile tweak: make badges compact & centered --- */
@media (max-width: 520px) {
  .dayBadge {
    left: 6px;
    right: 6px;
    width: auto;
    justify-content: center;
    padding: 2px 6px;
    font-size: 10px;
    gap: 5px;
  }
  .dot {
    width: 9px;
    height: 9px;
  }
}

.bg-closed {
  background: rgba(239, 68, 68, 0.1);
}

.closedMark {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

@media (max-width: 520px) {
  .closedMark {
    top: 6px;
    right: 6px;
    width: 22px;
    height: 18px;
    font-size: 11px;
  }
}

.err {
  white-space: pre-wrap;
}

/* ---- modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.show {
  display: flex;
}
.modalCard {
  background: #ffffff;
  border: 1px solid #d7dde8;
  border-radius: 16px;
  width: min(92vw, 520px);
  max-height: 80vh;
  overflow: auto;
}
.modalHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}
.modalBody {
  padding: 12px 14px;
}
.modalClose {
  cursor: pointer;
  border: 1px solid #cfd6e4;
  background: #ffffff;
  border-radius: 10px;
  padding: 6px 10px;
}
.list {
  display: grid;
  gap: 8px;
}
.item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  font-size: 12px;
  background: #ffffff;
}
.item .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.badgeMini {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
}
.approved {
  background: rgba(74, 222, 128, 0.12);
}
.tentative {
  background: rgba(251, 191, 36, 0.07);
}
.none {
  background: rgba(51, 65, 85, 0.06);
}

/* --- day detail (mobile friendly) --- */
.day-rooms {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
}
.room-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.room-code {
  font-weight: 900;
  width: 2.2em;
  text-align: center;
  background: #f3f4f6;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 6px 0;
  flex: 0 0 auto;
}
.room-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.statusPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(17, 24, 39, 0.12);
  color: #111827;
  flex: 0 0 auto;
}
.statusPill.approved {
  background: rgba(34, 197, 94, 0.18);
  color: #111827;
  border-color: rgba(34, 197, 94, 0.35);
}
.statusPill.tentative {
  background: rgba(245, 158, 11, 0.18);
  color: #111827;
  border-color: rgba(245, 158, 11, 0.35);
}
.statusPill.empty {
  background: rgba(156, 163, 175, 0.18);
  color: #374151;
}
@media (max-width: 420px) {
  .room-name {
    max-width: 10em;
  }
}

.room-dots {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: flex;
  gap: 6px;
  margin: 0;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  z-index: 6;
  pointer-events: none;
}
.room-dot-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.room-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(17, 24, 39, 0.14);
  color: #111827;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  user-select: none;
}
.room-dot.approved {
  background: rgba(34, 197, 94, 0.25);
}
.room-dot.tentative {
  background: rgba(245, 158, 11, 0.25);
}
/* 黄 */
.room-dot.empty {
  background: rgba(156, 163, 175, 0.18);
  color: #374151;
}

@media (max-width: 520px) {
  /* スマホは「月全体が一画面で見える」優先で高さを圧縮 */
  input,
  button {
    padding: 6px 8px;
    border-radius: 10px;
    font-size: 12px;
  }

  .wrap {
    gap: 10px;
  }

  .day {
    min-height: 64px;
    padding: 6px 6px 30px;
  }

  .bars {
    top: 22px;
  }

  .barEvt {
    height: 12px;
    font-size: 9px;
    padding: 0 4px;
    letter-spacing: 0.02em;
  }

  /* ドットは「幅を押し広げない」最優先（7列が必ず収まる） */
  .room-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 3px 4px;
  }

  .room-dot-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
  }

  .room-dot {
    width: 12px;
    height: 12px;
    font-size: 8px;
  }
}

/* iframe URL 表示をコンパクトに（PC/スマホ共通） */
.embed-code {
  display: block;
  width: 100%;
  max-width: 750px;
  height: 38px; /* 1行分に固定 */
  line-height: 22px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;

  white-space: nowrap; /* 折り返さない */
  overflow: hidden; /* はみ出し隠す */
  text-overflow: ellipsis; /* … 表示 */

  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #374151;
}

/* タップ時のフィードバック */
.embed-code:active {
  background: #f3f4f6;
}

/* スマホはさらに少しだけ高さを詰める */
@media (max-width: 520px) {
  .embed-code {
    width: 100%;
    height: 34px;
    font-size: 11px;
    padding: 7px 9px;
  }
}

.win-closed {
  opacity: 0.35;
  filter: grayscale(1);
}
.win-closed.disabled {
  pointer-events: none;
}

.win-5plus {
  opacity: 0.7;
  filter: grayscale(0.4);
}

.badge-5plus {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  margin-left: 4px;
}

.notYetOpen {
  opacity: 0.35;
  filter: grayscale(0.6);
}
.notYetOpen .bars,
.notYetOpen .bar,
.notYetOpen .dot {
  opacity: 0.4;
}

.monthTitle {
  font-weight: 900;
  font-size: 22px;
  line-height: 1.2;
  margin: 6px 0 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #111827;
}

/* スマホは少しだけ小さく、でも見失わないサイズ */
@media (max-width: 520px) {
  .monthTitle {
    font-size: 18px;
    margin: 4px 0 6px;
    padding: 7px 9px;
  }
}

/* スタジオ色（A-D） */
.barEvt.room-A {
  background-color: rgba(255, 0, 0, 0.15);
  outline: 2px solid rgba(255, 0, 0, 0.35);
}
.barEvt.room-B {
  background-color: rgba(0, 128, 255, 0.15);
  outline: 2px solid rgba(0, 128, 255, 0.35);
}
.barEvt.room-C {
  background-color: rgba(0, 170, 90, 0.15);
  outline: 2px solid rgba(0, 170, 90, 0.35);
}
.barEvt.room-D {
  background-color: rgba(160, 80, 255, 0.15);
  outline: 2px solid rgba(160, 80, 255, 0.35);
}