
.calendar-top-controls-host {
  --sotido-calendar-view-switcher-stack-clearance: 60px;
  position: relative;
  display: grid;
  grid-row: 2;
  grid-column: 1;
  align-self: start;
  z-index: 90;
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  box-sizing: border-box;
  row-gap: 8px;
  pointer-events: none;
}

html[data-app-surface-bundle="calendar-surface"] body:not(.discover-mode):not(.feed-mode) .calendar-top-controls-host,
body.calendar-mode-list:not(.discover-mode):not(.feed-mode) .calendar-top-controls-host,
body.calendar-mode-grid:not(.discover-mode):not(.feed-mode) .calendar-top-controls-host{
  position: relative;
  grid-row: auto;
  left: auto;
  right: auto;
  top: auto;
  margin-top: 0;
  will-change: auto;
}

body:is(.feed-mode, .discover-mode) .calendar-top-controls-host,
html[data-app-surface-bundle="events-surface"] .calendar-top-controls-host,
html[data-app-surface-bundle="discover-surface"] .calendar-top-controls-host{
  position: fixed;
  grid-row: 1;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  margin-top: 0;
  background: transparent;
}

body.is-telegram-webapp:is(.feed-mode, .discover-mode) .calendar-top-controls-host,
html.is-telegram-webapp body:is(.feed-mode, .discover-mode) .calendar-top-controls-host{
  margin-top: 0;
}

body.is-telegram-webapp:is(.feed-mode, .discover-mode) .calendar-top-controls-host > .calendar-view-switcher,
html.is-telegram-webapp body:is(.feed-mode, .discover-mode) .calendar-top-controls-host > .calendar-view-switcher{
  margin-top: 22px;
}

.calendar-audience-switcher-host{
  display: grid;
  justify-items: center;
  min-height: 0;
  padding: 0 10px;
  box-sizing: border-box;
  pointer-events: none;
}

.calendar-audience-switcher-host:empty{
  display: none;
}

.calendar-slots-legend-host{
  display: grid;
  justify-items: center;
  min-height: 0;
  padding: 0 10px;
  box-sizing: border-box;
  pointer-events: none;
}

.calendar-slots-legend-panel{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(100%, 420px);
  padding: 6px 10px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-2) 88%, var(--surface-6));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.calendar-slots-legend-chip{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-3) 82%, transparent);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.calendar-slots-legend-dot{
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.calendar-slots-legend-label{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-view-switcher {
  --switcher-highlight-x: 2px;
  --switcher-highlight-y: 2px;
  --switcher-highlight-width: 0px;
  --switcher-highlight-height: calc(100% - 4px);
  justify-self: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 180ms ease;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(100%, 480px);
  padding: 2px;
  border-radius: 18px;
  background: var(--surface-2);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}

.calendar-view-switcher::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: var(--switcher-highlight-x);
  top: var(--switcher-highlight-y);
  width: var(--switcher-highlight-width);
  height: var(--switcher-highlight-height);
  border-radius: 15px;
  background: var(--surface-6);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  opacity: 1;
  pointer-events: none;
  transition: none;
}

.calendar-view-switcher.is-highlight-ready::before {
  transition:
    left 240ms cubic-bezier(0.2, 0.9, 0.2, 1),
    top 240ms cubic-bezier(0.2, 0.9, 0.2, 1),
    width 240ms cubic-bezier(0.2, 0.9, 0.2, 1),
    height 240ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.calendar-audience-switcher {
  width: min(100%, 480px);
  background: color-mix(in srgb, var(--surface-2) 86%, var(--surface-6));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.34);
}

.calendar-top-controls-host.is-visible > .calendar-view-switcher {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.calendar-audience-switcher-host.is-visible > .calendar-audience-switcher {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.calendar-top-controls-host.is-hidden > .calendar-view-switcher {
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.calendar-audience-switcher-host.is-hidden > .calendar-audience-switcher {
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.calendar-freshness-control {
  justify-self: center;
  position: relative;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-main);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-1px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background-color 160ms ease;
}

.calendar-top-controls-host.is-visible > .calendar-freshness-control {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.calendar-top-controls-host.is-hidden > .calendar-freshness-control {
  opacity: 0;
  pointer-events: none;
}

.calendar-freshness-control:hover,
.calendar-freshness-control:focus-visible {
  background: var(--surface-3);
}

.calendar-freshness-control:focus-visible {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}

.calendar-freshness-control:disabled {
  cursor: default;
  opacity: 0.68;
}

.calendar-freshness-action {
  font-size: 11px;
  line-height: 1;
}

.calendar-freshness-age {
  font-size: 10px;
  line-height: 1;
  color: var(--text-second);
}

.calendar-view-switcher-login-btn {
  justify-self: center;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--accent-blue);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.calendar-top-controls-host.is-visible > .calendar-view-switcher-login-btn {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.calendar-view-switcher-login-btn:hover,
.calendar-view-switcher-login-btn:focus-visible {
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
  transform: translateY(-1px);
}

.calendar-view-switcher-login-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.26);
  outline-offset: 2px;
}

.calendar-view-switcher-btn {
  color: var(--text-main);
  appearance: none;
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;

  border: none;
  padding: 0;
  background: none;
}

.calendar-view-switcher-btn.is-active,
.calendar-view-switcher-btn.is-filter-active {
  background: transparent;
  box-shadow: none;
  border-radius: 15px;
}

.calendar-view-switcher-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .calendar-view-switcher,
  .calendar-view-switcher.is-highlight-ready::before,
  .calendar-view-switcher-btn,
  .calendar-freshness-control {
    transition: none;
  }
}

@media (max-width: 680px) {
  .calendar-freshness-control {
    transform: translateY(-1px);
  }

  .calendar-top-controls-host.is-visible > .calendar-freshness-control {
    transform: translateY(0);
  }
}
