:root {
  --main-card-bg: linear-gradient(180deg, rgba(34, 34, 38, 0.85), rgba(24, 24, 28, 0.8));
  --main-card-border: rgba(255, 255, 255, 0.25);
  --main-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --main-text: #ffffff;
  --main-text-soft: rgba(255, 255, 255, 0.72);
  --main-title-soft: rgba(255, 255, 255, 0.84);
  --main-gap: 12px;
  --main-horizontal-inset: 8px;
  --main-widget-top: 108px;
  --main-widget-min-height: 74px;
  --main-widget-gap-to-cards: 10px;
}

.main-dashboard-page {
  min-height: 100vh;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: calc(
      var(--main-widget-top) + var(--main-widget-min-height) + var(--main-widget-gap-to-cards)
    )
    0 0;
  box-sizing: border-box;
}

.container.main-dashboard-page {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.main-dashboard-panel {
  width: 100%;
  max-width: none;
}

.main-dashboard-layout {
  width: calc(100vw - (var(--main-horizontal-inset) * 2));
  max-width: none;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--main-gap);
}

.main-dashboard-layout > * {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.main-panel-card,
.main-last-room-card,
.spa-weather-chip {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--main-card-border);
  background: var(--main-card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--main-card-shadow);
  overflow: hidden;
}

.main-panel-card {
  padding: 12px 14px;
}

.main-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.main-panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--main-title-soft);
  font-weight: 700;
}

.main-panel-state {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--main-text-soft);
  line-height: 1.2;
}

.main-now-playing-content {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: center;
}

.main-now-playing-art-wrap {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(240, 235, 225, 0.96);
  display: grid;
  place-items: center;
}

.main-now-playing-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main-now-playing-track,
.main-now-playing-artist,
.main-now-playing-album {
  margin: 0;
}

.main-now-playing-track {
  color: var(--main-text);
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.12;
  font-weight: 500;
}

.main-now-playing-artist {
  color: var(--main-text-soft);
  font-size: clamp(14px, 1.6vw, 19px);
  line-height: 1.2;
}

.main-now-playing-album {
  color: rgba(255, 255, 255, 0.6);
  font-size: clamp(13px, 1.2vw, 16px);
  line-height: 1.25;
}

.main-now-playing-controls {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.main-now-playing-controls[hidden] {
  display: none;
}

.main-now-playing-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.main-now-playing-btn img {
  width: 22px;
  height: 22px;
  filter: brightness(0) saturate(100%) invert(100%);
}

.main-last-room-card {
  min-height: 126px;
}

.main-last-room-photo {
  position: absolute;
  inset: 0;
}

.main-last-room-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.5) saturate(0.95);
}

.main-last-room-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.44));
}

.main-last-room-content {
  position: relative;
  z-index: 1;
  padding: 14px;
}

.main-last-room-eyebrow {
  display: block;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.76);
  margin-bottom: 4px;
}

.main-last-room-name {
  margin: 0;
  color: var(--main-text);
  font-size: clamp(20px, 2.1vw, 28px);
  font-weight: 500;
}

.main-last-room-link {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.main-active-devices-card {
  height: auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}

.main-active-devices-off-btn {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--main-text-soft);
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.main-active-devices-off-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
}

.main-active-devices-off-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.main-active-devices-list {
  overflow: auto;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
}

.main-active-empty {
  color: rgba(255, 255, 255, 0.74);
  margin: 10px 0 0;
  font-size: 16px;
}

.main-active-env-group {
  position: relative;
}

.main-active-env-group + .main-active-env-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.main-active-env-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.main-active-env-title {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.78);
}

.main-active-env-count {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.09);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.main-active-env-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block;
}

.main-active-device-item + .main-active-device-item {
  margin-top: 8px;
  transition: margin-top 320ms ease;
}

.main-active-device-item {
  --main-active-item-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  max-height: var(--main-active-item-height);
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.02)
  );
  opacity: 1;
  transform: translateX(0);
  transition:
    transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 220ms ease,
    max-height 320ms ease,
    padding 320ms ease,
    margin-top 320ms ease,
    border-color 220ms ease,
    background 220ms ease;
}

.main-active-device-item.is-removing {
  pointer-events: none;
  opacity: 0;
  transform: translateX(28px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: rgba(255, 255, 255, 0);
  background: rgba(255, 255, 255, 0);
}

.main-active-device-item.is-removing + .main-active-device-item {
  margin-top: 0;
}

.main-active-device-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.main-active-device-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(100%);
  opacity: 0.94;
}

.main-active-device-name {
  color: var(--main-text);
  font-size: clamp(14px, 1.35vw, 17px);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.main-active-device-off-btn {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.main-active-device-off-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.34);
}

.main-active-device-off-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.spa-home-widget {
  position: fixed;
  top: var(--main-widget-top);
  left: var(--main-horizontal-inset);
  right: var(--main-horizontal-inset);
  transform: none;
  width: auto;
  max-width: none;
  box-sizing: border-box;
  z-index: 15;
}

.spa-weather-chip {
  min-height: var(--main-widget-min-height);
  height: var(--main-widget-min-height);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spa-weather-chip[data-state="loading"],
.spa-weather-chip[data-state="error"] {
  opacity: 0.88;
}

.spa-weather-greeting {
  color: var(--main-text);
  flex: 1;
  min-width: 0;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.15;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.spa-weather-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 108px;
}

.spa-weather-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(100%);
}

.spa-weather-separator {
  color: rgba(255, 255, 255, 0.62);
  font-size: 18px;
}

.spa-weather-value {
  color: var(--main-text);
  font-size: clamp(16px, 1.9vw, 22px);
  font-weight: 500;
}

@media (max-width: 768px) {
  :root {
    --main-horizontal-inset: 8px;
    --main-widget-top: 104px;
    --main-widget-min-height: 74px;
    --main-widget-gap-to-cards: 10px;
  }

  .main-dashboard-page {
    padding-top: calc(
      var(--main-widget-top) + var(--main-widget-min-height) + var(--main-widget-gap-to-cards)
    );
  }

  .main-now-playing-track {
    font-size: clamp(16px, 7vw, 20px);
  }

  .main-active-device-item {
    padding: 9px 10px;
  }

  .main-active-device-name {
    font-size: 14px;
  }

  .main-active-device-off-btn {
    font-size: 12px;
    padding: 5px 9px;
  }
}
