:root {
  --font-main: "Futura PT", "Futura", "Trebuchet MS", "Avenir Next", Arial, sans-serif;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #005987;
  --ink-soft: #005987;
  --brand: #005987;
  --brand-deep: #005987;
  --gold: #ffc000;
  --line: #d7dee7;
  --new-teacher: #63aeca;
  --staff-dev: #ffd44c;
  --holiday: #a3d0a8;
  --early-release: #d9d9d9;
  --first-last: #b18fc2;
  --gp6: #005987;
  --gp9: #ffc000;
  --staar: #fcb142;
  --ab-b-day: #efc4d2;
  --day-slot-h: clamp(1.3rem, 0.18vw + 1.22rem, 1.48rem);
  --marker-depth: clamp(0.24rem, 0.08vw + 0.22rem, 0.38rem);
  --marker-gap: 1px;
  --marker-stroke: 2px;
  --frame-stroke: 2px;
  --calendar-number-size: clamp(0.7rem, 0.08vw + 0.67rem, 0.82rem);
  --weekend-col-fr: 0.67fr;
  --outer-col-slot: 1.35em;
  --visual-boundary-gap: 0.16rem;
  --week-row-gap: 0.16rem;
  --panel-gap: 1rem;
  --month-column-max: clamp(14.6rem, 17.1vw, 17.3rem);
  --month-gap-x: clamp(1.5rem, 1.9vw, 2.75rem);
  --month-gap-y: clamp(1.45rem, 1.7vw, 2.2rem);
  --month-heading-size: 1.2rem;
  --weekday-size: clamp(0.92rem, 0.08vw + 0.9rem, 1rem);
  --info-panel-padding: 1.8rem 1.5rem 0.85rem;
  --info-heading-rule-pad: 0.6rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

.embed-controls {
  display: none;
}

.calendar-shell {
  width: 100%;
}

.calendar-shell.is-scaled {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
}

.calendar-app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0;
  transform-origin: top center;
}

.language-switch {
  position: relative;
  z-index: 8;
  width: min(24rem, calc(100% - 5rem));
  margin: 0 auto;
  padding: 0.26rem 0.34rem 0.34rem;
  background: #ffffff;
  border: 1px solid #d7dfe8;
  border-top: 0;
  border-radius: 0 0 2px 2px;
  box-shadow: 0 2px 0 rgba(8, 32, 56, 0.06);
  transform: none;
  transition: box-shadow 180ms ease, opacity 180ms ease;
  backdrop-filter: none;
}

.language-switch.is-collapsed {
  transform: none;
  opacity: 1;
}

.language-switch:hover,
.language-switch:focus-within {
  transform: none;
  box-shadow: 0 2px 0 rgba(8, 32, 56, 0.06);
  opacity: 1;
}

.language-switch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.language-option {
  width: 100%;
  min-width: 0;
  border: 1px solid #d8dce1;
  background: #ffffff;
  color: var(--brand);
  padding: 0.3rem 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
  border-radius: 0;
}

.language-option.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

#languageOptionEn {
  border-bottom-left-radius: 1px;
}

#languageOptionEs {
  border-bottom-right-radius: 1px;
}

.app-header {
  margin-top: 0;
  background: var(--brand);
  color: white;
  padding: 1.3rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 2.1rem;
  min-width: 0;
}

.district-logo {
  width: clamp(11rem, 24vw, 15rem);
  height: auto;
  display: block;
}

.icon-logo {
  width: 5.2rem;
  height: auto;
  display: none;
}

.brand-text {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-header h1 {
  margin: 0;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  word-spacing: -0.4rem;
  line-height: 1.1em;
  font-size: clamp(1.25rem, 2.1vw, 1.95rem);
  white-space: nowrap;
}

.school-year {
  margin: 0;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 4rem);
  color: var(--gold);
  text-shadow: none;
  line-height: 1;
  flex: 0 0 auto;
}

.event-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.55rem;
  align-items: stretch;
  padding: 0.85rem 0 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  min-height: 2.1rem;
  padding: 0.42rem 0.78rem;
  border: 1px solid #d4dce5;
  border-radius: 2px;
  background: #ffffff;
  color: #0d2235;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 0 rgba(12, 33, 51, 0.03);
  overflow: hidden;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.filter-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(8, 32, 56, 0.08);
}

