.presence-widget {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(20, 184, 166, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 250, 247, 0.92));
  color: #243b53;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 12px 26px rgba(23, 84, 92, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body.dark-mode .presence-widget {
  border-color: rgba(94, 234, 212, 0.16);
  background:
    linear-gradient(180deg, rgba(16, 35, 44, 0.94), rgba(11, 24, 35, 0.9));
  color: #d9fbf5;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.presence-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.98rem;
  font-weight: 700;
}

.presence-title i {
  color: #0f766e;
}

body.dark-mode .presence-title i {
  color: #5eead4;
}

.presence-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 700;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.presence-widget.is-offline .presence-live {
  color: #7b8794;
}

.presence-widget.is-offline .presence-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
}

.presence-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.presence-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0f766e;
  background: rgba(20, 184, 166, 0.13);
  font-size: 1.15rem;
}

body.dark-mode .presence-icon {
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.12);
}

.presence-copy {
  min-width: 0;
}

.presence-activity {
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-subtitle,
.presence-meta,
.presence-secondary {
  margin-top: 4px;
  color: #607086;
  font-size: 0.82rem;
  line-height: 1.45;
}

body.dark-mode .presence-subtitle,
body.dark-mode .presence-meta,
body.dark-mode .presence-secondary {
  color: #9ab7c6;
}

.presence-secondary {
  display: none;
  padding-top: 10px;
  margin-top: 12px;
  border-top: 1px solid rgba(15, 118, 110, 0.12);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.presence-widget.has-secondary .presence-secondary {
  display: grid;
  gap: 8px;
}

.presence-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-music-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.presence-music-link-primary {
  align-self: center;
  justify-self: end;
}

.presence-music-link:hover,
.presence-music-link:focus-visible {
  background: rgba(15, 118, 110, 0.14);
  border-color: rgba(15, 118, 110, 0.22);
  color: #115e59;
  transform: translateY(-1px);
  outline: none;
}

body.dark-mode .presence-music-link {
  border-color: rgba(94, 234, 212, 0.16);
  background: rgba(94, 234, 212, 0.08);
  color: #99f6e4;
}

body.dark-mode .presence-music-link:hover,
body.dark-mode .presence-music-link:focus-visible {
  background: rgba(94, 234, 212, 0.14);
  border-color: rgba(94, 234, 212, 0.24);
  color: #ccfbf1;
}

.presence-secondary strong {
  color: inherit;
  font-size: 0.84rem;
}

.presence-secondary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.presence-secondary-copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.presence-secondary strong {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-secondary-meta-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.presence-secondary-meta {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-secondary-duration {
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
  color: inherit;
}

.presence-secondary-link {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.1);
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.presence-secondary-link:hover,
.presence-secondary-link:focus-visible {
  background: rgba(15, 118, 110, 0.18);
  color: #115e59;
  transform: translateY(-1px);
  outline: none;
}

body.dark-mode .presence-secondary-link {
  color: #99f6e4;
  background: rgba(94, 234, 212, 0.1);
}

body.dark-mode .presence-secondary-link:hover,
body.dark-mode .presence-secondary-link:focus-visible {
  background: rgba(94, 234, 212, 0.18);
  color: #ccfbf1;
}

.presence-detail-trigger {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.presence-detail-trigger:hover,
.presence-detail-trigger:focus-visible {
  background: rgba(15, 118, 110, 0.2);
  color: #115e59;
  outline: none;
}

body.dark-mode .presence-detail-trigger {
  color: #99f6e4;
  background: rgba(94, 234, 212, 0.12);
}

body.dark-mode .presence-detail-trigger:hover,
body.dark-mode .presence-detail-trigger:focus-visible {
  background: rgba(94, 234, 212, 0.2);
  color: #ccfbf1;
}

.presence-detail-popup {
  position: absolute;
  z-index: 1200;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  background: rgba(255, 255, 255, 0.98);
  color: #243b53;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
  pointer-events: none;
}

.presence-detail-popup[hidden] {
  display: none;
}

body.dark-mode .presence-detail-popup {
  border-color: rgba(94, 234, 212, 0.16);
  background: rgba(11, 24, 35, 0.96);
  color: #d9fbf5;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.32);
}

@media (max-width: 600px) {
  .presence-widget {
    padding: 12px;
    border-radius: 10px;
  }

  .presence-main {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
  }

  .presence-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .presence-secondary-item {
    gap: 10px;
  }
}
