/* FlightPlanner design tokens — light / dark */

:root {
  --button-outline: rgba(0, 0, 0, 0.10);
  --badge-outline: rgba(0, 0, 0, 0.05);
  --elevate-1: rgba(0, 0, 0, 0.03);
  --elevate-2: rgba(0, 0, 0, 0.08);
  --background: 210 20% 98%;
  --foreground: 210 20% 12%;
  --border: 210 15% 90%;
  --card: 210 18% 96%;
  --card-foreground: 210 18% 14%;
  --card-border: 210 16% 92%;
  --sidebar: 210 16% 94%;
  --sidebar-foreground: 210 16% 16%;
  --sidebar-border: 210 14% 88%;
  --sidebar-primary: 211 85% 48%;
  --sidebar-primary-foreground: 211 85% 98%;
  --sidebar-accent: 210 14% 86%;
  --sidebar-accent-foreground: 210 14% 20%;
  --sidebar-ring: 211 85% 48%;
  --popover: 210 18% 92%;
  --popover-foreground: 210 18% 18%;
  --popover-border: 210 16% 86%;
  --primary: 211 85% 48%;
  --primary-foreground: 211 85% 98%;
  --secondary: 210 14% 88%;
  --secondary-foreground: 210 14% 22%;
  --muted: 210 12% 90%;
  --muted-foreground: 210 12% 38%;
  --accent: 210 16% 92%;
  --accent-foreground: 210 16% 24%;
  --destructive: 0 84% 52%;
  --destructive-foreground: 0 84% 98%;
  --input: 210 18% 78%;
  --ring: 211 85% 48%;
  --radius: 0.5rem;
  --font-sans: "Open Sans", sans-serif;
}

.dark {
  --button-outline: rgba(255, 255, 255, 0.10);
  --badge-outline: rgba(255, 255, 255, 0.05);
  --elevate-1: rgba(255, 255, 255, 0.04);
  --elevate-2: rgba(255, 255, 255, 0.09);
  --background: 210 18% 8%;
  --foreground: 210 18% 92%;
  --border: 210 14% 18%;
  --card: 210 16% 10%;
  --card-foreground: 210 16% 90%;
  --card-border: 210 14% 14%;
  --sidebar: 210 14% 12%;
  --sidebar-foreground: 210 14% 88%;
  --sidebar-border: 210 12% 16%;
  --sidebar-primary: 211 82% 55%;
  --sidebar-primary-foreground: 211 82% 98%;
  --sidebar-accent: 210 12% 18%;
  --sidebar-accent-foreground: 210 12% 85%;
  --sidebar-ring: 211 82% 55%;
  --popover: 210 16% 14%;
  --popover-foreground: 210 16% 88%;
  --popover-border: 210 14% 20%;
  --primary: 211 82% 52%;
  --primary-foreground: 211 82% 98%;
  --secondary: 210 12% 20%;
  --secondary-foreground: 210 12% 86%;
  --muted: 210 10% 22%;
  --muted-foreground: 210 10% 68%;
  --accent: 210 14% 16%;
  --accent-foreground: 210 14% 84%;
  --destructive: 0 80% 48%;
  --destructive-foreground: 0 80% 98%;
  --input: 210 16% 30%;
  --ring: 211 82% 55%;
}

*,
*::before,
*::after {
  border-color: hsl(var(--border));
}

html {
  font-family: var(--font-sans);
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
}

/* Lucide / inline icons follow text color in both themes */
svg.lucide,
i[data-lucide] svg {
  color: inherit;
  stroke: currentColor;
}

/* Inputs */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  color-scheme: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* Native date/time calendar & clock icons (WebKit/Blink) */
input[type="date"].input::-webkit-calendar-picker-indicator,
input[type="time"].input::-webkit-calendar-picker-indicator,
input[type="datetime-local"].input::-webkit-calendar-picker-indicator,
input[type="month"].input::-webkit-calendar-picker-indicator,
input[type="week"].input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}
input[type="date"].input::-webkit-calendar-picker-indicator:hover,
input[type="time"].input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
/*
 * Keep a dark base glyph, then invert in dark mode.
 * Relying only on color-scheme leaves the icon invisible in some Chromium builds.
 */
html.dark input[type="date"].input,
html.dark input[type="time"].input,
html.dark input[type="datetime-local"].input,
html.dark input[type="month"].input,
html.dark input[type="week"].input {
  color-scheme: light;
}
html.dark input[type="date"].input::-webkit-calendar-picker-indicator,
html.dark input[type="time"].input::-webkit-calendar-picker-indicator,
html.dark input[type="datetime-local"].input::-webkit-calendar-picker-indicator,
html.dark input[type="month"].input::-webkit-calendar-picker-indicator,
html.dark input[type="week"].input::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.25);
  opacity: 0.9;
}