.filter-chip.is-off {
  background: #eef2f6;
  color: #5c6a77;
  border-color: #d8dee6;
  box-shadow: none;
  opacity: 0.82;
}

.filter-chip-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 0.95rem;
  border-radius: 2px;
  overflow: hidden;
  flex: 0 0 auto;
}

.filter-chip-swatch-er {
  font-size: 0.7rem;
  font-weight: 500;
  color: #000000;
}

.filter-chip-swatch-frame {
  border: var(--frame-stroke) solid var(--first-last);
}

.filter-chip-swatch-staar {
  background: transparent;
  border: 2px solid var(--staar);
}

.filter-chip-label {
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chip-swatch-marker {
  background: transparent;
  position: relative;
}

.filter-chip-swatch-ab {
  width: auto;
  min-width: 3.55rem;
  background: transparent;
}

.filter-chip-ab-shell {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.12rem 0.14rem;
  background: #f5f7fa;
  border: 1px solid #e1e7ee;
  border-radius: 3px;
}

.filter-chip-ab-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.36rem;
  height: 1.02rem;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
}

.filter-chip-ab-a {
  background: #ffffff;
  color: #0d2235;
  box-shadow: 0 1px 3px rgba(8, 32, 56, 0.08);
}

.filter-chip-ab-b {
  background: var(--ab-b-day);
  color: #0d2235;
}

.filter-chip-ab-divider {
  width: 1px;
  height: 1.02rem;
  margin: 0 0.18rem;
  background: #d4dce5;
}

.filter-chip-marker-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--marker-depth);
}

.filter-chip-swatch-marker.event-gp6 {
  --marker-color: var(--gp6);
}

.filter-chip-swatch-marker.event-gp9 {
  --marker-color: var(--gp9);
}

.filter-chip-marker-start {
  left: 0;
  border-left: var(--marker-stroke) solid var(--marker-color);
  border-top: var(--marker-stroke) solid var(--marker-color);
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.filter-chip-marker-end {
  right: 0;
  border-right: var(--marker-stroke) solid var(--marker-color);
  border-top: var(--marker-stroke) solid var(--marker-color);
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.app-layout {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: var(--panel-gap);
  margin-top: var(--panel-gap);
  align-items: start;
}

.calendar-grid {
  background: var(--panel);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, var(--month-column-max)));
  justify-content: space-between;
  gap: var(--month-gap-y) var(--month-gap-x);
  padding: 1.5rem;
  align-content: start;
}

.month-card {
  padding: 0;
  background: transparent;
}

.month-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--gold);
  width: 100%;
  margin: 0 0 0.6rem;
}

.month-card h3,
.month-card p {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  font-family: var(--font-main);
}

.month-card h3 {
  font-size: var(--month-heading-size);
  line-height: 1;
}

.month-card p {
  color: var(--gold);
  font-size: var(--month-heading-size);
}

.weekday-row,
.days-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: var(--weekend-col-fr) repeat(5, 1fr) var(--weekend-col-fr);
  column-gap: 0;
  width: 100%;
}

.weekday-row {
  margin-bottom: 0.25rem;
  row-gap: 0;
}

.days-grid {
  row-gap: var(--week-row-gap);
  position: relative;
}

.weekday-row li {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  color: var(--brand);
  font-size: var(--weekday-size);
}

.weekday-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.weekday-row li:first-child {
  justify-content: flex-start;
}

.weekday-row li:last-child {
  justify-content: flex-end;
}

.weekday-row li:first-child .weekday-label,
.weekday-row li:last-child .weekday-label {
  width: var(--outer-col-slot);
}

.day-cell {
  width: 100%;
  height: var(--day-slot-h);
  border: 0;
  border-radius: 0;
  text-align: center;
  font-size: var(--calendar-number-size);
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  justify-self: stretch;
  overflow: hidden;
}

.day-cell.split-right {
  border-right: var(--visual-boundary-gap) solid var(--bg);
}

.day-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.days-grid .day-cell:nth-child(7n + 1) {
  justify-content: flex-start;
}

.days-grid .day-cell:nth-child(7n) {
  justify-content: flex-end;
}

.days-grid .day-cell:nth-child(7n + 1) .day-glyph,
.days-grid .day-cell:nth-child(7n) .day-glyph {
  width: var(--outer-col-slot);
}

.day-number {
  line-height: 1;
  font-weight: 500;
  position: relative;
  z-index: 2;
}

