:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --calendar-text: #111827;
  --muted: #66737f;
  --line: #d9dfd7;
  --accent: #087f8c;
  --accent-dark: #05616b;
  --coral: #c75b39;
  --header-bg: rgba(27, 39, 203, 0.72);
  --day-bg: rgba(255, 255, 255, 0.55);
  --outside-day-bg: rgba(255, 255, 255, 0.22);
  --chip-bg: #dff3ef;
  --chip-text: #111827;
  --image-bg: #dfe7e3;
  --preview-bg: rgba(255, 255, 255, 0.96);
  --dialog-backdrop: rgba(21, 30, 37, 0.45);
  --shadow: 0 16px 40px rgba(31, 41, 51, 0.1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000b1f;
  --panel: #07152b;
  --ink: #eef6ff;
  --calendar-text: #eef6ff;
  --muted: #9aabc2;
  --line: rgba(150, 176, 210, 0.24);
  --accent: #35c2d0;
  --accent-dark: #82ecf0;
  --coral: #f07c5c;
  --header-bg: rgba(27, 39, 203, 0.78);
  --day-bg: rgba(10, 29, 56, 0.72);
  --outside-day-bg: rgba(8, 22, 45, 0.42);
  --chip-bg: rgba(53, 194, 208, 0.18);
  --chip-text: #eef6ff;
  --image-bg: #061226;
  --preview-bg: rgba(7, 21, 43, 0.97);
  --dialog-backdrop: rgba(0, 5, 15, 0.72);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 5px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
}

.site-logo img {
  width: auto;
  height: 100%;
  max-height: 40px;
  object-fit: contain;
  display: block;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1rem, 3vw, 2.25rem);
  line-height: 0.95;
}

.controls,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls button,
.controls select,
.toolbar input,
.toolbar select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

.controls button {
  min-width: 42px;
  cursor: pointer;
}

.controls .theme-toggle {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.controls button:hover,
.event-card:hover {
  border-color: var(--accent);
}

#monthLabel {
  min-width: 150px;
  text-align: center;
}

.month-jump {
  position: relative;
  display: flex;
}

.month-label {
  min-width: 150px;
}

.month-jump-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.month-jump-panel[hidden] {
  display: none;
}

.month-jump-panel select {
  min-height: 34px;
  padding: 0 8px;
}

.hero-banner {
  position: relative;
  min-height: clamp(310px, 46vh, 490px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px minmax(300px, 420px);
  align-items: end;
  gap: 28px;
  padding: clamp(22px, 4vw, 46px) clamp(16px, 4vw, 48px);
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(17, 31, 39, 0.76), rgba(17, 31, 39, 0.54) 47%, rgba(17, 31, 39, 0.22)),
    linear-gradient(135deg, #14343a, #245e61 48%, #d5e6df);
  color: white;
}

.hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5, 17, 22, 0.62), rgba(5, 17, 22, 0.38) 44%, rgba(5, 17, 22, 0.16)),
    linear-gradient(0deg, rgba(5, 17, 22, 0.34), rgba(5, 17, 22, 0.08) 56%);
}

.hero-banner::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.34), transparent);
  z-index: -1;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: -3;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.02);
  will-change: opacity;
  transition: opacity 1200ms ease-in-out;
}

.hero-media.active {
  opacity: 1;
  transform: scale(1.02);
}

.hero-media:not(.has-image) {
  background:
    linear-gradient(135deg, rgba(8, 127, 140, 0.9), rgba(199, 91, 57, 0.58)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 18px);
}

.hero-media.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(11, 24, 30, 0);
}

.hero-media.default-image {
  background-color: #050505;
  background-position: center;
  background-size: min(72vw, 520px);
  background-repeat: no-repeat;
}

.hero-media.default-image.active {
  opacity: 1;
}

.hero-content.text-fade {
  animation: heroTextFade 520ms ease both;
}

