.custom-palette-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.custom-palette-trigger {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
}

.custom-palette-trigger:hover,
.custom-palette-trigger.active {
  border-color: #4e6f9b;
  background: #172335;
  color: #bad4fa;
}

.custom-palette-trigger b {
  min-width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 9px;
  background: #0b0e12;
  color: var(--subtle);
  font-size: 8px;
}

.custom-palette-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #11151a;
  color: var(--text);
  box-shadow: 0 26px 90px #000a;
}

.custom-palette-dialog::backdrop {
  background: #05070acc;
  backdrop-filter: blur(4px);
}

.custom-palette-shell {
  max-height: min(760px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto auto minmax(140px, 1fr) auto;
}

.custom-palette-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.custom-palette-header h2 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -.02em;
}

.custom-palette-header p,
.custom-palette-save p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.custom-palette-close {
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.custom-palette-close:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.custom-palette-save {
  display: grid;
  gap: 8px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--line);
  background: #141920;
}

.custom-palette-save > label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.custom-palette-save > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.custom-palette-save input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0c0f13;
  font-size: 12px;
  font-weight: 700;
}

.custom-palette-list {
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 12px 14px;
  overflow-y: auto;
}

.custom-palette-empty {
  min-height: 150px;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  text-align: center;
}

.custom-palette-empty strong {
  color: var(--text);
  font-size: 12px;
}

.custom-palette-empty span {
  max-width: 360px;
  font-size: 10px;
  line-height: 1.5;
}

.custom-palette-item {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.custom-palette-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.custom-palette-item.active {
  border-color: #41618c;
  box-shadow: inset 3px 0 0 #5e93e6;
  background: #162131;
}

.custom-palette-info {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.custom-palette-info > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.custom-palette-info strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-palette-info small {
  color: var(--muted);
  font-size: 9px;
}

.custom-palette-colors {
  width: 86px;
  height: 34px;
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  overflow: hidden;
  border: 1px solid #ffffff20;
  border-radius: 7px;
  background: #0a0c10;
}

.custom-palette-colors i {
  display: block;
  background: var(--palette-color);
}

.custom-palette-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.custom-palette-action {
  min-height: 29px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.custom-palette-action:hover {
  border-color: var(--line-strong);
  background: #252b34;
  color: var(--text);
}

.custom-palette-action.danger:hover {
  border-color: #7d3f49;
  background: #321b20;
  color: #f4a5b0;
}

.custom-palette-footer {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: 9px;
}

.custom-palette-footer b {
  color: var(--muted);
}

@media (max-width: 680px) {
  .custom-palette-dialog,
  .custom-palette-shell {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .custom-palette-save > div {
    grid-template-columns: 1fr;
  }

  .custom-palette-item {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .custom-palette-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .custom-palette-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}