.day-weekend .day-number {
  color: #6d6d6d;
  font-weight: 400;
}

.day-cell.spacer {
  background: transparent;
}

.day-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid #b8c1ca;
  opacity: 0.9;
}

.event-new-teacher {
  background: var(--new-teacher);
}

.event-teacher-pl {
  background: var(--staff-dev);
}

.event-holiday {
  background: var(--holiday);
}

.event-first-last {
  background: transparent;
}

.event-early-release {
  background: var(--early-release);
}

.event-gp6 {
  color: var(--gp6);
}

.event-gp9 {
  color: var(--gp9);
}

.event-staar {
  background: transparent;
}

.day-cell-er .day-number {
  font-weight: inherit;
  font-size: inherit;
  letter-spacing: 0;
}

.day-bracket {
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

.day-bracket-gp6 {
  --marker-color: var(--gp6);
}

.day-bracket-gp9 {
  --marker-color: var(--gp9);
}

.staar-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

.staar-perimeter {
  fill: none;
  stroke: var(--staar);
  stroke-width: 2.4px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.day-bracket-start {
  left: 0;
  width: var(--marker-depth);
  border-left: var(--marker-stroke) solid var(--marker-color);
}

.day-bracket-end {
  right: 0;
  width: var(--marker-depth);
  border-right: var(--marker-stroke) solid var(--marker-color);
}

.day-bracket-full {
  top: 0;
  bottom: 0;
}

.day-bracket-upper {
  top: 0;
  height: calc((var(--day-slot-h) - var(--marker-gap)) / 2);
}

.day-bracket-lower {
  bottom: 0;
  height: calc((var(--day-slot-h) - var(--marker-gap)) / 2);
}

.day-bracket-start.day-bracket-full,
.day-bracket-start.day-bracket-upper {
  border-top: var(--marker-stroke) solid var(--marker-color);
}

.day-bracket-start.day-bracket-full,
.day-bracket-start.day-bracket-lower {
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.day-bracket-end.day-bracket-full,
.day-bracket-end.day-bracket-upper {
  border-top: var(--marker-stroke) solid var(--marker-color);
}

.day-bracket-end.day-bracket-full,
.day-bracket-end.day-bracket-lower {
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.day-frame-first-last {
  position: absolute;
  inset: 0;
  border: var(--frame-stroke) solid var(--first-last);
  pointer-events: none;
  z-index: 4;
}

.day-cell.has-marker-start .day-frame-first-last {
  left: calc(var(--marker-depth) + var(--marker-gap));
}

.day-cell.has-marker-end .day-frame-first-last {
  right: calc(var(--marker-depth) + var(--marker-gap));
}

.day-cell.has-marker-start .day-frame-first-last {
  border-left: 0;
}

.day-cell.has-marker-end .day-frame-first-last {
  border-right: 0;
}

.info-panel {
  background: var(--panel);
  padding: var(--info-panel-padding);
  display: grid;
  gap: 1rem;
  align-content: stretch;
  min-height: 0;
  align-self: start;
  position: sticky;
  top: var(--panel-gap);
  height: auto;
  max-height: none;
  overflow: hidden;
}

body.hide-header .app-header {
  display: none;
}

body.hide-info-panel .info-panel {
  display: none;
}

body.hide-info-panel .app-layout {
  grid-template-columns: 1fr;
}

.info-panel h2 {
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  color: var(--brand);
  border-bottom: 2px solid var(--gold);
  padding-bottom: var(--info-heading-rule-pad);
  font-size: 1.2rem;
  line-height: 1;
  font-family: var(--font-main);
}

.info-panel > section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.info-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

#importantDates li {
  display: grid;
  gap: 0.25rem;
  align-items: start;
  margin-bottom: 0;
  position: relative;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 0;
  transition: background-color 160ms ease;
}

#importantDates span {
  color: #000000;
  font-weight: 500;
  letter-spacing: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: normal;
  word-break: keep-all;
}

#importantDates strong {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 500;
  order: 1;
}

#importantDates span {
  order: 2;
}

#importantDates {
  max-height: none;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding-right: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

#importantDates::-webkit-scrollbar {
  width: 10px;
}

#importantDates::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 999px #00598720;
}

#importantDates::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #ffd65a, var(--gold));
  border-radius: 999px;
  border: 2px solid #00598720;
}

#importantDates .important-date-item:hover,
#importantDates .important-date-item.is-related-highlight {
  background: #fff8de;
}