/* Native select chevron stays readable */
.select {
  color-scheme: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
  appearance: none;
  -webkit-appearance: none;
}
html.dark .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%94a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.textarea {
  min-height: 5rem;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  color: hsl(var(--foreground));
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-outline {
  border-color: hsl(var(--border));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
  background-color: hsl(var(--accent));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}

.btn-ghost:hover:not(:disabled) {
  background-color: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: hsl(var(--foreground));
}

.field {
  margin-bottom: 0.75rem;
}

.field-hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* Station autocomplete — full names, not clipped to half-column */
.leg-change-slot {
  --change-accent: hsl(45, 90%, 42%);
  border: 1px dashed var(--change-accent);
  border-radius: 0.5rem;
  background: hsl(var(--muted) / 0.35);
  padding: 0.5rem 0.75rem;
}
.leg-change-slot-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.input-sm {
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
  height: 2rem;
}

.leg-insert-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 60;
  min-width: 8.5rem;
  padding: 0.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 8px 24px hsl(210 20% 10% / 0.18);
}
.journey-choice {
  border-color: hsl(var(--border));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.leg-insert-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}
.leg-insert-menu-item:hover,
.leg-insert-menu-item:focus-visible {
  background: hsl(var(--accent));
  outline: none;
}

.station-suggest {
  position: absolute;
  z-index: 40;
  left: 0;
  top: calc(100% + 0.25rem);
  min-width: 100%;
  width: max-content;
  max-width: min(28rem, calc(100vw - 2rem));
  max-height: 16rem;
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  box-shadow: 0 8px 24px hsl(var(--foreground) / 0.08);
}
.station-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: hsl(var(--foreground));
  background: transparent;
  border: 0;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  cursor: pointer;
}
.station-suggest-item--city .station-suggest-name {
  color: hsl(var(--primary));
}
.station-suggest-item--city {
  background: hsl(var(--primary) / 0.06);
}
.station-suggest-detail {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
}
.station-suggest-item:last-child {
  border-bottom: 0;
}
.station-suggest-item:hover,
.station-suggest-item:focus-visible {
  background: hsl(var(--muted) / 0.55);
  outline: none;
}

/* Card */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--card-border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.03);
}

.card-body {
  padding: 1.25rem;
}

.card-header {
  padding: 1.25rem 1.25rem 0;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.card-desc {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  white-space: nowrap;
}

.badge-outline {
  background: transparent;
}

.badge-primary {
  background-color: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  border-color: transparent;
}

.badge-success {
  background-color: hsl(142 70% 40% / 0.12);
  color: hsl(142 70% 32%);
  border-color: transparent;
}

.badge-warning {
  background-color: hsl(45 90% 45% / 0.15);
  color: hsl(40 80% 30%);
  border-color: transparent;
}

.dark .badge-warning {
  color: hsl(45 90% 70%);
}

.badge-danger {
  background-color: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
  border-color: transparent;
}

/* Tabs */
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius);
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.tab:hover {
  color: hsl(var(--foreground));
  background-color: hsl(var(--accent));
}

.tab-active {
  color: hsl(var(--primary));
  background-color: hsl(var(--primary) / 0.1);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

/* Sidebar */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background-color: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
}

.sidebar-link-active {
  background-color: hsl(var(--sidebar-primary) / 0.12);
  color: hsl(var(--sidebar-primary));
}

.sidebar-link-active:hover {
  background-color: hsl(var(--sidebar-primary) / 0.16);
  color: hsl(var(--sidebar-primary));
}

/* Layout helpers */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 15rem;
  flex-shrink: 0;
  background-color: hsl(var(--sidebar));
  color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
}

.app-content {
  flex: 1;
  padding: 1.5rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Never let a hidden/transitioning backdrop swallow clicks */
.modal-backdrop[style*="display: none"],
.modal-backdrop[aria-hidden="true"] {
  pointer-events: none !important;
}

.modal {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-lg {
  max-width: 42rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
}

.toast {
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: 0.875rem;
  animation: toast-in 0.2s ease;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.toast-destructive {
  border-color: hsl(var(--destructive) / 0.4);
}

.toast-destructive .toast-title {
  color: hsl(var(--destructive));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Alert */
.alert {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  background: hsl(var(--muted) / 0.4);
}

.alert-destructive {
  border-color: hsl(var(--destructive) / 0.35);
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
}

.alert-success {
  border-color: hsl(142 70% 40% / 0.35);
  background: hsl(142 70% 40% / 0.08);
}

/* Misc */
.separator {
  height: 1px;
  background: hsl(var(--border));
  margin: 1rem 0;
}

.checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: hsl(var(--primary));
  cursor: pointer;
}

.switch {
  appearance: none;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 999px;
  background: hsl(var(--input));
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  vertical-align: middle;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  background: white;
  transition: transform 0.15s;
}

.switch:checked {
  background: hsl(var(--primary));
}

.switch:checked::after {
  transform: translateX(1.1rem);
}

.muted {
  color: hsl(var(--muted-foreground));
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid hsl(var(--sidebar-border));
  }
}

[x-cloak] {
  display: none !important;
}

/* Trip day calendar */
.trip-day-card {
  overflow: hidden;
}

.trip-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
}

.trip-day-grid {
  position: relative;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  --ppm: 1px;
}

.trip-day-hours {
  position: relative;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.2);
}