@keyframes heroTextFade {
  0% {
    opacity: 0.58;
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-content {
  max-width: 820px;
}

.hero-content .eyebrow {
  color: #9be1da;
}

.hero-content h2 {
  max-width: 760px;
  font-size: clamp(1.31rem, 3.6vw, 3rem);
  line-height: 0.98;
}

.hero-date {
  margin: 14px 0 0;
  color: #d9f2ee;
  font-size: 1.05rem;
  font-weight: 800;
}

.hero-description {
  max-width: 680px;
  max-height: 4.8em;
  margin: 14px 0 22px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.55;
}

.hero-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  color: #14343a;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  background: rgba(9, 25, 41, 0.2);
  color: #ffffff;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.hero-action-link[aria-label="Export event"] {
  width: 38px;
  padding: 0;
  font-size: 0;
}

.hero-button:disabled {
  cursor: default;
  opacity: 0.65;
}

.hero-progress {
  display: grid;
  justify-items: center;
  align-self: end;
  align-content: end;
  gap: 12px;
  width: 18px;
  padding: 4px 0;
  margin-top: auto;
}

.hero-progress-track {
  position: relative;
  width: 4px;
  height: 45px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.hero-progress-track span {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0%;
  border-radius: inherit;
  background: #9be1da;
}

.hero-progress-track span.running {
  animation-name: heroProgress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.hero-progress-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  min-height: 120px;
  gap: 7px;
}

.hero-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.hero-progress-dot.active {
  background: #9be1da;
}

@keyframes heroProgress {
  from {
    height: 0%;
  }
  to {
    height: 100%;
  }
}

.hero-upcoming {
  display: grid;
  gap: 0;
  align-self: stretch;
  align-content: end;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.hero-event {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: white;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.hero-event:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hero-event:last-child {
  border-bottom: 0;
}

.hero-event.is-active {
  background: rgba(155, 225, 218, 0.18);
  box-shadow: inset 4px 0 0 #9be1da;
}

.hero-event span {
  color: #9be1da;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-event strong {
  font-size: 0.95rem;
  line-height: 1.25;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 40px;
}

.calendar-panel,
.details-panel {
  min-width: 0;
}

.weekday-grid,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(88px, 1fr));
}

.weekday-grid {
  color: var(--calendar-text);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
}

.weekday-grid span {
  padding: 10px 8px;
}

.calendar-grid {
  border-left: 1px solid var(--line);
}

.day-cell {
  color: var(--calendar-text);
  min-height: 128px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--day-bg);
  padding: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-cell.outside {
  background: var(--outside-day-bg);
  color: #9aa4ac;
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-bottom: 2px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.88rem;
}

.day-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-cell.today .day-number {
  background: var(--coral);
  color: white;
}

.mini-event {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: var(--chip-bg);
  color: var(--chip-text);
  box-shadow: inset 0 0 0 1px rgba(7, 26, 36, 0.06);
  padding: 5px 7px;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.2;
  max-height: 2.1rem;
  overflow: hidden;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-event.mini-event-default {
  border-left-color: #b45309;
}

.mini-event.is-multiday {
  border-left-color: #0d9488;
  background: var(--chip-bg);
}

.mini-event.mini-event-club-meeting {
  border-left-color: #be185d;
}

.mini-event.mini-event-pool-training {
  border-left-color: #1d4ed8;
}

.mini-event.mini-event-shore {
  border-left-color: #db2777;
}

.mini-event.mini-event-course {
  border-left-color: #16a34a;
}

.mini-event.mini-event-boat {
  border-left-color: #0284c7;
}

.mini-event.mini-event-cancelled {
  border-left-color: #dc2626;
}

.mini-event.mini-event-spanning.mini-event-cancelled {
  background: var(--chip-bg);
}

.mini-event.mini-event-ghost {
  visibility: hidden;
  pointer-events: none;
  background: transparent;
  border-left-color: transparent;
}

.mini-event-spanning {
  position: relative;
  z-index: 2;
  width: 100%;
  margin-top: calc(38px + (var(--event-lane, 0) * 34px));
  margin-bottom: 0;
  margin-inline: 8px;
  width: auto;
  border-left-width: 4px;
  border-radius: 4px;
  padding: 5px 7px;
  line-height: 1.2;
  max-height: 2.1rem;
  justify-self: stretch;
  align-self: start;
}

.hover-card {
  position: fixed;
  z-index: 30;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(300px, calc(100vh - 24px));
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--preview-bg);
  box-shadow: var(--shadow);
  padding: 10px;
  transition: opacity 120ms ease, transform 120ms ease;
}

.hover-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.hover-card img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--image-bg);
}