#importantDates .important-date-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0;
  background: var(--item-accent, #ffc000);
  opacity: 1;
  z-index: 2;
  pointer-events: none;
}

.day-cell.is-related-highlight {
  z-index: 6;
  transform: translateY(-1px);
  transition: transform 140ms ease;
}

.calendar-tooltip {
  --tooltip-accent: #ffc000;
  --tooltip-arrow-x: 50%;
  position: absolute;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 130ms ease, transform 130ms ease;
  background: #ffffff;
  color: #0d2235;
  border: 0;
  border-left: 3px solid var(--tooltip-accent);
  border-radius: 0;
  padding: 0.45rem 0.6rem;
  box-shadow: 0 6px 18px rgba(8, 32, 56, 0.22);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
  max-width: 260px;
}

.calendar-tooltip::after {
  content: "";
  position: absolute;
  left: var(--tooltip-arrow-x);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}

.calendar-tooltip[data-placement="top"]::after {
  bottom: -8px;
  border-top: 8px solid #ffffff;
}

.calendar-tooltip[data-placement="bottom"]::after {
  top: -8px;
  border-bottom: 8px solid #ffffff;
}

.calendar-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.calendar-tooltip div + div {
  margin-top: 0.15rem;
}

.calendar-tooltip .tooltip-date {
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
}

.legend {
  margin-top: var(--panel-gap);
  background: var(--panel);
  padding: 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 0.5rem 0.8rem;
}

@media screen {
  .legend {
    display: none;
  }
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #000000;
  font-weight: 500;
}

.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.15rem;
  border-radius: 0;
}

.legend-swatch-er {
  font-size: var(--calendar-number-size);
  font-weight: 500;
  color: #000000;
}

.legend-swatch.event-first-last {
  background: transparent;
  border: var(--frame-stroke) solid var(--first-last);
}

.legend-marker-cell {
  width: 1.85rem;
  height: 1.15rem;
  position: relative;
  display: inline-block;
  overflow: hidden;
}

.legend-marker-event-gp6 {
  --marker-color: var(--gp6);
}

.legend-marker-event-gp9 {
  --marker-color: var(--gp9);
}

.legend-marker-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--marker-depth);
}

.legend-marker-start {
  left: 0;
  border-left: var(--marker-stroke) solid var(--marker-color);
  border-top: var(--marker-stroke) solid var(--marker-color);
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.legend-marker-end {
  right: 0;
  border-right: var(--marker-stroke) solid var(--marker-color);
  border-top: var(--marker-stroke) solid var(--marker-color);
  border-bottom: var(--marker-stroke) solid var(--marker-color);
}

.legend-fab,
.legend-backdrop {
  display: none;
}

.legend-fab-icon {
  width: 1rem;
  height: 0.85rem;
  position: relative;
  display: inline-block;
}

.legend-fab-icon::before,
.legend-fab-icon::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.legend-fab-icon::before {
  top: 0.1rem;
  box-shadow: 0 0.28rem 0 currentColor, 0 0.56rem 0 currentColor;
}

.legend-fab-label {
  line-height: 1;
}

body.is-embedded .embed-controls {
  display: flex;
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 24;
}

.embed-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid #ccd6df;
  border-radius: 2px;
  background: #ffffff;
  color: #0d2235;
  font: inherit;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(8, 32, 56, 0.12);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.embed-expand-icon {
  position: relative;
  width: 1rem;
  height: 1rem;
  display: block;
}

.embed-expand-icon::before,
.embed-expand-icon::after {
  content: "";
  position: absolute;
  width: 0.5rem;
  height: 0.5rem;
  border-color: currentColor;
  border-style: solid;
}

.embed-expand-icon::before {
  top: 0;
  right: 0;
  border-width: 2px 2px 0 0;
}

.embed-expand-icon::after {
  left: 0;
  bottom: 0;
  border-width: 0 0 2px 2px;
}

.embed-controls {
  display: none;
}

body.is-embedded .calendar-app {
  max-width: none;
}

body.is-embedded .event-filters {
  padding-top: 0.7rem;
}

body.embedded-wide .app-header {
  display: flex !important;
  padding: 1.3rem 3rem !important;
  gap: 1.25rem !important;
  align-items: center !important;
}

body.embedded-wide .brand-block {
  display: flex !important;
  gap: 2.1rem !important;
  align-items: center !important;
}

body.embedded-wide .district-logo {
  display: block !important;
  width: clamp(11rem, 24vw, 15rem) !important;
}

body.embedded-wide .icon-logo {
  display: none !important;
}

body.embedded-wide .brand-text {
  display: flex !important;
  align-items: center !important;
  width: auto !important;
}

body.embedded-wide .app-header h1 {
  font-size: clamp(1.25rem, 2.1vw, 1.95rem) !important;
  text-align: left !important;
}

body.embedded-wide .school-year {
  font-size: clamp(2rem, 5vw, 4rem) !important;
  line-height: 1 !important;
}

body.embedded-wide .event-filters {
  position: static !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)) !important;
  gap: 0.55rem !important;
  width: auto !important;
  max-height: none !important;
  padding: 0.85rem 0 0 !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

