:root {
  --sc-bg: #25292E;
  --sc-surface: #30363D;
  --sc-surface-2: #25292E;
  --sc-border: #3a3f46;
  --sc-text: #e6edf6;
  --sc-text-dim: #aab6c5;
  --sc-accent: #4e7df3;
  --sc-gutter-w: 64px;
  --sc-gap: 8px;
  --sc-radius: 10px;
  --sc-event-radius: 8px;
}

/* container */
.sc-calendar {
  position: relative;
  color: var(--sc-text);
  background: var(--sc-bg);
  padding: 16px;
  border-radius: var(--sc-radius);
  border: 1px solid var(--sc-border);
}

/* toolbar */
.sc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  user-select: none;
}

.sc-weeklabel {
  font-weight: 600;
  letter-spacing: .2px;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  padding: 6px 10px;
  border-radius: 7px;
  min-width: 120px;
  text-align: center;
}

.sc-nav {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sc-text);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  line-height: 30px;
  font-size: 18px;
  cursor: pointer;
  transition: background .15s ease, transform .06s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sc-nav:focus {
  border: 1px solid transparent;
  background: transparent;
}

.sc-nav:hover {
  border: 1px solid transparent;
  background: transparent;
}

.sc-nav:active {
  border: 1px solid transparent;
  background: transparent;
}

.sc-nav::before {
  content: '\f345';
  font-family: dashicons;
  font-size: 18px;
  color: #EC6608;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.sc-nav.sc-prev::before {
  content: '\f341';
  /* Left arrow dashicon */
}

.sc-nav.sc-next::before {
  content: '\f345';
  /* Right arrow dashicon */
}

.sc-nav:hover {
  background: var(--sc-surface-2);
}

.sc-nav:active {
  transform: translateY(1px);
}

/* grid */
.sc-grid {
  display: grid;
  grid-template-columns: var(--sc-gutter-w) repeat(var(--sc-days, 7), 1fr);
  gap: var(--sc-gap);
}

.sc-grid-no-gutter {
  grid-template-columns: repeat(var(--sc-days, 7), 1fr);
}

/* time gutter */
.sc-time-gutter {
  position: relative;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius);
  overflow: hidden;
  min-height: calc(var(--sc-total-mins) * var(--sc-px-per-min) * 1px + 48px);
}

.sc-time {
  position: absolute;
  left: 8px;
  top: 0px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--sc-text-dim);
  padding: 2px 4px;
  pointer-events: none;
  line-height: 1;
  text-align: left;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* day column */
.sc-day {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sc-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 10px 8px;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: 8px 8px 0px 0px;
}

.sc-day-name {
  font-weight: 600;
}

.sc-day-date {
  color: var(--sc-text-dim);
  font-size: 12px;
}

.sc-day-body {
  position: relative;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-top: none;
  border-radius: 0 0 var(--sc-radius) var(--sc-radius);
  padding: 0 0 24px 0;
  min-height: 480px;
  /* hour stripes */
  background-image:
    repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) calc(60 * var(--sc-px-per-min) * 1px),
      transparent calc(60 * var(--sc-px-per-min) * 1px),
      transparent calc(120 * var(--sc-px-per-min) * 1px));
}

/* events */
.sc-event {
  position: absolute;
  /*margin-left: 3px; /* leaves 3px gap at left */
  /*margin-right: 3px;*/
  border-radius: var(--sc-event-radius);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 6px 14px rgba(0, 0, 0, 0.22);
  color: #f7faff;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.06);
  z-index: 1;
  transition: transform .08s ease, box-shadow .12s ease;
  /* Bakgrundsbild-stöd */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.sc-event.is-merged {
  margin-left: 0;
  margin-right: 0;
}

.sc-event.is-merged-first {
  margin-left: 3px;
  border-top-left-radius: var(--sc-event-radius);
  border-bottom-left-radius: var(--sc-event-radius);
}

.sc-event.is-merged-last {
  margin-right: 3px;
  border-top-right-radius: var(--sc-event-radius);
  border-bottom-right-radius: var(--sc-event-radius);
}

.is-merged+.is-merged {
  /* subtle inner seam */
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.06), 0 1px 0 rgba(0, 0, 0, 0.25), 0 6px 14px rgba(0, 0, 0, 0.22);
}

.sc-event.is-tight-top {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.sc-event.is-tight-bottom {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.sc-event .sc-event-strip {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-top-left-radius: var(--sc-event-radius);
  border-bottom-left-radius: var(--sc-event-radius);
}

.sc-event-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  /* Gradient overlay för läsbarhet av text över bakgrundsbild */
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.7) 100%);
  position: relative;
  z-index: 1;
  height: 100%;
}

/* Platform icons */
.sc-platform-icons {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  z-index: 2;
  pointer-events: none;
}

.sc-platform-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sc-event:hover {
  z-index: 2;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28), 0 10px 20px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.sc-event.is-stacked {
  z-index: 3;
}

.sc-avatar.sc-img {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: #fff;
  border: 2px solid #fff;
  /* white rim like screenshot */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
}

.sc-avatar.sc-initial {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .25);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .3px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.sc-event-meta {
  min-width: 0;
  display: grid;
  width: 100%;
}

