/* ========================================================
   Window Lights Controller Modal (#lightsModal)
   Frosted glass styling matching system modals (Compact Fit)
   ======================================================== */
.lights-modal-intro {
  font-size: 0.8rem;
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.35;
}

.lights-modal-header-icon {
  font-size: 1.1rem;
  margin-right: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

.lights-header-svg,
.lights-section-svg {
  display: block;
}

.lights-modal .modal-dialog {
  max-width: 500px;
  margin: 0.75rem auto;
}

.lights-modal .modal-header {
  padding: 0.55rem 0.9rem;
}

.lights-modal .modal-body {
  padding: 0.6rem 0.9rem;
  overflow-x: hidden;
}

.lights-modal .modal-footer {
  padding: 0.45rem 0.9rem;
}

/* Status Card with Integrated Bulb & Devices */
.lights-status-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.7rem;
  border-radius: 12px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lights-lamp-preview-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark .lights-lamp-preview-wrap {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lights-lamp-bulb {
  position: relative;
  z-index: 2;
  color: rgb(255, 214, 170);
  transition: color 0.35s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lights-bulb-svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.22));
  stroke: rgba(0, 0, 0, 0.22);
  stroke-width: 0.75px;
  paint-order: stroke fill;
  transition: filter 0.35s ease;
}

body.dark .lights-bulb-svg {
  stroke: rgba(0, 0, 0, 0.45);
}

.lights-lamp-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

@keyframes bulbPulseEffect {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.18); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

.bulb-pulse {
  animation: bulbPulseEffect 0.75s ease-out;
}

.lights-status-main-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-grow: 1;
  min-width: 0;
}

.lights-status-current-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.lights-status-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-color);
  opacity: 0.7;
}

.lights-current-color-val {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lights-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
  background-color: rgb(255, 214, 170);
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.lights-color-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
  letter-spacing: 0.02em;
}

/* ========================================================
   Connected Lights Device Telemetry Pills
   ======================================================== */
.lights-devices-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  width: 100%;
}

.lights-device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--frosted-inner-border);
  transition: border-color 0.2s ease, background-color 0.2s ease;
  user-select: none;
  min-width: 0;
}

body.dark .lights-device-card {
  background: rgba(255, 255, 255, 0.04);
}

.lights-device-card.device-off {
  opacity: 0.6;
}

.lights-device-icon-wrap {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
}

body.dark .lights-device-icon-wrap {
  background: rgba(0, 0, 0, 0.25);
}

.lights-device-bulb-svg {
  width: 13px;
  height: 13px;
}

.lights-device-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-grow: 1;
  min-width: 0;
}

.lights-device-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.lights-device-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  line-height: 1.2;
}

.lights-device-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lights-device-dot.is-on {
  background-color: #2ecc71;
  box-shadow: 0 0 4px rgba(46, 204, 113, 0.8);
}

.lights-device-dot.is-off {
  background-color: #7f8c8d;
}

.lights-device-dot.is-offline {
  background-color: #f59e0b;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.7);
}

.lights-device-state {
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--text-color);
  opacity: 0.75;
  white-space: nowrap;
}

.lights-device-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

/* Preset Buttons Grid (4 columns x 2 rows) */
.lights-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

@media (max-width: 440px) {
  .lights-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.lights-preset-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--frosted-inner-border);
  background: var(--frosted-inner-surface);
  color: var(--text-color);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

.lights-preset-btn:hover {
  background: rgba(var(--accent-color-rgb), 0.1);
  border-color: rgba(var(--accent-color-rgb), 0.35);
  transform: translateY(-1px);
}

.lights-preset-btn:focus-visible,
.lights-custom-btn:focus-visible,
.lights-back-btn:focus-visible,
.color-picker-chip:focus-visible,
.color-picker-sat-val:focus-visible,
.color-picker-hue-track:focus-visible {
  outline: 2px solid rgba(var(--accent-color-rgb), 0.75);
  outline-offset: 2px;
}

.lights-preset-btn.active {
  background: rgba(var(--accent-color-rgb), 0.14);
  border-color: var(--accent-color);
  box-shadow: 0 0 8px 1px rgba(var(--accent-color-rgb), 0.35);
  font-weight: 600;
}

.lights-preset-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.lights-preset-name {
  flex-grow: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.74rem;
}