body.embedded-wide .app-layout {
  display: grid !important;
  grid-template-columns: 1fr 330px !important;
  gap: var(--panel-gap) !important;
}

body.embedded-wide .calendar-grid {
  grid-template-columns: repeat(4, minmax(0, var(--month-column-max))) !important;
  justify-content: space-between !important;
  gap: var(--month-gap-y) var(--month-gap-x) !important;
  padding: 1.5rem !important;
  align-content: start !important;
}

body.embedded-wide .info-panel {
  display: grid !important;
  padding: var(--info-panel-padding) !important;
}

body.embedded-wide.hide-info-panel .info-panel {
  display: none !important;
}

body.embedded-wide.hide-info-panel .app-layout {
  grid-template-columns: 1fr !important;
}

@media (max-width: 1220px) and (min-aspect-ratio: 4 / 3) {
  :root {
    --day-slot-h: 1.52rem;
    --calendar-number-size: 0.92rem;
    --marker-depth: 0.34rem;
    --marker-stroke: 2px;
    --frame-stroke: 2px;
    --outer-col-slot: 1.28em;
    --week-row-gap: 0.18rem;
    --month-column-max: 14.2rem;
  }

  .app-header {
    padding: 1.15rem 2rem;
  }

  .brand-block {
    gap: 1.35rem;
  }

  .district-logo {
    width: clamp(9.5rem, 22vw, 13rem);
  }

  .app-header h1 {
    font-size: clamp(1rem, 1.9vw, 1.65rem);
  }

  .school-year {
    font-size: clamp(1.9rem, 4vw, 3.35rem);
  }

  .event-filters {
    padding: 0.75rem 0 0;
  }

  .app-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, var(--month-column-max)));
    justify-content: space-between;
    gap: 1.4rem 1rem;
    padding: 1rem;
  }

  .month-card h3,
  .month-card p,
  .info-panel h2 {
    font-size: 1.05rem;
  }

  .legend {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }
}

@media (max-width: 920px) and (min-aspect-ratio: 4 / 3) {
  :root {
    --day-slot-h: 1.6rem;
    --calendar-number-size: 0.95rem;
    --marker-depth: 0.36rem;
    --outer-col-slot: 1.3em;
    --month-column-max: 12.8rem;
  }

  .app-header {
    padding: 1rem 1.25rem;
    gap: 0.9rem;
  }

  .brand-block {
    gap: 1rem;
  }

  .district-logo {
    display: block;
    width: clamp(8rem, 21vw, 10.5rem);
  }

  .icon-logo {
    display: none;
  }

  .brand-text {
    display: flex;
    align-items: center;
    width: auto;
  }

  .app-header h1 {
    font-size: clamp(0.92rem, 1.95vw, 1.35rem);
    text-align: left;
  }

  .school-year {
    font-size: clamp(1.6rem, 3.9vw, 2.5rem);
    justify-self: auto;
  }

  .event-filters {
    gap: 0.45rem;
    padding: 0.65rem 0 0;
  }

  .filter-chip {
    min-height: 1.95rem;
    padding: 0.38rem 0.72rem;
    font-size: 0.8rem;
  }

  .app-layout {
    grid-template-columns: minmax(0, 1fr) 235px;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, var(--month-column-max)));
    justify-content: space-between;
    gap: 1.1rem 0.8rem;
    padding: 0.85rem;
  }

  .info-panel {
    padding: 1rem 1rem 0.65rem;
  }
}