.trip-hour-row {
  position: relative;
  box-sizing: border-box;
}

.trip-hour-label {
  position: absolute;
  top: -0.55em;
  right: 0.4rem;
  font-size: 0.65rem;
  line-height: 1;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}

.trip-day-canvas {
  position: relative;
  min-height: 100%;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent calc(30 * var(--ppm) - 1px),
      hsl(var(--border) / 0.4) calc(30 * var(--ppm) - 1px),
      hsl(var(--border) / 0.4) calc(30 * var(--ppm))
    );
}

.trip-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid hsl(var(--border));
  pointer-events: none;
  z-index: 0;
}

.trip-hour-line-end {
  /* end boundary */
}

.trip-cal-event {
  position: absolute;
  left: 0.45rem;
  right: 0.45rem;
  border-radius: 0.4rem;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  z-index: 1;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.trip-cal-event:hover {
  z-index: 2;
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.trip-cal-event-inner {
  height: 100%;
  padding: 0.3rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
}

.trip-cal-event-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}

.trip-cal-event-title {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.trip-cal-event-time,
.trip-cal-event-dur {
  font-size: 0.65rem;
  opacity: 0.92;
  margin: 0;
  line-height: 1.2;
}

.trip-cal-event--compact .trip-cal-event-inner {
  justify-content: center;
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

.trip-cal-event-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-width: 0;
  width: 100%;
}

.trip-cal-event-inline {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  opacity: 0.98;
}

.trip-cal-event-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.trip-cal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.3rem;
  border: 0;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.trip-cal-btn:hover {
  background: rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
  .trip-day-grid {
    grid-template-columns: 2.75rem 1fr;
  }

  .trip-cal-event {
    left: 0.3rem;
    right: 0.3rem;
  }

  .trip-cal-event-title {
    font-size: 0.7rem;
  }
}

/* App calendar — week view */
.cal-week-card,
.cal-day-card {
  overflow: visible;
}

.cal-week-grid {
  display: grid;
  grid-template-columns: 3.25rem repeat(7, minmax(0, 1fr));
  grid-template-rows: auto auto;
  --ppm: 1px;
  --week-h: auto;
}

.cal-week-corner {
  border-bottom: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.2);
}

.cal-week-dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.25);
  cursor: pointer;
}

.cal-week-dayhead:last-child {
  border-right: none;
}

.cal-week-dayhead:hover {
  background: hsl(var(--muted) / 0.45);
}

.cal-week-dayhead-today {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.cal-week-body {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  grid-column: 1 / -1;
  min-height: var(--week-h);
}

.cal-week-hours {
  position: relative;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.15);
}

.cal-week-hour {
  position: relative;
  box-sizing: border-box;
}

.cal-week-hour span {
  position: absolute;
  top: 0;
  right: 0.3rem;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
  background: hsl(var(--card));
  padding: 0 0.15rem;
  z-index: 1;
}

.cal-week-cols {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: 100%;
}

.cal-week-col {
  position: relative;
  height: 100%;
  border-right: 1px solid hsl(var(--border));
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent calc(30 * var(--ppm) - 1px),
      hsl(var(--border) / 0.35) calc(30 * var(--ppm) - 1px),
      hsl(var(--border) / 0.35) calc(30 * var(--ppm))
    );
}

.cal-week-col:last-child {
  border-right: none;
}

.cal-week-hline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid hsl(var(--border));
  pointer-events: none;
  z-index: 0;
}

.cal-week-event {
  position: absolute;
  left: 0.2rem;
  right: 0.2rem;
  z-index: 1;
  border-radius: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  text-align: left;
  padding: 0.25rem 0.35rem;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cal-week-event:hover {
  filter: brightness(1.08);
  z-index: 2;
}

.cal-week-event-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cal-week-event-time {
  display: block;
  font-size: 0.62rem;
  opacity: 0.9;
  line-height: 1.2;
  margin-top: 0.1rem;
}

.cal-week-event--compact {
  display: flex;
  align-items: center;
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
}

.cal-week-event--compact .cal-week-event-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  .cal-week-grid {
    display: block;
    overflow-x: auto;
  }

  .cal-week-grid > .cal-week-corner,
  .cal-week-grid > .cal-week-dayhead {
    display: none;
  }

  .cal-week-body {
    min-width: 44rem;
    grid-template-columns: 3rem 1fr;
  }
}