/* Views Switcher inside #lightsModal */
.lights-view {
  width: 100%;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.lights-view.view-slide-left {
  opacity: 0;
  transform: translateX(-24px);
}

.lights-view.view-slide-right {
  opacity: 0;
  transform: translateX(24px);
}

.lights-back-btn {
  background: none;
  border: none;
  color: var(--text-color);
  padding: 0 0.35rem 0 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  opacity: 0.8;
  outline: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.lights-back-btn:hover {
  opacity: 1;
  transform: translateX(-2px);
}

/* Custom Color Trigger Row */
.lights-custom-picker-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
}

.lights-custom-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-color);
}

.lights-custom-trigger-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.lights-color-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: none;
  margin: 0;
  padding: 0;
}

.lights-custom-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--frosted-border);
  border-radius: 20px;
  padding: 0.2rem 0.55rem 0.2rem 0.35rem;
  cursor: pointer;
  color: var(--text-color);
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  transition: background 0.18s ease, transform 0.15s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.dark .lights-custom-btn {
  background: rgba(255, 255, 255, 0.07);
}

body:not(.dark) .lights-custom-btn {
  background: rgba(0, 0, 0, 0.04);
}

.lights-custom-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--frosted-border);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.lights-custom-btn:active {
  transform: scale(0.97);
}

.lights-custom-btn.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb), 0.3);
}

.lights-custom-swatch {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.lights-custom-hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-color);
  opacity: 0.9;
}

.lights-custom-arrow {
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.lights-custom-btn:hover .lights-custom-arrow {
  opacity: 1;
  transform: translateX(1.5px);
}

/* ========================================================
   Custom Color Picker View Elements (Saturation, Hue, Inputs)
   ======================================================== */
.color-picker-sat-val {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: 10px;
  background-color: #ff0000;
  background-image:
    linear-gradient(to top, #000000, transparent),
    linear-gradient(to right, #ffffff, transparent);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15), 0 3px 10px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.color-picker-pointer {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background-color: #ffd6aa;
  transition: background-color 0.08s ease;
}

.color-picker-hue-track {
  position: relative;
  width: 100%;
  height: 18px;
  border-radius: 9px;
  background: linear-gradient(
    to right,
    #ff0000 0%,
    #ffff00 17%,
    #00ff00 33%,
    #00ffff 50%,
    #0000ff 67%,
    #ff00ff 83%,
    #ff0000 100%
  );
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15), 0 2px 5px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.6rem;
}

.color-picker-hue-thumb {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 5px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background-color: #ffd6aa;
}

.color-picker-preview-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.6rem;
}

.color-picker-live-swatch {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.color-picker-inputs-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.color-picker-hex-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--frosted-border);
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
}

body:not(.dark) .color-picker-hex-input-wrap {
  background: rgba(255, 255, 255, 0.7);
}

.color-picker-hex-prefix {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-color);
  opacity: 0.6;
}

.color-picker-hex-field {
  width: 70px;
  background: none;
  border: none;
  color: var(--text-color);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
}

.color-picker-rgb-label {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.72rem;
  color: var(--text-color);
  opacity: 0.75;
  font-weight: 600;
  white-space: nowrap;
}

.color-picker-quick-palette {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
}

.color-picker-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, border-color 0.15s ease;
  outline: none;
  flex-shrink: 0;
  padding: 0;
}

.color-picker-chip:hover {
  transform: scale(1.15);
  border-color: #ffffff;
}

/* Feedback & Cooldown Animated Wrapper */
.lights-feedback-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  margin-bottom: 0;
  opacity: 0;
  transition:
    grid-template-rows 0.36s cubic-bezier(0.16, 1, 0.3, 1),
    margin-bottom 0.36s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.22s ease;
  pointer-events: none;
}

.lights-feedback-wrapper.is-open {
  grid-template-rows: 1fr;
  margin-bottom: 0.5rem;
  opacity: 1;
  pointer-events: auto;
}

.lights-feedback-inner {
  overflow: hidden;
  min-height: 0;
}

.lights-feedback-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateY(-8px) scale(0.98);
  transition:
    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

.lights-feedback-wrapper.is-open .lights-feedback-banner {
  transform: translateY(0) scale(1);
}

.lights-feedback-icon-box {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.92rem;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lights-feedback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lights-feedback-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.lights-feedback-text {
  display: inline;
  vertical-align: middle;
}

/* Cooldown Number Badge */
.lights-cooldown-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: currentColor;
  margin-left: 0.25rem;
  vertical-align: middle;
}

body.dark .lights-cooldown-badge {
  background: rgba(245, 158, 11, 0.3);
  border-color: rgba(253, 230, 138, 0.45);
  color: #fff;
}

