sg-detail-panel {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 380px;
  min-width: 280px;
  max-width: 600px;
  height: 100%;
  position: relative;
}

.sg-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
  border-left: 1px solid var(--color-border);
  overflow: hidden;
}

.sg-detail-panel__resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
}

.sg-detail-panel__resize-handle:hover,
.sg-detail-panel__resize-handle--active {
  background-color: var(--color-primary);
}

.sg-detail-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 12px;
}

.sg-detail-panel__title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sg-detail-panel__close {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sg-detail-panel__close:hover {
  background: var(--color-sidebar-hover);
}

.sg-detail-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sg-detail-panel__image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin-bottom: 16px;
}

.sg-detail-panel__image--placeholder {
  background-color: var(--color-bg-tertiary);
}

.sg-detail-panel__service {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.sg-detail-panel__service--spotify {
  color: #1db954;
}

.sg-detail-panel__service--apple_music {
  color: #fc3c44;
}

.sg-detail-panel__service--soundcloud {
  color: #ff5500;
}

.sg-detail-panel__name {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.3;
}

.sg-detail-panel__meta {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.sg-detail-panel__description {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0 0 16px;
}

.sg-detail-panel__external-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
}

.sg-detail-panel__external-link:hover {
  text-decoration: underline;
}

/* Selection toggle */
.sg-detail-panel__selection-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-text-secondary);
}

.sg-detail-panel__selection-toggle--selected {
  color: var(--color-success);
}

.sg-detail-panel__selection-toggle svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Tracks section */
.sg-detail-panel__tracks-section {
  margin-top: 12px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.sg-detail-panel__tracks-heading {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
}

.sg-detail-panel__track {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border);
}

.sg-detail-panel__track:hover {
  background-color: var(--color-sidebar-hover);
}

.sg-detail-panel__track:last-child {
  border-bottom: none;
}

.sg-detail-panel__track-num {
  font-size: 12px;
  color: var(--color-text-secondary);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.sg-detail-panel__track-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sg-detail-panel__track-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sg-detail-panel__track-artist {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sg-detail-panel__track-duration {
  font-size: 12px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.sg-detail-panel__tracks-empty,
.sg-detail-panel__tracks-error {
  font-size: 13px;
  color: var(--color-text-secondary);
  padding: 8px 0;
}

.sg-detail-panel__tracks-error {
  color: var(--color-error, #e53e3e);
}

/* Loader */
.sg-detail-panel__loader {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.sg-detail-panel__loader-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-text-secondary);
  animation: sg-detail-panel-pulse 1.4s ease-in-out infinite;
}

.sg-detail-panel__loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.sg-detail-panel__loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes sg-detail-panel-pulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Cover Art Section */
.sg-detail-panel__coverart {
  margin-bottom: 16px;
}


.sg-detail-panel__coverart-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sg-detail-panel__coverart-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.sg-detail-panel__coverart-swatches {
  display: flex;
  gap: 8px;
  padding: 0 2px;
}

.sg-detail-panel__coverart-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s;
}

.sg-detail-panel__coverart-swatch--active {
  border-color: var(--color-text);
}

.sg-detail-panel__coverart-swatch:hover:not(.sg-detail-panel__coverart-swatch--active) {
  border-color: var(--color-text-secondary);
}

.sg-detail-panel__coverart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.sg-detail-panel__coverart-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: sg-detail-panel-spin 0.8s linear infinite;
}

@keyframes sg-detail-panel-spin {
  to { transform: rotate(360deg); }
}

.sg-detail-panel__coverart-error {
  font-size: 12px;
  color: var(--color-error);
  text-align: center;
  padding: 4px 0;
}

/* Editable title (in header) */
.sg-detail-panel__title[data-editable-title] {
  cursor: pointer;
}

.sg-detail-panel__title:has(.sg-detail-panel__title-input) {
  overflow: visible;
  white-space: normal;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sg-detail-panel__title-input {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  padding: 2px 6px;
  font-family: inherit;
  box-sizing: border-box;
}

.sg-detail-panel__title-save {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Editable description */
.sg-detail-panel__hero-info .sg-detail-panel__description {
  margin-bottom: 0;
  cursor: pointer;
}

.sg-detail-panel__description-refresh {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: inline;
  vertical-align: middle;
}

.sg-detail-panel__description-refresh:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-sidebar-hover);
}

.sg-detail-panel__description-refresh:disabled {
  opacity: 0.4;
  cursor: default;
}

.sg-detail-panel__description-input {
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  padding: 4px 6px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  min-height: 140px;
}

.sg-detail-panel__description-save {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  vertical-align: top;
  margin-left: 4px;
}

/* Hero layout (SoundCloud playlist) */
.sg-detail-panel__hero {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.sg-detail-panel__hero-art {
  flex-shrink: 0;
  width: 140px;
}

.sg-detail-panel__hero-info {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}


/* Coverart overrides inside hero-art */
.sg-detail-panel__hero-art .sg-detail-panel__coverart {
  margin-bottom: 0;
}

.sg-detail-panel__hero-art .sg-detail-panel__coverart-canvas {
  margin-bottom: 4px;
}

.sg-detail-panel__hero-art .sg-detail-panel__coverart-swatches {
  gap: 4px;
}

.sg-detail-panel__hero-art .sg-detail-panel__coverart-swatch {
  width: 20px;
  height: 20px;
}

/* Coverart hover overlay */
.sg-detail-panel__coverart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 8px;
}

.sg-detail-panel__coverart-canvas:hover .sg-detail-panel__coverart-overlay {
  opacity: 1;
}

.sg-detail-panel__coverart-overlay button {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sg-detail-panel__coverart-overlay button:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Track count next to heading */
.sg-detail-panel__tracks-count {
  font-weight: 400;
  color: var(--color-text-secondary);
}

/* Footer (sticky publish section) */
.sg-detail-panel__footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
}

.sg-detail-panel__footer .sg-detail-panel__publish {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

@media (max-width: 768px) {
  sg-detail-panel {
    position: fixed;
    top: 49px;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100%;
    min-height: 0;
    height: auto;
    z-index: 100;
  }

  .sg-detail-panel__resize-handle {
    display: none;
  }
}

/* Publish section */
.sg-detail-panel__publish {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.sg-detail-panel__publish-heading {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--color-text);
}

.sg-detail-panel__publish-account {
  margin-bottom: 12px;
}

.sg-detail-panel__publish-label {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.sg-detail-panel__publish-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  font-size: 13px;
  font-family: inherit;
}

.sg-detail-panel__publish-btn {
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(#f70, #f30);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  text-transform: uppercase;
}

.sg-detail-panel__publish-btn:hover:not(:disabled) {
  filter: brightness(0.9);
  color: white;
}

.sg-detail-panel__publish-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.sg-detail-panel__publish-btn--view {
  opacity: 1;
  color: white;
}

.sg-detail-panel__publish-btn--view:hover {
  filter: brightness(0.9);
  color: white;
}

.sg-detail-panel__publish-status {
  margin-top: 8px;
  font-size: 13px;
}

.sg-detail-panel__publish-status--success {
  color: var(--color-success);
}

.sg-detail-panel__publish-status--error {
  color: var(--color-error);
}

.sg-detail-panel__publish-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-success);
  vertical-align: middle;
  margin-right: 4px;
}