@media (max-width: 1220px) and (max-aspect-ratio: 4 / 3) {
  :root {
    --day-slot-h: 1.76rem;
    --calendar-number-size: 1.02rem;
    --marker-depth: 0.42rem;
    --marker-stroke: 2.3px;
    --frame-stroke: 2.3px;
    --outer-col-slot: 1.5em;
    --week-row-gap: 0.22rem;
  }

  .calendar-app {
    display: flex;
    flex-direction: column;
  }

  .calendar-grid {
    order: 1;
  }

  .legend {
    order: 2;
    margin-top: 0;
  }

  .info-panel {
    order: 3;
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .app-layout {
    display: contents;
  }

  .calendar-grid {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }
}

@media (max-width: 920px) and (max-aspect-ratio: 4 / 3) {
  :root {
    --day-slot-h: 1.95rem;
    --calendar-number-size: 1.1rem;
    --marker-depth: 0.48rem;
    --marker-stroke: 2.5px;
    --frame-stroke: 2.5px;
    --outer-col-slot: 1.58em;
    --week-row-gap: 0.26rem;
  }

  .app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    padding: 1rem 1.2rem 1.15rem;
    gap: 0.9rem 0.9rem;
  }

  .brand-block {
    display: contents;
    width: auto;
    align-items: center;
  }

  .district-logo {
    display: none;
  }

  .icon-logo {
    display: block;
    width: clamp(3.4rem, 14vw, 5.5rem);
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .brand-text {
    display: block;
    width: 100%;
    min-width: 0;
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }

  .app-header h1 {
    font-size: clamp(1.05rem, 5.8vw, 2.2rem);
    max-width: 100%;
    text-align: left;
  }

  .school-year {
    font-size: clamp(1.05rem, 5.8vw, 2.2rem);
    line-height: 1;
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 620px) and (max-aspect-ratio: 4 / 3) {
  :root {
    --day-slot-h: 2.2rem;
    --calendar-number-size: 1.18rem;
    --marker-depth: 0.56rem;
    --marker-stroke: 2.9px;
    --frame-stroke: 2.9px;
    --outer-col-slot: 1.72em;
    --week-row-gap: 0.28rem;
  }

  .calendar-app {
    padding-inline: 0;
  }

  .language-switch {
    width: min(100%, calc(100% - 2.2rem));
    margin: 0 auto 1rem;
    padding: 8px;
  }

  .language-switch.is-collapsed,
  .language-switch:hover,
  .language-switch:focus-within {
    transform: none;
    box-shadow: 0 2px 0 rgba(8, 32, 56, 0.06);
  }

  .language-switch-controls {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .language-option {
    padding: 0.5rem 0;
    font-size: clamp(0.82rem, 2.5vw, 0.96rem);
    white-space: nowrap;
  }

  .event-filters {
    position: fixed;
    right: 0.65rem;
    bottom: calc(4.55rem + env(safe-area-inset-bottom));
    z-index: 36;
    width: min(92vw, 22rem);
    max-height: min(60vh, 28rem);
    overflow: auto;
    padding: 0.7rem;
    background: var(--panel);
    border: 1px solid #d5dce6;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    transform-origin: bottom right;
    transform: translateY(10px) scale(0.92);
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
    padding: 0.6rem;
  }

  .month-card {
    padding: 0.65rem;
  }

  .info-panel {
    order: 2;
    background: var(--panel);
    padding: 0.75rem 0.6rem;
    gap: 0.6rem;
    margin: 0.35rem 0 0;
    box-shadow: none;
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .info-panel h2 {
    margin-bottom: 0.45rem;
  }

  #importantDates {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .filter-chip {
    width: 100%;
    justify-content: flex-start;
    min-height: 2.1rem;
    font-size: 0.9rem;
  }

  .legend-fab {
    position: fixed;
    right: 0.65rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
    z-index: 38;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.1rem;
    height: 3.1rem;
    gap: 0.45rem;
    padding: 0 0.78rem;
    border: 0;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  }

  .legend-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(0, 0, 0, 0.16);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.filter-drawer-open .event-filters {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }

  body.filter-drawer-open .legend-fab {
    background: #0a4a79;
  }

  body.filter-drawer-open .legend-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 820px) {
  .event-filters {
    grid-template-columns: repeat(auto-fit, minmax(12.75rem, 1fr));
  }
}

@media print {
  .embed-controls,
  .event-filters,
  .legend-fab,
  .legend-backdrop {
    display: none !important;
  }

  .legend {
    display: grid !important;
  }
}