/* Success theme */
.lights-feedback-banner.feedback-success {
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.92) 0%, rgba(167, 243, 208, 0.8) 100%);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #065f46;
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.feedback-success .lights-feedback-icon-box {
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

body.dark .lights-feedback-banner.feedback-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(5, 150, 105, 0.25) 100%);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
  box-shadow: 0 3px 14px rgba(16, 185, 129, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Warning / Cooldown theme */
.lights-feedback-banner.feedback-warning {
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.92) 0%, rgba(253, 230, 138, 0.8) 100%);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #92400e;
  box-shadow: 0 3px 12px rgba(245, 158, 11, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.feedback-warning .lights-feedback-icon-box {
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

body.dark .lights-feedback-banner.feedback-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(217, 119, 6, 0.25) 100%);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Error theme */
.lights-feedback-banner.feedback-error {
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.92) 0%, rgba(254, 202, 202, 0.8) 100%);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #991b1b;
  box-shadow: 0 3px 12px rgba(239, 68, 68, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.feedback-error .lights-feedback-icon-box {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

body.dark .lights-feedback-banner.feedback-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(220, 38, 38, 0.25) 100%);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  box-shadow: 0 3px 14px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

@keyframes hourglass-tilt {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

.feedback-warning .lights-feedback-icon {
  animation: hourglass-tilt 3s ease-in-out infinite;
  transform-origin: center center;
}

@keyframes success-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.feedback-success .lights-feedback-icon {
  animation: success-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.feedback-error .lights-feedback-icon {
  animation: error-shake 0.35s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  .lights-feedback-wrapper,
  .lights-feedback-banner,
  .lights-feedback-icon-box {
    transition: none !important;
  }
  .feedback-warning .lights-feedback-icon,
  .feedback-success .lights-feedback-icon,
  .feedback-error .lights-feedback-icon {
    animation: none !important;
  }
}

.lights-schedule-info {
  font-size: 0.7rem;
  color: var(--text-color);
  opacity: 0.65;
  line-height: 1.3;
  text-align: center;
}

#lightsModal .cv-modal-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  background: rgba(var(--text-color-rgb), 0.08) !important;
  color: var(--text-color) !important;
  border: 1px solid rgba(var(--text-color-rgb), 0.22) !important;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

#lightsModal .cv-modal-cancel-btn:hover {
  background: rgba(var(--text-color-rgb), 0.16) !important;
  color: var(--text-color) !important;
  border-color: rgba(var(--text-color-rgb), 0.4) !important;
  transform: translateY(-1px);
}

#lightsModal .cv-modal-cancel-btn:active {
  transform: scale(0.96);
}

#lightsModal .cv-modal-confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.45rem 1.15rem;
  border-radius: 8px;
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 2px 8px rgba(var(--accent-color-rgb), 0.35);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

#lightsModal .cv-modal-confirm-btn:hover {
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  box-shadow: 0 0 10px 3px rgba(var(--accent-color-rgb), 0.55);
  transform: translateY(-1px);
}

#lightsModal .cv-modal-confirm-btn:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(var(--accent-color-rgb), 0.4);
}

@media (max-width: 600px) {
  #lightsModal .cv-modal-cancel-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
  }

  #lightsModal .cv-modal-confirm-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.95rem;
  }
}

/* ========================================================
   Home Assistant Modal Tab Switcher (Lampor <-> Växter)
   ======================================================== */
.ha-modal-switcher-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0 0.9rem;
  border-bottom: 1px solid var(--frosted-inner-border);
  background: rgba(0, 0, 0, 0.02);
  overflow-x: auto;
  scrollbar-width: none;
}

body.dark .ha-modal-switcher-bar {
  background: rgba(255, 255, 255, 0.025);
}

.ha-modal-switcher-bar::-webkit-scrollbar {
  display: none;
}

.ha-switcher-tab {
  position: relative;
  flex: none;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.56rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-color);
  opacity: 0.68;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.16s ease, color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}

.ha-switcher-tab:hover {
  opacity: 0.95;
}

.ha-switcher-tab:focus-visible {
  outline: 2px solid rgba(var(--accent-color-rgb), 0.75);
  outline-offset: -3px;
  border-radius: 6px;
}

.ha-switcher-tab[aria-selected="true"] {
  opacity: 1;
  color: var(--accent-color);
}

.ha-switcher-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0.25rem 0;
  border-block-end: 2.5px solid var(--accent-color);
  border-radius: 2px 2px 0 0;
}

/* ========================================================
   Plant Status Modal (#plantsModal) & Section Block
   ======================================================== */