.hover-card img.default-image {
  object-fit: contain;
  background: #050505;
  padding: 8px;
}

.hover-card-date {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hover-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.22;
}

.hover-card-description {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.details-panel {
  position: sticky;
  top: 112px;
  align-self: start;
  max-height: calc(100vh - 136px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar {
  flex-wrap: wrap;
}

.toolbar input {
  flex: 1 1 180px;
}

.sort-toggle {
  display: inline-flex;
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.sort-toggle button {
  min-width: 68px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  cursor: pointer;
}

.sort-toggle button:last-child {
  border-right: 0;
}

.sort-toggle button.active {
  background: var(--accent);
  color: white;
}

.event-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.event-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.event-card.event-card-club-meeting {
  border-left: 4px solid #be185d;
}

.event-card.event-card-default {
  border-left: 4px solid #b45309;
}

.event-card.event-card-pool-training {
  border-left: 4px solid #1d4ed8;
}

.event-card.event-card-shore {
  border-left: 4px solid #db2777;
}

.event-card.event-card-course {
  border-left: 4px solid #16a34a;
}

.event-card.event-card-boat {
  border-left: 4px solid #0891b2;
}

.event-card.event-card-cancelled {
  border-left: 4px solid #dc2626;
}

.event-card img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--image-bg);
}

.event-card img.default-image {
  object-fit: contain;
  background: #050505;
  padding: 7px;
}

.event-card h3 {
  margin: 2px 0 6px;
  font-size: 0.98rem;
  line-height: 1.2;
}

.event-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.status {
  color: var(--muted);
  min-height: 22px;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: var(--dialog-backdrop);
}

dialog img {
  display: none;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
}

dialog img.default-image {
  object-fit: contain;
  background: #050505;
  padding: 24px;
}

dialog .eyebrow,
dialog h2,
dialog p:not(.eyebrow),
dialog .structured-description {
  padding-left: 24px;
  padding-right: 24px;
}

dialog .eyebrow {
  margin-top: 24px;
}

dialog h2 {
  font-size: 1.7rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 24px 0;
}

.dialog-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent-dark);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.dialog-action-link[aria-label="Export event"] {
  width: 38px;
  padding: 0;
  font-size: 0;
}

.calendar-vector-icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  stroke: currentColor;
  fill: none;
  display: block;
}

.dialog-action-link:hover {
  border-color: var(--accent);
}

#dialogDescription {
  line-height: 1.55;
  padding-bottom: 24px;
}

.structured-description {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.description-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.description-section h3 {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.95rem;
  letter-spacing: 0;
}

.description-section dl {
  display: grid;
  grid-template-columns: minmax(130px, 0.42fr) minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0 0 12px;
}

.description-section dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.description-section dd {
  margin: 0;
  min-width: 0;
}

.description-section p {
  margin: 0 0 8px;
}

.icon-button {
  position: sticky;
  top: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 10px 10px -46px auto;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

@media (max-width: 980px) {
  .app-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }

  .site-logo {
    flex: 0 0 auto;
    align-self: center;
  }

  .site-logo img {
    height: 32px;
  }

  .controls {
    flex: 0 1 auto;
    margin-left: auto;
    min-width: 0;
    gap: 4px;
    justify-content: flex-end;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
  }

  .controls button {
    min-width: 34px;
    min-height: 32px;
    padding: 0 8px;
    flex: 0 0 auto;
  }

  .controls .theme-toggle {
    width: 32px;
    min-width: 32px;
    padding: 0;
  }

  .controls::-webkit-scrollbar {
    display: none;
  }

  #monthLabel {
    flex: 0 0 auto;
    min-width: 92px;
    font-size: 0.82rem;
  }

  .month-label {
    min-width: 92px;
  }

  .month-jump-panel {
    left: auto;
    right: 0;
    transform: none;
  }

  .layout {
    display: block;
  }

  .hero-banner {
    grid-template-columns: 1fr 18px;
    min-height: auto;
  }

  .hero-upcoming {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .calendar-panel {
    overflow-x: auto;
    margin-bottom: 24px;
  }

  .weekday-grid,
  .calendar-grid {
    min-width: 720px;
  }

  .details-panel {
    position: static;
    max-height: none;
    height: auto;
  }
}

@media (hover: none) {
  .hover-card {
    display: none;
  }
}