.sc-event-title {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.8);
  color: #fff;
}

.sc-event-time {
  font-size: 15px;
  color: #fff;
  font-weight: 500;
  opacity: .95;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* loading */
.sc-calendar.is-loading {
  opacity: .7;
  pointer-events: none;
}

.sc-calendar.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.18), transparent 60%);
  pointer-events: none;
}

.sc-calendar.is-loading::before {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 999px;
  animation: sc-spin 0.8s linear infinite;
}

@keyframes sc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* responsive */
@media (max-width: 980px) {
  .sc-grid {
    grid-template-columns: 48px repeat(7, 1fr);
  }

  .sc-weeklabel {
    min-width: 96px;
  }
}

@media (max-width: 768px) {
  .sc-grid {
    grid-template-columns: 60px repeat(7, minmax(140px, 1fr));
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    max-height: 70vh;
    /* Limit height so scroll is more accessible */
  }

  /* Single day view optimizations for mobile */
  .sc-mobile-day-view .sc-grid {
    grid-template-columns: 60px 1fr;
    overflow-x: visible;
    scroll-snap-type: none;
    max-height: 70vh;
    overflow-y: auto;
  }

  .sc-calendar {
    padding: 12px;
  }

  .sc-event-title {
    font-size: 12px;
  }

  .sc-weeklabel {
    min-width: 80px;
    font-size: 13px;
    padding: 5px 8px;
  }

  .sc-nav {
    width: 28px;
    height: 28px;
  }

  .sc-nav::before {
    font-size: 16px;
  }

  .sc-day {
    scroll-snap-align: start;
  }

  .sc-day-header {
    padding: 8px 6px 6px;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--sc-surface);
  }

  .sc-day-name {
    font-size: 13px;
  }

  .sc-day-date {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .sc-calendar {
    padding: 8px;
  }

  .sc-grid {
    grid-template-columns: 50px repeat(7, minmax(160px, 1fr));
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    max-height: 60vh;
  }

  /* Single day view optimizations for small mobile */
  .sc-mobile-day-view .sc-grid {
    grid-template-columns: 50px 1fr;
    overflow-x: visible;
    scroll-snap-type: none;
    max-height: 80vh;
    /* More space for single day */
    overflow-y: auto;
  }

  .sc-toolbar {
    gap: 6px;
    margin-bottom: 8px;
  }

  .sc-weeklabel {
    min-width: 60px;
    font-size: 12px;
    padding: 4px 6px;
  }

  /* Larger weeklabel for single day view to accommodate day name + date */
  .sc-mobile-day-view .sc-weeklabel {
    min-width: 120px;
    font-size: 13px;
  }

  .sc-nav {
    width: 24px;
    height: 24px;
  }

  .sc-nav::before {
    font-size: 14px;
  }

  .sc-day {
    scroll-snap-align: start;
    min-width: 160px;
  }

  /* Remove min-width for single day view */
  .sc-mobile-day-view .sc-day {
    min-width: auto;
  }

  .sc-day-header {
    padding: 6px 4px 4px;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--sc-surface);
  }

  .sc-day-name {
    font-size: 12px;
  }

  .sc-day-date {
    font-size: 10px;
  }

  .sc-time {
    font-size: 10px;
    left: 4px;
  }

  .sc-event-title {
    font-size: 11px;
  }

  .sc-event-time {
    font-size: 10px;
  }

  .sc-avatar.sc-initial {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  .sc-event-bar {
    padding: 4px 6px;
    gap: 6px;
  }

  .sc-avatar.sc-img {
    width: 24px;
    height: 24px;
    border-width: 2px;
  }
}

@media (max-width: 360px) {
  .sc-calendar {
    padding: 6px;
  }

  .sc-grid {
    grid-template-columns: 45px repeat(7, minmax(180px, 1fr));
    gap: 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    max-height: 50vh;
  }

  /* Single day view optimizations for very small screens */
  .sc-mobile-day-view .sc-grid {
    grid-template-columns: 45px 1fr;
    overflow-x: visible;
    scroll-snap-type: none;
    max-height: 75vh;
    /* More vertical space for single day */
    overflow-y: auto;
  }

  .sc-weeklabel {
    min-width: 50px;
    font-size: 11px;
    padding: 3px 4px;
  }

  /* Accommodate day name + date on very small screens */
  .sc-mobile-day-view .sc-weeklabel {
    min-width: 100px;
    font-size: 11px;
  }

  .sc-nav {
    width: 22px;
    height: 22px;
  }

  .sc-nav::before {
    font-size: 12px;
  }

  .sc-day {
    scroll-snap-align: start;
    min-width: 180px;
  }

  .sc-mobile-day-view .sc-day {
    min-width: auto;
  }

  .sc-day-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--sc-surface);
  }

  .sc-day-name {
    font-size: 11px;
  }

  .sc-day-date {
    font-size: 10px;
  }

  .sc-time {
    font-size: 9px;
    left: 2px;
  }

  .sc-event-title {
    font-size: 10px;
  }

  .sc-event-time {
    font-size: 9px;
  }
}