.plants-modal .ha-plants-modal-dialog {
  max-width: 780px;
  margin: 0.75rem auto;
}

@media (min-width: 1120px) {
  .plants-modal .ha-plants-modal-dialog:has(.ha-plant-card:nth-child(3)) {
    max-width: 1120px;
  }
  .plants-modal .ha-plants-modal-dialog:has(.ha-plant-card:nth-child(3)) .ha-plants-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.plants-modal .modal-header {
  padding: 0.55rem 0.95rem;
}

.plants-modal .modal-body {
  padding: 0.75rem 0.95rem 0.9rem;
  overflow-x: hidden;
}

.plants-modal .modal-footer {
  padding: 0.45rem 0.95rem;
}

.ha-plants-header-icon {
  color: #10b981;
}

body:not(.dark) .ha-plants-header-icon {
  color: #059669;
}

#plantsModal .cv-modal-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.42rem 1rem;
  border-radius: 8px;
  background: rgba(var(--text-color-rgb), 0.08) !important;
  color: var(--text-color) !important;
  border: 1px solid rgba(var(--text-color-rgb), 0.22) !important;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}

#plantsModal .cv-modal-cancel-btn:hover {
  background: rgba(var(--text-color-rgb), 0.16) !important;
  border-color: rgba(var(--text-color-rgb), 0.4) !important;
}

.ha-plants-topbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.ha-plants-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.ha-plants-section-toolbar {
  margin-bottom: 0.9rem;
}

.ha-plants-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-color);
}

.ha-plants-summary-pill.all-good {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
  color: #065f46;
}

body.dark .ha-plants-summary-pill.all-good {
  color: #6ee7b7;
}

.ha-plants-summary-pill.has-attention {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.38);
  color: #92400e;
}

body.dark .ha-plants-summary-pill.has-attention {
  color: #fde68a;
}

.ha-plants-summary-pill.is-offline {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.42);
  color: #92400e;
}

body.dark .ha-plants-summary-pill.is-offline {
  color: #fde68a;
}

.ha-plants-updated-label {
  font-size: 0.72rem;
  color: var(--text-color);
  opacity: 0.68;
  margin-right: auto;
}

.ha-plants-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
  color: var(--text-color);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.14s ease;
}

.ha-plants-refresh-btn:hover:not(:disabled) {
  background: rgba(var(--accent-color-rgb), 0.12);
  border-color: rgba(var(--accent-color-rgb), 0.4);
}

.ha-plants-refresh-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ha-plants-refresh-btn.is-loading svg {
  animation: haPlantSpin 0.9s linear infinite;
}

@keyframes haPlantSpin {
  to { transform: rotate(360deg); }
}

.ha-plants-status-line {
  display: none;
  font-size: 0.74rem;
  padding: 0.32rem 0.6rem;
  margin-bottom: 0.6rem;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #92400e;
}

body.dark .ha-plants-status-line {
  color: #fde68a;
}

.ha-plants-status-line.is-visible {
  display: block;
}

.ha-plants-status-line.is-offline {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.38);
  color: #92400e;
}

body.dark .ha-plants-status-line.is-offline {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.36);
  color: #fde68a;
}

/* Grid Container */
.ha-plants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

@media (min-width: 960px) {
  .ha-plants-section-grid[data-columns="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .ha-plants-section-grid[data-columns="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .ha-plants-grid {
    grid-template-columns: 1fr;
  }
}

.ha-plants-loading,
.ha-plants-empty,
.ha-plants-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.4rem 1rem;
  font-size: 0.82rem;
  border-radius: 12px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
  color: var(--text-color);
  opacity: 0.82;
}

/* Individual Plant Card */
.ha-plant-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.78rem 0.85rem;
  border-radius: 14px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--frosted-inner-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s ease, transform 0.16s ease;
  min-width: 0;
}

.ha-plant-card.tone-alert {
  border-color: rgba(239, 68, 68, 0.34);
}

.ha-plant-card.tone-warn {
  border-color: rgba(245, 158, 11, 0.34);
}

.ha-plant-hero {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
}

@container (max-width: 265px) {
  .ha-plant-hero {
    flex-direction: column;
    align-items: stretch;
  }
}

.ha-plant-photo,
.ha-plant-photo-placeholder {
  width: 74px;
  height: 74px;
  border-radius: 11px;
  flex-shrink: 0;
  border: 1px solid var(--frosted-inner-border);
}

.ha-plant-photo {
  object-fit: cover;
  display: block;
  background: rgba(15, 23, 42, 0.08);
}

