.ecsc-calendar {
  --ecsc-black: #101214;
  --ecsc-border: #cfd2d6;
  --ecsc-soft: #f4f5f6;
  position: relative;
  width: 100%;
  padding: 24px;
  border: 3px solid var(--ecsc-black);
  background: #fff;
  color: #17191c;
  box-shadow: inset 0 0 0 8px #fff, inset 0 0 0 9px #e7e8ea;
}
.ecsc-calendar::before,
.ecsc-calendar::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--ecsc-black);
  box-shadow: 5px 0 #fff, 0 5px #fff, 5px 5px var(--ecsc-black);
}
.ecsc-calendar::before { top: 7px; left: 7px; }
.ecsc-calendar::after { right: 7px; bottom: 7px; transform: rotate(180deg); }
.ecsc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 26px 14px;
}
.ecsc-month-nav { display: flex; align-items: center; gap: 14px; }
.ecsc-month-title { min-width: 260px; margin: 0; text-align: center; font-size: clamp(28px, 3.4vw, 48px); line-height: 1.2; letter-spacing: .08em; }
.ecsc-nav-button,
.ecsc-today-button,
.ecsc-filter,
.ecsc-event,
.ecsc-modal__close { font: inherit; color: inherit; cursor: pointer; }
.ecsc-nav-button { width: 46px; height: 46px; border: 0; background: transparent; font-size: 46px; font-weight: 900; line-height: 1; }
.ecsc-today-button { border: 1px solid #bec2c7; border-radius: 8px; padding: 7px 12px; background: #fff; font-weight: 700; }
.ecsc-rank-legend { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border: 1px dashed #aeb2b8; border-radius: 10px; font-size: 13px; font-weight: 800; }
.ecsc-rank { display: inline-grid; place-items: center; width: 23px; height: 23px; flex: 0 0 23px; border: 2px solid currentColor; border-radius: 50%; background: #fff; font-size: 13px; line-height: 1; }
.ecsc-rank--s { color: #9b6500; background: #fff5cf; }
.ecsc-rank--a { color: #b52b2b; background: #ffe3e3; }
.ecsc-rank--b { color: #176697; background: #dff3ff; }
.ecsc-rank--c { color: #555; background: #eee; }
.ecsc-filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 26px 18px; }
.ecsc-filter { min-width: 108px; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; background: #f0f1f2; font-weight: 800; }
.ecsc-filter.is-active { background: #111; color: #fff; }
.ecsc-filter[data-platform="amazon"] { background: #f4e5d3; }
.ecsc-filter[data-platform="rakuten"] { background: #ffe1e1; }
.ecsc-filter[data-platform="yahoo"] { background: #e9ddf5; }
.ecsc-filter[data-platform="qoo10"] { background: #ffe0ec; }
.ecsc-filter.is-active { background: #111; }
.ecsc-status { min-height: 24px; padding: 0 26px 8px; color: #62666d; font-size: 14px; }
.ecsc-scroll { overflow-x: auto; border: 1px solid #aeb3b8; }
.ecsc-grid { min-width: 950px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: #aeb3b8; gap: 1px; }
.ecsc-weekday { padding: 8px; background: #13212b; color: #fff; text-align: center; font-size: 17px; font-weight: 900; }
.ecsc-day { min-height: 112px; padding: 6px 8px 8px; background: #fff; overflow: hidden; }
.ecsc-day.is-outside { background: #f7f7f7; color: #969aa0; }
.ecsc-day.is-today { box-shadow: inset 0 0 0 3px #111; }
.ecsc-day__number { margin-bottom: 4px; font-size: 16px; font-weight: 900; line-height: 1.2; }
.ecsc-day.is-sunday .ecsc-day__number { color: #e02424; }
.ecsc-day.is-saturday .ecsc-day__number { color: #1769e0; }
.ecsc-day__events { display: grid; gap: 4px; }
.ecsc-event { width: 100%; min-width: 0; padding: 3px 4px; display: flex; align-items: center; gap: 4px; border: 1px solid transparent; border-radius: 5px; background: #fafafa; text-align: left; font-size: 11px; line-height: 1.25; }
.ecsc-event:hover { border-color: #111; }
.ecsc-event .ecsc-rank { width: 18px; height: 18px; flex-basis: 18px; border-width: 1px; font-size: 10px; }
.ecsc-platform-mark { width: 18px; height: 18px; flex: 0 0 18px; display: grid; place-items: center; border: 1px solid #777; border-radius: 4px; background: #fff; color: #111; font-weight: 900; }
.ecsc-event--amazon .ecsc-platform-mark { border-bottom: 3px solid #e6a400; }
.ecsc-event--rakuten .ecsc-platform-mark { color: #bf0000; }
.ecsc-event--yahoo .ecsc-platform-mark { color: #145fb4; }
.ecsc-event--qoo10 .ecsc-platform-mark { color: #d60055; border-color: #d60055; }
.ecsc-event__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ecsc-predicted { margin-left: auto; padding: 1px 3px; border: 1px dashed #777; border-radius: 3px; font-size: 9px; }
.ecsc-more { padding-left: 4px; color: #62666d; font-size: 11px; font-weight: 700; }
.ecsc-calendar.is-loading .ecsc-grid { opacity: .42; pointer-events: none; }
.ecsc-modal[hidden] { display: none; }
.ecsc-modal { position: fixed; z-index: 100000; inset: 0; display: grid; place-items: center; padding: 20px; }
.ecsc-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.ecsc-modal__dialog { position: relative; width: min(760px, 100%); max-height: min(820px, calc(100vh - 40px)); overflow: auto; padding: 34px; border: 3px solid #111; background: #fff; box-shadow: 0 18px 60px rgba(0,0,0,.35); }
.ecsc-modal__close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 34px; line-height: 1; }
.ecsc-modal__content h2 { margin: 8px 48px 5px 0; font-size: 28px; line-height: 1.4; }
.ecsc-detail-platform { display: inline-block; padding: 4px 8px; border-radius: 5px; background: #111; color: #fff; font-size: 12px; font-weight: 800; }
.ecsc-detail-shortname { margin: 0 0 20px; color: #62666d; font-weight: 700; }
.ecsc-detail-list { margin: 22px 0; border-top: 1px solid #d7d9dc; }
.ecsc-detail-row { display: grid; grid-template-columns: 125px 1fr; border-bottom: 1px solid #d7d9dc; }
.ecsc-detail-row dt, .ecsc-detail-row dd { margin: 0; padding: 10px 12px; }
.ecsc-detail-row dt { background: #f3f4f5; font-weight: 800; }
.ecsc-detail-text { max-height: 300px; overflow: auto; padding: 16px; border: 1px solid #ddd; background: #fafafa; font-size: 14px; }
.ecsc-detail-text p:first-child { margin-top: 0; }
.ecsc-detail-link a { display: inline-block; padding: 12px 20px; border-radius: 7px; background: #111; color: #fff; font-weight: 800; }
body.ecsc-modal-open { overflow: hidden; }
@media (max-width: 780px) {
  .ecsc-calendar { padding: 15px; }
  .ecsc-toolbar { align-items: stretch; flex-direction: column; padding: 8px 10px 12px; }
  .ecsc-month-nav { justify-content: center; }
  .ecsc-month-title { min-width: 0; font-size: 28px; }
  .ecsc-rank-legend { align-self: center; }
  .ecsc-filters { padding: 0 10px 14px; gap: 7px; }
  .ecsc-filter { min-width: auto; flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }
  .ecsc-status { padding-inline: 10px; }
  .ecsc-modal__dialog { padding: 26px 18px; }
  .ecsc-detail-row { grid-template-columns: 1fr; }
  .ecsc-detail-row dt { padding-bottom: 3px; }
  .ecsc-detail-row dd { padding-top: 3px; }
}

/* v0.1.3 detail modal */
.ecsc-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

/* v0.1.5 smartphone calendar + selected-day list */
.ecsc-mobile-view { display: none; }
.ecsc-rank-guide { display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 780px) {
  .ecsc-calendar {
    padding: 12px;
    border-width: 2px;
    box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 6px #e7e8ea;
  }
  .ecsc-calendar::before,
  .ecsc-calendar::after { display: none; }
  .ecsc-toolbar { padding: 4px 0 12px; }
  .ecsc-toolbar .ecsc-rank-legend { display: none; }
  .ecsc-month-nav { width: 100%; gap: 8px; justify-content: space-between; }
  .ecsc-month-title { flex: 1; min-width: 0; white-space: nowrap; font-size: clamp(24px, 8vw, 34px); letter-spacing: .03em; }
  .ecsc-nav-button { width: 38px; height: 42px; font-size: 38px; }
  .ecsc-today-button { flex: 0 0 auto; padding: 8px 12px; }
  .ecsc-status { min-height: 0; padding: 0 2px 6px; font-size: 12px; }
  .ecsc-desktop-view { display: none; }
  .ecsc-mobile-view { display: block; }

  .ecsc-mobile-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid #b9bec4;
    border-left: 1px solid #b9bec4;
    background: #fff;
  }
  .ecsc-mobile-weekday {
    padding: 7px 2px;
    border-right: 1px solid #b9bec4;
    border-bottom: 1px solid #b9bec4;
    background: #13212b;
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 900;
  }
  .ecsc-mobile-weekday--0 { color: #ff3b3b; }
  .ecsc-mobile-weekday--6 { color: #3b9cff; }
  .ecsc-mobile-day {
    min-width: 0;
    min-height: 74px;
    padding: 5px 3px;
    border: 0;
    border-right: 1px solid #cdd1d5;
    border-bottom: 1px solid #cdd1d5;
    background: #fff;
    color: #16191c;
    text-align: left;
    cursor: pointer;
  }
  .ecsc-mobile-day.is-outside { color: #9ba0a5; background: #fafafa; }
  .ecsc-mobile-day.is-selected { background: #111; color: #fff; box-shadow: inset 0 0 0 2px #111, inset 0 0 0 3px #fff; }
  .ecsc-mobile-day.is-today:not(.is-selected) { box-shadow: inset 0 0 0 2px #111; }
  .ecsc-mobile-day__number { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 900; line-height: 1; }
  .ecsc-mobile-day.is-sunday .ecsc-mobile-day__number { color: #e02424; }
  .ecsc-mobile-day.is-saturday .ecsc-mobile-day__number { color: #1769e0; }
  .ecsc-mobile-day.is-selected .ecsc-mobile-day__number { color: #fff; }
  .ecsc-mobile-day__marks { display: grid; gap: 3px; align-content: start; }
  .ecsc-mobile-mark { display: flex; align-items: center; gap: 3px; min-width: 0; }
  .ecsc-mobile-mark .ecsc-rank { width: 18px; height: 18px; flex-basis: 18px; border-width: 1px; font-size: 10px; }
  .ecsc-mobile-mark .ecsc-platform-mark { width: 18px; height: 18px; flex-basis: 18px; font-size: 10px; }
  .ecsc-mobile-day.is-selected .ecsc-rank { background: #fff; }
  .ecsc-mobile-overflow { color: #62666d; font-size: 9px; font-weight: 800; }
  .ecsc-mobile-day.is-selected .ecsc-mobile-overflow { color: #fff; }

  .ecsc-mobile-filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 0 8px;
  }
  .ecsc-mobile-filters .ecsc-filter {
    min-width: 0;
    padding: 9px 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .ecsc-mobile-rank-guide {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
    padding: 8px 7px;
    border: 1px dashed #aeb2b8;
    border-radius: 9px;
    font-size: 11px;
  }
  .ecsc-mobile-rank-guide > strong { font-size: 12px; }
  .ecsc-mobile-rank-guide .ecsc-rank { width: 21px; height: 21px; flex-basis: 21px; font-size: 11px; }

  .ecsc-mobile-day-panel {
    padding: 10px;
    border: 1px solid #cfd2d6;
    border-radius: 10px;
    background: #fff;
  }
  .ecsc-mobile-day-panel__header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .ecsc-mobile-day-panel__header h3 { margin: 0; font-size: 20px; line-height: 1.25; }
  .ecsc-mobile-selected-count { padding: 3px 8px; border-radius: 999px; background: #777; color: #fff; font-size: 11px; font-weight: 800; }
  .ecsc-mobile-event-list { display: grid; gap: 6px; }
  .ecsc-mobile-card {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 10px;
    border: 1px solid #cfd2d6;
    border-left: 3px solid #777;
    border-radius: 8px;
    background: #fff;
    color: #17191c;
    text-align: left;
    cursor: pointer;
  }
  .ecsc-mobile-card.ecsc-event--amazon { border-left-color: #d99b00; }
  .ecsc-mobile-card.ecsc-event--rakuten { border-left-color: #bf0000; }
  .ecsc-mobile-card.ecsc-event--yahoo { border-left-color: #7560b9; }
  .ecsc-mobile-card.ecsc-event--qoo10 { border-left-color: #d60055; }
  .ecsc-mobile-card__badges { display: flex; align-items: center; gap: 6px; }
  .ecsc-mobile-card__badges .ecsc-rank { width: 26px; height: 26px; flex-basis: 26px; font-size: 13px; }
  .ecsc-mobile-card__badges .ecsc-platform-mark { width: 30px; height: 30px; flex-basis: 30px; font-size: 16px; }
  .ecsc-mobile-card__body { min-width: 0; display: grid; gap: 4px; }
  .ecsc-mobile-card__body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
  .ecsc-mobile-card__meta { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; color: #555b62; font-size: 10px; }
  .ecsc-mobile-card__meta small { padding: 2px 5px; border-radius: 4px; background: #f1f2f3; color: #333; }
  .ecsc-mobile-card__arrow { font-size: 28px; font-weight: 700; line-height: 1; }
  .ecsc-mobile-empty { margin: 0; padding: 16px 8px; color: #62666d; text-align: center; font-size: 13px; }
  .ecsc-mobile-help { margin: 10px 0 0; padding: 10px 12px; border: 1px dashed #c3c7cc; border-radius: 9px; color: #4f545a; font-size: 11px; line-height: 1.65; }

  .ecsc-modal { padding: 10px; }
  .ecsc-modal__dialog { max-height: calc(100vh - 20px); padding: 28px 16px 18px; border-width: 2px; }
  .ecsc-modal__content h2 { margin-right: 42px; font-size: 22px; }
}

@media (max-width: 390px) {
  .ecsc-calendar { padding: 9px; }
  .ecsc-mobile-day { min-height: 68px; padding-inline: 2px; }
  .ecsc-mobile-mark { gap: 2px; }
  .ecsc-mobile-mark .ecsc-rank,
  .ecsc-mobile-mark .ecsc-platform-mark { width: 16px; height: 16px; flex-basis: 16px; font-size: 9px; }
  .ecsc-mobile-card { gap: 6px; padding: 8px 7px; }
  .ecsc-mobile-card__badges { gap: 4px; }
  .ecsc-mobile-card__badges .ecsc-rank { width: 23px; height: 23px; flex-basis: 23px; }
  .ecsc-mobile-card__badges .ecsc-platform-mark { width: 27px; height: 27px; flex-basis: 27px; }
  .ecsc-mobile-card__body strong { font-size: 14px; }
}

/* v0.1.6 mobile selected-day usability fixes */
@media (max-width: 767px) {
  .ecsc-mobile-day {
    display: grid;
    grid-template-rows: 18px minmax(0, 1fr);
    align-content: start;
  }

  .ecsc-mobile-day__number {
    height: 18px;
    margin: 0;
    line-height: 18px;
  }

  .ecsc-mobile-day__marks {
    min-height: 0;
    padding-top: 5px;
  }

  .ecsc-mobile-day-panel {
    scroll-margin-top: 12px;
  }
}



.ecsc-modal__footer:empty { display: none; }
.ecsc-modal__footer { padding-top: 18px; }
.ecsc-modal__footer a { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 0 20px; background: #111; color: #fff; font-weight: 700; text-decoration: none; }

/* v0.1.8 iOS-safe mobile modal */
@media (max-width: 780px) {
  .ecsc-modal {
    display: block;
    padding: 0;
    background: #fff;
  }

  .ecsc-modal__backdrop {
    display: none;
  }

  .ecsc-modal__dialog {
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100svh;
    max-height: 100svh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  .ecsc-modal__close {
    position: absolute;
    z-index: 10;
    top: calc(10px + env(safe-area-inset-top));
    right: 12px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #cfd2d6;
    border-radius: 999px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 2px 12px rgba(0,0,0,.16);
    color: #111;
    font-size: 34px;
    line-height: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .ecsc-modal__content {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-top: calc(76px + env(safe-area-inset-top));
    scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
    padding: calc(26px + env(safe-area-inset-top)) 18px 28px;
    background: #fff;
  }

  .ecsc-modal__content h2 {
    margin: 8px 58px 16px 0;
    font-size: 24px;
    line-height: 1.35;
  }

  .ecsc-modal__footer {
    flex: 0 0 auto;
    position: relative;
    z-index: 6;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.98);
    border-top: 1px solid #d7d9dc;
    box-shadow: 0 -8px 18px rgba(0,0,0,.06);
  }

  .ecsc-modal__footer:empty {
    display: none;
  }

  .ecsc-modal__footer a {
    display: flex;
    width: 100%;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 8px;
    background: #111;
    color: #fff;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
  }
}

body.ecsc-modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}