.ha-plant-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #10b981;
  background: rgba(16, 185, 129, 0.09);
  border-color: rgba(16, 185, 129, 0.24);
}

.ha-plant-head-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.ha-plant-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.ha-plant-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.25;
}

.ha-plant-sub {
  font-size: 0.72rem;
  color: var(--text-color);
  opacity: 0.72;
  line-height: 1.3;
}

.ha-plant-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.52rem;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.ha-plant-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ha-plant-status-badge.tone-good {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #065f46;
}

body.dark .ha-plant-status-badge.tone-good {
  color: #6ee7b7;
}

.ha-plant-status-badge.tone-warn {
  background: rgba(245, 158, 11, 0.17);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #92400e;
}

body.dark .ha-plant-status-badge.tone-warn {
  color: #fde68a;
}

.ha-plant-status-badge.tone-alert {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #991b1b;
}

body.dark .ha-plant-status-badge.tone-alert {
  color: #fca5a5;
}

.ha-plant-status-badge.tone-muted {
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-color);
  opacity: 0.8;
}

.ha-plant-problems {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.1rem;
}

.ha-plant-problem-chip {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.08rem 0.42rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #991b1b;
}

body.dark .ha-plant-problem-chip {
  color: #fca5a5;
}

/* 4 Metric Meters Grid */
.ha-plant-meters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

@container (max-width: 280px) {
  .ha-plant-meters-grid {
    grid-template-columns: 1fr;
  }
}

.ha-plant-meter {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.48rem 0.56rem;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--frosted-inner-border);
  min-width: 0;
  overflow: hidden;
}

body.dark .ha-plant-meter {
  background: rgba(255, 255, 255, 0.035);
}

.ha-plant-meter-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.16rem;
  min-width: 0;
}

.ha-plant-meter-label {
  display: block;
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  color: var(--text-color);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ha-plant-meter-valwrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.18rem 0.3rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.ha-plant-meter-value {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--text-color);
  white-space: nowrap;
}

.ha-plant-subtag {
  font-size: 0.59rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.08rem 0.34rem;
  border-radius: 5px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ha-plant-subtag.tone-warn {
  background: rgba(245, 158, 11, 0.16);
  color: #92400e;
}

body.dark .ha-plant-subtag.tone-warn {
  color: #fde68a;
}

.ha-plant-subtag.tone-alert {
  background: rgba(239, 68, 68, 0.16);
  color: #991b1b;
}

body.dark .ha-plant-subtag.tone-alert {
  color: #fca5a5;
}

.ha-plant-subtag.tone-muted {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-color);
  opacity: 0.75;
}

.ha-plant-track {
  position: relative;
  height: 7px;
  margin-top: auto;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
}

.ha-plant-opt-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.22);
  border-inline: 1px solid rgba(16, 185, 129, 0.45);
}

.ha-plant-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  z-index: 1;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ha-plant-fill.tone-good {
  background: #10b981;
}

.ha-plant-fill.tone-warn {
  background: #f59e0b;
}

.ha-plant-fill.tone-alert {
  background: #ef4444;
}

.ha-plant-fill.tone-muted {
  background: rgba(148, 163, 184, 0.65);
}

.ha-plant-meter-goal {
  font-size: 0.63rem;
  color: var(--text-color);
  opacity: 0.62;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Care Advice Footer */
.ha-plant-advice {
  margin: auto 0 0;
  padding: 0.44rem 0.6rem;
  border-radius: 9px;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.73rem;
  line-height: 1.4;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.22);
  color: var(--text-color);
}

.ha-plant-advice.tone-warn {
  background: rgba(245, 158, 11, 0.09);
  border-color: rgba(245, 158, 11, 0.28);
}

.ha-plant-advice.tone-alert {
  background: rgba(239, 68, 68, 0.09);
  border-color: rgba(239, 68, 68, 0.28);
}

.ha-plant-advice.tone-muted {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.24);
}

.ha-plant-advice-icon {
  flex-shrink: 0;
  margin-top: 0.08rem;
  color: #10b981;
}

.ha-plant-advice.tone-warn .ha-plant-advice-icon {
  color: #f59e0b;
}

.ha-plant-advice.tone-alert .ha-plant-advice-icon {
  color: #ef4444;
}

.ha-plant-advice.tone-muted .ha-plant-advice-icon {
  color: var(--text-color);
  opacity: 0.65;
}

.ha-plant-advice-text {
  min-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  .ha-plant-fill,
  .ha-plant-card,
  .ha-plants-refresh-btn.is-loading svg {
    transition: none !important;
    animation: none !important;
  }
}
